ESP32-C3 WiFi connection error

Posted on
  • The ESP32-C3 WIFI connection code I am using is:

    var wifi = require("Wifi");
    var ssid = 'FOFStudioWifi';
    var password = 'FOFStudioWifiQQ';
    wifi.connect(ssid, {password: password}, function() {
        
    });
    

    The ESP32-C3 firmware I am using is:https://www.espruino.com/binaries/travis/master/

    ERRER:
    assert failed: jsvUnLockInline jsvar.c:865 (jsvGetLocks(var)>0)
    Core 0 register dump:
    MEPC : 0x403808c0 RA : 0x4038d64e SP : 0x3fcbd4d0 GP : 0x3fc98e00
    TP : 0x3fc7c170 T0 : 0x37363534 T1 : 0x7271706f T2 : 0x33323130
    S0/FP : 0x00000088 S1 : 0x00000001 A0 : 0x3fcbd50c A1 : 0x3fc9a9dd
    A2 : 0x00000001 A3 : 0x00000029 A4 : 0x00000001 A5 : 0x3fca0000
    A6 : 0x7a797877 A7 : 0x76757473 S2 : 0x00000009 S3 : 0x3fcbd61f
    S4 : 0x3fc9a9dc S5 : 0x00000003 S6 : 0x00000000 S7 : 0x3fcbd790
    S8 : 0x00000000 S9 : 0x4200de20 S10 : 0x00000000 S11 : 0x00000000
    T3 : 0x6e6d6c6b T4 : 0x6a696867 T5 : 0x66656463 T6 : 0x62613938
    MSTATUS : 0x00001881 MTVEC : 0x40380001 MCAUSE : 0x00000007 MTVAL : 0x00000000
    MHARTID : 0x00000000
    Stack memory:
    3fcbd4d0: 0x00000000 0x3fcbd541 0x3c178494 0x40394ff0 0x3fc9ab1c 0x3c178494 0x3fc9af0c 0x3c17918d
    3fcbd4f0: 0x3fc9ab2c 0x3fcbd504 0x3fc9ab30 0x3c179828 0x3fc9a9dc 0x00353638 0x420261d0 0x65737361
    3fcbd510: 0x66207472 0x656c6961 0x6a203a64 0x6e557673 0x6b636f4c 0x696c6e49 0x6a20656e 0x72617673
    3fcbd530: 0x383a632e 0x28203536 0x4776736a 0x6f4c7465 0x28736b63 0x29726176 0x0029303e 0x4202aa18
    3fcbd550: 0x00000000 0x00000016 0x00000004 0x420261d0 0x00000000 0x3fcbd5d1 0x3fcbd5d0 0x42026192
    3fcbd570: 0x00000004 0x00000000 0x420261d0 0x420261b6 0x00000001 0x3c180825 0x00000000 0x420261d8
    3fcbd590: 0x00008105 0x00000003 0x3fcbd6f9 0x00000013 0x00000014 0x3fcbd6f8 0x3fcc9d50 0x42013200
    3fcbd5b0: 0x0000000a 0x3fcc9d42 0x3fcbd5dc 0x4201b5e2 0x3fcc9d42 0x3fcbd6f8 0x00000020 0x42017002
    3fcbd5d0: 0x00000003 0x00000000 0x00000000 0x00000000 0x00000000 0x0000000d 0x3fcc9da4 0x00000000
    3fcbd5f0: 0x3fcc9d42 0x3fcc9da4 0x3fcc8bd0 0x420131fa 0x3fcc9d42 0x3fcc9da4 0x3fcc9d5e 0x4200de6a
    3fcbd610: 0x00000001 0x00000005 0x00000000 0x00000000 0x3fcc9da4 0x3fcc9e22 0x3fcc9e06 0x42013200
    3fcbd630: 0x3fcc9da4 0x3fcc9cd2 0x3fcc9e06 0x42017b3a 0x3fcc9e14 0x00000005 0x00000000 0x00000000
    3fcbd650: 0x3fcc9da4 0x0000007d 0x0000007d 0x42045a52 0x3fcc9da4 0x00000000 0x00000086 0x42046f3e
    3fcbd670: 0x3fcc9da4 0x00000000 0x00000086 0x42020392 0x0000000a 0x00000000 0x00000069 0x0000008a
    3fcbd690: 0x00000000 0x3fcc8a8e 0x3fcc8a9c 0x00000063 0x00000010 0x3fcc8a3a 0x00000000 0x3fcbd790
    3fcbd6b0: 0x00000000 0x00000000 0x3fcc9da4 0x420203e0 0x00000000 0x000000aa 0x000000aa 0x4201f5d6
    3fcbd6d0: 0x00000000 0x3fcc9d42 0x3fcc9d42 0x42013200 0x00000001 0x3fcc9d42 0x3fcc9d34 0x53464f46
    3fcbd6f0: 0x69647574 0x6669576f 0x00000069 0x3fcbd790 0x00000000 0x000000aa 0x000000aa 0x4201f748
    3fcbd710: 0x00000003 0x00000003 0x00000000 0x420477f4 0x00000000 0x3fcc8a3a 0x00000000 0x3fcbd790
    3fcbd730: 0x3fcc9d42 0x3fcc9d5e 0x3fcc9da4 0x3fcbd790 0x00000010 0x3fcc8a3a 0x00000007 0x420175bc
    3fcbd750: 0x3fcc9d18 0x00000002 0x00000000 0x3fcbd790 0x3fcc9d18 0x00000001 0x00000003 0x3fcbd790
    3fcbd770: 0x00000010 0x3fcc8a3a 0x3fcc87a8 0x00000003 0x3fcc9d18 0x4200de20 0x3fcbd8a0 0x42022e82
    3fcbd790: 0x3fcc9d42 0x3fcc9d5e 0x3fcc9da4 0x3fcc9d50 0x00000000 0x3fcbd970 0x3fcc9d26 0x3fcc8a3a
    3fcbd7b0: 0x3fcc9d18 0x00000028 0x00000028 0x42046206 0x00000000 0x00000001 0x3fcbd8a0 0x42046f3e
    3fcbd7d0: 0x00000000 0x00000001 0x3fcbd8a0 0x42022bec 0x3fcc8914 0x3fcbd970 0x3fcc9d18 0x3fcc9d26
    3fcbd7f0: 0x3fcc9d34 0x00000000 0x3fcc9d34 0x42013200 0x3fcc9d34 0x3fcc9d34 0x3fcc9d26 0x42014d68
    3fcbd810: 0x00000001 0x3fcbd970 0x3fcc9d18 0x3fcbd970 0x3fcc9d26 0x3fcc9d26 0x3fcc9d18 0x42013c10
    3fcbd830: 0x3fcc9d26 0x3fcc8a3a 0x3fcc9d26 0x4201e97a 0x00000000 0x00000080 0xfffffff3 0x3fcc8a3a
    3fcbd850: 0x00000001 0x3fcbd970 0x3fcc9d26 0x3fcbd8ac 0x3fcc88f8 0x00000080 0x00000189 0x00000000
    ELF file SHA256: ebacf89e19576d86
    Rebooting...
    ESP-ROM:esp32c3-api1-20210207
    Build:Feb 7 2021
    rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
    Saved PC:0x403806ba
    SPIWP:0xee
    mode:DIO, clock div:1
    load:0x3fcd5810,len:0x1684
    load:0x403cc710,len:0x934
    load:0x403ce710,len:0x2e74
    entry 0x403cc710
    ;32mI (15) boot: ESP-IDF v4.4.7 2nd stage bootloaderm
    ;32mI (15) boot: compile time 10:07:49m
    ;32mI (15) boot: chip revision: v0.4m
    ;32mI (17) boot.esp32c3: SPI Speed : 80MHzm
    ;32mI (22) boot.esp32c3: SPI Mode : DIOm
    ;32mI (26) boot.esp32c3: SPI Flash Size : 4MBm
    ;32mI (31) boot: Enabling RNG early entropy source...m
    ;32mI (37) boot: Partition Table:m
    ;32mI (40) boot: ## Label Usage Type ST Offset Lengthm
    ;32mI (47) boot: 0 nvs WiF

  • Due to my poor English, it is often difficult to ask questions; Please help us answer this question
    Thank you again to the ESPRUINO community

  • I am definitely not an Espruino codebase nor an ESP32 expert, but from what I see in the source, it seems that a null pointer is passed to jsvUnLockInline --> https://github.com/espruino/Espruino/blob/ff487e008472deff8113a32ebd3217dbd606405c/src/jsvar.c#L860

    It won't help you directly, I'm sure, but it might help others identify your problem and guide you to a solution.

  • Hello, thank you for your answer. We have just started researching ESPRUINO, and it may be a bit difficult to compile the firmware ourselves

  • If you compile by yourself it will allow you to generate an ELF file, that you can use following this quick explanation to have more clue on what is happening

  • We have been troubled by this issue for some time now, and we hope that technical experts can provide updates to solve the WiFi problem
    I sincerely hope that ESPRUINO can flourish and we will also donate to ESPRUINO in the future

  • Thank you for your answer. Although I currently do not have the ability to compile firmware; But still thank you for your answer; I will try my best to wait and see if there are any technical experts who can help solve this problem

  • For the time being, if you need to use Espruino with WiFi on ESP32, I strongly recommend you to use one version of the chip which is already well supported (see this table, 1st column)

  • Thank you for your answer. The main reason is that our company currently chooses the ESP32-C3 board; And currently, ESPRUINO happens to support this board; That's why I chose ESPRUINO.
    ESPRUINO is a very good product, and I hope some experts can take a look at the WiFi issue with C3

  • Espruino doesn't officially support ESP32-C3, everything which is provided is gracefully brought by @Gordon and the community. It may take several months until a stable firmware can be deployed on ESP32-C3. That said, if your company is keen to support Espruino, you could find a way on this page: http://www.espruino.com/Business

  • Hi @user158605 this is a known issue, check the workaround for this.

  • Hi, thank you for your answer. However, the WiFi connection code did not trigger a callback

  • After our verification, the wifi is indeed unable to connect, and there is no callback output when connecting to wifi; It seems that we can only wait for @Gordon to take a look

  • In this case I guess you are already connected, check with wifi.getState()

  • Thank you for your answer. We have tested it; Command cannot be used correctly
    We also checked the connection information of the router and did not see any devices successfully connected

    var WIFI_NAME = "123";
    var WIFI_OPTIONS = { password : "123456789" };
    
    var wifi = require("Wifi");
    wifi.scan(function (err, networks) {
        console.log(err, networks);
        wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) {
          if (err) {
            console.log("Connection error: "+err);
            return;
          }
          console.log("Connected!");
        });
    });
    
    setTimeout(function() {
      console.log(wifi.getState());
    },4000)
    

    1 Attachment

    • Xnip2024-08-15_13-56-44.jpg
  • I just took a quick look at this - I'm afraid I don't have much time now.

    Has anyone else got WiFi working? I'm sure I did test this originally and it worked, so I'm not sure what's up....

    Compiling with the WiFi info (commenting out esp_log_level_set("*", ESP_LOG_VERBOSE)) and enabling jsDebug I see:

    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:jswrap_wifi_connect: entry
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:jswrap_wifi_connect: SSID, password, Callback done
    I (3420) wifi:mode : sta (34:b7:da:fb:4b:68) + softAP (34:b7:da:fb:4b:69)
    I (3420) wifi:enable tsf
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:wifiReasonToString 2
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:Wifi: Event(2):SYSTEM_EVENT_STA_START
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:wifiErrorToString 12298
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:Wifi: event_handler STA_START: esp_wifi_connect: 12298(SSID is invalid)
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:jswrap_wifi_connect: esi_wifi_set_mode done
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:jswrap_wifi_connect: esp_wifi_set_config done
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:jswrap_wifi_connect: esp_wifi_start Tea
    =undefined
    >I (4230) wifi:ap channel adjust o:1,1 n:4,1
    I (4230) wifi:new:<4,1>, old:<1,1>, ap:<4,1>, sta:<4,1>, prof:1
    I (4540) wifi:state: init -> auth (b0)
    I (5540) wifi:state: auth -> init (200)
    I (5540) wifi:new:<4,0>, old:<4,1>, ap:<4,1>, sta:<4,1>, prof:1
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:wifiReasonToString 5
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:Wifi: Event(5):SYSTEM_EVENT_STA_DISCONNECTED
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:wifiReasonToString 2
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:wifiGetEvent: Got event: 5
    [/home/gw/workspace/Espruino/libs/network/esp32/jswrap_esp32_network.c]:sendWifiEvent [#ondisconnected](https://forum.espruino.com/search/?q=%23ondisconnected)
    

    So it's actually just not connecting as far as I can tell (rather than Espruino having some issue and not reporting it).

    To try and get enough space in the IRAM I did change some things in targets/esp32/IDF4/sdkconfig_c3 - possibly CONFIG_ESP_WIFI_IRAM_OPT based on https://docs.espressif.com/projects/esp-idf/en/stable/esp32c3/api-guides/performance/ram-usage.html#optimizing-iram-usage - and I wonder if that affected Wifi stability?

    BUT PLEASE STOP POSTING THE SAME THING MULTIPLE TIMES - just post a new thread (like this) for each issue you encounter. The more duplicate things I have to go through the more time is wasted that I could be using fixing stuff

  • It is definitly working! This is also an issue on ESP32 devices and even with earlier IDF version like 3.x.

    Edit:

    Ok, this is only true for ESP32_IDF4

    ESP32C3_IDF4 latest build does not connect anymore to an AP

    Event-> disconnected: {.......,"reason":"2","msg":"AUTH_EXPIRE"}
    
  • Try this

    // Test ESP32 WiFi event callbacks
    var ssid="<SSID>";
    var password="<PASSWORD>";
    
    var wifi=require("Wifi");
    
    wifi.on("associated", function(details) {
    	console.log("  Event-> associated: " + JSON.stringify(details));
    });
    wifi.on("connected", function(details) {
    	console.log("  Event-> connected: " + JSON.stringify(details));
    });
    wifi.on("disconnected", function(details) {
    	console.log("  Event-> disconnected: " + JSON.stringify(details));
    });
    wifi.on("auth_change", function(details) {
    	console.log("  Event-> auth_change: " + JSON.stringify(details));
    });
    wifi.on("dhcp_timeout", function(details) {
    	console.log("  Event-> dhcp_timeout: " + JSON.stringify(details));
    });
    wifi.on("probe_recv", function(details) {
    	console.log("  Event-> probe_recv: " + JSON.stringify(details));
    });
    wifi.on("sta_joined", function(details) {
    	console.log("  Event-> sta_joined: " + JSON.stringify(details));
    });
    wifi.on("sta_left", function(details) {
    	console.log("  Event-> sta_left: " + JSON.stringify(details));
    });
    
    level = 0;
    wifi.stopAP(()=> {
      level ++;
      print("I stoped AP", level);
      wifi.disconnect(()=>{
        level ++;
        print("II disconnect station", level);
        wifi.connect(ssid, {password: password}, function() {
          level ++;
    	    console.log("III Connect completed", level);
        });
      });
    });
    
  • Has anyone else got WiFi working? I'm sure I did test this originally and it worked, so I'm not sure what's up...

    Yes it worked before, but now its broken for ESP32C3_IDF4

  • Yes, we have been testing for a long time; It has indeed been effective; Unable to connect properly

  • Check my recent update on https://forum.espruino.com/conversations/395499/?offset=125#comment17502762

    Are you using "supermini" boards? It seems these boards are just broken and WiFi doesn't work reliably on them. But if not, using wifi.stopAP() first (or using the latest build that does it automatically) may help

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

ESP32-C3 WiFi connection error

Posted by Avatar for user158605 @user158605

Actions