.github | ||
bl808-pine64-ox64.dtb | ||
bl808-pine64-ox64.dts | ||
LICENSE | ||
README.md |
Apache NuttX RTOS for Pine64 Ox64 64-bit RISC-V SBC (BouffaloLab BL808)
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.
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...
-
code0: Executable code
(4 bytes, offset
0x00
)4d 5a 6f 10
-
code1: Executable code
(4 bytes, offset
0x04
)20 08 01 00
-
text_offset: Image load offset, little endian
(8 bytes, offset
0x08
)00 00 20 00 00 00 00 00
-
image_size: Effective Image size, little endian
(8 bytes, offset
0x10
)00 80 cd 00 00 00 00 00
-
flags: Kernel flags, little endian
(8 bytes, offset
0x18
)00 00 00 00 00 00 00 00
-
version: Version of this header (MinL MinM
.
MajL MajM)(4 bytes, offset
0x20
)02 00 00 00
-
res1: Reserved
(4 bytes, offset
0x24
)00 00 00 00
-
res2: Reserved
(8 bytes, offset
0x28
)00 00 00 00 00 00 00 00
-
magic: Magic number, little endian, "RISCV\x00\x00\x00"
(8 bytes, offset
0x30
)52 49 53 43 56 00 00 00
-
magic2: Magic number 2, little endian, "RSC\x05"
(4 bytes, offset
0x38
)52 53 43 05
-
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!
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>;
};
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>;
};
TODO: Print Debug Logs with OpenSBI
-
BL808 D0 Core: T-Head C906 480MHz 64-bit RISC-V CPU
(Multimedia Core)
-
BL808 M0 Core: T-Head E907 320MHz 32-bit RISC-V CPU
(Wireless Core)
-
BL808 LP Core: T-Head E902 150MHz 32-bit RISC-V CPU
(Low Power Core)
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 - A 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