STM32 CubeIDE and CMSIS bare metal project
Remarks:
Steps:
Install and run STM32 CubeIDE
Create new project – select STM32 Project (from menu File or right-click in Project Explorer)
In MCU/MPU selector type “f411” select “STM32F411RE” or search in List
Fill Project Name and select radio-button Empty in Targeted Project Type
CubeIDE creates default file-structure “empty” project:
Simplify files structure – remove file …RAM.ld , move file startup….s to Src folder and remove Startup folder
Create a ”New Source Folder ” named “CMSIS ” in the project tree – at the same level as Src folder
Find a place, where is Repository of CubeIDE – see menu Window /Preferences item STM32Cube /FirmwareUpdater
Search the directory from preferences and there must be at least one folder – STM32Cube_FW_F4_Vx.xx.x
If it’s not there, you've never created a “F4 Cube” project and you have to do it at least once:
Create new project with any STM32F4 with choice Targeted Project Type to STM32Cube (!)
CubeIDE automatically downloads necessary files for F4 projects (firmware)
You can delete created project (even from disk), firmware files remains in repo-folder
Or simpler alternative – menu Help / Manage embedded software packages and install last repo for STM32F4
Now copy files (drag-drop etc.) from repository folder STM32Cube_FW_F4_Vx.xx.x (select last installed version) to project - into our CMSIS folder :
Drivers\CMSIS\Include\cmsis_compiler.h
Drivers\CMSIS\Include\cmsis_gcc.h
Drivers\CMSIS\Include\cmsis_version.h
Drivers\CMSIS\Include\core_cm4.h
Drivers\CMSIS\Include\mpu_armv7.h
Drivers\CMSIS\Device\ST\STM32F4xx\Include\stmf4xx.h
Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f411xe.h
Drivers\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h
Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
Folder tree looks like this:
OK, files are located to their folders, now we must be update “project settings”
Right click on project and last menu-item “Properties ” or menu Project or …
Item C/C++ General / Path and Symbols / tab Includes … add path to CMSIS folder – there are our new header files (and check “For all configurations”)
Next, if wee created CMSIS folder as “Source folder ”, item in tab Source location is filled
If not, add CMSIS folder to “Source folders”
Add primary include (#include <stm32f4xx.h> ) to beginning of main.c file and you will receive error (not just one) after compilation (e.g. Build):
“Please select first the target STM32F4xx device used in your application (in stm32f4xx.h file)”
OK, we use F411RE – copy symbol STM32F411xE from line 154 in file stm32f4xx.h and add to symbols in project
Project /Properties – C/C++ Build /Settings – tab Tool Settings – item MCU GCC Compiler /Preprocesor
Add our symbol STM32F411xE
Remove ambiguous symbol STM32F411RETx
...
Now program can be compiled with only one warning about FPU, but “FPU things” solves function SystemInit in source file system_stm32f4xx.c , so we can remove preprocessor lines from the file main.c
Try simple LED blinking code and it works !!
Žádné komentáře:
Okomentovat