[PATCH 3/3] efi: add option to generate vfat file for barebox.efi
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Nov 28 09:21:55 PST 2025
This can be fairly useful for testing and may in future, even be
extended to hold the state.dtb.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
efi/Kconfig | 4 ++++
images/.gitignore | 3 +++
images/Makefile | 10 ++++++++++
scripts/mkesp | 14 ++++++++++++++
scripts/mkvfat | 20 ++++++++++++++++++++
5 files changed, 51 insertions(+)
create mode 100755 scripts/mkesp
create mode 100755 scripts/mkvfat
diff --git a/efi/Kconfig b/efi/Kconfig
index 35850b20ef50..49839f8466ea 100644
--- a/efi/Kconfig
+++ b/efi/Kconfig
@@ -4,6 +4,10 @@ menu "EFI (Extensible Firmware Interface) Support"
source "efi/payload/Kconfig"
+config EFI_PAYLOAD_ESP_IMAGE
+ bool "Generate barebox.esp image from payload"
+ depends on EFI_PAYLOAD
+
config EFI
bool
diff --git a/images/.gitignore b/images/.gitignore
index fc464ff2e3cb..0e0d2fa71859 100644
--- a/images/.gitignore
+++ b/images/.gitignore
@@ -43,3 +43,6 @@ barebox.sum
*.missing-firmware
*.k3img
fuzz-*
+*.efi
+*.esp
+*.vfat
diff --git a/images/Makefile b/images/Makefile
index 448479ee8cf3..119e7a6e2b8e 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -215,6 +215,16 @@ FILE_barebox.img = start_pbl.pblb
image-$(CONFIG_PBL_SINGLE_IMAGE) += barebox.img
endif
+FILE_barebox.vfat = $(if CONFIG_EFI_STUB,barebox-dt-2nd.img,../barebox.efi)
+FILE_barebox.esp = barebox.vfat
+image-$(CONFIG_EFI_PAYLOAD_ESP_IMAGE) += barebox.esp barebox.vfat
+
+.SECONDEXPANSION:
+$(obj)/barebox.vfat: $(obj)/$$(FILE_$$(@F))
+ $(Q)$(srctree)/scripts/mkvfat $@ $< $(CONFIG_EFI_PAYLOAD_DEFAULT_PATH)
+$(obj)/barebox.esp: $(obj)/$$(FILE_$$(@F))
+ $(Q)$(srctree)/scripts/mkesp $@ $<
+
ifneq ($(pblx-y)$(pblx-),)
$(error pblx- has been removed. Please use pblb- instead.)
endif
diff --git a/scripts/mkesp b/scripts/mkesp
new file mode 100755
index 000000000000..08772fb0f163
--- /dev/null
+++ b/scripts/mkesp
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+img="$1"
+part="$2"
+
+# We operate on local files only, so sfdisk in /sbin is still ok
+export PATH="$PATH:/sbin"
+
+truncate -s 4114KiB "$img"
+dd if="/dev/zero" of="$img" seek=2048 count=1 conv=notrunc status=none
+echo ',2M,U' | sfdisk --quiet --force --label gpt "$img"
+dd if="$part" of="$img" seek=2048 conv=notrunc status=none
diff --git a/scripts/mkvfat b/scripts/mkvfat
new file mode 100755
index 000000000000..6ccbffe093ce
--- /dev/null
+++ b/scripts/mkvfat
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+img="$1"
+bb="$2"
+fullpath="$3"
+
+truncate -s 2048KiB "$img"
+mkdosfs "$img" >/dev/null
+
+path="$fullpath"
+while true; do
+ path="$(dirname "$path")"
+ if [ "$path" = "." ]; then break; fi
+ components="::$path $components"
+done
+
+mmd -DsS -i "$img" $components
+mcopy -sp -D overwrite -i "$img" "$bb" "::$fullpath"
--
2.47.3
More information about the barebox
mailing list