* [PATCH] Pass barebox version to kernel @ 2018-02-26 8:23 Sascha Hauer 2018-02-26 10:12 ` Peter Mamonov 0 siblings, 1 reply; 5+ messages in thread From: Sascha Hauer @ 2018-02-26 8:23 UTC (permalink / raw) To: Barebox List When userspace is interested in the barebox version it has currently no way of reliably reading it. Add it to the kernel command line as it's an established way to pass information from the bootloader to the kernel. If CONFIG_FLEXIBLE_BOOTARGS is enabled then the barebox version is passed in the "bootloader.version=" variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- common/globalvar.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/globalvar.c b/common/globalvar.c index b9bfce7dac..eff4cbc72e 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -571,6 +571,8 @@ int globalvar_add_simple_ip(const char *name, IPaddr_t *ip) return 0; } +static char *kernel_arg_bootloader_version; + static int globalvar_init(void) { register_device(&global_device); @@ -580,6 +582,13 @@ static int globalvar_init(void) globalvar_add_simple("version", UTS_RELEASE); + if (IS_ENABLED(CONFIG_FLEXIBLE_BOOTARGS)) { + kernel_arg_bootloader_version = basprintf("bootloader.version=barebox-%s", + UTS_RELEASE); + globalvar_add_simple_string("linux.bootargs.bootloader.version", + &kernel_arg_bootloader_version); + } + return 0; } pure_initcall(globalvar_init); -- 2.16.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Pass barebox version to kernel 2018-02-26 8:23 [PATCH] Pass barebox version to kernel Sascha Hauer @ 2018-02-26 10:12 ` Peter Mamonov 2018-02-27 8:34 ` Sascha Hauer 0 siblings, 1 reply; 5+ messages in thread From: Peter Mamonov @ 2018-02-26 10:12 UTC (permalink / raw) To: Sascha Hauer; +Cc: Barebox List Hi, Sasha, On Mon, Feb 26, 2018 at 09:23:49AM +0100, Sascha Hauer wrote: > When userspace is interested in the barebox version it has currently no > way of reliably reading it. Add it to the kernel command line as it's an > established way to pass information from the bootloader to the kernel. > If CONFIG_FLEXIBLE_BOOTARGS is enabled then the barebox version is > passed in the "bootloader.version=" variable. Some time ago we solved a similar problem: a number of parameters including barebox version, MAC address (which may be random due to the lack of a NIC EEPROM) and some vendor specific parameters are passed to the kernel via DTB. A dedicated command was implemented which can either patch the existing DTB or generate an overlay DTB. In the latter case the overlay DTB is passed to the kernel with the help of a new `bootm` option. Of course the latter approach requires support on the kernel side. Are you interested in adopting this code into barebox? Regards, Peter > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > --- > common/globalvar.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/common/globalvar.c b/common/globalvar.c > index b9bfce7dac..eff4cbc72e 100644 > --- a/common/globalvar.c > +++ b/common/globalvar.c > @@ -571,6 +571,8 @@ int globalvar_add_simple_ip(const char *name, IPaddr_t *ip) > return 0; > } > > +static char *kernel_arg_bootloader_version; > + > static int globalvar_init(void) > { > register_device(&global_device); > @@ -580,6 +582,13 @@ static int globalvar_init(void) > > globalvar_add_simple("version", UTS_RELEASE); > > + if (IS_ENABLED(CONFIG_FLEXIBLE_BOOTARGS)) { > + kernel_arg_bootloader_version = basprintf("bootloader.version=barebox-%s", > + UTS_RELEASE); > + globalvar_add_simple_string("linux.bootargs.bootloader.version", > + &kernel_arg_bootloader_version); > + } > + > return 0; > } > pure_initcall(globalvar_init); > -- > 2.16.1 > > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Pass barebox version to kernel 2018-02-26 10:12 ` Peter Mamonov @ 2018-02-27 8:34 ` Sascha Hauer 2018-02-27 19:43 ` Peter Mamonov 0 siblings, 1 reply; 5+ messages in thread From: Sascha Hauer @ 2018-02-27 8:34 UTC (permalink / raw) To: Peter Mamonov; +Cc: Barebox List Hi Peter, On Mon, Feb 26, 2018 at 01:12:02PM +0300, Peter Mamonov wrote: > Hi, Sasha, > > On Mon, Feb 26, 2018 at 09:23:49AM +0100, Sascha Hauer wrote: > > When userspace is interested in the barebox version it has currently no > > way of reliably reading it. Add it to the kernel command line as it's an > > established way to pass information from the bootloader to the kernel. > > If CONFIG_FLEXIBLE_BOOTARGS is enabled then the barebox version is > > passed in the "bootloader.version=" variable. > > Some time ago we solved a similar problem: a number of parameters including > barebox version, MAC address (which may be random due to the lack of a NIC > EEPROM) and some vendor specific parameters are passed to the kernel via DTB. > A dedicated command was implemented which can either patch the existing DTB or > generate an overlay DTB. In the latter case the overlay DTB is passed to the > kernel with the help of a new `bootm` option. Of course the latter approach > requires support on the kernel side. We could of course pass the barebox version in the /chosen node. That would require a of_register_fixup(). Why would we need an extra command for that? The MAC address should already be inserted into the kernel device tree automatically. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Pass barebox version to kernel 2018-02-27 8:34 ` Sascha Hauer @ 2018-02-27 19:43 ` Peter Mamonov 2018-02-28 7:34 ` Sascha Hauer 0 siblings, 1 reply; 5+ messages in thread From: Peter Mamonov @ 2018-02-27 19:43 UTC (permalink / raw) To: Sascha Hauer; +Cc: Barebox List On Tue, Feb 27, 2018 at 09:34:30AM +0100, Sascha Hauer wrote: > Hi Peter, > > On Mon, Feb 26, 2018 at 01:12:02PM +0300, Peter Mamonov wrote: > > Hi, Sasha, > > > > On Mon, Feb 26, 2018 at 09:23:49AM +0100, Sascha Hauer wrote: > > > When userspace is interested in the barebox version it has currently no > > > way of reliably reading it. Add it to the kernel command line as it's an > > > established way to pass information from the bootloader to the kernel. > > > If CONFIG_FLEXIBLE_BOOTARGS is enabled then the barebox version is > > > passed in the "bootloader.version=" variable. > > > > Some time ago we solved a similar problem: a number of parameters including > > barebox version, MAC address (which may be random due to the lack of a NIC > > EEPROM) and some vendor specific parameters are passed to the kernel via DTB. > > A dedicated command was implemented which can either patch the existing DTB or > > generate an overlay DTB. In the latter case the overlay DTB is passed to the > > kernel with the help of a new `bootm` option. Of course the latter approach > > requires support on the kernel side. > > We could of course pass the barebox version in the /chosen node. That > would require a of_register_fixup(). Why would we need an extra command > for that? Well, it allows some extra flexibility: either original DTB is patched or a separate DTB blob is generated. However there is no strict need for a command. My actual point is that passing various bootloader stuff to a kernel via DTB feels like a cleaner solution, rather than using kernel cmdline for that purpose. Regards, Peter > The MAC address should already be inserted into the kernel device tree > automatically. > > Sascha > > -- > Pengutronix e.K. | | > Industrial Linux Solutions | http://www.pengutronix.de/ | > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Pass barebox version to kernel 2018-02-27 19:43 ` Peter Mamonov @ 2018-02-28 7:34 ` Sascha Hauer 0 siblings, 0 replies; 5+ messages in thread From: Sascha Hauer @ 2018-02-28 7:34 UTC (permalink / raw) To: Peter Mamonov; +Cc: Barebox List On Tue, Feb 27, 2018 at 10:43:59PM +0300, Peter Mamonov wrote: > On Tue, Feb 27, 2018 at 09:34:30AM +0100, Sascha Hauer wrote: > > Hi Peter, > > > > On Mon, Feb 26, 2018 at 01:12:02PM +0300, Peter Mamonov wrote: > > > Hi, Sasha, > > > > > > On Mon, Feb 26, 2018 at 09:23:49AM +0100, Sascha Hauer wrote: > > > > When userspace is interested in the barebox version it has currently no > > > > way of reliably reading it. Add it to the kernel command line as it's an > > > > established way to pass information from the bootloader to the kernel. > > > > If CONFIG_FLEXIBLE_BOOTARGS is enabled then the barebox version is > > > > passed in the "bootloader.version=" variable. > > > > > > Some time ago we solved a similar problem: a number of parameters including > > > barebox version, MAC address (which may be random due to the lack of a NIC > > > EEPROM) and some vendor specific parameters are passed to the kernel via DTB. > > > A dedicated command was implemented which can either patch the existing DTB or > > > generate an overlay DTB. In the latter case the overlay DTB is passed to the > > > kernel with the help of a new `bootm` option. Of course the latter approach > > > requires support on the kernel side. > > > > We could of course pass the barebox version in the /chosen node. That > > would require a of_register_fixup(). Why would we need an extra command > > for that? > > Well, it allows some extra flexibility: either original DTB is patched or a > separate DTB blob is generated. However there is no strict need for a command. > > My actual point is that passing various bootloader stuff to a kernel via DTB > feels like a cleaner solution, rather than using kernel cmdline for that > purpose. I tend to buy that argument. Especially when the stuff the bootloader wants to pass becomes more and more then the device tree seems like a good place. The downside is that not all boards have a devicetree (not counting legacy boards here, but for example UEFI boards). Any other opinions? We could also do both. If we only pass the version then this would be ok I guess, but I have no idea where this leads to. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-28 7:35 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-02-26 8:23 [PATCH] Pass barebox version to kernel Sascha Hauer 2018-02-26 10:12 ` Peter Mamonov 2018-02-27 8:34 ` Sascha Hauer 2018-02-27 19:43 ` Peter Mamonov 2018-02-28 7:34 ` Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox