Size overflow issue in IRAM: Not enough place for my own program <SOLVED by Angus>

User avatar
fasani
Posts: 195
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Size overflow issue in IRAM: Not enough place for my own program <SOLVED by Angus>

Postby fasani » Tue Jul 13, 2021 10:22 am

Hi there,
I've find out that when I try to use RainMaker with my epaper Firmware, using a display buffer bigger than 80/100Kb is already giving me problems. When I do idf.py build

/home/martin/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: region `iram0_0_seg' overflowed by 25320 bytes

If I see this correctly is failing since it's about 25 Kb too big. So it's not about RAM since I'm initializing the _buffer directly in PSRAM:

Code: Select all

uint8_t* _buffer = (uint8_t*)heap_caps_malloc(WAVE5I7COLOR_BUFFER_SIZE, MALLOC_CAP_SPIRAM);
This problem is gone if I compile this on a branch without RainMaker WiFi provisioning. My question is: There is any way to place BLE libraries directly on PSRAM or similar?
I see an option that compiles WiFi libraries in SPI Ram but it does not make any difference. Is still giving the same overflow in the build process after checking that option in idf.py menuconfig

Any ideas how I can solve this?
Just as a reference, this is the CPP file that is my main program:
https://github.com/martinberlin/cale-id ... r-wifi.cpp

For further info this are my partitions:

Code: Select all

# Note: Firmware partition offset needs to be 64K aligned, initial 36K (9 sectors) are reserved for bootloader and partition table
sec_cert,  0x3F, ,0xd000,    0x3000, ,  # Never mark this as an encrypted partition
nvs,      data, nvs,     0x10000,   0x6000,
otadata,  data, ota,     ,          0x2000
phy_init, data, phy,     ,          0x1000,
ota_0,    app,  ota_0,   0x20000,   1600K,
ota_1,    app,  ota_1,   ,          1600K,
fctry,    data, nvs,     0x340000,  0x6000
And here the report from make size-components

Code: Select all

Total sizes:
 DRAM .data size:   19612 bytes
 DRAM .bss  size:   32432 bytes
Used static DRAM:   52044 bytes (  72536 available, 41.8% used)
Used static IRAM:    1027 bytes ( 130045 available, 0.8% used)
      Flash code: 1154451 bytes
    Flash rodata:  311828 bytes
Total image size:~1486918 bytes (.bin may be padded larger)
Per-archive contributions to ELF file:
            Archive File DRAM .data & .bss & other   IRAM   D/IRAM Flash code & rodata   Total
                 libbt.a        228  12803       0      0        0     268970    75021  357022
           libnet80211.a       1267   6041       0      0        0     108628    18435  134371
               liblwip.a         25   3891       0      0        0     105993    16249  126158
                  libc.a       1355     54       0      0        0      89977     8665  100051
         libmbedcrypto.a         64     81       0      0        0      86790    11762   98697
           libbtdm_app.a        773   2573       0      0        0      69839     4551   77736
     libwpa_supplicant.a         12    848       0      0        0      44702     3760   49322
      libesp_rainmaker.a         12    126       0      0        0      23528    23418   47084
                 libpp.a       2427   1292       0      0        0      37226     4704   45649
                libphy.a       1436    715       0      0        0      33149        0   35300
            libmbedtls.a         60    200       0      0        0      28447     5206   33913
              libesp32.a         16     89       0      0        0      13664    16489   30258
  libwifi_provisioning.a          4     12       0      0        0      13224    12710   25950
             libdriver.a        232    106       0      0        0      15258     9054   24650
             libnghttp.a          0      0       0      0        0      15604     4084   19688
          libnvs_flash.a          0     24       0      0        0      16565     3019   19608
      librmaker_common.a         12     26       0      0        0       4135    15231   19404
          libprotocomm.a          1     39       0      0        0       9680     9330   19050
               libmqtt.a          4      0       0      0        0      13922     4013   17939
         libprotobuf-c.a         12      0       0      0        0      12075     1616   13703
      libtcp_transport.a          0      0       0      0        0       9253     3022   12275
    libesp_http_client.a          0      0       0      0        0       9397     2717   12114
           libmbedx509.a          0      0       0      0        0       8931     2089   11020
         libesp_system.a        278    206       0      0        0       6404     3928   10816
           libfreertos.a       3112   1044       0    425        0        413     4632    9626
             libqrcode.a          0      0       0      0        0       6970     2488    9458
            libesp-tls.a          0      4       0      0        0       5736     3463    9203
                libvfs.a        308     48       0      0        0       8160      602    9118
     libesp_hw_support.a        256     40       0      0        0       6117     2562    8975
          libesp_netif.a         12     25       0      0        0       6284     2378    8699
           libesp_wifi.a        572     57       0      0        0       5092     2772    8493
               libmain.a          9    760       0      0        0       4197     2737    7703
         libesp_common.a          0      0       0      0        0         53     6957    7010
            libcoexist.a       1816     33       0      0        0       4713      325    6887
                libgcc.a          8     12       0      0        0       5924      872    6816
             libCalEPD.a          0      3       0      0        0       2967     3086    6056
       libesp_schedule.a          0      5       0      0        0       4000     2019    6024
          libspi_flash.a       1538    294       0      0        0       2149     1819    5800
 libbootloader_support.a          0      4       0      0        0       3701     1416    5121
          libesp_event.a          0      4       0      0        0       3815     1211    5030
                libhal.a        136      0       0      0        0       3290     1442    4868
               libheap.a       1965      8       0      0        0       1523      777    4273
      libesp_https_ota.a          0      0       0      0        0       2459     1647    4106
             libstdc++.a          8     20       0      0        0       2686     1044    3758
       libAdafruit-GFX.a          0      0       0      0        0       2257     1387    3644
         libapp_update.a          1     20       0      0        0       2467     1096    3584
                libsoc.a          0      0       0      0        0        543     2994    3537
        libjson_parser.a          0      0       0      0        0       2428      817    3245
               libjson.a         12      0       0      0        0       3091       42    3145
              libefuse.a         64      4       0      0        0       1307      807    2182
          libesp_timer.a         32     24       0      0        0       1218      757    2031
             libnewlib.a        190    272       0      0        0       1268      151    1881
                liblog.a          8    272       0      0        0        887      144    1311
            libpthread.a         16     12       0      0        0        815      459    1302
             libxtensa.a       1024      0       0      0        0        210       35    1269
     libjson_generator.a          0      0       0      0        0       1105       42    1147
               libcore.a          0     33       0      0        0        615      228     876
            libesp_ipc.a          0     56       0      0        0        474       89     619
        libesp_ringbuf.a          0      0       0      0        0          0      512     512
      libtcpip_adapter.a          0     17       0      0        0        240        0     257
             libxt_hal.a          0      0       0      0        0          0       32      32
                   (exe)          0      0       0      3        0          3       12      18
                libcxx.a          0      0       0      0        0         11        0      11
             libesp_pm.a          0      0       0      0        0          8        0       8
                librtc.a          0      4       0      0        0          0        0       4
            libesp_eth.a          0      0       0      0        0          0        0       0
            libesp_rom.a          0      0       0      0        0          0        0       0
               libmesh.a          0      0       0      0        0          0        0       0
              
Last edited by fasani on Mon Jul 19, 2021 10:04 am, edited 1 time in total.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Size overflow issue in IRAM: Not enough place for my own program

Postby ESP_Angus » Tue Jul 13, 2021 11:04 am

Hi fasani,

You may find some of the tips here useful:
https://docs.espressif.com/projects/esp ... iram-usage

(Note that a few of these options are only available on master branch ESP-IDF, but many are available in older versions also.)

User avatar
fasani
Posts: 195
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: Size overflow issue in IRAM: Not enough place for my own program

Postby fasani » Wed Jul 14, 2021 6:29 am

Thanks Mr Angus.
That's very useful. I find the list a bit hard to find using menuconfig
So one day when I get some time will write an article on how to find this Config options and approx. how many bytes free you get per each.
IRAM free space is one of my highest concerns this days. Basically when you use so many libraries for BLE - WiFi provisioning you get little space for your own program.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

User avatar
fasani
Posts: 195
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: Size overflow issue in IRAM: Not enough place for my own program

Postby fasani » Wed Jul 14, 2021 10:04 am

It was hard but worth the research. Finally my epaper with 130 Kb buffer is working in this branch:

https://github.com/martinberlin/cale-id ... est/vector

Using our own ESP-IDF component CalEPD to drive the epaper. I also added the deepsleep minutes as a RainMaker parameter that is stored in NVS.
It does only 2 things and two things only:

1.- Connects to WiFi and downloads an image
2.- Renders the image and goes to deepsleep NVS minutes, repeats 1 :)
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

Who is online

Users browsing this forum: No registered users and 36 guests