I'm booting my imx6q off an sd card on custom hardware. Uboot works fine but during the boot of the linux kernel I get an error reading the sd card.
mmcblk1: error -84 transferring data, sector 0, nr 8, cmd response 0x900, card status 0xb00
I don't always get this error. Booting two different SD cards (one class 2 and one class 4) the class 2 card throws the error while the class 4 card successfully boots. With the class 4 card I can get all the way to the log-in prompt. Given the flaky nature of booting off the sdcard slot, I'm guessing my problem may be that the distance between my sdcard slot and the cpu is too long. I'd like to slow down reading from the sd card to see if this increases my boot fidelity. How can you slow down reading from and sdcard on the imx6q?
已解决! 转到解答。
We found two things that helped the sd card performance. Specifically the second change made sd card reads and writes much more stable.
1) Edit the /drivers/mmc/host/sdhci-esdhc-imx.c
struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
.quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC
| SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
| SDHCI_QUIRK_BROKEN_CARD_DETECTION
| SDHCI_QUIRK_BROKEN_ADMA
| SDHCI_QUIRK_NO_HISPD_BIT
+ | SDHCI_QUIRK_FORCE_1_BIT_DATA
+ | SDHCI_QUIRK_FORCE_BLK_SZ_2048
+ | SDHCI_QUIRK_PIO_NEEDS_DELAY,
/* ADMA has issues. Might be fixable */
.ops = &sdhci_esdhc_ops,
.init = esdhc_pltfm_init,
.exit = esdhc_pltfm_exit,
};
2) Change the pull-ups on the SD card interface lines to be faster.
arch/arm/plat-mxc/include/mach/iomux-mx6q.h
#define MX6Q_PAD_SD2_DAT1__USDHC2_DAT1 \
(_MX6Q_PAD_SD2_DAT1__USDHC2_DAT1 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT2__USDHC2_DAT2 \
(_MX6Q_PAD_SD2_DAT2__USDHC2_DAT2 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT0__USDHC2_DAT0 \
(_MX6Q_PAD_SD2_DAT0__USDHC2_DAT0 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT4__USDHC2_DAT4 \
(_MX6Q_PAD_SD2_DAT4__USDHC2_DAT4 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT5__USDHC2_DAT5 \
(_MX6Q_PAD_SD2_DAT5__USDHC2_DAT5 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT6__USDHC2_DAT6 \
(_MX6Q_PAD_SD2_DAT6__USDHC2_DAT6 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_NANDF_D7__USDHC2_DAT7 \
(_MX6Q_PAD_NANDF_D7__USDHC2_DAT7 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_CLK__USDHC2_CLK \
(_MX6Q_PAD_SD2_CLK__USDHC2_CLK | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_CMD__USDHC2_CMD \
(_MX6Q_PAD_SD2_CMD__USDHC2_CMD | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT3__USDHC2_DAT3 \
(_MX6Q_PAD_SD2_DAT3__USDHC2_DAT3 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
We found two things that helped the sd card performance. Specifically the second change made sd card reads and writes much more stable.
1) Edit the /drivers/mmc/host/sdhci-esdhc-imx.c
struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
.quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC
| SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
| SDHCI_QUIRK_BROKEN_CARD_DETECTION
| SDHCI_QUIRK_BROKEN_ADMA
| SDHCI_QUIRK_NO_HISPD_BIT
+ | SDHCI_QUIRK_FORCE_1_BIT_DATA
+ | SDHCI_QUIRK_FORCE_BLK_SZ_2048
+ | SDHCI_QUIRK_PIO_NEEDS_DELAY,
/* ADMA has issues. Might be fixable */
.ops = &sdhci_esdhc_ops,
.init = esdhc_pltfm_init,
.exit = esdhc_pltfm_exit,
};
2) Change the pull-ups on the SD card interface lines to be faster.
arch/arm/plat-mxc/include/mach/iomux-mx6q.h
#define MX6Q_PAD_SD2_DAT1__USDHC2_DAT1 \
(_MX6Q_PAD_SD2_DAT1__USDHC2_DAT1 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT2__USDHC2_DAT2 \
(_MX6Q_PAD_SD2_DAT2__USDHC2_DAT2 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT0__USDHC2_DAT0 \
(_MX6Q_PAD_SD2_DAT0__USDHC2_DAT0 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT4__USDHC2_DAT4 \
(_MX6Q_PAD_SD2_DAT4__USDHC2_DAT4 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT5__USDHC2_DAT5 \
(_MX6Q_PAD_SD2_DAT5__USDHC2_DAT5 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT6__USDHC2_DAT6 \
(_MX6Q_PAD_SD2_DAT6__USDHC2_DAT6 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_NANDF_D7__USDHC2_DAT7 \
(_MX6Q_PAD_NANDF_D7__USDHC2_DAT7 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_CLK__USDHC2_CLK \
(_MX6Q_PAD_SD2_CLK__USDHC2_CLK | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_CMD__USDHC2_CMD \
(_MX6Q_PAD_SD2_CMD__USDHC2_CMD | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
#define MX6Q_PAD_SD2_DAT3__USDHC2_DAT3 \
(_MX6Q_PAD_SD2_DAT3__USDHC2_DAT3 | MUX_PAD_CTRL(MX6Q_USDHC_PAD_CTRL_50MHZ_40OHM))
Hi j b
I do not think that it is easily possible to slow down sd card without
modification of kernel sources. You can look at .../mach-mx6/clock.c
to see how clocks are produced. On the other hand, for reading, class 2 and class 4
performance is not always different check link below
http://elinux.org/RPi_SD_cards#SD_card_performance
Some class 2 have the same reading speed as class 4.
In writing performance is different.
Raspberry Pi • View topic - Class 10 vs Class 4 sd cards
Note, there are many fake cards on market.
So it makes sense to pay attention to SD signal integrity or
try brand new cards from well-known vendors.
Best regards
chip
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------