compiling for 8MB PSRAM

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
tecdroid
Posts: 27
Joined: Thu Apr 08, 2021 6:22 am

compiling for 8MB PSRAM

Post by tecdroid » Wed Aug 17, 2022 6:44 am

Hi,

I'm using an ESP32-WROVER-E which has 4MB Flash and 8MB PSRAM.
Since GENERIC_PSRAM only utilizes 4MB of RAM i wonder what to put in my mpconfigboard.h to enhance this.

Is there anyone who can tell?

Edit: Just seen that I was in the wrong tab. The post may be right here but I feel like it should have been in Development section? If so, sorry for that!

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: compiling for 8MB PSRAM

Post by davef » Wed Aug 17, 2022 7:08 am

Check if I am referring to the correct device, mine is a VIE SPIRAM variant.

I copied this off a previous post, maybe search for <ESP32_SPIRAM 4MB to 8MB>
a) create a partition table for that 8 MB flash and place it in the esp32 directory. The name is arbitrary. I named it partitions_8mb.csv. My copy:

Code: Select all

# Name,   Type, SubType, Offset,  Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs,      data, nvs,     0x9000,  0x6000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000, 0x1F0000,
vfs,      data, fat,     0x200000, 0x600000,
b) create a board definition subdirectory for that board. That could be a copy of the most similar board. I called it GENERIC_SPIRAM_8MB. But you can give it any suitable name. That name is used in the make command and in the changed mpconfigboard.cmake (see below).
c) create a file sdkconfig.board in the board directory which sets the flash size and partition table name. My version:

Code: Select all

CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_8mb.csv"
c) change the mpconfigboard.cmake file in adding the name of the sdkconfig.board file. Mine looks as follows after the change:

Code: Select all

set(SDKCONFIG_DEFAULTS
    boards/sdkconfig.base
    boards/sdkconfig.ble
    boards/sdkconfig.spiram
    boards/GENERIC_SPIRAM_8MB/sdkconfig.board
)

Code: Select all

set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
Then you can build & flash the image with

Code: Select all

make BOARD=<new_board_name> deploy
I have two of these devices but haven't had the need to reclaim all the memory.

tecdroid
Posts: 27
Joined: Thu Apr 08, 2021 6:22 am

Re: compiling for 8MB PSRAM

Post by tecdroid » Wed Aug 17, 2022 10:56 am

Hi,

thank you but doesn't this just set flash to 8M?
What I need is 4MB flash and 8MB RAM

edit: just found out that ESP32 only can allocate 4M of RAM directly. The rest is available via another kind of memory allocation or via bank switching (as far as I understand) so either, bank switching can be enabled or some himem library must be developed :-D

.. if I only had this much time.

Post Reply