espressif / esp-hosted

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

WIFI Disconnnetion status not available and its not reconnecting automatically while using esp host control #114

Closed vijay-yaga closed 2 years ago

vijay-yaga commented 2 years ago

Hi we are working on the esp hosted driver we have succesfully connected using esp hostcontrol c file test.c but we are unable to know the status of WIFI disconnection and we are unable to connect to same ssid and password when wifi is available kindly can you help me rresolve this issue

thank you Regards vijay

mantriyogesh commented 2 years ago

Hello @vijay-yaga

Thank you for trying out the solution and for your query.

We have developed the control path events for such scenarios. It will shortly be pushed out to github, I would suggest you to wait for another day or so.

What are these events? Upon some interesting condition like disconnection in station mode happens, a event message will be sent to host. Upon receiving such event, host can do expected things (open for user what to do) like re-connection etc.

mantriyogesh commented 2 years ago

Hello @vijay-yaga,

The GitHub page is updated for above change.

Please visit https://github.com/espressif/esp-hosted and use master branch to test the changes. As there are multiple optimizations and code changes, I would suggest going through control path documentation to get to know info like how the events are expected to be subscribed etc.

vijay-yaga commented 2 years ago

Hi @mantriyogesh we ported the master hosrted driver and c support file to our board before with release v4.0 its all working fine but now with new master branch i am unable to connect the wifi to my ssid we have release 4 firmware in esp32c3 module error liog are shown as below:

$ insmod ../../bsp/esp32_spi_new_event.ko esp32_spi: loading out-of-tree module taints kernel. ESP32 peripheral is registered to SPI bus [2],chip select [0], SPI Clock [10] ./test.out sta_connect Enable heartbeat with duration 2 Received INIT event from ESP32 peripheral0

EVENT: 2 EVENT: 1 ESP Reconfigure SPI CLK to 30 MHz ESP32 peripheral is registered to SPI bus [2],chip select [0], SPI Clock [30] EVENT: 0 ESP peripheral capabilities: 0x68 Control response timed out after Received INIT event from ESP32 peripheral 30 sec Respons e not received EVENT: 2 EVENT: 1 ESP Reconfigure SPI CLK to 30 MHz ESP32 peripheral is registered to SPI bus [2],chip select [0], SPI Clock [30] EVENT: 0 ESP peripheral capabilities: 0x68

Requested operation complete Sleeping for some time just to showcase heartbeat Illegal instruction

kindly give me the solution

mantriyogesh commented 2 years ago

Have you used same commit at both places, at esp and linux?

Also, please try to mimic rpi_init.sh to load the driver. After loading new module, please rebuild the application. And keep at least 3 sec gap after loading driver to run the app.

mantriyogesh commented 2 years ago

Still not working despite above trials? please get us the detailed log..

vijay-yaga commented 2 years ago

Hi @mantriyogesh thanks for your quick response i am attching the esp32 module error log its giving protocomm_pserial_common_handler failed so the module is not responding to driver please find the error log attachement and we have compile host driver and host control from master branch but we have loaded the firware version 4.0 for esp32

esp32_master_log.txt

mantriyogesh commented 2 years ago

Okay. The problem is that for code changes done as part of control path optimizations are not compatible with old ESP32 firmwares. There are changes in protobuf messages.

In short, you need all to point same commit, ESP32 and host. Considering this, you have two options to proceed,

mantriyogesh commented 2 years ago

Hello @vijay-yaga,

Were you able to get it working?

mantriyogesh commented 2 years ago

@vijay-yaga Any updates?

vijay-yaga commented 2 years ago

Hi @mantriyogesh

we have succesfully compiled and loaded the master C3 firmware and we also compiled master branch hosted driver and host controller c support test.out we have loaded the module and reset the esp32 module and after we have run the below commands $ mknod /dev/esps0 c 221 0 $ chmod 666 /dev/esps0 after that i have executed the test.out with arg sta_connect and its not connecting to wifi i am attaching the error log belo esp32_hosted_error_log.txt w

mantriyogesh commented 2 years ago

Hello @vijay-yaga,

Thank you for the all logs.

The ESP log says it is connected to sta, 'yaga'. Overall observations:

  1. First SPI transaction is complete ('EVENT' in the log). This is Rx path wrt host.
  2. Multiple control path commands worked (Tx,Rx), but sta_connect had not received the response.
  3. I see 'Control response timed out after 30 sec', which is a first problem.
  4. 'Illegal instruction' in the log is second problem.
  5. 'test.out' is expected to be run as superuser, which I hope you are doing.

Can you please let us know -

  1. If there is some delay after loading module and running $ sudo ./test.out <some_command>
  2. If commenting line at https://github.com/espressif/esp-hosted/blob/master/host/linux/host_control/c_support/test_utils.c#L717 and rebuild, rerun of test.out helps?
  3. Is this Raspberry Pi?
  4. Output of $ uname -a command at host
  5. Attach the $ git diff at both the sides, ESP and Linux?
vijay-yaga commented 2 years ago

Hi @mantriyogesh

  1. 1.If there is some delay after loading module and running $ sudo ./test.out

A.we are manually loading the module and after that we are executing the test.out(1 min max) 2.If commenting line at https://github.com/espressif/esp-hosted/blob/master/host/linux/host_control/c_support/test_utils.c#L717 and rebuild, rerun of test.out helps? A.we have commented the 717 line but still same issue occures 3.Is this Raspberry Pi? A.No we are working on our own custom board based on NUC980 4.Output of $ uname -a command at host A.Linux iot 4.4.289 #95 PREEMPT Sat Mar 26 11:20:29 IST 2022 armv5tejl GNU/Linux

mantriyogesh commented 2 years ago

Okay. Understood. From the log,

 ./test.out sta_connect
Enable heartbeat with duration 2
Received INIT event from ESP32 peripheral0

EVENT: 2
EVENT: 1
ESP Reconfigure SPI CLK to 30 MHz
ESP32 peripheral is registered to SPI bus [2],chip select [0], SPI Clock [30]
EVENT: 0
ESP peripheral capabilities: 0x68
Control response timed out after 30 sec
Response not received
1970-01-01 00:04:01 >  App EVENT: ESP INIT
Requested operation complete
Sleeping for some time just to showcase heartbeat
Illegal instruction
mantriyogesh commented 2 years ago

Requested operation complete Sleeping for some time just to showcase heartbeat

process_ctrl_rx_msg:657 msg type: 0x3 msg id: 0x12e CB available for 302 process_ctrl_rx_msg:673: event cb available EVENT: Heartbeat ctrl_app_event_callback:105 processing event 302 2022-04-07 05:59:04 > App EVENT: Heartbeat event [0] ctrl_rx_thread:846 processed ctrl rx msg process_ctrl_rx_msg:657 msg type: 0x3 msg id: 0x12e CB available for 302 process_ctrl_rx_msg:673: event cb available EVENT: Heartbeat ctrl_app_event_callback:105 processing event 302 2022-04-07 05:59:29 > App EVENT: Heartbeat event [1] ctrl_rx_thread:846 processed ctrl rx msg ctrl_app_send_req:1157 Sending req 121 Disable Heartbeat config_heartbeat:158 sync proc for req 121 process_ctrl_rx_msg:657 msg type: 0x2 msg id: 0xdd ctrl_app_parse_resp:294 msgid 221 Success for ctrl resp msg id 221 process_ctrl_rx_msg:746 sync proc for 221 ctrl_rx_ind:616 ctrl_rx_thread:846 processed ctrl rx msg get_response:923 data: 0x76400a78 ctrl_app_resp_callback:452 processing resp 221 Heartbeat operation successful reset_event_callback:1063 event: 301 set_event_callback:1055 event: 301 reset_event_callback:1063 event: 302 set_event_callback:1055 event: 302 reset_event_callback:1063 event: 303 set_event_callback:1055 event: 303 reset_event_callback:1063 event: 304 set_event_callback:1055 event: 304 Exiting..pi@raspberrypi:~/hosted/host/linux/host_control/c_support $

