Unable to get new project running for STM32L476

Hello-
We are working with FreeRTOS for the first time as it is a requirement for a different software suite we wished to use. The processor we need to run is the STM32L476 and our development environment is Segger Embedded Studio.

To start off we downloaded the kernel-only archive and set it up using the portable\GCC\ARM_CM4F files as directed by the starting guide. This guide:

Running the RTOS on a ARM Cortex-M Core

…then says “If you are using an STM32 with the STM32 driver library then ensure all the priority bits are assigned to be preempt priority bits by calling NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); before the RTOS is started”. The problem here is that function NVIC_PriorityGroupConfig doesn’t exist in the core kernel files. We had to download the entire archive to find that this function is frequently defined in STM32 StdPeriph_Driver files (specifically, in misc.c). It is a puzzlement why these driver directories are scattered around all the demo example projects rather than being placed together in a common directory. We also failed to find a STM32L4xx_StdPeriph_Driver directory anywhere, so instead we took the files from the F4xx directory and modified them. This included commenting out the IS_SYSTICK_CLK_SOURCE and IS_NVIC_PRIORITY_GROUP macros from the misc.h file as they were flagged as having multiple definitions. Also changed to include stm32l4xx.h rather than stm32f4xx.h.

Doing this allowed the project to compile but now the code is trapped in:

configASSERT( ucMaxSysCallPriority );

…on line 379 of port.c. The top of port.c declares:

static uint8_t ucMaxSysCallPriority = 0;

…which reads as if it is hard-coded to automatically fail the assert test. Regardless, changing the value to 1 did not help and it is not clear from the help webpage referenced above what other steps need to be taken to get things to execute correctly. Any assistance would be appreciated.

@Eqqm4n

It is a puzzlement why these driver directories are scattered around all the demo example projects rather than being placed together in a common directory.

Those implementations are for specific demos and are not generic to all the supported hardware.

The problem here is that function NVIC_PriorityGroupConfig doesn’t exist in the core kernel files

Thats a function provided by ST and shouldn’t be part of the core kernel files. If you are configuring your project using STM32 cube the relevant CMSIS files generated for your target achitecture should contain NVIC_SetPriorityGrouping. Calling NVIC_SetPriorityGrouping( 0 ); before starting the scheduler should ensure all the priority bits are assigned to be preempt priority bits.

code is trapped in:

configASSERT( ucMaxSysCallPriority );

Whats the value of configMAX_SYSCALL_INTERRUPT_PRIORITY set in your FreeRTOSConfig.h?
The reason for the assert could be an incorrect setting of configMAX_SYSCALL_INTERRUPT_PRIORITY.

As stated we are using Segger Embedded Studio for development. Their directions for getting FreeRTOS to work are here-
https://wiki.segger.com/How_to_create_a_simple_FreeRTOS_project_with_Embedded_Studio

Since the-

…directions also state that “Most systems default to the wanted configuration, with the noticeable exception of the STM32 driver library”, it might be assumed that since we’re using Segger’s start-up files and not ones from ST, we might fall into the “most systems” category. Removing the NVIC_PriorityGroupConfig call and taking the copied misc.c file out of the project leads the code to be trapped at the same assertion.

configMAX_SYSCALL_INTERRUPT_PRIORITY and configMAX_API_CALL_INTERRUPT_PRIORITY are defined as 1. The default value in the file was zero, leaving it at zero traps us on the same assertion.

I think for a Cortex-M4 CPU configMAX_SYSCALL_INTERRUPT_PRIORITY defined to 1 is not right. Did you dig into the doc you mentioned ? Sure, it’s a bit convoluted for Cortex-M and it’s confusing, but it has to done right.

Could you try setting the configMAX_SYSCALL_INTERRUPT_PRIORITY to something higher, for example:


#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5

#define configMAX_SYSCALL_INTERRUPT_PRIORITY        ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )