[U-Boot] rpi: bcm2835_sdhost: occasional errors while writing

Zubair Lutfullah Kakakhel zubair at balena.io
Mon Feb 25 10:43:03 UTC 2019


Hi,

I've encountered occasional glitches while writing to the sd card
via u-boot(2018.07) on a Pi 3 B+. The goal is to write the bootcount
in the boot partition. As a test, this is the loop I used to read, display
contents, write to the same file over and over again.

```
mw 200000 0
while itest *200000 == 0 ; do
    fatload mmc 0:1 $kernel_addr_r resin-image
    md $kernel_addr_r 18
    fatwrite mmc 0:1 $kernel_addr_r resin-image 18
    echo === done ====
done
```
resin-image is a file in the boot partition that has some text in it.

After a few minutes of this loop running, I 'sometimes' get this error
and the sd card stops working

```
writing resin-image
wait_transfer_complete - still waiting after 100001 retries
mmc write failed
Error: flush fat buffer

** Unable to write "resin-image" from mmc 0:1 **
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:376/bcm2835_prepare_data()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
** Can't read partition table on 0:0 **
** Invalid partition 1 **
00080000: 4e204f44 5220544f 564f4d45 48542045    DO NOT REMOVE TH
00080010: 46205349 0a454c49 0f030f03 0f030f03    IS FILE.........
00080020: 0f030f03 0f030f03 01600103 03030300    ..........`.....
00080030: 03030303 03030303 03030303 03030303    ................
00080040: 03030303 03030303 03030303 03034103    .............A..
00080050: 03030303 03030303 03030303 03030303    ................
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
** Can't read partition table on 0:0 **
** Invalid partition 1 **
```

What is even more concerning is that the device can't boot. Even if a
write failed.
Subsequent reads seem to fail as well.

```
U-Boot> mmc part

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
WARNING at /home/zubairlk/resin/yocto/resin-raspberrypi3/build/tmp/work/raspberrypi3-poky-linux-gnueabi/u-boot/1_2018.07-r0/git/drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
** Can't read partition table on 0:0 **
U-Boot>
```

I can recover the device after a reboot.

Any thoughts/ideas about where/what I should look for?
Or if I'm lucky, any wip patches floating around?

Thanks

Regards,
ZubairLK

p.s. The sd card is a good SanDisk one..


More information about the U-Boot mailing list