Skip to content

SDIO 4-Bit mode not working / DAT2 pulled down by ESP32 #596

Open
@olell

Description

@olell

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate.
  • Provided a clear description of your suggestion.
  • Included any relevant context or examples.

Issue or Suggestion Description

I'm currently porting esp-hosted to a custom board using a Rockchip RV1106G3 as hosting SoC and an ESP32-WROOM-32. In 1-Bit mode the SDIO communication between the ESP32 and the SoC works fine except the low data throughput. Currently I'm trying to switch to 4-Bit mode and encountered a problem with the DAT2 line.

The connections on the board are kept short, below 30mm, referencing to a solid ground plane and very similar length. I will attach a schematic diagram. According to the documentation I added 51kΩ pull up resistors on CMD & DAT0..3.

I detected the following behavior: All lines are working correctly in 4-Bit mode except DAT2, there I can measure a voltage of around 1.5V which stays permanently. Therefore I guess the initialization of the driver fails. I put both chips in reset state to test the influence of those chips on the line:

Chip in Reset Voltage on DAT2
ESP32 3.3V
None 1.5V
RV1106G3 0V

from that I concluded, that the ESP32 is pulling the line down with a similar resistor as the SoC is pulling it up. My conclusion is that it might have something to do with the MTDI bootstrapping pin.

But I burned the efuses of the ESP32 so that the MTDI strapping pin is disabled:

Vdd fuses:
XPD_SDIO_REG (BLOCK0)                              read for XPD_SDIO_REG                              = True R/W (0b1)
XPD_SDIO_TIEH (BLOCK0)                             If XPD_SDIO_FORCE & XPD_SDIO_REG                   = 3.3V R/W (0b1)
XPD_SDIO_FORCE (BLOCK0)                            Ignore MTDI pin (GPIO12) for VDD_SDIO on reset     = True R/W (0b1)

Is there anything in the firmware or configuration that I might have overseen or can you maybe help me figure out why the ESP32 is pulling that line down. Or is it maybe something completely different. I'm beginning to despair because I can't find the error :/

# dmesg | grep -C4 esp32

[    5.713461] g_cdc gadget.0: CDC Composite Gadget, version: King Kamehameha Day 2008
[    5.713476] g_cdc gadget.0: g_cdc ready
[    5.728879] g_cdc gadget.0: suspend
[    5.857192] usb0: eth_open
[    5.966190] esp32_sdio: loading out-of-tree module taints kernel.
[    7.232466] gs_open: ttyGS0 (b05e7824,e6a6bf49)
[    7.241472] gs_close: ttyGS0 (b05e7824,e6a6bf49) ...
[    7.241550] gs_close: ttyGS0 (b05e7824,e6a6bf49) done!
[    7.243320] gs_open: ttyGS0 (2c3e93e5,99650811)
--
[    8.691486] mmc2: queuing unknown CIS tuple 0x01 [d9 01 ff] (3 bytes)
[    8.699221] mmc2: queuing unknown CIS tuple 0x1a [01 01 00 02 07] (5 bytes)
[    8.702663] mmc2: queuing unknown CIS tuple 0x1b [c1 41 30 30 ff ff ff ff] (8 bytes)
[    8.705858] mmc2: new SDIO card at address 0001
[    8.706685] esp32_sdio: esp_probe: ESP network device detected
[    8.707328] esp32_sdio: probe of mmc2:0001:1 failed with error -84
[    8.707811] esp32_sdio: probe of mmc2:0001:2 failed with error -22
[    9.844665] g_cdc gadget.0: packet filter 0e
[    9.844720] g_cdc gadget.0: ecm req21.43 v000e i0000 l0
[    9.903971] g_cdc gadget.0: packet filter 0e
[    9.904017] g_cdc gadget.0: ecm req21.43 v000e i0000 l0

# cat /sys/kernel/debug/mmc2/ios

