Repository navigation
openipc: SD/USB recovery writes every uImage-wrapped *.img at its address - #44
Conversation
…ress Recovery from a card or stick looked for files by name (firmware.bin, the per-SoC kernel and rootfs names), had a special path for a split firmware.bin, and wrote the wrapper's header along with the payload. Make it one rule, the same on every branch: - script.txt still runs first; - otherwise every *.img in the root, in directory order, that is a valid uImage (magic, header CRC, data CRC) whose load address plus data size fit the flash, starting on an erase boundary, and that fits in RAM, has its payload -- never the wrapper header -- written at the load address. Whatever it is (U-Boot at 0, a kernel, a rootfs, a whole firmware) is the card author's call; - an image already on the flash is skipped, so a card left in the slot does not rewrite anything; the boot then goes on as usual; - the SPI NAND path (rootfs.ubifs.<soc>.img) is unchanged. The split firmware.bin path and the name lookups go. Under qemu-hisilicon on openipc-gk710x (gk7102, gk7102s) and openipc-xm (xm530), with this file byte for byte: U-Boot, kernel and rootfs images written at their load addresses and booted; bad data CRC, non-uImage, past-the-end and off-boundary images skipped; a second boot finds them all already on the flash.
PR Summary by QodoRecover uImage payloads from SD or USB at their flash addresses
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Recovered kernels can remain unbootable
|
…iled script - script.txt was read to CONFIG_SYS_LOAD_ADDR whatever its size; one larger than the free RAM below the stack would have run over U-Boot. It now gets the same bound as the images (recovery_ram_room()). - a uImage wrapper with a data size of 0 passed every check and was then read with length 0, which the FAT read takes as "the rest of the file", past the RAM bound. It is skipped now. - a script that fails is reported as failed. It still ends recovery: the card author chose a script over the images. Under qemu-hisilicon gk7102: a 0-length wrapper in front of 2 MiB is "has no data, skipped", and the rest of the card recovers as before. Reported by Qodo on #44, #45 and #46.
…iled script - script.txt was read to CONFIG_SYS_LOAD_ADDR whatever its size; one larger than the free RAM below the stack would have run over U-Boot. It now gets the same bound as the images (recovery_ram_room()). - a uImage wrapper with a data size of 0 passed every check and was then read with length 0, which the FAT read takes as "the rest of the file", past the RAM bound. It is skipped now. - a script that fails is reported as failed. It still ends recovery: the card author chose a script over the images. Under qemu-hisilicon gk7102: a 0-length wrapper in front of 2 MiB is "has no data, skipped", and the rest of the card recovers as before. Reported by Qodo on #44, #45 and #46.
…iled script - script.txt was read to CONFIG_SYS_LOAD_ADDR whatever its size; one larger than the free RAM below the stack would have run over U-Boot. It now gets the same bound as the images (recovery_ram_room()). - a uImage wrapper with a data size of 0 passed every check and was then read with length 0, which the FAT read takes as "the rest of the file", past the RAM bound. It is skipped now. - a script that fails is reported as failed. It still ends recovery: the card author chose a script over the images. Under qemu-hisilicon gk7102: a 0-length wrapper in front of 2 MiB is "has no data, skipped", and the rest of the card recovers as before. Reported by Qodo on #44, #45 and #46.
script.txt is read on SPI NAND builds too, so its RAM bound has to be there as well; the helper sat in the NOR-only section and every NOR+NAND HiSilicon build failed to link (undefined reference to recovery_ram_room).
One recovery rule for every branch (
common/openipc.cis to be byte for byte the same on openipc-hisilicon, openipc-xm and openipc-gk710x):script.txtstill runs first;*.imgin the card's or stick's root, in directory order, that is a valid uImage (magic, header CRC, data CRC) whose load address + data size fit the flash, on an erase boundary, and fits in RAM, has its payload written at the load address. The wrapper header is never written. U-Boot at 0 included;rootfs.ubifs.<soc>.img) is unchanged;firmware.binpath and the per-name lookups are gone.Tested: under qemu-hisilicon on openipc-gk710x (gk7102, gk7102s) and openipc-xm (xm530), with this exact file: images written and booted; bad data CRC, non-uImage, past-the-end and off-boundary images skipped with a message; a second boot finds everything already on the flash.
Not tested: a HiSilicon build or boot. This host's gcc 15 cannot build the vendor tree, so this PR's CI is the first build of it on HiSilicon SoCs.