Skip to content

Commit cbe5063

Browse files
iabdalkaderdpgeorge
authored andcommitted
stm32/main: Add support for additional GC blocks.
Add support for defining additional GC blocks via linker scripts. A board would need to define `_gc_blocks_table_start` and `_gc_blocks_table_end` and within that region have pairs of (address, length) for each GC block to add. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
1 parent 0815b45 commit cbe5063

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ports/stm32/main.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,23 @@ void stm32_main(uint32_t reset_mode) {
521521
// GC init
522522
gc_init(MICROPY_HEAP_START, MICROPY_HEAP_END);
523523

524+
// Add additional GC blocks (if enabled).
525+
#if MICROPY_GC_SPLIT_HEAP
526+
typedef struct {
527+
uint8_t *addr;
528+
uint32_t size;
529+
} gc_blocks_table_t;
530+
531+
extern const gc_blocks_table_t _gc_blocks_table_start;
532+
extern const gc_blocks_table_t _gc_blocks_table_end;
533+
534+
for (gc_blocks_table_t const *block = &_gc_blocks_table_start; block < &_gc_blocks_table_end; block++) {
535+
if (block->size) {
536+
gc_add(block->addr, block->addr + block->size);
537+
}
538+
}
539+
#endif
540+
524541
#if MICROPY_ENABLE_PYSTACK
525542
static mp_obj_t pystack[384];
526543
mp_pystack_init(pystack, &pystack[384]);

0 commit comments

Comments
 (0)