WIP: Apache NuttX RTOS for RISC-V QEMU (Initial RAM Disk)
Pre-release
Pre-release
Read the article...
See below for the Build Outputs. We built NuttX with these steps...
## Install the Build Prerequisites and Toolchain:
## https://lupyuen.github.io/articles/nuttx#install-prerequisites
## https://lupyuen.github.io/articles/riscv#appendix-download-toolchain-for-64-bit-risc-v
## Download the `ramdisk` branch of our WIP NuttX Repos
mkdir nuttx
cd nuttx
git clone --branch ramdisk https://github.com/lupyuen2/wip-pinephone-nuttx nuttx
git clone --branch ramdisk https://github.com/lupyuen2/wip-pinephone-nuttx-apps apps
## Configure and build NuttX
cd nuttx
tools/configure.sh rv-virt:knsh64
make
## Build Apps Filesystem
make export V=1
pushd ../apps
./tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz
make import V=1
popd
## Generate Initial RAM Disk
genromfs -f initrd -d ../apps/bin -V "NuttXBootVol"
## We assume that `nuttx` contains the NuttX ELF Image.
## Export the NuttX Binary Image to `nuttx.bin`
riscv64-unknown-elf-objcopy \
-O binary \
nuttx \
nuttx.bin
## Dump the disassembly to nuttx.S
riscv64-unknown-elf-objdump \
-t -S --demangle --line-numbers --wide \
nuttx \
>nuttx.S \
2>&1
## Dump the init disassembly to init.S
riscv64-unknown-elf-objdump \
-t -S --demangle --line-numbers --wide \
../apps/bin/init \
>init.S \
2>&1
## Copy the config to nuttx.config
cp .config nuttx.config
## Start QEMU with Initial RAM Disk
qemu-system-riscv64 \
-semihosting \
-M virt,aclint=on \
-cpu rv64 \
-smp 8 \
-bios none \
-kernel nuttx \
-initrd initrd \
-nographic
Here's the QEMU Output Log...
→ qemu-system-riscv64 \
-semihosting \
-M virt,aclint=on \
-cpu rv64 \
-smp 8 \
-bios none \
-kernel nuttx \
-initrd initrd \
-nographic \
ABCnx_start: Entry
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS0
work_start_lowpri: Starting low-priority kernel worker thread(s)
board_late_initialize:
nx_start_application: Starting init task: /system/bin/init
elf_symname: Symbol has no name
elf_symvalue: SHN_UNDEF: Failed to get symbol name: -3
elf_relocateadd: Section 2 reloc 2: Undefined symbol[0] has no name: -3
up_exit: TCB=0x802088d0 exiting
NuttShell (NSH) NuttX-12.0.3
nsh> nx_start: CPU0: Beginning Idle Loop
nsh> ls -l /system/bin/init
posix_spawn: pid=0xc0202978 path=ls file_actions=0xc0202980 attr=0xc0202988 argv=0xc0202a28
exec_spawn: ERROR: Failed to load program 'ls': -2
nxposix_spawn_exec: ERROR: exec failed: 2
-r-xr-xr-x 3278720 /system/bin/init
nsh>