Skip to content

Apache NuttX RTOS for Pine64 Ox64 BL808 RISC-V SBC

Compare
Choose a tag to compare
@lupyuen lupyuen released this 13 Dec 00:49
· 2 commits to bl808c since this release

Ready to upstream Ox64 BL808 to NuttX Mainline. See apache#11377

See the NuttX Log

See the Build Log

Watch the Demo on YouTube

Build Script:

#!/usr/bin/env bash
#  Build NuttX for Ox64

## TODO: Set PATH
export PATH="$HOME/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/bin:$PATH"

rm init.S
rm initrd
rm -r boards/risc-v/bl808/ox64/src/etctmp

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
}

## Build Apps Filesystem
function build_apps {

  ## Go to NuttX Folder
  pushd ../nuttx

  ## Build Apps Filesystem
  make -j 8 export
  pushd ../apps
  ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz
  make -j 8 import
  popd

  ## Return to previous folder
  popd
}

## Download the WIP NuttX Source Code
git clone \
  --branch bl808c \
  https://github.com/lupyuen2/wip-pinephone-nuttx \
  nuttx
git clone \
  --branch bl808c \
  https://github.com/lupyuen2/wip-pinephone-nuttx-apps \
  apps
cd nuttx

## 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 version of GCC
riscv64-unknown-elf-gcc -v

## Configure build
tools/configure.sh ox64:nsh

## Build NuttX
build_nuttx

## Build Apps Filesystem
build_apps

## Generate Initial RAM Disk
genromfs -f initrd -d ../apps/bin -V "NuttXBootVol"

## Show the size
riscv64-unknown-elf-size nuttx

## Export the Binary Image to `nuttx.bin`
riscv64-unknown-elf-objcopy \
  -O binary \
  nuttx \
  nuttx.bin

## Prepare a Padding with 64 KB of zeroes
head -c 65536 /dev/zero >/tmp/nuttx.pad

## Append Padding and Initial RAM Disk to NuttX Kernel
cat nuttx.bin /tmp/nuttx.pad initrd \
  >Image

## 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

## Dump the init disassembly to init.S
riscv64-unknown-elf-objdump \
  --syms --source --reloc --demangle --line-numbers --wide \
  --debugging \
  ../apps/bin/init \
  >init.S \
  2>&1

## Dump the hello disassembly to hello.S
riscv64-unknown-elf-objdump \
  --syms --source --reloc --demangle --line-numbers --wide \
  --debugging \
  ../apps/bin/hello \
  >hello.S \
  2>&1

echo ----- Wait for microSD
set +x  #  Don't echo commands
echo "***** Insert microSD into computer"
while : ; do
  if [ -d "/Volumes/NO NAME" ]
  then
    break
  fi
  sleep 1
done
sleep 1
set -x  #  Echo commands

echo ----- Copy to microSD
cp Image "/Volumes/NO NAME/"
ls -l "/Volumes/NO NAME/Image"

## TODO: Verify that /dev/disk2 is microSD
echo ----- Unmount microSD
diskutil unmountDisk /dev/disk2

## Run the firmware
open -a CoolTerm

## Check coding style
../nxstyle arch/risc-v/Kconfig
../nxstyle arch/risc-v/include/bl808/chip.h
../nxstyle arch/risc-v/include/bl808/irq.h
../nxstyle arch/risc-v/src/bl808/Kconfig
../nxstyle arch/risc-v/src/bl808/Make.defs
../nxstyle arch/risc-v/src/bl808/bl808_allocateheap.c
../nxstyle arch/risc-v/src/bl808/bl808_head.S
../nxstyle arch/risc-v/src/bl808/bl808_irq.c
../nxstyle arch/risc-v/src/bl808/bl808_irq_dispatch.c
../nxstyle arch/risc-v/src/bl808/bl808_memorymap.h
../nxstyle arch/risc-v/src/bl808/bl808_mm_init.c
../nxstyle arch/risc-v/src/bl808/bl808_mm_init.h
../nxstyle arch/risc-v/src/bl808/bl808_pgalloc.c
../nxstyle arch/risc-v/src/bl808/bl808_serial.c
../nxstyle arch/risc-v/src/bl808/bl808_serial.h
../nxstyle arch/risc-v/src/bl808/bl808_start.c
../nxstyle arch/risc-v/src/bl808/bl808_timerisr.c
../nxstyle arch/risc-v/src/bl808/chip.h
../nxstyle arch/risc-v/src/bl808/hardware/bl808_memorymap.h
../nxstyle arch/risc-v/src/bl808/hardware/bl808_plic.h
../nxstyle arch/risc-v/src/bl808/hardware/bl808_uart.h

../nxstyle boards/Kconfig
../nxstyle boards/risc-v/bl808/ox64/Kconfig
../nxstyle boards/risc-v/bl808/ox64/configs/nsh/defconfig
../nxstyle boards/risc-v/bl808/ox64/include/board.h
../nxstyle boards/risc-v/bl808/ox64/include/board_memorymap.h
../nxstyle boards/risc-v/bl808/ox64/scripts/Make.defs
../nxstyle boards/risc-v/bl808/ox64/scripts/ld.script
../nxstyle boards/risc-v/bl808/ox64/src/.gitignore
../nxstyle boards/risc-v/bl808/ox64/src/Makefile
../nxstyle boards/risc-v/bl808/ox64/src/bl808_appinit.c
../nxstyle boards/risc-v/bl808/ox64/src/etc/init.d/rc.sysinit
../nxstyle boards/risc-v/bl808/ox64/src/etc/init.d/rcS

../nxstyle Documentation/platforms/risc-v/bl808/boards/ox64/index.rst
../nxstyle Documentation/platforms/risc-v/bl808/index.rst
../nxstyle Documentation/platforms/risc-v/jh7110/boards/star64/index.rst