Skip to content

mmc0: unexpected command 5 error #2003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zougloub opened this issue May 11, 2017 · 12 comments
Closed

mmc0: unexpected command 5 error #2003

zougloub opened this issue May 11, 2017 · 12 comments

Comments

@zougloub
Copy link

zougloub commented May 11, 2017

I'm plugging in a Pi 3 main µSD-card slot one BRCM43340 Wifi SDIO module which is working fine on my ThinkPad's SD/SDIO slot.

There are MMC issues, mmc0: unexpected command 5 error from drivers/mmc/host/bcm2835-sdhost.c (ping @pelwell) while the card is inserted.

I also made the system boot by USB to rule out the possibility of hot-plugging issues, same thing.

Running v4.8.y or v4.9.y (32-bit), and I'll try to build and troubleshoot, see if I can see something, but since my goal is to work with the wifi board, I'll probably quickly end up plugging it to another SoC.

@pelwell
Copy link
Contributor

pelwell commented May 11, 2017

The SDHOST interface - the one that drives the SD card - is unlikely to work with an SDIO card because it turns off the SD clock between bus transactions.

@zougloub
Copy link
Author

OK, good to know!

The other one (I have an MMC-HAT on the way), does it do SDIO?

@zougloub
Copy link
Author

The interwebs says that yes, so I'm closing the issue. Thanks @pelwell for the prompt response.

@pelwell
Copy link
Contributor

pelwell commented May 11, 2017

I'll give you a brief version of the whole story. The BCM2835 family of processors has two MMC/SD interfaces - mmc (also known as the Arasan block) is suitable for SDIO, sdhost isn't. There are 3 GPIO groups where mmc can be used (22-27, 34-39 and 48-53), and two for sdhost (34-39, 48-53); the SD slot (or EMMC) is on 48-53. We used to use mmc for everything (SD, uSD and EMMC) but then we switched to sdhost because a) it can be made quicker, and b) it frees up the SDIO-capable mmc. Then along comes the Pi3 and uses mmc to drive the WiFi chip via SDIO.

The assignment of mmc/sdhost interfaces to pins on the BCM2835 under Linux is controlled by Device Tree. Device Tree overlays can be used to change the group of pins used by each interface, and even force mmc to be used on the SD/uSD slot. This means that my first answer didn't give you the full picture. You could use a DT overlay to make mmc drive the uSD slot, which would make it SDIO capable, but then you would lose WiFi. Similarly, the MMC-HAT is capable of SDIO - it's just wiring pins 22-27 to the new uSD slot, which means it must be using mmc) but you won't also be able to use WiFi on the Pi3.

@zougloub
Copy link
Author

I see. If I can't get the card to work on i.MX 6, I'll come back to the Pi and try to make a dtbo for my use case. Thanks again,

@pelwell
Copy link
Contributor

pelwell commented May 11, 2017

The standard sdio overlay (which I've just simplified - https://github.com/raspberrypi/linux/blob/rpi-4.9.y/arch/arm/boot/dts/overlays/sdio-overlay.dts) ought to do what you want, or at least it should be a good starting point.

@zougloub
Copy link
Author

zougloub commented May 11, 2017

(couldn't get my iMX6 board to underclock whereas the Pi3 is OK doing that with config.txt, so I'm back)

While I don't have the MMC-HAT, I tried the following, with the intent of routing mmc to the SD slot:

diff --git a/arch/arm/boot/dts/overlays/sdhost-overlay.dts b/arch/arm/boot/dts/overlays/sdhost-overlay.dts
index de3d1b0a5e40..305272b377b5 100644
--- a/arch/arm/boot/dts/overlays/sdhost-overlay.dts
+++ b/arch/arm/boot/dts/overlays/sdhost-overlay.dts
@@ -7 +7 @@
-       compatible = "brcm,bcm2708";
+       compatible = "brcm,bcm2837", "brcm,bcm2836";
diff --git a/arch/arm/boot/dts/overlays/sdio-overlay.dts b/arch/arm/boot/dts/overlays/sdio-overlay.dts
index 215d5e3e8a8c..28ded260878e 100644
--- a/arch/arm/boot/dts/overlays/sdio-overlay.dts
+++ b/arch/arm/boot/dts/overlays/sdio-overlay.dts
@@ -4 +4 @@
-/* Enable SDIO from MMC interface via GPIOs 22-27. Includes sdhost overlay. */
+/* Enable SDIO from MMC interface via GPIOs 48-53. Includes sdhost overlay. */
@@ -7 +7 @@
-       compatible = "brcm,bcm2708";
+       compatible = "brcm,bcm2837", "brcm,bcm2836";
@@ -25 +25 @@
-                               brcm,pins = <22 23 24 25 26 27>;
+                               brcm,pins = <48 49 50 51 52 53>;

but it looks like it's not doing anything (checked that /proc/device-tree/soc/gpio@*/sdio_pins/brcm,pins is indeed outputting the right values) to make the error go away ([ 231.776344] mmc0: unexpected command 5 error)

Did I do anything wrong?

@zougloub
Copy link
Author

(reopening the issue, as there should be a way to get SDIO in the SD-card slot)

@zougloub zougloub reopened this May 11, 2017
@pelwell
Copy link
Contributor

pelwell commented May 11, 2017

Try dtoverlay=mmc.

@zougloub
Copy link
Author

OK, I'll try to make it work and attach my dts.

@zougloub
Copy link
Author

Cool, mmc-overlay.dtbs is working as it is.

Note that brcm.pull is brcm,pull in sdio-overlay.dtbs, I'm not sure how brcm,bcm2708 is still making it work, and IMHO adding comments to these overlays could be useful for those who aren't brute-forcing their way with web search engines.

@pelwell
Copy link
Contributor

pelwell commented May 11, 2017

Thanks for spotting the typo - I've fixed that now. Using brcm,bcm2708 as the compatible string makes sense because that is the name of the family of SoCs, but in reality nothing is checking the string value.

Are you aware of the dtoverlay command in Raspbian? dtoverlay -a lists all known overlays, and dtoverlay -h <overlay> gives usage information for a named overlay. It reads /boot/overlays/README, so you may prefer to search it manually.

popcornmix added a commit to raspberrypi/firmware that referenced this issue May 15, 2017
kernel: dwc_otg: Fixes for root port disconnect issues
See: raspberrypi/linux#2010

kernel: BCM270X_DT: Tidy up mmc, sdhost, sdio overlays
See: raspberrypi/linux#2003

firmware: platform: Move trait initialisation out of #ifdef'd function

firmware: usb: Change USB PHY settings to make device mode work correctly

firmware: dtoverlay: Update fixups when a node is renamed
firmware: dtoverlay app: Add the -D (dry-run) option
See: raspberrypi/linux#2002

firmware: dispserver: Adjust open/close refcount on application exit
See: #778

firmware: filex: Optimise directory search of the root directory
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this issue May 15, 2017
kernel: dwc_otg: Fixes for root port disconnect issues
See: raspberrypi/linux#2010

kernel: BCM270X_DT: Tidy up mmc, sdhost, sdio overlays
See: raspberrypi/linux#2003

firmware: platform: Move trait initialisation out of #ifdef'd function

firmware: usb: Change USB PHY settings to make device mode work correctly

firmware: dtoverlay: Update fixups when a node is renamed
firmware: dtoverlay app: Add the -D (dry-run) option
See: raspberrypi/linux#2002

firmware: dispserver: Adjust open/close refcount on application exit
See: raspberrypi/firmware#778

firmware: filex: Optimise directory search of the root directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants