Linux SpacemiT device drivers
 help / color / mirror / Atom feed
* [PATCH v2 0/2] tools: mkimage: add SpacemiT K3 boot image support
@ 2026-09-09 15:51 Junhui Liu
  2026-09-09 15:51 ` [PATCH v2 1/2] " Junhui Liu
  2026-09-09 15:51 ` [PATCH v2 2/2] doc: board: spacemit: document the SpacemiT boot image format Junhui Liu
  0 siblings, 2 replies; 5+ messages in thread
From: Junhui Liu @ 2026-09-09 15:51 UTC (permalink / raw)
  To: u-boot
  Cc: Tom Rini, Quentin Schulz, Junhui Liu, Simon Glass, Daniel Golle,
	Randolph Sapp, Ilias Apalodimas, Kory Maincent, E Shattow,
	Yixun Lan, spacemit

The SpacemiT BootROM loads a first-stage bootloader from storage or over
USB in MaskROM mode. Vendor firmware packages this bootloader as FSBL.bin.

This series documents the SpacemiT boot image format and adds the
"smtimage" mkimage type for the CRC32-protected K3 variant used in
non-secure boot mode. It provides the FSBL packaging needed for future
K3 SPL support. Select K3 with "-n k3" when creating an image.

K1 and K3 secure boot use RSA authentication and are not supported yet.

How to test
-----------

Rebuild mkimage, wrap a small UART test payload, and load it through K3
MaskROM fastboot. The payload is linked at 0xc0801000 because the BootROM
places the complete image at 0xc0800000 and enters the payload after the
4 KiB prefix. UART0 should print "Hello SpacemiT K3!" and then loop
indefinitely.

  $ make tools-only_defconfig
  $ make tools-only

  $ cat > k3-uart.S << 'EOF'
  	.equ	UART0_THR, 0xd4017000
	.equ	UART0_LSR, 0xd4017014

	.section	.text
	.global	_start
_start:
	la	s0, str
1:
	lbu	a0, (s0)
	beqz	a0, exit
	call	uart_send
	addi	s0, s0, 1
	j	1b

exit:
	j	exit

uart_send:
	li	t0, UART0_LSR
	lw	t1, (t0)
	andi	t1, t1, 0x20
	beqz	t1, uart_send
	li	t0, UART0_THR
	sw	a0, (t0)
	ret

	.section	.rodata
str:
	.asciz	"Hello SpacemiT K3!\n"
EOF

  $ riscv64-linux-gnu-gcc -nostdlib -fno-builtin -fno-pie -no-pie -static \
    -march=rv64gc -mabi=lp64 -g -Wall -Wl,--build-id=none \
    -Ttext=0xc0801000 -o k3-uart.elf k3-uart.S
  $ riscv64-linux-gnu-objcopy -O binary k3-uart.elf k3-uart.bin
  $ ./tools/mkimage -T smtimage -n k3 -d k3-uart.bin k3-uart-smt.bin

Hold the FDL button, power on the board to enter MaskROM, then run
fastboot on host:

  $ fastboot stage k3-uart-smt.bin
  $ fastboot continue

---
Changes in v2:
- Use "smtimage" for the image type
- Update the documentation and command examples to match
- Link to v1: https://patch.msgid.link/20260822-spacemit-aihd-v1-0-bf4c41993891@pigmoral.tech

---
Junhui Liu (2):
      tools: mkimage: add SpacemiT K3 boot image support
      doc: board: spacemit: document the SpacemiT boot image format

 boot/image.c                    |   1 +
 doc/board/spacemit/index.rst    |   2 +-
 doc/board/spacemit/smtimage.rst | 143 ++++++++++++++++++++++++++++
 include/image.h                 |   1 +
 tools/Makefile                  |   1 +
 tools/smtimage.c                | 202 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 349 insertions(+), 1 deletion(-)
---
base-commit: 6073c36b2c8d39afe3ecc789b281667a3ddebc70
change-id: 20260820-spacemit-aihd-05c46aae886e

Best regards,
--  
Junhui Liu <junhui.liu@pigmoral.tech>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-10 12:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 15:51 [PATCH v2 0/2] tools: mkimage: add SpacemiT K3 boot image support Junhui Liu
2026-09-09 15:51 ` [PATCH v2 1/2] " Junhui Liu
2026-09-10 10:02   ` Yixun Lan
2026-09-10 12:35   ` Yao Zi
2026-09-09 15:51 ` [PATCH v2 2/2] doc: board: spacemit: document the SpacemiT boot image format Junhui Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox