[SeaBIOS] Failure to detect high-capacity SD card

Kevin O'Connor kevin at koconnor.net
Sat Oct 28 02:08:49 CEST 2017


On Thu, Oct 26, 2017 at 09:04:57PM -0500, Matt DeVillier wrote:
> On Thu, Oct 26, 2017 at 11:26 AM, Kevin O'Connor <kevin at koconnor.net> wrote:
> 
> > On Thu, Oct 26, 2017 at 11:14:53AM -0400, Matt DeVillier wrote:
> > > On Thu, Oct 26, 2017 at 10:59 AM, Kevin O'Connor <kevin at koconnor.net>
> > wrote:
> > >
> > > with the patch, USB devices are not available from the boot menu either
> > (it
> > > appears to hang?), and therefore device cannot be booted to get said log
> >
> > That sounds like a bad compile then - nothing in the patch should have
> > impacted usb.
> >
> > In any case, the patch below tests the same thing and it should work
> > on eMMC also.
> 
> still timing out on detection: https://paste.ubuntu.com/25826387/

Can you try the two patches below?  (Go back to master, apply the
first, gather the log, go back to master, apply the second, gather the
log.)

-Kevin


====================== patch 1 =========================

--- a/src/hw/sdcard.c
+++ b/src/hw/sdcard.c
@@ -181,7 +181,7 @@ static int
 sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)
 {
     u32 state = readl(&regs->present_state);
-    dprintf(9, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);
+    dprintf(1, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);
     if ((state & SP_CMD_INHIBIT)
         || ((cmd & 0x03) == 0x03 && state & SP_DAT_INHIBIT)) {
         dprintf(1, "sdcard_pio not ready %x\n", state);
@@ -203,7 +203,7 @@ sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)
     writew(&regs->irq_status, SI_CMD_COMPLETE);
     // Read response
     memcpy(param, regs->response, sizeof(regs->response));
-    dprintf(9, "sdcard cmd %x response %x %x %x %x\n"
+    dprintf(1, "sdcard cmd %x response %x %x %x %x\n"
             , cmd, param[0], param[1], param[2], param[3]);
     return 0;
 }
@@ -403,7 +403,7 @@ sdcard_card_setup(struct sddrive_s *drive, int volt, int prio)
     param[0] = vrange;
     ret = sdcard_pio(regs, SC_SEND_IF_COND, param);
     if (!ret && param[0] == vrange)
-        hcs = (1<<30);
+        hcs = (1<<30) | (1<<28);
     // Verify SD card (instead of MMC or SDIO)
     param[0] = 0x00;
     ret = sdcard_pio_app(regs, SC_APP_SEND_OP_COND, param);


====================== patch 2 =========================

--- a/src/hw/sdcard.c
+++ b/src/hw/sdcard.c
@@ -123,6 +123,7 @@ struct sdhci_s {
 #define SRF_DATA 0x04
 
 // SDHCI result flags
+#define SR_OCR_S18R    (1<<24)
 #define SR_OCR_CCS     (1<<30)
 #define SR_OCR_NOTBUSY (1<<31)
 
@@ -181,7 +182,7 @@ static int
 sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)
 {
     u32 state = readl(&regs->present_state);
-    dprintf(9, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);
+    dprintf(1, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);
     if ((state & SP_CMD_INHIBIT)
         || ((cmd & 0x03) == 0x03 && state & SP_DAT_INHIBIT)) {
         dprintf(1, "sdcard_pio not ready %x\n", state);
@@ -203,7 +204,7 @@ sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)
     writew(&regs->irq_status, SI_CMD_COMPLETE);
     // Read response
     memcpy(param, regs->response, sizeof(regs->response));
-    dprintf(9, "sdcard cmd %x response %x %x %x %x\n"
+    dprintf(1, "sdcard cmd %x response %x %x %x %x\n"
             , cmd, param[0], param[1], param[2], param[3]);
     return 0;
 }
@@ -416,6 +417,9 @@ sdcard_card_setup(struct sddrive_s *drive, int volt, int prio)
         drive->card_type |= SF_MMC;
         hcs = (1<<30);
     }
+    // XXX
+    if (volt == (1<<20) && hcs && readl(&regs->cap_lo) & SD_CAPLO_V18)
+        hcs |= SR_OCR_S18R;
     // Init card
     u32 end = timer_calc(SDHCI_POWERUP_TIMEOUT);
     for (;;) {
@@ -434,6 +438,10 @@ sdcard_card_setup(struct sddrive_s *drive, int volt, int prio)
         }
         msleep(5); // Avoid flooding log when debugging
     }
+    if (param[0] & SR_OCR_S18R) {
+        dprintf(1, "Card requests 1.8 volt\n");
+        return -1;
+    }
     drive->card_type |= (param[0] & SR_OCR_CCS) ? SF_HIGHCAPACITY : 0;
     // Select card (get cid, set rca, get csd, select card)
     param[0] = 0x00;



More information about the SeaBIOS mailing list