mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/3] efi: add option to generate vfat file for barebox.efi
Date: Fri, 28 Nov 2025 18:21:55 +0100	[thread overview]
Message-ID: <20251128172158.36324-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20251128172158.36324-1-a.fatoum@pengutronix.de>

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@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




  parent reply	other threads:[~2025-11-28 17:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-28 17:21 [PATCH 1/3] efi: payload: image: set LoaderTimeExecUSec for kernel images Ahmad Fatoum
2025-11-28 17:21 ` [PATCH 2/3] efi: payload: fold setup_header.h into handover.c Ahmad Fatoum
2025-11-28 17:21 ` Ahmad Fatoum [this message]
2025-12-01  9:04 ` [PATCH 1/3] efi: payload: image: set LoaderTimeExecUSec for kernel images Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251128172158.36324-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox