Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Cellie
#41209 Hello all!

Got my feet wet with an Arduino a couple of weeks back and then discovered the esp8266 (by accident) and am now totally hooked.
I use the Arduino IDE with the add-on for esp8266 development.
Works like a dream. Kudos to all those involved.

But......

Why does the add-on for esp8266 use so much memory?

Compiling a barebone sketch for an Arduino Uno:Image
Compiling the same sketch for a Sparkfun esp8266 WiFi Shield:Image

And when I ran some code on my esp8266 to show memory use at runtime another thing caught my eye:

Code: Select allvoid setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println();
  Serial.println("Flash memory:     "+String(ESP.getFlashChipSize())+" Bytes.");
  Serial.println("Free heap memory: "+String(ESP.getFreeHeap())+" Bytes.");
  Serial.println("Chip speed:       "+String(ESP.getFlashChipSpeed())+" Hz.");
 
}
void loop() {
  // put your main code here, to run repeatedly:
  while( 1==1) {
    delay(10);
  }
}


Outputs this:
Code: Select allFlash memory:     524288 Bytes.
Free heap memory: 46080 Bytes.
Chip speed:       40000000 Hz.


So my Sparkfun WiFi Shield is running at 40Mhz?
I thought these chips ran at 80Mhz or 160Mhz, according to the datasheet.
And in the Arduino IDE there are only options for 80/160Mhz for this board.

Also, 500KB of mem, of which only 46KB are free?
What's up with that?

Am I confusing Flash and RAM or EEPROM here?
Please enlighten me!
User avatar
By damage31
#41568 First - don't worry about sketch size just yet. There's more room that you think. Some things to note about your post if you look at the 2nd image you posted would be that you still have ~200K of room for raw code, and another ~48K for more variables.

If you search around for Memory Map, there's lots of posts you will see with a lot of good info about the why's/how's on where things are put - I was going to post up a link to a nice webpage I saw a few days ago showing the flash layout but alas, I cant find it at the moment. Google around and you'll see lots of info on how the memory on the device is laid out.

And a tidbit about the first 200K being used by the sketch, remember this: there is a RTOS running the device that is taking the vast majority of the sketch size, and that's just how it is. What we think normally of as the sketch, is actually only a tiny fraction of the overall code that is running on the device keeping it operating.
User avatar
By cicciocb
#41570 Hi,
Take into account that there are 2 chip frequencies :
The first is the Cpu speed that can be selected to 80 or 160 Mhz in the ide
The second is the Flash speed that can be also selected to 40 or 80 Mhz in the ide.
The size of the available flash is function of the memory chip installed in the module;
It can be 512kb, 1M, 2M, 4M and maybe more.
The size of the available Ram is fixed to 80Kb.

Regards