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

esp_hosted_ng - esp32c3 - RSSI/level/signal strengh in WiFi scans is always 0 #495

Open
3 tasks done
caipiblack opened this issue Sep 23, 2024 · 22 comments
Open
3 tasks done

Comments

@caipiblack
Copy link

caipiblack commented Sep 23, 2024

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Expected behavior

When I execute a WiFi scan, I am supposed to see correct signal level

Actual behavior (suspected bug)

The RSSI/signal level/signal strengh is always seen to 0.

root@board:~# wpa_cli -i espsta0 scan_r
bssid / frequency / signal level / flags / ssid
60:38:e0:cd:92:69	2447	0	[WPA2-PSK-CCMP][ESS][UTF-8]	Linksys-DEA9
50:6f:0c:93:ea:90	2412	0	[WPA2-PSK-CCMP][WPS][ESS]	Livebox-EA90
50:6f:0c:93:ea:91	2412	0	[WPA2-PSK-CCMP][ESS]	Livebox-EA90_wifi_invite


root@board:~# wpa_cli scan
Selected interface 'esps[ 1570.865503] esp_cfg80211_scan
ta0'
OK
root@board:~# wpa_cli scan_results
Selected interface 'espsta0'
bssid / frequency / signal level / flags / ssid
60:38:e0:cd:92:69	2447	0	[WPA2-PSK-CCMP][ESS][UTF-8]	Linksys-DEA9
50:6f:0c:93:ea:90	2412	0	[WPA2-PSK-CCMP][WPS][ESS]	Livebox-EA90
50:6f:0c:93:ea:91	2412	0	[WPA2-PSK-CCMP][ESS]	Livebox-EA90_wifi_invite
70:fc:8f:ef:62:60	2437	0	[WPA2-PSK-CCMP][WPS][ESS]	Freebox-51C2B0_5GHz
50:6f:0c:94:64:80	2462	0	[WPA2-PSK-CCMP][WPS][ESS]	Livebox-6480

root@board:~# iwlist scan
lo        Interf[ 1638.323724] esp_cfg80211_scan
ace doesn't support scanning.

sit0      Interface doesn't support scanning.

eth0      Interface doesn't support scanning.

espsta0   Scan completed :
          Cell 01 - Address: 50:6F:0C:93:EA:90
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=70/70  Signal level=0 dBm  
                    Encryption key:on
                    ESSID:"Livebox-EA90"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                              24 Mb/s; 36 Mb/s; 54 Mb/s
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
                    Mode:Master
                    Extra:tsf=000000d9f7d7b48b
                    Extra: Last beacon: 1624ms ago
                    IE: Unknown: 000C4C697665626F782D45413930
                    IE: Unknown: 010882848B962430486C
                    IE: Unknown: 030101
                    IE: Unknown: 0706465220010D14
                    IE: Unknown: 200100
                    IE: Unknown: 23021100
                    IE: Unknown: 2A0100
                    IE: Unknown: 32040C121860
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 0B050100180000
                    IE: Unknown: 42020000
                    IE: Unknown: 4605334F010000
                    IE: Unknown: 2D1AAC091BFFFF000000000000000000000000000000000000000000
                    IE: Unknown: 3D1601080400000000000000000000000000000000000000
                    IE: Unknown: 7F080400080000000040
                    IE: Unknown: DD9A0050F204104A0001101044000102103B00010310470010353036463043F933F54139303530364610210008536167656D636F6D10230014536167656D636F6D46617374353635365F4F46521024000C53475F4C42465F312E322E31104200094C4B323132383146461054000800060050F20400011011000D4C697665626F78204669627265100800020006103C0001011049000600372A000120
                    IE: Unknown: DD090010180201001C0000
                    IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00
          Cell 02 - Address: 50:6F:0C:93:EA:91
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=70/70  Signal level=0 dBm  
                    Encryption key:on
                    ESSID:"Livebox-EA90_wifi_invite"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                              24 Mb/s; 36 Mb/s; 54 Mb/s
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
                    Mode:Master
                    Extra:tsf=000000d9f7d7cc3d
                    Extra: Last beacon: 1624ms ago
                    IE: Unknown: 00184C697665626F782D454139305F776966695F696E76697465
                    IE: Unknown: 010882848B962430486C
                    IE: Unknown: 030101
                    IE: Unknown: 0706465220010D14
                    IE: Unknown: 200100
                    IE: Unknown: 23021100
                    IE: Unknown: 2A0100
                    IE: Unknown: 32040C121860
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 0B050000180000
                    IE: Unknown: 42020000
                    IE: Unknown: 2D1AAC091BFFFF000000000000000000000000000000000000000000
                    IE: Unknown: 3D1601080400000000000000000000000000000000000000
                    IE: Unknown: 7F080400080000000040
                    IE: Unknown: DD090010180200001C0000
                    IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00
          Cell 03 - Address: 60:38:E0:CD:92:69
                    Channel:8
                    Frequency:2.447 GHz (Channel 8)
                    Quality=70/70  Signal level=0 dBm  
                    Encryption key:on
                    ESSID:"Linksys-DEA9"
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
                              36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=000002d86b1448ea
                    Extra: Last beacon: 1752ms ago
                    IE: Unknown: 000C4C696E6B7379732D44454139
                    IE: Unknown: 01088C129824B048606C
                    IE: Unknown: 030108
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 7F080400000001000140
                    IE: Unknown: DD180050F2020101810003A4000027A4000042435E0062322F00
          Cell 04 - Address: 70:97:41:C1:6C:75
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=70/70  Signal level=0 dBm  
                    Encryption key:on
                    ESSID:"Livebox-6C75"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                              24 Mb/s; 36 Mb/s; 54 Mb/s
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
                    Mode:Master
                    Extra:tsf=000000d9f7c8ef11
                    Extra: Last beacon: 1632ms ago
                    IE: Unknown: 000C4C697665626F782D36433735
                    IE: Unknown: 010882848B962430486C
                    IE: Unknown: 030101
                    IE: Unknown: 0706465220010D14
                    IE: Unknown: 200100
                    IE: Unknown: 23021100
                    IE: Unknown: 2A0100
                    IE: Unknown: 32040C121860
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 0B0501000F0000
                    IE: Unknown: 42020000
                    IE: Unknown: 4605334F010000
                    IE: Unknown: 2D1AAC091BFFFF000000000000000000000000000000000000000000
                    IE: Unknown: 3D1601080400000000000000000000000000000000000000
                    IE: Unknown: 7F080400080000000040
                    IE: Unknown: DD990050F204104A0001101044000102103B00010310470010373039373431F331F64337353730393710210008417263616479616E10230013417263616479616E4C4246494252455F4F46521024000C41525F4C42465F312E322E32104200094A41323131373946461054000800060050F20400011011000D4C697665626F78204669627265100800020006103C0001011049000600372A000120
                    IE: Unknown: DD090010180201001C0000
                    IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00

wpan0     Interface doesn't support scanning.

Error logs or terminal output

No response

Steps to reproduce the behavior

We are using the release 1.0.2, (ESP-Hosted-NG_release_v1.0.2.bin)

Project release version

1.0.2

System architecture

ARM 64-bit (Apple M1/M2, Raspberry Pi 4/5)

Operating system

Linux

Operating system version

Yocto - Hardknott
Linux hubmz-rzg2ul 5.10.201-cip41-yocto-standard #1 SMP PREEMPT Sat Feb 27 02:21:18 UTC 2021 aarch64 GNU/Linux

Shell

Bash

Additional context

No response

@mantriyogesh
Copy link
Collaborator

Fixed in c13c46a ?

@caipiblack
Copy link
Author

Fixed in c13c46a ?

I don't know, we are using releases versions only.

If it's fixed, then are you going to provide a new release version soon ?

@mantriyogesh
Copy link
Collaborator

Please test with master, at both sides.

When the new release will happen, it will be included.

@caipiblack
Copy link
Author

caipiblack commented Sep 23, 2024

Currently I am not able to run the built firmware (impossible to connect to an AP), but I didn't change the driver yet!

This is what I do:

Create the firmware using the master branch

  1. Clone the repository:
git clone https://github.com/espressif/esp-hosted.git
  1. Generate the firmware (documentation):
cd esp-hosted/esp_hosted_ng/esp/esp_driver
cmake .
cd esp-idf
. ./export.sh
cd ../network_adapter
idf.py set-target esp32c3
idf.py build
  1. Create the binary file:
esptool.py --chip esp32c3 merge_bin -o ESP-Hosted-NG_dirty_v1.0.3.bin --flash_mode dio --flash_size 4MB 0x0 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0xd000 build/ota_data_initial.bin 0x10000 build/network_adapter.bin

Previously I was using the RELEASE firmwares from esp32c3/spi_only directory, so is it building this firmware when we build with idf.py build like in the documentation ?

I am going to update the kernel module now

@caipiblack
Copy link
Author

caipiblack commented Sep 23, 2024

During the build I get into this issue:

| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/esp_cmd.c:14:
| esp-hosted-ng-mod/esp_hosted_ng/host/include/esp_kernel_port.h:227:20: error: redefinition of 'eth_hw_addr_set'
|   227 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/include/esp.h:16,
|                  from esp-hosted-ng-mod/esp_hosted_ng/host/include/esp_cmd.h:11,
|                  from esp-hosted-ng-mod/esp_hosted_ng/host/esp_cmd.c:9:
| /path-to/kernel-source/include/linux/etherdevice.h:309:20: note: previous definition of 'eth_hw_addr_set' was here
|   309 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/main.c:20:
| esp-hosted-ng-mod/esp_hosted_ng/host/include/esp_kernel_port.h:227:20: error: redefinition of 'eth_hw_addr_set'
|   227 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/include/esp.h:16,
|                  from esp-hosted-ng-mod/esp_hosted_ng/host/main.c:15:
| /path-to/kernel-source/include/linux/etherdevice.h:309:20: note: previous definition of 'eth_hw_addr_set' was here
|   309 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/esp_bt.c:10:
| esp-hosted-ng-mod/esp_hosted_ng/host/include/esp_kernel_port.h:227:20: error: redefinition of 'eth_hw_addr_set'
|   227 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/include/esp.h:16,
|                  from esp-hosted-ng-mod/esp_hosted_ng/host/include/esp_api.h:11,
|                  from esp-hosted-ng-mod/esp_hosted_ng/host/esp_bt.c:9:
| /path-to/kernel-source/include/linux/etherdevice.h:309:20: note: previous definition of 'eth_hw_addr_set' was here
|   309 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| make[3]: *** [/path-to/kernel-source/scripts/Makefile.build:286: esp-hosted-ng-mod/esp_hosted_ng/host/esp_cmd.o] Error 1
| make[3]: *** Waiting for unfinished jobs....
| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/esp_cfg80211.c:14:
| esp-hosted-ng-mod/esp_hosted_ng/host/include/esp_kernel_port.h:227:20: error: redefinition of 'eth_hw_addr_set'
|   227 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/include/esp.h:16,
|                  from esp-hosted-ng-mod/esp_hosted_ng/host/esp_cfg80211.c:10:
| /path-to/kernel-source/include/linux/etherdevice.h:309:20: note: previous definition of 'eth_hw_addr_set' was here
|   309 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| make[3]: *** [/path-to/kernel-source/scripts/Makefile.build:286: esp-hosted-ng-mod/esp_hosted_ng/host/esp_bt.o] Error 1
| make[3]: *** [/path-to/kernel-source/scripts/Makefile.build:286: esp-hosted-ng-mod/esp_hosted_ng/host/main.o] Error 1
| make[3]: *** [/path-to/kernel-source/scripts/Makefile.build:286: esp-hosted-ng-mod/esp_hosted_ng/host/esp_cfg80211.o] Error 1
| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/spi/esp_spi.c:16:
| esp-hosted-ng-mod/esp_hosted_ng/host/include/esp_kernel_port.h:227:20: error: redefinition of 'eth_hw_addr_set'
|   227 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| In file included from esp-hosted-ng-mod/esp_hosted_ng/host/include/esp.h:16,
|                  from esp-hosted-ng-mod/esp_hosted_ng/host/spi/esp_spi.h:10,
|                  from esp-hosted-ng-mod/esp_hosted_ng/host/spi/esp_spi.c:12:
| /path-to/kernel-source/include/linux/etherdevice.h:309:20: note: previous definition of 'eth_hw_addr_set' was here
|   309 | static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|       |                    ^~~~~~~~~~~~~~~
| make[3]: *** [/path-to/kernel-source/scripts/Makefile.build:286: esp-hosted-ng-mod/esp_hosted_ng/host/spi/esp_spi.o] Error 1
| make[2]: Leaving directory '/path-to/kernel-build-artifacts'
| make[2]: *** [/path-to/kernel-source/Makefile:1832: esp-hosted-ng-mod/esp_hosted_ng/host] Error 2
| make[1]: *** [Makefile:192: __sub-make] Error 2
| make[1]: Leaving directory '/path-to/kernel-source'
| make: *** [Makefile:29: all] Error 2
| ERROR: oe_runmake failed
| WARNING: exit code 1 from a shell command.

I fixed it by commenting static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr) in esp_kernel_port.h

At this point I have the ESP32C3 + driver updated to 9f809ff unfortunately it's not starting, I try to find what happens..

# dmesg | grep "esp_hosted_ng"
[    5.657848] esp_hosted_ng: loading out-of-tree module taints kernel.
[    5.894875] esp_hosted_ng: spi_dev_init: ESP32 peripheral is registered to SPI bus [1],chip select [0], SPI Clock [10]
[    7.343487] esp_hosted_ng: process_esp_bootup_event: Received ESP bootup event
[    7.350938] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 3
[    7.358063] esp_hosted_ng: esp_validate_chipset: Chipset=ESP32-C3 ID=05 detected over SPI
[    7.367178] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 2
[    7.374262] esp_hosted_ng: adjust_spi_clock: ESP Reconfigure SPI CLK to 30 MHz
[    7.381632] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 0
[    7.388451] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 1
[    7.395255] esp_hosted_ng: process_fw_data: ESP chipset's last reset cause:
[    7.402303] esp_hosted_ng: print_reset_reason: POWERON_RESET
[    7.408056] esp_hosted_ng: check_esp_version: ESP-Hosted Version: NG-1.0.3.0.0
[    7.421205] esp_hosted_ng: esp_reg_notifier: Driver init is ongoing
[    7.679343] esp_hosted_ng: init_bt: ESP Bluetooth init
[    7.685090] esp_hosted_ng: print_capabilities: Capabilities: 0xe8. Features supported are:
[    7.693681] esp_hosted_ng: print_capabilities: 	 * WLAN on SPI
[    7.699763] esp_hosted_ng: print_capabilities: 	 * BT/BLE
[    7.705277] esp_hosted_ng: print_capabilities: 	   - HCI over SPI
[    7.711467] esp_hosted_ng: print_capabilities: 	   - BLE only
[    7.844280] esp_hosted_ng: esp_reg_notifier: cfg80211 regulatory domain callback for 00, current=\x00\x00
[   12.902834] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface lo ip changed to  127.000.000.001
[   13.013728] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   14.939922] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface eth0 ip changed to  192.168.100.001
[   14.993918] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   45.939806] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   45.946234] esp_hosted_ng: esp_inetaddr_event: Interface Down: 0

I don't know if the problem is related to the comit that I take, or something in my setup. I'm searching

@caipiblack
Copy link
Author

Nice, same issue as here now: #426

@mantriyogesh
Copy link
Collaborator

Can you please attach the log from esp as well?

What is your Linux based system, also please attach the photo of your setup

@caipiblack
Copy link
Author

caipiblack commented Sep 23, 2024

Can you please attach the log from esp as well?

What is your Linux based system, also please attach the photo of your setup

Thanks for your help,

  • We are running on a Yocto (Hardknott) board
  • This is a custom IOT board using a RZG2UL + ESP32C3 for WiFi
  • The esp32-c3 is connected using SPI
  • It was working good with the last release (1.0.2) except the RSSI level that was always returned to "0 Dbm" in the scans. And we need to get is returning correct values for PCBA tests.

Currently I am not able to have traces on my esp32, I think this is firmware related because with old FW (pre-built in the release) it was OK.

Did we have to configure something in menuconfig ?

For example:

(Top) → Example Configuration
    Transport layer (SPI interface)  --->
    SPI Configuration  --->
[ ] SDIO CD Pin support
[*] OTA workaround - Add sleeps while OTA write
[ ] Debug Serial driver data path
[ ] Debug Wlan driver data path
[ ] Debug Bluetooth driver data path
(921600) UART Baudrate for HCI

@caipiblack
Copy link
Author

Also I see something strange. With the most recent version (9f809ff) I see that the driver is not able to stop:

  • The command rmmod {driver name} is blocking infinitely

In our usecase it's a problem, because the "reset" pin of the ESP32 is "taken" by the driver.
We need to keep the possibility to control it from userspace (to update/flash the ESP32 using UART).

Note: Currently I don't know if the driver refuse to stop due to a bug or if it's a new feature that comes with recent commits.

@caipiblack
Copy link
Author

caipiblack commented Sep 23, 2024

I just realized that with the recent changes of the driver, the interface espsta0 become wlan0 so I had to change it in the wpa_supplicant service!

So at this point, i can connect to access-point!

root@board:~# dmesg | grep esp
[    5.624660] esp_hosted_ng: loading out-of-tree module taints kernel.
[    5.877084] esp_hosted_ng: spi_dev_init: ESP32 peripheral is registered to SPI bus [1],chip select [0], SPI Clock [10]
[    7.326568] esp_hosted_ng: process_esp_bootup_event: Received ESP bootup event
[    7.334007] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 3
[    7.341364] esp_hosted_ng: esp_validate_chipset: Chipset=ESP32-C3 ID=05 detected over SPI
[    7.349618] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 2
[    7.356343] esp_hosted_ng: adjust_spi_clock: ESP Reconfigure SPI CLK to 30 MHz
[    7.363590] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 0
[    7.370856] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 1
[    7.377648] esp_hosted_ng: process_fw_data: ESP chipset's last reset cause:
[    7.384670] esp_hosted_ng: print_reset_reason: POWERON_RESET
[    7.390356] esp_hosted_ng: check_esp_version: ESP-Hosted Version: NG-1.0.3.0.0
[    7.403637] esp_hosted_ng: esp_reg_notifier: Driver init is ongoing
[    7.675208] esp_hosted_ng: init_bt: ESP Bluetooth init
[    7.680937] esp_hosted_ng: print_capabilities: Capabilities: 0xe8. Features supported are:
[    7.689858] esp_hosted_ng: print_capabilities: 	 * WLAN on SPI
[    7.695803] esp_hosted_ng: print_capabilities: 	 * BT/BLE
[    7.701203] esp_hosted_ng: print_capabilities: 	   - HCI over SPI
[    7.707286] esp_hosted_ng: print_capabilities: 	   - BLE only
[    7.838538] esp_hosted_ng: esp_reg_notifier: cfg80211 regulatory domain callback for 00, current=\x00\x00
[   13.138398] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface lo ip changed to  127.000.000.001
[   13.191811] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   14.956141] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface eth0 ip changed to  192.168.100.001
[   15.006509] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   46.083498] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   46.089596] esp_hosted_ng: esp_inetaddr_event: Interface Down: 0
[   57.735371] esp_hosted_ng: cmd_auth_request: Authentication request: 60:38:e0:cd:92:69 8 0 0 0
[   57.980747] esp_hosted_ng: cmd_assoc_request: Association request: 60:38:e0:cd:92:69 8 35
[   58.043154] esp_hosted_ng: process_assoc_event: Connection status: 0
[   58.208411] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface wlan0 ip changed to  192.168.003.243
[   58.271931] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface lo ip changed to  127.000.000.001
[   58.316936] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   89.275583] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   89.282336] esp_hosted_ng: esp_inetaddr_event: Interface Down: 0


root@board:~# journalctl -u wpa_supplicant
Sep 23 14:26:55 board systemd[1]: Starting WPA supplicant...
Sep 23 14:26:55 board systemd[1]: Started WPA supplicant.
Sep 23 14:26:55 board wpa_supplicant[888]: Successfully initialized wpa_supplicant
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:55 board wpa_supplicant[888]: nl80211: kernel reports: Registration to specific type not supported
Sep 23 14:26:57 board wpa_supplicant[888]: wlan0: SME: Trying to authenticate with 60:38:e0:cd:92:69 (SSID='Linksys-DEA9' freq=2447 MHz)
Sep 23 14:26:57 board wpa_supplicant[888]: wlan0: Trying to associate with 60:38:e0:cd:92:69 (SSID='Linksys-DEA9' freq=2447 MHz)
Sep 23 14:26:57 board wpa_supplicant[888]: wlan0: Associated with 60:38:e0:cd:92:69
Sep 23 14:26:57 board wpa_supplicant[888]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Sep 23 14:26:57 board wpa_supplicant[888]: wlan0: WPA: Key negotiation completed with 60:38:e0:cd:92:69 [PTK=CCMP GTK=CCMP]
Sep 23 14:26:57 board wpa_supplicant[888]: wlan0: CTRL-EVENT-CONNECTED - Connection to 60:38:e0:cd:92:69 completed [id=1 id_str=]

There are still cmd_set_ip_address: Invalid argument messages, I don't know yet if it's important..

And at this point I can scan the WiFi networks and get the correct RSSI values (maybe):

root@board:~# iwlist scan
lo        Interface doesn't support scanning.

sit0      Interface doesn't support scanning.

eth0      Interface doesn't support scanning.

wlan0     Scan completed :
          Cell 01 - Address: 60:38:E0:CD:92:69
                    Channel:8
                    Frequency:2.447 GHz (Channel 8)
                    Quality=70/70  Signal level=-29 dBm  
                    Encryption key:on
                    ESSID:"Linksys-DEA9"
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
                              36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=000002dc7f288ab0
                    Extra: Last beacon: 1752ms ago
                    IE: Unknown: 000C4C696E6B7379732D44454139
                    IE: Unknown: 01088C129824B048606C
                    IE: Unknown: 030108
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 7F080400000001000140
                    IE: Unknown: DD180050F2020101810003A4000027A4000042435E0062322F00
          Cell 02 - Address: 50:6F:0C:93:EA:90
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=16/70  Signal level=-94 dBm  
                    Encryption key:on
                    ESSID:"Livebox-EA90"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                              24 Mb/s; 36 Mb/s; 54 Mb/s
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
                    Mode:Master
                    Extra:tsf=000000de0bebab25
                    Extra: Last beacon: 1628ms ago
                    IE: Unknown: 000C4C697665626F782D45413930
                    IE: Unknown: 010882848B962430486C
                    IE: Unknown: 030101
                    IE: Unknown: 0706465220010D14
                    IE: Unknown: 200100
                    IE: Unknown: 23021100
                    IE: Unknown: 2A0100
                    IE: Unknown: 32040C121860
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 0B050100150000
                    IE: Unknown: 42020000
                    IE: Unknown: 4605334F010000
                    IE: Unknown: 2D1AAC091BFFFF000000000000000000000000000000000000000000
                    IE: Unknown: 3D1601080400000000000000000000000000000000000000
                    IE: Unknown: 7F080400080000000040
                    IE: Unknown: DD9A0050F204104A0001101044000102103B00010310470010353036463043F933F54139303530364610210008536167656D636F6D10230014536167656D636F6D46617374353635365F4F46521024000C53475F4C42465F312E322E31104200094C4B323132383146461054000800060050F20400011011000D4C697665626F78204669627265100800020006103C0001011049000600372A000120
                    IE: Unknown: DD090010180201001C0000
                    IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00
          Cell 03 - Address: 50:6F:0C:93:EA:91
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=20/70  Signal level=-90 dBm  
                    Encryption key:on
                    ESSID:"Livebox-EA90_wifi_invite"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                              24 Mb/s; 36 Mb/s; 54 Mb/s
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
                    Mode:Master
                    Extra:tsf=000000de0bebb957
                    Extra: Last beacon: 1624ms ago
                    IE: Unknown: 00184C697665626F782D454139305F776966695F696E76697465
                    IE: Unknown: 010882848B962430486C
                    IE: Unknown: 030101
                    IE: Unknown: 0706465220010D14
                    IE: Unknown: 200100
                    IE: Unknown: 23021100
                    IE: Unknown: 2A0100
                    IE: Unknown: 32040C121860
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 0B050000150000
                    IE: Unknown: 42020000
                    IE: Unknown: 2D1AAC091BFFFF000000000000000000000000000000000000000000
                    IE: Unknown: 3D1601080400000000000000000000000000000000000000
                    IE: Unknown: 7F080400080000000040
                    IE: Unknown: DD090010180200001C0000
                    IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00

New issues:

  1. When I configure a second IP to the interface it seems to be "breaking the driver", if I try to ping something on the network with an IP from this network, it fails (like timeout)
# ip addr add 192.168.100.1/24 dev wlan0
[   74.088220] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface wlan0 ip changed to  192.168.100.001
[   88.367768] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   88.373893] esp_hosted_ng: esp_inetaddr_event: Interface Down: 0

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 02:03:00:00:00:02 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.1/24 brd 192.168.100.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::3:ff:fe00:2/64 scope link 
       valid_lft forever preferred_lft forever
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 80:65:99:85:02:d8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.3.243/24 metric 20 brd 192.168.3.255 scope global dynamic wlan0
       valid_lft 43024sec preferred_lft 43024sec
    inet 192.168.100.1/24 scope global wlan0
       valid_lft forever preferred_lft forever
    inet6 2a01:cb00:879d:bd0::607/128 scope global dynamic noprefixroute 
       valid_lft 43025sec preferred_lft 414sec
    inet6 fdf3:54e7:4f05::607/128 scope global dynamic noprefixroute 
       valid_lft 43025sec preferred_lft 414sec
    inet6 fdf3:54e7:4f05:0:8265:99ff:fe85:2d8/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 4294967120sec preferred_lft 4294967120sec
    inet6 2a01:cb00:879d:bd0:8265:99ff:fe85:2d8/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 86214sec preferred_lft 414sec
    inet6 fe80::8265:99ff:fe85:2d8/64 scope link 
       valid_lft forever preferred_lft forever
# ping 192.168.100.2
PING 192.168.100.2 (192.168.100.2): 56 data bytes



^C
--- 192.168.100.2 ping statistics ---
6 packets transmitted, 0 packets received, 100% packet loss

  1. This is currently impossible to stop the driver from the userspace (as root), using rmmod the command is blocking.

@mantriyogesh
Copy link
Collaborator

Old firmware and new host driver might behave strange , @caipiblack .

Please flash the same git commit both sides..

@caipiblack
Copy link
Author

caipiblack commented Sep 24, 2024

Hello,

I have the host driver + ESP32C3 firmware using the same commit: 9f809ff

This was the most recent commit of yesterday.

Can someone try to reproduce to check if he see the same issues:

  1. Impossible to stop the driver using rmmod (was possible in release 1.0.2)
  2. Errors appear when we configure a second IP (the interface have DHCP IPv4, and you add a fixed ip) ip addr add 192.168.100.1/24 dev wlan0

Question:

  • Is there a recent commit that is known to work perfectly ? (except the release 1.0.2 that I was using from 2022)

@mantriyogesh
Copy link
Collaborator

@kapilkedawat, PTAL

@kapilkedawat
Copy link
Contributor

@caipiblack could you please share your kernel version number?

@caipiblack
Copy link
Author

@caipiblack could you please share your kernel version number?

Hello,

Linux hubmz-rzg2ul 5.10.201-cip41-yocto-standard #1 SMP PREEMPT Sat Feb 27 02:21:18 UTC 2021 aarch64 GNU/Linux

This is 5.10.201-cip41 is it what you are looking for ?

About the version, note that in esp_kernel_port.h I had to remove somes lines to fix an error as said in a previous comment (#495 (comment)):

#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
{
	ether_addr_copy(dev->dev_addr, addr);
}
#endif

My version is less than 5.15.0, (5.10.201) but this function is defined in my side so I don't need this.

@kapilkedawat
Copy link
Contributor

kapilkedawat commented Sep 24, 2024

@caipiblack thanks for the detail, we will try to check the behavior on nearest available kernel version with us. Compilation error should be resolved by 382dc37

Also you should be able to unload the driver now using same commit, please let us know if that doesn't work.

Could you please recheck the IP issue on your setup again. Invalid argument supposed to come when driver is not initialized. We gave two IPs in our system and it was able to communicate correctly.

root@raspberrypi:~# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:23:07:20 brd ff:ff:ff:ff:ff:ff
    inet 192.168.60.194/24 brd 192.168.60.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::cab7:4e8c:f396:bce7/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:76:52:75 brd ff:ff:ff:ff:ff:ff
8: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 7c:df:a1:c2:11:84 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.1/24 scope global wlan1
       valid_lft forever preferred_lft forever
    inet 192.168.15.32/24 scope global wlan1
       valid_lft forever preferred_lft forever
    inet6 fe80::cad5:86e8:cd11:1a2/64 scope link 
       valid_lft forever preferred_lft forever
root@raspberrypi:~# ping 192.168.15.4
PING 192.168.15.4 (192.168.15.4) 56(84) bytes of data.
64 bytes from 192.168.15.4: icmp_seq=1 ttl=64 time=99.6 ms
64 bytes from 192.168.15.4: icmp_seq=2 ttl=64 time=85.8 ms
^C
--- 192.168.15.4 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 85.838/92.755/99.672/6.917 ms

@caipiblack
Copy link
Author

Hello,

I take your commit for the ESP32C3 firmware + Host driver.

  1. I am now able to stop the driver (like in 1.0.2, with rmmod) (Thanks!)
  2. I still have issues with IP addresses
  3. I see that you put a ifndef around eth_hw_addr_set in esp_kernel_ports.h, this is not enought to resolve the build issue. Note that with my kernel this function is defined in include/linux/etherdevice.h also I don't know if in C we can do "ifndef" with function names (I never do it and will learn something if possible).

etherdevice.h:
image

esp_kernel_ports.h:
image

Logs from dmesg, grepped with 'esp':

[    5.695347] esp_hosted_ng: loading out-of-tree module taints kernel.
[    5.932601] esp_hosted_ng: spi_dev_init: ESP32 peripheral is registered to SPI bus [1],chip select [0], SPI Clock [10]
[    7.375873] esp_hosted_ng: process_esp_bootup_event: Received ESP bootup event
[    7.384162] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 3
[    7.391592] esp_hosted_ng: esp_validate_chipset: Chipset=ESP32-C3 ID=05 detected over SPI
[    7.400028] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 2
[    7.406811] esp_hosted_ng: adjust_spi_clock: ESP Reconfigure SPI CLK to 30 MHz
[    7.414121] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 0
[    7.421510] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 1
[    7.428364] esp_hosted_ng: process_fw_data: ESP chipset's last reset cause:
[    7.435433] esp_hosted_ng: print_reset_reason: POWERON_RESET
[    7.441205] esp_hosted_ng: check_esp_version: ESP-Hosted Version: NG-1.0.3.0.0
[    7.453281] esp_hosted_ng: esp_reg_notifier: Driver init is ongoing
[    7.703366] esp_hosted_ng: init_bt: ESP Bluetooth init
[    7.709060] esp_hosted_ng: print_capabilities: Capabilities: 0xe8. Features supported are:
[    7.717957] esp_hosted_ng: print_capabilities: 	 * WLAN on SPI
[    7.723846] esp_hosted_ng: print_capabilities: 	 * BT/BLE
[    7.729244] esp_hosted_ng: print_capabilities: 	   - HCI over SPI
[    7.735337] esp_hosted_ng: print_capabilities: 	   - BLE only
[    7.918385] esp_hosted_ng: esp_reg_notifier: cfg80211 regulatory domain callback for 00, current=\x00\x00
[   12.424388] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface lo ip changed to  127.000.000.001
[   12.469216] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   13.903620] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface eth0 ip changed to  192.168.100.001
[   13.945486] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   14.701285] esp_hosted_ng: cmd_auth_request: Authentication request: 60:38:e0:cd:92:69 8 0 0 0
[   14.997467] esp_hosted_ng: cmd_assoc_request: Association request: 60:38:e0:cd:92:69 8 35
[   15.119346] esp_hosted_ng: process_assoc_event: Connection status: 0
[   15.415790] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface wlan0 ip changed to  192.168.003.243
[   45.479829] esp_hosted_ng: cmd_set_ip_address: Invalid argument
[   45.485837] esp_hosted_ng: esp_inetaddr_event: Interface Down: 0
[   91.655447] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface wlan0 ip changed to  192.168.100.001

But your response give me some ideas, here you can see what I change in the driver to make it working on my board:

diff --git a/esp_hosted_ng/host/include/esp_kernel_port.h b/esp_hosted_ng/host/include/esp_kernel_port.h
index 028daeb..5f0be21 100644
--- a/esp_hosted_ng/host/include/esp_kernel_port.h
+++ b/esp_hosted_ng/host/include/esp_kernel_port.h
@@ -217,12 +217,14 @@ static inline bool wireless_dev_current_bss_exists(struct wireless_dev *wdev)
 #define ZERO_LINK_ID
 #endif
 
+#if 0
 #ifndef eth_hw_addr_set
 static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
 {
 	ether_addr_copy(dev->dev_addr, addr);
 }
 #endif
+#endif
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 9, 0))
 #define spi_master			spi_controller
diff --git a/esp_hosted_ng/host/main.c b/esp_hosted_ng/host/main.c
index fa8d991..516532d 100644
--- a/esp_hosted_ng/host/main.c
+++ b/esp_hosted_ng/host/main.c
@@ -31,7 +31,7 @@
 
 #define RELEASE_VERSION PROJECT_NAME "-" STRINGIFY(PROJECT_VERSION_MAJOR_1) "." STRINGIFY(PROJECT_VERSION_MAJOR_2) "." STRINGIFY(PROJECT_VERSION_MINOR) "." STRINGIFY(PROJECT_REVISION_PATCH_1) "." STRINGIFY(PROJECT_REVISION_PATCH_2)
 
-static int resetpin = HOST_GPIO_PIN_INVALID;
+static int resetpin = 506;
 static u32 clockspeed = 0;
 extern u8 ap_bssid[MAC_ADDR_LEN];
 extern volatile u8 host_sleep;
diff --git a/esp_hosted_ng/host/spi/esp_spi.c b/esp_hosted_ng/host/spi/esp_spi.c
index b6ee52d..bd7c5cb 100644
--- a/esp_hosted_ng/host/spi/esp_spi.c
+++ b/esp_hosted_ng/host/spi/esp_spi.c
@@ -422,7 +422,7 @@ static int spi_dev_init(int spi_clk_mhz)
 	strscpy(esp_board.modalias, "esp_spi", sizeof(esp_board.modalias));
 	esp_board.mode = SPI_MODE_2;
 	esp_board.max_speed_hz = spi_clk_mhz * NUMBER_1M;
-	esp_board.bus_num = 0;
+	esp_board.bus_num = 1;
 	esp_board.chip_select = 0;
 
 	master = spi_busnum_to_master(esp_board.bus_num);
diff --git a/esp_hosted_ng/host/spi/esp_spi.h b/esp_hosted_ng/host/spi/esp_spi.h
index 7ce272c..19a5486 100644
--- a/esp_hosted_ng/host/spi/esp_spi.h
+++ b/esp_hosted_ng/host/spi/esp_spi.h
@@ -9,9 +9,9 @@
 
 #include "esp.h"
 
-#define HANDSHAKE_PIN           22
+#define HANDSHAKE_PIN           505
 #define SPI_IRQ                 gpio_to_irq(HANDSHAKE_PIN)
-#define SPI_DATA_READY_PIN      27
+#define SPI_DATA_READY_PIN      504
 #define SPI_DATA_READY_IRQ      gpio_to_irq(SPI_DATA_READY_PIN)
 #define SPI_BUF_SIZE            1600

And i don't really configure the parameters of the driver as the driver starts automatically on the first run.

So these parameters keep their defaults values:

module_param(resetpin, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(resetpin, "Host's GPIO pin number which is connected to ESP32's EN to reset ESP32 device");

module_param(clockspeed, uint, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(clockspeed, "Hosts clock speed in MHz");

module_param(raw_tp_mode, uint, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(raw_tp_mode, "Mode choosed to test raw throughput");

In my case:

resetpin = 506; // Modified by me from my patch
clockspeed = 0; // Default value, so the driver use default SPI CLK value, maybe OK
raw_tp_mode = 0; // Default value, maybe OK

But if these parameters are not "set" when the driver is started, can it produce Invalid argument because driver thinks he is not "initialized" ?

This is just an idea, I don't know if the solution is around this.

@kapilkedawat
Copy link
Contributor

Yes, my bad, I'll correct the function later. It seems there are some missing checks in esp_inetaddr_event, which is causing it to process the IP for other interfaces as well. However, that shouldn't cause any issues, since the IP is only used for SDIO wakeup in the firmware.

You can skip the event processing using this patch(will be committed later):

diff --git a/esp_hosted_ng/host/esp_cfg80211.c b/esp_hosted_ng/host/esp_cfg80211.c
index 09380d4d..a2b9af9a 100644
--- a/esp_hosted_ng/host/esp_cfg80211.c
+++ b/esp_hosted_ng/host/esp_cfg80211.c
@@ -158,9 +158,18 @@ static int esp_inetaddr_event(struct notifier_block *nb,
 {
        struct in_ifaddr *ifa = data;
        struct net_device *netdev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL;
-       struct esp_wifi_device *priv = netdev_priv(netdev);
+       struct esp_wifi_device *priv;
+       struct esp_adapter *adapter = esp_get_adapter();
+       struct esp_wifi_device *esp_priv = adapter->priv[0];
+
+       if (!netdev)
+               return 0;
 
-       esp_verbose("------- IP event -------\n");
+       esp_info("------- IP event for interface %s -------\n", netdev->name);
+
+       priv = netdev_priv(netdev);
+       if (esp_priv != priv)
+               return 0;
 
        switch (event) {
 
@@ -174,7 +183,7 @@ static int esp_inetaddr_event(struct notifier_block *nb,
        case NETDEV_DOWN:
                if (priv && (priv->if_type == ESP_STA_IF)) {
                        cmd_set_ip_address(priv, 0);
-                       esp_info("Interface Down: %d\n", priv->if_type);
+                       esp_info("Interface %s Down: %d\n", netdev->name, priv->if_type);
                }
                break;
        }

Could you please share your system's route after you give two IPs, also does it work as expected when you add two IPs on Ethernet interface?

@caipiblack
Copy link
Author

caipiblack commented Sep 25, 2024

Hello, your patch solved the invalid parameters errors!

[    5.487006] esp_hosted_ng: loading out-of-tree module taints kernel.
[    5.742435] esp_hosted_ng: spi_dev_init: ESP32 peripheral is registered to SPI bus [1],chip select [0], SPI Clock [10]
[    7.182184] esp_hosted_ng: process_esp_bootup_event: Received ESP bootup event
[    7.189572] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 3
[    7.196599] esp_hosted_ng: esp_validate_chipset: Chipset=ESP32-C3 ID=05 detected over SPI
[    7.204832] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 2
[    7.211567] esp_hosted_ng: adjust_spi_clock: ESP Reconfigure SPI CLK to 30 MHz
[    7.218819] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 0
[    7.225548] esp_hosted_ng: process_event_esp_bootup: Bootup Event tag: 1
[    7.232281] esp_hosted_ng: process_fw_data: ESP chipset's last reset cause:
[    7.239281] esp_hosted_ng: print_reset_reason: POWERON_RESET
[    7.244939] esp_hosted_ng: check_esp_version: ESP-Hosted Version: NG-1.0.3.0.0
[    7.256683] esp_hosted_ng: esp_reg_notifier: Driver init is ongoing
[    7.507384] esp_hosted_ng: init_bt: ESP Bluetooth init
[    7.513157] esp_hosted_ng: print_capabilities: Capabilities: 0xe8. Features supported are:
[    7.521932] esp_hosted_ng: print_capabilities: 	 * WLAN on SPI
[    7.527972] esp_hosted_ng: print_capabilities: 	 * BT/BLE
[    7.533377] esp_hosted_ng: print_capabilities: 	   - HCI over SPI
[    7.539527] esp_hosted_ng: print_capabilities: 	   - BLE only
[    9.143485] esp_hosted_ng: esp_reg_notifier: cfg80211 regulatory domain callback for 00, current=\x00\x00
[   13.356542] esp_hosted_ng: esp_inetaddr_event: ------- IP event for interface lo -------
[   15.492317] esp_hosted_ng: cmd_auth_request: Authentication request: 60:38:e0:cd:92:69 8 0 0 0
[   15.861018] esp_hosted_ng: cmd_assoc_request: Association request: 60:38:e0:cd:92:69 8 35
[   15.949929] esp_hosted_ng: process_assoc_event: Connection status: 0
[   16.300224] esp_hosted_ng: esp_inetaddr_event: ------- IP event for interface eth0 -------
[   16.418064] esp_hosted_ng: esp_inetaddr_event: ------- IP event for interface wlan0 -------
[   16.493508] esp_hosted_ng: esp_inetaddr_event: NETDEV_UP interface wlan0 ip changed to  192.168.003.243
[   47.111989] esp_hosted_ng: esp_inetaddr_event: ------- IP event for interface lo -------

For the IP address it's also working, i found out that the IP address was also set to the ETH interface.
This board does not have eth interface, but it is enabled in DTS, for unknown reason the interface appear as up/connected (very strange)

So at this point the main issues are solved!

There are still minor issues that I fix by my side:

  • Are you going to push your recent changes that "ignore" the network configuration not for the driver ?
  • Are you going to fix the issue with eth_hw_addr_set ? (not with ifndef, I don't know how)

This is just to know if I wait a little to update the commits (after you fix these issues) or if I fix them by my side with patches like now.

For the second issue, I have no ideas how you can know if an inline function is "redefined" to prevent "re-redefining it". It can also stay like it was previously, who need to remove it, just patch it to remove it..

Also, is there a 1.0.3 release coming soon ? We always prefer to use "released versions" in our platform instead of "the commit of a day"

@kapilkedawat
Copy link
Contributor

@caipiblack thanks for the confirmation, changes will be pushed shortly. Yes, will plan a release in some time, but it may take a week or two.

@caipiblack
Copy link
Author

@caipiblack thanks for the confirmation, changes will be pushed shortly. Yes, will plan a release in some time, but it may take a week or two.

If it just take one week or two, I think I'm going to wait for the release!

I keep the issue open if someone want to say something / to test something,

You can close if it's all good.

@caipiblack
Copy link
Author

@caipiblack thanks for the confirmation, changes will be pushed shortly. Yes, will plan a release in some time, but it may take a week or two.

Hello, What is the status of the future new release ?

Next week we need to know if we are going to use "the commit of the day" (last commit of the master branch), or a release version

If you are not working on a release 1.0.3 then I'm going to use "the last commit", we don't really like to use "un-released versions" but if we have no choice..

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

3 participants