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

HanJiec commented 1 year ago

Now our board is ready and I download firmware (In ESP-Hosted-NG_release_v1.0.2\esp32\sdio_only ) , uart0 print the following log. I thinks it is Esp32-SOWD in my board , while the firmware is for DOWD. Is it right? And where can I get the FW for SOWD ?

Rebooting... I (12) boot: ESP-IDF v4.4.1-584-g91dc99a3ce-dirty 2nd stage bootloader I (12) boot: compile time 12:09:04 I (12) boot: chip revision: 1 I (16) boot_comm: chip revision: 1, min. bootloader chip revision: 0 I (23) boot.esp32: SPI Speed : 40MHz I (28) boot.esp32: SPI Mode : DIO I (32) boot.esp32: SPI Flash Size : 8MB I (37) boot: Enabling RNG early entropy source... I (42) boot: Partition Table: I (46) boot: ## Label Usage Type ST Offset Length I (53) boot: 0 nvs WiFi data 01 02 00009000 00004000 I (60) boot: 1 otadata OTA data 01 00 0000d000 00002000 I (68) boot: 2 phy_init RF data 01 01 0000f000 00001000 I (75) boot: 3 factory factory app 00 00 00010000 00100000 I (83) boot: 4 ota_0 OTA app 00 10 00110000 00100000 I (90) boot: 5 ota_1 OTA app 00 11 00210000 00100000 I (98) boot: End of partition table I (102) boot: Defaulting to factory image I (107) boot_comm: chip revision: 1, min. application chip revision: 0 I (114) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=17950h ( 96592) map I (157) esp_image: segment 1: paddr=00027978 vaddr=3ffbdb60 size=05574h ( 21876) load I (166) esp_image: segment 2: paddr=0002cef4 vaddr=40080000 size=03124h ( 12580) load I (172) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=88d8ch (560524) map I (377) esp_image: segment 4: paddr=000b8db4 vaddr=40083124 size=1a43ch (107580) load I (421) esp_image: segment 5: paddr=000d31f8 vaddr=50000000 size=00010h ( 16) load I (436) boot: Loaded app from partition at offset 0x10000 I (436) boot: Disabling RNG early entropy source... I (448) cpu_start: Pro cpu up. E (448) cpustart: **### Running on single core variant of a chip, but app is built with multi-core support_**. E (452) cpu_start: Check that CONFIG_FREERTOS_UNICORE is enabled in menuconfig

abort() was called at PC 0x400d22e4 on core 0 Backtrace:0x40081baa:0x3ffe3b600x400908a9:0x3ffe3b80 0x40097946:0x3ffe3ba0 0x400d22e4:0x3ffe3c10 0x400813ca:0x3ffe3c40 0x400794e0:0x3ffe3c80 |<-CORRUPTED

mantriyogesh commented 1 year ago

Please follow https://github.com/espressif/esp-hosted/tree/master/esp_hosted_ng

Instead of using 1.0.2 in your case, please use master. Build the host Linux driver & esp firmware using same code base and same git commit.

While following the documentation, you will come across hardware and software setup with spi only to flash the esp firmware from sources

HanJiec commented 1 year ago

In https://github.com/espressif/esp-hosted/tree/master/esp_hosted_ng/esp/esp_driver , It is esp-idf @ 91dc99a , do we using esp-idf @ 91dc99a to compile firmware?

mantriyogesh commented 1 year ago

https://github.com/espressif/esp-hosted/blob/master/esp_hosted_ng/esp/esp_driver/README.md will setup the ESP-IDF for you. Please make sure that all local changes saved outside the repo as setup.sh will clean the repo.

HanJiec commented 1 year ago

Should it be built in Linux host system? Where set the core SOWD or DOWD?

mantriyogesh commented 1 year ago

which machine is used as development environment?

Your development environment should flash the ESP32. It would be typically your laptop/desktop. Any Linux/Windows/Mac should work.

For changing the number of cores,

  1. $ cd esp_hosted_fg/esp/esp_driver/network_adapter
  2. Change sdkconfig.defaults.esp32 https://github.com/espressif/esp-hosted/blob/644eb875dc1997916cfc5c0f66b5b9964e2ca55d/esp_hosted_fg/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32#L22-L27

to

CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=400 # CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1=y # CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 # CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 # CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y

$ cd esp_hosted_fg/esp/esp_driver/network_adapter
$ rm -rf sdkconfig build

Follow normal flashing ESP from sources using documentation for your transport.

mantriyogesh commented 1 year ago

please note that rm -rf sdkconfig is important to take effect of changed sdkconfig.defaults.esp32

HanJiec commented 1 year ago

The firmware bin which are download from Github is divided into a few kinds. SPI-Only/SDIO-Only/... How to config these ? image

mantriyogesh commented 1 year ago

These are alternative transport ESP-Hosted provides. Have you checked the documentation?

You have to choose the transport and use the correct one.

HanJiec commented 1 year ago

Do you mean the doc which is pointed by url : https://github.com/espressif/esp-hosted/tree/644eb875dc1997916cfc5c0f66b5b9964e2ca55d/esp_hosted_ng#22-transport-layer-protocol ? In https://github.com/espressif/esp-hosted/blob/644eb875dc1997916cfc5c0f66b5b9964e2ca55d/esp_hosted_ng/docs/sdio_protocol.md , in the line “0x3FF5508C: Interrupt vector used by host to interrupt ESP peripheral” ,0x3FF5508C is a register in ESP32 ?

mantriyogesh commented 1 year ago

https://github.com/espressif/esp-hosted/tree/644eb875dc1997916cfc5c0f66b5b9964e2ca55d/esp_hosted_ng#31-setup -> Hardware and Software Setup.

HanJiec commented 1 year ago

I ever read this doc and study it again. It doesn't describe how to select transport Layer when compile a firmware. It provide the prebuilt firmware bin and guide us how to flash the firmware into esp board. Compare the sdio firmware bin directory with spi. I found sdkconfig is different. In ESP-Hosted-NG_release_v1.0.2\esp32\sdio_only\sdkconfig , there are line : CONFIG_ESP_SDIO_HOST_INTERFACE=y ; while in ESP-Hosted-NG_release_v1.0.2\esp32\spi_only , there is line : CONFIG_ESP_SPI_HOST_INTERFACE=y. Can I write these config lines into esp-hostede/esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32 , are there any other configs for SDIO or SPI? ( Your last comment write esp-hostede/esp_hosted_fg/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32 , I think this is a mistake in writing ,-fg should be -ng, is right ?)

HanJiec commented 11 months ago

Hi, wpa_supplicant -B -i espsta0 -c /etc/wpa_supplicant/wpa_supplicant.conf < x9hp_ms:/etc/wpa_supplicant # ifconfig espsta0 Link encap:Ethernet HWaddr 3c:e9:0e:1a:47:9c Driver esp_sdio inet6 addr: fe80::3ee9:eff:fe1a:479c/64 Scope: Link UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:57 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 TX bytes:0 why the wifi station is of inet6 mode ?how to change inet4 ?

mantriyogesh commented 11 months ago

Is the DHCP client running on espsta0? You can run sudo dhclient -v espsta0

Again it depends which DHCP client software you have. ESP-Hosted will just expose the espsta0. IP assignment is left open to configure.

HanJiec commented 11 months ago

Is the DHCP client running on espsta0? You can run sudo dhclient -v espsta0

Again it depends which DHCP client software you have. ESP-Hosted will just expose the espsta0. IP assignment is left open to configure.

Android have no dhclient , try cp some linux dhclient in adb device, always fail to execute .And DL a open source , It seems needing lots of time to compile it . Is some other method to configure IP ?

mantriyogesh commented 11 months ago

dhcp client varies per machine, no standard process/software and its config. dhcpcd / dhclient / udhcpc to name a few.

Your system would support some DHCP client out of the box, and it is recommended to use the same.

From ESP-Hosted point of view, we don't care which is being used. ESP-Hosted scope ends till virtual network interface.

Also, to verify you can even try disabling DHCP client & set up static IP, which should be very easy to verify the ESP-Hosted networking. Once you confirm that is working, you can easily try any existing/new DHCP client on your own.

HanJiec commented 11 months ago

After insmod esp32_sdio.ko . And using ifconfig , espsta0 cannot be seen. In wpa_supplicant.conf , I fill SSID and psk , then run : wpa_supplicant -B -i espsta0 -c /etc/wpa_supplicant/wpa_supplicant.conf and the espsta0 can be seen . Then ifconfig espsta0 inet 192.168.1.107 netmask 255.255.255.0 but when I run : route add default gw 192.168.1.1 espsta0 It fails . Ping 192.168.1.1 with "unreachable host" Response

Could you please help to analyze the process ?

mantriyogesh commented 11 months ago

Networking is left with higher layer or users to configure. But Can check if ESP-Hosted is not setup correctly.

[A] Enable Slave logs:

  1. https://github.com/espressif/esp-hosted/blob/master/esp_hosted_ng/esp/esp_driver/network_adapter/main/app_main.c#L478
  2. https://github.com/espressif/esp-hosted/blob/master/esp_hosted_ng/esp/esp_driver/network_adapter/main/sdio_slave_api.c#L275
  3. cd esp_hosted_ng/esp/esp_driver/network_adapter idf.py menuconfig Component config > Log output > Default log verbosity => VERBOSE Component config > Wi-Fi => Print debug messages from WPA Supplicant

Flash using idf.py flash monitor

[B] Enable Host logs

  1. Need to add correct log at to print first 32 bytes received of valid packet https://github.com/espressif/esp-hosted/blob/479e76e80f2200a4f620809e715394c76135b2fc/esp_hosted_ng/host/main.c#L604
  2. Need to add correct log at to print first 32 bytes about to send towards ESP : https://github.com/espressif/esp-hosted/blob/479e76e80f2200a4f620809e715394c76135b2fc/esp_hosted_ng/host/main.c#L769
  3. dmesg or /var/log/kern.log Full log
  4. output of hciconfig

Some things to note:

  1. if you have not tested Raw Throughput, please test it first
  2. Most of porting issues are discussed in Porting guide
  3. Please note the jumper cables provide very unstable SDIO. use PCB with external Pull-ups specified in porting guide.
  4. Always use same code base (exact same git commit) at ESP and Host for that specific flavour (FG or NG)
mantriyogesh commented 10 months ago

any updates here?

HanJiec commented 10 months ago

After asking questions the other day, my test board was broken and I couldn't download programs to the esp32

mantriyogesh commented 10 months ago

Oh.. sorry to hear that. thanks for the update.

Wet the open issue, Should we close issue for now and later reopen if you face any problems?