Skip to content

Commit 96be505

Browse files
committed
moves some function from IRAM into flash.
I don't know how much this is going to impact performance or if it is going to cause a problem. This is specific to the ESP32 with SPIRAM.
1 parent ee1bdbc commit 96be505

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

builder/esp32.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,28 @@ def compile(): # NOQA
834834
with open(board_config_path, 'w') as f:
835835
f.write('\n'.join(base_config))
836836

837+
if board == 'ESP32_GENERIC' and board_variant and board_variant == 'SPIRAM':
838+
mpconfigport = 'lib/micropython/ports/esp32/mpconfigport.h'
839+
840+
with open(mpconfigport, 'rb') as f:
841+
data = f.read().decode('utf-8')
842+
843+
pattern = (
844+
'#if !(CONFIG_IDF_TARGET_ESP32 && CONFIG_SPIRAM && CONFIG_SPIRAM_CACHE_WORKAROUND)\n'
845+
'#define MICROPY_WRAP_MP_BINARY_OP(f) IRAM_ATTR f\n'
846+
'#endif'
847+
)
848+
849+
if pattern in data:
850+
pattern = '#if !(CONFIG_IDF_TARGET_ESP32 && CONFIG_SPIRAM && CONFIG_SPIRAM_CACHE_WORKAROUND)\n'
851+
data = data.replace('#define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) IRAM_ATTR f\n', '')
852+
data = data.replace('#define MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(f) IRAM_ATTR f\n', '')
853+
854+
data = data.replace(pattern, pattern + '#define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) IRAM_ATTR f\n')
855+
data = data.replace(pattern, pattern + '#define MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(f) IRAM_ATTR f\n')
856+
with open(mpconfigport, 'rb') as f:
857+
f.write(data.encode('utf-8'))
858+
837859
if board in ('ESP32_GENERIC_S2', 'ESP32_GENERIC_S3') and disable_OTG:
838860
mphalport_path = 'lib/micropython/ports/esp32/mphalport.c'
839861

0 commit comments

Comments
 (0)