From: Troy Mitchell <troy.mitchell@linux.spacemit.com>
To: opensbi@lists.infradead.org
Cc: Xianbin Zhu <xianbin.zhu@linux.spacemit.com>,
Anup Patel <anup@brainfault.org>, Bo Gan <ganboing@gmail.com>,
Samuel Holland <samuel.holland@sifive.com>,
Heinrich Schuchardt <heinrich.schuchardt@canonical.com>,
Troy Mitchell <troy.mitchell@linux.spacemit.com>
Subject: [PATCH v3 0/5] platform: generic: spacemit: add K3 platform support
Date: Thu, 27 Aug 2026 17:19:18 +0800 [thread overview]
Message-ID: <20260827-spacemit-k3-v3-0-5d8dbb68539d@linux.spacemit.com> (raw)
SpacemiT K3 combines eight X100 harts and eight A100 harts in four
clusters. The two core types expose different ISA capabilities: X100
implements H and has a 256-bit VLEN, while A100 does not implement H and
has a 1024-bit VLEN. OpenSBI currently selects one expected-trap handler
from the cold-boot hart, so an X100 boot hart would make A100 access H-only
CSRs. Select that handler per hart; the remaining extension and vector
state used by OpenSBI is already maintained or queried per hart.
Only hart 0 is powered at reset. Add a start-only HSM backend which removes
the requested hart's core and cluster power-down votes and wakes it on
demand. Before common warm-boot code runs, each hart restores the PMA
attributes expected by later firmware, enables cache snooping and prefetch,
and enables H on X100. The cold-boot hart also programs the cluster reset
vectors and enables CCI-550 snoop and DVM requests before secondary harts
can start.
K1 shares the vendor cache CSRs, PMU fields, cluster sizing, and CCI-550
helper with K3. Factor only those definitions and helpers into common
SpacemiT files; K1 keeps its topology, boot flow, and HSM behavior. Two
independent K1 fixes clarify the cache operation name and move per-hart
setup out of cold_boot_allowed().
The K3 SDK still loads ESOS for RPMI reset, suspend, and MPXY services.
Secondary-hart startup does not depend on the ESOS HSM service: the K3 HSM
driver matches the root node first and uses the SoC PMU directly, following
the SDK firmware's direct wakeup path.
Runtime validation on a SpacemiT K3 COM260 used the SDK's split NOR
firmware layout. OpenSBI was flashed as fw_dynamic.itb, then loaded from
NOR by the SDK FSBL. OpenSBI built from this series selected the
spacemit-k3-hsm device and reported 16 harts. U-Boot and Linux 6.18.3
started, Linux detected SBI v3.0 and the HSM extension, and all 16 CPUs
came online.
The series has been build-tested with:
- the RV64 generic default configuration
- RV64 K1-only and K3-only configurations
- the RV32 generic configuration, where SpacemiT platform objects are
intentionally omitted
- the K3 SDK split OpenSBI and U-Boot packaging flow
The public K3 SDK v1.0.7 components needed to reproduce the firmware build
are pinned at:
manifests:
https://github.com/spacemit-com/manifests
6d767b42fdbd759dc9511b8a13523c3de42aaa5a
scripts:
https://github.com/spacemit-com/scripts
96418825a37a1cf07d3275c13d9d3329934224f0
U-Boot:
https://github.com/spacemit-com/uboot-2022.10
676971d3a61f2583dfd53d8f7dfbc9607cea74b7
ESOS and esos-lite:
https://github.com/spacemit-com/esos
eaf9afd83b27583b9bcafe0153028b32219518f5
https://github.com/spacemit-com/esos-lite
df4b2665cd4f3af563538cb41ba85c85dd39de7c
The kernel and root filesystem are independent of this firmware build.
Any board-compatible kernel and root filesystem may be used, so neither is
pinned here. EDK II is not used in this fastboot path.
Before building U-Boot, update UART0 in
bsp-src/uboot-2022.10/arch/riscv/dts/k3.dtsi. This DT is passed to OpenSBI:
uart0: uart@d4017000 {
...
compatible = "spacemit,k1-uart", "intel,xscale-uart",
"ns16550";
...
};
The compatible order makes OpenSBI select UART_CAP_UUE and preserve
UART_IER_UUE (bit 6); matching only "ns16550" writes 0x00 to UART_IER and
stops serial output. Build U-Boot and use the FSBL, bootinfo, and U-Boot
FIT produced by the same SDK build:
K3_SDK_DIR=/path/to/k3-sdk
make -C "$K3_SDK_DIR" uboot
This produces the following files under output/k3/images:
FSBL.bin
bootinfo_spinor.bin
u-boot.itb
Build OpenSBI at the address used by the SDK, then wrap fw_dynamic.bin in
the SDK's standalone OpenSBI FIT:
make O=build-k3 CROSS_COMPILE=riscv64-linux-gnu- PLATFORM=generic \
PLATFORM_RISCV_ISA=rv64gc FW_TEXT_START=0x100000000
FW_DIR="$PWD/build-k3/platform/generic/firmware"
cp "$K3_SDK_DIR/bsp-src/opensbi/platform/generic/spacemit/fw_dynamic.its" \
"$FW_DIR/"
(cd "$FW_DIR" && \
"$K3_SDK_DIR/output/k3/build/uboot-custom/tools/mkimage" \
-f fw_dynamic.its fw_dynamic.itb)
There are two ways to enter U-Boot fastboot. On a provisioned board, hold
`s` during U-Boot startup and run:
=> fastboot 0
Alternatively, extract factory/FSBL.bin and u-boot.itb from
Bianbu-Minimal-K3-20260728010729.tar.gz. Hold FEL while resetting the
board to enter BROM fastboot, then run on the host:
fastboot stage factory/FSBL.bin
fastboot continue
sleep 8
fastboot stage u-boot.itb
fastboot continue
COM260 boots from SPI NOR and uses partition_4M.json from the Bianbu image
for its firmware layout. Select that MTD layout before writing a firmware
partition:
fastboot flash mtd partition_4M.json
If the installed FSBL and U-Boot already match the prerequisites above,
only the OpenSBI partition needs updating:
fastboot flash opensbi "$FW_DIR/fw_dynamic.itb"
fastboot reboot
For an older boot firmware, update the boot-chain components from the
pinned SDK build in the same fastboot session before rebooting:
SDK_IMAGES="$K3_SDK_DIR/output/k3/images"
fastboot flash bootinfo "$SDK_IMAGES/bootinfo_spinor.bin"
fastboot flash fsbl "$SDK_IMAGES/FSBL.bin"
fastboot flash uboot "$SDK_IMAGES/u-boot.itb"
fastboot flash opensbi "$FW_DIR/fw_dynamic.itb"
fastboot reboot
The full Bianbu Minimal image is only needed to initialize a board without
a usable system; this OpenSBI test does not otherwise depend on its Linux
or root filesystem images.
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
---
Changes in v3:
- select the HSM backend from the root compatible while preserving K1's
existing start and stop behavior
- start secondary harts on demand from the K3 HSM callback; remove the
cold-boot wake-all loop, WFI tables, and timeout
- perform PMA, cache, and H-extension setup before the common warm entry;
use the OpenSBI VMA and guest-translation fence helpers
- use assembler-safe constants shared by the C and assembly paths
- omit the 64-bit-only SpacemiT platform objects from RV32 builds
- clarify the boundary between the K3 HSM backend and ESOS services
- update the cover letter with the public SDK build and split NOR
validation procedure
- add Reviewed-by trailers from Bo Gan
- Link to v2: https://patch.msgid.link/20260818-spacemit-k3-v2-0-84cb7773a481@linux.spacemit.com
Changes in v2:
- correct the K3 PMACFG0 CSR number from 0xbc0 to 0x7de
- select the expected-trap handler per hart for heterogeneous H support
- move K1 and K3 per-hart setup out of cold_boot_allowed()
- split the generic and K1 fixes into standalone patches, growing the
series from three patches to five
- document X100/A100 ISA and VLEN differences and the homogeneous-core
audit
- document OpenSBI/U-Boot packaging, the UART compatible adjustment,
and the USB fastboot test procedure
- Link to v1: https://lore.kernel.org/r/20260724-spacemit-k3-v1-0-f0e49329feb8@linux.spacemit.com
---
Troy Mitchell (2):
lib: sbi: select expected trap handler per hart
platform: generic: spacemit: k1: move hart init to nascent hook
Xianbin Zhu (3):
platform: generic: spacemit: k1: rename cache flush operation
platform: generic: spacemit: k1: refactor platform support
platform: generic: spacemit: k3: add platform support
include/sbi/sbi_csr_detect.h | 4 +-
include/sbi/sbi_hart.h | 2 +-
lib/sbi/sbi_hart.c | 9 +-
lib/sbi/sbi_illegal_atomic.c | 4 +-
lib/sbi/sbi_unpriv.c | 6 +-
lib/utils/hsm/fdt_hsm_spacemit.c | 125 ++++++++++++++++++++------
platform/generic/Kconfig | 11 +++
platform/generic/configs/defconfig | 1 +
platform/generic/include/spacemit/common.h | 90 +++++++++++++++++++
platform/generic/include/spacemit/k1.h | 96 ++++----------------
platform/generic/include/spacemit/k3.h | 127 +++++++++++++++++++++++++++
platform/generic/include/spacemit/k3_asm.h | 16 ++++
platform/generic/include/spacemit/spacemit.h | 14 +++
platform/generic/spacemit/k1.c | 45 ++++------
platform/generic/spacemit/k3.c | 122 +++++++++++++++++++++++++
platform/generic/spacemit/k3_asm.S | 52 +++++++++++
platform/generic/spacemit/objects.mk | 5 ++
platform/generic/spacemit/spacemit.c | 36 ++++++++
18 files changed, 617 insertions(+), 148 deletions(-)
---
base-commit: c0f87f10d1bfb9e72a84ddfafb5604ee1bfe9d04
change-id: 20260723-spacemit-k3-84720a7be53d
Best regards,
--
Troy Mitchell <troy.mitchell@linux.spacemit.com>
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next reply other threads:[~2026-08-27 9:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 9:19 Troy Mitchell [this message]
2026-08-27 9:19 ` [PATCH v3 1/5] lib: sbi: select expected trap handler per hart Troy Mitchell
2026-08-31 2:21 ` Alvin Chang
2026-09-01 5:45 ` Troy Mitchell
2026-08-27 9:19 ` [PATCH v3 2/5] platform: generic: spacemit: k1: rename cache flush operation Troy Mitchell
2026-08-27 9:19 ` [PATCH v3 3/5] platform: generic: spacemit: k1: move hart init to nascent hook Troy Mitchell
2026-08-27 9:19 ` [PATCH v3 4/5] platform: generic: spacemit: k1: refactor platform support Troy Mitchell
2026-08-27 9:19 ` [PATCH v3 5/5] platform: generic: spacemit: k3: add " Troy Mitchell
[not found] ` <20260831200832.404000-1-valentin.haudiquet@canonical.com>
2026-08-31 20:07 ` [PATCH 1/3] platform: generic: spacemit: k3: de-vote cluster power-downs and ungate DMASYS before CCI enable Valentin Haudiquet
2026-09-01 2:25 ` Troy Mitchell
2026-08-31 20:07 ` [PATCH 2/3] platform: generic: spacemit: k3: override cold_boot_allowed for hart 0 only Valentin Haudiquet
2026-09-01 5:45 ` Troy Mitchell
2026-08-31 20:07 ` [PATCH 3/3] platform: generic: spacemit: k3: wake A100 core 8 for ESOS/RPMI services Valentin Haudiquet
2026-09-01 2:25 ` Troy Mitchell
2026-09-01 5:48 ` [PATCH 0/3] platform: generic: spacemit: k3: follow-up fixes Troy Mitchell
2026-09-02 8:41 ` Bo Gan
2026-09-02 9:38 ` Troy Mitchell
2026-09-02 11:42 ` Valentin Haudiquet
2026-09-01 22:41 ` [PATCH v3 0/5] platform: generic: spacemit: add K3 platform support Bo Gan
2026-09-02 5:51 ` Bo Gan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260827-spacemit-k3-v3-0-5d8dbb68539d@linux.spacemit.com \
--to=troy.mitchell@linux.spacemit.com \
--cc=anup@brainfault.org \
--cc=ganboing@gmail.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=opensbi@lists.infradead.org \
--cc=samuel.holland@sifive.com \
--cc=xianbin.zhu@linux.spacemit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox