Releases: lupyuen2/wip-nuttx
Apache NuttX RTOS for Sophgo SG2000 RISC-V SoC (Milk-V Duo S SBC)
See apache#12510
Build Script:
#!/usr/bin/env bash
# Build NuttX for SG2000
## TODO: Set PATH
export PATH="$HOME/xpack-riscv-none-elf-gcc-13.2.0-2/bin:$PATH"
rm init.S
rm initrd
rm -r boards/risc-v/sg2000/milkv_duos/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
}
## 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
riscv-none-elf-gcc -v
## Configure build
tools/configure.sh milkv_duos:nsh || true
## Build NuttX
build_nuttx
## Build Apps Filesystem
build_apps
## Add a.out to Apps Filesystem for TCC
rm -f /tmp/pattern.txt
start=$((0x22056900))
set +x # Don't echo commands
for i in {0..1023}
do
printf 0x%x\\n $(($start + $i)) >> /tmp/pattern.txt
done
set -x # Echo commands
cat /tmp/pattern.txt \
| xxd -revert -plain \
>../apps/bin/a.out
## Generate Initial RAM Disk
genromfs -f initrd -d ../apps/bin -V "NuttXBootVol"
## Show the size
riscv-none-elf-size nuttx
## 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
riscv-none-elf-objdump \
--syms --source --reloc --demangle --line-numbers --wide \
--debugging \
nuttx \
>nuttx.S \
2>&1
## Dump the init disassembly to init.S
riscv-none-elf-objdump \
--syms --source --reloc --demangle --line-numbers --wide \
--debugging \
../apps/bin/init \
>init.S \
2>&1
## Dump the hello disassembly to hello.S
riscv-none-elf-objdump \
--syms --source --reloc --demangle --line-numbers --wide \
--debugging \
../apps/bin/hello \
>hello.S \
2>&1
## Copy NuttX Image to TFTP Server
scp Image tftpserver:/tftpboot/Image-sg2000
ssh tftpserver ls -l /tftpboot/Image-sg2000
## Check the Coding Style
../nxstyle .gitignore
../nxstyle arch/risc-v/Kconfig
../nxstyle arch/risc-v/include/sg2000/chip.h
../nxstyle arch/risc-v/include/sg2000/irq.h
../nxstyle arch/risc-v/src/sg2000/Kconfig
../nxstyle arch/risc-v/src/sg2000/Make.defs
../nxstyle arch/risc-v/src/sg2000/chip.h
../nxstyle arch/risc-v/src/sg2000/hardware/sg2000_memorymap.h
../nxstyle arch/risc-v/src/sg2000/hardware/sg2000_plic.h
../nxstyle arch/risc-v/src/sg2000/sg2000_allocateheap.c
../nxstyle arch/risc-v/src/sg2000/sg2000_head.S
../nxstyle arch/risc-v/src/sg2000/sg2000_irq.c
../nxstyle arch/risc-v/src/sg2000/sg2000_irq_dispatch.c
../nxstyle arch/risc-v/src/sg2000/sg2000_memorymap.h
../nxstyle arch/risc-v/src/sg2000/sg2000_mm_init.c
../nxstyle arch/risc-v/src/sg2000/sg2000_mm_init.h
../nxstyle arch/risc-v/src/sg2000/sg2000_pgalloc.c
../nxstyle arch/risc-v/src/sg2000/sg2000_start.c
../nxstyle arch/risc-v/src/sg2000/sg2000_timerisr.c
../nxstyle boards/Kconfig
../nxstyle boards/risc-v/sg2000/milkv_duos/Kconfig
../nxstyle boards/risc-v/sg2000/milkv_duos/configs/nsh/defconfig
../nxstyle boards/risc-v/sg2000/milkv_duos/include/board.h
../nxstyle boards/risc-v/sg2000/milkv_duos/include/board_memorymap.h
../nxstyle boards/risc-v/sg2000/milkv_duos/scripts/Make.defs
../nxstyle boards/risc-v/sg2000/milkv_duos/scripts/ld.script
../nxstyle boards/risc-v/sg2000/milkv_duos/src/.gitignore
../nxstyle boards/risc-v/sg2000/milkv_duos/src/Makefile
../nxstyle boards/risc-v/sg2000/milkv_duos/src/etc/init.d/rc.sysinit
../nxstyle boards/risc-v/sg2000/milkv_duos/src/etc/init.d/rcS
../nxstyle boards/risc-v/sg2000/milkv_duos/src/sg2000_appinit.c
../nxstyle drivers/serial/uart_16550.c
## Run the firmware
script /tmp/nuttx-sg2000.log screen /dev/tty.usbserial-0001 115200
Apache NuttX RTOS for Sophgo SG2000 RISC-V SoC (Milk-V Duo S SBC)
See apache#12510
Build Script:
#!/usr/bin/env bash
# Build NuttX for SG2000
## TODO: Set PATH
export PATH="$HOME/xpack-riscv-none-elf-gcc-13.2.0-2/bin:$PATH"
rm init.S
rm initrd
rm -r boards/risc-v/sg2000/duos/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
}
## 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
riscv-none-elf-gcc -v
## Configure build
tools/configure.sh duos:nsh || true
## Build NuttX
build_nuttx
## Build Apps Filesystem
build_apps
## Add a.out to Apps Filesystem for TCC
rm -f /tmp/pattern.txt
start=$((0x22056900))
set +x # Don't echo commands
for i in {0..1023}
do
printf 0x%x\\n $(($start + $i)) >> /tmp/pattern.txt
done
set -x # Echo commands
cat /tmp/pattern.txt \
| xxd -revert -plain \
>../apps/bin/a.out
## Generate Initial RAM Disk
genromfs -f initrd -d ../apps/bin -V "NuttXBootVol"
## Show the size
riscv-none-elf-size nuttx
## Export the Binary Image to `nuttx.bin`
riscv-none-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
riscv-none-elf-objdump \
--syms --source --reloc --demangle --line-numbers --wide \
--debugging \
nuttx \
>nuttx.S \
2>&1
## Dump the init disassembly to init.S
riscv-none-elf-objdump \
--syms --source --reloc --demangle --line-numbers --wide \
--debugging \
../apps/bin/init \
>init.S \
2>&1
## Dump the hello disassembly to hello.S
riscv-none-elf-objdump \
--syms --source --reloc --demangle --line-numbers --wide \
--debugging \
../apps/bin/hello \
>hello.S \
2>&1
## Copy NuttX Image to TFTP Server
scp Image tftpserver:/tftpboot/Image-sg2000
ssh tftpserver ls -l /tftpboot/Image-sg2000
## Check Coding Style
../nxstyle .gitignore
../nxstyle arch/risc-v/Kconfig
../nxstyle arch/risc-v/include/sg2000/chip.h
../nxstyle arch/risc-v/include/sg2000/irq.h
../nxstyle arch/risc-v/src/sg2000/Kconfig
../nxstyle arch/risc-v/src/sg2000/Make.defs
../nxstyle arch/risc-v/src/sg2000/chip.h
../nxstyle arch/risc-v/src/sg2000/hardware/sg2000_memorymap.h
../nxstyle arch/risc-v/src/sg2000/hardware/sg2000_plic.h
../nxstyle arch/risc-v/src/sg2000/sg2000_allocateheap.c
../nxstyle arch/risc-v/src/sg2000/sg2000_head.S
../nxstyle arch/risc-v/src/sg2000/sg2000_irq.c
../nxstyle arch/risc-v/src/sg2000/sg2000_irq_dispatch.c
../nxstyle arch/risc-v/src/sg2000/sg2000_memorymap.h
../nxstyle arch/risc-v/src/sg2000/sg2000_mm_init.c
../nxstyle arch/risc-v/src/sg2000/sg2000_mm_init.h
../nxstyle arch/risc-v/src/sg2000/sg2000_pgalloc.c
../nxstyle arch/risc-v/src/sg2000/sg2000_start.c
../nxstyle arch/risc-v/src/sg2000/sg2000_timerisr.c
../nxstyle boards/Kconfig
../nxstyle boards/risc-v/sg2000/duos/Kconfig
../nxstyle boards/risc-v/sg2000/duos/configs/nsh/defconfig
../nxstyle boards/risc-v/sg2000/duos/include/board.h
../nxstyle boards/risc-v/sg2000/duos/include/board_memorymap.h
../nxstyle boards/risc-v/sg2000/duos/scripts/Make.defs
../nxstyle boards/risc-v/sg2000/duos/scripts/ld.script
../nxstyle boards/risc-v/sg2000/duos/src/.gitignore
../nxstyle boards/risc-v/sg2000/duos/src/Makefile
../nxstyle boards/risc-v/sg2000/duos/src/etc/init.d/rc.sysinit
../nxstyle boards/risc-v/sg2000/duos/src/etc/init.d/rcS
../nxstyle boards/risc-v/sg2000/duos/src/sg2000_appinit.c
../nxstyle drivers/serial/uart_16550.c
## Run the firmware
script /tmp/nuttx-sg2000.log screen /dev/tty.usbserial-0001 115200
Apache NuttX RTOS for Sophgo SG2000 RISC-V SoC (Milk-V Duo S SBC)
See https://github.com/lupyuen/nuttx-sg2000
Build Script:
## For xPack Toolchain:
## Change all `riscv64-unknown-elf` to `riscv-none-elf`
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 WIP NuttX for SG2000 (based on Ox64 BL808)
git clone --branch sg2000 \
https://github.com/lupyuen2/wip-nuttx \
nuttx
git clone --branch sg2000 \
https://github.com/lupyuen2/wip-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
## Copy NuttX Image and Device Tree to TFTP Server
cp Image Image-sg2000
scp Image-sg2000 tftpserver:/tftpboot/Image-sg2000
scp cv181x_milkv_duos_sd.dtb tftpserver:/tftpboot/cv181x_milkv_duos_sd.dtb
Apache NuttX RTOS for QEMU RISC-V 64-bit Kernel Mode (With LED Driver)
-
Copy
nuttx
to$HOME/nuttx/
-
Unzip
apps-bin.zip
and copy the files inside (not the folder) into$HOME/apps/bin/
(We should see
$HOME/apps/bin/qjs
andblink.js
) -
Then run
$ cd $HOME/nuttx/ $ qemu-system-riscv64 \ -semihosting \ -M virt,aclint=on \ -cpu rv64 \ -smp 8 \ -bios none \ -kernel nuttx \ -nographic
Build Script:
#!/usr/bin/env bash
# Build NuttX for QEMU RISC-V
## 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 QuickJS
pushd ../quickjs-nuttx/nuttx; ./build.sh ; popd ; exit
## 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 qemuled \
https://github.com/lupyuen2/wip-pinephone-nuttx \
nuttx
git clone \
--branch qemuled \
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 versions of GCC and Zig
riscv64-unknown-elf-gcc -v
## Configure build
tools/configure.sh rv-virt:knsh64
## 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
## 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
## Start the emulator
qemu-system-riscv64 \
-semihosting \
-M virt,aclint=on \
-cpu rv64 \
-smp 8 \
-bios none \
-kernel nuttx \
-nographic
Apache NuttX RTOS for Ox64 BL808 RISC-V SBC (With GPIO and LED Drivers)
Remember to Switch Ox64 QuickJS to Full Linking
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 gpio2 \
https://github.com/lupyuen2/wip-pinephone-nuttx \
nuttx
git clone \
--branch gpio2 \
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
## Add a.out to Apps Filesystem for TCC
rm -f /tmp/pattern.txt
start=$((0x22056900))
set +x # Don't echo commands
for i in {0..1023}
do
printf 0x%x\\n $(($start + $i)) >> /tmp/pattern.txt
done
set -x # Echo commands
cat /tmp/pattern.txt \
| xxd -revert -plain \
>../apps/bin/a.out
## 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
Apache NuttX RTOS for TinyEMU Emulator (64-bit RISC-V)
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
Apache NuttX RTOS for Pine64 Ox64 BL808 RISC-V SBC
NuttX Source: https://github.com/apache/nuttx/tree/96c2707737391642ac1d3ade84fb03f4c1fa51e4
NuttX Apps: https://github.com/apache/nuttx-apps/tree/f12586c51e0003c03e708b09baaf21348891f370
Inside menuconfig, we selected...
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, Info"
- Enable "Memory Manager Debug Features > Errors, Warnings"
- Enable "Scheduler Debug Features > Errors, Warnings, Info"
- Enable "SYSCALL Debug Features > Errors, Warnings"
- Enable "Timer Debug Features > Errors, Warnings, Info"
- Enable "IPC Debug Features > Errors, Warnings, Info"
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"
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
}
## 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 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
## Copy to Web Server
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/
Apache NuttX RTOS for Pine64 Ox64 BL808 RISC-V SBC
Official release of Ox64 BL808 Binaries from NuttX Mainline. See apache#11377
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
Ready to upstream Ox64 BL808 to NuttX Mainline. See apache#11377
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
Console Input and NuttX Commands are working OK yay!
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