Skip to content
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

The use of spi interface of ESP32-C6-DevKitC-1 module in Linux system #578

Open
3 tasks done
gali-chen opened this issue Mar 5, 2025 · 15 comments
Open
3 tasks done

Comments

@gali-chen
Copy link

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 am using the wifi Bluetooth module of ESP32-C6, I let my development board communicate with esp32 through spi,
I have burned the firmware of esp32, and I can see the information of esp32 through ttl, but after I connect the pins in the following picture to the development board, I also loaded the esp32_spi.ko file,

but did not see the generation of wlan0. Please help me confirm whether my wiring is correct and there is something missing in my operation.

Thank you very much for your support

Image

esp32 log.txt

@mantriyogesh
Copy link
Collaborator

Any GPIO pins could be used.

We recommend using IO_MUX pins, but diferent pins than io mux are used, still would be routed through GPIO matrix.
If they are unused in any other peripheral, any other pins also would work fine.

When you change the pins, change the code accordingly and the hardware connections as well accordingly.

Should you face any issues, attach full textual log:

  1. esp flashing from start and full idf.py monitor log
  2. host side dmesg log from startup
  3. git commit used both sides
  4. host details (platform details and kernel version)
  5. Confirm if you have followed Porting Guide

Image

@gali-chen
Copy link
Author

Thank you for your quick reply

Here are my questions:

I loaded the esp32_spi.ko module on the st platform, and it did not report any error. Besides, I connected the four pins clk, spid, spiq and cs of esp32 spi, but I failed to see the wlan0 node

root@myd-yf13x:# ls
README-CHECK-GPU eeprom.txt esp32_spi.ko mount.sh
root@myd-yf13x:
#
root@myd-yf13x:#
root@myd-yf13x:
# modprobe hci_uart
[ 39.428906] Bluetooth: Core ver 2.22
[ 39.443238] NET: Registered PF_BLUETOOTH protocol family
[ 39.447110] Bluetooth: HCI device and connection manager initialized
[ 39.455560] Bluetooth: HCI socket layer initialized
[ 39.460399] Bluetooth: L2CAP socket layer initialized
[ 39.464164] Bluetooth: SCO socket layer initialized
[ 39.504322] Bluetooth: HCI UART driver ver 2.3
[ 39.507395] Bluetooth: HCI UART protocol H4 registered
[ 39.523026] Bluetooth: HCI UART protocol LL registered
[ 39.534401] Bluetooth: HCI UART protocol Broadcom registered
[ 39.549119] Bluetooth: HCI UART protocol QCA registered
[ 39.555925] Bluetooth: HCI UART protocol Marvell registered
root@myd-yf13x:#
root@myd-yf13x:
# insmod esp32_spi.ko
[ 46.462184] esp32_spi: loading out-of-tree module taints kernel.
[ 46.690949] esp32_spi: spi_dev_init: Using SPI MODE 2
[ 46.703216] esp32_spi: spi_dev_init: ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [10]
root@myd-yf13x:~# ifconfig -a
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:50

eth0 Link encap:Ethernet HWaddr B6:87:A1:77:17:4C
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:45 Base address:0x8000

eth1 Link encap:Ethernet HWaddr BE:70:FA:58:DA:F2
inet addr:192.168.1.51 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::bc70:faff:fe58:daf2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:168 errors:0 dropped:10 overruns:0 frame:0
TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17230 (16.8 KiB) TX bytes:8666 (8.4 KiB)
Interrupt:52 Base address:0xe000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:99 errors:0 dropped:0 overruns:0 frame:0
TX packets:99 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8720 (8.5 KiB) TX bytes:8720 (8.5 KiB)

usb0 Link encap:Ethernet HWaddr 1E:8D:06:00:62:E3
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

@gali-chen
Copy link
Author

@mantriyogesh

@mantriyogesh
Copy link
Collaborator

If you only connect four pins, this shows that you have not followed the documentation.

I would request you to go through the documentation first. Also check the porting guide.

Documentation includes all steps to get the wifi working

@gali-chen
Copy link
Author

Thanks for the heads-up, I think I've looked at https://docs.espressif.com/projects/esp-dev-kits/zh_CN/latest/esp32c6/esp32-c6-devkitc-1/user_guide.html that the content of the above, Here is the user guide for the esp32-c6

I would like to know which document and migration guide you mentioned can be sent out for my reference, I really need the working steps of esp32-c6 for configuration

@mantriyogesh
Copy link
Collaborator

You have raised issue in ESP-Hosted project, so expect you to see ESPHosted documentation?

https://github.com/espressif/esp-hosted

@gali-chen
Copy link
Author

I have connected the spi lines correctly, and testing spi communication individually is fine, but I have a problem loading the module
insmod esp32_spi.ko
[64.856557] esp32_spi: loading out-of-tree module taints kernel.
[65.081732] esp32_spi: spi_dev_init: Using SPI MODE 2
[65.088189] esp32_spi: spi_dev_init: ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [1]
[65.143713] esp32_spi: process_rx_buf: offset_rcv[0]! = exp[12], drop

The node cannot come out

ifconfig -a
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0B) TX bytes:0 (0.0B)
Interrupt:50

eth0 Link encap:Ethernet HWaddr B6:87:A1:77:17:4C
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0B) TX bytes:0 (0.0B)
Interrupt:45 Base address:0x8000

eth1 Link encap:Ethernet HWaddr BE:70:FA:58:DA:F2
inet addr:192.168.1.47 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::bc70:faff:fe58:daf2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1312 errors:0 dropped:172 overruns:0 frame:0
TX packets:113 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:144608 (141.2 KiB) TX bytes:17814 (17.3 KiB)
Interrupt:52 Base address:0xe000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:187 errors:0 dropped:0 overruns:0 frame:0
TX packets:187 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14064 (13.7 KiB) TX bytes:14064 (13.7 KiB)

usb0 Link encap:Ethernet HWaddr 0E:88:AC:DE:F4:E3
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0B) TX bytes:0 (0.0B)

@mantriyogesh
Copy link
Collaborator

How many pins connected?

Can you send a camera photo ?

@gali-chen
Copy link
Author

A total of 7 pins are configured

This is the esp32-c6 module information

I (435) stats: *********************************************************************
I (441) stats: ESP-Hosted Firmware version :: NG-1.0.3.0.9
I (450) stats: Transport used :: SPI + UART
I (457) stats: *********************************************************************
I (464) FW_MAIN: Supported features are:
I (468) FW_MAIN: - WLAN over SPI
I (471) FW_BT: - BT/BLE
I (473) FW_BT: - HCI Over UART
I (476) FW_BT: - BLE only
I (478) FW_MAIN: Capabilities: 0xaa
pp rom version: 5b8dcfa
net80211 rom version: 5b8dcfa
I (494) wifi:wifi driver task: 40830acc, prio:23, stack:6656, core=0
I (495) wifi:wifi firmware version: 87d6f3c
I (497) wifi:wifi certification version: v7.0
I (501) wifi:config NVS flash: disabled
I (504) wifi:config nano formatting: disabled
I (508) wifi:mac_version:HAL_MAC_ESP32AX_761,ut_version:N, band mode:0x1
I (515) wifi:Init data frame dynamic rx buffer num: 60
I (520) wifi:Init static rx mgmt buffer num: 5
I (524) wifi:Init management short buffer num: 32
I (528) wifi:Init dynamic tx buffer num: 40
I (532) wifi:Init static tx FG buffer num: 2
I (536) wifi:Init static rx buffer size: 1700 (rxctrl:92, csi:512)
I (542) wifi:Init static rx buffer num: 40
I (546) wifi:Init dynamic rx buffer num: 60
I (550) wifi_init: rx ba win: 32
I (553) wifi_init: accept mbox: 6
I (556) wifi_init: tcpip mbox: 32
I (559) wifi_init: udp mbox: 6
I (561) wifi_init: tcp mbox: 6
I (564) wifi_init: tcp tx win: 5760
I (567) wifi_init: tcp rx win: 5760
I (571) wifi_init: tcp mss: 1440
I (574) wifi_init: WiFi IRAM OP enabled
I (577) wifi_init: WiFi RX IRAM OP enabled
I (581) wifi_init: WiFi SLP IRAM OP enabled
I (585) FW_BT: UART Pins: Tx:5 Rx:12
I (588) BLE_INIT: Using main XTAL as clock source
I (597) BLE_INIT: ble controller commit:[b623f7a]
I (598) BLE_INIT: Bluetooth MAC: 40:4c:ca:50:24:06
I (602) hci_uart_config: set uart pin tx:19, rx:10.

I (606) hci_uart_config: set rts:-1, cts:-1.

I (610) hci_uart_config: set baud_rate:921600.

I (615) hci_uart_config: set flow_ctrl:0.

I (619) uart: ALREADY NULL
I (622) uart: queue free spaces: 1
I (625) hci_uart: hci transport task create successfully, prio:23, stack size: 1024
I (632) phy_init: phy_version 320,348a293,Sep 3 2024,16:33:12
I (690) phy: libbtbb version: 04952fd, Sep 3 2024, 16:33:30
I (691) FW_MAIN: ESP Bluetooth MAC addr: 40-4c-ca-50-24- 6

I (691) FW_SPI: Using SPI interface
I (693) FW_SPI: Using SPI MODE 2
I (696) gpio: GPIO[3]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (704) gpio: GPIO[4]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1714) FW_MAIN: Initial set up done
I (1714) main_task: Returned from app_main()

This is my wiring picture
Image

@mantriyogesh
Copy link
Collaborator

I can't figure out the length of jumper cables, in general restrict length to use <=10cm wires for spi.

[65.143713] esp32_spi: process_rx_buf: offset_rcv[0]! = exp[12], drop

Is big issue.

If it was bit shifted would have tried other spi mode like spi mode 3.

But offset is zero.
Is the host sufficiently powered? Also independently host pins attached could be tested for spi?

One way is to check with spidev. For ESP module to world you would already have disabled the spidev (if this is new, unknown, let us know if not already done). To let spidev load, you might have to re enable temporarily and test the spi 4 pins validity with spidev.

It doesn't mandatorily need to be spidev, any user space easy application (python spi user space?)if can confirm spi is working should be sufficient.

The spi transaction right now is only from host to slave. What happened other side?

Does dmesg or /var/log/messages or /var/log/kernel.log log shoe'init' event received? Or at least similar error?

First message in verification sequence is host rx..

@gali-chen
Copy link
Author

I have tested the spi communication, he is no problem, can send and receive, if it is worried about the connection is too long, I have configured the spi rate in the driver, so that he first run at a low speed, I want to know sp32_spi: process_rx_buf: offset_rcv[0]! = exp[12], drop the possible reasons for this problem

@mantriyogesh
Copy link
Collaborator

As I explained, first message is not through. Means, the spi 4 lines are yet not behaving how they should.
The INIT message is sent from slave, should reach the host at

static int process_event_esp_bootup(struct esp_adapter *adapter, u8 *evt_buf, u8 len)

the buffer incoming was dropped at

esp_info("offset_rcv[%d] != exp[%d], drop\n",

If you add the hex dump trace at line,

esp_hex_dump_verbose("rx : ", skb->data, 32);

Worth to check if there is random data or all zeros.

Possible reasons:

  1. SPI interoperability. But we have many customers using the stm32 MPU fine, so I am doubting this less. Maybe refer one of GitHub issue I need to use ESP32-C3 or ESP32 as the wifi module for other Linux hosts #336. It was STM32 MPU used there.
  2. SPI mode mismatch
  3. base SPI Linux driver possibly using incorrect SPI instance
  4. Device tree configured incorrectly for intended SPI instance or intended Chip select
  5. esp32_spi.ko Kernel module is using incorrect SPI instance or incorrect CS instance or both.

The debug way is step-wise but slower. The most easy way and fast way is to attach the logic analyser and send us the capture. With analyser, we would see it clearly.. "दूध का दूध, पानी का पानी" !

@gali-chen
Copy link
Author

insmod esp32_spi.ko
[ 133.471454] esp32_spi: spi_dev_init: Using SPI MODE 2
[ 133.479323] esp32_spi: spi_dev_init: ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [10]
root@myd-yf13x:~# ifconfig
eth0 Link encap:Ethernet HWaddr B6:87:A1:77:17:4C
inet addr:192.168.1.53 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::b487:a1ff:fe77:174c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2329 errors:0 dropped:54 overruns:0 frame:0
TX packets:495 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2582883 (2.4 MiB) TX bytes:51050 (49.8 KiB)
Interrupt:45 Base address:0x8000

eth1 Link encap:Ethernet HWaddr BE:70:FA:58:DA:F2
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:52 Base address:0xe000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:187 errors:0 dropped:0 overruns:0 frame:0
TX packets:187 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14064 (13.7 KiB) TX bytes:14064 (13.7 KiB)

usb0 Link encap:Ethernet HWaddr A2:1C:7C:AC:3D:70
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

I have eliminated the bit offset error, but there is still no wlan node, I need to choose which firmware

@mantriyogesh
Copy link
Collaborator

by running ifconfig, you are not magically going to get wlan0.

Better check the issue and logs for failure and the steps I had mentioned earlier, where to look..

@mantriyogesh
Copy link
Collaborator

Did the dmesg show init event?

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