2024-03-08 02:55 AM - edited 2024-03-08 05:56 AM
Im currently porting a CPU performance benchmark from ESP32 to STM32 that uses FreeRTOS. Im unable to make it work due to some errors that continue appearing that might suggest there is a stack overflow, but increasing the stack size doesn´t help.
Debugger console error:
set *(int *)0xE000EDFC=*(int *)0xE000EDFC|0x7F0
set *(unsigned int *)0xe0042008&=~0x1800
The project is composed of main.c, dhrystone.c and whetstone.c. I have added the FreeRTOSconfig.h file.
Now the benchmark codes whetstone.c and dhrystone.c initialiced as tasks. Both codes return information as such:
xTaskNotifyGive( taskHandle );
vTaskDelete( NULL );
2024-03-08 03:14 AM - edited 2024-03-08 05:45 AM
nothing
2024-03-08 03:15 AM - edited 2024-03-08 05:40 AM
nothing
2024-03-08 03:20 AM - edited 2024-03-08 05:53 AM
My freeRTOSconfig.h:
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( 216000000)
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMAX_PRIORITIES ( 5 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 2048)
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 60 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 8
#define configGENERATE_RUN_TIME_STATS 0
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_RECURSIVE_MUTEXES 0
#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 0
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( 3 )
#define configTIMER_QUEUE_LENGTH 5
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#ifdef __NVIC_PRIO_BITS
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
#define configPRIO_BITS 4 /* 15 priority levels */
#endif
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
#endif /* FREERTOS_CONFIG_H */
2024-03-08 04:49 AM
Do you really expect someone to wade through four posts of unformatted source code?
If you want an answer from one of the community volunteers, you should firstly insert the code with the </> button and secondly minimise the description of the problem. Otherwise, your call for help will slowly sink into the mass of daily requests like in a bog.
Regards
/Peter
2024-03-08 05:19 AM - edited 2024-03-08 05:51 AM
main.c code:
#include"main.h"
#include"FreeRTOS.h"
#include"task.h"
#include"stdio.h"
#include"inttypes.h"
#include "stm32f7xx_hal.h"
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
/* USER CODE BEGIN PFP */
void dhrystone(void *pvParameters);
void whetstone(void *pvParameters);
/* USER CODE END PFP */
int main(void)
{
/* USER CODE BEGIN 1 */
TaskHandle_t taskHandle = xTaskGetCurrentTaskHandle();
UBaseType_t my_prio = uxTaskPriorityGet(NULL);
xTaskCreate(dhrystone, "DHRY", 1024*4, (void*)taskHandle, my_prio+1, NULL);
xTaskCreate(whetstone, "WHET", 1024*4, (void*)taskHandle, my_prio+1, NULL);
vTaskStartScheduler();
HAL_Init();
/* USER CODE BEGIN Init */
uint32_t cpu_frequency = HAL_RCC_GetSysClockFreq();
printf("CPU Frequency: %" PRIu32 "Hz\n", cpu_frequency);
/* USER CODE END Init */
SystemClock_Config();
MX_GPIO_Init();
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 8;
RCC_OscInitStruct.PLL.PLLN = 216;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
if (HAL_PWREx_EnableOverDrive() != HAL_OK)
{
Error_Handler();
}
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7) != HAL_OK)
{
Error_Handler();
}
}
static void MX_GPIO_Init(void)
{
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if (htim->Instance == TIM1) {
HAL_IncTick();
}
}
void Error_Handler(void)
{
__disable_irq();
#ifdef USE_FULL_ASSERT
}
#endif /* USE_FULL_ASSERT */
2024-03-08 05:20 AM
Thank you for your advice.
2024-03-08 01:54 PM
Does this code indeed work on esp32?
In lines 26, 27 the RTOS is not running yet so you are not in context of any thread. What do you expect xTaskGetCurrentTaskHandle() to return?
Line 43: something is missing. Does it compile at all?
Here you can find helping hands for your project.