Skip to content

Commit

Permalink
Merge branch 'airguard' of github.com:open-lv/micropython into airguard
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyLV committed Mar 20, 2022
2 parents 06c1b0f + 3dd3548 commit 6041354
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ports/esp32/boards/AIRGUARD/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -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)

4 changes: 4 additions & 0 deletions ports/esp32/boards/AIRGUARD/sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
}
6 changes: 5 additions & 1 deletion ports/esp32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6041354

Please sign in to comment.