Unable to run "sta+ap" on my ESP32S

Posted on
  • Here's what happened for my newly flashed ESP32S

    >require("Wifi").getStatus()
    ={ 
      station: "Unknown reason", 
      mode: "AP", 
      powersave: "modem"
     }
    >require("Wifi").save("sta+ap");
    =undefined
    >require("Wifi").getStatus()
    ={ 
      station: "Unknown reason", 
      mode: "AP", 
      powersave: "modem"
     }
    >E.reboot()
    ets Jun  8 2016 00:22:57
    
    rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_d­rv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:2
    load:0x3fff0018,len:4
    load:0x3fff001c,len:2668
    load:0x40078000,len:7304
    load:0x40080000,len:5312
    entry 0x40080274
    E (536) spiram: SPI RAM enabled but initialization failed. Bailing out.
    
     ____                 _ 
    |  __|___ ___ ___ _ _|_|___ ___ 
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v04.3 (c) 2019 G.Williams
    
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    
    WARNING: jswrap_wifi_restore: AP=ESP_4CA4D5
    >require("Wifi").getStatus()
    ={ 
      station: "Unknown reason", 
      mode: "AP", 
      powersave: "modem"
     }
    >process.env
    ={ 
      VERSION: "2v04.3", 
      GIT_COMMIT: "83fba1f3", 
      BOARD: "ESP32", 
      FLASH: 0, RAM: 524288, 
      SERIAL: "3c71bf4c-a4d4", 
      CONSOLE: "Serial1", 
      MODULES: "Flash,Storage,hea" ... "lnetServer,crypto", 
      EXPTR: 1073484860 }
    >
    

    so how to make my ESP32S to support "sta+ap" ?
    This MCU can run both mode when I script it in Arduino, but when I script it in Espruino, it will automatically disconnect station wifi when it has Access point on.

    also, how to fix "E (536) spiram: SPI RAM enabled but initialization failed. Bailing out." ?

    thanks for reading

  • and here's what happened when I try to startAP and also connect wifi:

    >wifi.startAP("test",{authMode:'wpa2',pa­ssword:"88888888"});
    =undefined
    >wifi.connect("xxxx",{password:"xxxxxxxx­"},(err)=>{if (err){print(err);return;}print("connecte­d");});
    ERROR: Wifi: event_handler STA_START: esp_wifi_connect: 12298(SSID is invalid)
    =undefined
    >wifi.getIP()
    ={ 
      ip: "0.0.0.0", 
      netmask: "0.0.0.0", 
      gw: "0.0.0.0", 
      mac: "3c:71:bf:4c:a4:d4"
     }
    WARNING: Wifi:startMDNS - espressif
    connected
    >wifi.getIP()
    ={ 
      ip: "192.168.11.31", 
      netmask: "255.255.240.0", 
      gw: "192.168.1.253", 
      mac: "3c:71:bf:4c:a4:d4"
     }
    >E (774880) event: post event to user fail!
    E (777720) event: post event to user fail!
    E (780562) event: post event to user fail!
    E (783403) event: post event to user fail!
    
    >wifi.getIP()
    ={ 
      ip: "0.0.0.0", 
      netmask: "0.0.0.0", 
      gw: "0.0.0.0", 
      mac: "3c:71:bf:4c:a4:d4"
     }
    >wifi.getDetails()
    ={ 
      status: "NO_AP_FOUND"
     }
    >
    
  • Wed 2019.07.17

    @Unreality, Is this a continuation of the snippets that were provided in #10 at

    http://forum.espruino.com/conversations/­336034/#comment14814269

  • Hi thx for asking, that was ESP8266, now I'm trying ESP32

  • okay, found out that after ESP32S serving as an AP, and connected with a client, then i need to disconnect it and wait for 10+ seconds before change it to station mode and connect to local wifi, however, after a minute or so, it will start to prompt errors :

    E (348565) MDNS_Networking: Cannot allocate memory (line: 34, free heap: 60 bytes)
    E (364028) MDNS: Cannot allocate memory (line: 113, free heap: 32 bytes)
    E (364132) MDNS_Networking: Cannot allocate memory (line: 34, free heap: 60 bytes)
    E (366178) MDNS: Cannot allocate memory (line: 113, free heap: 32 bytes)
    E (374166) MDNS_Networking: Cannot allocate memory (line: 34, free heap: 108 bytes)
    E (470118) MDNS: Cannot allocate memory (line: 113, free heap: 32 bytes)
    E (470425) MDNS: Cannot allocate memory (line: 113, free heap: 32 bytes)
    E (472170) MDNS: Cannot allocate memory (line: 113, free heap: 32 bytes)
    E (485172) MDNS: Cannot allocate memory (line: 113, free heap: 32 bytes)
    E (486402) MDNS: Cannot allocate memory (line: 113, free heap: 32 bytes)
    E (490277) event: post event to user fail!
    WARNING: Wifi:startMDNS - espressif
    WARNING: Wifi:stopMDNS
    
  • Would like to have some help, thanks!

  • Looks like runs out of memory. Are you doing anything that may cause the out of memory or a memory leak?

  • Sorry let me be more specific for this question

    the above snippets are after reset(true)

  • it's not out of memory, as process.memory() still showing a lot of memory available

  • I'm not an expert in ESP32's memory, but AFAIK there is a separate amount of memory for the underlying Espressif RTOS. Used for networking & stuff. And those Cannot allocate memory (line: 34, free heap: 60 bytes) messages seem to be complaining about that heap.

    If you don't use BLE, maybe you can try to disable BLE by calling ESP32.enableBLE(false). That gives more JS vars, maybe some heap too. I must admit, I'm just guessing here...

  • Sounds like heap memory is incredibly low! Not sure what the cause of it could be. Did you try downgrading the firmware to 1v97-1v98? These use an earlier version of the Espressif SDK. Maybe could help -- just guessing.

  • Yes it seems ESP32 wifi station connect eats up all heap memory!

    This is what happened after a reset(true)

    >wifi=require("Wifi")
    =function () { [native code] }
    >wifi.startAP("test",{authMode:'open'});­
    =undefined
    >wifi.connect("xxxx",{password:"xxxxxxxx­"},(err)=>{if (err){print(err);return;}print("connecte­d");});
    ERROR: Wifi: event_handler STA_START: esp_wifi_connect: 12298(SSID is invalid)
    =undefined
    >E (27318) event: post event to user fail!
    ESP32.getState()
    ={ 
      sdkVersion: "v3.1.3-dirty", 
      freeHeap: 33856, BLE: false, Wifi: true, minHeap: 21880 }
    WARNING: Wifi:startMDNS - espressif
    connected
    >ESP32.getState()
    ={ 
      sdkVersion: "v3.1.3-dirty", 
      freeHeap: 3112, BLE: false, Wifi: true, minHeap: 3044 }
    >
    
    

    You can see that the freeHeap dropped dramatically after connecting to the local network!

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

Unable to run "sta+ap" on my ESP32S

Posted by Avatar for Unreality @Unreality

Actions