Skip to main content
Rajeev Arora
Senior
December 1, 2020
Solved

No means to detect ASSERT trigger without a debugger for configASSERT(0)

  • December 1, 2020
  • 2 replies
  • 1283 views

Hello @ALABB​ , @Khouloud ZEMMELI​ 

I am requesting an enhancement in file FreeRTOSConfig.h. I observe STM32CubeMX adds the file to any STM32H7 project that uses FreeRTOS version 10.2.1 (with CMSIS version 2).

https://github.com/STMicroelectronics/STM32CubeH7/blob/beced99ac090fece04d1e0eb6648b8075e156c6c/Projects/STM32H743I-EVAL/Demonstrations/STemWin/Config/FreeRTOSConfig.h#L121

And in the template file:

https://github.com/STMicroelectronics/STM32CubeH7/blob/beced99ac090fece04d1e0eb6648b8075e156c6c/Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOSConfig_template.h#L149

During code execution, if

configASSERT(0)

 gets executed, the code execution will stop, and without a debugger it is impossible to know why code got stuck.

I therefore request to please update the ST provided Header file, and add a weak function to the statement, which can later be coded by the user.

Is it possible to change the below line of code:

#defineconfigASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }

to:

#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); rvUserAssertInformFunction(__FILE__, __LINE__); for( ;; );}

and add:

__weak void rvUserAssertInformFunction(char * pF, unsigned long ln)
{
 pF = pF;
 ln = ln;
}

Please share your views.

I have already reported my concern to the STM32CubeH7 community, bit it seems they are not the ones who need to make change to the code.

https://github.com/STMicroelectronics/STM32CubeH7/issues/96

Please help.

Thanks,

Rajeev

This topic has been closed for replies.
Best answer by Khouloud ZEMMELI

Hi @Rajeev Arora​ ,

After discussed with team, as the user section was made for allowing such flexibility, so you need to add or change it by hand.

As a workaround you can change the USER SECTION as follows :

/* USER CODE BEGIN 1 */

#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)

extern void rvUserAssertInformFunction(char * pF, unsigned long ln);

#endif

#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); rvUserAssertInformFunction(__FILE__, __LINE__); for( ;; );}

/* USER CODE END 1 */

And define the function rvUserAssertInformFunction elsewhere is his application:

- In a USER SECTION of main.c / freertos.c / elsewhere

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thanks, Khouloud

2 replies

Khouloud ZEMMELI
ST Employee
December 2, 2020

Hi @Rajeev Arora​ 

Your proposal will be discussed internally with the team, I will keep you informed of any decision regarding your request.

Thanks for your feedback, Khouloud

Khouloud ZEMMELI
Khouloud ZEMMELIBest answer
ST Employee
December 18, 2020

Hi @Rajeev Arora​ ,

After discussed with team, as the user section was made for allowing such flexibility, so you need to add or change it by hand.

As a workaround you can change the USER SECTION as follows :

/* USER CODE BEGIN 1 */

#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)

extern void rvUserAssertInformFunction(char * pF, unsigned long ln);

#endif

#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); rvUserAssertInformFunction(__FILE__, __LINE__); for( ;; );}

/* USER CODE END 1 */

And define the function rvUserAssertInformFunction elsewhere is his application:

- In a USER SECTION of main.c / freertos.c / elsewhere

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thanks, Khouloud