fix: import first variable from auxiliary environment#1483
Merged
wkz merged 1 commit intokernelkit:mainfrom Apr 30, 2026
Merged
fix: import first variable from auxiliary environment#1483wkz merged 1 commit intokernelkit:mainfrom
wkz merged 1 commit intokernelkit:mainfrom
Conversation
Contributor
|
@wkz could you have a look at this, please? |
Contributor
|
This looks like the right fix 👍 I would prefer a bit more thorough commit message though:
|
Contributor
Author
|
Thank you for the review @wkz , as discussed below are runs with -b and -c to compare: No Fix(-b) (ixboot) load ${devtype} ${devnum}:${auxpart} ${loadaddr} /uboot.env
16384 bytes read in 0 ms
(ixboot) md.b ${loadaddr} 100
40200000: b0 f2 30 3b 42 4f 4f 54 5f 4f 52 44 45 52 3d 70 ..0;BOOT_ORDER=p
40200010: 72 69 6d 61 72 79 20 73 65 63 6f 6e 64 61 72 79 rimary secondary
40200020: 20 6e 65 74 00 42 4f 4f 54 5f 70 72 69 6d 61 72 net.BOOT_primar
40200030: 79 5f 4c 45 46 54 3d 31 00 42 4f 4f 54 5f 73 65 y_LEFT=1.BOOT_se
40200040: 63 6f 6e 64 61 72 79 5f 4c 45 46 54 3d 31 00 42 condary_LEFT=1.B
40200050: 4f 4f 54 5f 6e 65 74 5f 4c 45 46 54 3d 31 00 00 OOT_net_LEFT=1..
40200060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
40200070: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
40200080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
40200090: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
(ixboot) setenv BOOT_ORDER FOOBARNOTSET
(ixboot) env import -b ${loadaddr} ${filesize} BOOT_ORDER
(ixboot) printenv BOOT_ORDER
BOOT_ORDER=FOOBARNOTSET
(ixboot) setenv BOOT_primary_LEFT FOOBARNOTSET
(ixboot) env import -b ${loadaddr} ${filesize} BOOT_primary_LEFT
(ixboot) printenv BOOT_primary_LEFT
BOOT_primary_LEFT=1
(ixboot)With Fix(-c) (ixboot) load ${devtype} ${devnum}:${auxpart} ${loadaddr} /uboot.env
16384 bytes read in 0 ms
(ixboot) md.b ${loadaddr} 100
40200000: b0 f2 30 3b 42 4f 4f 54 5f 4f 52 44 45 52 3d 70 ..0;BOOT_ORDER=p
40200010: 72 69 6d 61 72 79 20 73 65 63 6f 6e 64 61 72 79 rimary secondary
40200020: 20 6e 65 74 00 42 4f 4f 54 5f 70 72 69 6d 61 72 net.BOOT_primar
40200030: 79 5f 4c 45 46 54 3d 31 00 42 4f 4f 54 5f 73 65 y_LEFT=1.BOOT_se
40200040: 63 6f 6e 64 61 72 79 5f 4c 45 46 54 3d 31 00 42 condary_LEFT=1.B
40200050: 4f 4f 54 5f 6e 65 74 5f 4c 45 46 54 3d 31 00 00 OOT_net_LEFT=1..
40200060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
40200070: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
40200080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
40200090: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
402000f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
(ixboot) printenv BOOT_ORDER
BOOT_ORDER=primary secondary net
(ixboot) setenv BOOT_ORDER FOOBARNOTSET
(ixboot) env import -c ${loadaddr} ${filesize} BOOT_ORDER
(ixboot) printenv BOOT_ORDER
BOOT_ORDER=primary secondary net
(ixboot) |
The U-Boot env file is generated by mkenvimage, which prefixes the variable data with a 4-byte CRC32 by default. ixpreboot.sh previously imported it with `env import -b` as per uboot docs(-b assume binary format (’0’ separated, “00” terminated).), which treats the buffer as raw binary and does not strip the CRC. As a result the first variable's name is parsed a part of CRC. Later variables import correctly because by then the parser is past the CRC. Switching to `env import -c` as per uboot docs (-c assume checksum protected environment format.) makes U-Boot validate and strip the CRC before parsing, so the first variable imports under its real name. Tested on: - QEMU Signed-off-by: Ejub Sabic <ejub1946@outlook.com>
72021cc to
29222e1
Compare
wkz
approved these changes
Apr 30, 2026
Contributor
wkz
left a comment
There was a problem hiding this comment.
Very nice to get to the bottom of this - great job! 🥇
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Checklist
Tick relevant boxes, this PR is-a or has-a: