Write to an A1-rated Micro SD card failed
#1
Hello,

While attempting to perform a performance comparison of A1-rated and non-A1-rated Micro SD cards, with additonal emphasis on using F2FS instead of ext4, I've encountered a major issue with the PineBook Pro's SD card interface.  Here are more details.

In a few words, attempting to write about 14.5 GiB to a Kingston A1-rated 16 GB UHS-I Micro SD card (SDCS2/16GB) resulted in a failure and the following Linux kernel messages, after writing about 700 MiB to the card:

Code:
[ 1933.684751] mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
[ 1933.732717] mmc_host mmc1: Bus speed (slot 0) = 148500000Hz (slot req 150000000Hz, actual 148500000HZ div = 0)
[ 1933.895841] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 78
[ 1935.187343] blk_update_request: I/O error, dev mmcblk1, sector 0 op 0x1:(WRITE) flags 0x104000 phys_seg 256 prio class 0
[ 1935.187418] Buffer I/O error on dev mmcblk1, logical block 0, lost async page write
[ 1935.187464] Buffer I/O error on dev mmcblk1, logical block 1, lost async page write
[ 1935.187495] Buffer I/O error on dev mmcblk1, logical block 2, lost async page write
[ 1935.187527] Buffer I/O error on dev mmcblk1, logical block 3, lost async page write
[ 1935.187557] Buffer I/O error on dev mmcblk1, logical block 4, lost async page write
[ 1935.187585] Buffer I/O error on dev mmcblk1, logical block 5, lost async page write
[ 1935.187614] Buffer I/O error on dev mmcblk1, logical block 6, lost async page write
[ 1935.187642] Buffer I/O error on dev mmcblk1, logical block 7, lost async page write
[ 1935.187672] Buffer I/O error on dev mmcblk1, logical block 8, lost async page write
[ 1935.187702] Buffer I/O error on dev mmcblk1, logical block 9, lost async page write
[ 1935.204901] mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
[ 1935.253334] mmc_host mmc1: Bus speed (slot 0) = 148500000Hz (slot req 150000000Hz, actual 148500000HZ div = 0)
[ 1935.675811] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 78
[ 1937.395704] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 78
[ 1937.656483] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 78
[ 1937.886460] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 78
[ 1937.887796] blk_update_request: I/O error, dev mmcblk1, sector 16384 op 0x1:(WRITE) flags 0x104000 phys_seg 256 prio class 0
[ 1938.316467] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 78
[ 1938.333230] mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
[ 1938.381886] mmc_host mmc1: Bus speed (slot 0) = 148500000Hz (slot req 150000000Hz, actual 148500000HZ div = 0)
[ 1938.536382] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 78
[ 1938.542689] blk_update_request: I/O error, dev mmcblk1, sector 67584 op 0x1:(WRITE) flags 0x104000 phys_seg 256 prio class 0

This happened two times in a row, which makes the issue very easily reproducible.  Unfortunately, it also caused the Linux kernel to become locked up on shutdown, requiring the laptop to be forcedly powered off.

Here are the kernel messages upon inserting the A1-rated card:

Code:
[ 1777.728204] mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
[ 1777.881900] mmc_host mmc1: Bus speed (slot 0) = 148500000Hz (slot req 150000000Hz, actual 148500000HZ div = 0)
[ 1778.177740] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 78
[ 1778.177828] mmc1: new ultra high speed SDR104 SDHC card at address 5048
[ 1778.179620] mmcblk1: mmc1:5048 SD16G 14.4 GiB
[ 1778.189478]  mmcblk1: p1

For reference, here are also the kernel messaged upon inserting a 16 GB UHS-I Micro SD card that is not A1-rated (Kingston SDCS/16GB):

