AnsweredAssumed Answered

printf issue of lcd_log layer of STM32F7 when using GCC Toolchain

Question asked by tarhan.farabi on Nov 10, 2016
Latest reply on Nov 14, 2016 by tarhan.farabi
Hi, 

I'm working on a project which is based on STM32F7. In order to get used to the F7 architecture, I am using STM32F746 Disco. board with Gnu-Arm-Gcc-Toolchain with Eclipse Ide on Windows instead of Keil. I managed to run FreeRtos and LCD without a problem. 

While I am trying to implement the LwIP stack as exemplified by the "LwIP_HTTP_Server_Netconn_RTOS" example in the STM32F7Cube package, I have faced with a problem. I noticed that lcd_log layer halts the system whenever I call the "LCD_UsrLog" function. LCD_UsrLog function is calling the printf. The printf seems that it is calling "__io_putch" if we use GCC, and "fputc" if we use Keil as seen below: (lcd_log_conf.h)

/* Redirect the printf to the LCD */
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
   set to 'Yes') calls __io_putchar() */
#define LCD_LOG_PUTCHAR int __io_putchar(int ch)
#else
#define LCD_LOG_PUTCHAR int fputc(int ch, FILE *f)
#endif /* __GNUC__ */

/
* Redirect the printf to the LCD */
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
   set to 'Yes') calls __io_putchar() */
#define LCD_LOG_PUTCHAR int __io_putchar(int ch)
#else
#define LCD_LOG_PUTCHAR int fputc(int ch, FILE *f)
#endif /* __GNUC__ *

And then it continues like this in lcd_log.c:

LCD_LOG_PUTCHAR
{
 
  sFONT *cFont = BSP_LCD_GetFont();
  uint32_t idx;
   
  if(LCD_Lock == DISABLE)
  {
    if(LCD_ScrollActive == ENABLE)
    {
      LCD_CacheBuffer_yptr_bottom = LCD_CacheBuffer_yptr_bottom_bak;
      LCD_CacheBuffer_yptr_top    = LCD_CacheBuffer_yptr_top_bak;
      LCD_ScrollActive = DISABLE;
...



LCD_LOG_PUTCHAR
{
 
  sFONT *cFont = BSP_LCD_GetFont();
  uint32_t idx;
   
  if(LCD_Lock == DISABLE)
  {
    if(LCD_ScrollActive == ENABLE)
    {
      LCD_CacheBuffer_yptr_bottom = LCD_CacheBuffer_yptr_bottom_bak;
      LCD_CacheBuffer_yptr_top    = LCD_CacheBuffer_yptr_top_bak;
      LCD_ScrollActive = DISABLE;
....

The example is working well in Keil as expected. I don't know how to enable small printf option as noted in the file lcd_log_conf. What is the flag of that option for linker? Or is there any other thing that I should do like changing syscalls.c? By the way, I don't have the file "syscalls.c" added to the project. ST dropped a "syscalls.c" for SW4ST but I don't know how to use it because it caused another problems when I added it to my project. 

Any help will be appreciated. Thanks in advance..


Outcomes