Skip to contentSkip to conversation

rpi-firmware: support installing autoobot configurations

PATCH In review Olivier Benjamin via buildroot 1 participant 2 messages May 7, 2025 – Feb 4

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpi-firmware: support installing autoobot configurations

autoboot.txt is an optional configuration file for the RPi firmware:
https://www.raspberrypi.com/documentation/computers/config_txt.html#autoboot-txt

Supporting several autoboot files will enable A/B setups, as using the renameat2() system call with the RENAME_EXCHANGE flag will let users atomically replace one autoboot configuratin file with the other. This improves reliability in the case of an update which could potentially be interrupted.

---
 package/rpi-firmware/Config.in       |  7 +++++++
 package/rpi-firmware/rpi-firmware.mk | 10 ++++++++++
 2 files changed, 17 insertions(+)
package/rpi-firmware/Config.in +7 -0
index f99c116ca2..42982514f8 100644
@@ -76,6 +76,13 @@ config BR2_PACKAGE_RPI_FIRMWARE_CMDLINE_FILE
 	  Path to a file stored as cmdline.txt in the boot partition
 	  of the generated SD card image.
 
+config BR2_PACKAGE_RPI_FIRMWARE_AUTOBOOT_FILES
+	string "List of path(s) to file(s) containing autoboot configuration."
+	help
+	  Space-separated path(s) to file(s) that should be stored
+	  in the boot partition. They will be stored under their own
+	  name in rpi-firmware.
+
 config BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS
 	bool "Install Device Tree Blobs (DTBs)"
 	default y
package/rpi-firmware/rpi-firmware.mk +10 -0
index 2577d16a01..17b7c0cbca 100644
@@ -62,6 +62,15 @@ define RPI_FIRMWARE_INSTALL_DTB_OVERLAYS
 endef
 endif
 
+RPI_FIRMWARE_AUTOBOOT_FILES = $(call qstrip,$(BR2_PACKAGE_RPI_FIRMWARE_AUTOBOOT_FILES))
+ifneq ($(RPI_FIRMWARE_AUTOBOOT_FILES),)
+define RPI_FIRMWARE_INSTALL_AUTOBOOTS
+	$(foreach f,$(RPI_FIRMWARE_AUTOBOOT_FILES), \
+		$(INSTALL) -D -m 0644 $(f) $(BINARIES_DIR)/rpi-firmware/$(notdir $(f))
+	)
+endef
+endif
+
 # Install prebuilt libraries if RPI_USERLAND not enabled
 ifneq ($(BR2_PACKAGE_RPI_USERLAND),y)
 define RPI_FIRMWARE_INSTALL_TARGET_LIB
@@ -86,6 +95,7 @@ define RPI_FIRMWARE_INSTALL_IMAGES_CMDS
 	$(RPI_FIRMWARE_INSTALL_BIN)
 	$(RPI_FIRMWARE_INSTALL_CONFIG)
 	$(RPI_FIRMWARE_INSTALL_CMDLINE)
+	$(RPI_FIRMWARE_INSTALL_AUTOBOOTS)
 	$(RPI_FIRMWARE_INSTALL_DTB)
 	$(RPI_FIRMWARE_INSTALL_DTB_OVERLAYS)
 endef
Signature · 6 lines
2.48.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hi Olivier,

Quoted 10 lines · Olivier Benjamin via buildroot

autoboot.txt is an optional configuration file for the RPi firmware:
https://www.raspberrypi.com/documentation/computers/config_txt.html#autoboot-txt

Supporting several autoboot files will enable A/B setups, as using the renameat2() system call with the RENAME_EXCHANGE flag will let users atomically replace one autoboot configuratin file with the other. This improves reliability in the case of an update which could potentially be interrupted.

This patch is actually very similar to the one that installs multiple
cmdline.txt. So instead, I changed it to introduce a single option BR2_PACKAGE_RPI_FIRMWARE_EXTRA_FILES.

In the end, the commit doesn't really look like what you submitted any more,
but I've kept your authorship :-)

So in the end, applied to master, thanks!

I haven't tested it much so please check if this covers your use cases and if
not send follow-up patches.

Regards,
Arnout

Quoted 44 lines
---
  package/rpi-firmware/Config.in       |  7 +++++++
  package/rpi-firmware/rpi-firmware.mk | 10 ++++++++++
  2 files changed, 17 insertions(+)
package/rpi-firmware/Config.in +7 -0
index f99c116ca2..42982514f8 100644
@@ -76,6 +76,13 @@ config BR2_PACKAGE_RPI_FIRMWARE_CMDLINE_FILE
  	  Path to a file stored as cmdline.txt in the boot partition
  	  of the generated SD card image.
 
+config BR2_PACKAGE_RPI_FIRMWARE_AUTOBOOT_FILES
+	string "List of path(s) to file(s) containing autoboot configuration."
+	help
+	  Space-separated path(s) to file(s) that should be stored
+	  in the boot partition. They will be stored under their own
+	  name in rpi-firmware.
+
  config BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS
  	bool "Install Device Tree Blobs (DTBs)"
  	default y
package/rpi-firmware/rpi-firmware.mk +9 -0
index 2577d16a01..17b7c0cbca 100644
@@ -62,6 +62,15 @@ define RPI_FIRMWARE_INSTALL_DTB_OVERLAYS
  endef
  endif
 
+RPI_FIRMWARE_AUTOBOOT_FILES = $(call qstrip,$(BR2_PACKAGE_RPI_FIRMWARE_AUTOBOOT_FILES))
+ifneq ($(RPI_FIRMWARE_AUTOBOOT_FILES),)
+define RPI_FIRMWARE_INSTALL_AUTOBOOTS
+	$(foreach f,$(RPI_FIRMWARE_AUTOBOOT_FILES), \
+		$(INSTALL) -D -m 0644 $(f) $(BINARIES_DIR)/rpi-firmware/$(notdir $(f))
+	)
+endef
+endif
+
  # Install prebuilt libraries if RPI_USERLAND not enabled
  ifneq ($(BR2_PACKAGE_RPI_USERLAND),y)
  define RPI_FIRMWARE_INSTALL_TARGET_LIB

package/rpi-firmware/rpi-firmware.mk define RPI_FIRMWARE_INSTALL_IMAGES_CMDS · line 101

Quoted 7 lines
package/rpi-firmware/rpi-firmware.mk +1 -0
@@ -86,6 +95,7 @@ define RPI_FIRMWARE_INSTALL_IMAGES_CMDS
  	$(RPI_FIRMWARE_INSTALL_BIN)
  	$(RPI_FIRMWARE_INSTALL_CONFIG)
  	$(RPI_FIRMWARE_INSTALL_CMDLINE)
+	$(RPI_FIRMWARE_INSTALL_AUTOBOOTS)
  	$(RPI_FIRMWARE_INSTALL_DTB)
  	$(RPI_FIRMWARE_INSTALL_DTB_OVERLAYS)
  endef

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot