Skip to contentSkip to conversation

arm: socfpga: Add Remote System Update (RSU) support

PATCH New [email protected] 1 participant 9 messages Jun 30

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover arm: socfpga: Add Remote System Update (RSU) support

From: Dinesh Maniyam <[email protected]>

This series adds Remote System Update (RSU) support for the Altera (Intel) SoCFPGA SoC64 family (Stratix 10, Agilex, N5X, Agilex5 and Agilex7m). RSU lets the application boot from one of several configuration images stored in QSPI NOR flash and recover to a known-good factory image when an update fails. The flash layout is described by a Sub-Partition Table (SPT) and a Configuration Pointer Block (CPB); U-Boot talks to the Secure Device Manager (SDM) over the mailbox, or via an SMC call when running on top of Arm Trusted Firmware.

The series is structured as small, individually buildable steps:

1. mailbox: the RSU SDM mailbox commands (prerequisite).
2. The core RSU library (session, SPT/CPB handling, QSPI low-level backend, SMC client) under arch/arm/mach-socfpga/.
3. An optional UCLASS_MISC driver-model anchor ("altr,socfpga-rsu") so the RSU session lives on a DT node rather than a file-scope variable.
4. The "rsu" console command plus documentation and a sandbox unit test.
5. Multiflash support (RSU spread across more than one QSPI device).
6. SPL multiboot SSBL selection and SSBL fallback.
7-8. Device-tree wiring: the DM anchor node for every SoC64 family and
the boot-partition label used by the label-based partition lookup.

The generic env/SPL hooks (env/sf.c, env/fat.c, common/spl/spl_mmc.c) use weak functions that default to existing behaviour and are only overridden when CONFIG_SOCFPGA_RSU_MULTIBOOT is enabled, so non-SoCFPGA boards are unaffected.

Built for all SoC64 defconfigs and verified on the U-Boot CI (world build, sandbox and qemu test suites all green). checkpatch reports no errors.

Dinesh Maniyam (8):
arm: socfpga: mailbox: Add RSU mailbox command support
arm: socfpga: Add Remote System Update (RSU) core library
misc: socfpga: Add RSU driver-model anchor device
cmd: socfpga: Add rsu command for Remote System Update
arm: socfpga: rsu: Add multiflash support
arm: socfpga: rsu: Add SPL multiboot SSBL selection
arm: dts: socfpga: rsu: Anchor RSU DM node across SoC64 families
arm: dts: socfpga: rsu: Label boot partition for label-based lookup

 MAINTAINERS                                   |    6 +
 arch/arm/dts/socfpga_agilex5-u-boot.dtsi      |    4 +
 arch/arm/dts/socfpga_agilex5_socdk.dts        |    2 +-
 arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi |   16 -
 arch/arm/dts/socfpga_n5x-u-boot.dtsi          |    4 +
 arch/arm/dts/socfpga_soc64_u-boot.dtsi        |    4 +
 .../dts/socfpga_stratix10_socdk-u-boot.dtsi   |    4 +
 arch/arm/mach-socfpga/Kconfig                 |   43 +
 arch/arm/mach-socfpga/Makefile                |   12 +
 .../mach-socfpga/include/mach/mailbox_s10.h   |   16 +
 arch/arm/mach-socfpga/include/mach/rsu.h      |  419 +++
 .../mach-socfpga/include/mach/rsu_flash_if.h  |   96 +
 arch/arm/mach-socfpga/include/mach/rsu_ll.h   |   94 +
 arch/arm/mach-socfpga/include/mach/rsu_misc.h |   65 +
 arch/arm/mach-socfpga/include/mach/rsu_s10.h  |   46 +
 arch/arm/mach-socfpga/include/mach/rsu_smc.h  |   14 +
 arch/arm/mach-socfpga/include/mach/rsu_spl.h  |   14 +
 arch/arm/mach-socfpga/include/mach/smc_s10.h  |   37 +
 .../include/mach/socfpga_rsu_dm.h             |   18 +
 arch/arm/mach-socfpga/mailbox_s10.c           |  141 +
 arch/arm/mach-socfpga/rsu.c                   | 1210 +++++++++
 arch/arm/mach-socfpga/rsu_ll_qspi.c           | 2402 +++++++++++++++++
 arch/arm/mach-socfpga/rsu_misc.c              |  854 ++++++
 arch/arm/mach-socfpga/rsu_s10.c               |  459 ++++
 arch/arm/mach-socfpga/rsu_spl.c               |  388 +++
 arch/arm/mach-socfpga/smc_rsu_s10.c           |  188 ++
 cmd/Kconfig                                   |   11 +
 cmd/Makefile                                  |    1 +
 cmd/socfpga_rsu.c                             | 1048 +++++++
 common/spl/spl_mmc.c                          |   24 +-
 configs/socfpga_agilex5_defconfig             |    2 +-
 configs/socfpga_agilex_defconfig              |    2 +-
 configs/socfpga_n5x_defconfig                 |    2 +
 configs/socfpga_stratix10_defconfig           |    2 +
 .../misc/altr,socfpga-rsu.yaml                |   41 +
 doc/usage/cmd/rsu.rst                         |  208 ++
 drivers/misc/Kconfig                          |   16 +
 drivers/misc/Makefile                         |    1 +
 drivers/misc/socfpga_rsu.c                    |   30 +
 env/fat.c                                     |   64 +-
 env/sf.c                                      |   33 +-
 include/env_internal.h                        |   11 +
 include/rsu_console.h                         |   14 +
 test/cmd/Makefile                             |    1 +
 test/cmd/socfpga_rsu.c                        |   59 +
 45 files changed, 8088 insertions(+), 38 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_flash_if.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_ll.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_misc.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_smc.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_spl.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/smc_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/socfpga_rsu_dm.h
 create mode 100644 arch/arm/mach-socfpga/rsu.c
 create mode 100644 arch/arm/mach-socfpga/rsu_ll_qspi.c
 create mode 100644 arch/arm/mach-socfpga/rsu_misc.c
 create mode 100644 arch/arm/mach-socfpga/rsu_s10.c
 create mode 100644 arch/arm/mach-socfpga/rsu_spl.c
 create mode 100644 arch/arm/mach-socfpga/smc_rsu_s10.c
 create mode 100644 cmd/socfpga_rsu.c
 create mode 100644 doc/device-tree-bindings/misc/altr,socfpga-rsu.yaml
 create mode 100644 doc/usage/cmd/rsu.rst
 create mode 100644 drivers/misc/socfpga_rsu.c
 create mode 100644 include/rsu_console.h
 create mode 100644 test/cmd/socfpga_rsu.c

base-commit: 77a48fa272161df9b778ffc09af814eec11cddd2

Signature · 1 line
2.43.7
#1 lore raw

PATCH 1/8 arm: socfpga: mailbox: Add RSU mailbox command support

From: Dinesh Maniyam <[email protected]>

Add the Secure Device Manager (SDM) mailbox commands used by the Remote System Update (RSU) feature on the Stratix 10 / Agilex family of SoCs:
GET_SUBPARTITION_TABLE, RSU_STATUS, RSU_UPDATE and QSPI_GET_DEVICE_INFO, together with their PSCI secure-world (_psci) variants. When CADENCE_QSPI is disabled the helpers return MBOX_FUNC_NOT_SUPPORTED.

Also add the RSU public headers (rsu.h, rsu_ll.h, rsu_misc.h, rsu_flash_if.h, rsu_s10.h, rsu_smc.h, smc_s10.h, socfpga_rsu_dm.h and rsu_console.h) describing the RSU session interface, the on-flash sub-partition table (SPT) / configuration pointer block (CPB) layout and the rsu_status_info structure the mailbox status command fills in.

---
 .../mach-socfpga/include/mach/mailbox_s10.h   |  13 +
 arch/arm/mach-socfpga/include/mach/rsu.h      | 419 ++++++++++++++++++
 .../mach-socfpga/include/mach/rsu_flash_if.h  |  96 ++++
 arch/arm/mach-socfpga/include/mach/rsu_ll.h   |  94 ++++
 arch/arm/mach-socfpga/include/mach/rsu_misc.h |  65 +++
 arch/arm/mach-socfpga/include/mach/rsu_s10.h  |  46 ++
 arch/arm/mach-socfpga/include/mach/rsu_smc.h  |  14 +
 arch/arm/mach-socfpga/include/mach/smc_s10.h  |  37 ++
 .../include/mach/socfpga_rsu_dm.h             |  18 +
 arch/arm/mach-socfpga/mailbox_s10.c           | 141 ++++++
 include/rsu_console.h                         |  14 +
 11 files changed, 957 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_flash_if.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_ll.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_misc.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_smc.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/smc_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/socfpga_rsu_dm.h
 create mode 100644 include/rsu_console.h
arch/arm/mach-socfpga/include/mach/mailbox_s10.h +13 -0
index 1a461de4819..5cb6ae4bcaf 100644
@@ -92,6 +92,8 @@ enum ALT_SDM_MBOX_RESP_CODE {
 	MBOX_RESP_TIMEOUT = 0xB,
 	/* HW (i.e. QSPI) is not ready (initialized or configured) */
 	MBOX_RESP_HW_NOT_RDY = 0xC,
+	/* Mailbox function not supported in this build (e.g. no QSPI) */
+	MBOX_FUNC_NOT_SUPPORTED = 0xF,
 	/* Invalid license for IID registration */
 	MBOX_RESP_PUF_ACCCES_FAILED = 0x80,
 	MBOX_PUF_ENROLL_DISABLE = 0x81,
@@ -128,7 +130,11 @@ enum ALT_SDM_MBOX_RESP_CODE {
 #define MBOX_QSPI_CLOSE		51
 #define MBOX_QSPI_DIRECT	59
 #define MBOX_REBOOT_HPS		71
+#define MBOX_GET_SUBPARTITION_TABLE	90
+#define MBOX_RSU_STATUS			91
+#define MBOX_RSU_UPDATE			92
 #define MBOX_HPS_STAGE_NOTIFY		93
+#define MBOX_QSPI_GET_DEVICE_INFO	116 /* get QSPI size and erasesize */
 
 /* Mailbox registers */
 #define MBOX_CIN			0	/* command valid offset */
@@ -405,4 +411,11 @@ int mbox_reset_cold(void);
 int mbox_hps_stage_notify(u32 execution_stage);
 int mbox_get_fpga_config_status(u32 cmd);
 int mbox_get_fpga_config_status_psci(u32 cmd);
+
+int mbox_qspi_get_device_info(u32 *resp_buf, u32 resp_buf_len);
+int mbox_rsu_get_spt_offset(u32 *resp_buf, u32 resp_buf_len);
+int mbox_rsu_status(u32 *resp_buf, u32 resp_buf_len);
+int mbox_rsu_status_psci(u32 *resp_buf, u32 resp_buf_len);
+int mbox_rsu_update(u32 *flash_offset);
+int mbox_rsu_update_psci(u32 *flash_offset);
 #endif /* _MAILBOX_S10_H_ */
arch/arm/mach-socfpga/include/mach/rsu.h new file +419 -0

419 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/rsu_flash_if.h new file +96 -0

96 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/rsu_ll.h new file +94 -0

94 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/rsu_misc.h new file +65 -0

65 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/rsu_s10.h new file +46 -0

46 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/rsu_smc.h new file +14 -0
new file mode 100644
index 00000000000..89b66ee0b05
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * SMC / PSCI-visible RSU state (secure RAM). Keep separate from rsu_s10.h so
+ * normal-world RSU code does not declare secure-only symbols.
+ */
+#ifndef __RSU_SMC_H__
+#define __RSU_SMC_H__
+
+#include <asm/types.h>
+#include <asm/secure.h>
+
+extern u32 smc_rsu_update_address __secure_data;
+
+#endif
arch/arm/mach-socfpga/include/mach/smc_s10.h new file +37 -0
new file mode 100644
index 00000000000..ba34b7c441f
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 Intel Corporation. All rights reserved
+ * Copyright (C) 2026 Altera Corporation <www.altera.com>
+ */
+
+#define SMC_ARG0		0
+#define SMC_ARG1		(SMC_ARG0 + 1)
+#define SMC_ARG2		(SMC_ARG1 + 1)
+#define SMC_ARG3		(SMC_ARG2 + 1)
+#define SMC_RETURN_ARGS_MAX	(SMC_ARG3 + 1)
+
+/*
+ * Macro functions for allocation and read/write of
+ * variables to be assigned to registers
+ */
+/* Allocate memory for variable */
+#define SMC_ALLOC_REG_MEM(var) unsigned long var[SMC_RETURN_ARGS_MAX]
+/* Clear variable */
+#define SMC_INIT_REG_MEM(var) \
+	do { \
+		int i; \
+		for (i = 0; i < SMC_RETURN_ARGS_MAX; i++) \
+			var[i] = 0; \
+	} while (0)
+/* Read variable */
+#define SMC_GET_REG_MEM(var, i) var[i]
+/* Write Variable */
+#define SMC_ASSIGN_REG_MEM(var, i, val) ((var)[i] = (val))
+/* Assign variables back to registers */
+#define SMC_RET_REG_MEM(var) \
+	asm volatile("ldr x0, %0\n" \
+		     "ldr x1, %1\n" \
+		     "ldr x2, %2\n" \
+		     "ldr x3, %3\n" \
+		     : : "m" (var[0]), "m" (var[1]), \
+			 "m" (var[2]), "m" (var[3]) :)
arch/arm/mach-socfpga/include/mach/socfpga_rsu_dm.h new file +18 -0
new file mode 100644
index 00000000000..05928f6aca0
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * SoC FPGA RSU driver model (UCLASS_MISC) private data.
+ */
+#ifndef __SOCFPGA_RSU_DM_H__
+#define __SOCFPGA_RSU_DM_H__
+
+#include <asm/arch/rsu_ll.h>
+
+/**
+ * struct socfpga_rsu_priv - per-DM-device RSU session anchor
+ * @ll: active low-level interface while a console session holds the device
+ */
+struct socfpga_rsu_priv {
+	struct rsu_ll_intf *ll;
+};
+
+#endif /* __SOCFPGA_RSU_DM_H__ */
arch/arm/mach-socfpga/mailbox_s10.c +141 -0

159 lines not on this page · raw message

include/rsu_console.h new file +14 -0
new file mode 100644
index 00000000000..4e851069183
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2026 Altera Corporation <www.altera.com>
+ *
+ * Public prototypes for SoC FPGA RSU console-helper functions.
+ */
+#ifndef _RSU_CONSOLE_H_
+#define _RSU_CONSOLE_H_
+
+int rsu_spt_cpb_list(int argc, char * const argv[]);
+int rsu_update(int argc, char * const argv[]);
+int rsu_dtb(int argc, char * const argv[]);
+
+#endif /* _RSU_CONSOLE_H_ */
Signature · 1 line
2.43.7
#2 lore raw

PATCH 2/8 arm: socfpga: Add Remote System Update (RSU) core library

In reply to [email protected]

From: Dinesh Maniyam <[email protected]>

Add the RSU core library for the Stratix 10 / Agilex family of SoCs. RSU lets the SoC boot from one of several configuration images held in SPI NOR flash and recover to a known-good factory image when an update fails. The feature is implemented in the SDM firmware and the on-board Cadence QSPI flash; this library drives it through the SDM mailbox (or an SMC call when running on top of Arm Trusted Firmware) and the SPI-NOR framework.

The library is split into the generic session/command layer (rsu.c), the helper and SPT/CPB logic (rsu_misc.c), the QSPI low-level backend (rsu_ll_qspi.c, rsu_s10.c) and the optional secure-monitor SMC handler (smc_rsu_s10.c, built only with ARMV8_PSCI). The decision-firmware version/status copy paths select the SMC client form under SPL_ATF, the secure-RAM form when U-Boot is itself the monitor (ARMV8_PSCI), and are a no-op otherwise.

Add the CMD_SOCFPGA_RSU and SOCFPGA_RSU_SF_CS Kconfig symbols that gate the library and select the RSU SPT/CPB chip-select. The objects are built for U-Boot proper only.

---
 arch/arm/mach-socfpga/Kconfig       |   12 +
 arch/arm/mach-socfpga/Makefile      |    7 +
 arch/arm/mach-socfpga/rsu.c         | 1210 ++++++++++++++
 arch/arm/mach-socfpga/rsu_ll_qspi.c | 2402 +++++++++++++++++++++++++++
 arch/arm/mach-socfpga/rsu_misc.c    |  854 ++++++++++
 arch/arm/mach-socfpga/rsu_s10.c     |  459 +++++
 arch/arm/mach-socfpga/smc_rsu_s10.c |  188 +++
 cmd/Kconfig                         |   11 +
 8 files changed, 5143 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/rsu.c
 create mode 100644 arch/arm/mach-socfpga/rsu_ll_qspi.c
 create mode 100644 arch/arm/mach-socfpga/rsu_misc.c
 create mode 100644 arch/arm/mach-socfpga/rsu_s10.c
 create mode 100644 arch/arm/mach-socfpga/smc_rsu_s10.c
arch/arm/mach-socfpga/Kconfig +12 -0
index fb98b647442..ff961e7f13c 100644
@@ -6,6 +6,18 @@ config ERR_PTR_OFFSET
 config NR_DRAM_BANKS
 	default 1
 
+config SOCFPGA_RSU_SF_CS
+	int "SPI flash chip-select used by the RSU flow (SPT/CPB)"
+	depends on CMD_SOCFPGA_RSU
+	depends on SPI_FLASH || DM_SPI_FLASH
+	default SF_DEFAULT_CS
+	help
+	  Chip select of the SPI flash that holds the RSU sub-partition
+	  table (SPT) and configuration pointer block (CPB) metadata.
+	  Independent from SF_DEFAULT_CS (which selects the flash SPL
+	  loads u-boot.itb from). Override only when RSU metadata lives
+	  on a different chip select than the u-boot.itb boot image.
+
 config SOCFPGA_SECURE_VAB_AUTH
 	bool "Enable boot image authentication with Secure Device Manager"
 	depends on ARCH_SOCFPGA_AGILEX || ARCH_SOCFPGA_N5X || \
arch/arm/mach-socfpga/Makefile +7 -0
index b6f35ddacc4..109af31ceb8 100644
@@ -138,6 +138,13 @@ endif
 else
 obj-$(CONFIG_SPL_ATF) += secure_reg_helper.o
 obj-$(CONFIG_SPL_ATF) += smc_api.o
+ifdef CONFIG_CMD_SOCFPGA_RSU
+obj-y	+= rsu.o
+obj-y	+= rsu_misc.o
+obj-y	+= rsu_ll_qspi.o
+obj-y	+= rsu_s10.o
+obj-$(CONFIG_ARMV8_PSCI)	+= smc_rsu_s10.o
+endif
 endif
 
 ifdef CONFIG_ARCH_SOCFPGA_GEN5
arch/arm/mach-socfpga/rsu.c new file +1210 -0

1,210 lines not on this page · raw message

arch/arm/mach-socfpga/rsu_ll_qspi.c new file +2402 -0

1,759 lines not on this page · raw message

arch/arm/mach-socfpga/rsu_misc.c new file +854 -0

854 lines not on this page · raw message

arch/arm/mach-socfpga/rsu_s10.c new file +459 -0

459 lines not on this page · raw message

arch/arm/mach-socfpga/smc_rsu_s10.c new file +188 -0

188 lines not on this page · raw message

cmd/Kconfig +11 -0
index c71c6824a19..67b035729f2 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.7

Part of the diff is not shown here. View the raw message.

#3 lore raw

PATCH 3/8 misc: socfpga: Add RSU driver-model anchor device

In reply to [email protected]

From: Dinesh Maniyam <[email protected]>

Add a UCLASS_MISC driver bound to the "altr,socfpga-rsu" compatible. The RSU command layer stores its active low-level session on this device's private data, so the session state lives on a driver-model device rather than in a file-scope variable.

The anchor has no MMIO and no flash-controller coupling of its own; the QSPI flash requirement is enforced by CMD_SOCFPGA_RSU, the only consumer of the device. Add the binding document and the devicetree node in socfpga_soc64_u-boot.dtsi, and the SOCFPGA_RSU_DM Kconfig symbol (default y, selected together with the command).

---
 arch/arm/dts/socfpga_soc64_u-boot.dtsi        |  5 +++
 .../misc/altr,socfpga-rsu.yaml                | 41 +++++++++++++++++++
 drivers/misc/Kconfig                          | 16 ++++++++
 drivers/misc/Makefile                         |  1 +
 drivers/misc/socfpga_rsu.c                    | 30 ++++++++++++++
 5 files changed, 93 insertions(+)
 create mode 100644 doc/device-tree-bindings/misc/altr,socfpga-rsu.yaml
 create mode 100644 drivers/misc/socfpga_rsu.c
arch/arm/dts/socfpga_soc64_u-boot.dtsi +5 -0
index ce5b37ef547..5ec3c0662e3 100644
@@ -7,6 +7,11 @@
 
 / {
 	soc@0 {
+		socfpga-rsu {
+			compatible = "altr,socfpga-rsu";
+			bootph-all;
+		};
+
 		socfpga-system-mgr-firewall {
 			compatible = "intel,socfpga-dtreg";
 			#address-cells = <1>;
doc/device-tree-bindings/misc/altr,socfpga-rsu.yaml new file +41 -0

41 lines not on this page · raw message

drivers/misc/Kconfig +16 -0
index ea785793d18..42bd08e038d 100644
@@ -66,6 +66,22 @@ config ALTERA_SYSID
 	  Select this to enable a sysid for Altera devices. Please find
 	  details on the "Embedded Peripherals IP User Guide" of Altera.
 
+config SOCFPGA_RSU_DM
+	bool "Altera SoC FPGA RSU driver-model anchor device"
+	depends on MISC
+	depends on OF_CONTROL
+	depends on CMD_SOCFPGA_RSU
+	default y
+	help
+	  Expose RSU as a devicetree-bound UCLASS_MISC device
+	  (altr,socfpga-rsu). The RSU command layer stores its active
+	  low-level session on this device; ensure the altr,socfpga-rsu
+	  node is present in the U-Boot DTS.
+
+	  This anchor driver has no MMIO and no flash-controller coupling
+	  of its own; the QSPI flash requirement is enforced by
+	  CMD_SOCFPGA_RSU (the only consumer of this device).
+
 config ATSHA204A
 	bool "Support for Atmel ATSHA204A module"
 	select BITREVERSE
drivers/misc/Makefile +1 -0
index e2170212e5a..1d26cf58284 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_SANDBOX) += spltest_sandbox.o
 endif
 endif
 obj-$(CONFIG_ALTERA_SYSID) += altera_sysid.o
+obj-$(CONFIG_SOCFPGA_RSU_DM) += socfpga_rsu.o
 obj-$(CONFIG_ATSHA204A) += atsha204a-i2c.o
 obj-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
 obj-$(CONFIG_FSL_DEVICE_DISABLE) += fsl_devdis.o
drivers/misc/socfpga_rsu.c new file +30 -0
new file mode 100644
index 00000000000..6e7d7ffc072
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2026 Altera Corporation <www.altera.com>
+ *
+ * SoC FPGA Remote System Update — driver model binding (UCLASS_MISC).
+ */
+
+#include <dm.h>
+#include <asm/arch/socfpga_rsu_dm.h>
+
+static int socfpga_rsu_probe(struct udevice *dev)
+{
+	struct socfpga_rsu_priv *priv = dev_get_priv(dev);
+
+	priv->ll = NULL;
+	return 0;
+}
+
+static const struct udevice_id socfpga_rsu_ids[] = {
+	{ .compatible = "altr,socfpga-rsu" },
+	{ }
+};
+
+U_BOOT_DRIVER(socfpga_rsu) = {
+	.name		= "socfpga_rsu",
+	.id		= UCLASS_MISC,
+	.of_match	= socfpga_rsu_ids,
+	.probe		= socfpga_rsu_probe,
+	.priv_auto	= sizeof(struct socfpga_rsu_priv),
+};
Signature · 1 line
2.43.7
#4 lore raw

PATCH 4/8 cmd: socfpga: Add rsu command for Remote System Update

In reply to [email protected]

From: Dinesh Maniyam <[email protected]>

Add the "rsu" command exposing the RSU core library to the user: list and inspect flash slots, manage and program configuration slots, trigger firmware updates, query DCMF version/status and max_retry, and maintain the sub-partition table (SPT) and configuration pointer block (CPB).

Add a sandbox unit test covering the usage and argument-parsing paths, command documentation under doc/usage/cmd/rsu.rst, and a MAINTAINERS entry for the RSU files not already covered by the SoCFPGA globs. Enable CMD_SOCFPGA_RSU in the agilex5, agilex, n5x and stratix10 defconfigs.

---
 MAINTAINERS                         |    6 +
 cmd/Makefile                        |    1 +
 cmd/socfpga_rsu.c                   | 1048 +++++++++++++++++++++++++++
 configs/socfpga_agilex5_defconfig   |    2 +-
 configs/socfpga_agilex_defconfig    |    2 +-
 configs/socfpga_n5x_defconfig       |    2 +
 configs/socfpga_stratix10_defconfig |    2 +
 doc/usage/cmd/rsu.rst               |  208 ++++++
 test/cmd/Makefile                   |    1 +
 test/cmd/socfpga_rsu.c              |   59 ++
 10 files changed, 1329 insertions(+), 2 deletions(-)
 create mode 100644 cmd/socfpga_rsu.c
 create mode 100644 doc/usage/cmd/rsu.rst
 create mode 100644 test/cmd/socfpga_rsu.c
MAINTAINERS +6 -0
index 571af196465..ce248c58b4d 100644
@@ -169,10 +169,16 @@ T:	git https://source.denx.de/u-boot/custodians/u-boot-socfpga.git
 F:	arch/arm/dts/socfpga_*
 F:	arch/arm/mach-socfpga/
 F:	board/intel/agilex-socdk/
+F:	cmd/socfpga_rsu.c
 F:	configs/socfpga_*
+F:	doc/device-tree-bindings/misc/altr,socfpga-rsu.yaml
+F:	doc/usage/cmd/rsu.rst
 F:	drivers/ddr/altera/
+F:	drivers/misc/socfpga_rsu.c
 F:	drivers/power/domain/altr-pmgr-agilex5.c
 F:	drivers/sysreset/sysreset_socfpga*
+F:	include/rsu_console.h
+F:	test/cmd/socfpga_rsu.c
 
 ARM AMLOGIC SOC SUPPORT
 M:	Neil Armstrong <[email protected]>
cmd/Makefile +1 -0
index bbbdfcc4ded..647f83a6263 100644
@@ -90,6 +90,7 @@ obj-$(CONFIG_CMD_FPGA) += fpga.o
 obj-$(CONFIG_CMD_FPGAD) += fpgad.o
 obj-$(CONFIG_CMD_FS_GENERIC) += fs.o
 obj-$(CONFIG_CMD_FUSE) += fuse.o
+obj-$(CONFIG_CMD_SOCFPGA_RSU) += socfpga_rsu.o
 obj-$(CONFIG_CMD_FWU_METADATA) += fwu_mdata.o
 obj-$(CONFIG_CMD_GETTIME) += gettime.o
 obj-$(CONFIG_CMD_GPIO) += gpio.o
cmd/socfpga_rsu.c new file +1048 -0

1,048 lines not on this page · raw message

configs/socfpga_agilex5_defconfig +1 -1
index 530eb229f3e..9e7f8407b7b 100644
@@ -57,6 +57,7 @@ CONFIG_SYS_PROMPT="SOCFPGA_AGILEX5 # "
 CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_NVEDIT_SELECT=y
 CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_SOCFPGA_RSU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_I3C=y
@@ -84,7 +85,6 @@ CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
 CONFIG_I3C=y
 CONFIG_DW_I3C_MASTER=y
-CONFIG_MISC=y
 CONFIG_MMC_IO_VOLTAGE=y
 CONFIG_SPL_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
configs/socfpga_agilex_defconfig +1 -1
index ba8dc821add..6e705ff0312 100644
@@ -48,6 +48,7 @@ CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
 CONFIG_SYS_PROMPT="SOCFPGA_AGILEX # "
 CONFIG_CMD_NVEDIT_SELECT=y
 CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_SOCFPGA_RSU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
@@ -70,7 +71,6 @@ CONFIG_SPL_ALTERA_SDRAM=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
-CONFIG_MISC=y
 CONFIG_SYS_MMC_MAX_BLK_COUNT=256
 CONFIG_MMC_DW=y
 CONFIG_DM_MTD=y
configs/socfpga_n5x_defconfig +2 -0
index 3b3916e676d..7ad3b53cb6d 100644
@@ -43,6 +43,7 @@ CONFIG_SPL_TARGET="spl/u-boot-spl-dtb.hex"
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="SOCFPGA_N5X # "
 CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_SOCFPGA_RSU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
@@ -65,6 +66,7 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
+# CONFIG_SPL_MISC is not set
 CONFIG_SYS_MMC_MAX_BLK_COUNT=256
 CONFIG_MMC_DW=y
 CONFIG_SPI_FLASH_SPANSION=y
configs/socfpga_stratix10_defconfig +2 -0
index 7b04859dec7..7f7958627e8 100644
@@ -47,6 +47,7 @@ CONFIG_SPL_TARGET="spl/u-boot-spl-dtb.hex"
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="SOCFPGA_STRATIX10 # "
 CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_SOCFPGA_RSU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
@@ -70,6 +71,7 @@ CONFIG_SPL_ALTERA_SDRAM=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
+# CONFIG_SPL_MISC is not set
 CONFIG_SYS_MMC_MAX_BLK_COUNT=256
 CONFIG_MMC_DW=y
 CONFIG_SPI_FLASH_SPANSION=y
doc/usage/cmd/rsu.rst new file +208 -0

208 lines not on this page · raw message

test/cmd/Makefile +1 -0
index 8d6932f1176..63e1302af00 100644
@@ -48,4 +48,5 @@ endif
 obj-$(CONFIG_CMD_SPAWN) += spawn.o
 ifdef CONFIG_CMD_ZIP
 obj-$(CONFIG_CMD_UNZIP) += unzip.o
+obj-$(CONFIG_CMD_SOCFPGA_RSU) += socfpga_rsu.o
 endif
test/cmd/socfpga_rsu.c new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.43.7
#5 lore raw

PATCH 5/8 arm: socfpga: rsu: Add multiflash support

In reply to [email protected]

From: Dinesh Maniyam <[email protected]>

Add the SOCFPGA_RSU_MULTIFLASH option to let the QSPI low-level RSU backend span the sub-partition layout across more than one SPI flash device. When enabled, rsu_ll_qspi_init() queries the Secure Device Manager via the QSPI get-device-info mailbox command to discover the number and size of attached flash devices and probes each enabled chip select; otherwise it falls back to the single-flash path.

Add the QSPI_GET_DEVICE_INFO_RESP_LEN definition used by the device info decode, and rename the integer power helper from the libm-clashing pow() to rsu_pow() since it is RSU-internal and only consumed by the multiflash flash-size calculation.

---
 arch/arm/mach-socfpga/Kconfig                    | 10 ++++++++++
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  3 +++
 arch/arm/mach-socfpga/include/mach/rsu_misc.h    |  2 +-
 arch/arm/mach-socfpga/rsu_ll_qspi.c              |  2 +-
 arch/arm/mach-socfpga/rsu_misc.c                 |  6 +++---
 5 files changed, 18 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/Kconfig +10 -0
index ff961e7f13c..e9d675344f7 100644
@@ -18,6 +18,16 @@ config SOCFPGA_RSU_SF_CS
 	  loads u-boot.itb from). Override only when RSU metadata lives
 	  on a different chip select than the u-boot.itb boot image.
 
+config SOCFPGA_RSU_MULTIFLASH
+	bool "Enable RSU multiflash support"
+	depends on CMD_SOCFPGA_RSU
+	help
+	  Allow the RSU flow to operate across multiple SPI flash devices.
+	  When enabled, the QSPI low-level backend queries the Secure Device
+	  Manager for the number and size of the attached flash devices and
+	  spans the RSU sub-partition layout across all of them. Leave
+	  disabled for the common single-flash layout.
+
 config SOCFPGA_SECURE_VAB_AUTH
 	bool "Enable boot image authentication with Secure Device Manager"
 	depends on ARCH_SOCFPGA_AGILEX || ARCH_SOCFPGA_N5X || \
arch/arm/mach-socfpga/include/mach/mailbox_s10.h +3 -0
index 5cb6ae4bcaf..ead9e510bac 100644
@@ -136,6 +136,9 @@ enum ALT_SDM_MBOX_RESP_CODE {
 #define MBOX_HPS_STAGE_NOTIFY		93
 #define MBOX_QSPI_GET_DEVICE_INFO	116 /* get QSPI size and erasesize */
 
+/* Response length (in words) of the QSPI get-device-info command */
+#define QSPI_GET_DEVICE_INFO_RESP_LEN	8
+
 /* Mailbox registers */
 #define MBOX_CIN			0	/* command valid offset */
 #define MBOX_ROUT			4	/* response output offset */
arch/arm/mach-socfpga/include/mach/rsu_misc.h +1 -1
index 7777d652912..6d2c8f90367 100644
@@ -61,5 +61,5 @@ void rsu_log(const enum rsu_log_level level, const char *format, ...);
 int smc_store_max_retry(u32 value);
 
 void swap_bits(char *data, int size);
-int pow(u32 x, u32 y);
+int rsu_pow(u32 x, u32 y);
 #endif
arch/arm/mach-socfpga/rsu_ll_qspi.c +1 -1
index 423df4dd676..11bd80a6eca 100644
@@ -2258,7 +2258,7 @@ int get_num_flash(u32 *flash_enabled)
 		if (mbox_flash_info[i].size > SZ_2G) {
 			/* >2Gb, power the bit 0-30 */
 			debug("RSU: QSPI %d larger than 2Gbits capacity.", i);
-			flash_enabled[i] = pow(2, mbox_flash_info[i].size & GENMASK(30, 0));
+			flash_enabled[i] = rsu_pow(2, mbox_flash_info[i].size & GENMASK(30, 0));
 			flash_enabled[i] = flash_enabled[i] / SZ_8;
 		} else {
 			/* <= 2Gb, total the bit 0-30 */
arch/arm/mach-socfpga/rsu_misc.c +3 -3
index 50a744d162e..6d34d0d2632 100644
@@ -135,14 +135,14 @@ void swap_bits(char *data, int len)
 	}
 }
 
-int pow(u32 x, u32 y)
+int rsu_pow(u32 x, u32 y)
 {
 	if (y == 0)
 		return 1;
 	else if ((y % 2) == 0)
-		return pow(x, y / 2) * pow(x, y / 2);
+		return rsu_pow(x, y / 2) * rsu_pow(x, y / 2);
 	else
-		return x * pow(x, y / 2) * pow(x, y / 2);
+		return x * rsu_pow(x, y / 2) * rsu_pow(x, y / 2);
 }
 
 /**
Signature · 1 line
2.43.7
#6 lore raw

PATCH 6/8 arm: socfpga: rsu: Add SPL multiboot SSBL selection

In reply to [email protected]

From: Dinesh Maniyam <[email protected]>

Add the SOCFPGA_RSU_MULTIBOOT feature so the SPL selects the U-Boot proper (SSBL) image, environment and FIT that pair with the RSU sub-partition the SPL itself booted from. rsu_spl.c reads the RSU sub-partition table (SPT), locates the SSBL.<slot> partition matching the running SPL slot and exposes:

  - spl_spi_get_uboot_offs()  : SSBL offset for SPI boot,
  - rsu_spl_mmc_filename()    : u-boot_<slot>.itb/.img for FAT/MMC boot,
  - rsu_spl_mmc_env_name()    : matching environment file name,
  - env_sf_get_env_offset()   : environment offset within the SSBL slot.

The generic SPL/env code grows small, default-off hooks for this:
spl_mmc.c and env/fat.c call weak filename helpers (default -ENOENT, overridden by rsu_spl.c), and env/sf.c gains a weak env_sf_get_env_offset() helper (default CONFIG_ENV_OFFSET) so the SPI environment offset can be computed at runtime instead of redefining the CONFIG symbol.

SPL_SOCFPGA_RSU_SSBL_FALLBACK bounds the SSBL slot size used when the SPT lookup fails so the environment-offset math cannot underflow.

---
 arch/arm/mach-socfpga/Kconfig                |  21 +
 arch/arm/mach-socfpga/Makefile               |   5 +
 arch/arm/mach-socfpga/include/mach/rsu_spl.h |  14 +
 arch/arm/mach-socfpga/rsu_spl.c              | 388 +++++++++++++++++++
 common/spl/spl_mmc.c                         |  24 +-
 env/fat.c                                    |  64 ++-
 env/sf.c                                     |  33 +-
 include/env_internal.h                       |  11 +
 8 files changed, 541 insertions(+), 19 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/rsu_spl.h
 create mode 100644 arch/arm/mach-socfpga/rsu_spl.c
arch/arm/mach-socfpga/Kconfig +21 -0
index e9d675344f7..889dcc825b0 100644
@@ -28,6 +28,27 @@ config SOCFPGA_RSU_MULTIFLASH
 	  spans the RSU sub-partition layout across all of them. Leave
 	  disabled for the common single-flash layout.
 
+config SOCFPGA_RSU_MULTIBOOT
+	bool "Enable RSU SPL multiboot SSBL selection"
+	depends on ARCH_SOCFPGA_SOC64 && SPL && SPI_FLASH
+	help
+	  Select the second-stage boot loader (SSBL, i.e. U-Boot proper)
+	  image based on the RSU sub-partition the SPL was loaded from.
+	  SPL reads the RSU sub-partition table (SPT) to locate the SSBL
+	  partition that pairs with the currently running SPL image and
+	  loads U-Boot proper, its environment and FIT from there. This
+	  keeps a multi-image RSU layout self-consistent across updates.
+
+config SPL_SOCFPGA_RSU_SSBL_FALLBACK
+	int "RSU SPL fallback SSBL slot size (MiB)"
+	depends on SOCFPGA_RSU_MULTIBOOT
+	default 8
+	range 1 64
+	help
+	  Conservative upper bound (in MiB) for the SSBL slot used when the
+	  SPT lookup fails, so the environment-offset math in env/sf.c cannot
+	  underflow. Override only if the board's SSBL exceeds the default.
+
 config SOCFPGA_SECURE_VAB_AUTH
 	bool "Enable boot image authentication with Secure Device Manager"
 	depends on ARCH_SOCFPGA_AGILEX || ARCH_SOCFPGA_N5X || \
arch/arm/mach-socfpga/Makefile +5 -0
index 109af31ceb8..14410cee149 100644
@@ -147,6 +147,11 @@ obj-$(CONFIG_ARMV8_PSCI)	+= smc_rsu_s10.o
 endif
 endif
 
+# RSU SPL multiboot selects the SSBL (U-Boot proper) image to load; the
+# helpers are consumed from both SPL (spl_mmc/spl_spi) and U-Boot proper
+# (env/fat, env/sf), so build for both.
+obj-$(CONFIG_SOCFPGA_RSU_MULTIBOOT)	+= rsu_spl.o
+
 ifdef CONFIG_ARCH_SOCFPGA_GEN5
 # QTS-generated config file wrappers
 CFLAGS_wrap_iocsr_config.o	+= -I$(srctree)/board/$(BOARDDIR)
arch/arm/mach-socfpga/include/mach/rsu_spl.h new file +14 -0
new file mode 100644
index 00000000000..c9507b4d934
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2022-2023 Intel Corporation <www.intel.com>
+ */
+
+#ifndef _RSU_S10_SPL_H_
+#define _RSU_S10_SPL_H_
+
+#include <asm/arch/rsu_s10.h>
+
+u32 rsu_spl_ssbl_address(bool is_qspi_imge_check);
+u32 rsu_spl_ssbl_size(bool is_qspi_imge_check);
+
+#endif /* _RSU_S10_SPL_H_ */
arch/arm/mach-socfpga/rsu_spl.c new file +388 -0

388 lines not on this page · raw message

common/spl/spl_mmc.c +23 -1
index cc16709dc9b..e4002591605 100644
@@ -11,6 +11,7 @@
 #include <spl.h>
 #include <spl_load.h>
 #include <linux/compiler.h>
+#include <linux/sizes.h>
 #include <errno.h>
 #include <mmc.h>
 #include <image.h>
@@ -456,11 +457,32 @@ int spl_mmc_load(struct spl_image_info *spl_image,
 	return ret;
 }
 
+#if IS_ENABLED(CONFIG_SOCFPGA_RSU_MULTIBOOT)
+__weak int rsu_spl_mmc_filename(char *filename, int max_size)
+{
+	return -ENOENT;
+}
+#endif
+
 int spl_mmc_load_image(struct spl_image_info *spl_image,
 		       struct spl_boot_device *bootdev)
 {
+#if IS_ENABLED(CONFIG_SOCFPGA_RSU_MULTIBOOT)
+	char filename[SZ_256] = {0};
+	int ret;
+
+	ret = rsu_spl_mmc_filename(filename, SZ_256);
+	if (ret) {
+		printf("RSU: multiboot filename not found\n");
+		return ret;
+	}
+
+	printf("%s: boot from filename: %s\n", __func__, filename);
+#endif
 	return spl_mmc_load(spl_image, bootdev,
-#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
+#if IS_ENABLED(CONFIG_SOCFPGA_RSU_MULTIBOOT)
+			    filename,
+#elif defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)
 			    CONFIG_SPL_FS_LOAD_PAYLOAD_NAME,
 #else
 			    NULL,
env/fat.c +57 -7

113 lines not on this page · raw message

env/sf.c +22 -11
index 14c35324e64..6cdb0e4a632 100644
@@ -38,6 +38,17 @@ static ulong env_new_offset	= CONFIG_ENV_OFFSET_REDUND;
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/*
+ * Offset of the primary environment within the SPI flash. Defaults to the
+ * static CONFIG_ENV_OFFSET, but boards may override this weak helper to
+ * compute the offset at runtime (e.g. RSU multiboot derives it from the
+ * SSBL slot the SPL booted from).
+ */
+__weak u32 env_sf_get_env_offset(void)
+{
+	return CONFIG_ENV_OFFSET;
+}
+
 __weak int spi_get_env_dev(void)
 {
 #ifdef CONFIG_ENV_SPI_BUS
@@ -98,9 +109,9 @@ static int env_sf_save(void)
 
 	if (gd->env_valid == ENV_VALID) {
 		env_new_offset = CONFIG_ENV_OFFSET_REDUND;
-		env_offset = CONFIG_ENV_OFFSET;
+		env_offset = env_sf_get_env_offset();
 	} else {
-		env_new_offset = CONFIG_ENV_OFFSET;
+		env_new_offset = env_sf_get_env_offset();
 		env_offset = CONFIG_ENV_OFFSET_REDUND;
 	}
 
@@ -182,7 +193,7 @@ static int env_sf_load(void)
 	if (ret)
 		goto out;
 
-	read1_fail = spi_flash_read(env_flash, CONFIG_ENV_OFFSET,
+	read1_fail = spi_flash_read(env_flash, env_sf_get_env_offset(),
 				    CONFIG_ENV_SIZE, tmp_env1);
 	read2_fail = spi_flash_read(env_flash, CONFIG_ENV_OFFSET_REDUND,
 				    CONFIG_ENV_SIZE, tmp_env2);
@@ -217,7 +228,7 @@ static int env_sf_save(void)
 	/* Is the sector larger than the env (i.e. embedded) */
 	if (sect_size > CONFIG_ENV_SIZE) {
 		saved_size = sect_size - CONFIG_ENV_SIZE;
-		saved_offset = CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE;
+		saved_offset = env_sf_get_env_offset() + CONFIG_ENV_SIZE;
 		saved_buffer = malloc(saved_size);
 		if (!saved_buffer) {
 			ret = -ENOMEM;
@@ -237,14 +248,14 @@ static int env_sf_save(void)
 	sector = DIV_ROUND_UP(CONFIG_ENV_SIZE, sect_size);
 
 	puts("Erasing SPI flash...");
-	ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET,
-		sector * sect_size);
+	ret = spi_flash_erase(env_flash, env_sf_get_env_offset(),
+			      sector * sect_size);
 	if (ret)
 		goto done;
 
 	puts("Writing to SPI flash...");
-	ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET,
-		CONFIG_ENV_SIZE, &env_new);
+	ret = spi_flash_write(env_flash, env_sf_get_env_offset(),
+			      CONFIG_ENV_SIZE, &env_new);
 	if (ret)
 		goto done;
 
@@ -284,7 +295,7 @@ static int env_sf_load(void)
 		goto out;
 
 	ret = spi_flash_read(env_flash,
-		CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, buf);
+		env_sf_get_env_offset(), CONFIG_ENV_SIZE, buf);
 	if (ret) {
 		env_set_default("spi_flash_read() failed", 0);
 		goto err_read;
@@ -314,7 +325,7 @@ static int env_sf_erase(void)
 		return ret;
 
 	memset(&env, 0, sizeof(env_t));
-	ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, &env);
+	ret = spi_flash_write(env_flash, env_sf_get_env_offset(), CONFIG_ENV_SIZE, &env);
 	if (ret)
 		goto done;
 
@@ -391,7 +402,7 @@ static int env_sf_init_early(void)
 	if (ret)
 		goto out;
 
-	read1_fail = spi_flash_read(env_flash, CONFIG_ENV_OFFSET,
+	read1_fail = spi_flash_read(env_flash, env_sf_get_env_offset(),
 				    CONFIG_ENV_SIZE, tmp_env1);
 
 	if (IS_ENABLED(CONFIG_ENV_REDUNDANT)) {
include/env_internal.h +11 -0
index 0589c435e84..8ce200fd6f1 100644
@@ -273,6 +273,17 @@ const char *env_fat_get_intf(void);
  * Return: string of device and partition
  */
 char *env_fat_get_dev_part(void);
+
+/**
+ * env_sf_get_env_offset() - Provide the offset of the env in SPI flash
+ *
+ * It is a weak function allowing boards to override the default offset of
+ * the U-Boot environment in SPI flash (CONFIG_ENV_OFFSET) with a value
+ * computed at runtime, e.g. derived from the RSU multiboot SSBL slot.
+ *
+ * Return: byte offset of the primary environment within the SPI flash
+ */
+u32 env_sf_get_env_offset(void);
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENV_INTERNAL_H_ */
Signature · 1 line
2.43.7
#7 lore raw

PATCH 7/8 arm: dts: socfpga: rsu: Anchor RSU DM node across SoC64 families

In reply to [email protected]

From: Dinesh Maniyam <[email protected]>

The RSU driver-model anchor ("altr,socfpga-rsu") is consumed only by the U-Boot-proper console command, never by SPL. It was previously present only for Agilex, via the socfpga-rsu node under soc@0 in socfpga_soc64_u-boot.dtsi.

The other SoC64 families assemble their devicetree under a "soc" node and pull in only the FIT image overlay (socfpga_soc64_fit-u-boot.dtsi), which carries no SoC nodes, so the anchor never reached them. With CONFIG_SOCFPGA_RSU_DM=y that left rsu_init() returning -ENODEV on Agilex5, Stratix10 and N5X even though the RSU command is enabled there.

Add the anchor node to the Agilex5, N5X and Stratix10 U-Boot devicetree overlays, and drop bootph-all from the Agilex node so the anchor is not carried into the pre-relocation/SPL devicetree; it is only needed by the proper-only console command.

---
 arch/arm/dts/socfpga_agilex5-u-boot.dtsi         | 4 ++++
 arch/arm/dts/socfpga_n5x-u-boot.dtsi             | 4 ++++
 arch/arm/dts/socfpga_soc64_u-boot.dtsi           | 1 -
 arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi | 4 ++++
 4 files changed, 12 insertions(+), 1 deletion(-)
arch/arm/dts/socfpga_agilex5-u-boot.dtsi +4 -0
index 0f0f457de54..90f36d42923 100644
@@ -18,6 +18,10 @@
 	soc {
 		bootph-all;
 
+		socfpga-rsu {
+			compatible = "altr,socfpga-rsu";
+		};
+
 		socfpga_ccu_config: socfpga-ccu-config {
 			compatible = "intel,socfpga-dtreg";
 			#address-cells = <1>;
arch/arm/dts/socfpga_n5x-u-boot.dtsi +4 -0
index e27a64651e1..0b38d1e8f70 100644
@@ -18,6 +18,10 @@
 	soc {
 		bootph-all;
 
+		socfpga-rsu {
+			compatible = "altr,socfpga-rsu";
+		};
+
 		ccu: cache-controller@f7000000 {
 			compatible = "arteris,ncore-ccu";
 			reg = <0xf7000000 0x100900>;
arch/arm/dts/socfpga_soc64_u-boot.dtsi +0 -1
index 5ec3c0662e3..91b4fe28624 100644
@@ -9,7 +9,6 @@
 	soc@0 {
 		socfpga-rsu {
 			compatible = "altr,socfpga-rsu";
-			bootph-all;
 		};
 
 		socfpga-system-mgr-firewall {
arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi +4 -0
index ef0df769762..701433cbc35 100644
@@ -14,6 +14,10 @@
 	};
 
 	soc {
+		socfpga-rsu {
+			compatible = "altr,socfpga-rsu";
+		};
+
 		freeze_controller: freeze_controller@f9000450 {
 			compatible = "altr,freeze-bridge-controller";
 			reg = <0xf9000450 0x00000010>;
Signature · 1 line
2.43.7
#8 lore raw

PATCH 8/8 arm: dts: socfpga: rsu: Label boot partition for label-based lookup

In reply to [email protected]

From: Dinesh Maniyam <[email protected]>

rsu_dtb() locates the RSU-managed boot partition by scanning every fixed-partitions node for the "Boot and fpga data" label, falling back to the legacy rsu-handle phandle only when no label matches.

Relabel the Agilex5 SoCDK qspi_boot partition from "u-boot" to "Boot and fpga data" so the primary label scan resolves on the local DTB. The unrelated NAND "u-boot" partition is left untouched. Stratix10 already carries the matching label (aligned with the upstream Linux DTS), and the other SoC64 SoCDKs are not in mainline yet.

While here, drop the redundant fixed-partitions override from socfpga_agilex_socdk-u-boot.dtsi: the Agilex SoCDK consumes its devicetree from the upstream source tree, which already defines the QSPI partitions, so the U-Boot overlay copy only risked drift.

---
 arch/arm/dts/socfpga_agilex5_socdk.dts        |  2 +-
 arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi | 16 ----------------
 2 files changed, 1 insertion(+), 17 deletions(-)
arch/arm/dts/socfpga_agilex5_socdk.dts +1 -1
index 886cc89fdb6..483760b6763 100644
@@ -158,7 +158,7 @@
 			#size-cells = <1>;
 
 			qspi_boot: partition@0 {
-				label = "u-boot";
+				label = "Boot and fpga data";
 				reg = <0x0 0x04200000>;
 			};
 
arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi +0 -16
index f2150b7eb7b..75d3aa08267 100644
@@ -164,22 +164,6 @@
 	cdns,tchsh-ns = <4>;
 	cdns,tslch-ns = <4>;
 	/delete-property/ cdns,read-delay;
-
-	partitions {
-		compatible = "fixed-partitions";
-		#address-cells = <1>;
-		#size-cells = <1>;
-
-		qspi_boot: partition@0 {
-			label = "u-boot";
-			reg = <0x0 0x04200000>;
-		};
-
-		root: partition@4200000 {
-			label = "root";
-			reg = <0x04200000 0x0BE00000>;
-		};
-	};
 };
 
 #if !defined(CONFIG_SOCFPGA_SECURE_VAB_AUTH)
Signature · 1 line
2.43.7