Skip to content

Guide to build reduced SpacemiT K3 vendor BSP (continued)

E Shattow u-boot 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest0 of 7 patches 0 repliesNew

Patches in v1 No applies recorded yet

None of the 7 patches the cover letter announces are in this archive.

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [DNM v1 0/7] Guide to build reduced SpacemiT K3 vendor BSP (continued)

Do Not Merge

Informational purpose only, to aid mainline development of SpacemiT K3 support.

...continued from https://lore.kernel.org/u-boot/[email protected]/

What is known to be working from mainline?
- mkimage to post-process SPL into spl/u-boot-spl-mkimage.bin
- FIT U-Boot main app u-boot.itb
- dependency on OpenSBI

What do we need from the vendor BSP?
- SPL

(Optional) Additional hardware used?
- K3 Pico-ITX BootROM UART SPL loader mode selected by pull-up via FPC-36P reverse cable and adapter to header pins (2.54mm pitch DuPont connector).

The assumption in this guide is root user in a fresh Debian 13 Trixie build environment on amd64 architecture build host.

dpkg --add-architecture riscv64
apt install -y bison ca-certificates flex gcc-riscv64-linux-gnu git \
libgnutls28-dev libpython3-dev libssl-dev python3-setuptools swig \
curl
export CROSS_COMPILE=riscv64-linux-gnu-

git clone https://github.com/riscv-software-src/opensbi.git \
opensbi.git
git -C opensbi.git checkout d28bc6f89837 # origin/master

# v6 "platform: generic: spacemit: add K3 platform support"
# https://patchwork.ozlabs.org/project/opensbi/list/?series=530305
curl https://patchwork.ozlabs.org/series/530305/mbox/ \
  | git -C opensbi.git am
make -C opensbi.git O=../opensbi clean
make -C opensbi.git O=../opensbi PLATFORM=generic

git clone https://git.u-boot-project.org/u-boot/u-boot.git u-boot.git git -C u-boot.git remote add -f spacemit-com \
https://github.com/spacemit-com/uboot-2022.10.git

git -C u-boot.git checkout 03e45557e1f3 # origin/main

# v1 "Spacemit K3 enable Linux boot"
# https://patchwork.ozlabs.org/project/uboot/list/?series=530384
curl https://patchwork.ozlabs.org/series/530384/mbox/ \
  | git -C u-boot.git am
make -C u-boot.git O=../u-boot spacemit_k3_defconfig
fw_dynbin=$(realpath opensbi/platform/generic/firmware/fw_dynamic.bin)
make -C u-boot.git O=../u-boot OPENSBI=$fw_dynbin

git -C u-boot.git checkout k3-br-v1.0.10 # spacemit-com/k3-br-v1.0.y

# v1 "Guide to build reduced SpacemiT K3 vendor BSP"
# https://patchwork.ozlabs.org/project/uboot/list/?series=530447
curl https://patchwork.ozlabs.org/series/530447/mbox/ \
  | git -C u-boot.git am
mki=$(realpath u-boot/tools/mkimage)
make -C u-boot.git O=../bsp-spi \
  spacemit_k3_uart_spi_defconfig
make -C u-boot.git O=../bsp-spi MKIMAGE=$mki \
  spl/u-boot-spl-mkimage.bin
make -C u-boot.git O=../bsp-nospi \
  spacemit_k3_uart_nospi_defconfig
make -C u-boot.git O=../bsp-nospi MKIMAGE=$mki \
  spl/u-boot-spl-mkimage.bin

tar -czf reduced-spacemit-k3-vendor-bsp.tar.gz \
--transform 's~^~reduced-spacemit-k3-vendor-bsp/~' \
bsp-nospi/spl/u-boot-spl-mkimage.bin \
bsp-spi/spl/u-boot-spl-mkimage.bin \
u-boot/u-boot.itb

### K3 Pico-ITX BootROM UART SPL loader
Connect USB selection bias-pulldown pin 10 high to VCC1V8 pin 1 or pin 2 for UART selection and pin 11 high to VCC1V8 selects BootROM USB/UART download mode; pin 11 low is normal operation from selected NOR/UFS/MMC/NAND secondary boot after SD card. If you do not have a flat flex cable then it is possible with a sharp probe and steady hands to do so, the easiest method apparently being to connect the physically large VCC1V8 leg of the EEPROM part to probe FPC-36P pin 10 and depress the Firmware DownLoad button held for a moment while pressing the reset or powering up the board. The reason for wanting to activate BootROM UART mode is to avoid the use of Fastboot USB, and to isolate any peripheral configuration that may have been acted upon by BootROM which may be different between the available BootROM SPL loader modes.

Visual reference:
https://web.archive.org/web/20261025124009/https://freeshell.de/e/riscv64/K3PicoITX-explainer_boot_resistors-20261017draft.webp

Connect for fastboot transfers the K3 Pico-ITX USB-C OTG port (not the corner USB-C power input/display port) using USB-C to USB-A cable and then to any USB-A port on the fastboot and serial terminal host.

Connect a serial UART cable, note the board TXD is adjacent to the PCB board edge and opposite of that is GND with board RXD in the middle; swap adapter TXD and adapter RXD as appropriate.

The vanilla vendor BSP assumes use of fastboot USB in FSBL.bin SPL for main.itb loading. If the vanilla vendor BSP main.itb runs with pin 10 low (the board default) then it again attempts to load an SPL and this can be escaped to a hush prompt by fastboot host 'fastboot continue'.

The UART variants of vendor BSP are patched to assume that u-boot.itb is loaded over serial UART in YMODEM protocol. If activated the BootROM UART loader assumes loading an SPL over serial UART in XMODEM protocol. Using the 'tio' serial terminal software the keybind sequences are (Control-t,x,0) for XMODEM and (Control-t,y) for YMODEM. If you initiate a transfer and question-mark characters '?' appear then the transfer has not synchronized correctly, so abort sending and then re-try sending the transfer until you will see '.' progress marks appear. The reduction in build config options for "bsp-spi" deletes support for USB from SPL. The "bsp-nospi" has nearly all options removed leaving only YMODEM loading, DRAM initialization, and dependency of EEPROM TLV access for DRAM id.

Example boot 'mini.efi' netinst Debian debian-installer:
Power on or reset board with FDL button pressed (or pin 11 high)
sys: 0x10001200
bm:2
usb_init : enter 3296,3072
usb_core_init : enter
DWC3_GRXTHRCFG:0x4400000
ROM: usb download handler
rst
done H
setup= 0x1000680 0x400000,
rst
done H
setup= 0x1a0500 0x0,
setup= 0x1000680 0x120000,
setup= 0x2000680 0x90000,
setup= 0x2000680 0x200000,
setup= 0x3000680 0xff0000,
setup= 0x3020680 0xff0409,
setup= 0x3010680 0xff0409,
setup= 0x10900 0x0,
usb_rx_bytes : start len[4096]
setup= 0x3020680 0xff0409,
setup= 0x3040680 0xff0409,
host$ fastboot stage bsp-nospi/spl/u-boot-spl-mkimage.bin
fastboot_handle_command: max-download-size
usb_tx_bytes : start len[14]
usb_rx_bytes : start len[4096]
fastboot_handle_command: 0003cd00
Starting download of 249088 bytes
usb_tx_bytes : start len[12]
usb_rx_bytes : start len[249088]
usb_tx_bytes : start len[4]
usb_rx_bytes : start len[4096]
host$ fastboot continue
fastboot_handle_command: continue
usb_tx_bytes : start len[4]
j...
U-Boot SPL 2022.10-00007-g69c3d4b55f6 (Oct 28 2026 - 21:57:06 +0000) LPDDR5 total size: 32 GB, data rate: 6400 MT/s
DDR training consume 5612ms
Get cluster clk error
CCC
host$ curl -LO \
https://d-i.debian.org/daily-images/riscv64/daily/netboot/mini.efi
host$ python3 -m http.server 8000
(Control-t,y)
[16:28:01.384] Send file with YMODEM
[16:28:01.384] Enter file name:
u-boot/u-boot.itb
[16:28:01.384] Enter file name: u-boot/u-boot.itb [16:28:01.384] Send file with YMODEM
[16:28:12.766] Sending file 'u-boot/u-boot.itb' [16:28:12.766] Press any key to abort transfer
...|
[16:29:57.267] Done
Loaded 1115321 bytes
load failed: uboot=-1 esos=-1
<debug_uart>
clk_register: failed to get external_clk device (parent of espi_s... U-Boot 2027.01-rc1-00037-g96c9b2e9d606 (Oct 28 2026 - 21:54:22 +0...
DRAM: 16 GiB
clk_register: failed to get external_clk device (parent of espi_s...
Core: 452 devices, 21 uclasses, devicetree: separate
*** Warning - spi_flash_probe_bus_cs() failed, using default envi...

  In:    serial@d4017000
  Out:   serial@d4017000
  Err:   serial@d4017000

Net:
Warning: ethernet@cac80000 (eth0) using random MAC address - 06:3...
eth0: ethernet@cac80000
Hit any key to stop autoboot: 2 1 0
(Control-c)
=>
dhcp
=> dhcp
ethernet@cac80000 Waiting for PHY auto negotiation to complete...... DHCP client bound to address 192.168.2.81 (29 ms)
error: no file name
=>
wget http://host:8000/mini.efi
##################################################
88906240 bytes transferred in 760 ms (111.6 MiB/s)
Bytes transferred = 88906240 (54c9a00 hex)
bootefi $loadaddr