test/shared_stack_printf: improved printf with shared stack function test

This commit is contained in:
Felipe Neves 2020-03-31 13:58:02 -03:00 committed by bot
parent 938a73756c
commit a700035a85
3 changed files with 27 additions and 6 deletions

View File

@ -8,9 +8,14 @@
#include "test_utils.h"
#include "esp_expression_with_stack.h"
#define SHARED_STACK_SIZE 8192
static StackType_t *shared_stack_sp = NULL;
void external_stack_function(void)
{
printf("Executing this printf from external stack! sp=%p\n", get_sp());
shared_stack_sp = (StackType_t *)get_sp();
}
void another_external_stack_function(void)
@ -19,11 +24,12 @@ void another_external_stack_function(void)
printf("We can even use FreeRTOS resources delaying..., sp=%p\n", get_sp());
vTaskDelay(100);
printf("Done!, sp=%p\n", get_sp());
shared_stack_sp = (StackType_t *)get_sp();
}
TEST_CASE("test printf using shared buffer stack", "[newlib]")
{
portSTACK_TYPE *shared_stack = malloc(8192);
portSTACK_TYPE *shared_stack = malloc(SHARED_STACK_SIZE);
TEST_ASSERT(shared_stack != NULL);
@ -32,8 +38,22 @@ TEST_CASE("test printf using shared buffer stack", "[newlib]")
printf("SP: %p\n", get_sp());
printf("shared_stack: %p\n", (void *)shared_stack);
esp_execute_shared_stack_function(printf_lock, shared_stack,8192,external_stack_function);
esp_execute_shared_stack_function(printf_lock, shared_stack,8192,another_external_stack_function);
esp_execute_shared_stack_function(printf_lock,
shared_stack,
SHARED_STACK_SIZE,
external_stack_function);
TEST_ASSERT(((shared_stack_sp >= shared_stack_sp) &&
(shared_stack_sp < (shared_stack + SHARED_STACK_SIZE))));
esp_execute_shared_stack_function(printf_lock,
shared_stack,
SHARED_STACK_SIZE,
another_external_stack_function);
TEST_ASSERT(((shared_stack_sp >= shared_stack_sp) &&
(shared_stack_sp < (shared_stack + SHARED_STACK_SIZE))));
vSemaphoreDelete(printf_lock);
free(shared_stack);
}

View File

@ -39,8 +39,9 @@ esp_shared_stack_invoke_function:
movi a7, 1
s32i a7, a6, 0 /* hint the function was finished */
movi a6, shared_stack_env
movi a7, 0
call4 longjmp /* jump to last clean state previously saved */
movi a7, 0
movi a12, longjmp
callx4 a12 /* jump to last clean state previously saved */
ret
#else
#error "this code is written for Window ABI"

View File

@ -19,7 +19,7 @@ System API
High Resolution Timer <esp_timer>
:esp32: Himem (large external SPI RAM) API <himem>
:esp32: Inter-Processor Call <ipc>
Call function with external stack <esp_expression_with_stack>
Call function with external stack <esp_function_with_shared_stack>
Interrupt Allocation <intr_alloc>
Logging <log>
Miscellaneous System APIs <system>