Custom firmware ESP32 WROVER #12065
-
So, I'm building a custom firmware for an ESP32 WROVER - E N8R8 following the steps that a user posted as an answer for this discussion https://github.com/orgs/micropython/discussions/11612 |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
It seems like you are facing some issues while building a custom firmware for your ESP32 WROVER-E N8R8 board using Micropython. The difference in available memory and the firmware not being recognized as an ESP32 firmware might be due to configuration or compilation issues. To help you troubleshoot and get a better understanding of the problem, let's go through some steps and possible solutions: Double-check the configuration settings when building the firmware. Make sure that you have selected the correct target configuration for your ESP32 WROVER-E N8R8 board. The target configuration should match the specific variant of the ESP32 chip you are using. Ensure that you are using the correct version of ESP-IDF (Espressif IoT Development Framework) corresponding to the Micropython version you are building. Different versions of ESP-IDF may have different memory configurations and compatibility with specific ESP32 chip variants. Memory allocation and partitioning can significantly affect the available RAM. Check the memory partition configuration in your custom firmware build and compare it to the downloaded firmware from micropython.org. Make sure the memory partitioning matches the requirements of your board.
If you are manually flashing the firmware, ensure that you are using the correct flashing procedure for your board. Double-check the flash size and the memory addresses used for flashing. Enable debugging options during the firmware build to get more insights into the boot process. This can help identify the point at which the firmware fails to boot. Reach out to the Micropython community or the specific ESP32 development community for support. The members in these communities might have experience with similar issues or provide guidance for custom firmware builds. Remember that building custom firmware for embedded platforms like ESP32 requires attention to detail, and small configuration errors can lead to unexpected behavior. Be cautious when making changes to the firmware, as incorrect configurations can result in bricked devices. Before flashing any firmware to your ESP32 board, always ensure you have a backup of the original firmware, and proceed with caution when experimenting with custom builds. |
Beta Was this translation helpful? Give feedback.
-
I'm using ESP-IDF v5.0.2 |
Beta Was this translation helpful? Give feedback.
-
There was nothing wrong with your build. ESP32 can only access 4MB SPIRAM!
In MP, the rest of the 4MB is not addressable (not used - wasted). There is nothing MicroPython can do, this is a hardware limitation of the ESP32. You can use the hmem API to address different banks of RAM, but this is not part of MicroPython.
Anyway, this is what I have of RAM
I managed to use all available SPIRAM on the ESP32-S3. If your projects require a lot of RAM, it is best to migrate to the ESP32-S3. |
Beta Was this translation helpful? Give feedback.
-
All MicroPython firmwares lower than or equal to v1.20.0-206 were built with ESP-IDF-4.x.x and sdkconfig.spiram uses The esp32-wrover-n4r8 board has 8MB of PSRAM, but only 4MB is usable in the MicroPython esp32 port. See execution results below:
So for ESP32, only 4MB of PSRAM will be used, no matter how the MicroPython heap is allocated and how much more physical PSRAM a board has. It seems that to use the rest of the physical PSRAM, the himem API must be used. |
Beta Was this translation helpful? Give feedback.
-
Newer versions of MicroPython will be based on ESP-IDF-5.X.X only. The ESP-IDF-4.X.X will not be supported anymore. Supporting both ESP-IDF versions is too much work for the MP-Core developers and maintainers. It is not quite correct to say that you have lost RAM with the new build. The main difference with the new firmware is that the ratio of RAM between the MicroPython heap and the IDF heap is 50/50. This is a fair assumption for the default distribution. Now some users may want to have more RAM allocated to the MicroPython heap. Like you for example, your want as much SPIRAM (4MB) allocated to MicroPython heap. Some users, like me, want to have more SPIRAM reserved for the IDF heap because I need RAM for the camera framebuffer. Therefore, there is an ongoing effort on gc to support a dynamic heap allocation mechanism. The memory mappings presented by Espressif are confusing. For an ESP32 board with SPIRAM, we have TotalRAM = PSRAM + SRAM, where PSRAM is the external SPIRAM and SRAM is the internal RAM. For an ESP32 board without SPIRAM, of course, TotalRAM = SRAM. Now 'full' MicroPython will run on ESP32 without SPIRAM, but with limited MicroPython heap size. So it is possible to allocate almost all SPIRAM to the MicroPython heap for SPIRAM-enhanced ESP32. Espressif also mentioned DRAM and IRAM, Data RAM and Instruction RAM, respectively. The important thing to remember about RAM is not its total size, but the largest continuously free allocatable block. MicroPython is an application built on top of the ESP-IDF architecture. It is just like any other application. Custom MicroPython builders are free to allocate as much or as little RAM to the application as necessary for the smooth running of their system. Keep in mind that WiFi, SSL, Bluetooth also need RAM. I manage to build a firmware that give these results:
I need to modiify the main.c file:
Now 4MB of SPIRAM is still wasted due to the 4MB mapping limitation of ESP32. Unless we use the himem API. Using this API I managed to include a C module named
Below is the full listing of my sdkconfig.board file.
|
Beta Was this translation helpful? Give feedback.
-
Where is this file and how to Incorporated into the build. |
Beta Was this translation helpful? Give feedback.
Newer versions of MicroPython will be based on ESP-IDF-5.X.X only. The ESP-IDF-4.X.X will not be supported anymore. Supporting both ESP-IDF versions is too much work for the MP-Core developers and maintainers.
It is not quite correct to say that you have lost RAM with the new build. The main difference with the new firmware is that the ratio of RAM between the MicroPython heap and the IDF heap is 50/50. This is a fair assumption for the default distribution.
Now some users may want to have more RAM allocated to the MicroPython heap. Like you for example, your want as much SPIRAM (4MB) allocated to MicroPython heap. Some users, like me, want to have more SPIRAM reserved for the IDF heap be…