Code:
[   56.649797] mmc_host mmc1: Bus speed (slot 0) = 148500000Hz (slot req 150000000Hz, actual 148500000HZ div = 0)
[   57.093248] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 97
[   57.093339] mmc1: new ultra high speed SDR104 SDHC card at address 1234
[   57.095057] mmcblk1: mmc1:1234 SA16G 14.5 GiB
[   57.103859]  mmcblk1: p1 p2

The card that is not A1-rated works perfectly.  As perfectly as it can be expected from a Micro SD card, of course. Cool

D'oh!  My first thoughts were that I got a bad A1-rated card.  Though, testing another A1-rated card (another sample of SDCS2/16GB) resulted in the same issue.  Time to try another approach; I wrote the same 14.5 GiB to the first A1-rated card using an external multi-format USB 3.0 card reader (Kingston FCR-HS3), and the write operation completed without errors.  Another write attempt, now using an el-cheapo, generic USB 2.0 Micro-SD-only card reader, resulted in no errors as well.

As a note, the write to the A1-rated card was about 30% slower (7.5 MB/s vs. 10.5 MB/s, as printed by dd) using the USB 2.0 card reader, compared with using the USB 3.0 card reader on the same upstream USB 3.0 port.  That's curious, but I'd need to test with a better USB 2.0 card reader before drawing any conclusions.

So, there is some good and some bad news.  The good news is that my A1-rated cards are fine (I was already prepared to blame Kingston!), and the bad news is that some problems exist in the Linux kernel driver for the Micro SD card interface in the PineBook Pro; it's pretty much safe to assume that the actual Micro SD card interface hardware is not the culprit.

I'm looking into the source of the Linux kernel driver, and I'll post my findings here.  Things don't look great, there are more than a few "this hardcoded value should be safe for all SoC implementations" points in the driver.  Though, those "safe" values could be tweaked and tested.

In the meantime, if anyone else has experienced the same or similar issues, please comment here.
  Reply
#2
Here's another thread describing pretty much the same issue.  There's even one more thread about the same issue.  Although no actual solutions have been offered, the culprit seems to be the difference in the BSP and Linux kernel mainline drivers and/or DTS files.
  Reply
#3
mmh weird, afaik only A2 cards require any special handling to unlock features, I only have two A1 cards (Sandisk Extreme A1 16GB and Sandisk Ultra A1 16GB) but they both seem to work at SDR104 with either BSP (tested on older ayufan Debian image) and mainline (tested on Armbian).

My issues with sdcards were mostly related to various u-boot versions before the link training was up to the same level as in the linux drivers...

Can you test your cards at a lower bus speed, like DDR50 or just high speed?
Also what kernel version did your run?
Come have a chat in the Pine IRC channel >>
  Reply
#4
It is weird, I agree.  As far as I know, A2-rated cards still work without enabling their additional features, albeit not at their maximum IOPS rate.  In my case, two A1-rated cards pretty much do not work as expected, which is weird.

I am running version 5.11.3 of the Linux kernel, which is the latest version in Manjaro ARM.  My intentions are to try running my A1-rated cards at a lower speed, with an additional delay prior to the card detection, etc.  If that doesn't help, I'll go through the differences between the Linux kernel drivers in the BSP and in the mainline.  I'll post the results, of course.
  Reply
#5
Here's a brief update...  Introducing a delay into the card detection, by adding "card-detect-delay = <0x320>;" into the relevant section of the device tree file, made no changes to the behavior of the A1-rated card; the write operation failed in the same way as before.

However, limiting the maximum speed of the card interface, by replacing "sd-uhs-sdr104;" with "sd-uhs-sdr50;" in the device tree file, resulted in a slower (10.4 MB/s vs. 13.8 MB/s; the latter was achieved with the non-A1-rated card) but successful write operation.  Here are the kernel messages upon inserting the A1-rated card:

Code:
[   76.077610] mmc_host mmc1: Bus speed (slot 0) = 100000000Hz (slot req 100000000Hz, actual 100000000HZ div = 0)
[   76.310549] dwmmc_rockchip fe320000.mmc: Successfully tuned phase to 213
[   76.310636] mmc1: new ultra high speed SDR50 SDHC card at address 5048
[   76.312424] mmcblk1: mmc1:5048 SD16G 14.4 GiB

The investigation continues.
  Reply
#6
Another brief update...  I've spent some time going through the SD specification and the Linux kernel MMC driver, and so far it seems that the issue might be related to the limiting of the current supplied to the microSD card, which is performed by the kernel driver.  To move forward with the debugging, now I need to extend the driver to export more information about the microSD card and its runtime configuration.
  Reply
#7
We are developing a SDMMC driver for RISC OS. We have similar issues , but not exactly the same. Some sd cards works and some don't. The symptoms can be anything from not detected at all  to  fail in writing (mounts successfully).

We think we got the clock setup right , even if it has been a long journey to get there.

One thing that worries me is that CMD6 returns same data when querying cards of different speeds. So our driver always thinks that 25Mhz is the max the card supports.
I wonder , what is the CMD6 output in linux and is it used at all in linux? Since the output is always the same , the speed setting in card also might fail, no way to find out. The read operation of CMD6 is successful , driver wise.

That's all I got at the moment. We are two developers working with it and it has been very confused. I thought really long that my PbP was faulty.
  Reply
#8
The MMC driver in the Linux kernel uses the SWITCH (CMD6) command.  There are a few interesting C functions:

The slight trouble is that the results of the SWITCH (CMD6) command, in the current state of the MMC driver, are not directly available for debugging purposes.  Regarding the issue I've originally described in this thread, my current "suspect" is the sd_set_current_limit() function, which may not properly handle all possible cases, i.e. all combinations of the MMC host capabilities and the microSD card requirements.
  Reply
#9
In our case most is solved , but one thing is strange..
We need half speed when writing card clock , but after that changing it back to full speed (50 Mhz atm) got it working.
AFAIK the clkdiv reg 0x0008 shouldn't have any effect without cardclock programmed, but from testing it has.

With our driver controller reports all speeds supported , but we are atm stuck with 3v3 signal voltage , and that means limit to 50Mhz.
The main driver needs modding for higher speed , and it would break OMAP port.. need to figure that out.

TBC.
  Reply
#10
The original issue described in this thread might actually be related to higher speeds, and the same issue might be just around the corner in your case.  For example, an A1-rated Kingston microSD card fails to work at SDR104 in the PineBook Pro, but limiting the speed of the MMC interface to SDR50, which still runs at 1.8 V, makes the same microSD card work just fine.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Both hinges completely failed phuzy 20 10,393 01-02-2024, 02:03 AM
Last Post: Uturn
  eMMC failed Dendrocalamus64 9 6,799 11-12-2021, 11:08 AM
Last Post: Dendrocalamus64
Question Disassembling PineBook Pro Docking Deck (due to disappeared microSD card) gritibaenz 4 4,285 04-02-2021, 06:45 PM
Last Post: tkudog
  microSD card stuck charlesnorris 7 7,820 11-19-2020, 05:11 AM
Last Post: KC9UDX
  NVME SPI Update not booting SD Card WZ9V 5 6,244 10-18-2020, 08:36 PM
Last Post: wdt
  Upgrade eMMC card - boot problems alpopa 0 2,233 09-16-2020, 12:31 PM
Last Post: alpopa
  PBP not booting screen blank after SD card boot Jakobp 10 13,458 08-18-2020, 08:56 PM
Last Post: trinapicot
  Privacy switches - cutting power to wifi card as400 1 2,720 08-10-2020, 09:48 AM
Last Post: belfastraven
  SD card slot stefan.schumacher 1 2,992 03-28-2020, 04:34 PM
Last Post: zaius
  USB-C HUB: sd card slots and USB ports not usable vfr400racer 2 4,026 12-15-2019, 03:50 AM
Last Post: vfr400racer

Forum Jump:


Users browsing this thread: 1 Guest(s)