[PATCH v2] Makefile: fix generating environment file
Oleksandr Suvorov
oleksandr.suvorov at toradex.com
Wed Apr 21 17:21:59 CEST 2021
Hi Rasmus,
On Wed, Apr 21, 2021 at 12:34 AM Rasmus Villemoes
<rasmus.villemoes at prevas.dk> wrote:
>
> On 20/04/2021 23.10, Oleksandr Suvorov wrote:
> > Hi Rasmus,
> >
> > Thanks for your feedback!
> > Yes, I noted that there were no possible situations with the trailing
> > code != 0x00, but simply removing the additional trailing 0x00
> > gives us an empty array default_environment[] for the empty defaultenv file.
> > I need to test whether this case is handled in u-boot properly and
> > then prepare the next patch version :P
>
> No, I'm not suggesting removing the trailing nul byte, it very much has
> to be there - the binary format of the environment is a sequence of
> nul-terminated C strings of the key=value form, concatenated
> back-to-back, terminated by an empty string.
(/me saying: never answer at night, never answer at night, never
answer at night :-D)
>
> What I'm suggesting is to take the input file
>
> ===
> foo=bar
>
> # Set our IP address
> ip=1.2.3.4
> ===
>
> do the comment- and empty-line stripping (the two first greps), and then
> after that add an extra empty line
>
> ===
> foo=bar
> ip=1.2.3.4
>
> ===
>
> and then feed that to the 'replace \n by nul bytes' | 'delete
> backslash+nul+whitespace' | xxd pipe. That way there's always that
> trailing nul on the input to xxd, i.e. in the example above, we would
> feed foo=bar\0ip-1.2.3.4\0\0 into xxd, while with an initially empty
> file xxd would just receive that single nul byte.
>
> It's just that I think terminating the sequence of key=value lines by an
> empty line more exactly matches the binary format.
Sure, now I see. Your solution is more straight and clear.
Unfortunately, it doesn't work :)
So if you don't mind, I'll try to make it work as it should and post
the next version of the patch.
>
> Rasmus
--
Best regards
Oleksandr Suvorov
Toradex AG
Ebenaustrasse 10 | 6048 Horw | Switzerland | T: +41 41 500 48 00
More information about the U-Boot
mailing list