Skip to content

Apache NuttX RTOS for TinyEMU Emulator (64-bit RISC-V)

Pre-release
Pre-release
Compare
Choose a tag to compare
@lupyuen lupyuen released this 19 Jan 12:06

NuttX Source: https://github.com/apache/nuttx/tree/15cb41bbea5efeda698ef5101eaab7e631c31d66

NuttX Apps: https://github.com/apache/nuttx-apps/tree/f12586c51e0003c03e708b09baaf21348891f370

Inside menuconfig, we selected...

Open Asymmetric Multi Processing

  • Enable "Open Asymmetric Multi Processing support"

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 "File System Debug Features > Errors, Warnings"
  • Enable "C Library Debug Features > Errors, Warnings"
  • Enable "Memory Manager Debug Features > Errors, Warnings"
  • Enable "Timer Debug Features > Errors, Warnings"
  • Enable "Virtio Debug Features > Error, Warnings"
  • Enable "IPC Debug Features > Errors, Warnings"

Application Configuration > Examples > Hello, World Example

  • Change "M" to "*"

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
}

## 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 and Zig
riscv64-unknown-elf-gcc -v

## Configure build
tools/configure.sh rv-virt:nsh64

## 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 $HOME/ox64/nuttx/Image        $HOME/riscv/nuttx-tinyemu/docs/ox64/
cp $HOME/ox64/nuttx/nuttx.bin    $HOME/riscv/nuttx-tinyemu/docs/ox64/
cp $HOME/ox64/nuttx/nuttx.S      $HOME/riscv/nuttx-tinyemu/docs/ox64/
cp $HOME/ox64/nuttx/nuttx.hash   $HOME/riscv/nuttx-tinyemu/docs/ox64/
cp $HOME/ox64/nuttx/nuttx.config $HOME/riscv/nuttx-tinyemu/docs/ox64/
cp $HOME/ox64/nuttx/initrd       $HOME/riscv/nuttx-tinyemu/docs/ox64/
cp $HOME/ox64/nuttx/init.S       $HOME/riscv/nuttx-tinyemu/docs/ox64/
cp $HOME/ox64/nuttx/hello.S      $HOME/riscv/nuttx-tinyemu/docs/ox64/

## Start TinyEMU
temu nuttx.cfg