diff --git a/components/newlib/test/test_shared_stack_printf.c b/components/newlib/test/test_shared_stack_printf.c index b99959f71a..5daa248a25 100644 --- a/components/newlib/test/test_shared_stack_printf.c +++ b/components/newlib/test/test_shared_stack_printf.c @@ -8,25 +8,22 @@ #include "esp_expression_with_stack.h" //makes sure this is not the task stack... -void check_stack(portSTACK_TYPE *sp, portSTACK_TYPE *base_sp) +void another_external_stack_function(void) { - StaticTask_t *hacked_task = (StaticTask_t *)xTaskGetCurrentTaskHandle(); - portSTACK_TYPE *task_sp = (portSTACK_TYPE *)hacked_task->pxDummy1; - TEST_ASSERT((intptr_t)task_sp < (intptr_t)base_sp || - (intptr_t)task_sp >= (intptr_t)sp); + //We can even use Freertos resources inside of this context. + vTaskDelay(100); + printf("Executing this another printf inside a function with external stack"); } TEST_CASE("test printf using shared buffer stack", "[newlib]") { portSTACK_TYPE *shared_stack = malloc(8192 * sizeof(portSTACK_TYPE)); - portSTACK_TYPE *ext_stack_top = (portSTACK_TYPE *)&shared_stack[0] + - ((sizeof(8192 * sizeof(portSTACK_TYPE))) / - sizeof(portSTACK_TYPE)); TEST_ASSERT(shared_stack != NULL); SemaphoreHandle_t printf_lock = xSemaphoreCreateMutex(); - ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,printf("Executing printf from external stack! \n")); - ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,check_stack(ext_stack_top, shared_stack)); + ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,printf("Executing this printf from external stack! \n")); + ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,another_external_stack_function()); + vSemaphoreDelete(printf_lock); free(shared_stack); } diff --git a/components/xtensa/expression_with_stack_xtensa.c b/components/xtensa/expression_with_stack_xtensa.c index c24470971d..310d924485 100644 --- a/components/xtensa/expression_with_stack_xtensa.c +++ b/components/xtensa/expression_with_stack_xtensa.c @@ -10,7 +10,7 @@ StackType_t * esp_switch_stack_setup(StackType_t *stack, size_t stack_size) sizeof(StackType_t)); //Align stack to a 16byte boundary, as required by CPU specific: - top_of_stack = (StackType_t *)(((UBaseType_t)(top_of_stack - 1) - + top_of_stack = (StackType_t *)(((UBaseType_t)(top_of_stack - 31) - ALIGNUP(0x10, sizeof(XtSolFrame) )) & ~0xf);