Repository navigation
dump-flash, restore: stage in the board's own DRAM - #149
Merged
Merged
Conversation
Over a U-Boot console, dump-flash never handed -c to dump_flash(), which
then staged at a fixed 0x82000000. DRAM on ev200-era parts starts at
0x40000000, so on a gk7201v200 (XM U-Boot 2020.01, xm72010200)
defib dump-flash -p /dev/ttyUSB3 --size 8MB
ran `sf read 0x82000000 0x0 0x800000`, every md.b chunk came back empty
("Retry 1: no data at 0x1000"), the output stayed 0 bytes and U-Boot
wedged until a power cycle.
The CLI now passes -c through, which already resolves gk7201v200 to
0x42000000 via its profile. Without a chip, dump_flash() asks the running
U-Boot instead of guessing: bdinfo's DRAM bank start first, then the env's
soc= resolved through the exact RAM table or a profile only (no loose
prefix match). XM's vendor U-Boot has no bdinfo but does carry
soc=gk7201v200. If neither answers it refuses before any sf read and asks
for -c.
Verified on the gk7201v200 board above: without -c,
defib dump-flash -p /dev/ttyUSB3 --size 0x10000
logged "SoC from U-Boot env: gk7201v200", staged at 0x42000000, passed
16/16 per-block CRC32 checks, and two runs were byte-identical.
restore hardcoded ram_addr = 0x82000000 for every tftpboot and every sf/nand/mmc write. On parts whose DRAM starts at 0x40000000 (gk7201v200, gk7205v200, hi3516ev300, ...) that is an address with no memory behind it -- the same mistake that wedged U-Boot under dump-flash. restore always has -c, so use get_ram_staging_addr(chip), as install already does. 0x80000000-family chips still get 0x82000000, so nothing changes there. tests/test_restore_ram_staging.py drives the real restore command against a scripted U-Boot console and checks the load and write addresses for gk7201v200, hi3516ev300 and hi3516cv300, and that boot is still written last. Not run on hardware: restore erases flash, and the change is covered by the end-to-end test above.
Contributor
|
/review |
Code Review by Qodo
1.
|
Passing -c through meant a mistyped chip (-c gk7201v201 on a gk7201v200) fell into get_ram_staging_addr()'s prefix and fixed-0x82000000 fallbacks, and the sf read went back to the address that wedges U-Boot on 0x40000000-DRAM parts. dump_flash() now accepts a chip only through the exact RAM table or a profile; anything else is logged and handed to the same U-Boot detection as no -c at all (bdinfo, then env soc=), which refuses before any sf read when it cannot tell. restore keeps get_ram_staging_addr(): it cannot get that far with an unknown chip, since loading U-Boot already needs the chip's profile.
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.
dump-flash(over a U-Boot console) andrestoreboth staged at a fixed0x82000000. DRAM on ev200-era parts starts at0x40000000, so on those boards the address has no memory behind it.Found on a gk7201v200 (XM U-Boot 2020.01,
xm72010200):defib dump-flash -p /dev/ttyUSB3 --size 8MBransf read 0x82000000 0x0 0x800000, everymd.bchunk came back empty, the output stayed 0 bytes, and U-Boot wedged until a power cycle.dump-flash
-cthrough todump_flash().dump_flash()asks the running U-Boot instead of guessing. It triesbdinfo's DRAM bank start first, then the env'ssoc=, accepted only if the exact RAM table or a profile knows it. XM's vendor U-Boot has nobdinfobut does carrysoc=.sf readand asks for-c.restore
restorealways has-c, so it now usesget_ram_staging_addr(chip), asinstallalready does.0x80000000still get0x82000000.Testing
bdinfopath, the XM env-socpath, the refuse paths, explicit-c, and the CLI passing-cthrough.tests/test_restore_ram_staging.pyruns the realrestorecommand against a scripted U-Boot console for gk7201v200, hi3516ev300 and hi3516cv300. On the old code it fails for the two0x40000000chips.pytest(1031 passed),ruffandmypyare clean.dump-flashwas checked on the gk7201v200 board: without-cit logged "SoC from U-Boot env: gk7201v200", staged at0x42000000, passed 16/16 CRC32 blocks, and two runs were byte-identical.restorewas not run on hardware, because it erases flash.