Skip to content

Releases: lupyuen2/wip-nuttx

Apache NuttX RTOS for Pine64 Ox64 BL808 RISC-V SBC

16 Dec 03:35
Compare
Choose a tag to compare

Official release of Ox64 BL808 Binaries from 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 NuttX Source Code
git clone \
  https://github.com/apache/nuttx \
  nuttx
git clone \
  https://github.com/apache/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

Apache NuttX RTOS for Pine64 Ox64 BL808 RISC-V SBC

13 Dec 00:49
Compare
Choose a tag to compare

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

Apache NuttX RTOS for Pine64 Ox64 BL808 RISC-V SBC

08 Dec 01:00
Compare
Choose a tag to compare

Console Input and NuttX Commands are working OK yay!

See the NuttX 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/jh7110/star64/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 ox64c \
  https://github.com/lupyuen2/wip-pinephone-nuttx \
  nuttx
git clone \
  --branch ox64c \
  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

## TODO: Configure build
## tools/configure.sh star64: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

## Insert 64 KB of zeroes after Binary Image for Kernel Stack
head -c 65536 /dev/zero >/tmp/nuttx.zero

## Append Initial RAM Disk to Binary Image
cat nuttx.bin /tmp/nuttx.zero 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

Apache NuttX RTOS for Pine64 Ox64 BL808 RISC-V SBC

01 Dec 06:20
Compare
Choose a tag to compare

UART Interrupt works OK but UART Input is null.

See the NuttX 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/jh7110/star64/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 ox64b \
  https://github.com/lupyuen2/wip-pinephone-nuttx \
  nuttx
git clone \
  --branch ox64b \
  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

## TODO: Configure build
## tools/configure.sh star64: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

## Insert 64 KB of zeroes after Binary Image for Kernel Stack
head -c 65536 /dev/zero >/tmp/nuttx.zero

## Append Initial RAM Disk to Binary Image
cat nuttx.bin /tmp/nuttx.zero 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

Apache NuttX RTOS for Pine64 Ox64 BL808 RISC-V SBC

18 Nov 04:32
Compare
Choose a tag to compare

Read the article...

Console Input and Interrupts not working yet.

See the NuttX Log

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/jh7110/star64/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 ox64a \
  https://github.com/lupyuen2/wip-pinephone-nuttx \
  nuttx
git clone \
  --branch ox64a \
  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

## TODO: Configure build
## tools/configure.sh star64: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

## Insert 64 KB of zeroes after Binary Image for Kernel Stack
head -c 65536 /dev/zero >/tmp/nuttx.zero

## Append Initial RAM Disk to Binary Image
cat nuttx.bin /tmp/nuttx.zero 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
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

Apache NuttX RTOS for Pine64 Star64 JH7110 RISC-V SBC

07 Aug 08:30
Compare
Choose a tag to compare

Read the articles...

Build Script

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

set -e  #  Exit when any command fails
set -x  #  Echo commands

git clone --branch 860571471da095948fa0c39ce8ac6593a1efbad7 https://github.com/apache/nuttx
git clone --branch ee71af840f543b067c72077ec7fe74c2c7153998 https://github.com/apache/nuttx-apps apps
cd nuttx

## Download the microSD Image sdcard.img
## - https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v3.1.5/sdcard.img
## Write the downloaded image to a microSD Card with Balena Etcher or GNOME Disks.
## Check that microSD has been inserted.
if [ ! -d "/Volumes/NO NAME" ] 
then
  echo "Insert microSD"
  exit 0
fi

## Clean up the NuttX Project
make distclean || true

## Show the version of GCC
riscv64-unknown-elf-gcc -v

## Configure and Build NuttX
rm -f nuttx.bin
tools/configure.sh star64:nsh
make
riscv64-unknown-elf-objcopy -O binary nuttx nuttx.bin
ls -l nuttx.bin

## Build Apps Filesystem as Initial RAM Disk
rm -f initrd
make export
pushd ../apps
tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz
make import
popd
genromfs -f initrd -d ../apps/bin -V "NuttXBootVol"
ls -l initrd

## Generate FIT Image
rm -f nuttx.its jh7110-visionfive-v2.dtb starfiveu.fit
wget https://raw.githubusercontent.com/lupyuen/nuttx-star64/main/nuttx.its
wget https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v3.1.5/jh7110-visionfive-v2.dtb
mkimage -f nuttx.its -A riscv -O linux -T flat_dt starfiveu.fit
ls -l starfiveu.fit

## Copy to microSD
cp starfiveu.fit "/Volumes/NO NAME"
ls -l "/Volumes/NO NAME/starfiveu.fit"

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

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

## Copy the config
cp .config nuttx.config

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

## Boot Star64 with the microSD Card

(See the Build Log)

Output Log

Script started on Mon Aug  7 16:27:21 2023
command: screen /dev/tty.usbserial-1420 115200
�[?1049h�[!p�[?3;4l�[4l�>�[4l�[?1h�=�[0m�(B�[1;61r�[H�[2J�[H�[2J
U-Boot SPL 2021.10 (Jan 19 2023 - 04:09:41 +0800)
DDR version: dc2e84f0.
Trying to boot from SPI

OpenSBI v1.2
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : StarFive VisionFive V2
Platform Features         : medeleg
Platform HART Count       : 5
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 4000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : jh7110-hsm
Platform PMU Device       : ---
Platform Reboot Device    : pm-reset
Platform Shutdown Device  : pm-reset
Firmware Base             : 0x40000000
Firmware Size             : 288 KB
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 1
Domain0 HARTs             : 0*,1*,2*,3*,4*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000040000000-0x000000004007ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000040200000
Domain0 Next Arg1         : 0x0000000042200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 1
Boot HART Domain          : root
Boot HART Priv Version    : v1.11
Boot HART Base ISA        : rv64imafdcbx
Boot HART ISA Extensions  : none
Boot HART PMP Count       : 8
Boot HART PMP Granularity : 4096
Boot HART PMP Address Bits: 34
Boot HART MHPM Count      : 2
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109


U-Boot 2021.10 (Jan 19 2023 - 04:09:41 +0800), Build: jenkins-github_visionfive2-6

CPU:   rv64imacu
Model: StarFive VisionFive V2
DRAM:  8 GiB
MMC:   sdio0@16010000: 0, sdio1@16020000: 1
Loading Environment from SPIFlash... SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
StarFive EEPROM format v2

--------EEPROM INFO--------
Vendor : PINE64
Product full SN: STAR64V1-2310-D008E000-00000003
data version: 0x2
PCB revision: 0xc1
BOM revision: A
Ethernet MAC0 address: 6c:cf:39:00:75:5d
Ethernet MAC1 address: 6c:cf:39:00:75:5e
--------EEPROM INFO--------

In:    serial@10000000
Out:   serial@10000000
Err:   serial@10000000
Model: StarFive VisionFive V2
Net:   eth0: ethernet@16030000, eth1: ethernet@16040000
switch to partitions #0, OK
mmc1 is current device
found device 1
bootmode flash device 1
Failed to load 'uEnv.txt'
Can't set block device
Hit any key to stop autoboot:  2 ��� 1 ��� 0 
1579 bytes read in 5 ms (307.6 KiB/s)
Importing environment from mmc1 ...
Can't set block device
## Warning: defaulting to text format
switch to partitions #0, OK
mmc1 is current device
10232366 bytes read in 438 ms (22.3 MiB/s)
## Loading kernel from FIT Image at a0000000 ...
   Using 'nuttx' configuration
   Trying 'vmlinux' kernel subimage
     Description:  vmlinux
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0xa00000b4
     Data Size:    2097800 Bytes = 2 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x40200000
     Entry Point:  0x40200000
   Verifying Hash Integrity ... OK
## Loading fdt from FIT Image at a0000000 ...
   Using 'nuttx' configuration
   Trying 'fdt' fdt subimage
     Description:  unavailable
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0xa09b58bc
     Data Size:    50235 Bytes = 49.1 KiB
     Architecture: RISC-V
     Load Address: 0x46000000
     Hash algo:    sha256
     Hash value:   42767c996f0544f513280805b41f996446df8b3956c656bdbb782125ae8ffeec
   Verifying Hash Integrity ... sha256+ OK
   Loading fdt from 0xa09b58bc to 0x46000000
   Booting using the fdt blob at 0x46000000
## Loading loadables from FIT Image at a0000000 ...
   Trying 'ramdisk' loadables subimage
     Description:  buildroot initramfs
     Type:         RAMDisk Image
     Compression:  uncompressed
     Data Start:   0xa02003f0
     Data Size:    8082432 Bytes = 7.7 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x46100000
     Entry Point:  unavailable
     Hash algo:    sha256
     Hash value:   41cdaae1d74fbf5f03e1a9c52ca91a13b14efc3de12f6ad690cf7b45474703a7
   Verifying Hash Integrity ... sha256+ OK
   Loading loadables from 0xa02003f0 to 0x46100000
   Loading Kernel Image
## Error: "cpu_vol_set" not defined
Booting kernel in
## Flattened Device Tree blob at 46000000
   Booting using the fdt blob at 0x46000000
   Using Device Tree in place at 0000000046000000, end 000000004600ffff

Starting kernel ...

clk u5_dw_i2c_clk_core already disabled
clk u5_dw_i2c_clk_apb already disabled
BC
NuttShell (NSH) NuttX-12.2.1-RC0
nsh> 
nsh> uname -a
NuttX 12.2.1-RC0 8605714 Aug  7 2023 16:20:45 risc-v star64
nsh> 
nsh> free
                   total       used       free    largest  nused  nfree
        Kmem:    2065400      14600    2050800    2049440     50      3
        Page:   20971520     643072   20328448   20328448
nsh> 
nsh> ls -l
/:
 dr--r--r--       0 dev/
 dr--r--r--       0 proc/
 dr--r--r--       0 system/
nsh> 
nsh> help
help usage:  help [-v] [<cmd>]

    .         break     dd        exit      kill      printf    sleep     uname     
    [         cat       df        false     ls        ps        source    umount    
    ?         cd        dmesg     fdinfo    mkdir     pwd       test      unset     
    alias     cp        echo      free      mkrd      rm        time      uptime    
    unalias   cmp       env       help      mount     rmdir     true      usleep    
    basename  dirname   exec      hexdump   mv        set       truncate  xd        
nsh> 
nsh> ls -l /dev
/dev:
 crw-rw-rw-       0 console
 crw-rw-rw-       0 null
 brw-rw-rw-16777216 ram0
 crw-rw-rw-       0 ttyS0
 crw-rw-rw-       0 zero
nsh> 
nsh> ls -l /system
/system:
 dr-xr-xr-x       0 bin/
nsh> 
nsh> ls -l /system/bin
/system/bin:
 -r-xr-xr-x  895184 getprime
 -r-xr-xr-x  512432 hello
 -r-xr-xr-x 3346072 init
 -r-xr-xr-x 3327736 sh
nsh> 
nsh> ls -l /system/bin/hello
 -r-xr-xr-x  512432 /system/bin/hello
nsh> 
nsh> hello
Hello, World!!
nsh> 
nsh> getprime
Set thread priority to 10
Set thread policy to SCHED_RR
Start thread #0
thread #0 started, looking for primes < 10000, doing 10 run(s)
thread #0 finished, found 1230 primes, last one was 9973
Done
getprime took 0 msec
nsh> 
nsh> 
Script done on Mon Aug  7 16:28:20 2023

Apache NuttX RTOS for Pine64 Star64 JH7110 RISC-V SBC

05 Aug 04:56
Compare
Choose a tag to compare

Build Script:

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

set -e  #  Exit when any command fails
set -x  #  Echo commands

## Download the microSD Image sdcard.img
## - https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v3.1.5/sdcard.img
## Write the downloaded image to a microSD Card with Balena Etcher or GNOME Disks.
## Check that microSD has been inserted.
if [ ! -d "/Volumes/NO NAME" ] 
then
  echo "Insert microSD"
  exit 0
fi

## Clean up the NuttX Project
make distclean || true

## Show the version of GCC
riscv64-unknown-elf-gcc -v

## Configure and Build NuttX
rm -f nuttx.bin
tools/configure.sh star64:nsh
make
riscv64-unknown-elf-objcopy -O binary nuttx nuttx.bin
ls -l nuttx.bin

## Build Apps Filesystem as Initial RAM Disk
rm -f initrd
make export
pushd ../apps
tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz
make import
popd
genromfs -f initrd -d ../apps/bin -V "NuttXBootVol"
ls -l initrd

## Generate FIT Image
rm -f nuttx.its jh7110-visionfive-v2.dtb starfiveu.fit
wget https://raw.githubusercontent.com/lupyuen/nuttx-star64/main/nuttx.its
wget https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v3.1.5/jh7110-visionfive-v2.dtb
mkimage -f nuttx.its -A riscv -O linux -T flat_dt starfiveu.fit
ls -l starfiveu.fit

## Copy to microSD
cp starfiveu.fit "/Volumes/NO NAME"
ls -l "/Volumes/NO NAME/starfiveu.fit"

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

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

## Copy the config
cp .config nuttx.config

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

## Boot Star64 with the microSD Card

(See the Build Log)

Output Log:

U-Boot SPL 2021.10 (Jan 19 2023 - 04:09:41 +0800)
DDR version: dc2e84f0.
Trying to boot from SPI

OpenSBI v1.2
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : StarFive VisionFive V2
Platform Features         : medeleg
Platform HART Count       : 5
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 4000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : jh7110-hsm
Platform PMU Device       : ---
Platform Reboot Device    : pm-reset
Platform Shutdown Device  : pm-reset
Firmware Base             : 0x40000000
Firmware Size             : 288 KB
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 1
Domain0 HARTs             : 0*,1*,2*,3*,4*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000040000000-0x000000004007ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000040200000
Domain0 Next Arg1         : 0x0000000042200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 1
Boot HART Domain          : root
Boot HART Priv Version    : v1.11
Boot HART Base ISA        : rv64imafdcbx
Boot HART ISA Extensions  : none
Boot HART PMP Count       : 8
Boot HART PMP Granularity : 4096
Boot HART PMP Address Bits: 34
Boot HART MHPM Count      : 2
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109


U-Boot 2021.10 (Jan 19 2023 - 04:09:41 +0800), Build: jenkins-github_visionfive2-6

CPU:   rv64imacu
Model: StarFive VisionFive V2
DRAM:  8 GiB
MMC:   sdio0@16010000: 0, sdio1@16020000: 1
Loading Environment from SPIFlash... SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
StarFive EEPROM format v2

--------EEPROM INFO--------
Vendor : PINE64
Product full SN: STAR64V1-2310-D008E000-00000003
data version: 0x2
PCB revision: 0xc1
BOM revision: A
Ethernet MAC0 address: 6c:cf:39:00:75:5d
Ethernet MAC1 address: 6c:cf:39:00:75:5e
--------EEPROM INFO--------

In:    serial@10000000
Out:   serial@10000000
Err:   serial@10000000
Model: StarFive VisionFive V2
Net:   eth0: ethernet@16030000, eth1: ethernet@16040000
switch to partitions #0, OK
mmc1 is current device
found device 1
bootmode flash device 1
Failed to load 'uEnv.txt'
Can't set block device
Hit any key to stop autoboot:  0 
1579 bytes read in 4 ms (384.8 KiB/s)
Importing environment from mmc1 ...
Can't set block device
## Warning: defaulting to text format
switch to partitions #0, OK
mmc1 is current device
10232366 bytes read in 436 ms (22.4 MiB/s)
## Loading kernel from FIT Image at a0000000 ...
   Using 'nuttx' configuration
   Trying 'vmlinux' kernel subimage
     Description:  vmlinux
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0xa00000b4
     Data Size:    2097800 Bytes = 2 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x40200000
     Entry Point:  0x40200000
   Verifying Hash Integrity ... OK
## Loading fdt from FIT Image at a0000000 ...
   Using 'nuttx' configuration
   Trying 'fdt' fdt subimage
     Description:  unavailable
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0xa09b58bc
     Data Size:    50235 Bytes = 49.1 KiB
     Architecture: RISC-V
     Load Address: 0x46000000
     Hash algo:    sha256
     Hash value:   42767c996f0544f513280805b41f996446df8b3956c656bdbb782125ae8ffeec
   Verifying Hash Integrity ... sha256+ OK
   Loading fdt from 0xa09b58bc to 0x46000000
   Booting using the fdt blob at 0x46000000
## Loading loadables from FIT Image at a0000000 ...
   Trying 'ramdisk' loadables subimage
     Description:  buildroot initramfs
     Type:         RAMDisk Image
     Compression:  uncompressed
     Data Start:   0xa02003f0
     Data Size:    8082432 Bytes = 7.7 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x46100000
     Entry Point:  unavailable
     Hash algo:    sha256
     Hash value:   05e61cf645e01893f6ac03ae0d098cb0f3dc0d75bed494945ebb6633092cdd68
   Verifying Hash Integrity ... sha256+ OK
   Loading loadables from 0xa02003f0 to 0x46100000
   Loading Kernel Image
## Error: "cpu_vol_set" not defined
Booting kernel in
## Flattened Device Tree blob at 46000000
   Booting using the fdt blob at 0x46000000
   Using Device Tree in place at 0000000046000000, end 000000004600ffff

Starting kernel ...

clk u5_dw_i2c_clk_core already disabled
clk u5_dw_i2c_clk_apb already disabled
BC
NuttShell (NSH) NuttX-12.2.1-RC0
nsh> 
nsh> 
nsh> uname -a
NuttX 12.2.1-RC0 57d5bba-dirty Aug  5 2023 12:30:55 risc-v star64
nsh> 
nsh> free
                   total       used       free    largest  nused  nfree
        Kmem:    2065400      14600    2050800    2049440     50      3
        Page:   20971520     643072   20328448   20328448
nsh> 
nsh> ls -l
/:
 dr--r--r--       0 dev/
 dr--r--r--       0 proc/
 dr--r--r--       0 system/
nsh> 
nsh> ls -l /dev
/dev:
 crw-rw-rw-       0 console
 crw-rw-rw-       0 null
 brw-rw-rw-16777216 ram0
 crw-rw-rw-       0 ttyS0
 crw-rw-rw-       0 zero
nsh> 
nsh> 
nsh> 
nsh> ls -l /system
/system:
 dr-xr-xr-x       0 bin/
nsh> 
nsh> ls -l /system/bin
/system/bin:
 -r-xr-xr-x  895184 getprime
 -r-xr-xr-x  512432 hello
 -r-xr-xr-x 3346040 init
 -r-xr-xr-x 3327696 sh
nsh> 
nsh> ls -l /system/bin/init
 -r-xr-xr-x 3346040 /system/bin/init
nsh> 
nsh> hello
Hello, World!!
nsh> 
nsh> 

WIP: Apache NuttX RTOS for Pine64 Star64 JH7110 RISC-V SBC (Fixed PLIC)

01 Aug 08:38
Compare
Choose a tag to compare

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 `star64d` branch of our WIP NuttX Repos
mkdir nuttx
cd nuttx
git clone --branch star64d https://github.com/lupyuen2/wip-pinephone-nuttx nuttx
git clone --branch star64d 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

## Copy NuttX Binary Image, Device Tree and
## Initial RAM Disk to TFTP Folder
cp nuttx.bin $HOME/tftproot/Image
cp jh7110-star64-pine64.dtb $HOME/tftproot
cp initrd $HOME/tftproot

## Boot NuttX over TFTP:
## https://lupyuen.github.io/articles/semihost#appendix-boot-nuttx-over-tftp-with-initial-ram-disk

Here's the Star64 Output Log...

123067BCnx_start: Entry
up_irq_enable: 
up_enable_irq: irq=17
up_enable_irq: RISCV_IRQ_SOFT=17
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
nx_start_application: ret=3
up_exit: TCB=0x404088d0 exiting
up_enable_irq: irq=57
up_enable_irq: extirq=32, RISCV_IRQ_EXT=25
..***main

NuttShell (NSH) NuttX-12.0.3
nsh> ......++.+.l......s......
................................................p.o.s.i.x._.s.p.a.w.n..:. .p.i.d.=...0.x.c.0.2.0.2.9.7.8. .p.a.t.h.=..l.s. .f.i.l.e._.a.c.t.i.o.n.s.=...0.x.c.0.2.0.2.9.8.0. .a.t.t.r.=...0.x.c.0.2.0.2.9.8.8. .a.r.g.v.=...0.x.c.0.2.0.2.a.2.8.
.........................................................e.x.e.c._.s.p.a.w.n.:. .E.R.R.O..R.:. .F.a.i.l.e.d. .t.o. .l.o.a.d. .p.r.o.g.r.a.m. .'..l.s.'.:. ..-.2.
.......n.x.p.o.s.i.x._.s.p.a.w.n._.e.x.e.c.:. .E.R.R.O.R.:. .e.x.e.c. .f.a.i.l.e.d.:. ..2.
............................................................................................................../:
............................................................... dev......../
.............. proc......../
............... system........./
.............................................................nsh> ...................n.x._.s.t.a.r.t.:. .C.P.U.0.:. .B.e.g.i.n.n.i.n.g. .I.d.l.e. .L.o.o.p.
..........................

WIP: Apache NuttX RTOS for RISC-V QEMU (Log Serial I/O)

01 Aug 10:25
Compare
Choose a tag to compare

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 `ramdisk2` branch of our WIP NuttX Repos
mkdir nuttx
cd nuttx
git clone --branch ramdisk2 https://github.com/lupyuen2/wip-pinephone-nuttx nuttx
git clone --branch ramdisk2 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=off \
    -cpu rv64 \
    -smp 8 \
    -bios none \
    -kernel nuttx \
    -initrd initrd \
    -nographic \

ABCnx_start: Entry
up_irq_enable: 
up_enable_irq: irq=17
up_enable_irq: RISCV_IRQ_SOFT=17
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS0
up_enable_irq: irq=35
up_enable_irq: extirq=10, RISCV_IRQ_EXT=25
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
$%&riscv_doirq: irq=8
$%&riscv_doirq: irq=8
$%&riscv_doirq: irq=8
...
$%&riscv_doirq: irq=8
$%&riscv_doirq: irq=8
$%&riscv_doirq: irq=8
uart_write (0xc0200428):
0000  2a 2a 2a 6d 61 69 6e 0a                          ***main.        
FAAAAAAAADEF*F*F*FmFaFiFnF
$%&riscv_doirq: irq=8
$%&riscv_doirq: irq=8
$%&riscv_doirq: irq=8
...
$%&riscv_doirq: irq=8
$%&riscv_doirq: irq=8
$%&riscv_doirq: irq=8
uart_write (0xc000a610):
0000  0a 4e 75 74 74 53 68 65 6c 6c 20 28 4e 53 48 29  .NuttShell (NSH)
0010  20 4e 75 74 74 58 2d 31 32 2e 30 2e 33 0a         NuttX-12.0.3.  
FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADEF
FNFuFtFtFSFhFeFlFlF F(FNFSFHF)F FNFuFtFtFXF-F1F2F.F0F.F3F
$%&riscv_doirq: irq=8
uart_write (0xc0015340):
0000  6e 73 68 3e 20                                   nsh>            
AAAAADEFnFsFhF>F $%&riscv_doirq: irq=8
uart_write (0xc0015318):
0000  1b 5b 4b                                         .[K             
AAADEF[FK$%&riscv_doirq: irq=8
nx_start: CPU0: Beginning Idle Loop
$%^&riscv_doirq: irq=35
#*ADEFa$%&riscv_doirq: irq=8
$%^&riscv_doirq: irq=35
#*ADEFa$%&riscv_doirq: irq=8
$%^&riscv_doirq: irq=35
#*ADEFa$%&riscv_doirq: irq=8

WIP: Apache NuttX RTOS for RISC-V QEMU (Initial RAM Disk)

26 Jul 23:08
Compare
Choose a tag to compare

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

(See the Build Log)

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>

(See the Detailed Run Log)