Repository navigation
allwinner-v83x: boot from the SD card first, and say so in boot_media - #204
Conversation
The mask ROM tries the card before the SPI NOR: an eGON.BT0 at sector 16 of the SD card wins. The stub ROM did not look there, so OpenIPC's SD card U-Boot images (u-boot-v83x-mmc.bin, mainline SPL) could not be tested. It also writes the medium into the eGON header's boot_media word (0x28; 0 card, 3 NOR) as the ROM does: mainline's sunxi SPL decides from it where to load U-Boot. The YI camera dump still boots to its kernel (boot0 does not read the word), and so does a flash with a card holding no SPL.
PR Summary by QodoBoot Allwinner V83x from SD before SPI NOR
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. A damaged card can block flash boot
|
| aw_boot0_ok(sdimg, AW_BOOT0_MAX, &plen)) { | ||
| boot0 = sdimg; | ||
| media = AW_BOOT_MEDIA_MMC0; |
There was a problem hiding this comment.
1. A damaged card can block flash boot 🐞 Bug ≡ Correctness
aw_boot0_ok() accepts an SD image with the eGON magic and a plausible length without checking the header checksum. When such an image is present at sector 16, the new SD-first branch selects it and skips a valid SPI NOR boot image.
Agent Prompt
## Issue description
A checksum-corrupt SD boot image can take priority over a valid SPI NOR image because the SD selection uses a magic-and-length-only check.
## Fix Focus Areas
- qemu/hw/arm/allwinner-v83x.c[224-236]
- qemu/hw/arm/allwinner-v83x.c[553-563]
## Recommended Fix
Validate the complete eGON image, including its checksum, before selecting the SD card. On validation failure, continue to the SPI NOR fallback.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| sdimg = boot0; | ||
| } | ||
| if (boot0) { | ||
| boot0[AW_EGON_BOOT_MEDIA] = media; |
There was a problem hiding this comment.
2. Boot media can retain the wrong value 🐞 Bug ≡ Correctness
boot0[AW_EGON_BOOT_MEDIA] = media replaces only one byte of the header’s 32-bit boot-media word. If the source image has nonzero bytes in the rest of that word, the loaded image contains neither documented media value when the SPL reads it.
Agent Prompt
## Issue description
The ROM stub changes only the low byte of the boot-media word, leaving the value dependent on the image’s original upper bytes.
## Fix Focus Areas
- qemu/hw/arm/allwinner-v83x.c[572-576]
## Recommended Fix
Store the selected media value as a little-endian 32-bit word at the boot-media offset in the loaded image copy.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
The V831/V833 mask ROM tries the SD card before the SPI NOR: an eGON.BT0 at sector 16 of the card wins. The stub ROM only looked at the flash, so OpenIPC's SD card U-Boot images (
u-boot-v831-mmc.bin/u-boot-v833-mmc.bin, mainline SPL withSPL_MMC, OpenIPC/u-bootopenipc-allwinner) could not be booted.-drive if=sdholding an eGON.BT0 at 8 KiB, that is loaded instead of the flash's.boot_mediaword (0x28: 0 SD card, 3 SPI NOR), as the ROM writes it: mainline's sunxi SPL decides from it where to load U-Boot. boot0 does not read it.Checked:
qemu-boot/test-v831-boot.sh's card).u-boot-v831-mmc.bin/u-boot-v833-mmc.binon a card with an erased flash reach the U-Boot prompt; a card with the image andu-boot-v831-nor.bin,uImage.v831,rootfs.squashfs.v831on FAT unbricks an erased flash (run ub,run fwupd, then the NOR boots the kernel to its root).-nor.bin) boot as before.Needed by the
-mmcsmoke legs of OpenIPC/u-boot'sbuild-allwinner.yml.