Skip to content

Instantly share code, notes, and snippets.

@smaeul
Last active February 19, 2023 20:34
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smaeul/6fc91324b66fcd001717263f61bf3d06 to your computer and use it in GitHub Desktop.
Save smaeul/6fc91324b66fcd001717263f61bf3d06 to your computer and use it in GitHub Desktop.
BL808 U-Boot HOWTO
git clone https://github.com/smaeul/bouffalo-loader
git clone https://github.com/smaeul/opensbi -b bl808
git clone https://github.com/smaeul/u-boot -b bl808-2023-01-18
cd u-boot
make CROSS_COMPILE=riscv64-linux-musl- bl808_d0_defconfig
make CROSS_COMPILE=riscv64-linux-musl-
cd ../opensbi
make CROSS_COMPILE=riscv64-linux-musl- PLATFORM=generic \
FW_FDT_PATH=../u-boot/arch/riscv/dts/bl808-d0-ox64.dtb \
FW_PAYLOAD_OFFSET=0x100000 \
FW_PAYLOAD_PATH=../u-boot/u-boot.bin \
FW_TEXT_START=0x50000000
strip --strip-all build/platform/generic/firmware/fw_payload.elf
# copy build/platform/generic/firmware/fw_payload.elf to SD card
cd ../u-boot
make CROSS_COMPILE=riscv32-linux-musl- bl808_m0_defconfig
make CROSS_COMPILE=riscv32-linux-musl-
# Connect /dev/ttyUSB0 to GPIO14/GPIO15. This is your M0 UART, running at 115200 baud.
# Connect /dev/ttyUSB1 to GPIO12/GPIO13. This is your D0 UART, running at 115200 baud.
# Flash the M0 U-Boot using any of the available tools, for example:
bflb-mcu-tool --chipname bl808 --port /dev/ttyUSB0 --baudrate 2000000 --firmware u-boot.bin
# On /dev/ttyUSB0, 115200 baud, you can interact with M0 U-Boot:
U-Boot 2023.01-00244-g1d993ea68a (Jan 15 2023 - 02:47:09 -0600)
DRAM: 512 KiB
Core: 30 devices, 13 uclasses, devicetree: embed
MMC: mmc@20060000: 0
Loading Environment from <NULL>... OK
=> load mmc 0:1 51000000 fw_payload.elf
564808 bytes read in 2058 ms (267.6 KiB/s)
=> rproc init 0
=> rproc load 0 51000000 100000
Load Remote Processor 0 with data@addr=0x51000000 1048576 bytes: Success!
=> rproc start 0
=>
# Note that you still have a shell here, so you can load and run more programs
# (e.g. an IRQ forwarder) or manipulate D0 state. You can reset D0 with:
=> rproc stop 0
=> rproc load 0 51000000 100000
Load Remote Processor 0 with data@addr=0x51000000 1048576 bytes: Success!
=> rproc start 0
# On /dev/ttyUSB1, 115200 baud, you can interact with D0 U-Boot:
# Note: OpenSBI messages will not show up the first time because the pin mux is not set up.
DRAM: 64 MiB
Core: 27 devices, 11 uclasses, devicetree: board
MMC: mmc@20060000: 0
Loading Environment from nowhere... OK
In: serial@2000a100
Out: serial@2000a100
Err: serial@2000a100
Net: No ethernet found.
Hit any key to stop autoboot: 0
## Error: "distro_bootcmd" not defined
=> load mmc 0:1 $loadaddr bl808/Image
13271040 bytes read in 2554 ms (5 MiB/s)
=> booti $loadaddr - $fdtcontroladdr
Moving Image from 0x51000000 to 0x50200000, end=50ee8000
## Flattened Device Tree blob at 53b6b260
Booting using the fdt blob at 0x53b6b260
Working FDT set to 53b6b260
Loading Device Tree to 0000000052b5a000, end 0000000052b5fb80 ... OK
Working FDT set to 52b5a000
Starting kernel ...
[ 0.000000] Linux version 6.2.0-rc2-00210-ge1525068345d (samuel@titanium) (riscv64-linux-musl-gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #2 PREEMPT Sat Jan 14 16:58:42 CST 2023
[ 0.000000] OF: fdt: Ignoring memory range 0x50000000 - 0x50200000
[ 0.000000] Machine model: Pine64 Ox64 (D0)
[ 0.000000] efi: UEFI not found.
[ 0.000000] Zone ranges:
[ 0.000000] DMA32 [mem 0x0000000050200000-0x0000000053ffffff]
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000050200000-0x0000000053ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000050200000-0x0000000053ffffff]
[ 0.000000] SBI specification v1.0 detected
[ 0.000000] SBI implementation ID=0x1 Version=0x10002
[ 0.000000] SBI TIME extension detected
[ 0.000000] SBI IPI extension detected
[ 0.000000] SBI RFENCE extension detected
[ 0.000000] riscv: base ISA extensions acdfim
[ 0.000000] riscv: ELF capabilities acdfim
...
@smaeul
Copy link
Author

smaeul commented Jan 18, 2023

Updates for tag bl808-2023-01-18:

  • M0 now builds an XIP binary by default. You can flash u-boot.bin with bflb-mcu-tool --chipname bl808 --port /dev/ttyUSB0 --baudrate 2000000 --firmware u-boot.bin or equivalent. You no longer need bouffalo-loader. However, if you want, you can still use it, by disabling CONFIG_XIP.
  • Because M0 no longer needs GPIO14/15 for the boot ROM, I swapped the UARTs so M0 gets its "normal" pins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment