Memory Problem on esp32p4 dev module kit

What do you want to achieve?

I built an HMI using LVGL. Until now, I’ve been using Modbus TCP over the LAN. I want to switch to Wi-Fi, but as soon as I initialize the Wi-Fi, I get the following error:

“FAILED: lvgl_demo_v9.elf
C:\Windows\system32\cmd.exe /C “cd . && C:\Users\omargelaptop\espressif\tools\riscv32-esp-elf\esp-14.2.0_20251107\riscv32-esp-elf\bin\riscv32-esp-elf-g++.exe -march=rv32imafc_zicsr_zifencei_xesploop_xespv -mabi=ilp32f -nostartfiles -march=rv32imafc_zicsr_zifencei_xesploop_xespv -mabi=ilp32f -Wl,–cref -Wl,–defsym=IDF_TARGET_ESP32P4=0 -Wl,–Map=D:/MUSTAFA/1-projeler/1-2-embedded_projects/OM_VALS/esp32-hmi/sss/OM_VALS_ESP32_7_inch_HMI/build/lvgl_demo_v9.map -Wl,–no-warn-rwx-segments -Wl,–orphan-handling=warn -fno-rtti -fno-lto -Wl,–gc-sections -Wl,–warn-common -T rom.api.ld -T esp32p4.peripherals.ld -T esp32p4.rom.ld -T esp32p4.rom.api.ld -T esp32p4.rom.rvfp.ld -T esp32p4.rom.wdt.ld -T esp32p4.rom.systimer.ld -T esp32p4.rom.version.ld -T esp32p4.rom.libc.ld -T esp32p4.rom.libc-suboptimal_for_misaligned_mem.ld -T esp32p4.rom.newlib.ld -T memory.ld -T sections.ld -Wl,–enable-non-contiguous-regions @CMakeFiles\lvgl_demo_v9.elf.rsp -o lvgl_demo_v9.elf && cd .”
C:/Users/omargelaptop/espressif/tools/riscv32-esp-elf/esp-14.2.0_20251107/riscv32-esp-elf/bin/…/lib/gcc/riscv32-esp-elf/14.2.0/…/…/…/…/riscv32-esp-elf/bin/ld.exe:sections.ld:1056 cannot move location counter backwards (from 481d34a5 to 481d0400)
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.”

What have you tried so far?

yardımınıza ihtiyacım var nasıl çözebilirim??

Code to reproduce

/*You code here*/

Screenshot and/or video

Environment

  • ESP32 p4 dev module kit:
  • LVGL V9.3.0: See lv_version.h

Hi @mstfablbl, have you tried cleaning your project and rebuilding?

And how many times. I’ve even deleted the files manually many times. The managed_components and build files

It seems your binary is to big for the P4, check if the PSRAM is configured properly. You can try using size optimization: Optimize for size (-Os). Check the final binary and the reported memory size

Yes, I’m aware of that. However, I’m not exactly sure where I went wrong, or what I need to do.

I think I’ve configured the settings so that lvgl can use the PSRAM. What other settings do I need to adjust? (I’ve been struggling with the AI for quite a while before turning to the forum.) The memory table looks like this:

                        Memory Type Usage Summary                             

┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Memory Type/Section ┃ Used [bytes] ┃ Used [%] ┃ Remain [bytes] ┃ Total [bytes] ┃
┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ External RAM │ 1529544 │ 1.14 │ 132688152 │ 134217696 │
│ .rodata │ 899560 │ 0.67 │ │ │
│ .text │ 629472 │ 0.47 │ │ │
│ .init_array │ 256 │ 0.0 │ │ │
│ .appdesc │ 256 │ 0.0 │ │ │
│ DIRAM │ 187871 │ 42.18 │ 257521 │ 445392 │
│ .text │ 158522 │ 35.59 │ │ │
│ .data │ 15237 │ 3.42 │ │ │
│ .bss │ 13088 │ 2.94 │ │ │
│ .bss │ 1024 │ 0.23 │ │ │
│ HP core RAM │ 134 │ 1.64 │ 8058 │ 8192 │
│ .text │ 74 │ 0.9 │ │ │
│ .data │ 60 │ 0.73 │ │ │
│ LP RAM │ 24 │ 0.07 │ 32744 │ 32768 │
│ .rtc_reserved │ 24 │ 0.07 │ │ │
└─────────────────────┴──────────────┴──────────┴────────────────┴───────────────┘

