Read the article...
This is the Full Version of NuttX on TinyEMU: NuttX Shell with Full VirtIO support.
- NuttX Source: https://github.com/apache/nuttx/tree/44aaae22d288b8d436e7ac7d715e31e49ac5939e
- NuttX Apps: https://github.com/apache/nuttx-apps/tree/95cec28ed6ff5c7af7f2f0fd8895699b98b496d4
- Build Log
- NuttX Log
Build Script:
#!/usr/bin/env bash
# Build NuttX for TinyEMU
## TODO: Set PATH
export PATH="$HOME/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/bin:$PATH"
set -e # Exit when any command fails
set -x # Echo commands
## Build NuttX
function build_nuttx {
## Go to NuttX Folder
pushd ../nuttx
## Build NuttX
make -j 8
## Return to previous folder
popd
}
## Download WIP NuttX
git clone --branch tinyemu2 https://github.com/lupyuen2/wip-pinephone-nuttx nuttx
git clone --branch tinyemu2 https://github.com/lupyuen2/wip-pinephone-nuttx-apps apps
## Configure NuttX for QEMU RISC-V (64-bit, Flat Mode)
cd nuttx
tools/configure.sh rv-virt:nsh64
make menuconfig
## Device Drivers > Serial Driver Support
## Disable "16550 UART Chip support"
## Device Drivers
## Enable "Simple AddrEnv"
## Enable "Virtio Device Support"
## Device Drivers > Virtio Device Support
## Enable "Virtio MMIO Device Support"
## Enable "Virtio Serial Support"
## Build Setup > Debug Options >
## Enable Debug Features
## Enable "Debug Assertions > Show Expression, Filename"
## Enable "Binary Loader Debug Features > Errors, Warnings, Info"
## Enable "File System Debug Features > Errors, Warnings, Info"
## Enable "C Library Debug Features > Errors, Warnings, Info"
## Enable "Memory Manager Debug Features > Errors, Warnings, Info"
## Enable "Scheduler Debug Features > Errors, Warnings, Info"
## Enable "Timer Debug Features > Errors, Warnings, Info"
## Enable "IPC Debug Features > Errors, Warnings, Info"
## Enable "Virtio Debug Features > Error, Warnings, Info"
## Application Configuration > Testing >
## Enable "OS Test Example"
## Save and exit menuconfig
## Pull updates
git pull && git status && hash1=`git rev-parse HEAD`
pushd ../apps
git pull && git status && hash2=`git rev-parse HEAD`
popd
echo NuttX Source: https://github.com/apache/nuttx/tree/$hash1 >nuttx.hash
echo NuttX Apps: https://github.com/apache/nuttx-apps/tree/$hash2 >>nuttx.hash
## Show the versions of GCC
riscv64-unknown-elf-gcc -v
## Build NuttX
build_nuttx
## Show the size
riscv64-unknown-elf-size nuttx
## Export the Binary Image to nuttx.bin
riscv64-unknown-elf-objcopy \
-O binary \
nuttx \
nuttx.bin
## Copy the config
cp .config nuttx.config
## Dump the disassembly to nuttx.S
riscv64-unknown-elf-objdump \
--syms --source --reloc --demangle --line-numbers --wide \
--debugging \
nuttx \
>nuttx.S \
2>&1
## Copy to Web Server
wget --output-document=nuttx.cfg https://raw.githubusercontent.com/lupyuen/nuttx-tinyemu/main/docs/root-riscv64.cfg
cp nuttx.cfg ../nuttx-tinyemu/docs/root-riscv64.cfg
cp nuttx.bin ../nuttx-tinyemu/docs/
cp nuttx.S ../nuttx-tinyemu/docs/
cp nuttx.hash ../nuttx-tinyemu/docs/
cp nuttx.config ../nuttx-tinyemu/docs/
## Start Web Server
echo simple-http-server $HOME/riscv/nuttx-tinyemu/docs/ &
echo http://localhost:8080
## Start TinyEMU
temu nuttx.cfg