Skip to content

The same sketch on ESP32 is much bigger than sketch on ESP8266 #1521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
electrical-pro opened this issue Jun 21, 2018 · 4 comments
Closed

The same sketch on ESP32 is much bigger than sketch on ESP8266 #1521

electrical-pro opened this issue Jun 21, 2018 · 4 comments

Comments

@electrical-pro
Copy link

Hardware:

Board: ESP32 vs ESP8266
Core Installation/update date: ESP32 git from 21/jun/2018 vs ESP8266 CoreV2.4.0)
IDE name: Arduino IDE
Flash Frequency: 40Mhz
Upload Speed: 115200

Description:

Sketch on ESP32 is much bigger (about 2 times bigger).
Here is WiFiMulti as an example.

Sketch ESP8266:

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti wifiMulti;

void setup() {
    Serial.begin(115200);
    delay(10);
	
    WiFi.mode(WIFI_STA);
    wifiMulti.addAP("ssid_from_AP_1", "your_password_for_AP_1");
    wifiMulti.addAP("ssid_from_AP_2", "your_password_for_AP_2");
    wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3");

	Serial.println("Connecting Wifi...");
    if(wifiMulti.run() == WL_CONNECTED) {
        Serial.println("");
        Serial.println("WiFi connected");
        Serial.println("IP address: ");
        Serial.println(WiFi.localIP());
    }
}

void loop() {
    if(wifiMulti.run() != WL_CONNECTED) {
        Serial.println("WiFi not connected!");
        delay(1000);
    }
}

RESULT:

Sketch uses 254175 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 33328 bytes (40%) of dynamic memory, leaving 48592 bytes for local variables. Maximum is 81920 bytes

Sketch ESP32:

#include <WiFi.h>
#include <WiFiMulti.h>

WiFiMulti wifiMulti;

void setup()
{
    Serial.begin(115200);
    delay(10);

    wifiMulti.addAP("ssid_from_AP_1", "your_password_for_AP_1");
    wifiMulti.addAP("ssid_from_AP_2", "your_password_for_AP_2");
    wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3");

    Serial.println("Connecting Wifi...");
    if(wifiMulti.run() == WL_CONNECTED) {
        Serial.println("");
        Serial.println("WiFi connected");
        Serial.println("IP address: ");
        Serial.println(WiFi.localIP());
    }
}

void loop()
{
    if(wifiMulti.run() != WL_CONNECTED) {
        Serial.println("WiFi not connected!");
        delay(1000);
    }
}

RESULT:

Sketch uses 537078 bytes (40%) of program storage space. Maximum is 1310720 bytes.
Global variables use 38036 bytes (12%) of dynamic memory, leaving 256876 bytes for local variables. Maximum is 294912 bytes.

537078 bytes vs 254175 byte is pretty big difference.
I doubt that I the first one who noticed this, but I did not find any info about this issue.

@jesse-schein
Copy link

The esp32 does more so it's unfair to think they should be of similar size. All the peripherals and dual core code takes up more space at run time. #1367

The general answer is you have to accept that code compiled on ESP32 will be bigger. Either refactor code or board manufacturers need to use larger flash memory.

@electrical-pro
Copy link
Author

electrical-pro commented Jun 22, 2018

@jesse-schein I understand... but 2 times bigger?
Just curious is it possible to make 2MB or 4MB available for a sketch?, because if I remember correctly there was some limitation 1MB or something for ESP8266 for the sketch...
My ESP32 uses 4MB chip, so I think 2MB for sketch and 2MB for SPIFFS would be fine for me, just dont know how to do it.

Update:
Ok, I see now, it is possible... after I choose ESP32 Dev Module in settings, 2097152 bytes become available.

@lbernstone
Copy link
Contributor

There is a "partition scheme" option in tools if you choose the esp32-dev board. If you are done venting, please close the issue.

@stickbreaker
Copy link
Contributor

@Deimos1994 What is the chance that the reason for the increased memory footprint is that the propitiatory WiFi code is causing the blot. And that the reason for this bloat is espionage? The WiFi code is a feeder system for Chinese Intelligence? Everyone of these IOT devices could be used as spying devices.
Just like how Amazon's Alexa records and forwards conversations.

Chuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants