espressif / esp-hosted

Hosted Solution (Linux/MCU) with ESP32 (Wi-Fi + BT + BLE)
Other
667 stars 152 forks source link

SDIO 通讯一定数量包后会卡主 #459

Open jankens opened 4 weeks ago

jankens commented 4 weeks ago

我们在使用 sdio 连接esp32 模块的时候遇到一个传送数据卡主的问题。具体情况如下,请帮忙澄清。非常感谢!! 以下是host cpu sdio driver的代码: image image 上图打印的结果是: image 当 *len达到4096以后,就会变成0,导致 buf_available < buf_needed

mantriyogesh commented 4 weeks ago

Can you please let us know some details:

  1. host used - any details? Is it MCU or Linux?
  2. if linux, what's kernel version
  3. Complete textual logs at ESP from start-up
  4. Complete textual logs at host from start-up
  5. git commit used at ESP
  6. git commit used at Host
jankens commented 3 weeks ago

1.host used - any details? Is it MCU or Linux? Linux

  1. if linux, what's kernel version Linux version 4.4.94+ (wang@jankens-home-ubuntu) (gcc version 7.2.0 (Ingenic Linux-Release5.1.0- Default(xburst2(fp64)+glibc2.29) 2021.12-22 10:52:10) ) #328 SMP PREEMPT Sat May 18 22:30:33 HKT 2024

  2. Complete textual logs at ESP from start-up ets Jul 29 2019 12:21:46

    rst:0x1 (POWERON_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT) configsip: 271414342, 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:7132 ho 0 tail 12 room 4 load:0x40078000,len:15616 load:0x40080400,len:4 load:0x40080404,len:3876 entry 0x4008064c I (32) boot: ESP-IDF v5.1.3-4-g9a1f2764fe-dirty 2nd stage bootloader I (32) boot: compile time Apr 29 2024 10:21:58 I (34) boot: Multicore bootloader I (38) boot: chip revision: v3.1 I (42) boot.esp32: SPI Speed : 40MHz I (46) boot.esp32: SPI Mode : DIO I (51) boot.esp32: SPI Flash Size : 2MB I (55) boot: Enabling RNG early entropy source... I (61) boot: Partition Table: I (64) boot: ## Label Usage Type ST Offset Length I (72) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (79) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (87) boot: 2 factory factory app 00 00 00010000 001c2000 I (94) boot: End of partition table I (98) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=4887ch (297084) map I (214) esp_image: segment 1: paddr=000588a4 vaddr=3ff80000 size=00004h ( 4) load I (214) esp_image: segment 2: paddr=000588b0 vaddr=3ffbdb60 size=05944h ( 22852) load I (229) esp_image: segment 3: paddr=0005e1fc vaddr=40080000 size=01e1ch ( 7708) load I (232) esp_image: segment 4: paddr=00060020 vaddr=400d0020 size=120a40h (1182272) map I (664) esp_image: segment 5: paddr=00180a68 vaddr=40081e1c size=19564h (103780) load I (721) boot: Loaded app from partition at offset 0x10000 I (721) boot: Disabling RNG early entropy source... I (733) cpu_start: Unicore app I (733) cpu_start: Pro cpu up. I (733) cpu_start: Single core mode W (897) clk: 32 kHz XTAL not found, switching to internal 150 kHz oscillator I (905) cpu_start: Pro cpu start user code I (905) cpu_start: cpu freq: 160000000 Hz I (905) cpu_start: Application information: I (910) cpu_start: Project name: cino_esp32 I (915) cpu_start: App version: v5.1.3-10-gfc265a3774 I (921) cpu_start: Compile time: Aug 7 2024 11:39:36 I (927) cpu_start: ELF file SHA256: 9ae92c267fcfc706... I (933) cpu_start: ESP-IDF: v5.1.3-10-gfc265a3774 I (939) cpu_start: Min chip rev: v0.0 I (944) cpu_start: Max chip rev: v3.99 I (949) cpu_start: Chip rev: v3.1 I (954) heap_init: Initializing. RAM available for dynamic allocation: I (961) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM I (967) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM I (973) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM I (979) heap_init: At 3FFD0B38 len 0000F4C8 (61 KiB): DRAM I (985) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM I (992) heap_init: At 40078000 len 00008000 (32 KiB): IRAM I (998) heap_init: At 4009B380 len 00004C80 (19 KiB): IRAM I (1004) heap_init: At 3Fmmc3: Unknown controller version (5). You may experience problems. I (1012) spi_flash: detected chip: generic I (1015) spi_flash: flize(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header. I (1044) coexist: coex firmware version: 77cd7f8 I (1045) app_start: Starting scheduler on CPU0 I (1045) main_task: Started on CPU0 I (1045) main_task: Calling awlan_mmc_num must be define! I (1060) gpio: GPIO[26]| linux_init_module filename=/mnt/debug/esp32_sdio.ko I (1065) CINO= slave ready ================ I (1605) BTDM_INIT: BT controller compile version [a38dc5c] W (1605) BTDM_INIT: 32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock I (1615) BTDM_INIT: Bluetooth MAC: 56:45:34:34:23:14 I (1625) phy_init: phy_version 4791,2c4672b,Dec 20 2023,16:06:06 I (2295) L2CAP_TAG: ESP_BT_L2CAP_INIT_EVT: status:0 I (2305) L2CAP_TAG: ESP_BT_L2CAP_CL_INIT_EVT: status:0 I (2305) L2CAP_TAG: Target address:[00:25:14:05:15:35] I (2305) L2CAP_TAG: Own address:[56:45:34:34:23:14] E (5995) BT_BTM: btm_sec_l2cap_access_req: (initiator) remote features unknown!!sec_flags:0x80 W (6000) BT_HCI: hcif conn complete: hdl 0x80, st 0x0 I (6005) L2CAP_TAG: event: 16 W (6120) BT_APPL: new conn_srvc id:26, app_id:1 I (6125) L2CAP_TAG: ESP_BT_L2CAP_OPEN_EVT: status:0, fd = 3, tx mtu = 65519, remote_address:00:25:14:05:15:35 W (6130) BT_HCI: hcif link supv_to changed: hdl 0x80, supv_to 4800

  3. Complete textual logs at host from start-up

    dmesg

    sdhci: Copyright(c) Pierre Ossman usbcore: registered new interface driver usbhid usbhid: USB HID core driver unable to request PWM, trying legacy API Enter 'CDT' mode. Enter 'DMA Descriptor chain' mode. create CDT index: 0 ~ 6, index number:7. ingenic-sfc 13440000.sfc: Use burner params. ingenic-sfc 13440000.sfc: magic is 0x726f6e version is 0x2 create CDT index: 6 ~ 24, index number:19. ingenic-sfc 13440000.sfc: nor flash quad mode is set, now use quad mode! Creating 9 MTD partitions on "sfc_mtd": 0x000000000000-0x000000040000 : "uboot" 0x000000040000-0x000000380000 : "upg_kernel" 0x000000380000-0x0000005c0000 : "kernel" 0x0000005c0000-0x000000ac0000 : "rootfs" 0x000000ac0000-0x000000af0000 : "SYSTEM" 0x000000af0000-0x000000bf0000 : "DATA" 0x000000bf0000-0x000000df0000 : "DATA2" 0x000000df0000-0x000000ff0000 : "DEBUG" 0x000000ff0000-0x000001000000 : "ingenic_hdr" ingenic-sfc 13440000.sfc: SPI NOR MTD LOAD OK ingenic-pwm 134c0000.pwm: ingenic-x2000 Probe of pwm success! 10030000.serial: ttyS0 at MMIO 0x10030000 (irq = 55, base_baud = 9375000) is a uart0 10031000.serial: ttyS1 at MMIO 0x10031000 (irq = 54, base_baud = 9375000) is a uart1 10032000.serial: ttyS2 at MMIO 0x10032000 (irq = 53, base_baud = 9375000) is a uart2 10033000.serial: ttyS3 at MMIO 0x10033000 (irq = 52, base_baud = 9375000) is a uart3 console [ttyS3] enabled bootconsole [early0] disabled Bluetooth: RFCOMM socket layer initialized Bluetooth: RFCOMM ver 1.11 Bluetooth: HIDP (Human Interface Emulation) ver 1.2 Bluetooth: HIDP socket layer initialized input: gpio-keys as /devices/platform/gpio-keys.0/input/input0 input: gpio-keys as /devices/platform/gpio-keys.1/input/input1 input: gpio-keys as /devices/platform/gpio-keys.2/input/input2 rtc-ingenic 10003000.rtc: setting system clock to 2020-03-01 12:27:40 UTC (1583065660) v4l2loopback driver version 0.12.5 loaded mtd: rootfs 5242880 32768 0 VFS: Mounted root (squashfs filesystem) readonly on device 50:3. Freeing unused kernel memory: 212K random: nonblocking pool is initialized md_i2c_gpio md_i2c_gpio.3: using pins 55 (SDA) and 54 (SCL) vic(mem)0 register successfully vic0 register successfully pag7930_init => pag7930_is_crop=0 camera_register_sensor : index=0 width:1280, height:800 === SPECIAL USB PHY SETTING === dwc2 13500000.otg_new: bound driver configfs-gadget pag7930 get chip id = 7830 reset_user_frame_when_stream_on=1 PM: Syncing filesystems ... done. Freezing user space processes ... (elapsed 0.001 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.000 seconds) done. x2000 suspend begin Suspending console(s) (use no_console_suspend to debug) PM: suspend of devices complete after 0.323 msecs PM: late suspend of devices complete after 0.166 msecs PM: noirq suspend of devices complete after 0.250 msecs Disabling non-boot CPUs ... SMP: CPU1 is offline SMP[1] is disabled x2000 pm enter!! soc pm sleep post wakeup! Enabling non-boot CPUs ... [SMP] Booting CPU1 ... Primary instruction cache 32kB, VIPT, 8-way, linesize 32 bytes. Primary data cache 32kB, 8-way, VIPT, no aliases, linesize 32 bytes =======found ...... ingenic sc cache ops ...!, found: 1

    Unified secondary cache 512kB 16-way, linesize 64 bytes.

    now starting init for cpu : 1

    percpu irq inited. percpu cpu_num:1 timerevent init clockevents_config_and_register success. CPU1 revision is: 00132000 (Ingenic XBurst@II.V2) FPU revision is: 00f32000 MSA revision is: 00002000 [SMP] slave cpu1 start up finished. CPU1 is up PM: noirq resume of devices complete after 0.186 msecs PM: early resume of devices complete after 0.136 msecs create CDT index: 0 ~ 24, index number:25. === SPECIAL USB PHY SETTING === PM: resume of devices complete after 6.873 msecs x2000 pm end! Restarting tasks ... done. configfs-gadget gadget: unbind function 'acm'/822e9900 mmc3: Unknown controller version (5). You may experience problems. sdhci [sdhci_add_host()]: mmc3: Auto-CMD23 available md_ingenic,sdhci md_ingenic,sdhci.1: No vmmc regulator found md_ingenic,sdhci md_ingenic,sdhci.1: No vqmmc regulator found sdhci: =========== REGISTER DUMP (mmc3)=========== sdhci: Sys addr: 0x00000000 | Version: 0x00000005 sdhci: Blk size: 0x00000000 | Blk cnt: 0x00000000 sdhci: Argument: 0x00000000 | Trn mode: 0x00000000 sdhci: Present: 0x03f70000 | Host ctl: 0x00000000 sdhci: Power: 0x00000000 | Blk gap: 0x00000000 sdhci: Wake-up: 0x00000000 | Clock: 0x00000000 sdhci: Timeout: 0x00000000 | Int stat: 0x00000000 sdhci: Int enab: 0x00ff0003 | Sig enab: 0x00ff0003 sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000 sdhci: Caps: 0x276dc898 | Caps_1: 0x08002077 sdhci: Cmd: 0x00000000 | Max curr: 0x00000000 sdhci: Host ctl2: 0x00000000 sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x00000000 sdhci: =========================================== md_ingenic,sdhci md_ingenic,sdhci.1: Initial signal voltage of 3.3v mmc3: SDHCI controller on ingenic-sdhci [md_ingenic,sdhci.1] using ADMA mmc3: mmc_rescan_try_freq: trying to init card at 400000 Hz esp32_sdio: unknown parameter 'wifi_power_on' ignored esp32_sdio: unknown parameter 'wifi_power_on_level' ignored esp32_sdio: unknown parameter 'wifi_reg_on' ignored esp32_sdio: unknown parameter 'wifi_reg_on_level' ignored esp32_sdio: unknown parameter 'msc0_is_enable' ignored esp32_sdio: unknown parameter 'msc0_cd_method' ignored esp32_sdio: unknown parameter 'msc0_bus_width' ignored esp32_sdio: unknown parameter 'msc0_speed' ignored esp32_sdio: unknown parameter 'msc0_max_frequency' ignored esp32_sdio: unknown parameter 'msc0_cap_power_off_card' ignored esp32_sdio: unknown parameter 'msc0_cap_mmc_hw_reset' ignored esp32_sdio: unknown parameter 'msc0_cap_sdio_irq' ignored esp32_sdio: unknown parameter 'msc0_full_pwr_cycle' ignored esp32_sdio: unknown parameter 'msc0_keep_power_in_suspend' ignored esp32_sdio: unknown parameter 'msc0_enable_sdio_wakeup' ignored esp32_sdio: unknown parameter 'msc0_dsr' ignored esp32_sdio: unknown parameter 'msc0_pio_mode' ignored esp32_sdio: unknown parameter 'msc0_enable_autocmd12' ignored esp32_sdio: unknown parameter 'msc0_enable_cpm_rx_tuning' ignored esp32_sdio: unknown parameter 'msc0_enable_cpm_tx_tuning' ignored esp32_sdio: unknown parameter 'msc0_sdio_clk' ignored esp32_sdio: unknown parameter 'msc0_rst' ignored esp32_sdio: unknown parameter 'msc0_rst_enable_level' ignored esp32_sdio: unknown parameter 'msc0_wp' ignored esp32_sdio: unknown parameter 'msc0_wp_enable_level' ignored esp32_sdio: unknown parameter 'msc0_pwr' ignored esp32_sdio: unknown parameter 'msc0_pwr_enable_level' ignored esp32_sdio: unknown parameter 'msc0_cd' ignored esp32_sdio: unknown parameter 'msc0_cd_enable_level' ignored esp32_sdio: unknown parameter 'msc0_sdr' ignored esp32_sdio: unknown parameter 'msc0_sdr_enable_level' ignored esp32_sdio: unknown parameter 'msc1_is_enable' ignored esp32_sdio: unknown parameter 'msc1_cd_method' ignored esp32_sdio: unknown parameter 'msc1_bus_width' ignored esp32_sdio: unknown parameter 'msc1_speed' ignored esp32_sdio: unknown parameter 'msc1_max_frequency' ignored esp32_sdio: unknown parameter 'msc1_cap_power_off_card' ignored esp32_sdio: unknown parameter 'msc1_cap_mmc_hw_reset' ignored esp32_sdio: unknown parameter 'msc1_cap_sdio_irq' ignored esp32_sdio: unknown parameter 'msc1_full_pwr_cycle' ignored esp32_sdio: unknown parameter 'msc1_keep_power_in_suspend' ignored esp32_sdio: unknown parameter 'msc1_enable_sdio_wakeup' ignored esp32_sdio: unknown parameter 'msc1_dsr' ignored esp32_sdio: unknown parameter 'msc1_pio_mode' ignored esp32_sdio: unknown parameter 'msc1_enable_autocmd12' ignored esp32_sdio: unknown parameter 'msc1_enable_cpm_rx_tuning' ignored esp32_sdio: unknown parameter 'msc1_enable_cpm_tx_tuning' ignored esp32_sdio: unknown parameter 'msc1_sdio_clk' ignored esp32_sdio: unknown parameter 'msc1_rst' ignored esp32_sdio: unknown parameter 'msc1_rst_enable_level' ignored esp32_sdio: unknown parameter 'msc1_wp' ignored esp32_sdio: unknown parameter 'msc1_wp_enable_level' ignored esp32_sdio: unknown parameter 'msc1_pwr' ignored esp32_sdio: unknown parameter 'msc1_pwr_enable_level' ignored esp32_sdio: unknown parameter 'msc1_cd' ignored esp32_sdio: unknown parameter 'msc1_cd_enable_level' ignored esp32_sdio: unknown parameter 'msc1_sdr' ignored esp32_sdio: unknown parameter 'msc1_sdr_enable_level' ignored esp32_sdio: unknown parameter 'msc2_is_enable' ignored esp32_sdio: unknown parameter 'msc2_cd_method' ignored esp32_sdio: unknown parameter 'msc2_bus_width' ignored esp32_sdio: unknown parameter 'msc2_speed' ignored esp32_sdio: unknown parameter 'msc2_max_frequency' ignored esp32_sdio: unknown parameter 'msc2_cap_power_off_card' ignored esp32_sdio: unknown parameter 'msc2_cap_mmc_hw_reset' ignored esp32_sdio: unknown parameter 'msc2_cap_sdio_irq' ignored esp32_sdio: unknown parameter 'msc2_full_pwr_cycle' ignored esp32_sdio: unknown parameter 'msc2_keep_power_in_suspend' ignored esp32_sdio: unknown parameter 'msc2_enable_sdio_wakeup' ignored esp32_sdio: unknown parameter 'msc2_dsr' ignored esp32_sdio: unknown parameter 'msc2_pio_mode' ignored esp32_sdio: unknown parameter 'msc2_enable_autocmd12' ignored esp32_sdio: unknown parameter 'msc2_enable_cpm_rx_tuning' ignored esp32_sdio: unknown parameter 'msc2_enable_cpm_tx_tuning' ignored esp32_sdio: unknown parameter 'msc2_sdio_clk' ignored esp32_sdio: unknown parameter 'msc2_rst' ignored esp32_sdio: unknown parameter 'msc2_rst_enable_level' ignored esp32_sdio: unknown parameter 'msc2_wp' ignored esp32_sdio: unknown parameter 'msc2_wp_enable_level' ignored esp32_sdio: unknown parameter 'msc2_pwr' ignored esp32_sdio: unknown parameter 'msc2_pwr_enable_level' ignored esp32_sdio: unknown parameter 'msc2_cd' ignored esp32_sdio: unknown parameter 'msc2_cd_enable_level' ignored esp32_sdio: unknown parameter 'msc2_sdr' ignored esp32_sdio: unknown parameter 'msc2_sdr_enable_level' ignored esp32 init wlan_mmc_num must be define! esp_wlan_power_on =====Enter download mode===== mmc3: queuing unknown CIS tuple 0x01 (3 bytes) mmc3: queuing unknown CIS tuple 0x1a (5 bytes) mmc3: queuing unknown CIS tuple 0x1b (8 bytes) mmc3: queuing unknown CIS tuple 0x80 (1 bytes) mmc3: queuing unknown CIS tuple 0x81 (1 bytes) mmc3: queuing unknown CIS tuple 0x82 (1 bytes) mmc3: queuing unknown CIS tuple 0x80 (1 bytes) mmc3: queuing unknown CIS tuple 0x81 (1 bytes) mmc3: queuing unknown CIS tuple 0x82 (1 bytes) mmc3: queuing unknown CIS tuple 0x91 (3 bytes) mmc3: new SDIO card at address 0001 no manual card detect esp_probe: ESP network device detected SDIO: Enabling device mmc3:0001:1... SDIO: Enabled device mmc3:0001:1 SDIO: Enabling IRQ for mmc3:0001:1... MAJOR = 249 MINOR = 0 esp_sdio: probe of mmc3:0001:2 failed with error -22 esp_serial_tx >>>>>: frag_len=52 ========esp_slave_get_tx_buffer_num 00100000, 0000000a esp_serial_rx <<<<<: len=52 esp_serial_rx <<<<<: len=68 esp_serial_tx >>>>>: frag_len=68 ========esp_slave_get_tx_buffer_num 00140000, 0000000d esp_serial_rx <<<<<: len=52 esp_serial_rx <<<<<: len=68 esp_serial_tx >>>>>: frag_len=112 ========esp_slave_get_tx_buffer_num 00180000, 00000010 esp_serial_rx <<<<<: len=52 pag7930 get chip id = 7830 reset_user_frame_when_stream_on=1 esp_serial_rx <<<<<: len=68 esp_serial_rx <<<<<: len=68 esp_serial_tx >>>>>: frag_len=136 ========esp_slave_get_tx_buffer_num 001c0000, 00000013 esp_serial_rx <<<<<: len=52 esp32_write_buffer len = 69 pos=0 ESP32: update pkg_idx_rsp 2 ESP32: update pkg_idx_rsp 3 ESP32: update pkg_idx_rsp 4 W (19265) BT_HCI: hci cmd send: sniff: hdl 0x80, intv(400 800) W (19290) BT_HCI: hcif mode change: hdl 0x80, mode 2, intv 800, status 0x0 I (19290) L2CAP_TAG: ESP_BT_GAP_MODE_CHG_EVT mode:2 bda:[00:25:14:05:15:35] ......

  4. git commit used at ESP commit e7771c75bd1dbbfb7b3c5381be7e063b197c9734 (tag: v5.1.3) Author: Marius Vikhammer marius.vikhammer@espressif.com Date: Mon Feb 26 11:09:16 2024 +0800

    versions: Update version to 5.1.3
  5. git commit used at Host We are using Ingenic 君正 X2100 CPU, and the host linux is the official linux of X2100.

