Problem creating new TrueStudio project for STM32L053 (and I assume all STM32L0 parts) in STM32CubeMX v5.0.1
I updated CubeMX to 5.0.1 today, then created a new project for the Nucleo-64-STM32L053 board. I'm using Atolic TrueStudio for STM32 v9.2.0 as the IDE and toolchain.
I set up the project for the board, selecting and configuring peripherals, along with FreeRTOS and USB device (virtual com port), then generated the code; I selected the "Advanced" option under "Application Structure" in the project settings. For this project, the firmware STM32Cube_FW_L0_V1.11.0 is being used.
My usual practice is to build the generated project before I start changing things. This revealed a number of problems right off:
- The generated project included the startup code directories for KEIL, IAR, and GCC under "Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates", (the "arm", "gcc", and "iar" directories), and under each of those were 20 chip-specific assembly files. In my projects for other devices made with earlier versions of STM32CubeMX (pre 5.0) only have the "gcc" directory (or nothing at all) under "Templates", and the actual startup file was in the top-level project directory. The builder attempts to assemble the KEIL versions of the .s files under the "arm" directory, and the gas assembler chokes on them. I excluded the "arm" and "iar" directories, along with the extra startup files for the L0 devices that I'm not targeting, and tried to build again.
- The next set of 551 errors detected are in "Drivers/CMSIS/Include/arm_math.h" because nothing is defining "ARM_MATH_CM0" in the generated project. I went into project properties, and added "ARM_MATH_CM0" to the symbol definitions in the "C/C++ Builder|Settings|Defined Symbols" pane, applied the change, and tried to build.
- The next 4 errors detected are in the file "Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_desc_template.c", which should not have been copied to the project, as the generated file "usbd_desc.c" is under "USB_DEVICE/App" along with the header file "usbd_desc.h". I excluded the template file from the build and tried again.
- The build gets quite a bit further with over 100 warnings, but then fails in the linker due to multiply defined symbols encountered because of the file "system_stm32l0xx.c" appearing in two places. I excluded the one from "Drivers/CMSIS/Devicee/ST/STM32L00x/Source/Templates", (actually, the entire "Templates" directory") and tried again...
- With this, the build succeeds
My impression is that this is a bug in the tool:
- STM32CubeMX is copying files it doesn't need into the project directory and not excluding them from the build.
- Something should be defining the "ARM_MATH_CM0" symbol for the project; if it's not supposed to be in a header file, then it needs to be added to the project file build settings.
Updates:
- I missed one of the templates that must be excluded in the above for the build to succeed: "Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_msp_template.c"; again, this file should not have been copied from the firmware repo by STM32CubeMX.
- This part doesn't have enough RAM to do what I need to do with FreeRTOS, so I pulled that from the configuration; it did not affect what was copied other than the FreeRTOS sources and header files (and the elimination of the generated free_rtos .c and .h files)
