nuttx-ox64/README.md
2023-11-04 08:40:09 +08:00

30 KiB

Pine64 Ox64 64-bit RISC-V SBC (Bouffalo Lab BL808)

Apache NuttX RTOS for Pine64 Ox64 64-bit RISC-V SBC (Bouffalo Lab BL808)

Read the article...

What's this BL808? (Datasheet) (Reference Manual)

BL808 is a complex creature with 3 (Asymmetric) RISC-V Cores (linked via IPC)...

  1. D0 Core: T-Head C906 64-bit RV64IMAFCV (480 MHz)

    (Multimedia Core with MIPI CSI / DSI, Neural Proc Unit)

    (Memory Mgmt Unit is Sv39, 128/256/512 TLB table entry. Same as Star64?)

  2. M0 Core: T-Head E907 32-bit RV32IMAFCP (320 MHz)

    (Wireless + Peripherals Core with WiFi, BLE, BT, Zigbee, Audio)

  3. LP Core: T-Head E902 32-bit RV32E[M]C (150 MHz)

    (Low Power Core)

    (Upcoming BL606 looks similar, minus the Low Power Core)

Bouffalo Lab BL808 is a complex creature with 3 (Asymmetric) RISC-V Cores

Pine64 Ox64 is the dev board for BL808C.

(BL808C supports MIPI CSI Cameras but not MIPI DSI Displays. Maybe someday we'll see BL808D for MIPI DSI Displays)

Is Ox64 BL808 an SBC? Or an MCU Board?

Technically Ox64 BL808 boots 64-bit RISC-V Linux (via MicroSD), so it feels like an SBC...

But Ox64 BL808 also feels like an MCU Board...

  • Form Factor is similar to MCU Board

  • Limited Memory: 64 MB of RAM, 128 Megabits (16 MB) of Flash Memory

  • M0 Wireless Core is 32-bit RISC-V MCU

  • UART Pins need a USB Serial Adapter for Flashing and Console I/O

  • Powered by Micro USB Port

    (Micro USB is not for Flashing either!)

  • Super Affordable: $8 for a 64-bit RISC-V Board!

Ox64 BL808 sounds a little tiny for 64-bit Linux?

Yeah 64-bit Linux runs with Limited RAM on the D0 Multimedia Core. But most Peripherals are hosted on the M0 Wireless Core: WiFi, BLE, BT, Zigbee, Audio, ...

So we flash M0 with a simple 32-bit RISC-V Firmware, to forward the Peripheral Interrupts from M0 to D0 Linux.

Here are the binaries loaded into D0 Multimedia Core and M0 Wireless Core, from buildroot_bouffalo...

  • d0_lowload_bl808_d0.bin: This is a very basic bootloader that loads opensbi, the kernel and dts files into ram

  • m0_lowload_bl808_m0.bin: This firmware runs on M0 and forwards interupts to the D0 for several peripherals

  • bl808-firmware.bin: An image containing OpenSBI, Uboot and uboot dtb files.

  • sdcard-*.tar.xz: A tarball containing the rootfs for the image to be flashed to the SD card

Perhaps Ox64 BL808 might run more efficiently with a tiny 64-bit RTOS.

Why Apache NuttX RTOS?

It might be interesting to run Apache NuttX RTOS on both the D0 Multimedia Core and the M0 Wireless Core. Then D0 and M0 can talk over OpenAMP (Asymmetric Multi-Processing).

Let's explore...

Flashing UART vs Serial Console

Read the article...

Flashing UART vs Serial Console

We need to handle TWO UART Ports on Ox64?

Yeah don't confuse the 2 UART Ports on Ox64! Let's give the UART Ports distinctive names (like Migi & Dali)...

  1. Ox64 Flashing UART: Used for Flashing Ox64

    • Flashing UART TX is GPIO 14 (Physical Pin 1)
    • Flashing UART RX is GPIO 15 (Physical Pin 2)
    • Remember to connect GND
    • Baud Rate for Normal Mode: 2,000,000 (2 Mbps)
    • Baud Rate for Flashing Mode: 230,400 (230.4 kbps)
    • BL808 UART0 is controlled by the M0 Wireless Core (OpenBouffalo Firmware)
  2. Ox64 Serial Console: Used for Linux Serial Console (plus OpenSBI and U-Boot Bootloader)

    • Serial Console TX is GPIO 16 (Physical Pin 32)
    • Serial Console RX is GPIO 17 (Physical Pin 31)
    • Remember to connect GND
    • Baud Rate: 2,000,000 (2 Mbps)
    • BL808 UART3 is controlled by the D0 Multimedia Core (Linux + OpenSBI + U-Boot)
    • Output is totally blank if OpenBouffalo Firmware wasn't flashed correctly, or if OpenSBI / U-Boot / Linux couldn't boot

NEITHER UART Port is accessible over USB-C or Micro USB. So yeah it's totally counterintuitive.

(Maybe someone can create a Stackable HAT or Breadboard, that will expose the 2 UART Ports as USB Dongles? Or a UART Switcher?)

(For Pre-Production Ox64: Physical Pins are different, but GPIOs above are correct)

Why 2 Baud Rates for Flashing UART?

When we power up Ox64 in Normal Mode: (Boot Button NOT pressed)

  • Flashing UART Port will show us the OpenBouffalo Firmware running on M0 Wireless Core

  • This M0 Firmware will forward Peripheral Interrupts to D0 Multimedia Core

  • M0 Firmware is hardcoded for 2 Mbps

  • Not really fun to watch. But we use this for testing our 2 Mbps USB Serial Adapter.

When we power up Ox64 in Flashing Mode: (Boot Button pressed)

  • Ox64 is ready for Firmware Flashing by the BL DevCube GUI Tool

  • Firmware Flashing supports various Baud Rates: 230.4 kbps, 2 Mbps, ...

  • But 2 Mbps will fail on macOS. That's why we Flash Firmware at 230.4 kbps.

    (Same problem when flashing BL602)

Serial Console is always 2 Mbps?

Yeah 2 Mbps is hardcoded in Ox64 Linux. Switching to other Baud Rates will show garbled text.

Thus our USB Serial Adapter must connect reliably to Ox64 at 2 Mbps.

Now we flash Ox64 and boot Linux...

Flash OpenSBI and U-Boot Bootloader to Ox64 BL808

Read the article...

Before booting Linux on Ox64, we flash OpenSBI + U-Boot Bootloader to D0 Multimedia Core, and the Peripheral Interrupt Firmware to M0 Wireless Core. From buildroot_bouffalo:

  • d0_lowload_bl808_d0.bin: This is a very basic bootloader that loads opensbi, the kernel and dts files into ram

  • m0_lowload_bl808_m0.bin: This firmware runs on M0 and forwards interupts to the D0 for several peripherals

  • bl808-firmware.bin: An image containing OpenSBI, Uboot and uboot dtb files.

Here are the steps, based on the Official Flashing Instructions...

  1. We tested with Pine64 Woodpecker CH340G USB Serial Adapter on macOS x64.

    Warning: Some USB Serial Adapters WON'T WORK!

    Probably because we are connecting at 2 Mbps, which might be too fast for some USB Serial Adapters.

    (Like this CP2102, which shows garbled text at 2 Mbps)

    Flashing UART

  2. To Test our USB Serial Adapter: Connect the USB Serial Adapter to Ox64 Flashing UART (pic above)...

    • Flashing UART TX is GPIO 14 (Physical Pin 1)
    • Flashing UART RX is GPIO 15 (Physical Pin 2)
    • Remember to connect GND
    • Baud 2,000,000 (2 Mbps)

    Start the USB Serial Terminal (Flashing UART).

    Power up Ox64 via the Micro USB Port. Ox64 Green LED should light up.

    This Clickety Micro USB Cable is very handy for rebooting Ox64...

    Clickety Micro USB Cable

  3. In the USB Serial Terminal (Flashing UART), we should see the Ox64 Factory Test Firmware...

    Build:19:50:39,Nov 20 2022
    Copyright (c) 2022 Bouffalolab team
    dynamic memory init success,heap size = 93 Kbyte 
    sig1:ffff32ff
    sig2:0000ffff
    Pong!
    Ping!
    

    (Source)

    If the text appears garbled: Try a different USB Serial Adapter. (See above)

    My prototype version shows this instead...

    Init CLI with event Driven
    start aos loop... 
    CLI RAW Data, c906
    /romfs/c906.bin not found!
    

    (Source)

  4. Pre-Flash Check: Set BL808 board to programming mode

    • Remove the microSD Card
    • Press and Hold BOOT Button
    • Unplug and replug the Micro USB Port
    • Release BOOT button
    • Ox64 Green LED should turn on

    In the USB Serial Terminal (Flashing UART), we should see this...

    .
    

    Yep Ox64 is ready for flashing!

  5. Now we prepare to flash:

    Disconnect the USB Serial Terminal (to release the Flashing UART)

    Set BL808 board to programming mode

    • Remove the microSD Card
    • Press and Hold BOOT Button
    • Unplug and replug the Micro USB Port
    • Release BOOT button
    • Ox64 Green LED should turn on
  6. We download the Ox64 Binaries...

    From the latest Ox64 Linux Release...

    Unzip the download and we should see this...

    → ls -l firmware
       7340032  bl808-firmware.bin
         31360  d0_lowload_bl808_d0.bin
         65760  m0_lowload_bl808_m0.bin
      43859444  sdcard-pine64_ox64_full_defconfig.img.xz    
    
  7. We'll run BouffaloLab DevCube for Flashing BL808.

    Only Ubuntu x64, macOS and Windows are supported.

    TODO: How to flash BL808 on Arm64 SBCs and Pinebook Pro? Sigh. See bflb-iot-tool / bflb-mcu-tool

  8. Download Bouffalo Lab DevCube 1.8.3 from...

    openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip

    (1.8.4 and later won't work)

    May need to Grant Execute Permission...

    cd BouffaloLabDevCube-v1.8.3
    chmod +x BLDevCube-macos-x86_64
    ./BLDevCube-macos-x86_64
    
  9. Run DevCube, select "BL808", and switch to "MCU" page

  10. M0 Group: Group0

    Image Addr: 0x58000000

    PATH: Select "m0_lowload_bl808_m0.bin"

  11. D0 Group: Group0

    Image Addr: 0x58100000

    PATH: Select "d0_lowload_bl808_d0.bin"

  12. Set UART Rate to 230400.

    Don't set to 2000000, it will fail on macOS!

    (Same problem when flashing BL602)

  13. Click "Create & Download" and wait until it's done

    (See the log)

  14. Switch to "IOT" page

  15. Enable 'Single Download'

    Set Address to 0x800000

    Select "bl808-firmware.bin"

  16. Set UART Rate to 230400.

    Don't set to 2000000, it will fail on macOS!

    (Same problem when flashing BL602)

  17. Click "Create & Download" again and wait until it's done

    (See the log)

  18. Start the USB Serial Terminal (Flashing UART at 2 Mbps).

    Unplug and replug the Micro USB Port.

    (Don't press the Boot Button!)

  19. On the USB Serial Terminal (Flashing UART) we should see...

    [I][] Powered by BouffaloLab
    [I][] Build:11:52:22,Mar  6 2023
    [I][] Copyright (c) 2023 OpenBouffalo team
    [I][] Copyright (c) 2022 Bouffalolab team
    [I][] =========== flash cfg ==============
    [I][] jedec id   0xEF6018
    [I][] mid            0xEF
    [I][] iomode         0x04
    [I][] clk delay      0x01
    [I][] clk invert     0x01
    [I][] read reg cmd0  0x05
    [I][] read reg cmd1  0x35
    [I][] write reg cmd0 0x01
    [I][] write reg cmd1 0x31
    [I][] qe write len   0x01
    [I][] cread support  0x00
    [I][] cread code     0xFF
    [I][] burst wrap cmd 0x77
    [I][] sector size:   0x04
    [I][] =====================================
    [I][] dynamic memory init success,heap size = 156 Kbyte 
    [I][MAIN] Starting Mailbox Handlers
    [I][MBOX] Forwarding Interupt SDH (33) to D0 (0x58008bbc)
    [I][MBOX] Forwarding Interupt GPIO (60) to D0 (0x58008d0e)
    [I][MAIN] Running...
    [I][MBOX] Mailbox IRQ Stats:
    [I][MBOX] .Peripheral SDH (33): 0
    [I][MBOX] .Peripheral GPIO (60): 0
    [I][MBOX] Unhandled Interupts: 0 Unhandled Signals 0
    

    (Source)

    Yep we have flashed the OpenBouffalo Firmware successfully!

    Serial Console

  20. Connect our USB Serial Adapter to Ox64 Serial Console: (pic above)

    • Serial Console TX is GPIO 16 (Physical Pin 32)
    • Serial Console RX is GPIO 17 (Physical Pin 31)
    • Remember to connect GND
    • Baud 2,000,000 (2 Mbps)

    Start the USB Serial Terminal (Serial Console).

    Unplug and replug the Micro USB Port.

    (Don't press the Boot Button!)

  21. On the USB Serial Terminal (Serial Console) we should see...

    U-Boot 2023.04-rc2 (Mar 06 2023 - 11:48:40 +0000)
    Card did not respond to voltage select! : -110
    BOOTP broadcast
    Retry time exceeded; starting again
    

    (Source)

    Which is OK because U-Boot Bootloader is waiting for a microSD Card.

  22. If nothing appears...

    Check that we are using Bouffalo Lab DevCube 1.8.3

    (1.8.4 and later won't work)

    In BL Dev Cube, UART Rate (for MCU and IoT) should be 230400.

    Don't set to 2000000, it will fail on macOS!

    (Same problem when flashing BL602)

Let's load Ox64 Linux into a microSD Card...

Boot Linux on Ox64 BL808

Ox64 Linux in a microSD Card

Read the article...

Now that D0 Multimedia Core is flashed with OpenSBI and U-Boot Bootloader, we're ready to boot Linux on microSD!

Based on the Official Flashing Instructions...

  1. Look for the microSD Image that we downloaded earlier...

    sdcard-pine64_ox64_full_defconfig.img.xz
    

    Uncompress the file to get...

    sdcard-pine64_ox64_full_defconfig.img
    
  2. Flash the uncompressed image to your microSD card.

    You can use Balena Etcher, GNOME Disks or dd.

  3. Insert the microSD Card into Ox64. (Pic above)

    Flashing UART

  4. Connect our USB Serial Adapter to Ox64 Flashing UART: (pic above)

    • Flashing UART TX is GPIO 14 (Physical Pin 1)
    • Flashing UART RX is GPIO 15 (Physical Pin 2)
    • Remember to connect GND
    • Baud 2,000,000 (2 Mbps)

    Start the USB Serial Terminal (Flashing UART).

    Unplug and replug the Micro USB Port.

    (Don't press the Boot Button!)

  5. On the USB Serial Terminal (Flashing UART) we should see the same thing as earlier...

    [I][MAIN] Starting Mailbox Handlers
    [I][MBOX] Forwarding Interupt SDH (33) to D0 (0x58008bbc)
    [I][MBOX] Forwarding Interupt GPIO (60) to D0 (0x58008d0e)
    [I][MAIN] Running...
    [I][MBOX] Mailbox IRQ Stats:
    [I][MBOX] .Peripheral SDH (33): 0
    [I][MBOX] .Peripheral GPIO (60): 0
    [I][MBOX] Unhandled Interupts: 0 Unhandled Signals 0
    

    (Source)

    Serial Console

  6. Connect our USB Serial Adapter to Ox64 Serial Console: (pic above)

    • Serial Console TX is GPIO 16 (Physical Pin 32)
    • Serial Console RX is GPIO 17 (Physical Pin 31)
    • Remember to connect GND
    • Baud 2,000,000 (2 Mbps)

    Start the USB Serial Terminal (Serial Console).

    Unplug and replug the Micro USB Port.

    (Don't press the Boot Button!)

  7. On the USB Serial Terminal (Serial Console) we should see...

    [I][] Powered by BouffaloLab
    [I][] Build:11:52:04,Mar  6 2023
    [I][] Copyright (c) 2023 OpenBouffalo team
    [I][] Copyright (c) 2022 Bouffalolab team
    [I][] dynamic memory init success,heap s[I][LowLoad] D0 start...
    [I][LowLoad] low_load start... 
    [I][LowLoad] Header at 0x5d5ff000
    [I][LowLoad] Section dtb(1) - Start 0x5d5ff100, Size 14314
    [I][LowLoad] Copying DTB to 0x51ff8000...0x51ffb7ea
    [I][LowLoad] Done!
    [I][LowLoad] Section OpenSBI(2) - Start 0x5d60f100, Size 109864
    [I][LowLoad] Copying OpenSBI to 0x3ef80000...0x3ef9ad28
    [I][LowLoad] Done!
    [I][LowLoad] Section Kernel(3) - Start 0x5d62f100, Size 315597
    [I][LowLoad] Uncompressing Kernel to 0x50000000...
    [I][LowLoad] Done!
    [I][LowLoad] CRC: 00000000
    [I][LowLoad] load time: 61306 us 
    [I][LowLoad] ing PMP
    [I][LowLoad] Booting OpenSBI at 0x000000003ef80000 with DTB at 0x51ff8000
    ...
    OpenSBI v1.2
    Platform Name             : Pine64 Ox64 (D0)
    Platform Features          medeleg
    Platform HART Count       : 1
    Platform IPI Device       : aclint-mswi
    Platform Timer Device     : aclint-mtimer @ 1000000Hz
    Platform Console Device   : bflb_uart
    Platform HSM Device       : ---
    Platform PMU Device       : ---
    Platform Reboot Device    : ---
    Platform Shutdown Device  : ---
    Firmware Base             : 0x3ef80000
    Firmware Size             : 200 KB
    Runtime SBI Version       : 1.0
    ...
    
    U-Boot 2023.04-rc2 (Mar 06 2023 - 11:48:40 +0000)
    DRAM:  64 MiB
    Core:  36 devices, 17 uclasses, devicetree: board
    MMC:   mmc@20060000: 0
    Loading Environment from FAT... Unable to read "uboot.env" from mmc0:2... 
    ...
    Starting kernel ...
    Linux version 6.2.0 (runner@fv-az587-938) (riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.6.1 B-20220906) 10.2.0, GNU ld (GNU Binutils) 2.35) #1 Mon Mar  6 11:17:27 UTC 2023
    ...
    Welcome to Buildroot
    ox64 login: 
    

    (See the Complete Log)

    (Watch the Video on YouTube)

    Yep Linux is running on Ox64 yay! (Pic below)

  8. If nothing appears...

    Check that we are using Bouffalo Lab DevCube 1.8.3

    (1.8.4 and later won't work)

    In BL Dev Cube, UART Rate (for MCU and IoT) should be 230400.

    Don't set to 2000000, it will fail on macOS!

    (Same problem when flashing BL602)

  9. If we see...

    U-Boot 2023.04-rc2 (Mar 06 2023 - 11:48:40 +0000)
    Card did not respond to voltage select! : -110
    BOOTP broadcast
    Retry time exceeded; starting again
    

    (Source)

    Check that the microSD Card is inserted correctly. (Pic above)

  10. TODO: TFTP Boot over Ethernet

Boot Linux on Ox64 BL808

Comment by @gamelaster...

"This is not hardware specific, but flasher specific. With blisp, I was able to get faster flashing working, but this is Apple's quirk. Or maybe not? Because FreeBSD need same quirks and exact buffer sizes as Apple."

Comment by @madushan1000...

"You can also use u-boot. https://github.com/openbouffalo/u-boot/releases/tag/bl808-2023-02-19 You can also get rid of mailbox, but you will have to build the kernel yourself https://github.com/openbouffalo/linux/tree/bl808/all"

Forward Peripheral Interrupts

Read the article...

TODO

[I][MAIN] Starting Mailbox Handlers
[I][MBOX] Forwarding Interupt SDH (33) to D0 (0x58008bbc)
[I][MBOX] Forwarding Interupt GPIO (60) to D0 (0x58008d0e)
[I][MAIN] Running...
[I][MBOX] Mailbox IRQ Stats:
[I][MBOX] .Peripheral SDH (33): 0
[I][MBOX] .Peripheral GPIO (60): 0
[I][MBOX] Unhandled Interupts: 0 Unhandled Signals 0

(Source)

SDH: SD Card (SDIO) Host Controller (BL808 RM Page 561)

IRQ 60: GPIO_INT0 (IRQ_NUM_BASE+44) GPIO Interrupt (BL808 RM Page 44)

GPIO_INT0_IRQn

SDH is IRQ 33: SDH_IRQn

IRQ_NUM_BASE is 16 (BL808 RM Page 45)

m0_lowload

d0_lowload

Forward GPIO Interrupt

Forward SDH Interrupt

Setup SDH Interrupt

Other Interrupts (unused)

Inspect the Linux Image for Ox64 BL808

Read the article...

Will Apache NuttX RTOS boot on Ox64 BL808?

Let's examine the Linux Kernel Image for Ox64, and we replicate the same format for NuttX. (Which is how we ported NuttX to 64-bit RISC-V Star64 JH7110 SBC)

We download the Ox64 Binaries...

From the latest Ox64 Linux Release...

Unzip it and mount the SD Card Image...

→ ls -l sdcard-pine64_ox64_full_defconfig     
-  13,154,816  Image
-       4,012  bl808-pine64-ox64.dtb
-       4,106  bl808-sipeed-m1s.dtb
-         350  boot-m1s.scr
-         352  boot-pine64.scr
-         352  boot.scr
d          96  extlinux

Dump the Image as hex...

→ hexdump sdcard-pine64_ox64_full_defconfig/Image
0000000 4d 5a 6f 10 20 08 01 00 00 00 20 00 00 00 00 00
0000010 00 80 cd 00 00 00 00 00 00 00 00 00 00 00 00 00
0000020 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000030 52 49 53 43 56 00 00 00 52 53 43 05 40 00 00 00

The Linux Kernel Image begins with this RISC-V Linux Image Header...

Here are the decoded bytes...

  1. code0: Executable code

    (4 bytes, offset 0x00)

    4d 5a 6f 10 
    
  2. code1: Executable code

    (4 bytes, offset 0x04)

    20 08 01 00 
    
  3. text_offset: Image load offset, little endian

    (8 bytes, offset 0x08)

    00 00 20 00 00 00 00 00
    
  4. image_size: Effective Image size, little endian

    (8 bytes, offset 0x10)

    00 80 cd 00 00 00 00 00
    
  5. flags: Kernel flags, little endian

    (8 bytes, offset 0x18)

    00 00 00 00 00 00 00 00
    
  6. version: Version of this header (MinL MinM . MajL MajM)

    (4 bytes, offset 0x20)

    02 00 00 00
    
  7. res1: Reserved

    (4 bytes, offset 0x24)

    00 00 00 00
    
  8. res2: Reserved

    (8 bytes, offset 0x28)

    00 00 00 00 00 00 00 00
    
  9. magic: Magic number, little endian, "RISCV\x00\x00\x00"

    (8 bytes, offset 0x30)

    52 49 53 43 56 00 00 00
    
  10. magic2: Magic number 2, little endian, "RSC\x05"

    (4 bytes, offset 0x38)

    52 53 43 05
    
  11. res3: Reserved for PE COFF offset

    (4 bytes, offset 0x3C)

    40 00 00 00
    

Our NuttX Kernel shall recreate this RISC-V Linux Image Header. (Total 0x40 bytes)

(Or U-Boot Bootloader might refuse to boot NuttX)

Header Values are exactly the same as Star64. (Except the Image Size and Executable Code, since the Jump Address is different)

Thus we simply reuse the code from NuttX Star64!

Linux Device Tree for Ox64 BL808

Read the article...

TODO: Dump the Device Tree

dtc \
  -o bl808-pine64-ox64.dts \
  -O dts \
  -I dtb \
  bl808-pine64-ox64.dtb

Here's the Decompiled Device Tree: bl808-pine64-ox64.dts

TODO: Transmit to UART3 at 0x30002000. Reuse the BL602 UART Driver for NuttX.

serial@30002000 {
  compatible = "bflb,bl808-uart";
  reg = <0x30002000 0x1000>;
  interrupts = <0x14 0x04>;
  clocks = <0x04>;
  status = "okay";
  phandle = <0x0a>;
};

(Source)

TODO: Forward the Interrupts from M0 Wireless Core to D0 Multimedia Core via Mailbox / IPC (Where are the addresses documented?)

mailbox@30005000 {
  compatible = "bflb,bl808-ipc";
  reg = <
    0x30005000 0x20 
    0x30005020 0x20 
    0x2000a800 0x20 
    0x2000a820 0x20
  >;
  interrupts = <0x36 0x04>;
  interrupt-controller;
  #interrupt-cells = <0x03>;
  #mbox-cells = <0x02>;
  status = "okay";
  phandle = <0x03>;
};

(Source)

TODO: Print Debug Logs with OpenSBI

Boot Apache NuttX RTOS on Ox64 BL808

What happens if we boot Star64 NuttX on Ox64 BL808?

Let's find out!

## Download and build NuttX for Star64
git clone --branch ox64 https://github.com/lupyuen2/wip-pinephone-nuttx nuttx
git clone --branch ox64 https://github.com/lupyuen2/wip-pinephone-nuttx-apps apps
cd nuttx
tools/configure.sh star64:nsh
make

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

## Copy to microSD
cp nuttx.bin Image
cp Image "/Volumes/NO NAME"
diskutil unmountDisk /dev/disk2

We boot Nuttx on Ox64 via microSD... But Ox64 shows absolutely nothing!

Retrieving file: /extlinux/../Image
append: root=PARTLABEL=rootfs rootwait rw rootfstype=ext4 console=ttyS0,2000000 loglevel=8 earlycon=sbi
Retrieving file: /extlinux/../bl808-pine64-ox64.dtb
## Flattened Device Tree blob at 51ff8000
   Booting using the fdt blob at 0x51ff8000
Working FDT set to 51ff8000
   Loading Device Tree to 0000000053f22000, end 0000000053f25fab ... OK
Working FDT set to 53f22000
Starting kernel ...

(Source)

Let's print to the Serial Console in the NuttX Boot Code (in RISC-V Assembly)

TODO

Documentation for Ox64 BL808

From buildroot_bouffalo:

  • m0_lowload_bl808_m0.bin - This firmware runs on M0 and forwards interupts to the D0 for several peripherals
  • d0_lowload_bl808_d0.bin - This is a very basic bootloader that loads opensbi, the kernel and dts files into ram
  • bl808-firmware.bin - An image containing OpenSBI, Uboot and uboot dtb files.
  • sdcard-*.tar.xz - A tarball containing the rootfs for the image to be flashed to the SD card