micro-ROS / micro_ros_stm32cubemx_utils

A set of utilities for integrating micro-ROS in a STM32CubeMX project
Apache License 2.0
173 stars 67 forks source link

HardFault_Handler when rclc_timer_init_default is use #99

Open hishambaharom opened 1 year ago

hishambaharom commented 1 year ago

I have a problem when debugger reach rclc_timer_init_default function. this cause the debugger go to HardFault_Handler function. Please help. Board: openCR(stm32f746) IDE: stm32cubeide OS: Freertos

pablogs9 commented 1 year ago

We need more details to be able to evaluate this issue.

hishambaharom commented 1 year ago

This the configuration for rtos

Screenshot from 2023-04-20 22-38-31

This what I capture in disassembly.

Screenshot from 2023-04-20 23-34-22

the problem is when it execute rcl_get_zero_initializes_timer at address 0x8017de4 ( bx lr), it trigger hardfault_handler

pablogs9 commented 1 year ago

Do you have any heap initialized?

hishambaharom commented 1 year ago

No I did not, what I know In microros, the heap is typically initialized automatically by the main() function or by the underlying operating system. How I can initialized microros heap any ref..,

This is all in my main for ref

/ USER CODE BEGIN 1 /

/ USER CODE END 1 /

/ MCU Configuration--------------------------------------------------------/

/ Reset of all peripherals, Initializes the Flash interface and the Systick. / HAL_Init();

/ USER CODE BEGIN Init /

/ USER CODE END Init /

/ Configure the system clock / SystemClock_Config();

/ USER CODE BEGIN SysInit /

/ USER CODE END SysInit /

/ Initialize all configured peripherals / MX_GPIO_Init(); MX_USART2_UART_Init(); MX_CAN2_Init(); MX_UART8_Init(); MX_TIM6_Init(); MX_TIM7_Init(); / USER CODE BEGIN 2 /

HAL_CAN_Start(&hcan2); HAL_CAN_ActivateNotification(&hcan2, CAN_IT_RX_FIFO0_MSG_PENDING);

HAL_UART_Receive_IT(&huart2, &uart2_it_data, 1); HAL_UART_Receive_IT(&huart8, &uart8_it_data, 1);

HAL_TIM_Base_Start(&htim6); // Start timer HAL_TIM_Base_Start_IT(&htim7);//

//FirstOrderIIR_Init(&iirBuffer, IIR_FILTER_ALPHA); Moving_Average_Init(&filterStruct);

if(HAL_GPIO_ReadPin(GPIOB, em_button_Pin) == 0x01){ //init emergency var emergency_trigger = 0x01; }else{ emergency_trigger = 0x02; }

/ USER CODE END 2 /

/ Init scheduler / osKernelInitialize();

/ USER CODE BEGIN RTOS_MUTEX / / add mutexes, ... / / USER CODE END RTOS_MUTEX /

/ USER CODE BEGIN RTOS_SEMAPHORES / / add semaphores, ... / / USER CODE END RTOS_SEMAPHORES /

/ USER CODE BEGIN RTOS_TIMERS / / start timers, add new ones, ... / / USER CODE END RTOS_TIMERS /

/ Create the queue(s) / / creation of myQueue01 / myQueue01Handle = osMessageQueueNew (16, sizeof(cmdVelData), &myQueue01_attributes);

/ creation of myQueue02 / myQueue02Handle = osMessageQueueNew (16, sizeof(cmdVelData), &myQueue02_attributes);

/ USER CODE BEGIN RTOS_QUEUES / / add queues, ... / / USER CODE END RTOS_QUEUES /

/ Create the thread(s) / / creation of ros2Task / ros2TaskHandle = osThreadNew(StartRos2Task, NULL, &ros2Task_attributes);

/ creation of motorDriver01Ta / motorDriver01TaHandle = osThreadNew(StartMotorDriver01Task, NULL, &motorDriver01Ta_attributes);

/ creation of motorDriver02Ta / motorDriver02TaHandle = osThreadNew(StartMotorDriver02Task, NULL, &motorDriver02Ta_attributes);

/ creation of uartDataProcess / uartDataProcessHandle = osThreadNew(StartUartDataProcessTask, NULL, &uartDataProcess_attributes);

/ USER CODE BEGIN RTOS_THREADS / / add threads, ... / / USER CODE END RTOS_THREADS /

/ USER CODE BEGIN RTOS_EVENTS / / add events, ... / / USER CODE END RTOS_EVENTS /

/ Start scheduler / osKernelStart(); / We should never get here as control is now taken by the scheduler / / Infinite loop / / USER CODE BEGIN WHILE / while (1) { / USER CODE END WHILE /

/* USER CODE BEGIN 3 */

} / USER CODE END 3 /

pablogs9 commented 1 year ago

In Cube IDE you need to have some heap configured for your platform. This is not related to micro-ROS but to your platform usage.

hishambaharom commented 1 year ago

I Have configure the heap to 10k but the problem still have

hishambaharom commented 1 year ago

What other data require for evaluate this issue..