diff --git a/ports/esp32/boards/AIRGUARD/mpconfigboard.h b/ports/esp32/boards/AIRGUARD/mpconfigboard.h index 644807f78e60..3dfffa9d93a5 100644 --- a/ports/esp32/boards/AIRGUARD/mpconfigboard.h +++ b/ports/esp32/boards/AIRGUARD/mpconfigboard.h @@ -1,2 +1,6 @@ #define MICROPY_HW_BOARD_NAME "ESP32 module" #define MICROPY_HW_MCU_NAME "ESP32" + +#define MICROPY_PY_BLUETOOTH (0) +#define MICROPY_BLUETOOTH_NIMBLE (0) + diff --git a/ports/esp32/boards/AIRGUARD/sdkconfig b/ports/esp32/boards/AIRGUARD/sdkconfig index 8bfa42cf93ec..78c44486d645 100644 --- a/ports/esp32/boards/AIRGUARD/sdkconfig +++ b/ports/esp32/boards/AIRGUARD/sdkconfig @@ -10,3 +10,7 @@ CONFIG_I2C_ADDR_SSD1306=60 CONFIG_PIN_NUM_SSD1306_RESET=-1 CONFIG_DRIVER_FRAMEBUFFER_ENABLE=y + +# disabling bt saves a couple kb of ram +CONFIG_BT_ENABLED=n +CONFIG_BT_NIMBLE_ENABLED=n diff --git a/ports/esp32/components/driver_framebuffer/png/deflate_reader.c b/ports/esp32/components/driver_framebuffer/png/deflate_reader.c index 45770254b04f..4c745bb11e55 100644 --- a/ports/esp32/components/driver_framebuffer/png/deflate_reader.c +++ b/ports/esp32/components/driver_framebuffer/png/deflate_reader.c @@ -165,10 +165,15 @@ lib_deflate_init(struct lib_deflate_reader *dr, lib_reader_read_t read, void *re dr->read_p = read_p; } +//statically allocated deflate reader eases pressure on heap fragmentation +//the size of this struct is quite large, which required large reserved dynamic +//memory +static struct lib_deflate_reader _reader; + struct lib_deflate_reader * lib_deflate_new(lib_reader_read_t read, void *read_p) { - struct lib_deflate_reader *dr = (struct lib_deflate_reader *) malloc(sizeof(struct lib_deflate_reader)); + struct lib_deflate_reader *dr = &_reader; if (unlikely(dr == NULL)) return NULL; @@ -526,5 +531,5 @@ lib_deflate_read(struct lib_deflate_reader *dr, uint8_t *buf, size_t buf_len) void lib_deflate_destroy(struct lib_deflate_reader *dr) { - free(dr); + //nothing to do for statically allocated deflate reader } diff --git a/ports/esp32/main.c b/ports/esp32/main.c index 66d772ddc121..75143ab2a0b5 100644 --- a/ports/esp32/main.c +++ b/ports/esp32/main.c @@ -142,11 +142,15 @@ void mp_task(void *pvParameter) { } #else // Allocate the uPy heap using malloc and get the largest available region - size_t mp_task_heap_size = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT) - 36*1024; + size_t mp_task_heap_size = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT); void *mp_task_heap = malloc(mp_task_heap_size); #endif + multi_heap_info_t info; soft_reset: + heap_caps_get_info(&info, MALLOC_CAP_8BIT); + printf("C heap: total=%d, free=%d, allocd=%d, mpy heap=%d bytes\n", info.total_free_bytes + info.total_allocated_bytes, + info.total_free_bytes, info.total_allocated_bytes, mp_task_heap_size); // initialise the stack pointer for the main thread mp_stack_set_top((void *)sp); mp_stack_set_limit(MP_TASK_STACK_SIZE - MP_TASK_STACK_LIMIT_MARGIN);