Sming - Open Source framework for high efficiency native ESP8266 development

User avatar
By anakod
#17280
I spent part of yesterday and today trying to sort out why a previously-running Sming app wouldn't connect. Turns out it was because I had updated my dev system to 2.03, which meant I no longer had version esp_iot_sdk_v1.0.1_b1 of the SDK. I downloaded this SDK from Espressif, replaced the SDK in my dev area with it... and boom! my project worked again.

Yes, it realted to Open LWIP issue: https://github.com/kadamski/esp-lwip/issues/7

New Sming update
    * Full crossplatform support: Windows, Mac, Linux
    * Useful WiFi network configuration example was added: HttpServer_ConfigNetwork
    * Many code optimizations and improovements
User avatar
By piontec
#17294 Hi Sming developers!

First of all, this project is really great!

Nevertheless, I'm trying to use it and I'm struggling with few things - I'll be really greatful for some help and/or answers :)

TL;DR: don't know how to make it shorter, just make yourself a coffee and try reading ;)

1) Can we use Spiffy to build spiffs image and flash it directly, without starting the FTP server? If yes, what is the correct address to flash spiffs image to?

2) Does anyone have a good explanaition/link/description of what ICACHE_FLASH_ATTR actually does? As far as i understand, it maps some part of RAM addresses into the flash chip space, so there is an impression, that esp8266 has more RAM for code. But why is also (nearly) everyone using "static" for all functions and variables? Is there any rationale to do that? As far as I read here, sming uses ICACHE_FLASH_ATTR for all methods and I have to specify IRAM_ATTR when I want somethig put really in RAM. Should I also put a callback for WifiStation.scan callback to RAM with that attribute? I'm asking, because I have some strange behaviour when trying to write a web network configuration GUI (just like the one you commited yesterday :D, only without FTP server)

3) Can someone please write a few words about memory management? For example, a BssList list in scan callback - should I delete it or deallocate memory it has reserved for SSID strings internally? I'm asking, because I'm having a lot of "critical exceptions" when testing my software: the chip just writes about a critical exception, writes out a serios of 0x000000 registers and resets by watchdog. I don't have an axample right now, but I can post one later, if it helps.

4) WDT specification - what is the default timeout of watchdog?

5) I have a strange problem with memory when trying to format a JSON reply with scan results. The code is like:
Code: Select allvoid onAjaxGetScan(HttpRequest &request, HttpResponse &response)
{
    debug_print("Got get scan request\r\n");
    JsonObjectStream* stream = new JsonObjectStream();
    JsonObject& json = stream->getRoot();
    json["scanInProgress"] = scanInProgress;
   
    if (scanInProgress)
    {
        debug_print ("scan in progress, finishing\r\n")
        response.sendJsonObject(stream);
        return;
    }
   
    JsonArray & arr = json.createNestedArray("networks");
   
    for (int i = 0; i < scanResult->count(); i++)
    {
        BssInfo bss = scanResult->elementAt(i);
        Serial.println ("JSONing for ssid %s " + bss.ssid);
        JsonObject & obj = arr.createNestedObject();
       
        obj ["authName"] = bss.getAuthorizationMethodName();
        obj ["open"] = bss.isOpen();
        obj ["channel"] = bss.channel;
        obj ["hidden"] = bss.hidden;
        obj ["rssi"] = bss.rssi;
        obj ["ssid"] = bss.ssid;
    }
   
    response.sendJsonObject(stream);
}


The debug code, which writes SSIDs on serial, works as expected -- all networks are correctly displayed. But in the return JSON there's total havoc - SSIDs show random strings form memory, like parts of the HTTP response - it looks like the memory used by obj ["ssid"] = bss.ssid; is also used by someone else or freed to early. What am I doing wrong?

Thanks in advance for any help!
User avatar
By alonewolfx2
#17312 1-) yes you can use with specified spiffy version in my repo. or just you can download lastest sming code from github and update spiffy version with choco. here is my repo link. https://github.com/alonewolfx2/spiffy/tree/sming
also we have automatic fs create and upload method in makefile now.


..
..
..
Thanks in advance for any help![/quote]
User avatar
By Markus Gritsch
#17320
piontec wrote:2) Does anyone have a good explanaition/link/description of what ICACHE_FLASH_ATTR actually does?

Read theese two excellent comments, they helped me to understand it a bit better:
http://tech.scargill.net/memory-use-esp ... mment-1213
http://tech.scargill.net/memory-use-esp ... mment-1214
And yes the Sming linker script is modified so that all function go per default into flash and not consume IRAM.