* how to persistently save config values
@ 2017-09-29 8:25 Giorgio Dal Molin
2017-09-29 9:02 ` Oleksij Rempel
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Giorgio Dal Molin @ 2017-09-29 8:25 UTC (permalink / raw)
To: barebox
Hi,
I'm working on a new project with an embedded system based on
a standard intel PC.
I already have a barebox.efi running on the system; my problem is now
how to permanently save some variables so that, on restart, they can be
automatically restored by my '/env/bin/init' script.
The variables I mean are for example 'eth0.ipaddr' or 'eth0.serveraddr'.
A solution I used in the past was a custom 'env_dump' command that generated
a config text file like:
eth0.ipaddr=10.0.0.15
eth0.serveraddr=10.0.0.1
...
Then I saved the file with 'saveenv' and restored it back with 'loadenv'.
Is there a better way to solve this problem ? I don't like very much having to
write 'custom commands' myself.
I had a look at the state framework but it seems kinda overkill for what I need.
giorgio
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to persistently save config values
2017-09-29 8:25 how to persistently save config values Giorgio Dal Molin
@ 2017-09-29 9:02 ` Oleksij Rempel
2017-09-29 9:27 ` B Gol
2017-09-29 11:35 ` Sascha Hauer
2 siblings, 0 replies; 7+ messages in thread
From: Oleksij Rempel @ 2017-09-29 9:02 UTC (permalink / raw)
To: Giorgio Dal Molin, barebox
[-- Attachment #1.1.1: Type: text/plain, Size: 1190 bytes --]
Hi,
http://www.barebox.org/doc/latest/user/booting-linux.html#network-boot
Am 29.09.2017 um 10:25 schrieb Giorgio Dal Molin:
> Hi,
>
> I'm working on a new project with an embedded system based on
> a standard intel PC.
>
> I already have a barebox.efi running on the system; my problem is now
> how to permanently save some variables so that, on restart, they can be
> automatically restored by my '/env/bin/init' script.
> The variables I mean are for example 'eth0.ipaddr' or 'eth0.serveraddr'.
> A solution I used in the past was a custom 'env_dump' command that generated
> a config text file like:
>
> eth0.ipaddr=10.0.0.15
> eth0.serveraddr=10.0.0.1
> ...
>
> Then I saved the file with 'saveenv' and restored it back with 'loadenv'.
>
> Is there a better way to solve this problem ? I don't like very much having to
> write 'custom commands' myself.
>
> I had a look at the state framework but it seems kinda overkill for what I need.
>
> giorgio
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Regards,
Oleksij
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to persistently save config values
2017-09-29 8:25 how to persistently save config values Giorgio Dal Molin
2017-09-29 9:02 ` Oleksij Rempel
@ 2017-09-29 9:27 ` B Gol
2017-09-29 10:25 ` Giorgio Dal Molin
2017-09-29 11:35 ` Sascha Hauer
2 siblings, 1 reply; 7+ messages in thread
From: B Gol @ 2017-09-29 9:27 UTC (permalink / raw)
To: Barebox List
I just put all the variables in the source directory and then compile again.
Look inside the following dir and its sub dirs, you'll see all the default(hard coded)
variables inside it:
/source-path/barebox-yyyy.mm.d/defaultenv/
Simply make a text file inside a sub dir.The file name would be your variable name and
the string inside the file would be the value for that particular variable.
On Friday, September 29, 2017 12:20 PM, Giorgio Dal Molin <giorgio.nicole@arcor.de> wrote:
Hi,
I'm working on a new project with an embedded system based on
a standard intel PC.
I already have a barebox.efi running on the system; my problem is now
how to permanently save some variables so that, on restart, they can be
automatically restored by my '/env/bin/init' script.
The variables I mean are for example 'eth0.ipaddr' or 'eth0.serveraddr'.
A solution I used in the past was a custom 'env_dump' command that generated
a config text file like:
eth0.ipaddr=10.0.0.15
eth0.serveraddr=10.0.0.1
...
Then I saved the file with 'saveenv' and restored it back with 'loadenv'.
Is there a better way to solve this problem ? I don't like very much having to
write 'custom commands' myself.
I had a look at the state framework but it seems kinda overkill for what I need.
giorgio
_______________________________________________
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] 7+ messages in thread
* Re: how to persistently save config values
2017-09-29 9:27 ` B Gol
@ 2017-09-29 10:25 ` Giorgio Dal Molin
0 siblings, 0 replies; 7+ messages in thread
From: Giorgio Dal Molin @ 2017-09-29 10:25 UTC (permalink / raw)
To: Barebox List, B Gol
Hi,
thanks for your answer but I think this is not really what I need.
I need a way to configure and change the variable values at runtime.
The envfs with the loadenv and saveenv commands is OK, what I'm missing
is a way to 'edit' the environment before I can save it back to the persistent
storage.
I'm thinking about adding some options to printenv to let it dump the variables
given on its command line to a file.
giorgio
> On September 29, 2017 at 11:27 AM B Gol wrote:
>
> I just put all the variables in the source directory and then compile again.
> Look inside the following dir and its sub dirs, you'll see all the default(hard coded)
> variables inside it:
>
> /source-path/barebox-yyyy.mm.d/defaultenv/
>
> Simply make a text file inside a sub dir.The file name would be your variable name and
> the string inside the file would be the value for that particular variable.
>
> On Friday, September 29, 2017 12:20 PM, Giorgio Dal Molin wrote:
>
> Hi,
>
> I'm working on a new project with an embedded system based on
>
> a standard intel PC.
>
> I already have a barebox.efi running on the system; my problem is now
>
> how to permanently save some variables so that, on restart, they can be
>
> automatically restored by my '/env/bin/init' script.
>
> The variables I mean are for example 'eth0.ipaddr' or 'eth0.serveraddr'.
>
> A solution I used in the past was a custom 'env_dump' command that generated
>
> a config text file like:
>
> eth0.ipaddr=10.0.0.15
>
> eth0.serveraddr=10.0.0.1
>
> ...
>
> Then I saved the file with 'saveenv' and restored it back with 'loadenv'.
>
> Is there a better way to solve this problem ? I don't like very much having to
>
> write 'custom commands' myself.
>
> I had a look at the state framework but it seems kinda overkill for what I need.
>
> giorgio
>
> _______________________________________________
>
> 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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to persistently save config values
2017-09-29 8:25 how to persistently save config values Giorgio Dal Molin
2017-09-29 9:02 ` Oleksij Rempel
2017-09-29 9:27 ` B Gol
@ 2017-09-29 11:35 ` Sascha Hauer
2017-09-29 12:31 ` Giorgio Dal Molin
2 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2017-09-29 11:35 UTC (permalink / raw)
To: Giorgio Dal Molin; +Cc: barebox
On Fri, Sep 29, 2017 at 10:25:03AM +0200, Giorgio Dal Molin wrote:
> Hi,
>
> I'm working on a new project with an embedded system based on
> a standard intel PC.
>
> I already have a barebox.efi running on the system; my problem is now
> how to permanently save some variables so that, on restart, they can be
> automatically restored by my '/env/bin/init' script.
> The variables I mean are for example 'eth0.ipaddr' or 'eth0.serveraddr'.
> A solution I used in the past was a custom 'env_dump' command that generated
> a config text file like:
>
> eth0.ipaddr=10.0.0.15
> eth0.serveraddr=10.0.0.1
(should be eth0.serverip)
> ...
>
> Then I saved the file with 'saveenv' and restored it back with 'loadenv'.
Normally you should edit /env/network/eth0 to change the network config.
Also there is the possibility to create a nv variable that automatically
mirrors to the device variable. In this case it would be
nv.dev.eth0.ipaddr and nv.dev.eth0.serverip. This doesn't work with dhcp
though.
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] 7+ messages in thread
* Re: how to persistently save config values
2017-09-29 11:35 ` Sascha Hauer
@ 2017-09-29 12:31 ` Giorgio Dal Molin
2017-09-29 13:00 ` Sascha Hauer
0 siblings, 1 reply; 7+ messages in thread
From: Giorgio Dal Molin @ 2017-09-29 12:31 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Hi Sascha,
thank you for the answer.
I just experimented a bit with the environment and the nv vars
and I think I'll go this way.
I was a bit surprised by the saveenv command though: my understanding
of the (default) environment was that it was a read only blob
hardcoded in the barebox image; I thought if I want some new/dynamic
env content to be saved for the next reboot I have to explicitly provide
a storage disk/cf/mtd partition to the saveenv and then to the loadenv.
Instead, just saying 'saveenv' saves the contents of '/env' 'somewhere'
from where it can be restored on next reboot (very good!).
Together with the nv vars and the 'nv.dev.' prefix this just does the
trick for me.
Thank you.
giorgio
> On September 29, 2017 at 1:35 PM Sascha Hauer wrote:
>
> On Fri, Sep 29, 2017 at 10:25:03AM +0200, Giorgio Dal Molin wrote:
> > Hi,
> >
> > I'm working on a new project with an embedded system based on
> > a standard intel PC.
> >
> > I already have a barebox.efi running on the system; my problem is now
> > how to permanently save some variables so that, on restart, they can be
> > automatically restored by my '/env/bin/init' script.
> > The variables I mean are for example 'eth0.ipaddr' or 'eth0.serveraddr'.
> > A solution I used in the past was a custom 'env_dump' command that generated
> > a config text file like:
> >
> > eth0.ipaddr=10.0.0.15
> > eth0.serveraddr=10.0.0.1
>
> (should be eth0.serverip)
> > ...
> >
> > Then I saved the file with 'saveenv' and restored it back with 'loadenv'.
>
> Normally you should edit /env/network/eth0 to change the network config.
>
> Also there is the possibility to create a nv variable that automatically
> mirrors to the device variable. In this case it would be
> nv.dev.eth0.ipaddr and nv.dev.eth0.serverip. This doesn't work with dhcp
> though.
>
> 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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to persistently save config values
2017-09-29 12:31 ` Giorgio Dal Molin
@ 2017-09-29 13:00 ` Sascha Hauer
0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2017-09-29 13:00 UTC (permalink / raw)
To: Giorgio Dal Molin; +Cc: barebox
On Fri, Sep 29, 2017 at 02:31:40PM +0200, Giorgio Dal Molin wrote:
> Hi Sascha,
>
> thank you for the answer.
>
> I just experimented a bit with the environment and the nv vars
> and I think I'll go this way.
>
> I was a bit surprised by the saveenv command though: my understanding
> of the (default) environment was that it was a read only blob
> hardcoded in the barebox image
Yes, it is.
> I thought if I want some new/dynamic
> env content to be saved for the next reboot I have to explicitly provide
> a storage disk/cf/mtd partition to the saveenv and then to the loadenv.
Yes, true. Normally the board code provides a storage place. In case of
UEFI the storage place is set to a EFI Variable in common/efi/efi.c:305
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] 7+ messages in thread
end of thread, other threads:[~2017-09-29 13:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 8:25 how to persistently save config values Giorgio Dal Molin
2017-09-29 9:02 ` Oleksij Rempel
2017-09-29 9:27 ` B Gol
2017-09-29 10:25 ` Giorgio Dal Molin
2017-09-29 11:35 ` Sascha Hauer
2017-09-29 12:31 ` Giorgio Dal Molin
2017-09-29 13:00 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox