ivmarkov / rust-esp32-std-demo

Rust on ESP32 STD demo app. A demo STD binary crate for the ESP32[XX] and ESP-IDF, which connects to WiFi, Ethernet, drives a small HTTP server and draws on a LED screen.
Apache License 2.0
784 stars 105 forks source link

Workspace setup issue #78

Closed callmephilip closed 2 years ago

callmephilip commented 2 years ago

@ivmarkov I am not sure if this is the right place to ask this question - please let me know if there is a better place for this

I am trying to reorganize the original project as a workspace in order to isolate part of the code in a library to improve test flow as described in this article. I created a PR to illustrate the approach.

The project builds and flashes correctly, however I get the following exception when running it on the device:

***ERROR*** A stack overflow in task sys_evt has been detected.

Backtrace:0x40082c0a:0x3ffbd6600x40087e15:0x3ffbd680 0x4008afaa:0x3ffbd6a0 0x400898a1:0x3ffbd720 0x40087f14:0x3ffbd750 0x40087ec6:0x00000080  |<-CORRUPTED

ELF file SHA256: 0000000000000000

I am fairly new to embedded development and I found myself stuck at this point. Any suggestion/pointer would be highly appreciated.

Including full log below

Chip type:         ESP32 (revision 1)
Crystal frequency: 40MHz
Flash size:        8MB
Features:          WiFi, BT, Dual Core, 240MHz, Coding Scheme None
MAC address:       30:83:98:71:28:24
[00:00:01] ########################################      16/16      segment 0x1000
[00:00:00] ########################################       1/1       segment 0x8000
[00:01:20] ########################################     775/775     segment 0x10000

Resetting device... done
0, SPIWP:0xee
clk_drv:0x00,q_drets Jun  8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0048,len:12
ho 0 tail 12 room 4
load:0x3fff0054,len:4800
load:0x40078000,len:17448
load:0x4007c428,len:4840
entry 0x4007c6a0
I (589) cpu_start: Pro cpu up.
I (589) cpu_start: Starting app cpu, entry point is 0x40082684
I (0) cpu_start: App cpu up.
I (603) cpu_start: Pro cpu start user code
I (603) cpu_start: cpu freq: 160000000
I (603) cpu_start: Application information:
I (607) cpu_start: Project name:     libespidf
I (613) cpu_start: App version:      1
I (617) cpu_start: Compile time:     Apr 21 2022 12:52:43
I (623) cpu_start: ELF file SHA256:  0000000000000000...
I (629) cpu_start: ESP-IDF:          4b2098b
I (634) heap_init: Initializing. RAM available for dynamic allocation:
I (641) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (647) heap_init: At 3FFB7860 len 000287A0 (161 KiB): DRAM
I (653) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (660) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (666) heap_init: At 400937B0 len 0000C850 (50 KiB): IRAM
I (674) spi_flash: detected chip: generic
I (677) spi_flash: flash io: dio
W (681) spi_flash: Detected size(8192k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (695) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
Hello from Rust!
More complex print ["foo", "bar"]
Result: 0, 1
Rust main thread: Thread { id: ThreadId(1), name: Some("main"), .. }
Main TLS before change: 13
Main TLS after change: 42
This is thread number 0, Thread { id: ThreadId(2), name: None, .. }
Inner TLS: 0
This is thread number 1, Thread { id: ThreadId(3), name: None, .. }
This is thread number 3, Thread { id: ThreadId(5), name: None, .. }
This is thread number 4, Thread { id: ThreadId(6), name: None, .. }
Inner TLS: 4
This is thread number 2, Thread { id: ThreadId(4), name: None, .. }
Inner TLS: 3
Inner TLS: 1
Inner TLS: 2
About to join the threads. If ESP-IDF was patched successfully, joining will NOT crash
Main TLS after threads: 42
Joins were successful.
I (4841) wifi:wifi driver task: 3ffc0970, prio:23, stack:6656, core=0
I (4841) system_api: Base MAC address is not set
I (4841) system_api: read default base MAC address from EFUSE
I (4841) wifi:wifi firmware version: 63017e0
I (4851) wifi:wifi certification version: v7.0
I (4851) wifi:config NVS flash: disabled
I (4851) wifi:config nano formating: disabled
I (4861) wifi:Init data frame dynamic rx buffer num: 32
I (4861) wifi:Init management frame dynamic rx buffer num: 32
I (4871) wifi:Init management short buffer num: 32
I (4871) wifi:Init dynamic tx buffer num: 32
I (4881) wifi:Init static rx buffer size: 1600
I (4881) wifi:Init static rx buffer num: 10
I (4891) wifi:Init dynamic rx buffer num: 32
I (4891) wifi_init: rx ba win: 6
I (4891) wifi_init: tcpip mbox: 32
I (4901) wifi_init: udp mbox: 6
I (4901) wifi_init: tcp mbox: 6
I (4911) wifi_init: tcp tx win: 5744
I (4911) wifi_init: tcp rx win: 5744
I (4911) wifi_init: tcp mss: 1440
I (4921) wifi_init: WiFi IRAM OP enabled
I (4921) wifi_init: WiFi RX IRAM OP enabled
I (4931) esp_idf_svc::wifi: Driver initialized
I (4931) esp_idf_svc::wifi: Event handlers registered
I (4941) esp_idf_svc::wifi: Initialization complete
I (4941) rust_esp32_std_demo: Wifi created, about to scan
I (4951) esp_idf_svc::wifi: About to scan for access points
I (4961) esp_idf_svc::wifi: Stopping
I (4961) esp_idf_svc::wifi: Disconnect requested
I (4971) esp_idf_svc::wifi: Stop requested
I (4971) esp_idf_svc::wifi: About to wait for status
I (4981) esp_idf_svc::wifi: Waiting for status done - success
I (4981) esp_idf_svc::wifi: Stopped
I (4991) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (5101) wifi:mode : sta (30:83:98:71:28:24)
I (5101) wifi:enable tsf
I (5101) esp_idf_svc::wifi: Got wifi event: StaStarted
I (5101) esp_idf_svc::wifi: STA event StaStarted handled, set status: Status(Started(Disconnected), Stopped)
I (7161) esp_idf_svc::wifi: Got wifi event: ScanDone
I (7161) esp_idf_svc::wifi: STA event ScanDone skipped
I (7211) esp_idf_svc::wifi: Found 10 access points
I (7211) esp_idf_svc::wifi: About to get info for found access points
I (7211) esp_idf_svc::wifi: Got info for 10 access points
I (7211) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "acs", bssid: [120, 69, 88, 77, 73, 17], channel: 6, secondary_channel: None, signal_strength: 215, protocols: EnumSet(), auth_method: WPA2Personal }
I (7231) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "acs-guest", bssid: [122, 69, 88, 29, 73, 17], channel: 6, secondary_channel: None, signal_strength: 212, protocols: EnumSet(), auth_method: None }
I (7251) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "ATTff2Buza", bssid: [56, 160, 103, 102, 185, 244], channel: 6, secondary_channel: None, signal_strength: 206, protocols: EnumSet(), auth_method: WPA2Personal }
I (7281) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "ATTff2Buza_Guest", bssid: [56, 160, 103, 102, 185, 245], channel: 6, secondary_channel: None, signal_strength: 206, protocols: EnumSet(), auth_method: WPA2Personal }
I (7301) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "Innovativesteps", bssid: [228, 247, 91, 190, 19, 144], channel: 1, secondary_channel: None, signal_strength: 195, protocols: EnumSet(), auth_method: WPA2Personal }
I (7321) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "DIRECT-C4-HP OfficeJet Pro 8720", bssid: [128, 206, 98, 251, 112, 197], channel: 1, secondary_channel: None, signal_strength: 194, protocols: EnumSet(), auth_method: WPA2Personal }
I (7341) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "DGLumen", bssid: [56, 160, 103, 247, 94, 164], channel: 1, secondary_channel: None, signal_strength: 191, protocols: EnumSet(), auth_method: WPA2Personal }
I (7361) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "ATTfJndGXi", bssid: [132, 187, 105, 148, 232, 64], channel: 1, secondary_channel: None, signal_strength: 182, protocols: EnumSet(), auth_method: WPA2Personal }
I (7381) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "tlef7f38", bssid: [12, 131, 204, 239, 127, 56], channel: 11, secondary_channel: None, signal_strength: 177, protocols: EnumSet(), auth_method: WPA2Personal }
I (7401) esp_idf_svc::wifi: Found access point AccessPointInfo { ssid: "DIRECT-D3C3FADE", bssid: [158, 174, 211, 195, 122, 222], channel: 11, secondary_channel: None, signal_strength: 168, protocols: EnumSet(), auth_method: WPA2Personal }
I (7431) rust_esp32_std_demo: Found configured access point acs on channel 6
I (7441) esp_idf_svc::wifi: Setting configuration: Mixed(ClientConfiguration { ssid: "acs", bssid: None, auth_method: WPA2Personal, password: "u%pg6PBJXgv9q0*edQ3B", channel: Some(6), ip_conf: Some(DHCP(DHCPClientSettings { hostname: None })) }, AccessPointConfiguration { ssid: "aptest", ssid_hidden: false, channel: 6, secondary_channel: None, protocols: EnumSet(P802D11B | P802D11BG | P802D11BGN), auth_method: None, password: "", max_connections: 255, ip_conf: Some(RouterConfiguration { subnet: Subnet { gateway: 192.168.71.1, mask: Mask(24) }, dhcp_enabled: true, dns: Some(8.8.8.8), secondary_dns: Some(8.8.4.4) }) })
I (7491) esp_idf_svc::wifi: Stopping
I (7491) esp_idf_svc::wifi: Disconnect requested
I (7501) wifi:flush txq
I (7501) wifi:stop sw txq
I (7501) wifi:lmac stop hw txq
I (7511) esp_idf_svc::wifi: Stop requested
I (7511) esp_idf_svc::wifi: Got wifi event: StaStopped
I (7521) esp_idf_svc::wifi: STA event StaStopped handled, set status: Status(Stopped, Stopped)
I (7531) esp_idf_svc::wifi: Stopped
I (7531) esp_idf_svc::wifi: Wifi mode APSTA set
I (7541) esp_idf_svc::wifi: Setting STA configuration: ClientConfiguration { ssid: "acs", bssid: None, auth_method: WPA2Personal, password: "u%pg6PBJXgv9q0*edQ3B", channel: Some(6), ip_conf: Some(DHCP(DHCPClientSettings { hostname: None })) }
I (7561) esp_idf_svc::wifi: Setting STA interface configuration: InterfaceConfiguration { key: "WIFI_STA_DEF", description: "sta", route_priority: 100, ip_configuration: Client(DHCP(DHCPClientSettings { hostname: None })), interface_stack: Sta }
I (7581) esp_idf_svc::wifi: STA IP configuration done
I (7591) esp_idf_svc::wifi: STA configuration done
I (7591) esp_idf_svc::wifi: Setting AP configuration: AccessPointConfiguration { ssid: "aptest", ssid_hidden: false, channel: 6, secondary_channel: None, protocols: EnumSet(P802D11B | P802D11BG | P802D11BGN), auth_method: None, password: "", max_connections: 255, ip_conf: Some(RouterConfiguration { subnet: Subnet { gateway: 192.168.71.1, mask: Mask(24) }, dhcp_enabled: true, dns: Some(8.8.8.8), secondary_dns: Some(8.8.4.4) }) }
I (7631) esp_idf_svc::wifi: Setting AP interface configuration: InterfaceConfiguration { key: "WIFI_AP_DEF", description: "ap", route_priority: 10, ip_configuration: Router(RouterConfiguration { subnet: Subnet { gateway: 192.168.71.1, mask: Mask(24) }, dhcp_enabled: true, dns: Some(8.8.8.8), secondary_dns: Some(8.8.4.4) }), interface_stack: Ap }
I (7661) esp_idf_svc::wifi: AP IP configuration done
I (7671) esp_idf_svc::wifi: AP configuration done
I (7671) esp_idf_svc::wifi: Starting with status: Status(Starting, Starting)
I (7681) esp_idf_svc::wifi: Status is of operating type, starting
I (7691) wifi:mode : sta (30:83:98:71:28:24) + softAP (30:83:98:71:28:25)
I (7691) wifi:enable tsf
I (7701) wifi:Total power save buffer number: 16
I (7701) wifi:Init max length of beacon: 752/752
I (7701) wifi:Init max length of beacon: 752/752
I (7711) esp_idf_svc::wifi: Start requested
I (7711) esp_idf_svc::wifi: STA netif status: EspNetif(EspNetifStack(PrivateData), 0x3ffc5968), index: 1, name: lo0, ifkey: WIFI_STA_DEF
I (7731) esp_idf_svc::wifi: AP netif status: EspNetif(EspNetifStack(PrivateData), 0x3ffc5cdc), index: 1, name: lo0, ifkey: WIFI_AP_DEF
I (7741) esp_idf_svc::wifi: Got wifi event: StaStarted
I (7741) esp_idf_svc::wifi: Reconnecting
I (7751) esp_idf_svc::wifi: STA event StaStarted handled, set status: Status(Started(Connecting), Starting)
I (7761) wifi:new:<6,1>, old:<6,1>, ap:<6,1>, sta:<6,0>, prof:6
I (8511) wifi:state: init -> auth (b0)
I (8511) esp_idf_svc::wifi: Got wifi event: ApStarted
I (8511) esp_idf_svc::wifi: STA event ApStarted handled, set status: Status(Started(Connecting), Started(Done))
I (8521) wifi:state: auth -> assoc (0)
I (8521) esp_idf_svc::wifi: Configuration set
I (8531) wifi:state: assoc -> run (10)
I (8531) rust_esp32_std_demo: Wifi configuration set, about to get status
I (8541) esp_idf_svc::wifi: About to wait 20s for status
I (8551) wifi:connected with acs, aid = 1, channel 6, BW20, bssid = 78:45:58:4d:49:11
I (8551) wifi:security: WPA2-PSK, phy: bgn, rssi: -41
I (8561) wifi:pm start, type: 1
I (8561) esp_idf_svc::wifi: Got wifi event: StaConnected
I (8561) esp_idf_svc::wifi: STA event StaConnected handled, set status: Status(Started(Connected(Waiting)), Started(Done))
I (8581) wifi:AP's beacon interval = 102400 us, DTIM period = 1
W (8611) wifi:<ba-add>idx:0 (ifx:0, 78:45:58:4d:49:11), tid:6, ssn:1, winSize:64
I (9321) esp_idf_svc::wifi: Got STA IP event: DhcpIpAssigned(DhcpIpAssignment { netif_handle: 0x3ffc5968, ip_settings: ClientSettings { ip: 192.168.0.217, subnet: Subnet { gateway: 192.168.0.1, mask: Mask(24) }, dns: None, secondary_dns: None }, ip_changed: true })
I (9331) esp_idf_svc::wifi: STA IP event DhcpIpAssigned(DhcpIpAssignment { netif_handle: 0x3ffc5968, ip_settings: ClientSettings { ip: 192.168.0.217, subnet: S
***ERROR*** A stack overflow in task sys_evt has been detected.

Backtrace:0x40082c0a:0x3ffbd6600x40087e15:0x3ffbd680 0x4008afaa:0x3ffbd6a0 0x400898a1:0x3ffbd720 0x40087f14:0x3ffbd750 0x40087ec6:0x00000080  |<-CORRUPTED

ELF file SHA256: 0000000000000000
Rebooting...
ivmarkov commented 2 years ago

It crashes because you need to move all sdkconfig.defaults* files into the root of your workspace. Otherwise they are not picked up and the tasks run with too little stack size.

ivmarkov commented 2 years ago

... and clean + rebuild after that.

callmephilip commented 2 years ago

@ivmarkov thank you very much for the quick response! moving configs did the trick. thank you. here's a link to the updated code for posterity - https://github.com/bakery/rust-esp32-std-demo/tree/workspace-setup