Available flash memory

Hi! I’m just starting with PlatformIO and I’m trying to use it to write code for ESP-01 module with 1MB of flash. I just created a new project using the esp01_1m board and it’s almost empty. However the build output reads:

DATA:    [====      ]  36.3% (used 29754 bytes from 81920 bytes)
PROGRAM: [=======   ]  73.9% (used 278664 bytes from 376832 bytes)

My concern here is with the total available PROGRAM space. Where is that 376832 bytes coming from? Shouldn’t say I have 1MB of total memory in the board?

Best,
Juan

Hm… something fishy going on here…

With the 2.6.2 esp8266 arduino core (platform-espressif8266 version is 2.3.1)…

[env:esp01_1m]
platform = espressif8266@2.3.1
board = esp01_1m
framework = arduino

… and …

#include <Arduino.h>

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
}

void loop() {
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  delay(500);
}

… I get …

RAM:   [===       ]  32.7% (used 26812 bytes from 81920 bytes)
Flash: [===       ]  33.6% (used 255752 bytes from 761840 bytes)

which looks to be correct, as the .ld script used by default for that board type defines the memory layout like this…
image

Can you double check your board is specified as esp01_1m in your platformio.ini and that you aren’t using a different linker-script via a build flag? (i.e. using one of the other memory layouts provided)

Thanks for replying!
I’m sorry, I should have mention that I’m not using Arduino. Here’s my platform.io file:

[env:esp01_1m]
platform = espressif8266
board = esp01_1m
framework = esp8266-rtos-sdk

I didn’t set any custom build flag. Also I don’t know what those .ld files are, so any link to learn about them is welcome!

What I can see is that these are all the .ld files I have in my .platformio directory, and none of them have the same name specified within the .json file. Do this mean something to you?

.platformio $ find . -name *.ld
./packages/framework-esp8266-rtos-sdk/ld/eagle.app.v6.new.1024.app2.ld
./packages/framework-esp8266-rtos-sdk/ld/eagle.app.v6.ld
./packages/framework-esp8266-rtos-sdk/ld/eagle.app.v6.new.2048.ld
./packages/framework-esp8266-rtos-sdk/ld/eagle.app.v6.common.ld
./packages/framework-esp8266-rtos-sdk/ld/eagle.app.v6.new.512.app2.ld
./packages/framework-esp8266-rtos-sdk/ld/eagle.app.v6.new.512.app1.ld
./packages/framework-esp8266-rtos-sdk/ld/eagle.app.v6.new.1024.app1.ld
./packages/framework-esp8266-rtos-sdk/ld/eagle.rom.addr.v6.ld
./packages/tool-esptoolpy/flasher_stub/ld/rom_8266.ld
./packages/tool-esptoolpy/flasher_stub/ld/rom_32.ld
./packages/tool-esptoolpy/flasher_stub/ld/stub_8266.ld
./packages/tool-esptoolpy/flasher_stub/ld/stub_32.ld

lol… oops!

Hm… don’t know anything about that… I seem to remember people mentioning some partition.csv file, but that could be in relation to ESP-IDF or ESP32? You could try a stab in the dark, and try a different linker file… i.e. build_flags = -Wl,-Teagle.app.v6.new.1024.app1.ld … but it would be better to wait to see what others familar with esp8266-rtos-sdk have to say.

@manuelbl Is this your territory?

ESP-RTOS-SDK is linked with

This file states

/* eagle.flash.bin     @ 0x00000 */
/* eagle.irom0text.bin @ 0x20000 */

/* Flash Map, support 512KB/1MB/2MB/4MB SPI Flash */
/* |......|..............................|..........................|.....|....|                       */
/* ^      ^                              ^                          ^     ^                            */
/* |_flash.bin start(0x0000)             |_irom0text.bin start(0x20000)   |                            */
/*        |_flash.bin end                                           |_irom0text.bin end                */
/*                                                                        |_system param area(0x7b000) */

/* NOTICE: */ 
/* 1. You can change irom0 org, but MUST make sure irom0text.bin start not overlap flash.bin end.   */
/* 2. You can change irom0 len, but MUST make sure irom0text.bin end not overlap system param area. */
/* 3. Space between flash.bin end and irom0text.bin start can be used as user param area.           */
/* 4. Space between irom0text.bin end and system param area can be used as user param area.         */
/* 5. Make sure irom0text.bin end < 0x100000                                                        */
/* 6. system param area:                                                                            */
/*    1>. 512KB--->0x07b000                                                                         */
/*    2>. 1MB----->0x0fb000                                                                         */
/*    3>. 2MB----->0x1fb000                                                                         */
/*    4>. 4MB----->0x3fb000                                                                         */
/* 7. Don't change any other seg.                                                                   */

MEMORY
{
  dport0_0_seg :                      	org = 0x3FF00000, len = 0x10
  dram0_0_seg :                       	org = 0x3FFE8000, len = 0x18000
  iram1_0_seg :                       	org = 0x40100000, len = 0x8000
  irom0_0_seg :                       	org = 0x40220000, len = 0x5C000
}

INCLUDE "../ld/eagle.app.v6.common.ld"`

So in this flash layout your IROM0 space for the code has len = 0x5C000 aka 376832 bytes, which is exactly the message you’re getting.

2 Likes