Skip to content

Commit

Permalink
Merge pull request #3668 from jepler/esp32s2-stack-size
Browse files Browse the repository at this point in the history
esp32s2: Correct port_stack_get_top()
  • Loading branch information
tannewt committed Nov 10, 2020
2 parents fd43c0a + 2d8ebfc commit 75a977f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ports/esp32s2/supervisor/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,18 @@ uint32_t *port_stack_get_limit(void) {
}

uint32_t *port_stack_get_top(void) {
return port_stack_get_limit() + CONFIG_ESP_MAIN_TASK_STACK_SIZE / (sizeof(uint32_t) / sizeof(StackType_t));
// The sizeof-arithmetic is so that the pointer arithmetic is done on units
// of uint32_t instead of units of StackType_t. StackType_t is an alias
// for a byte sized type.
//
// The main stack is bigger than CONFIG_ESP_MAIN_TASK_STACK_SIZE -- an
// "extra" size is added to it (TASK_EXTRA_STACK_SIZE). This total size is
// available as ESP_TASK_MAIN_STACK. Presumably TASK_EXTRA_STACK_SIZE is
// additional stack that can be used by the esp-idf runtime. But what's
// important for us is that some very outermost stack frames, such as
// pyexec_friendly_repl, could lie inside the "extra" area and be invisible
// to the garbage collector.
return port_stack_get_limit() + ESP_TASK_MAIN_STACK / (sizeof(uint32_t) / sizeof(StackType_t));
}

supervisor_allocation _fixed_stack;
Expand Down

0 comments on commit 75a977f

Please sign in to comment.