1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-04-15 23:05:45 +00:00

fix(core): presize __main__ module to avoid heap fragmentation

[no changelog]
This commit is contained in:
Roman Zeyde 2025-03-31 10:46:48 +03:00 committed by Roman Zeyde
parent 101d584aa4
commit ec87d2d21d
3 changed files with 4 additions and 0 deletions

View File

@ -41,6 +41,7 @@
#define MICROPY_ALLOC_PATH_MAX (128)
#define MICROPY_ENABLE_PYSTACK (1)
#define MICROPY_LOADED_MODULES_DICT_SIZE (160)
#define MICROPY_MAIN_DICT_SIZE (8)
// emitters
#define MICROPY_PERSISTENT_CODE_LOAD (0)

View File

@ -46,6 +46,7 @@
#define MICROPY_MEM_STATS (1)
#define MICROPY_ENABLE_PYSTACK (1)
#define MICROPY_LOADED_MODULES_DICT_SIZE (160)
#define MICROPY_MAIN_DICT_SIZE (8)
// emitters
#define MICROPY_PERSISTENT_CODE_LOAD (0)

View File

@ -49,6 +49,8 @@ Micropython to preallocate 160 slots in `mpconfigport.h` variable
`trezor.utils`, so if we ever need more modules than that, the test suite _should_ catch
it.
Presizing is also applied to `__main__` module by setting `MICROPY_MAIN_DICT_SIZE`.
## Top-level and function-local imports
In order to keep the imported image size in check, in certain places we avoid importing