The memory of ESP32S3 is too large when using microython
I use the board of the ESP32. When I turn on microython, there will be more than 100 k of internal memory consumption. I have other functions to add. This more than 100 k of memory will cause me to run out of memory. What can I do to reduce the memory consumption of esp32 when using microython
esp32: ULP programs limited to 512 bytes
Is there a reason why in 3d49b157b89a59774fc4958dcaacd2c96ba6eaa4 (the move from sdkconfig.h to sdkconfig), CONFIG_ULP_COPROC_RESERVE_MEM = 2040 was removed, reverting to the IDF default value 512?
This causes esp32.ULP.load_binary() to fail with OSError: 260 (ESP_ERR_INVALID_SIZE) on programs larger than 512 bytes, for no reason that I can see. It is possible to work around the limitation by rewriting load_binary() in Python (everything the underlying IDF function ulp_load_binary() does can be replicated using machine.mem32) and the ULP runs the resulting code just fine. (Interestingly enough, ulp_load_binary() only applies the limit to the .text and .data sections of the ULP binary, while the .bss section is allowed to overflow into “non-reserved” memory. I wonder what the point of that is.)
In case that was an oversight, the attached commit restores it. As discussed in #3578, 2040 = 4096 - MICROPY_HW_RTC_USER_MEM_MAX - 8 is the maximum size that fits into RTC slow memory next to rtc_user_mem_{data|len|magic}, higher values cause a linker error.
I have not looked into whether the value could be computed for non-standard values of MICROPY_HW_RTC_USER_MEM_MAX, but for now am just restoring the hardcoded value that was there before. Nor have I looked into how to overlap the ULP and machine.RTC.memory() ranges, as suggested in https://github.com/micropython/micropython/pull/3578#discussion_r184373665.
Tested on a UM_TINYPICO board, built with ESP-IDF v4.2.2.