PlatformIO Community

STM32 Platform Update broke code

I just updated from 5.7 to 6.0 of the STM platform. My previously working code is now broken. I have identified 2 differences:

  1. My interrupt routines that had the flag clearing anywhere except VERY FIRST THING all failed, mocing the register clear to be the very first command in the functions fixed this.

  2. The following code is compiling, but then failing, It is part of the statistics displaying for freeRTOS. It uses a few structs to describe a task and then creates an array of them. It fails on the last line starting with “memset”. Not sure what the problem is:

uart1_printf("Starting task manager\n"); 
    signed char *pcWriteBuffer; 
    TaskStatus_t *pxTaskStatusArray; 
    volatile UBaseType_t uxArraySize, uxArraySize2, x; 
    unsigned long ulStatsAsPercentage, ulTotalRunTime;

    /* Make sure the write buffer does not contain a string. */ 
    /* Take a snapshot of the number of tasks in case it changes while this
    function is executing. */

    //uxArraySize = uxTaskGetNumberOfTasks(); 
    /* Allocate a TaskStatus_t structure for each task.  An array could be 
    allocated statically at compile time. */

    uart1_printf("Creating task array\n"); 
    pxTaskStatusArray = (TaskStatus_t*)pvPortMalloc( uxArraySize * sizeof(TaskStatus_t)); 
    uart1_printf("Allocating task array\n"); 
    memset(pxTaskStatusArray, 0, uxArraySize * sizeof(TaskStatus_t));

False alarm!

I fixed it. Not sure how it was working before. It is possible I made a change and forgot it.

Anyway my problem was that I was never reading the initial number of tasks in. Weird because I ‘swear it was working’ with this line commented out before. To fix my self-imposed problem the following had to be uncommented:

uxArraySize = uxTaskGetNumberOfTasks();

My observation that now interrupt flag clearing has to be done strictly first does seem to still be true though.

Thank you for your patience!

1 Like