Skip to contentSkip to conversation

expand macros in bootargs env var for bootm command

PATCH New Murray.Jensen at csiro.au 2 participants 6 messages Jun 30, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 expand macros in bootargs env var for bootm command

This patch expands $(...) macros present in the bootargs environment variable for the bootm command. Same code could be (and probably should be, for consistencies sake) used in other boot commands. Required exposing the "process_macros()" function in common/main.c. Cheers!

								Murray...
Signature · 20 lines
Murray Jensen, CSIRO Manufacturing & Infra. Tech.      Phone: +61 3 9662 7763
Locked Bag No. 9, Preston, Vic, 3072, Australia.         Fax: +61 3 9662 7853
Internet: Murray.Jensen at csiro.au

To the extent permitted by law, CSIRO does not represent, warrant and/or
guarantee that the integrity of this communication has been maintained or
that the communication is free of errors, virus, interception or interference.

The information contained in this e-mail may be confidential or privileged.
Any unauthorised use or disclosure is prohibited. If you have received this
e-mail in error, please delete it immediately and notify Murray Jensen on
+61 3 9662 7763. Thank you.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: EXPAND-M.PAT
Type: text/x-patch
Size: 1663 bytes
Desc: expand-macros-in-bootargs.patch
Url : http://lists.denx.de/pipermail/u-boot/attachments/20050630/3065cd24/attachment.bin 
#1 lore raw

PATCH 1/1 expand macros in bootargs env var for bootm command

Quoted 5 lines · In message <29194.1120112716@gerd> you wrote:

This patch expands $(...) macros present in the bootargs environment variable for the bootm command. Same code could be (and probably should be, for consistencies sake) used in other boot commands. Required exposing the "process_macros()" function in common/main.c. Cheers!

Please explain in a little more detail which problem this patch is supposed to fix or which extension it is supposed to implement?

Also, please stick with the rules for submitting patches.

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The thing is, as you progress in the Craft,  you'll  learn  there  is
another rule... When you break rules, break 'em good and hard.
                                    - Terry Pratchett, _Wyrd Sisters_
#2 lore raw

PATCH 1/1 expand macros in bootargs env var for bootm command

Quoted 2 lines · Wolfgang Denk

Please explain in a little more detail which problem this patch is supposed to fix or which extension it is supposed to implement?

I wanted to define the flash partition map in the kernel command line. I want to do this with reference to other u-boot environment variables, which contain the start addresses and sizes for each partition (just numbers).

I found that if the "bootargs" environment variable contained macros, they were not expanded before the command line was passed to the kernel. The patch does this expansion.

Quoted 1 line

Also, please stick with the rules for submitting patches.

No worries - I will do that, except I don't know what they are. Where are the rules defined? If you can give me a link I will study them before I submit any more patches.

Note that a search of the mailing list archive using "patch submission guidelines" as the keywords (which I did after reading your next email) returned only one reference - your next email (i.e. I spent some time hunting around for them, but couldn't find them). Cheers!

								Murray...

--
Murray Jensen, CSIRO Manufacturing & Infra. Tech. Phone: +61 3 9662 7763
Locked Bag No. 9, Preston, Vic, 3072, Australia. Fax: +61 3 9662 7853
Internet: Murray.Jensen at csiro.au

To the extent permitted by law, CSIRO does not represent, warrant and/or guarantee that the integrity of this communication has been maintained or that the communication is free of errors, virus, interception or interference.

The information contained in this e-mail may be confidential or privileged. Any unauthorised use or disclosure is prohibited. If you have received this e-mail in error, please delete it immediately and notify Murray Jensen on +61 3 9662 7763. Thank you.

#3 lore raw

PATCH 1/1 expand macros in bootargs env var for bootm command

Quoted 5 lines · In message <7938.1120137797@huldra> you wrote:

I wanted to define the flash partition map in the kernel command line. I want to do this with reference to other u-boot environment variables, which contain the start addresses and sizes for each partition (just numbers).

We're working on something in this area, too (allowing U-Boot to "edit" the partitions, especially on NAND devices, and to automa- tically generate the required kernel arguments.

Quoted 1 line

I found that if the "bootargs" environment variable contained macros, they

This is intentional.

Quoted 2 lines

were not expanded before the command line was passed to the kernel. The patch does this expansion.

You can expand all macros when building the bootargs variable like it is shown in all the examples in the DULG; is there any problem with that?

Quoted 3 lines

No worries - I will do that, except I don't know what they are. Where are the rules defined? If you can give me a link I will study them before I submit any more patches.

See section "Submitting Patches" in the README.

There is no excuse for not reding the README.

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
At the source of every error which is blamed on the computer you will
find at least two human errors, including the error of blaming it  on
the computer.
#4 lore raw

PATCH 1/1 expand macros in bootargs env var for bootm command

Quoted 3 lines · Wolfgang Denk

You can expand all macros when building the bootargs variable like it is shown in all the examples in the DULG; is there any problem with that?

Quoting from the DULG:

"We can use U-Boot environment variables to store all necessary configuration parameters:

=> setenv ipaddr 10.0.0.99
=> setenv serverip 10.0.0.2
=> setenv netmask 255.0.0.0
=> setenv hostname tqm
=> setenv rootpath /opt/eldk/ppc_8xx
=> saveenv

Then you can use these variables to build the boot arguments to be passed to the Linux kernel:

=> setenv bootargs root=/dev/nfs rw nfsroot=\$(serverip):\$(rootpath) ip=\$(ipaddr):\$(serverip):\$(gatewayip):\$(netmask):\$(hostname)::off

Note how backslashes are used to delay the substitution of the referenced environment variables. This way, the current values of these variables get inserted when the "bootargs" variable itself is used, i. e. when the kernel gets booted. This allows us to simply redefine any of the variables (say, the value of "ipaddr" if it has to be changed), and the changes will automatically propagate to the Linux kernel."

But I found that this (or at least, an almost identical situation) simply didn't work. Macros in the bootargs variable weren't expanded when the kernel was booted. Maybe I've missed something?

Quoted 3 lines

See section "Submitting Patches" in the README.

There is no excuse for not reding the README.

Except that I read the README file many years ago before this section was in there. Obviously, I need to re-read it. Cheers!

								Murray...

--
Murray Jensen, CSIRO Manufacturing & Infra. Tech. Phone: +61 3 9662 7763
Locked Bag No. 9, Preston, Vic, 3072, Australia. Fax: +61 3 9662 7853
Internet: Murray.Jensen at csiro.au

To the extent permitted by law, CSIRO does not represent, warrant and/or guarantee that the integrity of this communication has been maintained or that the communication is free of errors, virus, interception or interference.

The information contained in this e-mail may be confidential or privileged. Any unauthorised use or disclosure is prohibited. If you have received this e-mail in error, please delete it immediately and notify Murray Jensen on +61 3 9662 7763. Thank you.

#5 lore raw

PATCH 1/1 expand macros in bootargs env var for bootm command

Quoted 2 lines · In message <9752.1120142248@huldra> you wrote:

Quoting from the DULG:

...

Quoted 1 line

=> setenv bootargs root=/dev/nfs rw nfsroot=\$(serverip):\$(rootpath) ip=\$(ipaddr):\$(serverip):\$(gatewayip):\$(netmask):\$(hostname)::off

...

And, did you try this out? It works fine for me.

Quoted 3 lines

But I found that this (or at least, an almost identical situation) simply didn't work. Macros in the bootargs variable weren't expanded when the kernel was booted. Maybe I've missed something?

Maybe. I cannot tell without knowing what you "almost identical situation" was exactly.

Quoted 2 lines

Except that I read the README file many years ago before this section was in there. Obviously, I need to re-read it. Cheers!

You should re-read every time it changes, and ideally before each posting :-)

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
1st Old Man:  Gee, its windy today.
2nd Old Man:  No it's not... it's Thursday.
3rd Old Man:  Yeh, me too.  Let's go for a beer.