Skip to main content
Heiko Jakob
Associate
October 28, 2017
Question

STM32CubeMX 4.23.0 syscalls.c bugs ?

  • October 28, 2017
  • 3 replies
  • 1224 views
Posted on October 28, 2017 at 14:31

Hi,

i'm using STM32CubeMX V 4.23.0 to build a project for a stm32f107vct with FatFs, LWIP & FreeRTOS using the gcc-arm-none-eabi-6-2017-q2-update toolchain.

Compiling the generated syscalls.c fails due various errors (see output below).

  1. One problem is that '

    #

    ifdef

    _SYS_TIME_H_' should be '

    #

    ifndef

    _SYS_TIME_H_', because timezone is already defined via the generated <sys/time.h> include in gcc-arm-none-eabi-6-2017-q2-update/arm-none-eabi/include/sys/time.h and _SYS_TIME_H_ is therefore already set.

    #ifdef _SYS_TIME_H_

    struct timezone {

    int tz_minuteswest; /* minutes west of Greenwich */

    int tz_dsttime; /* type of dst correction */

    };

    #endif

  2. gcc relies on __asm_() instead asm() when using ANSI-C or STD-C so the following generated statement should be changed

    caddr_t _sbrk(int incr)

    {

    extern char end

    asm

    ('end'); // should be

    __

    asm__

    ('end');

    static char *heap_end;

    char *prev_heap_end,*min_stack_ptr;

With best regards

Heiko Jakob

arm-none-eabi-gcc -mthumb -mcpu=cortex-m3 -mfloat-abi=soft -ffunction-sections -fdata-sections -Os -flto -fno-exceptions -Wall -DSTM32F107xC -c -g -Iinclude -Ilib/STM32CubeMX/Inc -Ilib/STM32CubeMX/Drivers/CMSIS/Include -Ilib/STM32CubeMX/Drivers/STM32F1xx_HAL_Driver/Inc -Ilib/STM32CubeMX/Drivers/CMSIS/Device/ST/STM32F1xx/Include -Ilib/STM32CubeMX/Middlewares/Third_Party/LwIP/src/include -Ilib/STM32CubeMX/Middlewares/Third_Party/LwIP/system -Ilib/STM32CubeMX/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -Ilib/STM32CubeMX/Middlewares/Third_Party/FreeRTOS/Source/include -Ilib/STM32CubeMX/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3 -Ilib/STM32CubeMX/Middlewares/Third_Party/FatFs/src -Ilib/STM32CubeMX/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -std=c11 -MMD -MP -MF 'build/Debug/GNU_ARM_NONE_EABI_6_2017Q2-Linux/lib/STM32CubeMX/Src/syscalls.o.d' -o build/Debug/GNU_ARM_NONE_EABI_6_2017Q2-Linux/lib/STM32CubeMX/Src/syscalls.o lib/STM32CubeMX/Src/syscalls.c

lib/STM32CubeMX/Src/syscalls.c: In function '_sbrk':

lib/STM32CubeMX/Src/syscalls.c:98:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'asm'

extern char end asm('end');

^~~

lib/STM32CubeMX/Src/syscalls.c:98:18: warning: implicit declaration of function 'asm' [-Wimplicit-function-declaration]

lib/STM32CubeMX/Src/syscalls.c:103:15: error: 'end' undeclared (first use in this function)

heap_end = &end;

^~~

lib/STM32CubeMX/Src/syscalls.c:103:15: note: each undeclared identifier is reported only once for each function it appears in

lib/STM32CubeMX/Src/syscalls.c: At top level:

lib/STM32CubeMX/Src/syscalls.c:129:8: error: redefinition of 'struct timezone'

struct timezone {

^~~~~~~~

In file included from lib/STM32CubeMX/Src/syscalls.c:75:0:

/opt/gcc-arm-none-eabi-6-2017-q2-update/arm-none-eabi/include/sys/time.h:50:8: note: originally defined here

struct timezone {

^~~~~~~~
    This topic has been closed for replies.

    3 replies

    Technical Moderator
    October 30, 2017
    Posted on October 30, 2017 at 11:49

    Hello

    jakob.heiko

    ,

    I confirm your reported issue and I raised it internally to the appropriate team.

    Best Regards

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Sirma Siang
    ST Employee
    October 30, 2017
    Posted on October 30, 2017 at 16:59

    Hello

    jakob.heiko

    ,

    I first thank you for your comment.

    The timezone definition was necessary because of lwip:sockets.h. That code is coming from LWIP community and ST does not change it.

    To avoid the timeval multidefinition, the pragma_SYS_TIME_H_ had to be defined at build level (btw: you should have it in the generated makefile), thus timezone had to be added 'manually', and this is done in the syscalls.c.

    Have you modified the generated makefile ?

    Kind regards

    Sirma

    Cyril FENARD
    ST Employee
    May 4, 2018
    Posted on May 04, 2018 at 13:45

    Hi

    jakob.heiko

    ‌,

    Most recent available version of CubeMX I used, i.e. 4.25, brings new defines for compilation line in Makefile.

    Please find here after some evidence log:

    make -C Canada_MkI BINPATH=/cygdrive/c/gcc-arm/bin -f Makefile -k

    make: Entering directory '/cygdrive/i/STM32/CUBE_MX/CubeMX_7921/support/Canada_MkI'

    mkdir build

    ...

    /cygdrive/c/gcc-arm/bin/arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb -D_TIMEVAL_DEFINED -D_SYS_TIME_H_ -DUSE_HAL_DRIVER -DSTM32F107xC -DUSE_FULL_LL_DRIVER

    -I../Inc

    ...

    -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF'build/ethip6.d' -MT'build/ethip6.d'

    -Wa,-a,-ad,-alms=build/ethip6.lst ../Middlewares/Third_Party/LwIP/src/core/ipv6/ethip6.c -o build/ethip6.o

    ...

    /cygdrive/c/gcc-arm/bin/arm-none-eabi-size build/Canada_MkI.elf

    text data bss dec hex filename

    86072 500 41364 127936 1f3c0 build/Canada_MkI.elf

    /cygdrive/c/gcc-arm/bin/arm-none-eabi-objcopy -O ihex build/Canada_MkI.elf build/Canada_MkI.hex

    /cygdrive/c/gcc-arm/bin/arm-none-eabi-objcopy -O binary -S build/Canada_MkI.elf build/Canada_MkI.bin

    make: Leaving directory '/cygdrive/i/STM32/CUBE_MX/CubeMX_7921/support/Canada_MkI'

    NOTE: I modified the 'Project Settings', i.e.,in 'Advance Settings', 'Driver Selector' as LL for RTC.

    Hope this helps completing this thread.

    Regards.

    Cyril