Skip to content

ESP32: .iram0.text overflow with recent IDF versions #8260

@jonathanhogg

Description

@jonathanhogg

I'm seeing a bunch of problems building against different versions of the IDF. All of the following is building 102cc12 with 2 of my patches integrated on top (#6263 and #7582).

A GENERIC ESP32 build against the latest v4.4 tag results in a binary that explodes on boot:

ELF file SHA256: 2995987005bacb8b

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4344
load:0x40078000,len:13816
load:0x40080400,len:3340
0x40080400: _init at ??:?

entry 0x40080618
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x4014899a  PS      : 0x00060733  A0      : 0x800d7048  A1      : 0x3ffcef20  
0x4014899a: uart_isr_register at /Users/jonathan/Projects/outputarts/esp-idf-4.4/components/driver/uart.c:594

A2      : 0x00000000  A3      : 0x00000000  A4      : 0x3ffb78e8  A5      : 0x0000040e  
A6      : 0x3ffcef50  A7      : 0x3ffbf24c  A8      : 0x00000000  A9      : 0x3ffceef0  
A10     : 0x00000000  A11     : 0x0000040e  A12     : 0x4008334c  A13     : 0x00000000  
0x4008334c: uart_irq_handler at /Users/jonathan/Projects/outputarts/micropython/ports/esp32/uart.c:46

A14     : 0x3ffcef50  A15     : 0x00000000  SAR     : 0x0000001d  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x00000008  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  


Backtrace:0x40148997:0x3ffcef200x400d7045:0x3ffcef50 0x400d6eb9:0x3ffcef80 
0x40148997: uart_isr_register at /Users/jonathan/Projects/outputarts/esp-idf-4.4/components/driver/uart.c:594

0x400d7045: uart_init at /Users/jonathan/Projects/outputarts/micropython/ports/esp32/uart.c:41

0x400d6eb9: mp_task at /Users/jonathan/Projects/outputarts/micropython/ports/esp32/main.c:96

Switching to v4.3.2 works, but I am unable to do a matching GENERIC_SPIRAM build (for the other boards that I use) as it seems to be overflowing the iram0 memory segment:

[100%] Linking CXX executable micropython.elf
/Users/jonathan/.espressif/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: micropython.elf section `.iram0.text' will not fit in region `iram0_0_seg'
/Users/jonathan/.espressif/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: IRAM0 segment data does not fit.
/Users/jonathan/.espressif/tools/xtensa-esp32-elf/esp-2021r2-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 492 bytes
collect2: error: ld returned 1 exit status
make[3]: *** [micropython.elf] Error 1
make[2]: *** [CMakeFiles/micropython.elf.dir/all] Error 2
make[1]: *** [all] Error 2
make failed with exit code 2
make: *** [all] Error 2

I have verified that this is the same building against master without my patches.

This last error is a little outside my area of expertise: I'm not actually familiar with the ESP32/MicroPython memory model. I did a little hunting to see if I could figure out what's in that text area and why it's suddenly overflowing with v4.3.2, but nothing immediately jumped out at me. I'm also not sure how the size of the regions is configured.

Backing up one more version to build against v4.3.1 appears to work OK, but suffers from the missing memory problem documented in #7813

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4604
ho 0 tail 12 room 4
load:0x40078000,len:13396
load:0x40080400,len:3312
entry 0x4008061c
MicroPython v1.18-82-gd57e23b8d on 2022-02-04; ESP32 module with ESP32
Type "help()" for more information.
>>> import gc
>>> gc.mem_free()
63008

This is about 109000 free on a straight MicroPython 1.18 GENERIC download.

Going back to v4.0.2 I get seemingly good builds for both GENERIC and GENERIC_SPIRAM and my memory back:

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4252
load:0x40078000,len:11920
load:0x40080400,len:3344
entry 0x4008060c
MicroPython v1.18-82-gd57e23b8d on 2022-02-04; ESP32 module with ESP32
Type "help()" for more information.
>>> import gc
>>> gc.mem_free()
110176

Is the moral of this tale: do not attempt to build MicroPython against any version of the IDF more recent than v4.0.2?

I've been using v4.3.1 for ages, but always with a GENERIC_SPIRAM build so I hadn't noticed the missing memory on a non-SPIRAM device until yesterday.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy