walmis / blackmagic-espidf

Blackmagic Wireless SWD Debug probe hosted on esp-idf SDK (for ESP8266) with UART on Telnet port and HTTP using xterm.js
255 stars 50 forks source link

Attempting to connect as a Station results in a MAC address error #4

Closed benvonhandorf closed 4 years ago

benvonhandorf commented 4 years ago

This may be a false error if my approach in #3 is not valid, but after implementing that fix I am unable to connect to my wifi network. The system serial output is:

I (315) system_api: Base MAC address is not set, read default base MAC address from EFUSE
I (319) system_api: Base MAC address is not set, read default base MAC address from EFUSE
�phy_version: 1155.0, 6cb3053, Nov 11 2019, 17:31:08, RTOS new
I (469) phy_init: phy ver: 1155_0
I (470) reset_reason: RTC reset 2 wakeup 0 store 4, reason is 2
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x40222e8b  PS      : 0x00000033  A0      : 0x40222e88  A1      : 0x3fffba40  
A2      : 0x00000001  A3      : 0x3ffea750  A4      : 0x00000020  A5      : 0xfffffffe  
A6      : 0x00000000 �������������������������������p����������������������������������I (307) system_api: Base MAC address is not set, read default base MAC address from EFUSE
I (311) system_api: Base MAC address is not set, read default base MAC address from EFUSE
�phy_version: 1155.0, 6cb3053, Nov 11 2019, 17:31:08, RTOS new
I (461) phy_init: phy ver: 1155_0
I (462) reset_reason: RTC reset 2 wakeup 0 store 4, reason is 2
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x40222e8b  PS      : 0x00000033  A0      : 0x40222e88  A1      : 0x3fffba40  
A2      : 0x00000001  A3      : 0x3ffea750  A4      : 0x00000020  A5      : 0xfffffffe  
A6      : 0x00000000  A7      : 0x7fffffff  A8      : 0x00000000  A9      : 0x00000000  
A10     : 0x00000000  A11     : 0x00000059  A12     : 0x00000000  A13     : 0x3fffba4c  
A14     : 0x00000000  A15     : 0x3fffba8c  SAR     : 0x00000000  EXCCAUSE: 0x0000001c  

Backtrace: 0x40222e8b:0x3fffba40 0x4022a870:0x3fffba80 0x4022abb1:0x3fffbaa0 0x4024b4f0:0x3fffbae0 0x4024b699:0x3fffbaf0 0x4024e143:0x3fffbb30 0x4022d02c:0x3fffbb40 0x40222e88:0x3fffbb40 

I'm digging in here and will update this if I find a solution.

benvonhandorf commented 4 years ago

In case it's relevant, here are the chip_id and flash_id results:

~/tools/esp/blackmagic-espidf$ esptool.py --chip esp8266 --port /dev/ttyUSB2 chip_id
esptool.py v3.0-dev
Serial port /dev/ttyUSB2
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 5c:cf:7f:68:22:57
Uploading stub...
Running stub...
Stub running...
Chip ID: 0x00682257
Hard resetting via RTS pin...
~/tools/esp/blackmagic-espidf$ esptool.py --chip esp8266 --port /dev/ttyUSB2 flash_id
esptool.py v3.0-dev
Serial port /dev/ttyUSB2
Connecting......
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 5c:cf:7f:68:22:57
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...
benvonhandorf commented 4 years ago

Got GDB stub in place and working.

0x402232a3 in xQueueGenericSend (xQueue=0x0, pvItemToQueue=pvItemToQueue@entry=0x3fffbfac, xTicksToWait=xTicksToWait@entry=4294967295, xCopyPosition=xCopyPosition@entry=0)
    at /home/benvh/tools/esp/blackmagic-espidf/ESP8266_RTOS_SDK/components/freertos/freertos/queue.c:752
752             if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
(gdb) bt
#0  0x402232a3 in xQueueGenericSend (xQueue=0x0, pvItemToQueue=pvItemToQueue@entry=0x3fffbfac, xTicksToWait=xTicksToWait@entry=4294967295, xCopyPosition=xCopyPosition@entry=0)
    at /home/benvh/tools/esp/blackmagic-espidf/ESP8266_RTOS_SDK/components/freertos/freertos/queue.c:752
#1  0x4022ae2c in sys_mbox_post (mbox=mbox@entry=0x40106a5c <mbox>, msg=msg@entry=0x3fffbfcc) at /home/benvh/tools/esp/blackmagic-espidf/ESP8266_RTOS_SDK/components/lwip/port/esp8266/freertos/sys_arch.c:207
#2  0x4022b16d in tcpip_send_msg_wait_sem (fn=fn@entry=0x4024e460 <lwip_netconn_do_newconn>, apimsg=apimsg@entry=0x3fffc010, sem=0x40107750)
    at /home/benvh/tools/esp/blackmagic-espidf/ESP8266_RTOS_SDK/components/lwip/lwip/src/api/tcpip.c:357
#3  0x4024d524 in netconn_apimsg (fn=0x4024e460 <lwip_netconn_do_newconn>, apimsg=apimsg@entry=0x3fffc010) at /home/benvh/tools/esp/blackmagic-espidf/ESP8266_RTOS_SDK/components/lwip/lwip/src/api/api_lib.c:105
#4  0x4024d6cd in netconn_new_with_proto_and_callback (t=<optimized out>, proto=0 '\000', callback=<optimized out>)
    at /home/benvh/tools/esp/blackmagic-espidf/ESP8266_RTOS_SDK/components/lwip/lwip/src/api/api_lib.c:135
#5  0x4024fedf in lwip_socket (domain=domain@entry=2, type=type@entry=1, protocol=protocol@entry=0) at /home/benvh/tools/esp/blackmagic-espidf/ESP8266_RTOS_SDK/components/lwip/lwip/src/api/sockets.c:1274
#6  0x4022d5e8 in net_uart_task (params=<optimized out>) at /home/benvh/tools/esp/blackmagic-espidf/main/platform.c:149
(gdb) p pxQueue
$1 = (Queue_t * const) 0x0
(gdb) p xQueue
$2 = (QueueHandle_t) 0x0

Looks to me like the xQueueGenericSend is getting called before the queue is initialized in station mode. I'll pick this up tomorrow evening and see if I can make any progress.

benvonhandorf commented 4 years ago

Or maybe I'll put off going to sleep a few more minutes and discover esp_event_loop_init isn't being called when not in AP mode. I'll get a PR together with this and the other STA mode fix once I get everything working end-to-end

benvonhandorf commented 4 years ago

Submitted PR #5. Addresses these issues and others found while getting the BMP up and running as a station.