Skip to content

Commit

Permalink
riscv: Allow disabling of BUILTIN_DTB for XIP
Browse files Browse the repository at this point in the history
This enables, among other things, testing with the QEMU virt machine.

To build an XIP kernel for the QEMU virt machine, configure the
the kernel as desired and apply the following configuration
```
CONFIG_NONPORTABLE=y
CONFIG_XIP_KERNEL=y
CONFIG_XIP_PHYS_ADDR=0x20000000
CONFIG_PHYS_RAM_BASE=0x80200000
CONFIG_BUILTIN_DTB=n
```

Since the QEMU virt flash memory expects a 32 MB file, the built image
must be padded. For example, with
`truncate -s 32M arch/riscv/boot/xipImage`

The kernel can be started using the following command in QEMU (v8+)
```
qemu-system-riscv64 -M virt,pflash0=pflash0 \
 -blockdev node-name=pflash0,driver=file,read-only=on,\
filename=arch/riscv/boot/xipImage <optional parameters>
```

Signed-off-by: Frederik Haxel <haxel@fzi.de>
Link: https://lore.kernel.org/r/20231212130116.848530-4-haxel@fzi.de
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
  • Loading branch information
Frederik Haxel authored and Palmer Dabbelt committed Jan 10, 2024
1 parent 5daa372 commit 6c4a2f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -904,13 +904,13 @@ config RISCV_ISA_FALLBACK
on the replacement properties, "riscv,isa-base" and
"riscv,isa-extensions".

endmenu # "Boot options"

config BUILTIN_DTB
bool
bool "Built-in device tree"
depends on OF && NONPORTABLE
default y if XIP_KERNEL

endmenu # "Boot options"

config PORTABLE
bool
default !NONPORTABLE
Expand Down
4 changes: 3 additions & 1 deletion arch/riscv/kernel/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,12 @@ SYM_CODE_START(_start_kernel)
la sp, _end + THREAD_SIZE
XIP_FIXUP_OFFSET sp
mv s0, a0
mv s1, a1
call __copy_data

/* Restore a0 copy */
/* Restore a0 & a1 copy */
mv a0, s0
mv a1, s1
#endif

#ifndef CONFIG_XIP_KERNEL
Expand Down

0 comments on commit 6c4a2f6

Please sign in to comment.