cancel
Showing results for 
Search instead for 
Did you mean: 

Once again. Bizarre in the set STM32CubeMX + FreeRTOS + Atollic TrueSTUDIO.

ivanbraga
Associate II

A little of history.

I was working on a board that had a stm32f407, where it had a partial code and printf function worked, so long.

Soon after, I received an update to stm32f429 at that moment gave $% & #.

Try debugging a third-party code where you do not have to read lines and lines of code to understand the problem.

Add to this a third-party rtos, it will stink, at the very least!

The tip is, I stopped debugging when I realized and I could not understand where the bad smell came from.

To reproduce the problem:

tools produced;

purchased tools;

tools used;

By ST.

Putting it together STM32CubeMX 5.1.0 + Atollic TrueSTUDIO + Freertos.

Put a printf inside a task. Of course with a usart port configured.

It certainly will not work.

First add this in your usart.c without changing even a line in syscalls.c.

/ * USER CODE BEGIN Includes * / 
#include <errno.h>
#include   <unistd.h>
 
/ * USER CODE END Includes * /
 
 
/ * USER CODE BEGIN 1 * /
 
int_read (int file, char * ptr, int len) 
{ 
    int n; 
    int num = 0; 
    uint8_t ch = '\ 0'; 
    HAL_StatusTypeDef status = HAL_TIMEOUT;
 
    switch (file) { 
        case STD_FILEN: 
            for (n = 0; n  
                of { 
                    status = HAL_UART_Receive (& huart1, (uint8_t *) & ch, 1, 1); 
                    HAL_UART_Transmit (& huart1, & ch, 1, 1); 
                } while (status! = HAL_OK);
                 * ptr ++ = ch;
                 num ++;
             }
             break; 
        default:
             errno = EBADF;
             return -1; 
    }
     return num;
 }
 
  
int _write (int file, char * ptr, int len) 
{ 
    int n;
     switch (file) { 
        case STDOUT_FILENO: / * stdout * /
             for (n = 0; n  
                HAL_UART_Transmit (& huart1, (uint8_t *) ptr ++, 1, 1);
             } 
            break;
         case STDERR_FILENO: / * stderr * /
             for (n = 0; n 
                 HAL_UART_Transmit (& huart1, (uint8_t *) ptr ++, 1, 1);
             }
             break;
         default: 
            errno = EBADF; 
            return -1;
     }
     return len; 
}
 / * USER CODE END 1 * /

To solve the problem, now add a printf before MX_FREERTOS_Init ();

printf ("running working ... \ r \ n");
 
MX_FREERTOS_Init ();

It will certainly work.

I love seeing these **** done by programmers paid by the contractors themselves "bosses", and nothing is checked.

Please disregard words of anguish.

1 REPLY 1
ivanbraga
Associate II

I want to see the st-ninjas answer