Wifi over SDIO on P4

JohnnyZ
Posts: 36
Joined: Thu Jan 11, 2024 10:24 am

Wifi over SDIO on P4

Postby JohnnyZ » Fri Jan 03, 2025 3:44 pm

I am trying to build examples/wifi/iperf for ESP32-P4 on ESP-IDF v5.4.
According to the README it is supported on P4. Even if it wireless-less chip it can utilize C6 for WiFi over SDIO.
idf menuconfig

Component config → ESP external connectivity
(54) Slave enable pin
(1) Slave enable gpio level
(6) Slave boot pin
Component config → ESP external connectivity → IO Configuration → SDIO Slot configuration
(1) host slot
(18) clk
(19) cmd
(14) D0
(15) D1
(16) D2
(17) D3
Component config → Wi-Fi → Host WiFi Enable
Partition Table → Partition Table: Single factory app (large), no OTA
After flashing and running:
Rebooting...
ESP-ROM:esp32p4-eco1-20240205
Build:Feb 5 2024
rst:0xc (SW_CPU_RESET),boot:0x10f (SPI_FAST_FLASH_BOOT)
Core0 Saved PC:0x4ff00c4c
Core1 Saved PC:0x4ff048c4
SPI mode:DIO, clock div:1
load:0x4ff33ce0,len:0x1150
load:0x4ff2abd0,len:0xaf4
load:0x4ff2cbd0,len:0x3078
entry 0x4ff2abd0
I (215) cpu_start: Multicore app
I (224) cpu_start: Pro cpu start user code
I (225) cpu_start: cpu freq: 360000000 Hz
I (225) app_init: Application information:
I (225) app_init: Project name: iperf
I (228) app_init: App version: v5.4-rc1-10-gde29670d9c-dirty
I (234) app_init: Compile time: Jan 3 2025 16:17:52
I (239) app_init: ELF file SHA256: 4008049d2...
I (243) app_init: ESP-IDF: v5.4-rc1-10-gde29670d9c-dirty
I (249) efuse_init: Min chip rev: v0.1
I (253) efuse_init: Max chip rev: v1.99
I (257) efuse_init: Chip rev: v0.1
I (261) heap_init: Initializing. RAM available for dynamic allocation:
I (267) heap_init: At 4FF1D8E0 len 0001D6E0 (117 KiB): RAM
I (272) heap_init: At 4FF3AFC0 len 00004BF0 (18 KiB): RAM
I (277) heap_init: At 4FF40000 len 00060000 (384 KiB): RAM
I (283) heap_init: At 50108080 len 00007F80 (31 KiB): RTCRAM
I (288) heap_init: At 30100044 len 00001FBC (7 KiB): TCM
I (294) spi_flash: detected chip: generic
I (297) spi_flash: flash io: dio
I (300) main_task: Started on CPU0
I (343) main_task: Calling app_main()
I (343) gpio: GPIO[6]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (344) gpio: GPIO[54]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (412) gpio: GPIO[18]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (412) gpio: GPIO[19]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (418) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (426) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (434) gpio: GPIO[16]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (443) gpio: GPIO[17]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (483) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (485) gpio: GPIO[17]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (489) fw_dl: sdmmc init success 0x0
Name:
Type: SDIO
Speed: 20.00 MHz (limit: 20.00 MHz)
Size: 0MB
CSD: ver=1, sector_size=0, capacity=0 read_bl_len=0
SCR: sd_spec=0, bus_width=0
I (525) esp_host: IOE: 0x06
I (525) esp_host: IE: 0x07
I (525) esp_host: BUS_WIDTH GET: 0x42
I (525) esp_host: BUS_WIDTH SET: 0x62
I (525) esp_host: Function 1 read: 0000
I (529) esp_host: Function 1 set: 0200
I (532) esp_host: Function 2 BS: 0000
I (536) esp_host: Function 2 BS: 0200
E (539) sdmmc_io: sdmmc_io_rw_extended: sdmmc_send_cmd returned 0x107
E (545) esp_host: read ESP_SLC_CONF1_REG error 0x107
E (550) esp_host: esp_extconn_sdio_init(210): esp host init slave link failed
I (557) extconn: extconn init ret 0x107
I (572) wifi:wifi driver task: 4ff27f64, prio:23, stack:6656, core=0
I (572) wifi:wifi Rxcontrol 28
E (572) esp_adapter: esp_extconn_get_mac() returned NULL, not good!
E (575) esp_adapter: esp_extconn_get_mac() returned NULL, not good!
I (582) wifi:wifi firmware version: 48ea317a7
I (585) wifi:wifi certification version: v7.0
I (590) wifi:config NVS flash: disabled
I (593) wifi:config nano formatting: disabled
I (597) wifi:Init data frame dynamic rx buffer num: 32
I (602) wifi:Init management frame dynamic rx buffer num: 32
I (607) wifi:Init management short buffer num: 32
I (612) wifi:Init dynamic tx buffer num: 32
I (616) wifi_init: rx ba win: 6
I (619) wifi_init: accept mbox: 6
I (622) wifi_init: tcpip mbox: 32
I (625) wifi_init: udp mbox: 6
I (627) wifi_init: tcp mbox: 6
I (630) wifi_init: tcp tx win: 5760
I (633) wifi_init: tcp rx win: 5760
I (637) wifi_init: tcp mss: 1440
I (640) wifi_init: WiFi IRAM OP enabled
I (643) wifi_init: WiFi RX IRAM OP enabled
I (647) wifi_init: LWIP IRAM OP enabled
I (651) wifi:(2.4G)set country: cc=CN schan=1 nchan=13 policy=0
Guru Meditation Error: Core 0 panic'ed (Instruction access fault). Exception was unhandled.
Core 0 register dump:
MEPC : 0x00000000 RA : 0x40072ce4 SP : 0x4ff27e90 GP : 0x4ff16580
TP : 0x4ff27f30 T0 : 0x4fc0a778 T1 : 0x00000000 T2 : 0x0000002c
S0/FP : 0x4ff29210 S1 : 0xffffffff A0 : 0x00000000 A1 : 0x00000000
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x4ff1c000 A5 : 0x4ff1d000
A6 : 0x00000006 A7 : 0x4000cc86 S2 : 0x4ff1c618 S3 : 0x4ff1d000
S4 : 0x4ff18000 S5 : 0x00000000 S6 : 0x4ff1ce6c S7 : 0x4010c000
S8 : 0x40112000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0x00000000 T4 : 0x4003e06a T5 : 0x4003e188 T6 : 0x4003decc
MSTATUS : 0x00011880 MTVEC : 0x4ff00003 MCAUSE : 0x00000001 MTVAL : 0x00000000
MHARTID : 0x00000000
Error 0x107 is ESP_ERR_TIMEOUT.
Let's ignore reboot loop for now (I've debugged it and it is because "static struct esp_sip *sip = NULL;" is still NULL at the time of access in esp_sip.c (in esp-extconn module)).

What would cause SDIO timeouts?
Pinouts are good.
Does anybody has success story with P4 and WiFi?

chegewara
Posts: 2505
Joined: Wed Jun 14, 2017 9:00 pm

Re: Wifi over SDIO on P4

Postby chegewara » Thu Jan 09, 2025 12:57 am

Hi,
sure, i have dozen different apps running wifi on P4 devkit w/o problems.
First of all this option should be disabled

Code: Select all

Component config → Wi-Fi → Host WiFi Enable
It is for chips which have hardware wifi support.

JohnnyZ
Posts: 36
Joined: Thu Jan 11, 2024 10:24 am

Re: Wifi over SDIO on P4

Postby JohnnyZ » Sat Jan 11, 2025 2:06 pm

Hi, thanks for joining in.
When host Wi-Fi is disabled in menuconfig and I try to build iperf example, builds fails same was as in this link https://esp32.com/viewtopic.php?f=13&t=42484
If solution from that thread is applied to my sdkconfig then I'll end up with the same situation as in the opening post of the thread.
sure, i have dozen different apps running wifi on P4 devkit w/o problems.
Can you share your sdkconfig? Are you using C6 as as slave to P4?
Do I need to flash my C6 with something before using it as a slave to P4?

chegewara
Posts: 2505
Joined: Wed Jun 14, 2017 9:00 pm

