mirror of https://github.com/wolfSSL/wolfBoot.git
sdcard_card_full_init() polled ACMD41 in an unbounded do/while until the card set OCR ready, so a card that answers every ACMD41 without ever setting the bit held the bootloader in the loop forever. F-7984 bounded the separate DATA0/CMD13 waits in sdhci_wait_busy(); this is the OCR readiness path, which still had no limit. Bound the poll with the same shape as sdhci_wait_busy(): a 30000 ms budget (SDCARD_ACMD41_TIMEOUT_MS, #ifndef-able) measured against hal_get_timer_us(), the watchdog serviced inside the loop, and -1 returned to fail the SD boot path. A healthy card reports ready in milliseconds, so the budget is far above any real initialization time. unit-sdhci-acmd41-timeout compiles the real driver (generated sdhci_host.c, as in the wait-busy test) against a scripted controller: commands complete without error, SRS12 is modeled write-1-to-clear, and the card model sets OCR ready after a configurable number of ACMD41 polls. A never-ready card must return -1 inside the shipped budget (and service the watchdog); a card ready after 5 polls must exit the loop promptly and proceed to the end of the init path. A command-write cap turns the pre-fix infinite loop into an abort instead of a hung build. Verification: - Built: gcc (host) unit-sdhci-acmd41-timeout with -DDISK_SDCARD: clean. - Tested: unit-sdhci-acmd41-timeout 2/2; pre-fix the never-ready case aborted at the 50001st command (the loop never terminates); post-fix it runs 3001 polls, reaches the 30 s budget, pets the watchdog every iteration and returns -1. - Pitfalls: the timeout returns -1 from the SD path, the same contract as a failed CMD0/CMD8; the budget is per init call, not shared with sdhci_wait_busy, and a card that becomes ready before the deadline is unaffected. - Style: cstyle-check.sh FMT diff on src/sdhci.c byte-identical to the pre-change file; the new test is flag-free. - Unverified: no SD card hardware execution. - Message: F-11032: prefix, no co-author trailers. |
||
|---|---|---|
| .. | ||
| armclang | ||
| bin-assemble | ||
| check_config | ||
| ci | ||
| delta | ||
| efi | ||
| elf-parser | ||
| fdt-parser | ||
| keytools | ||
| lms | ||
| openocd | ||
| renode | ||
| sbom | ||
| scripts | ||
| squashelf | ||
| test-expect-version | ||
| test-update-server | ||
| tpm | ||
| uart-flash-server | ||
| unit-tests | ||
| xmss | ||
| config.mk | ||
| test-delta.mk | ||
| test-enc.mk | ||
| test-renode.mk | ||
| test.mk | ||
| wolfboot-rpi-devicetree.diff | ||