BBB MMC / SD detection instability with U-Boot 2014.04 (CPU 1GHz)
Sulev-Madis Silber (ketas)
madis555 at hot.ee
Tue May 20 01:57:15 UTC 2014
On 2014-05-20 04:52, Sulev-Madis Silber (ketas) wrote:
> On 2014-05-19 16:20, Sulev-Madis Silber (ketas) wrote:
>> Hello.
>>
>> Although maybe I could write this as reply to some other message, I feel
>> like it might deserve separate one.
>>
>> I use U-Boot 2014.04 which sets CPU frequency to 1GHz, which seems nice.
>> Apart from inability to find eMMC in ubldr (SD card is always fine), now
>> I get whole different issues here. With 2013.04, I get occasional eMMC
>> failure I mentioned earlier. With 2014.04, it's very hard to get SD
>> devices detected at all. And I get all sorts of weird errors (megabytes
>> of boot logs from serial if anyone wishes to see). I'm aware how HW
>> clock changes can affect things like this, but I'm not exactly sure
>> where and what happens when this is done. If I boot with 2013.04, it's
>> ok again, if I switch to 2014.04 again, it's ok again for a while. It
>> really feels like it's overheating. After a while, it gets extremely
>> hard to get thing booted up. Both devices sometimes detect and sometimes
>> not. I get things like "no compatible cards found on bus" (mmc 0/1), or
>> things like "card at relative address x lost". Tried adding delays like
>> suggested earlier, but that doesn't help and now the issue seems
>> different. I get no other issues. System is very stable once it's booted
>> up. There are no hangs, panics... Everything works. I must mention that
>> I always use latest CURRENT. I didn't find a way to make kernel reboot
>> system when root mount fails, so I manually patched that option in. Last
>> time I got 11 failures before it booted up with both SD and eMMC found
>> (they don't fail same way every time, sometimes SD is missing, often
>> eMMC is missing).
>>
>> What would somebody else think about such issues? I don't have
>> experience in HW dev, I can only guess what goes wrong. And again, if it
>> boots, it works. And no component on BBB gets too warm to hold finger
>> there for long time, too (if that matters). I have 5V 2.5A PSU powering
>> it (but the PMIC should fail if voltage drops too much, etc, I read the
>> datasheet for that), I have few LEDs with resistors connected to GPIO
>> pins, two ~30cm wires that sit on table for input testing (resistors
>> there too, of course) and Nokia DKU-5 data cable for USB-TTL serial
>> console. If the board gets any ground, it's via this cable. But I don't
>> see how my HW config is related to this issue. And I don't change this
>> when I try different U-Boot's?! I don't have USB devices connected to
>> host port and nothing to other USB port too. I use old 64MB SD card to
>> help with booting (because of ubldr issues), not sure that matters, though.
>>
>> Thanks.
>>
>
>
> Now I have patch too. I feel much better now. It seems to fix
> everything. I'm sure that not all of those "delay"'s are needed. I got
> tired of failures and just put one into each place that seemed to need
> some waiting before continue. The side effect is that mmc detection
> doesn't take several seconds now, it's near instant. It also feels like
> device read speed is faster but I'm not entirely sure about that. So,
> what happened here? Slower CPU acted as some kind of limiter by itself?
> What's correct solution here? I'm only guessing but it at least works
> now. I don't think I've lost devices after this change, both SD card and
> eMMC device are always there. I should disable reboot on rootfs mount
> fail to fully confirm it. However that BUSTEST_W still gives error. Now,
> only ubldr-no-eMMC fix is needed. And / or U-Boot fix?
>
Early "Send"...
patch:
http://ketas.si.pri.ee/mmc-detection-hacks2.diff
(and attached)
-------------- next part --------------
Index: sys/dev/mmc/mmc.c
===================================================================
--- sys/dev/mmc/mmc.c (revision 266442)
+++ sys/dev/mmc/mmc.c (working copy)
@@ -414,6 +414,7 @@
int err;
do {
+ mmc_ms_delay(10);
memset(&mreq, 0, sizeof(mreq));
memset(cmd->resp, 0, sizeof(cmd->resp));
cmd->retries = 0; /* Retries done here, not in hardware. */
@@ -436,6 +437,7 @@
int err;
do {
+ mmc_ms_delay(10);
memset(&appcmd, 0, sizeof(appcmd));
appcmd.opcode = MMC_APP_CMD;
appcmd.arg = rca << 16;
@@ -465,6 +467,7 @@
struct mmc_command cmd;
int err;
+ mmc_ms_delay(10);
memset(&cmd, 0, sizeof(cmd));
cmd.opcode = opcode;
cmd.arg = arg;
@@ -488,6 +491,7 @@
device_t dev;
struct mmc_command cmd;
+ mmc_ms_delay(10);
dev = sc->dev;
mmcbr_set_chip_select(dev, cs_high);
mmcbr_update_ios(dev);
@@ -769,8 +773,15 @@
data.data = p8;
data.len = 8;
data.flags = MMC_DATA_WRITE;
- mmc_wait_for_cmd(sc, &cmd, 0);
-
+ err = mmc_wait_for_cmd(sc, &cmd, 0);
+ if (err != 0) {
+ device_printf(sc->dev, "BUSTEST_W err %d\n", err);
+ mmc_ms_delay(10);
+ err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES);
+ if (err != 0)
+ device_printf(sc->dev, "BUSTEST_W err %d (retried %d times)\n", err, CMD_RETRIES);
+ }
+
memset(&cmd, 0, sizeof(cmd));
memset(&data, 0, sizeof(data));
cmd.opcode = MMC_BUSTEST_R;
@@ -782,10 +793,19 @@
data.len = 8;
data.flags = MMC_DATA_READ;
err = mmc_wait_for_cmd(sc, &cmd, 0);
-
+ if (err != 0) {
+ device_printf(sc->dev, "BUSTEST_R err %d\n", err);
+ mmc_ms_delay(10);
+ err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES);
+ if (err != 0)
+ device_printf(sc->dev, "BUSTEST_R err %d (retried %d times)\n", err, CMD_RETRIES);
+ }
+
+ device_printf(sc->dev, "read %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
+
mmcbr_set_bus_width(sc->dev, bus_width_1);
mmcbr_update_ios(sc->dev);
-
if (err == MMC_ERR_NONE && memcmp(buf, p8ok, 8) == 0)
return (bus_width_8);
}
@@ -1264,6 +1284,7 @@
if (bootverbose || mmc_debug)
device_printf(sc->dev, "Probing cards\n");
while (1) {
+ mmc_ms_delay(10);
err = mmc_all_send_cid(sc, raw_cid);
if (err == MMC_ERR_TIMEOUT)
break;
@@ -1586,7 +1607,9 @@
(err ? 0 : MMC_OCR_CCS) | mmcbr_get_ocr(dev), NULL);
} else
mmc_send_op_cond(sc, mmcbr_get_ocr(dev), NULL);
+ mmc_ms_delay(10);
mmc_discover_cards(sc);
+ mmc_ms_delay(10);
mmc_rescan_cards(sc);
mmcbr_set_bus_mode(dev, pushpull);
More information about the freebsd-arm
mailing list