Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HardFault_Handler when rclc_timer_init_default is use #99

Open
hishambaharom opened this issue Apr 20, 2023 · 7 comments
Open

HardFault_Handler when rclc_timer_init_default is use #99

hishambaharom opened this issue Apr 20, 2023 · 7 comments

Comments

@hishambaharom
Copy link

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
Copy link
Member

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

@hishambaharom
Copy link
Author

hishambaharom commented Apr 20, 2023

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
Copy link
Member

Do you have any heap initialized?

@hishambaharom
Copy link
Author

hishambaharom commented Apr 21, 2023

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
Copy link
Member

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
Copy link
Author

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

@hishambaharom
Copy link
Author

What other data require for evaluate this issue..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants