espressif / esp-hosted

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

Raspberry PI 4B using Esp32_Wroom_32e as WLan card , failed #226

Closed HanJiec closed 10 months ago

HanJiec commented 1 year ago

Pi OS: ubuntu 22 .kernel is 5.15 using SDIO only firmware SDIO pins and reset pin are connected between Pi and Esp32. CMD and DATA03 are pull-up by Rpi gpio setting After modprobe bluetooth and cfg80211 , insmod esp32_sdio.ko resetpin=6. But espsta0 not comes. The Log is as the following: [23133.927844] Enter esp_init [23133.927876] gpio_request(6) ret 0 [23133.927884] gpio_direction_output ret 0 [23134.127982] esp_reset, ESP32: Triggering ESP reset. [23134.335555] esp_sdio: probe of mmc1:0001:1 failed with error -110 [23134.776229] mmc1: card 0001 removed [23136.074618] mmc1: queuing unknown CIS tuple 0x01 [d9 01 ff] (3 bytes) [23136.082639] mmc1: queuing unknown CIS tuple 0x1a [01 01 00 02 07] (5 bytes) [23136.085975] mmc1: queuing unknown CIS tuple 0x1b [c1 41 30 30 ff ff ff ff] (8 bytes) [23136.091816] mmc1: new SDIO card at address 0001 [23136.093535] esp_probe: ESP network device detected [23136.093775] Rx Pre ====== 0 [23136.093785] Rx Pos ====== 0 [23136.093842] Tx Pre ====== 0 [23136.093850] Tx Pos ====== 10 [23136.544299] Received ESP bootup event [23136.544325] EVENT: 3 [23136.544338] ESP chipset detected [esp32] [23136.544349] EVENT: 0 [23136.544359] ESP peripheral capabilities: 0x1d [23136.751267] ESP Bluetooth init [23136.751783] Capabilities: 0x1d. Features supported are: [23136.751800] WLAN on SDIO [23136.751809] BT/BLE [23136.751818] - HCI over SDIO [23136.751826] - BT/BLE dual mode [23136.751836] EVENT: 4 [23136.751846] EVENT: 1 [23136.751856] esp32: process_fw_data ESP chipset's last reset cause: [23136.751866] POWERON_RESET [23136.751875] esp32: ESP Firmware version: 1.0.2 [23141.847330] esp32: Command[1] timed out [23141.847381] esp32: wait_and_decode_cmd_resp(priv, cmd_node) failure, ret: -22 [23141.847442] esp32: add_network_iface() failure, ret: -1 [23141.847462] network iterface init failed ubuntu@ubuntu-desktop:~/esp32/esp-hosted/esp_hosted_ng/host$ sudo ifconfig espsta0 up espsta0: ERROR while getting interface flags: No such device

mantriyogesh commented 1 year ago

Hello @HanJiec

We have tested Raspberry Pi With Raspberry Pi O, as it give full control and exposes /boot/config.txt to alter config. Raspberry Pi OS is also based on debian.

Have you attached the external pull-ups required?

HanJiec commented 1 year ago

Using Rpi internal pulls-ups can works ? I didn't attach extern pull-ups

HanJiec commented 1 year ago

If I add extern pull-ups , set Pi Gpio to no pull-up ?

mantriyogesh commented 1 year ago

We have not tried but if the internal pull ups meet expectation in above link, can be used.

Minimum 10k pulls required. In our pcb for sdio we use 51k.

HanJiec commented 1 year ago

Unfortunatively , I cannot success。 If I add 5 pullups to CMD and DAT0 to DAT3 each,the card cannot attached. the following log stops at "card 0001 removed" [ 665.475170] esp_init [ 665.475406] esp_reset, ESP32: Triggering ESP reset. [ 665.682735] esp_sdio: probe of mmc1:0001:1 failed with error -110 [ 665.711024] mmc1: card 0001 removed Then if I remove the pullup of DAT2 the following log voluntarily out : [ 688.226064] mmc1: queuing unknown CIS tuple 0x01 [d9 01 ff] (3 bytes) [ 688.234102] mmc1: queuing unknown CIS tuple 0x1a [01 01 00 02 07] (5 bytes) [ 688.237483] mmc1: queuing unknown CIS tuple 0x1b [c1 41 30 30 ff ff ff ff] (8 bytes) [ 688.243071] mmc1: new SDIO card at address 0001 [ 688.243522] esp_probe: ESP network device detected [ 688.243778] Rx Pre ====== 0 [ 688.243789] Rx Pos ====== 0 [ 688.243851] Tx Pre ====== 0 [ 688.243860] Tx Pos ====== 10 [ 689.124507] Received ESP bootup event [ 689.124533] EVENT: 3 [ 689.124546] ESP chipset detected [esp32] [ 689.124557] EVENT: 0 [ 689.124566] ESP peripheral capabilities: 0x1d [ 689.330724] ESP Bluetooth init [ 689.331216] Capabilities: 0x1d. Features supported are: [ 689.331232] WLAN on SDIO [ 689.331240] BT/BLE [ 689.331249] - HCI over SDIO [ 689.331258] - BT/BLE dual mode [ 689.331266] EVENT: 4 [ 689.331276] EVENT: 1 [ 689.331286] esp32: process_fw_data ESP chipset's last reset cause: [ 689.331296] RTCWDT_RTC_RESET [ 689.331305] esp32: ESP Firmware version: 1.0.2 [ 694.510805] esp32: Command[1] timed out [ 694.510855] esp32: wait_and_decode_cmd_resp(priv, cmd_node) failure, ret: -22 [ 694.510902] esp32: add_network_iface() failure, ret: -1 [ 694.510920] network iterface init failed Now DAT2 pullup is removed , I rmmod esp32_sdio: ubuntu@ubuntu-desktop: Esp32_20230509$ sudo rmmod esp32_sdio.ko the follwing log out: [ 699.400545] mmc1: card 0001 removed [ 699.451844] mmc1: queuing unknown CIS tuple 0x01 [d9 01 ff] (3 bytes) [ 699.460103] mmc1: queuing unknown CIS tuple 0x1a [01 01 00 02 07] (5 bytes) [ 699.463456] mmc1: queuing unknown CIS tuple 0x1b [c1 41 30 30 ff ff ff ff] (8 bytes) [ 699.468754] mmc1: new SDIO card at address 0001 [ 699.469223] esp_probe: ESP network device detected [ 699.469489] Rx Pre ====== 0 [ 699.469499] Rx Pos ====== 38 [ 699.469696] Tx Pre ====== 0 [ 699.469706] Tx Pos ====== 10 [ 949.059340] esp_exit and at state DAT2 pullup removed and re-insmod esp32_sdio,ko the following log out : [ 986.664244] esp_init [ 986.664482] esp_reset, ESP32: Triggering ESP reset. [ 986.871756] esp_sdio: probe of mmc1:0001:1 failed with error -110 [ 987.220584] mmc1: card 0001 removed [ 988.518921] mmc1: queuing unknown CIS tuple 0x01 [d9 01 ff] (3 bytes) [ 988.526680] mmc1: queuing unknown CIS tuple 0x1a [01 01 00 02 07] (5 bytes) [ 988.530047] mmc1: queuing unknown CIS tuple 0x1b [c1 41 30 30 ff ff ff ff] (8 bytes) [ 988.536342] mmc1: new SDIO card at address 0001 [ 988.536903] esp_probe: ESP network device detected [ 988.537191] Rx Pre ====== 0 [ 988.537202] Rx Pos ====== 0 [ 988.537270] Tx Pre ====== 0 [ 988.537280] Tx Pos ====== 10 [ 989.085598] Received ESP bootup event [ 989.085613] EVENT: 3 [ 989.085620] ESP chipset detected [esp32] [ 989.085626] EVENT: 0 [ 989.085631] ESP peripheral capabilities: 0x1d [ 989.291500] ESP Bluetooth init [ 989.291999] Capabilities: 0x1d. Features supported are: [ 989.292015] WLAN on SDIO [ 989.292024] BT/BLE [ 989.292033] - HCI over SDIO [ 989.292041] - BT/BLE dual mode [ 989.292050] EVENT: 4 [ 989.292061] EVENT: 1 [ 989.292070] esp32: process_fw_data ESP chipset's last reset cause: [ 989.292081] POWERON_RESET [ 989.292091] esp32: ESP Firmware version: 1.0.2 [ 994.547594] esp32: Command[1] timed out [ 994.547640] esp32: wait_and_decode_cmd_resp(priv, cmd_node) failure, ret: -22 [ 994.547682] esp32: add_network_iface() failure, ret: -1 [ 994.547698] network iterface init failed ubuntu@ubuntu-desktop:~/Esp32_20230509$

I use 22K pullup . From log , Rpi have get Firmware version (1.0.2) from esp32 ,so I guess sdio link is built, Capabilities(0x1d) is transfered , is it right ?

HanJiec commented 1 year ago

Any comments are waiting

mantriyogesh commented 1 year ago

Yes the first event is transferred. but transfer ahead not successful.

A. Can you please send your setup image/picture? B. Please send below:

  1. esp log
  2. git commit at both, esp and host
  3. host dmesg

C. Can you please try changing timing at https://github.com/espressif/esp-hosted/blob/3500b252d904b6a5b65ae50eba04f3eac0cf2a33/esp_hosted_ng/esp/esp_driver/network_adapter/main/sdio_slave_api.c#L104

similar to https://github.com/espressif/esp-hosted/blob/3500b252d904b6a5b65ae50eba04f3eac0cf2a33/esp_hosted_fg/esp/esp_driver/network_adapter/main/sdio_slave_api.c#L201

HanJiec commented 1 year ago

A The setup image is: ed73528fa34b05e132c848c295e75e1

mantriyogesh commented 1 year ago

Lines that need pull-up: CMD and DATA (DAT0 - DAT3) i.e. total 5.

What is wire lengths? try make as short as possible, with all in equal size which serve SDIO peripheral. Try to connect all grounds (to reduce the noise and increase signal integrity).

HanJiec commented 1 year ago

The the wire for SDIO ,length is 12cm , are same size. Only 4 pull-ups in image , because all 5 pull-ups are connected , It cannot run , dmesg log stops at "[ 665.475406] esp_reset, ESP32: Triggering ESP reset."

mantriyogesh commented 1 year ago

because all 5 pull-ups are connected , It cannot run

Actually 5 pull-ups is requirement. you can lower length as much as possible

Wire lengths need to be <6cm. SDIO protocol face signal integrity issues if longer wires used. We generally recommend to use PCB board or good wires with much smaller possible length.

With 5 pull-ups, try to change the timing as mentioned above.

HanJiec commented 1 year ago

because all 5 pull-ups are connected , It cannot run

Actually 5 pull-ups is requirement. you can lower length as much as possible

Wire lengths need to be <6cm. SDIO protocol face signal integrity issues if longer wires used. We generally recommend to use PCB board or good wires with much smaller possible length.

With 5 pull-ups, try to change the timing as mentioned above.

I Using prebuilt firmware 1.0.1 (https://github.com/espressif/esp-hosted/releases) , Your suggestion about timing should compile the firmware (stored in Esp32) by myself? now I didn't know how to compile it . Host driver source commit is $ git log -1 commit cf871bbaef0906b34812a1e920c745fe101d855e Merge: 81778f6 1294f8a Author: Yogesh Mantri yogesh.mantri@espressif.com Date: Wed Apr 19 12:55:03 2023 +0800

Merge branch 'bugfix/compatibility_with_higher_kernels' into 'master'

Add support for Linux version 6.1.21

See merge request app-frameworks/esp_hosted!283
mantriyogesh commented 1 year ago

Please use ESP-Hosted master for NG, where you can build and flash esp using ESP-IDF.

By the way, latest release 1.0.2 is not backward compatible with 1.0.1. Better to use latest master for current debugging.

HanJiec commented 1 year ago

Please use ESP-Hosted master for NG, where you can build and flash esp using ESP-IDF.

By the way, latest release 1.0.2 is not backward compatible with 1.0.1. Better to use latest master for current debugging.

I did use 1.0.2 , 1.0.1 is mis-writing: [ 989.292091] esp32: ESP Firmware version: 1.0.2

mantriyogesh commented 1 year ago

Okay. We experience the similar issues if connected with wires. PCB recommended. Anyway, Please reduce the length as explained earlier <6cm. connect as many grounds to reduce the signal integrity issues.

Please get complete logs both sides. Both with and change in timing.

HanJiec commented 1 year ago

esp32 cannot get, the com port always flash ,seems the serial chip reset all along.

HanJiec commented 1 year ago

I want try it using SPI first , Is wire legth critical?

mantriyogesh commented 1 year ago

SPI doesn't face signal integrity issues. can use your wires (~10-12 cm) Use same commit at ESP and Host and follow SPI instructions how to change /boot/config.txt etc. Documentation & code: https://github.com/espressif/esp-hosted/tree/master

HanJiec commented 1 year ago

For SDIO driver , in esp_sdio.c, static const struct sdio_device_id esp_devices[] = { { SDIO_DEVICE(ESP_VENDOR_ID, ESP_DEVICE_ID_1) }, { SDIO_DEVICE(ESP_VENDOR_ID, ESP_DEVICE_ID_2) }, {} }; The above id is read from ESP device by SDIO signal line and compare ?

HanJiec commented 1 year ago

using https://github.com/espressif/esp-hosted/tree/master/esp_hosted_ng/host as host driver code + ESP Firmware version: 1.0.2 as SPI solution , can it works ?
host code ,commit log-l : commit 3500b252d904b6a5b65ae50eba04f3eac0cf2a33 (HEAD -> master, origin/master, origin/HEAD) Merge: d515213 c13c46a Author: Yogesh Mantri yogesh.mantri@espressif.com Date: Thu May 11 16:49:42 2023 +0800

Merge branch 'bugfix/rssi_correction' into 'master'

esp_hosted_ng: Correct signal strength in scan results

See merge request app-frameworks/esp_hosted!287
mantriyogesh commented 1 year ago

It would work. However, for 1.0.2 firmware better ton use source code from same git commit where the binaries were formed.

For 1.0.2, host code https://github.com/espressif/esp-hosted/tree/release/ng-v1.0.2 could be referred.

This is well tested. However, if that doesn't meet your expectations and need something from master, you can use current master which is currently compatible with 1.0.2.

mantriyogesh commented 1 year ago

So, were you able to test https://github.com/espressif/esp-hosted/issues/226#issuecomment-1547423835 With spi?

HanJiec commented 1 year ago

So, were you able to test #226 (comment) With spi?

Yes

HanJiec commented 1 year ago

Via SPI , wifi station espsta0 comes . Using wpa_supplicant configure , Raspberry Pi can link to wifi AP . Ping www.baidu.com successfully. I don't know what code set MISO/MOSI/SCLK pin to 21/19/23 . Would you please give me some guidance?

HanJiec commented 1 year ago

image

mantriyogesh commented 1 year ago

As I understand you are asking about Raspberry Pi Pins. Please check https://pinout.xyz/pinout/spi (Raspberry Pi datasheet will be better reference than this obviously)

So we are using SPI0 and not SPI1. I am not pretty sure if these pins are manually configurable by RaspberryPi, if you intent to change them. May be Raspberry Pi data sheet will help. In case you wish to use SPI1, you might have to change spi_disabler.dts accordingly from repo.

On the contrary, ESP side GPIOs are all configurable, but then they will take standard GPIO_MUX path than IO_MUX path. (check ESP datasheet if need to go in detail) with negligible lower performance but with a needed good flexibility of using any GPIO.

HanJiec commented 1 year ago

I did change spi_disabler.dts . In /boot/firmware/config.txt , I add the following lines: dtparam=spi=on dtoverlay=disable-bt core_freq=250 core_freq_min=250 dtoverlay=spidev_disabler and connect pin as the following graph: image In Raspberry Pi , I only study and try . In real Prj , I need config by myself . Set such kind things in dts ?

mantriyogesh commented 1 year ago

yes, in general, your expected linux should be configured with Device Tree (DT)

  1. Enable your SPI Device instance in DT
  2. Do not load hosted module yet. first test with spidev Tx and Rx is fine
  3. change the expected pins, module loader script etc used for SPI as mentioned in per esp_hosted_fg porting_guide.md
  4. test the GPIOs like resetpin actually restting ESP, Handshake ISR & Data ready ISR
  5. load the module and check if first instance is received.
mantriyogesh commented 1 year ago

You might have to see if there is any timing mismatch in between your new Linux and ESP. In general, people have issues setting up the transport (but it has to be done!). Once the SPI timings are fine (or raw throughput is fine), you can add your own demo app and remove c demo app with your own logic.

HanJiec commented 1 year ago

Sorry , "remove c demo app" , c means what ?

mantriyogesh commented 1 year ago

https://github.com/espressif/esp-hosted/tree/master/esp_hosted_fg/host/linux/host_control/c_support -> test.c

https://github.com/espressif/esp-hosted/blob/master/esp_hosted_fg/docs/common/c_demo.md

Is user space demo application to showcase how the API to be used. your application might re-use this app or you might develop referring to this c demo application.

HanJiec commented 1 year ago

I always using esp_hosted_ng. Using nothing from esp_hosted_fg. The process is as the following : make esp32_spi.ko make dtbo: dtc spidev_disabler.dts -O dtb > spidev_disabler.dtbo cp spidev_disabler.dtbo /boot/firmware/overlays modprobe bluetooth ;modprobe cfg80211;insmod esp32_spi.ko resetpin=6

And then using wpa_supplicant to bring up esta0 and link to wifi AP

mantriyogesh commented 1 year ago

okay

HanJiec commented 1 year ago

Using SDIO, in esp_sdio.c esp_init_interface_layer include sdio_register_driver to register a slave driver (for esp32). Using Spi , in esp_spi.c , no calling spi_register_driver, this is confusing me ? Could you please give me some help ?

mantriyogesh commented 1 year ago

It is a way to use underlying Linux bus driver for your SoC. APIs provided by Linux for different buses could have different way to use. Not necessarily would resemble names.

For sdio, sdio_register_driver used. See: https://elixir.bootlin.com/linux/latest/source/drivers/mmc/core/sdio_bus.c#L271

Whereas, In spi case we use

https://github.com/espressif/esp-hosted/blob/2755b0db0280510757ed9c3e221ed9a1630be981/esp_hosted_ng/host/spi/esp_spi.c#L514

See - https://elixir.bootlin.com/linux/latest/source/drivers/spi/spi.c#L744

HanJiec commented 1 year ago

spi_new_device creates a device (Esp32) . I think there should be a Spi Slave driver to work with this device, in linux interior ? Could you help tell which driver which code create such a driver ?

mantriyogesh commented 1 year ago

Now the question are going out of scope for ESP-Hosted.

Nevermind, I had came across one interesting post at https://www.linkedin.com/posts/activity-7067402712312651776-vi_v . This is general (not related to Esp-Hosted) post and credits to author.

HanJiec commented 1 year ago

In real project PCB , the reset Pin ( Esp32 EN) is connected to other CPU , the pin can be always set to high level, but canot control it to send a reset signal . Host driver cannot excute the else part (or similar code to reset Esp32 ) of esp_reset

static void esp_reset(void)
{
    if (resetpin != HOST_GPIO_PIN_INVALID) {
        /* Check valid GPIO or not */
        if (!gpio_is_valid(resetpin)) {
            printk(KERN_WARNING "%s, ESP32: host resetpin (%d) configured is invalid GPIO\n", __func__, resetpin);
            resetpin = HOST_GPIO_PIN_INVALID;
        } else {
            gpio_request(resetpin, "sysfs");
            /* HOST's resetpin set to OUTPUT, HIGH */
            gpio_direction_output(resetpin, true);
            /* HOST's resetpin set to LOW */
            gpio_set_value(resetpin, 0);
            udelay(200);
            /* HOST's resetpin set to INPUT */
            gpio_direction_input(resetpin);
            printk(KERN_DEBUG "%s, ESP32: Triggering ESP reset.\n", __func__);
        }
    }
}

Can it works ? How to fix this part ? I try " insmod esp32-spi.ko resetpin=-1 " in RaspberryPi 4B , dmesg shows the the driver don't go forward. Please give some advice about this issue.

HanJiec commented 1 year ago

And in PCB, all VDD pin is controled by the same source : VCC_WIFI image Please comment this issue. Thanks.

mantriyogesh commented 1 year ago

Reset pin is mandatory ove GPIO. Reason is that The GPIO output with High->Low->High (with small delays in between transitions) when applied on EN pin of ESP32, will only reset the esp32.

Intention is whenever the kernel module is reloaded, the esp32 should be reset so as the sdio is detected. make sure that you have https://github.com/espressif/esp-hosted/blob/master/esp_hosted_fg/docs/Linux_based_host/SDIO_setup.md#12-raspberry-pi-software-setup done

dtoverlay=sdio,poll_once=off

will allow to poll the esp32 sdio slave (kind of hot pluggable sdio identification on esp reset)

dtoverlay=disable-bt

will stop onboard bt and only use from esp.

mantriyogesh commented 1 year ago

Above is analysis, however below config/logs will help to assess.

ESP -> idf.py flash monitor logs OR minicom over ESP's USB port Host -> Device Tree or /boot/config.txt, dmesg logs

Just to keep common understanding, getting the platform up (with transport) is requirement of ESP-Hosted project. Any issues introduced because of incorrect configuration, we will try to address those with good intention. But doesn't fall into ESP-Hosted issues.

HanJiec commented 1 year ago

By Spi connection , after insmod esp32_spi.ko resetpin=6, the wlan card espsta0 appear. This means the esp32 wifi card is OK. But after rmmod esp32_spi.ko and then insmod again , it fails.

[ 513.354223] spi_exit [ 563.071489] esp_reset, ESP32: Triggering ESP reset. [ 563.278425] sysfs: cannot create duplicate filename '/bus/spi/devices/spi0.0' [ 563.278442] CPU: 3 PID: 3697 Comm: insmod Tainted: G C OE 5.15.0-1032-raspi #35-Ubuntu [ 563.278449] Hardware name: Raspberry Pi 4 Model B Rev 1.2 (DT) [ 563.278453] Call trace: [ 563.278456] dump_backtrace+0x0/0x200 [ 563.278467] show_stack+0x20/0x30 [ 563.278471] dump_stack_lvl+0x8c/0xb8 [ 563.278478] dump_stack+0x18/0x34 [ 563.278482] sysfs_warn_dup+0x6c/0x90 [ 563.278489] sysfs_do_create_link_sd+0xf8/0x100 [ 563.278495] sysfs_create_link+0x28/0x50 [ 563.278500] bus_add_device+0x74/0x150 [ 563.278510] device_add+0x370/0x780 [ 563.278514] spi_add_device+0x80/0x174 [ 563.278519] spi_add_device+0x68/0xa0 [ 563.278523] spi_new_device+0xd0/0x15c [ 563.278527] esp_init_interface_layer+0x164/0x590 [esp32_spi] [ 563.278550] esp_init+0x1a4/0x1000 [esp32_spi] [ 563.278564] do_one_initcall+0x4c/0x2c0 [ 563.278570] do_init_module+0x50/0x260 [ 563.278575] load_module+0xa30/0xbd0 [ 563.278579] __do_sys_finit_module+0xa8/0x114 [ 563.278583] arm64_sys_finit_module+0x28/0x3c [ 563.278587] invoke_syscall+0x50/0x120 [ 563.278594] el0_svc_common.constprop.0+0x6c/0x1a0 [ 563.278599] do_el0_svc+0x30/0xb0 [ 563.278605] el0_svc+0x4c/0x170 [ 563.278609] el0t_64_sync_handler+0xa4/0x12c [ 563.278614] el0t_64_sync+0x1a4/0x1a8 [ 563.278717] spi-bcm2835 fe204000.spi: can't add spi0.0, status -17 [ 563.278737] Failed to add new SPI device [ 563.278744] spi_exit [ 563.694146] spi_exit:spi_context.esp_spi_dev=0 [ 563.694165] Failed Init SPI device

rmmod don't remove /sys/bus/spi/devices/spi0.0 Plese help me on this issue.

mantriyogesh commented 1 year ago

Hello @HanJiec

https://github.com/espressif/esp-hosted/blob/8dc9280339e1539ba4a5bae65a77b3fe99c9ce14/esp_hosted_ng/host/spi/esp_spi.c#L614 'Failed Init SPI device' means your spi instance is not claimable by the spi driver.

After unloading the driver, can you please check:

  1. ls /dev/spidev*
  2. lsmod
  3. ls /bus/spi/devices/spi*

Also, can you please state how are you loading or unloading spidev?

HanJiec commented 1 year ago

Please see my comments:

https://github.com/espressif/esp-hosted/blob/8dc9280339e1539ba4a5bae65a77b3fe99c9ce14/esp_hosted_ng/host/spi/esp_spi.c#L614

'Failed Init SPI device' means your spi instance is not claimable by the spi driver. After unloading the driver, can you please check:

  1. ls /dev/spidev*
  2. lsmod
  3. ls /bus/spi/devices/spi*

ubuntu@ubuntu-desktop: ~ / Esp32_20230516/host$ modprobe bluetooth ubuntu@ubuntu-desktop: ~ / Esp32_20230516/host$ modprobe cfg80211 ubuntu@ubuntu-desktop: ~ / Esp32_20230516/host$ sudo insmod esp32_spi.ko resetpin=6 [sudo] password for ubuntu: ubuntu@ubuntu-desktop: ~ /Esp32_20230516/host$ sudo rmmod esp32_spi ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ ls /dev/spidev /dev/spidev0.1 ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ lsmod Module Size Used by bnep 32768 2 binfmt_misc 24576 1 btsdio 20480 0 bluetooth 712704 8 btsdio,bnep vc4 339968 10 ecdh_generic 16384 1 bluetooth ecc 36864 1 ecdh_generic snd_soc_hdmi_codec 24576 2 snd_soc_core 311296 2 vc4,snd_soc_hdmi_codec brcmfmac 417792 0 bcm2835_codec 53248 0 snd_compress 28672 1 snd_soc_core ac97_bus 16384 1 snd_soc_core snd_bcm2835 36864 1 bcm2835_v4l2 49152 0 bcm2835_isp 36864 0 brcmutil 28672 1 brcmfmac v4l2_mem2mem 45056 1 bcm2835_codec bcm2835_mmal_vchiq 40960 3 bcm2835_codec,bcm2835_v4l2,bcm2835_isp videobuf2_vmalloc 20480 1 bcm2835_v4l2 videobuf2_dma_contig 24576 2 bcm2835_codec,bcm2835_isp snd_pcm_dmaengine 20480 1 snd_soc_core videobuf2_memops 20480 2 videobuf2_vmalloc,videobuf2_dma_contig cfg80211 966656 1 brcmfmac videobuf2_v4l2 32768 4 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,bcm2835_isp snd_seq_midi 20480 0 snd_seq_midi_event 16384 1 snd_seq_midi videobuf2_common 81920 8 bcm2835_codec,videobuf2_vmalloc,videobuf2_dma_contig,videobuf2_v4l2,bcm2835_v4l2,v4l2_mem2mem,videobuf2_memops,bcm2835_isp snd_pcm 163840 5 snd_bcm2835,snd_soc_hdmi_codec,snd_compress,snd_soc_core,snd_pcm_dmaengine v3d 94208 6 snd_rawmidi 49152 1 snd_seq_midi drm_kms_helper 344064 2 vc4 snd_seq 90112 2 snd_seq_midi,snd_seq_midi_event videodev 282624 6 bcm2835_codec,videobuf2_v4l2,bcm2835_v4l2,videobuf2_common,v4l2_mem2mem,bcm2835_isp crct10dif_ce 20480 1 gpu_sched 49152 1 v3d raspberrypi_hwmon 16384 0 cec 81920 2 drm_kms_helper,vc4 snd_seq_device 20480 3 snd_seq,snd_seq_midi,snd_rawmidi mc 73728 6 videodev,bcm2835_codec,videobuf2_v4l2,videobuf2_common,v4l2_mem2mem,bcm2835_isp fb_sys_fops 20480 1 drm_kms_helper snd_timer 45056 2 snd_seq,snd_pcm syscopyarea 16384 1 drm_kms_helper vc_sm_cma 40960 2 bcm2835_mmal_vchiq,bcm2835_isp sysfillrect 20480 1 drm_kms_helper snd 126976 11 snd_seq,snd_seq_device,snd_bcm2835,snd_soc_hdmi_codec,snd_timer,snd_compress,snd_soc_core,snd_pcm,snd_rawmidi sysimgblt 16384 1 drm_kms_helper bcm2835_gpiomem 16384 0 rpivid_mem 16384 0 uio_pdrv_genirq 20480 0 uio 24576 1 uio_pdrv_genirq nvmem_rmem 16384 0 sch_fq_codel 20480 7 ramoops 32768 0 drm 647168 15 gpu_sched,drm_kms_helper,v3d,vc4 reed_solomon 28672 1 ramoops pstore_blk 16384 0 pstore_zone 28672 1 pstore_blk ip_tables 36864 0 x_tables 57344 1 ip_tables autofs4 49152 2 btrfs 1609728 0 blake2b_generic 24576 0 xor 20480 1 btrfs xor_neon 16384 1 xor zstd_compress 229376 1 btrfs raid6_pq 114688 1 btrfs libcrc32c 16384 1 btrfs spidev 24576 0 dwc2 311296 0 i2c_brcmstb 20480 0 roles 20480 1 dwc2 i2c_bcm2835 20480 0 udc_core 73728 1 dwc2 spi_bcm2835 28672 0 xhci_pci 24576 0 xhci_pci_renesas 24576 1 xhci_pci phy_generic 20480 1 ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ ls /bus/spi/devices/spi ls: cannot access '/bus/spi/devices/spi': No such file or directory ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ ls /sys/bus/spi/devices/spi /sys/bus/spi/devices/spi0.0

/sys/bus/spi/devices/spi0.1: driver driver_override modalias of_node power spidev statistics subsystem uevent ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ ls /sys/bus/spi/devices/spi0.0 /sys/bus/spi/devices/spi0.0 ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ ls -l /sys/bus/spi/devices/spi0.0 lrwxrwxrwx 1 root root 0 6月 21 09:37 /sys/bus/spi/devices/spi0.0 -> ../../../devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.0 ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ cd /sys/bus/spi/devices/spi0.0 -bash: cd: /sys/bus/spi/devices/spi0.0: No such file or directory ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ cd /sys/bus/spi/devices/spi0.1 ubuntu@ubuntu-desktop:/sys/bus/spi/devices/spi0.1$ ls driver driver_override modalias of_node power spidev statistics subsystem uevent ubuntu@ubuntu-desktop:/sys/bus/spi/devices/spi0.1$

Also, can you please state how are you loading or unloading spidev? ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ cat /boot/firmware/config.txt | grep spidev dtoverlay=spidev_disabler ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ cat spidev_disabler.dts /dts-v1/; /plugin/;

/ { compatible = "brcm,bcm2708"; fragment@0 { target = <&spidev0>; overlay { status = "disabled"; }; }; }; ubuntu@ubuntu-desktop:~ /Esp32_20230516/host$ ls /boot/firmware/overlays | grep spidev
spidev_disabler.dtbo

HanJiec commented 1 year ago

Hi, mantriyogesh , Above answer is enough for positioning my question ?

mantriyogesh commented 1 year ago

Hello @HanJiec ,

The answer is fine. We will need to try at our place ( till now we didn't face such issue)

Can you please send the diff from the repo, be it code or rpi_init.sh script etc.?

HanJiec commented 1 year ago

I didn't use rpi_init.sh. I modified Makefile . In esp_hosted_ng/host dir , using make to produce ko. And load module according the bottom lines of rpi_init.sh: sudo modprobe bluetooth; sudo modprobe cfg80211; sudo insmod ./esp32_sdio.ko resetpin=6; The following is Makefile modified:

#2023/3/31 Created by HanJc for using in prj X94M 

MODULE_NAME=esp32_spi
obj-m := $(MODULE_NAME).o
$(MODULE_NAME)-y := spi/esp_spi.o 
$(MODULE_NAME)-y += esp_bt.o main.o esp_cmd.o esp_wpa_utils.o esp_cfg80211.o esp_stats.o 

KERNELDIR ?= /lib/modules/$(shell uname -r)/build

EXTRA_CFLAGS += -I$(shell pwd)/include -I$(shell pwd)/spi

all default: modules
install: modules_install

modules modules_install help clean:
    $(MAKE) -C $(KERNELDIR) M=$(shell pwd) $@   

Please find diff in the following:

diff --git a/esp_hosted_ng/host/Makefile b/esp_hosted_ng/host/Makefile
index 4bf3da6..4d8c58e 100644
--- a/esp_hosted_ng/host/Makefile
+++ b/esp_hosted_ng/host/Makefile
@@ -1,53 +1,19 @@
-CONFIG_TEST_RAW_TP := n
-CONFIG_ENABLE_MONITOR_PROCESS = n
+#2023/3/31 Created by HanJc for using in prj X94M 

-# Toolchain Path
-CROSS_COMPILE := /usr/bin/arm-linux-gnueabihf-
-# Linux Kernel header
-KERNEL := /lib/modules/$(shell uname -r)/build
-# Architecture
-ARCH := arm
-
-#Default interface is sdio
-MODULE_NAME=esp32_sdio
-
-#Targets passed overrrides default value
-ifeq ($(target), sdio)
-   MODULE_NAME=esp32_sdio
-endif
-
-ifeq ($(target), spi)
-   MODULE_NAME=esp32_spi
-endif
-
-ifeq ($(CONFIG_ENABLE_MONITOR_PROCESS), y)
-   EXTRA_CFLAGS += -DCONFIG_ENABLE_MONITOR_PROCESS
-endif
-
-ifeq ($(CONFIG_TEST_RAW_TP), y)
-   EXTRA_CFLAGS += -DCONFIG_TEST_RAW_TP
-endif
-
-EXTRA_CFLAGS += -I$(PWD)/include -I$(PWD)
+MODULE_NAME=esp32_spi
+obj-m := $(MODULE_NAME).o
+$(MODULE_NAME)-y := spi/esp_spi.o 
+$(MODULE_NAME)-y += esp_bt.o main.o esp_cmd.o esp_wpa_utils.o esp_cfg80211.o esp_stats.o 

-ifeq ($(MODULE_NAME), esp32_sdio)
-   EXTRA_CFLAGS += -I$(PWD)/sdio
-   module_objects += sdio/esp_sdio.o sdio/esp_sdio_api.o
-endif
+KERNELDIR ?= /lib/modules/$(shell uname -r)/build

-ifeq ($(MODULE_NAME), esp32_spi)
-   EXTRA_CFLAGS += -I$(PWD)/spi
-   module_objects += spi/esp_spi.o
-endif
+EXTRA_CFLAGS += -I$(shell pwd)/include -I$(shell pwd)/spi

-PWD := $(shell pwd)

-obj-m := $(MODULE_NAME).o
-$(MODULE_NAME)-y := esp_bt.o main.o esp_cmd.o esp_wpa_utils.o esp_cfg80211.o esp_stats.o $(module_objects)
+all default: modules
+install: modules_install

-all: clean
-   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL) M=$(PWD) modules
+modules modules_install help clean:
+   $(MAKE) -C $(KERNELDIR) M=$(shell pwd) $@   
+   

-clean:
-   rm -rf *.o sdio/*.o spi/*.o *.ko
-   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL) M=$(PWD) clean
diff --git a/esp_hosted_ng/host/Makefile.original b/esp_hosted_ng/host/Makefile.original
new file mode 100644
index 0000000..4bf3da6
--- /dev/null
+++ b/esp_hosted_ng/host/Makefile.original
@@ -0,0 +1,53 @@
+CONFIG_TEST_RAW_TP := n
+CONFIG_ENABLE_MONITOR_PROCESS = n
+
+# Toolchain Path
+CROSS_COMPILE := /usr/bin/arm-linux-gnueabihf-
+# Linux Kernel header
+KERNEL := /lib/modules/$(shell uname -r)/build
+# Architecture
+ARCH := arm
+
+#Default interface is sdio
+MODULE_NAME=esp32_sdio
+
+#Targets passed overrrides default value
+ifeq ($(target), sdio)
+   MODULE_NAME=esp32_sdio
+endif
+
+ifeq ($(target), spi)
+   MODULE_NAME=esp32_spi
+endif
+
+ifeq ($(CONFIG_ENABLE_MONITOR_PROCESS), y)
+   EXTRA_CFLAGS += -DCONFIG_ENABLE_MONITOR_PROCESS
+endif
+
+ifeq ($(CONFIG_TEST_RAW_TP), y)
+   EXTRA_CFLAGS += -DCONFIG_TEST_RAW_TP
+endif
+
+EXTRA_CFLAGS += -I$(PWD)/include -I$(PWD)
+
+ifeq ($(MODULE_NAME), esp32_sdio)
+   EXTRA_CFLAGS += -I$(PWD)/sdio
+   module_objects += sdio/esp_sdio.o sdio/esp_sdio_api.o
+endif
+
+ifeq ($(MODULE_NAME), esp32_spi)
+   EXTRA_CFLAGS += -I$(PWD)/spi
+   module_objects += spi/esp_spi.o
+endif
+
+PWD := $(shell pwd)
+
+obj-m := $(MODULE_NAME).o
+$(MODULE_NAME)-y := esp_bt.o main.o esp_cmd.o esp_wpa_utils.o esp_cfg80211.o esp_stats.o $(module_objects)
+
+all: clean
+   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL) M=$(PWD) modules
+
+clean:
+   rm -rf *.o sdio/*.o spi/*.o *.ko
+   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL) M=$(PWD) clean
diff --git a/esp_hosted_ng/host/esp_bt.c b/esp_hosted_ng/host/esp_bt.c
index 5308821..a043bbb 100644
--- a/esp_hosted_ng/host/esp_bt.c
+++ b/esp_hosted_ng/host/esp_bt.c
@@ -16,9 +16,9 @@
  * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
  * this warranty disclaimer.
  */
-#include "esp_bt_api.h"
-#include "esp_api.h"
-#include "esp_kernel_port.h"
+#include "include/esp_bt_api.h"
+#include "include/esp_api.h"
+#include "include/esp_kernel_port.h"

 #define INVALID_HDEV_BUS (0xff)

diff --git a/esp_hosted_ng/host/esp_cfg80211.c b/esp_hosted_ng/host/esp_cfg80211.c
index 6197933..ef810f0 100644
--- a/esp_hosted_ng/host/esp_cfg80211.c
+++ b/esp_hosted_ng/host/esp_cfg80211.c
@@ -17,11 +17,11 @@
  * this warranty disclaimer.
  */

-#include "esp.h"
-#include "esp_api.h"
-#include "esp_cfg80211.h"
-#include "esp_cmd.h"
-#include "esp_kernel_port.h"
+#include "include/esp.h"
+#include "include/esp_api.h"
+#include "include/esp_cfg80211.h"
+#include "include/esp_cmd.h"
+#include "include/esp_kernel_port.h"

 /**
   * @brief WiFi PHY rate encodings
diff --git a/esp_hosted_ng/host/esp_cmd.c b/esp_hosted_ng/host/esp_cmd.c
index 2ef65b0..ce463f6 100644
--- a/esp_hosted_ng/host/esp_cmd.c
+++ b/esp_hosted_ng/host/esp_cmd.c
@@ -17,12 +17,12 @@
  * this warranty disclaimer.
  */

-#include "esp_cmd.h"
-#include "esp_api.h"
-#include "esp_wpa_utils.h"
-#include "esp.h"
-#include "esp_cfg80211.h"
-#include "esp_kernel_port.h"
+#include "include/esp_cmd.h"
+#include "include/esp_api.h"
+#include "include/esp_wpa_utils.h"
+#include "include/esp.h"
+#include "include/esp_cfg80211.h"
+#include "include/esp_kernel_port.h"

 #define PRINT_HEXDUMP(STR,ARG, ARG_LEN,level) \
    print_hex_dump(KERN_INFO, STR, DUMP_PREFIX_ADDRESS, 16, 1, ARG, ARG_LEN, 1);
diff --git a/esp_hosted_ng/host/esp_stats.c b/esp_hosted_ng/host/esp_stats.c
index d50d595..91ea930 100644
--- a/esp_hosted_ng/host/esp_stats.c
+++ b/esp_hosted_ng/host/esp_stats.c
@@ -18,7 +18,7 @@
  */

-#include "esp_stats.h"
+#include "include/esp_stats.h"

 #if TEST_RAW_TP

diff --git a/esp_hosted_ng/host/esp_wpa_utils.c b/esp_hosted_ng/host/esp_wpa_utils.c
index dcbc69e..4faa288 100644
--- a/esp_hosted_ng/host/esp_wpa_utils.c
+++ b/esp_hosted_ng/host/esp_wpa_utils.c
@@ -17,7 +17,7 @@
  * this warranty disclaimer.
  */

-#include "esp_wpa_utils.h"
+#include "include/esp_wpa_utils.h"

 int wpa_cipher_to_alg(int cipher)
diff --git a/esp_hosted_ng/host/include/esp_kernel_port.h b/esp_hosted_ng/host/include/esp_kernel_port.h
index 42d730a..32c8442 100644
--- a/esp_hosted_ng/host/include/esp_kernel_port.h
+++ b/esp_hosted_ng/host/include/esp_kernel_port.h
@@ -209,7 +209,7 @@ void CFG80211_RX_ASSOC_RESP(struct net_device *dev,

    cfg80211_rx_assoc_resp(dev, &resp);
 #else
-   cfg80211_rx_assoc_resp(dev, bss, buf, len, uapsd_queues, req_ies, req_ies_len)
+   cfg80211_rx_assoc_resp(dev, bss, buf, len, uapsd_queues, req_ies,req_ies_len);
 #endif
 }

diff --git a/esp_hosted_ng/host/main.c b/esp_hosted_ng/host/main.c
index c5cb875..a1e1976 100644
--- a/esp_hosted_ng/host/main.c
+++ b/esp_hosted_ng/host/main.c
@@ -23,15 +23,15 @@
 #include <linux/gpio.h>
 #include <linux/igmp.h>

-#include "esp.h"
-#include "esp_if.h"
-#include "esp_bt_api.h"
-#include "esp_api.h"
-#include "esp_cmd.h"
-#include "esp_kernel_port.h"
-
-#include "esp_cfg80211.h"
-#include "esp_stats.h"
+#include "include/esp.h"
+#include "include/esp_if.h"
+#include "include/esp_bt_api.h"
+#include "include/esp_api.h"
+#include "include/esp_cmd.h"
+#include "include/esp_kernel_port.h"
+
+#include "include/esp_cfg80211.h"
+#include "include/esp_stats.h"

 #define HOST_GPIO_PIN_INVALID -1
 static int resetpin = HOST_GPIO_PIN_INVALID;
diff --git a/esp_hosted_ng/host/spi/esp_spi.c b/esp_hosted_ng/host/spi/esp_spi.c
index dbf34ae..9048999 100644
--- a/esp_hosted_ng/host/spi/esp_spi.c
+++ b/esp_hosted_ng/host/spi/esp_spi.c
@@ -14,17 +14,19 @@
  * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
  * this warranty disclaimer.
  */
+#define DEBUG_HAN
+
 #include <linux/device.h>
 #include <linux/spi/spi.h>
 #include <linux/gpio.h>
 #include <linux/mutex.h>
 #include <linux/delay.h>
 #include "esp_spi.h"
-#include "esp_if.h"
-#include "esp_api.h"
-#include "esp_bt_api.h"
-#include "esp_kernel_port.h"
-#include "esp_stats.h"
+#include "../include/esp_if.h"
+#include "../include/esp_api.h"
+#include "../include/esp_bt_api.h"
+#include "../include/esp_kernel_port.h"
+#include "../include/esp_stats.h"

 #define SPI_INITIAL_CLK_MHZ     10
 #define NUMBER_1M               1000000
@@ -66,6 +68,7 @@ static void close_data_path(void)

 static irqreturn_t spi_data_ready_interrupt_handler(int irq, void * dev)
 {
+    printk("%s", __func__ ) ;
    /* ESP peripheral has queued buffer for transmission */
    if (spi_context.spi_workqueue)
        queue_work(spi_context.spi_workqueue, &spi_context.spi_work);
@@ -75,6 +78,7 @@ static irqreturn_t spi_data_ready_interrupt_handler(int irq, void * dev)

 static irqreturn_t spi_interrupt_handler(int irq, void * dev)
 {
+    printk("%s", __func__ ) ;
    /* ESP peripheral is ready for next SPI transaction */
    if (spi_context.spi_workqueue)
        queue_work(spi_context.spi_workqueue, &spi_context.spi_work);
@@ -373,6 +377,7 @@ static void esp_spi_work(struct work_struct *work)

    trans_ready = gpio_get_value(HANDSHAKE_PIN);
    rx_pending = gpio_get_value(SPI_DATA_READY_PIN);
+    printk("%s:trans_ready=%d rx_pending=%d" , __func__ ,trans_ready,rx_pending ) ;

    if (trans_ready) {
        if (data_path) {
@@ -521,13 +526,39 @@ static int spi_dev_init(int spi_clk_mhz)
    }

    spi_context.esp_spi_dev = spi_new_device(master, &esp_board);
+    printk("%s:After spi_new_device , It should call spi_setup=>spi->controller->setup",__func__ ) ;

    if (!spi_context.esp_spi_dev) {
        printk(KERN_ERR "Failed to add new SPI device\n");
        return -ENODEV;
-   }
-
+   }else {
+        printk( "%s:spi_context.esp_spi_dev->dev.init_name=%x", __func__, 
+        (unsigned int)spi_context.esp_spi_dev->dev.init_name ) ;
+        if( !spi_context.esp_spi_dev->dev.init_name ) {
+            spi_context.esp_spi_dev->dev.init_name=kzalloc( 12 , GFP_KERNEL ) ;
+            strcpy( (char*)spi_context.esp_spi_dev->dev.init_name , "esp32spidev" ) ; 
+        }
+        printk("%s" , spi_context.esp_spi_dev->dev.init_name ) ;
+        
+    }
+#ifdef DEBUG_HAN
+    {
+        struct spi_device* sdev = spi_context.esp_spi_dev ;
+        printk("master:%x ", (unsigned long)sdev->master) ;
+        printk("controller:%x", (unsigned long)sdev->controller) ;
+        printk("esp_spi_dev dev driver  :%x", sdev->dev.driver) ;
+        if( sdev->master && sdev->master->dev.driver && sdev->master->dev.driver->name )
+            printk("master:%x , esp_spi_dev master driver name :%s", (unsigned long)sdev->master, sdev->master->dev.driver->name) ;
+        if( sdev->controller && sdev->controller->dev.driver && sdev->controller->dev.driver->name )
+            printk("controller:%x , esp_spi_dev controller driver name:%s", (unsigned long)sdev->controller, sdev->controller->dev.driver->name) ;
+        if( sdev->dev.driver && sdev->dev.driver->name )
+            printk("esp_spi_dev dev driver name :%s", sdev->dev.driver->name) ;
+    }
+#endif 
+
+    printk("%s:Direct call spi_setup=>spi->controller->setup",__func__ ); ;
    status = spi_setup(spi_context.esp_spi_dev);
+    printk("%s:after call spi_setup",__func__ );

    if (status) {
        printk (KERN_ERR "Failed to setup new SPI device");
@@ -593,6 +624,16 @@ static int spi_dev_init(int spi_clk_mhz)

    open_data_path();

+#ifdef DEBUG_HAN
+    {
+        struct spi_device* sdev = spi_context.esp_spi_dev ;
+        printk("2 spi_context.esp_spi_dev:%x ", (unsigned long)sdev) ;
+        printk("2 master:%x ", (unsigned long)sdev->master) ;
+        printk("2 controller:%x", (unsigned long)sdev->controller) ;
+        printk("2  esp_spi_dev dev driver  :%x", sdev->dev.driver) ;
+    }
+#endif 
+
    return 0;
 }

@@ -640,6 +681,7 @@ static void spi_exit(void)
 {
    uint8_t prio_q_idx = 0;

+    printk("%s", __func__ ) ;
    disable_irq(SPI_IRQ);
    disable_irq(SPI_DATA_READY_IRQ);
    close_data_path();
@@ -669,6 +711,7 @@ static void spi_exit(void)
        gpio_free(SPI_DATA_READY_PIN);
    }

+    printk("%s:spi_context.esp_spi_dev=%x", __func__ , spi_context.esp_spi_dev  ) ;
    if (spi_context.esp_spi_dev)
        spi_unregister_device(spi_context.esp_spi_dev);

diff --git a/esp_hosted_ng/host/spi/esp_spi.h b/esp_hosted_ng/host/spi/esp_spi.h
index 577c562..db931f3 100644
--- a/esp_hosted_ng/host/spi/esp_spi.h
+++ b/esp_hosted_ng/host/spi/esp_spi.h
@@ -17,7 +17,7 @@
 #ifndef _ESP_SPI_H_
 #define _ESP_SPI_H_

-#include "esp.h"
+#include "../include/esp.h"

 #define HANDSHAKE_PIN           22
 #define SPI_IRQ                 gpio_to_irq(HANDSHAKE_PIN)
HanJiec commented 1 year ago

Hi mantriyogesh ,

I sloved it, It 's my fault.

mantriyogesh commented 1 year ago

Any resolution you identified might potentially help someone else visiting this page (if you could share). Can we please close the issue?

HanJiec commented 1 year ago

In order to study , I kmalloc some memory for spi_context.esp_spi_dev->dev.init_name, and strcpy "esp32spidev" to this item in esp_spi.c . It fails the rmmod esp32_spi.ko. Failing rmmod is a sub-issue. For my project , I need your more support and want continue this issue.