You can try the optimization and if that does not work you can try poking around the configs. I’ll try finding the rights configs but in the meantime you if have any progress let me know.

And I just remembered, the P4 does not have wifi, in your board you have another ESP to handle that?

You are using this demo as a base?

I ran into similar memory problems with my P4.
Then with the ESP32-P4 is supported by Espressif, but only the ESP32-P4 Funtion EV board(pre-rev.3.00) is available.
It has limited ROM and RAM availble (about 1Mb flash) when used without extra settings.

Therefor the additional settings as below are used in the platformio.ini file.
board_build.flash_size = 16MB
board_build.partitions = custom_partitions.csv
The file custom_partitons.csv file wil maked use of the full memory potential.
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x300000,
app1, app, ota_1, 0x310000,0x300000,
ffat, data, fat, 0x610000,0x9E0000,
coredump, data, coredump,0xFF0000,0x10000,
A deep dive into how to configure the the flash bank on the ESP32. I found it here and the actual setting here, from Espressif itself.

I’m using a product from Waveshare. Product: “https://www.waveshare.com/wiki/ESP32-P4-Module-DEV-KIT-StartPage”. There’s also an LGV demo on the site. I used that demo and proceeded by adding the components I’ll be using myself.

Actually, rather than a memory error, I think it was a linker error; it compiled after I disabled the two options below.

"Wi-Fi IRAM speed optimization

Wi-Fi Rx IRAM speed optimization"

Translated with DeepL.com (free version)

Product: “https://www.waveshare.com/wiki/ESP32-P4-Module-DEV-KIT-StartPage

I have a significant amount of PSRAM—16MB—and I’ve enabled it in the configuration settings. But I’m not entirely sure how to do this: “How do I use the PSRAM space???” I mean, I think that when I enable the “enable PSRAM” option in the configuration, I’m not able to use the PSRAM at full performance???

In the link you posted it mentions ESP32-P4NRW32 wich is 32MB of PSRAM, maybe you can share your sdkconfig file

Of course: But the ESP32-P4 Dev modules come in 16MB and 32MB versions; mine says “16MB Flash” on it. If you search for “ESP32-P4 Dev module” on Google, you’ll see that it lists “Flash: 16MB” or “32MB.”
sdkconfig.zip (21.6 KB)

Yes, but this part number ( ESP32-P4NRW32 ) mentions the PSRAM config, not the flash. In the P4 datasheet you can see the possible configurations.

Just to be clear i am talking about only the PSRAM

image

On the waveshare website it also mentions this configuration:

Package with 32 MB PSRAM stacked inside, module integrated with 16MB Nor Flash

So your module has 32MB of PSRAM and 16MB of flash.

Thank you for the sdkconfig file

Did you changed your partitions.csv? Only with wifi + lvgl the problem happens, right?

Yes, the issue only occurred when I used Wi-Fi + LVGL. But as I said:

"Wi-Fi IRAM speed optimization

Wi-Fi Rx IRAM speed optimization"

When I unchecked these two options, it compiled and the Wi-Fi worked.

Where do I edit the “partitions.csv” file? I’ve never done anything like this before, and this is my first project with the ESP32.

You can use the menuconfig tool and search for partitions

In there you can set to custom partition.

I don’t know why it does not work with :

“Wi-Fi IRAM speed optimization
Wi-Fi Rx IRAM speed optimization”

But maybe you can continue with that disabled, because re-reading the issue it seems like you said just a linker error.

Maybe the partitions.csv will do nothing in your case but its usefull tool to know.