clock:          25000000 Hz
vdd:            21 (3.3 ~ 3.4 V)
bus mode:       2 (push-pull)
chip select:    0 (don't care)
power mode:     2 (on)
bus width:      2 (4 bits)
timing spec:    0 (legacy)
signal voltage: 0 (3.30 V)
driver type:    0 (driver type B)
Hardware Setup / Schematic Image

The bright green lines are the SDIO lines
Image

Linux device tree section

Everything actually works if I set the bus-width to 1. But the throughput is very poor then.

&sdio {
	status = "okay";
	bus-width = <4>;
	num-slots = <1>;
	clock-frequency = <50000000>;
	clock-freq-min-max = <200000 50000000>;
	supports-highspeed;
	supports-sdio;
	broken-cd;
	disable-wp;

	pinctrl-names = "default", "idle";
	pinctrl-0 = <&sdmmc1m1_cmd &sdmmc1m1_clk &sdmmc1m1_bus4>;
	pinctrl-1 = <&sdmmc1m1_idle_pins>;
};
The esp-hosted serial output after start
rst:0x1 (POWERON_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6276
load:0x40078000,len:15716
load:0x40080400,len:4
ho 8 tail 4 room 4
load:0x40080404,len:3572
entry 0x4008062c
I (30) boot: ESP-IDF 67c1de1e-dirty 2nd stage bootloader
I (30) boot: compile time Apr 21 2025 20:09:59
I (30) boot: Multicore bootloader
I (32) boot: chip revision: v1.0
I (35) boot.esp32: SPI Speed      : 40MHz
I (39) boot.esp32: SPI Mode       : DIO
I (42) boot.esp32: SPI Flash Size : 4MB
I (46) boot: Enabling RNG early entropy source...
I (50) boot: Partition Table:
I (53) boot: ## Label            Usage          Type ST Offset   Length
I (59) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (66) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (72) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (79) boot:  3 factory          factory app      00 00 00010000 00100000
I (85) boot:  4 ota_0            OTA app          00 10 00110000 00100000
I (92) boot:  5 ota_1            OTA app          00 11 00210000 00100000
I (98) boot: End of partition table
I (101) boot: Defaulting to factory image
I (105) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=19e18h (106008) map
I (149) esp_image: segment 1: paddr=00029e40 vaddr=3ff80000 size=0001ch (    28) load
I (149) esp_image: segment 2: paddr=00029e64 vaddr=3ffbdb60 size=05d60h ( 23904) load
I (162) esp_image: segment 3: paddr=0002fbcc vaddr=40080000 size=0044ch (  1100) load
I (162) esp_image: segment 4: paddr=00030020 vaddr=400d0020 size=92b9ch (600988) map
I (373) esp_image: segment 5: paddr=000c2bc4 vaddr=4008044c size=1e7ech (124908) load
I (437) boot: Loaded app from partition at offset 0x10000
I (437) boot: Disabling RNG early entropy source...
I (448) cpu_start: Multicore app
I (456) cpu_start: Pro cpu start user code
I (456) cpu_start: cpu freq: 240000000 Hz
I (456) app_init: Application information:
I (456) app_init: Project name:     network_adapter
I (461) app_init: App version:      NG-1.0.3.0.12
I (465) app_init: Compile time:     Apr 21 2025 20:10:08
I (470) app_init: ELF file SHA256:  b05617139...
I (474) app_init: ESP-IDF:          67c1de1e-dirty
I (479) efuse_init: Min chip rev:     v0.0
I (483) efuse_init: Max chip rev:     v3.99
I (487) efuse_init: Chip rev:         v1.0
I (491) heap_init: Initializing. RAM available for dynamic allocation:
I (497) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (502) heap_init: At 3FFB7CD8 len 00000328 (0 KiB): DRAM
I (507) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (512) heap_init: At 3FFD2490 len 0000DB70 (54 KiB): DRAM
I (518) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (523) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (528) heap_init: At 4009EC38 len 000013C8 (4 KiB): IRAM
I (535) spi_flash: detected chip: generic
I (537) spi_flash: flash io: dio
I (541) coexist: coex firmware version: 49a8cdc
I (546) main_task: Started on CPU0
I (549) main_task: Calling app_main()
I (551) stats: *********************************************************************
I (558) stats:                 ESP-Hosted Firmware version :: NG-1.0.3.0.12
I (567) stats:                 Transport used :: SDIO only
I (574) stats: *********************************************************************
I (582) FW_MAIN: Supported features are:
I (585) FW_MAIN: - WLAN over SDIO
I (588) FW_BT: - BT/BLE
I (591) FW_BT:    - HCI Over SDIO
I (594) FW_BT:    - BT/BLE dual mode
I (597) FW_MAIN: Capabilities: 0x1d
I (610) wifi:wifi driver task: 3ffd5ea4, prio:23, stack:6656, core=1
I (613) wifi:wifi firmware version: 87d6f3c
I (613) wifi:wifi certification version: v7.0
I (614) wifi:config NVS flash: disabled
I (618) wifi:config nano formatting: disabled
I (622) wifi:Init data frame dynamic rx buffer num: 40
I (627) wifi:Init static rx mgmt buffer num: 5
I (631) wifi:Init management short buffer num: 32
I (635) wifi:Init dynamic tx buffer num: 64
I (639) wifi:Init static rx buffer size: 1600
I (644) wifi:Init static rx buffer num: 16
I (647) wifi:Init dynamic rx buffer num: 40
I (652) wifi_init: rx ba win: 32
I (654) wifi_init: accept mbox: 6
I (657) wifi_init: tcpip mbox: 32
I (660) wifi_init: udp mbox: 6
I (663) wifi_init: tcp mbox: 6
I (666) wifi_init: tcp tx win: 5760
I (669) wifi_init: tcp rx win: 5760
I (672) wifi_init: tcp mss: 1440
I (675) wifi_init: WiFi IRAM OP enabled
I (679) wifi_init: WiFi RX IRAM OP enabled
I (683) BTDM_INIT: BT controller compile version [20b459d]
I (689) BTDM_INIT: Bluetooth MAC: e0:e2:e6:d6:42:1e
I (695) phy_init: phy_version 4840,02e0d70,Sep  2 2024,19:39:07
I (1075) FW_MAIN: ESP Bluetooth MAC addr: e0-e2-e6-d6-42-1e

I (1075) FW_SDIO_SLAVE: Using SDIO interface
I (2077) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (491) heap_init: Initializing. RAM available for dynamic allocation:
I (497) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (502) heap_init: At 3FFB7CD8 len 00000328 (0 KiB): DRAM
I (507) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (512) heap_init: At 3FFD2490 len 0000DB70 (54 KiB): DRAM
I (518) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (523) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (528) heap_init: At 4009EC38 len 000013C8 (4 KiB): IRAM
I (535) spi_flash: detected chip: generic
I (537) spi_flash: flash io: dio
I (541) coexist: coex firmware version: 49a8cdc
I (546) main_task: Started on CPU0
I (549) main_task: Calling app_main()
I (551) stats: *********************************************************************
I (558) stats:                 ESP-Hosted Firmware version :: NG-1.0.3.0.12
I (567) stats:                 Transport used :: SDIO only
I (574) stats: *********************************************************************
I (582) FW_MAIN: Supported features are:
I (585) FW_MAIN: - WLAN over SDIO
I (588) FW_BT: - BT/BLE
I (591) FW_BT:    - HCI Over SDIO
I (594) FW_BT:    - BT/BLE dual mode
I (597) FW_MAIN: Capabilities: 0x1d
I (610) wifi:wifi driver task: 3ffd5ea4, prio:23, stack:6656, core=1
I (613) wifi:wifi firmware version: 87d6f3c
I (613) wifi:wifi certification version: v7.0
I (614) wifi:config NVS flash: disabled
I (618) wifi:config nano formatting: disabled
I (622) wifi:Init data frame dynamic rx buffer num: 40
I (627) wifi:Init static rx mgmt buffer num: 5
I (631) wifi:Init management short buffer num: 32
I (635) wifi:Init dynamic tx buffer num: 64
I (639) wifi:Init static rx buffer size: 1600
I (644) wifi:Init static rx buffer num: 16
I (647) wifi:Init dynamic rx buffer num: 40
I (652) wifi_init: rx ba win: 32
I (654) wifi_init: accept mbox: 6
I (657) wifi_init: tcpip mbox: 32
I (660) wifi_init: udp mbox: 6
I (663) wifi_init: tcp mbox: 6
I (666) wifi_init: tcp tx win: 5760
I (669) wifi_init: tcp rx win: 5760
I (672) wifi_init: tcp mss: 1440
I (675) wifi_init: WiFi IRAM OP enabled
I (679) wifi_init: WiFi RX IRAM OP enabled
I (683) BTDM_INIT: BT controller compile version [20b459d]
I (689) BTDM_INIT: Bluetooth MAC: e0:e2:e6:d6:42:1e
I (695) phy_init: phy_version 4840,02e0d70,Sep  2 2024,19:39:07
I (1075) FW_MAIN: ESP Bluetooth MAC addr: e0-e2-e6-d6-42-1e

I (1075) FW_SDIO_SLAVE: Using SDIO interface
I (2077) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0

There is nothing more is happening after this line was printed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions