espressif / esp-hosted

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

I need to use ESP32-C3 or ESP32 as the wifi module for other Linux hosts #336

Closed qinyunliu closed 3 months ago

qinyunliu commented 9 months ago

I need to use ESP32-C3 or ESP32 as the wifi module for other Linux hosts!

Use method on other ARM development board ![image](https://github.com/espressif/esp-hosted/assets/155231213/49e764a8-dccd-4d57-852d-dd3ceace6934) ![image](https://github.com/espressif/esp-hosted/assets/155231213/8caea6c8-38bb-43be-bc37-c6fb300b2a5a)
mantriyogesh commented 9 months ago

You can choose one from FG or NG, whichever suits your development workflow. Please let us know if you have followed the complete documentation.

qinyunliu commented 9 months ago

I have chosen the NG solution,I modified Makefiel to generate esp32_spi.ko, insmod esp32_spi.ko Only one line of information is displayed "ep32_spi:spi__dev_init: ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI clock [10]" I don't know if this is loading successfully,"ifconfig -a " The port number is not shown wpa_supplicant and bluez Can't call it

kapilkedawat commented 9 months ago

Hi @qinyunliu Please recheck the connections and provide full host and slave logs.

qinyunliu commented 9 months ago

[root@buildroot]:/home/drivers$:insmod esp32_spi.ko esp32_spi: loading out-of-tree module taints kernel. Division by zero in kernel. CPU: 0 PID: 1200 Comm: insmod Tainted: G O 4.4.289 #4 Hardware name: NUC980 Backtrace: [] (dump_backtrace) from [] (show_stack+0x18/0x1c) r6:00000000 r5:c3b5a400 r4:c3ace210 r3:00000000 [] (show_stack) from [] (dump_stack+0x20/0x28) [] (dump_stack) from [] (div0+0x18/0x20) [] (div0) from [] (Ldiv0+0x8/0x10) [] (nuc980_qspi0_update_state) from [] (nuc980_qspi0_setup+0x20/0xfc) r6:00000000 r5:c3ace210 r4:c3b5a400 r3:c3ace000 [] (nuc980_qspi0_setup) from [] (spi_setup+0xdc/0x160) r5:00000000 r4:c3b5a400 [] (spi_setup) from [] (spi_add_device+0x7c/0x134) r6:00000000 r5:c3ace000 r4:c3b5a400 r3:00000000 [] (spi_add_device) from [] (spi_new_device+0x7c/0xb8) r7:bf00824c r6:00000000 r5:c385bd50 r4:c3b5a400 [] (spi_new_device) from [] (esp_init_interface_layer+0x15c/0x47c [esp32_spi]) r6:00000000 r5:bf00824c r4:00000000 r3:00000009 [] (esp_init_interface_layer [esp32_spi]) from [] (esp_init+0x198/0x1ec [esp32_spi]) r7:ffffffe0 r6:bf008198 r5:00000000 r4:bf008160 [] (esp_init [esp32_spi]) from [] (do_one_initcall+0x88/0x1f0) r8:bf00b000 r7:c3ba7064 r6:c3ba3f00 r5:c05f7b80 r4:c05f7b80 [] (do_one_initcall) from [] (do_init_module+0x60/0x1c0) r10:c3ba7048 r9:bf008000 r8:00000001 r7:c3ba7064 r6:c3ba36a0 r5:00000001 r4:bf008000 [] (do_init_module) from [] (load_module+0x1a24/0x1d48) r6:c3ba7040 r5:00000001 r4:c385bf3c [] (load_module) from [] (SyS_init_module+0xd4/0x130) r10:00000000 r9:004bb008 r8:c385a000 r7:c4924204 r6:00000000 r5:b6eb420c r4:0000e204 [] (SyS_init_module) from [] (ret_fast_syscall+0x0/0x3c) r9:c385a000 r8:c000fec8 r7:00000080 r6:004bb008 r5:b6ea6008 r4:beef6f23 esp32_spi:spi_dev_init: ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [0]

qinyunliu commented 9 months ago

sorry,Apart from this log, there is no other information

mantriyogesh commented 9 months ago
  1. Have you checked the porting guide ?
  2. setup picture?
  3. ESP side logs?
  4. From log,
    esp32_spi:spi_dev_init: ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [0]

    your current clock doesn't seem to be in effect. Please follow porting guide, to first get your SPI and GPIOs verified to be working.

PercyHide commented 6 months ago

@mantriyogesh hi, i used esp32 as the wifi module for Linux, i choice ng spi driver,but ,i get this log for linux, "add_network_iface() failure",can you hele me or give me some advice for this question, Looking forward to your reply。 ![Uploading 微信截图_20240428112009.png…]() root@buildroot:~$insmod esp32_spi.ko esp32_spi: loading out-of-tree module taints kernel. ESP32 peripheral is registered to SPI bus [1],chip select [0], SPI Clock [10] ESP32 init end

*****spi_interrupt_handler** HANDSHAKE_PIN=1 SPI_DATA_READY_PIN=1

Received ESP bootup event EVENT: 3 EVENT: 2 EVENT: 0 EVENT: 1 esp32: process_fw_data ESP chipset's last reset cause: POWERON_RESET esp32: ESP Firmware version: 1.0.3 ESP chipset detected [esp32] *add_network_iface** *esp_cfg80211_add_iface** *****cmd_init_interface** HANDSHAKE_PIN=1 SPI_DATA_READY_PIN=0 esp32: Command[1] timed out esp32: wait_and_decode_cmd_resp(priv, cmd_node) failure, ret: -22 esp32: add_network_iface() failure, ret: -1 network iterface init failed ESP peripheral capabilities: 0xf8 ESP Bluetooth init esp_init_bt: Kernel version does not support HCI over SPI BUS Capabilities: 0xf8. Features supported are:

root@buildroot:~$ifconfig -a

mantriyogesh commented 6 months ago

Could you please attach full ESP log and host log from bootup (textual logs)? We could not retrieve the image you attached in https://github.com/espressif/esp-hosted/issues/336#issuecomment-2081308126. Possible to re-attach?

mantriyogesh commented 6 months ago

From your current set of logs looks, your SPI pins are configured fine and bootup event is received, but failure reason in ESP log might be the key.

Also could you please first help to assess your transport (Tx and Rx both directions)? For this, you can run raw transport test

It is worthwhile to cross-check your porting against Porting guide for any frequently faced issues.

PercyHide commented 6 months ago

From your current set of logs looks, your SPI pins are configured fine and bootup event is received, but failure reason in ESP log might be the key.

Also could you please first help to assess your transport (Tx and Rx both directions)? For this, you can run raw transport test

It is worthwhile to cross-check your porting against Porting guide for any frequently faced issues.

Thank you very much for your reply. Through log analysis, it was found that my Linux host did not receive an interrupt, but there was an interrupt generated through the oscilloscope. My Linux host did not enter the interrupt function.

mantriyogesh commented 6 months ago

Hello @kangpei1 ,

Anything to be done from our side further? If the driver works for you, please feel free to close this issue.

PercyHide commented 6 months ago

Hello @kangpei1 ,

Anything to be done from our side further? If the driver works for you, please feel free to close this issue.

thank you for you help,the drivers works

PercyHide commented 6 months ago

Hello @kangpei1 ,

Anything to be done from our side further? If the driver works for you, please feel free to close this issue. I cant close this issue,Not created by me

mantriyogesh commented 6 months ago

Oh! I got confused on this. @qinyunliu , Are you still blocked on this ?

QuiGonRazor commented 3 months ago

Hello, I'm experiencing the same issue.

I'm trying to use the ESP32C3 as wifi/bt module. I've downloaded the last commit and compiled both kernel driver and ESP's firmware.

I've added a lot of comments to understand what's happening and it seems it is able to receive only bootup events. After it receives only zeroes

I've added the log as file

esp.log fw.log

mantriyogesh commented 3 months ago
  1. Can you please let us know the host SoC, CPU, and kernel version details?
  2. Does it work if you add https://github.com/espressif/esp-hosted/blob/da21e362d5bced2e8ed9bc4eadb9cffb1d6c1be1/esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c#L619 and associate code from FG?
QuiGonRazor commented 3 months ago

Hello, below the details

Architecture: armv7l Byte Order: Little Endian CPU(s): 1 On-line CPU(s) list: 0 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 1 Vendor ID: ARM Model: 5 Model name: Cortex-A7 Stepping: r0p5 CPU max MHz: 650.0000 CPU min MHz: 650.0000 BogoMIPS: 48.00 Flags: half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm

Linux stm32mp151a-mx 5.10.10 #1 SMP PREEMPT Wed Mar 10 11:42:35 UTC 2021 armv7l armv7l armv7l GNU/Linux

I'm actually trying the versione hosted_ng

QuiGonRazor commented 3 months ago

@mantriyogesh Which code should I try? Are you suggesting to copy FG code into NG driver?

mantriyogesh commented 3 months ago
  1. Can you also send us the picture, how you connect the C3 with STM32MP ?
  2. Before doing (2) above, can you please comment: https://github.com/espressif/esp-hosted/blob/da21e362d5bced2e8ed9bc4eadb9cffb1d6c1be1/esp_hosted_ng/host/main.c#L311 this should be simple to try.

Regarding, your latest comment, I meant, try (4) first. It is safe to keep (4) in the code, unless you get stable solution. Details of (2): There are some Linux hosts, with which we observe race condition on SPI. Host runs back to back SPI (wrongly), because they observe the Handshake was high from earlier transaction, just due to some timing issue (only happens for some hosts). So, you can try to add selective code to 'disable handshake when CS is asserted (enabled, which means generally set to 0)' from FG to NG. Only spi_slave_api.c register_hs_disable_pin() function to be added in NG and called similar place as that of FG.

Do not even attempt NG module with FG firmware or vice versa, it would not work. Also use latest master of NG at both sides, ESP and host.

QuiGonRazor commented 3 months ago

I confirm you I'm using NG for both kernel ESP driver and firmware. The repo has been cloned 2 days ago I think it is updated.

I've already tried to comment the spi clock adjusting with no luck

I'm gonna try the point 2.

Not sure if I can share an image, it is a prototype. I'm gonna check and see what I can do

mantriyogesh commented 3 months ago

Not sure if I can share an image, it is a prototype. I'm gonna check and see what I can do

In case you are using the jumper cables to evaluate, Just ensure that the cable lengths are minimal <6cm, with good quality and points, and equal lengths.

I've already tried to comment the spi clock adjusting with no luck

for clock adjustments, the module param, clockspeed is useful. Irrespective of the module param, comment the function, esp_adjust_spi_clock() as above.

mantriyogesh commented 3 months ago

Also, if you have logic analyser, would really be helpful to understand the case.

QuiGonRazor commented 3 months ago

I've found the issue using the logical analyzer. I had to add a further line into the device tree to manage correctly the chip select.

Now the wlan0 interface is up, it communicates and I can see the hci0 bluetooth device. Today and next week I'll proceed with a stress test for both connections.

Thank you for your support. For me this issue is solved