Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve SDhost driver to fail gracefully when no card is present #14

Closed
andreiw opened this issue Apr 16, 2020 · 6 comments
Closed

Improve SDhost driver to fail gracefully when no card is present #14

andreiw opened this issue Apr 16, 2020 · 6 comments
Assignees

Comments

@andreiw
Copy link
Member

andreiw commented Apr 16, 2020

Booting UEFI from USB or network still requires an SD card, because the SDhost driver will loop forever on I/O errors. Unfortunately the Pi Foundation didn't wire up the card detect pin so we have to do something more creative.

@andreiw andreiw added bug Something isn't working uefi-future and removed bug Something isn't working labels Apr 16, 2020
@MagicRB
Copy link

MagicRB commented Apr 29, 2020

A stupid solution would be try 200 or so times and then assume no card there

@andreiw
Copy link
Member Author

andreiw commented Apr 30, 2020

something like that, yeah

@ehem
Copy link

ehem commented Jul 13, 2020

The log in pftf/RPi4#77 seems interesting. Notably that consistent "ERRI MmcStatus 0x18040" being an indicator of card absent. The alternative which comes to mind is adding something to the command-line to tell it to skip trying MMC.

@MagicRB
Copy link

MagicRB commented Jul 13, 2020

I kind of maybe unrelated question, but from what I had gathered the in-CPU bootloader only looks for stuff to boot on the sdcard, so how can you get this UEFI bios running, without an sdcard?

@pbatard
Copy link
Member

pbatard commented Jul 13, 2020

the in-CPU bootloader only looks for stuff to boot on the sdcard

That is not the case. The Pi 3 and Pi 4 on-die bootloader code is able to perform a lookup for boot files that reside on a USB drive. If you use a recent EEPROM with a recent start4.elf, you will get straight to USB boot.

@MagicRB
Copy link

MagicRB commented Jul 13, 2020

cool, i thought it didn't do that, you learn something new everyday ain't that right?

leiflindholm pushed a commit to tianocore/edk2-platforms that referenced this issue Jul 14, 2020
The Raspberry Pi 3 and Pi 4 platforms (with latest EEPROM) can boot
straight from USB, without the need for an SD card being present.
However, the IsCardPresent () calls from the ArasanMmcHost and SdHost
drivers are currently hardwired to return TRUE, which results in
straight to USB boot failing due to the SD drivers looping on
errors while trying to poke at a non-existent card...

Ideally, we would use the Card Detect signal from the uSD slot, to
report on the presence or absence of a card, but the Raspberry Pi
Foundation did not wire those signals in the Pi 2 and subsequent
models, leaving us with only potentially interfering SD commands
as means to perform card detection.

As a result of this, we are left with no other choice but limit
detection to occurring only once, prior to formal SD card init,
and then return the detected value for subsequent calls. This,
however, is more than good enough for the intended purpose, which
is to allow straight to USB boot. The sequence is a simplified
variant of the identification code in MmcDxe.

Tested on Raspberry Pi 2B, 3B and CM3 (for both SD controllers)
and Pi 4 (for Arasan, as that's the only controller available today)

Addresses pftf/RPi3#13, pftf/RPi3#14, pftf/RPi4#37.

Co-authored-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Tested-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants