mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Burri Markus LabTec <Markus.Burri@mt.com>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: RE: EXTERNAL - [PATCH v1] Add bootchooser command option for active boot target
Date: Mon, 17 Apr 2023 09:42:39 +0000	[thread overview]
Message-ID: <PA4PR03MB7488267E1064820DC94F3E00EF9C9@PA4PR03MB7488.eurprd03.prod.outlook.com> (raw)
In-Reply-To: <b8847e00-0e27-c7f8-af75-977fa41fa64e@pengutronix.de>

Hi Ahmad
I removed my init script and replaced it by a script added to bootchooser.system0.boot=<script>.
This fit my requirements and therefor the patch is obsolete.
Thanks for your support.
Best regards Markus

-----Original Message-----
From: Ahmad Fatoum <a.fatoum@pengutronix.de> 
Sent: Freitag, 14. April 2023 14:47
To: Burri Markus LabTec <Markus.Burri@mt.com>
Cc: barebox@lists.infradead.org
Subject: Re: EXTERNAL - [PATCH v1] Add bootchooser command option for active boot target

Hello Markus,

On 14.04.23 14:41, Burri Markus LabTec wrote:
> Hello Ahmad
> 
> The Idea is to run some scripts stored in the rootfs before booting 
> the system. In our case e.g we enable led according to customer needs. 
> This is stored in to rootfs where the customer is able to update 
> without update barebox

Once you give your customer the ability to run arbitrary code, they will run arbitrary code, e.g. apply an overlay to the kernel DT or tune kernel command line argument. With your init script approach, you could apply old overlays when booting a new kernel, which can lead to very surprising results.

> The new command option will store this information in a variable where I can use this information in the init script.
> It sound that a script as bootchooser target will fit my requirement. 
> I didn't know that. I will try

I am not opposed to give these scripts knowledge of what bootchooser target is executed, see untested patch below. But it should be the boot scripts that run hooks, not an init script on a subsequent boot.

Cheers,
Ahmad

---
 common/bootchooser.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/common/bootchooser.c b/common/bootchooser.c index 08d05e885250..3d400af08ef1 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -827,6 +827,7 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain)
                goto out;
        }

+       globalvar_add_simple("bootchooser.active", target->name);
        system = basprintf("bootchooser.active=%s", target->name);
        globalvar_add_simple("linux.bootargs.bootchooser", system);
        free(system);
@@ -854,6 +855,7 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain)
        *tryagain = 1;
 out:
        globalvar_set_match("linux.bootargs.bootchooser", NULL);
+       globalvar_set_match("bootchooser.active", NULL);

        bootentries_free(entries);

@@ -976,3 +978,5 @@ BAREBOX_MAGICVAR(global.bootchooser.default_priority,
                 "bootchooser: Default priority for a target");  BAREBOX_MAGICVAR(global.bootchooser.state_prefix,
                 "bootchooser: state name prefix, empty for nv backend");
+BAREBOX_MAGICVAR(global.bootchooser.active,
+                "bootchooser: holds name of active bootchooser target 
+during boot");


      reply	other threads:[~2023-04-17  9:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14  9:40 Markus Burri
2023-04-14  9:49 ` Ahmad Fatoum
     [not found]   ` <PA4PR03MB748854E525009BC8F015D570EF999@PA4PR03MB7488.eurprd03.prod.outlook.com>
2023-04-14 12:27     ` EXTERNAL - " Ahmad Fatoum
2023-04-14 12:41       ` Burri Markus LabTec
2023-04-14 12:46         ` Ahmad Fatoum
2023-04-17  9:42           ` Burri Markus LabTec [this message]

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=PA4PR03MB7488267E1064820DC94F3E00EF9C9@PA4PR03MB7488.eurprd03.prod.outlook.com \
    --to=markus.burri@mt.com \
    --cc=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