From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: barebox@lists.infradead.org, Sascha Hauer <s.hauer@pengutronix.de>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: [PATCH 3/4] boot: add bootm.bootconfig override
Date: Tue, 27 Oct 2026 14:23:55 +0100 [thread overview]
Message-ID: <20261027-v2026-10-0-topic-bootconfig-v1-3-2758d3d9a165@pengutronix.de> (raw)
In-Reply-To: <20261027-v2026-10-0-topic-bootconfig-v1-0-2758d3d9a165@pengutronix.de>
boot -o bootm.bootconfig=FILE replaces the bootconfig a boot entry would
get from global.bootm.bootconfig, an empty value removes it. Together
with the other overrides this changes kernel parameters, init options or
tracing for one boot of an existing entry.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
Documentation/user/devboot.rst | 17 +++++++++++++++++
commands/boot.c | 5 ++++-
common/bootm-overrides.c | 23 +++++++++++++++++++++--
include/bootm-overrides.h | 3 +++
include/bootm.h | 1 +
5 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/Documentation/user/devboot.rst b/Documentation/user/devboot.rst
index e319636994..fce8398b22 100644
--- a/Documentation/user/devboot.rst
+++ b/Documentation/user/devboot.rst
@@ -105,6 +105,23 @@ Override rules
mount -n --bind /lib/modules ${ROOT_MOUNT}/lib/modules
+``bootm.bootconfig``
+ A Linux bootconfig file (``CONFIG_BOOTM_BOOTCONFIG``), appended to the
+ initrd after all initrds, or passed alone as the initrd if there is
+ none, see :ref:`global.bootm.bootconfig
+ <magicvar_global_bootm_bootconfig>`. It replaces the bootconfig the boot
+ entry would get from the variable; an empty string removes it. This
+ configures the kernel and init without touching the boot entry's
+ command line or the root filesystem, e.g. tracing for one boot:
+
+ .. code-block:: sh
+
+ # /mnt/tftp/trace.bconf
+ ftrace.event.sched.sched_switch.enable
+ kernel.trace_buf_size = 4M
+
+ boot -o bootm.bootconfig=/mnt/tftp/trace.bconf mmc
+
.. note::
When secure boot is enforced (``bootm_signed_images_are_forced()``),
diff --git a/commands/boot.c b/commands/boot.c
index cc7a64bcca..bd09b90901 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -49,6 +49,9 @@ static int boot_add_override(struct bootm_overrides *overrides, char *var)
overrides->oftree_file = val;
} else if (!strcmp(var, "bootm.initrd")) {
overrides->initrd_file = val;
+ } else if (IS_ENABLED(CONFIG_BOOTM_BOOTCONFIG) &&
+ !strcmp(var, "bootm.bootconfig")) {
+ overrides->bootconfig_file = val;
} else {
return -EINVAL;
}
@@ -241,7 +244,7 @@ BAREBOX_CMD_HELP_OPT ("-m","Show a menu with boot options")
BAREBOX_CMD_HELP_OPT ("-M DEFAULT","Show a menu with boot options with entry DEFAULT preselected")
BAREBOX_CMD_HELP_OPT ("-w SECS","Start watchdog with timeout SECS before booting")
#ifdef CONFIG_BOOT_OVERRIDE
-BAREBOX_CMD_HELP_OPT ("-o VAR[=VAL]","override VAR (bootm.{oftree,initrd}) with VAL")
+BAREBOX_CMD_HELP_OPT ("-o VAR[=VAL]","override VAR (bootm.{oftree,initrd,bootconfig}) with VAL")
BAREBOX_CMD_HELP_OPT (" ","if VAL is not specified, the value of VAR is taken")
#endif
BAREBOX_CMD_HELP_OPT ("-t SECS","specify timeout in SECS")
diff --git a/common/bootm-overrides.c b/common/bootm-overrides.c
index 720d5636f3..f02a037b13 100644
--- a/common/bootm-overrides.c
+++ b/common/bootm-overrides.c
@@ -3,6 +3,7 @@
#include <bootm.h>
#include <bootm-overrides.h>
#include <bootm-fit.h>
+#include <bootconfig.h>
#include <init.h>
#include <libfile.h>
#include <of.h>
@@ -107,6 +108,8 @@ static void report_active_overrides(const struct image_data *data)
report_active_override("initrd", data->initrd);
if (data->is_override.oftree)
report_active_override("FDT", data->oftree);
+ if (data->is_override.bootconfig)
+ report_active_override("bootconfig", data->bootconfig);
}
/**
@@ -114,8 +117,9 @@ static void report_active_overrides(const struct image_data *data)
* @data: image data context
* @overrides: overrides to apply
*
- * Applies bootm.image, bootm.initrd, and bootm.oftree overrides by translating
- * them into file-based loadables or FIT image replacements.
+ * Applies bootm.image, bootm.initrd, bootm.oftree and bootm.bootconfig
+ * overrides by translating them into file-based loadables or FIT image
+ * replacements.
*
* Context: Called during boot preparation
* Return: 0 on success, negative error code otherwise
@@ -143,6 +147,21 @@ int bootm_apply_overrides(struct image_data *data,
data->is_override.initrd = true;
}
+ if (IS_ENABLED(CONFIG_BOOTM_BOOTCONFIG) && overrides->bootconfig_file) {
+ /* an empty bootconfig_file removes the bootconfig */
+ loadable_release(&data->bootconfig);
+ if (nonempty(overrides->bootconfig_file)) {
+ data->bootconfig = bootconfig_loadable(overrides->bootconfig_file);
+ if (IS_ERR(data->bootconfig)) {
+ ret = PTR_ERR(data->bootconfig);
+
+ data->bootconfig = NULL;
+ return ret;
+ }
+ }
+ data->is_override.bootconfig = true;
+ }
+
if (overrides->oftree_file) {
int ret = loadables_from_files(&data->oftree,
overrides->oftree_file, ":",
diff --git a/include/bootm-overrides.h b/include/bootm-overrides.h
index 0dbf6e7fa8..fde543a8e4 100644
--- a/include/bootm-overrides.h
+++ b/include/bootm-overrides.h
@@ -6,6 +6,7 @@ struct bootm_overrides {
const char *os_file;
const char *oftree_file;
const char *initrd_file;
+ const char *bootconfig_file;
};
struct image_data;
@@ -21,6 +22,8 @@ static inline void bootm_merge_overrides(struct bootm_overrides *dst,
dst->oftree_file = src->oftree_file;
if (src->initrd_file)
dst->initrd_file = src->initrd_file;
+ if (src->bootconfig_file)
+ dst->bootconfig_file = src->bootconfig_file;
}
int bootm_apply_overrides(struct image_data *data,
diff --git a/include/bootm.h b/include/bootm.h
index 134b01d453..9038ba7300 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -148,6 +148,7 @@ struct image_data {
u8 os:1;
u8 initrd:1;
u8 oftree:1;
+ u8 bootconfig:1;
} is_override;
enum bootm_efi_mode efi_boot;
};
--
2.56.0
next prev parent reply other threads:[~2026-10-27 13:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 13:23 [PATCH 0/4] Linux bootconfig support Steffen Trumtrar
2026-10-27 13:23 ` [PATCH 1/4] loadable: add loadable_from_buf() Steffen Trumtrar
2026-10-27 13:23 ` [PATCH 2/4] bootm: append a Linux bootconfig to the initrd Steffen Trumtrar
2026-10-27 13:23 ` Steffen Trumtrar [this message]
2026-10-27 13:23 ` [PATCH 4/4] defaultenv: devboot: add devboot_bootconfig Steffen Trumtrar
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=20261027-v2026-10-0-topic-bootconfig-v1-3-2758d3d9a165@pengutronix.de \
--to=s.trumtrar@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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