Skip to main content
Explorer
December 6, 2023
Solved

FreeRTOS STM32H743ZI FPU Assembler Error

  • December 6, 2023
  • 3 replies
  • 2628 views

Hi there,
I’m trying to compile a project using the STM32H743ZI2 Nucleo board with STM32CUBE Framework with FreeRTOS with PlatformIO.

The project can be found here:
Zafeer_FreeRTOSFromGroundUp/PlatformIO/17_WorkingWithQueueSets at main · ZafeerAbbasi/Zafeer_FreeRTOSFromGroundUp (github.com)

But basically, I’m using an extra script to add flags:

Import( “env” )

flags = [
    "-mcpu=cortex-m7",
    "-mfloat-abi=hard",
    "-mfpu=fpv5-d16",
    "-mthumb",
    "-u _printf_float",
    "-DDEBUG",
    "--specs=nano.specs",
    "-march=armv7e-m",
    "-std=gnu11",
    "-g3"
]
env.Append(CCFLAGS=flags, LINKFLAGS=flags, ASFLAGS=flags)

However I keep getting the following errors:

…\Local\Temp\ccTwSuW0.s: Assembler messages:
…\Local\Temp\ccTwSuW0.s:330: Error: selected processor does not support vstmdbeq r0!,{s16-s31}' in Thumb mode ...\Local\Temp\ccTwSuW0.s:332: Error: instruction not allowed in IT block -- stmdb r0!,{r4-r11,r14}’
…\Local\Temp\ccTwSuW0.s:352: Error: selected processor does not support vldmiaeq r0!,{s16-s31}' in Thumb mode ...\Local\Temp\ccTwSuW0.s:354: Error: instruction not allowed in IT block -- msr psp,r0’
*** [.pio\build\nucleo_h743zi\libe54\Source\portable\GCC\ARM_CM4F\port.o] Error 1

The exact instructions can be found in port.c of FreeRTOS Kernel:

void xPortPendSVHandler( void )
{
    /* This is a naked function. */

    __asm volatile
    (
    "   mrs r0, psp                         \n"
    "   isb                                 \n"
    "                                       \n"
    "   ldr r3, pxCurrentTCBConst           \n" /* Get the location of the current TCB. */
    "   ldr r2, [r3]                        \n"
    "                                       \n"
    "   tst r14, #0x10                      \n" /* Is the task using the FPU context?  If so, push high vfp registers. */
    "   it eq                               \n"
    "   vstmdbeq r0!, {s16-s31}             \n"
    "                                       \n"
    "   stmdb r0!, {r4-r11, r14}            \n" /* Save the core registers. */
    "   str r0, [r2]                        \n" /* Save the new top of stack into the first member of the TCB. */
    "                                       \n"
    "   stmdb sp!, {r0, r3}                 \n"
    "   mov r0, %0                          \n"
    "   msr basepri, r0                     \n"
    "   dsb                                 \n"
    "   isb                                 \n"
    "   bl vTaskSwitchContext               \n"
    "   mov r0, #0                          \n"
    "   msr basepri, r0                     \n"
    "   ldmia sp!, {r0, r3}                 \n"
    "                                       \n"
    "   ldr r1, [r3]                        \n" /* The first item in pxCurrentTCB is the task top of stack. */
    "   ldr r0, [r1]                        \n"
    "                                       \n"
    "   ldmia r0!, {r4-r11, r14}            \n" /* Pop the core registers. */
    "                                       \n"
    "   tst r14, #0x10                      \n" /* Is the task using the FPU context?  If so, pop the high vfp registers too. */
    "   it eq                               \n"
    "   vldmiaeq r0!, {s16-s31}             \n"
    "                                       \n"
    "   msr psp, r0                         \n"
    "   isb                                 \n"
    "                                       \n"
    #ifdef WORKAROUND_PMU_CM001 /* XMC4000 specific errata workaround. */
        #if WORKAROUND_PMU_CM001 == 1
    "           push { r14 }                \n"
    "           pop { pc }                  \n"
        #endif
    #endif
    "                                       \n"
    "   bx r14                              \n"
    "                                       \n"
    "   .align 4                            \n"
    "pxCurrentTCBConst: .word pxCurrentTCB  \n"
    ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY)
    );
}

I’m not too experienced but any help would be greatly appreciated!

    This topic has been closed for replies.
    Best answer by rockybalboa__

    The solution was based on PlatformIO platform.ini file, basically instead of:

    extra_scripts = add_hardfloat.py
    I used:
    extra_scripts = pre:add_hardfloat.py
    and that did the trick!

    ( Also I used the CM7 Port instead of the CM4 port, S/O to @RomainR. for pointing that out!

    3 replies

    ST Employee
    December 6, 2023

    Hello @rockybalboa__ 

    I'm not familliar with PlateformIO IDE, but in errors you get, it seems you are using port.c of FreeRTOS Kernel for CM4. As STM32H7 is a CM7, you should use adequate FreeRTOS port.c for CM7.

    Regards,

    Romain,   

     

    Explorer
    December 6, 2023

    Thank you for pointing that out, it really did help!

    rockybalboa__AuthorAnswer
    Explorer
    December 6, 2023

    The solution was based on PlatformIO platform.ini file, basically instead of:

    extra_scripts = add_hardfloat.py
    I used:
    extra_scripts = pre:add_hardfloat.py
    and that did the trick!

    ( Also I used the CM7 Port instead of the CM4 port, S/O to @RomainR. for pointing that out!
    ST Employee
    December 6, 2023

    Thank you @rockybalboa__ 

    Does it mean "pre:add_hardfloat.py" is a typo ?

    Regards.

    Romain,