Skip to contentSkip to conversation

ARM: stm32mp: Add Avenger96 board support

PATCH Applied Sohaib Mohamed 4 participants 8 messages Dec 3, 2025 – Dec 8, 2025

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

v2 cover ARM: stm32mp: Add Avenger96 board support

Add support for Arrow STM32MP157A Avenger96 board with bootloader update handlers for MMC and NOR flash.

---
Changes in v2:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Sohaib Mohamed (3):
common: bbu: refactor flash operations into separate function
ARM: stm32mp: bbu: add NOR flash FIP update handler
ARM: stm32mp: add support for STM32MP157A Avenger96 board

 arch/arm/boards/Makefile                    |  1 +
 arch/arm/boards/dhcor-stm32mp1/Makefile     |  2 +
 arch/arm/boards/dhcor-stm32mp1/board.c      | 47 ++++++++++++++++++
 arch/arm/configs/multi_v7_defconfig         |  2 +
 arch/arm/configs/stm32mp_defconfig          |  2 +
 arch/arm/dts/Makefile                       |  1 +
 arch/arm/dts/stm32mp157a-dhcor-stm32mp1.dts |  4 ++
 arch/arm/mach-stm32mp/Kconfig               |  4 ++
 arch/arm/mach-stm32mp/bbu.c                 | 77 +++++++++++++++++++++++++++++
 common/bbu.c                                | 17 ++++---
 include/bbu.h                               |  2 +
 include/mach/stm32mp/bbu.h                  | 10 ++++
 12 files changed, 163 insertions(+), 6 deletions(-)

---
base-commit: a831f32782a5ce216301ccb52e4d27e3462632f3
change-id: 20251128-avenger96-2b70277cdd7a

Best regards,

Signature · 1 line
Sohaib Mohamed <[email protected]>
#1 lore raw

PATCH v2 1/3 common: bbu: refactor flash operations into separate function

Extract flash logic (protect, erase, write) from bbu_std_file_handler() into a new flash() function that accepts an offset parameter, so it can be used from further barebox update handlers as well.

---
 common/bbu.c  | 17 +++++++++++------
 include/bbu.h |  2 ++
 2 files changed, 13 insertions(+), 6 deletions(-)
common/bbu.c +11 -6
index 03261583fe..39db87e823 100644
@@ -431,8 +431,7 @@ int bbu_mmcboot_register_handler(const char *name,
 	return ret;
 }
 
-int bbu_std_file_handler(struct bbu_handler *handler,
-			 struct bbu_data *data)
+int bbu_flash(struct bbu_data *data, loff_t offset)
 {
 	int fd, ret;
 	struct stat s;
@@ -458,25 +457,25 @@ int bbu_std_file_handler(struct bbu_handler *handler,
 	if (fd < 0)
 		return fd;
 
-	ret = protect(fd, data->len, 0, 0);
+	ret = protect(fd, data->len, offset, 0);
 	if (ret && (ret != -ENOSYS) && (ret != -ENOTSUPP)) {
 		printf("unprotecting %s failed with %pe\n", data->devicefile,
 				ERR_PTR(ret));
 		goto err_close;
 	}
 
-	ret = erase(fd, data->len, 0, ERASE_TO_WRITE);
+	ret = erase(fd, data->len, offset, ERASE_TO_WRITE);
 	if (ret && ret != -ENOSYS) {
 		printf("erasing %s failed with %pe\n", data->devicefile,
 				ERR_PTR(ret));
 		goto err_close;
 	}
 
-	ret = write_full(fd, data->image, data->len);
+	ret = pwrite_full(fd, data->image, data->len, offset);
 	if (ret < 0)
 		goto err_close;
 
-	protect(fd, data->len, 0, 1);
+	protect(fd, data->len, offset, 1);
 
 	ret = 0;
 
@@ -486,6 +485,12 @@ int bbu_std_file_handler(struct bbu_handler *handler,
 	return ret;
 }
 
+int bbu_std_file_handler(struct bbu_handler *handler,
+			 struct bbu_data *data)
+{
+	return bbu_flash(data, 0);
+}
+
 static int bbu_std_file_handler_checked(struct bbu_handler *handler,
 					struct bbu_data *data)
 {
include/bbu.h +2 -0
index 94006563c9..f5b74b32ac 100644
@@ -56,6 +56,8 @@ int bbu_mmcboot_handler(struct bbu_handler *, struct bbu_data *,
 int bbu_std_file_handler(struct bbu_handler *handler,
 			 struct bbu_data *data);
 
+int bbu_flash(struct bbu_data *data, loff_t offset);
+
 #ifdef CONFIG_BAREBOX_UPDATE
 
 bool bbu_handlers_available(void);
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/3 ARM: stm32mp: bbu: add NOR flash FIP update handler

In reply to Sohaib Mohamed

Add a barebox update handler for STM32MP NOR flash to support firmware updates in different scenarios. The STM32MP NOR flash layout uses offset 0 for FSBL and offset 512K for FIP, while eMMC boot partitions have FSBL at offset 0 and FIP at offset 256K. The handler detects the image type and flashes accordingly: standalone FIP images go to 512K, standalone FSBL images to offset 0, and combined eMMC boot partition images (detected by finding FIP at 256K offset) get split with FSBL flashed to offset 0 and FIP to 512K. Images that exceed available space will fail with -ENOSPC when pwrite_full() cannot write all bytes.

---
 arch/arm/mach-stm32mp/bbu.c | 77 +++++++++++++++++++++++++++++++++++++++++++++
 include/mach/stm32mp/bbu.h  | 10 ++++++
 2 files changed, 87 insertions(+)
arch/arm/mach-stm32mp/bbu.c +77 -0
index 07b5111341..e8d0138cc7 100644
@@ -193,3 +193,80 @@ int stm32mp_bbu_mmc_fip_register(const char *name,
 
 	return ret;
 }
+
+static int stm32mp_bbu_nor_fip_handler(struct bbu_handler *handler,
+			 struct bbu_data *data)
+{
+	struct bbu_data *fsbl_data, *fip_data;
+	enum filetype filetype;
+	int ret;
+
+	filetype = file_detect_type(data->image, data->len);
+	if (filetype == filetype_fip) {
+		pr_debug("Flashing FIP at offset 512K\n");
+		return bbu_flash(data, SZ_512K);
+	}
+
+	if (filetype != filetype_stm32_image_fsbl_v1) {
+		if (!bbu_force(data, "incorrect image type. Expected: %s, got %s",
+				file_type_to_string(filetype_stm32_image_fsbl_v1),
+				file_type_to_string(filetype)))
+			return -EINVAL;
+
+		/* Force: Let's assume it's an FSBL and flash anyway */
+	}
+
+	if (data->len > SZ_256K)
+		filetype = file_detect_type(data->image + SZ_256K,
+					    data->len - SZ_256K);
+	else
+		filetype = filetype_unknown;
+
+	/* Not an eMMC image, just flash 1:1 */
+	if (filetype != filetype_fip) {
+		pr_debug("Flashing FSBL at offset 0\n");
+		return bbu_flash(data, 0);
+	}
+
+	/* On SPI-NOR, offset 256K is FSBL2. If we get a FIP image there
+	 * instead, let's assume that's an eMMC boot partition image
+	 * and flash the FSBL to offset 0 and the remainder to offset 512K
+	 */
+
+	pr_debug("Flashing FSBL at offset 0\n");
+	fsbl_data = data;
+	fsbl_data->image = data->image;
+	fsbl_data->len = SZ_256K;
+
+	ret = bbu_flash(fsbl_data, 0);
+	if (ret < 0)
+		return ret;
+
+	pr_debug("Flashing FIP from file offset 256K at offset 512K\n");
+	fip_data = data;
+	fip_data->image = data->image + SZ_256K;
+	fip_data->len = data->len - SZ_256K;
+
+	return bbu_flash(fip_data, SZ_512K);
+}
+
+int stm32mp_bbu_nor_fip_register(const char *name,
+				 const char *devicefile,
+				 unsigned long flags)
+{
+	struct stm32mp_bbu_handler *priv;
+	int ret;
+
+	priv = xzalloc(sizeof(*priv));
+
+	priv->handler.flags = flags;
+	priv->handler.devicefile = devicefile;
+	priv->handler.name = name;
+	priv->handler.handler = stm32mp_bbu_nor_fip_handler;
+
+	ret = bbu_register_handler(&priv->handler);
+	if (ret)
+		free(priv);
+
+	return ret;
+}
include/mach/stm32mp/bbu.h +10 -0
index 233bcf6478..87b29f1527 100644
@@ -10,6 +10,9 @@
 int stm32mp_bbu_mmc_fip_register(const char *name, const char *devicefile,
 				 unsigned long flags);
 
+int stm32mp_bbu_nor_fip_register(const char *name, const char *devicefile,
+				 unsigned long flags);
+
 #else
 
 static inline int stm32mp_bbu_mmc_fip_register(const char *name,
@@ -19,6 +22,13 @@ static inline int stm32mp_bbu_mmc_fip_register(const char *name,
 	return -ENOSYS;
 }
 
+static inline int stm32mp_bbu_nor_fip_register(const char *name,
+					       const char *devicefile,
+					       unsigned long flags)
+{
+	return -ENOSYS;
+}
+
 #endif
 
 #endif /* MACH_STM32MP_BBU_H_ */
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/3 ARM: stm32mp: add support for STM32MP157A Avenger96 board

In reply to Sohaib Mohamed

Add board support for the Arrow Electronics STM32MP157A Avenger96 board.

This commit adds:
- Board initialization code with boot source detection
- barebox_update handlers for SD card, eMMC

Tested with STM32MP157A DHCOR SoM on Avenger96 carrier board.

---
 arch/arm/boards/Makefile                    |  1 +
 arch/arm/boards/dhcor-stm32mp1/Makefile     |  2 ++
 arch/arm/boards/dhcor-stm32mp1/board.c      | 47 +++++++++++++++++++++++++++++
 arch/arm/configs/multi_v7_defconfig         |  2 ++
 arch/arm/configs/stm32mp_defconfig          |  2 ++
 arch/arm/dts/Makefile                       |  1 +
 arch/arm/dts/stm32mp157a-dhcor-stm32mp1.dts |  4 +++
 arch/arm/mach-stm32mp/Kconfig               |  4 +++
 8 files changed, 63 insertions(+)
arch/arm/boards/Makefile +1 -0
index f73285ede9..f75277bc17 100644
@@ -135,6 +135,7 @@ obj-$(CONFIG_MACH_LXA_MC1)			+= lxa-mc1/
 obj-$(CONFIG_MACH_LXA_TAC)			+= lxa-tac/
 obj-$(CONFIG_MACH_LXA_FAIRYTUX2)		+= lxa-fairytux2/
 obj-$(CONFIG_MACH_STM32MP15X_EV1)		+= stm32mp15x-ev1/
+obj-$(CONFIG_MACH_DHCOR_STM32MP1)		+= dhcor-stm32mp1/
 obj-$(CONFIG_MACH_TECHNEXION_PICO_HOBBIT)	+= technexion-pico-hobbit/
 obj-$(CONFIG_MACH_TECHNEXION_WANDBOARD)		+= technexion-wandboard/
 obj-$(CONFIG_MACH_TNY_A9260)			+= tny-a926x/
arch/arm/boards/dhcor-stm32mp1/Makefile new file +2 -0
new file mode 100644
index 0000000000..bcca1a9f84
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0+
+obj-y += board.o
arch/arm/boards/dhcor-stm32mp1/board.c new file +47 -0

47 lines not on this page · raw message

arch/arm/configs/multi_v7_defconfig +2 -0
index 93f79c79d2..ef4e106148 100644
@@ -82,6 +82,7 @@ CONFIG_MACH_STM32MP15XX_DKX=y
 CONFIG_MACH_LXA_MC1=y
 CONFIG_MACH_LXA_TAC=y
 CONFIG_MACH_LXA_FAIRYTUX2=y
+CONFIG_MACH_DHCOR_STM32MP1=y
 CONFIG_MACH_SEEED_ODYSSEY=y
 CONFIG_MACH_STM32MP15X_EV1=y
 CONFIG_MACH_PROTONIC_STM32MP1=y
@@ -214,6 +215,7 @@ CONFIG_DEEP_PROBE_DEFAULT=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_AIODEV=y
 CONFIG_STM32_ADC=y
+CONFIG_STM32_QSPI=y
 CONFIG_SERIAL_AMBA_PL011=y
 CONFIG_DRIVER_SERIAL_STM32=y
 CONFIG_DRIVER_SERIAL_NS16550=y
arch/arm/configs/stm32mp_defconfig +2 -0
index 4df7b371f3..1d1b75fbb0 100644
@@ -4,6 +4,7 @@ CONFIG_MACH_STM32MP15XX_DKX=y
 CONFIG_MACH_LXA_MC1=y
 CONFIG_MACH_LXA_TAC=y
 CONFIG_MACH_LXA_FAIRYTUX2=y
+CONFIG_MACH_DHCOR_STM32MP1=y
 CONFIG_MACH_SEEED_ODYSSEY=y
 CONFIG_MACH_STM32MP15X_EV1=y
 CONFIG_MACH_PROTONIC_STM32MP1=y
@@ -104,6 +105,7 @@ CONFIG_NET_FASTBOOT=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_AIODEV=y
 CONFIG_STM32_ADC=y
+CONFIG_STM32_QSPI=y
 CONFIG_DRIVER_SERIAL_STM32=y
 CONFIG_DRIVER_NET_DESIGNWARE_STM32=y
 CONFIG_AT803X_PHY=y
arch/arm/dts/Makefile +1 -0
index e78722a9a7..3cd1d8fe59 100644
@@ -169,6 +169,7 @@ lwl-$(CONFIG_MACH_LXA_MC1) += stm32mp157c-lxa-mc1.dtb.o stm32mp157c-lxa-mc1-scmi
 lwl-$(CONFIG_MACH_LXA_TAC) += stm32mp157c-lxa-tac-gen1.dtb.o stm32mp157c-lxa-tac-gen2.dtb.o \
 				stm32mp153c-lxa-tac-gen3.dtb.o
 lwl-$(CONFIG_MACH_LXA_FAIRYTUX2) += stm32mp153c-lxa-fairytux2-gen1.dtb.o stm32mp153c-lxa-fairytux2-gen2.dtb.o
+lwl-$(CONFIG_MACH_DHCOR_STM32MP1) += stm32mp157a-dhcor-stm32mp1.dtb.o
 lwl-$(CONFIG_MACH_STM32MP15X_EV1) += stm32mp157c-ev1.dtb.o stm32mp157c-ev1-scmi.dtb.o
 lwl-$(CONFIG_MACH_SCB9328) += imx1-scb9328.dtb.o
 lwl-$(CONFIG_MACH_TECHNEXION_WANDBOARD) += imx6q-wandboard.dtb.o imx6dl-wandboard.dtb.o
arch/arm/dts/stm32mp157a-dhcor-stm32mp1.dts new file +4 -0
new file mode 100644
index 0000000000..5187cc882f
@@ -0,0 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+
+#include <arm/st/stm32mp157a-dhcor-avenger96.dts>
+#include "stm32mp151.dtsi"
arch/arm/mach-stm32mp/Kconfig +4 -0
index 5ea0c4004f..54ce644d73 100644
@@ -39,6 +39,10 @@ config MACH_LXA_FAIRYTUX2
 	bool "Linux Automation FairyTux 2"
 	select BOARD_LXA
 
+config MACH_DHCOR_STM32MP1
+	select ARCH_STM32MP157
+	bool "DHCOR STM32MP1 boards including Arrow Avenger96"
+
 config MACH_SEEED_ODYSSEY
 	select ARCH_STM32MP157
 	bool "Seeed Studio Odyssey"
Signature · 1 line
2.43.0
#4 lore raw
In reply to Sohaib Mohamed
Quoted 9 lines · Sohaib Mohamed

Add support for Arrow STM32MP157A Avenger96 board with bootloader update handlers for MMC and NOR flash.

---
Changes in v2:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://lore.kernel.org/r/[email protected]

It seems you forgot to update your cover letter for v2 with a changelog, maybe send a reply email the amend it to help with review.

Quoted 24 lines

---
Sohaib Mohamed (3):
common: bbu: refactor flash operations into separate function
ARM: stm32mp: bbu: add NOR flash FIP update handler
ARM: stm32mp: add support for STM32MP157A Avenger96 board

  arch/arm/boards/Makefile                    |  1 +
  arch/arm/boards/dhcor-stm32mp1/Makefile     |  2 +
  arch/arm/boards/dhcor-stm32mp1/board.c      | 47 ++++++++++++++++++
  arch/arm/configs/multi_v7_defconfig         |  2 +
  arch/arm/configs/stm32mp_defconfig          |  2 +
  arch/arm/dts/Makefile                       |  1 +
  arch/arm/dts/stm32mp157a-dhcor-stm32mp1.dts |  4 ++
  arch/arm/mach-stm32mp/Kconfig               |  4 ++
  arch/arm/mach-stm32mp/bbu.c                 | 77 +++++++++++++++++++++++++++++
  common/bbu.c                                | 17 ++++---
  include/bbu.h                               |  2 +
  include/mach/stm32mp/bbu.h                  | 10 ++++
  12 files changed, 163 insertions(+), 6 deletions(-)

---
base-commit: a831f32782a5ce216301ccb52e4d27e3462632f3
change-id: 20251128-avenger96-2b70277cdd7a

Best regards,

#5 lore raw

Hi,

Quoted 12 lines · Maud Spierings
Quoted 10 lines · Sohaib Mohamed

Add support for Arrow STM32MP157A Avenger96 board with bootloader update handlers for MMC and NOR flash.

---
Changes in v2:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://lore.kernel.org/r/20251128-avenger96-
[email protected]

Quoted 2 lines

It seems you forgot to update your cover letter for v2 with a changelog, maybe send a reply email the amend it to help with review.

@Sohaib, b4 prep --compare-to v1 can be very useful to see what changes occurred, so you can summarize them.

Cheers,
Ahmad

Quoted 29 lines
Quoted 26 lines

---
Sohaib Mohamed (3):
       common: bbu: refactor flash operations into separate function
       ARM: stm32mp: bbu: add NOR flash FIP update handler
       ARM: stm32mp: add support for STM32MP157A Avenger96 board

  arch/arm/boards/Makefile                    |  1 + arch/arm/boards/dhcor-stm32mp1/Makefile     |  2 + arch/arm/boards/dhcor-stm32mp1/board.c      | 47 ++++++++++++++++++ arch/arm/configs/multi_v7_defconfig         |  2 + arch/arm/configs/stm32mp_defconfig          |  2 + arch/arm/dts/Makefile                       |  1 + arch/arm/dts/stm32mp157a-dhcor-stm32mp1.dts |  4 ++ arch/arm/mach-stm32mp/Kconfig               |  4 ++ arch/arm/mach-stm32mp/bbu.c                 | 77 +++++++++++++++++++
++++++++++
  common/bbu.c                                | 17 ++++--- include/bbu.h                               |  2 + include/mach/stm32mp/bbu.h                  | 10 ++++

  12 files changed, 163 insertions(+), 6 deletions(-)

---
base-commit: a831f32782a5ce216301ccb52e4d27e3462632f3
change-id: 20251128-avenger96-2b70277cdd7a

Best regards,

Signature · 4 lines
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |
#6 lore raw
In reply to Sohaib Mohamed
Quoted 10 lines · Sohaib Mohamed

Add support for Arrow STM32MP157A Avenger96 board with bootloader update handlers for MMC and NOR flash.

---
Changes in v2:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
v1 -> v2:
- Improved NOR flash handler commit message clarity
- Link to v1: https://lore.kernel.org/r/[email protected]

Quoted 27 lines

---
Sohaib Mohamed (3):
common: bbu: refactor flash operations into separate function
ARM: stm32mp: bbu: add NOR flash FIP update handler
ARM: stm32mp: add support for STM32MP157A Avenger96 board

 arch/arm/boards/Makefile                    |  1 +
 arch/arm/boards/dhcor-stm32mp1/Makefile     |  2 +
 arch/arm/boards/dhcor-stm32mp1/board.c      | 47 ++++++++++++++++++
 arch/arm/configs/multi_v7_defconfig         |  2 +
 arch/arm/configs/stm32mp_defconfig          |  2 +
 arch/arm/dts/Makefile                       |  1 +
 arch/arm/dts/stm32mp157a-dhcor-stm32mp1.dts |  4 ++
 arch/arm/mach-stm32mp/Kconfig               |  4 ++
 arch/arm/mach-stm32mp/bbu.c                 | 77 +++++++++++++++++++++++++++++
 common/bbu.c                                | 17 ++++---
 include/bbu.h                               |  2 +
 include/mach/stm32mp/bbu.h                  | 10 ++++
 12 files changed, 163 insertions(+), 6 deletions(-)

---
base-commit: a831f32782a5ce216301ccb52e4d27e3462632f3
change-id: 20251128-avenger96-2b70277cdd7a

Best regards,
--
Sohaib Mohamed <[email protected]>

Applied
#7 lore raw
In reply to Sohaib Mohamed
Quoted 4 lines · Sohaib Mohamed

Add support for Arrow STM32MP157A Avenger96 board with bootloader update handlers for MMC and NOR flash.

Applied, thanks!

[1/3] common: bbu: refactor flash operations into separate function
https://git.pengutronix.de/cgit/barebox/commit/?id=8efd705a65bf (link may not be stable)
[2/3] ARM: stm32mp: bbu: add NOR flash FIP update handler
https://git.pengutronix.de/cgit/barebox/commit/?id=d3e05db632b8 (link may not be stable)
[3/3] ARM: stm32mp: add support for STM32MP157A Avenger96 board
https://git.pengutronix.de/cgit/barebox/commit/?id=0f9bb90b24af (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>