diff mbox series

[1/1] rpi-firmware: support installing autoobot configurations

Message ID 20250507160832.121159-1-olivier.benjamin@bootlin.com
State Accepted
Headers show
Series [1/1] rpi-firmware: support installing autoobot configurations | expand

Commit Message

Olivier Benjamin May 7, 2025, 4:08 p.m. UTC
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.

Signed-off-by: Olivier Benjamin <olivier.benjamin@bootlin.com>
---
 package/rpi-firmware/Config.in       |  7 +++++++
 package/rpi-firmware/rpi-firmware.mk | 10 ++++++++++
 2 files changed, 17 insertions(+)

Comments

Arnout Vandecappelle Feb. 4, 2026, 11:01 a.m. UTC | #1
Hi Olivier,

On 07/05/2025 18:08, Olivier Benjamin via buildroot wrote:
> 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.
> 
> Signed-off-by: Olivier Benjamin <olivier.benjamin@bootlin.com>

  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

> ---
>   package/rpi-firmware/Config.in       |  7 +++++++
>   package/rpi-firmware/rpi-firmware.mk | 10 ++++++++++
>   2 files changed, 17 insertions(+)
> 
> diff --git a/package/rpi-firmware/Config.in b/package/rpi-firmware/Config.in
> index f99c116ca2..42982514f8 100644
> --- a/package/rpi-firmware/Config.in
> +++ b/package/rpi-firmware/Config.in
> @@ -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
> diff --git a/package/rpi-firmware/rpi-firmware.mk b/package/rpi-firmware/rpi-firmware.mk
> index 2577d16a01..17b7c0cbca 100644
> --- a/package/rpi-firmware/rpi-firmware.mk
> +++ b/package/rpi-firmware/rpi-firmware.mk
> @@ -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
diff mbox series

Patch

diff --git a/package/rpi-firmware/Config.in b/package/rpi-firmware/Config.in
index f99c116ca2..42982514f8 100644
--- a/package/rpi-firmware/Config.in
+++ b/package/rpi-firmware/Config.in
@@ -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
diff --git a/package/rpi-firmware/rpi-firmware.mk b/package/rpi-firmware/rpi-firmware.mk
index 2577d16a01..17b7c0cbca 100644
--- a/package/rpi-firmware/rpi-firmware.mk
+++ b/package/rpi-firmware/rpi-firmware.mk
@@ -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