mantriyogesh commented 3 weeks ago

Which ESP hosted commit you have used for esp-hosted slave?

I am unsure if if is esp-hosted slave, or some other binary.

jankens commented 3 weeks ago

The esp_hosted code is merged into Ingenic x2100 linux by Ingenic company (supported by ESP company as I know), I don't know which commit they are using. but I can send you the source code of the sdio driver. the driver can communicate with esp32 module using SDIO at the beginning, but after a fix number of packets transmit from host to esp32. it is stuck as descript in the question. host can receive packets from esp32 module when sending stuck. esp32_linux.zip

mantriyogesh commented 3 weeks ago

Cannot exactly tell which commit. But In any case, if the Linux was tested using ESP32, it should work if hardware is already on PCB.

Is it possible to show the connections in camera photo?

Also, the current firmware in ESP looks not to be flash from ESP-Hosted. It looks some general ESP-IDF example been flashed.

I think, you can just back this code and copy the latest master code here (I really suggest handling this through some kind of version system, as otherwise it would become hard to manage for you). and build and flash latest master slave code into ESP32.

reboot whole machine and get the logs at botth sides.

jankens commented 3 weeks ago

I think I will not flash to the lastest version of esp-hosted, cause it works well at the beginning packets. Can you help me to answer some question?

  1. what is the meaning of the register ESP_SLAVE_TOKEN_RDATA which is read from host driver every sending packet?
  2. why is this register alway be increased its number,
  3. can this register be clear / what action can clear this register on host site or esp32 site?
jankens commented 2 weeks ago

@mantriyogesh can you help me?

mantriyogesh commented 2 weeks ago

Can you please reflash the firmware at ESP from master? Also please use master at host for kernel module build.

Once you have same version of both, they should be compatible.

Get the logs with this arrangement, to debug effectively