Re: Wifi over SDIO on P4

Postby chegewara » Sat Jan 11, 2025 2:21 pm

Hi,
if you have factory p4 devboard then you dont have to flash anything on C6, it is already flashed with firmware which allows to use wifi and nimble.

To use wifi and/or ble on P4 you need some components from components registry:
https://components.espressif.com/compon ... ions/1.0.2
https://components.espressif.com/compon ... ions/0.5.3

There is detailed instruction how to use it
https://github.com/espressif/esp-hosted ... v_board.md

JohnnyZ
Posts: 36
Joined: Thu Jan 11, 2024 10:24 am

Re: Wifi over SDIO on P4

Postby JohnnyZ » Sat Jan 11, 2025 4:21 pm

Hi, thanks for the links! Now some things are clearer.
But, I am failing to build iperf example.

I am building on v5.4 branch of IDF.

Code: Select all

cd examples/wifi/iperf/
rm -rf build/
idf.py add-dependency "espressif/esp_wifi_remote"
idf.py add-dependency "espressif/esp_hosted"
"esp-extconn" is removed:
main/idf_component.yml
dependencies:
espressif/esp_hosted: "*"
espressif/esp_wifi_remote: "*"
cmd_system:
path: ${IDF_PATH}/examples/system/console/advanced/components/cmd_system
espressif/iperf-cmd:
version: "~0.1.1"
esp-qa/wifi-cmd:
version: "~0.1.8"
esp-qa/ping-cmd:
version: "~1.0.0"
sdkconfig.defaults.esp32p4:
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=64
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
CONFIG_ESP_WIFI_TX_BA_WIN=32
CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y
CONFIG_ESP_WIFI_RX_BA_WIN=32

CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534
CONFIG_LWIP_TCP_WND_DEFAULT=65534
CONFIG_LWIP_TCP_RECVMBOX_SIZE=64
CONFIG_LWIP_UDP_RECVMBOX_SIZE=64
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64

CONFIG_LWIP_TCP_SACK_OUT=y
idf.py set-target esp32p4
idf.py build

But build fails with:
In file included from /usr/home/johnny/esp32/idf/examples/wifi/iperf/managed_components/esp-qa__wifi-cmd/src/wifi_init.c:7:
/usr/home/johnny/esp32/idf/examples/wifi/iperf/managed_components/esp-qa__wifi-cmd/src/wifi_init.c: In function 'wifi_cmd_initialize_wifi':
/usr/home/johnny/esp32/idf/components/esp_wifi/include/esp_wifi.h:303:26: error: 'CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM' undeclared (first use in this function); did you mean 'CONFIG_ETH_DMA_RX_BUFFER_NUM'?
303 | .static_rx_buf_num = CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM,\
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/home/johnny/esp32/idf/examples/wifi/iperf/managed_components/esp-qa__wifi-cmd/src/wifi_init.c:129:34: note: in expansion of macro 'WIFI_INIT_CONFIG_DEFAULT'
129 | wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
| ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/home/johnny/esp32/idf/components/esp_wifi/include/esp_wifi.h:303:26: note: each undeclared identifier is reported only once for each function it appears in
303 | .static_rx_buf_num = CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM,\
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
....
After looking into sdkconfig, the first block (CONFIG_ESP_WIFI_*) from sdkconfig.defaults.esp32p4 is not present in sdkconfig.

chegewara
Posts: 2505
Joined: Wed Jun 14, 2017 9:00 pm

Re: Wifi over SDIO on P4

Postby chegewara » Sun Jan 12, 2025 6:24 pm

Hi,
seems i was mistaken.
My projects seems to work with this option disabled

Code: Select all

Component config → Wi-Fi → Host WiFi Enable
but according to this docs and your error you need it enabled
https://github.com/espressif/esp-hosted ... g-defaults

JohnnyZ
Posts: 36
Joined: Thu Jan 11, 2024 10:24 am

Re: Wifi over SDIO on P4

Postby JohnnyZ » Mon Jan 13, 2025 3:21 pm

This is finally compiled and run without crashes :)

After many tries I noticed that I was unable to go to "(Top) → Component config → Wi-Fi Remote: Wi-Fi configuration ----" menu. And that was the reason why I wasn't able to compile it without undefined references to:
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM
CONFIG_ESP_WIFI_TX_BUFFER_TYPE
CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF
CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM

That defines will be defined in the code if "Host WiFi enable" in menuconfig is selected. But then it won't work, because that option is for SoCs with builtin WiFi (which ESP32-P4 lacks).

The missing link was "export ESP_IDF_VERSION=5.4" and then run menuconfig. After that "Wi-Fi configuration" menu is enabled in menuconfig. And I was able to compile it and it ran without problems.
I didn't need to update slave firmware on my board.

JohnnyZ
Posts: 36
Joined: Thu Jan 11, 2024 10:24 am

Re: Wifi over SDIO on P4

Postby JohnnyZ » Mon Jan 13, 2025 3:31 pm

In the end, this was the procedure how to use Wifi over SDIO with esp-hosted on ESP32-P4:
cd examples/wifi/iperf
rm -rf build sdkconfig
idf.py add-dependency "espressif/esp_wifi_remote"
idf.py add-dependency "espressif/esp_hosted"
remove "ext-conn" from main/idf_component.yml
idf.py set-target esp32p4
idf.py menuconfig
Should be default, but, recheck:
- that "Host WiFi Enable" is disabled
- that you can enter "Component config → Wi-Fi Remote → Wi-Fi configuration" menu and see things like "(16) Max number of WiFi static RX buffers"
- that your SDIO pins are correct (default was OK for my board)
- that "CONFIG_SLAVE_IDF_TARGET" is set to correct value (ESP32-C6 in my case)
After building and flashing:
I (269) gpio: GPIO[18]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (277) gpio: GPIO[19]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (285) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (293) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (302) gpio: GPIO[16]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (310) gpio: GPIO[17]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (319) H_API: ** add_esp_wifi_remote_channels **
I (323) transport: Add ESP-Hosted channel IF[1]: S[0] Tx[0x4000e732] Rx[0x4001cbf8]
I (330) transport: Add ESP-Hosted channel IF[2]: S[0] Tx[0x4000e678] Rx[0x4001cbf8]
I (338) main_task: Started on CPU0
I (341) main_task: Calling app_main()
I (354) transport: Attempt connection with slave: retry[0]
I (354) transport: Reset slave using GPIO[54]
I (354) os_wrapper_esp: GPIO [54] configured
I (357) gpio: GPIO[54]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1538) sdio_wrapper: SDIO master: Data-Lines: 4-bit Freq(KHz)[40000 KHz]
I (1538) sdio_wrapper: GPIOs: CLK[18] CMD[19] D0[14] D1[15] D2[16] D3[17] Slave_Reset[54]
I (1538) H_SDIO_DRV: Starting SDIO process rx task
I (1541) sdio_wrapper: Queues: Tx[20] Rx[20] SDIO-Rx-Mode[1]
I (1583) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1585) gpio: GPIO[17]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
Name:
Type: SDIO
Speed: 40.00 MHz (limit: 40.00 MHz)
Size: 0MB
CSD: ver=1, sector_size=0, capacity=0 read_bl_len=0
SCR: sd_spec=0, bus_width=0
TUPLE: DEVICE, size: 3: D9 01 FF
TUPLE: MANFID, size: 4
MANF: 0092, CARD: 6666
TUPLE: FUNCID, size: 2: 0C 00
TUPLE: FUNCE, size: 4: 00 00 02 32
TUPLE: CONFIG, size: 5: 01 01 00 02 07
TUPLE: CFTABLE_ENTRY, size: 8
INDX: C1, Intface: 1, Default: 1, Conf-Entry-Num: 1
IF: 41
FS: 30, misc: 0, mem_space: 1, irq: 1, io_space: 0, timing: 0, power: 0
IR: 30, mask: 1, IRQ: FF FF
LEN: FFFF
TUPLE: END
I (1639) sdio_wrapper: Function 0 Blocksize: 512
I (1643) sdio_wrapper: Function 1 Blocksize: 512
I (1647) H_SDIO_DRV: SDIO Host operating in STREAMING MODE
I (1652) H_SDIO_DRV: generate slave intr
I (1659) transport: Received INIT event from ESP32 peripheral
I (1661) transport: EVENT: 12
I (1664) transport: EVENT: 11
I (1667) transport: capabilities: 0xd
I (1670) transport: Features supported are:
I (1674) transport: * WLAN
I (1677) transport: - HCI over SDIO
I (1680) transport: - BLE only
I (1683) transport: EVENT: 13
I (1686) transport: ESP board type is : 13
I (1690) transport: Base transport is set-up
I (1694) transport: Slave chip Id[12]
I (1698) hci_stub_drv: Host BT Support: Disabled
I (1702) H_SDIO_DRV: Received INIT event
==================================================
| Steps to test WiFi throughput |
| |
| 1. Print 'help' to gain overview of commands |
| 2. Configure device to station or soft-AP |
| 3. Setup WiFi connection |
| 4. Run iperf to test UDP/TCP RX/TX throughput |
| |
=================================================
Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.
I (2781) main_task: Returned from app_main()
iperf>

ujurmsde
Posts: 73
Joined: Tue Jan 19, 2021 6:37 am

Re: Wifi over SDIO on P4

Postby ujurmsde » Tue Sep 02, 2025 5:46 pm

Hi,
I am posting this reply because I have similar configuration both in hardware and software but facing some unexpected error.

I have the same configuration means I have P4 SoC connected to ESP32C6 over SDIO. But when flashing the iperf example I see the following error.

W (478) ldo: The voltage value 0 is out of the recommended range [500, 2700]
I (478) sdmmc_periph: sdmmc_host_init: SDMMC host already initialized, skipping init flow
E (509) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
HINT: Please reboot the board and then try again
W (509) fw_dl: slave init failed 0x107, retry...
E (1036) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
From the very basic, look I thought it might be issue with power domain. I tried to look in menuconfig but did not find anything missing. Then I added the following line of code to example but the error remains the same.!

I have checked the PINs for SDIO and they are correct. Most other configs are right.
Anyone has got any idea?

Code: Select all

esp_ldo_channel_handle_t ldo_mipi_phy = NULL;
    esp_ldo_channel_config_t ldo_mipi_phy_config = {
        .chan_id = 3,
        .voltage_mv = 2500,
    };

JohnnyZ
Posts: 36
Joined: Thu Jan 11, 2024 10:24 am

Re: Wifi over SDIO on P4

Postby JohnnyZ » Wed Sep 03, 2025 5:18 pm

I had same worries trying to fix my SD card, but LDO is okay, I still have that error and my SDIO WIFI (and SD card) works:

Code: Select all

W (2787) ldo: The voltage value 0 is out of the recommended range [500, 2700]
...
I (7507) WIFI: - IPv4 address: 192.168.1.12,

Who is online

Users browsing this forum: Bytespider, Google [Bot], PetalBot, Semrush [Bot] and 2 guests