vijay-yaga commented 2 years ago

Hi @mantriyogesh

after making changes in using patch file

./test.out sta_connect set_event_callback:1055 event: 301 set_event_ca Received INIT event from ESP32 peripheralllback:1055 even t: 302 set_evenEVENT: 2 t_callback:1055 EVENT: 1 event: 303 set_ESP Reconfigure SPI CLK to 30 MHz event_callback:1055 event: 304 ctrl_app_send_req:1157 Sending req 121 Enable heartbeat with duration 20 CB available for 302 config_heartbeat:158 sync proc for req 121 ESP32 peripheral is registered to SPI bus [2],chip select [0], SPI Clock [30] EVENT: 0 ESP peripheral capabilities: 0x68 Control response timed out after 30 sec Response not received ctrl_app_resp_callback:439 Failure ctrl_app_send_req:1157 Sending req 107 wifi_connect_ap:104 sync proc for req 107 process_ctrl_rx_msg:657 msg type: 0x3 msg id: 0x12d CB available for 301 process_ctrl_rx_msg:673: event cb available EVENT: ESP INIT ctrl_app_event_callback:105 processing event 301 1970-01-01 00:04:35 > App EVENT: ESP INIT ctrl_rx_thread:846 processed ctrl rx msg Control response timed out after 30 sec Response not received

Requested operation complete Sleeping for some time just to showcase heartbeat ctrl_app_send_req:1157 Sending req 121 Disable Heartbeat config_heartbeat:158 sync proc for req 121 process_ctrl_rx_msg:657 msg type: 0x2 msg id: 0xdd ctrl_app_parse_resp:294 msgid 221 Success for ctrl resp msg id 221 process_ctrl_rx_msg:746 sync proc for 221 ctrl_rx_ind:616 ctrl_rx_thread:846 processed ctrl rx msg get_response:923 data: 0x15f30a0 ctrl_app_resp_callback:453 processing resp 221 Heartbeat operation successful reset_event_callback:1063 event: 301 set_event_callback:1055 event: 301 reset_event_callback:1063 event: 302 set_event_callback:1055 event: 302 reset_event_callback:1063 event: 303 set_event_callback:1055 event: 303 reset_event_callback:1063 event: 304 set_event_callback:1055 event: 304 Exiting..#

mantriyogesh commented 2 years ago

Hello @vijay-yaga Can you please confirm if data ready pin is correctly configured, intact and not loose? To verify this, you can try to add counter in https://github.com/espressif/esp-hosted/blob/master/host/linux/host_driver/esp32/spi/esp_spi.c#L72 and print counter somewhere in user space, if this is getting incremented ?

mantriyogesh commented 2 years ago

Anything worked ahead @vijay-yaga ?

vijay-yaga commented 2 years ago

Hi @mantriyogesh its connecing to wifi now we are working on callback events

mantriyogesh commented 2 years ago

Sure. Can you please educate us what was the issue, might help us in similar situation ahead.

Also please do connect here if you have issues ahead.

vijay-yaga commented 2 years ago

Hi @mantriyogesh thanks for your support data ready pin and Irq pins we are used different we make changes in driver file so its working now

jcormier commented 2 years ago

In short, you need all to point same commit, ESP32 and host.

Thanks. Just got tripped up by this. Ended up checking out the release/v0.4 tag.

Is it recommended to try the master branch for both ESP and ARM code. Or stick with the release?

mantriyogesh commented 2 years ago

Overall, both approaches hold good. Both 0.4 (being latest release) and master are supported.

mantriyogesh commented 2 years ago

@vijay-yaga, Could you please help to close the issue(s) if they are solved as per your expectations?