Difference between revisions of "Import projects from STM32CubeMX to Embedded Studio"

From SEGGER Wiki
Jump to: navigation, search
(Import tutorial)
Line 18: Line 18:
 
This tutorial will show the steps necessary to get the resulting example project from above. But the same steps apply for any of the ST boards and MCUs in STM32CubeMX.
 
This tutorial will show the steps necessary to get the resulting example project from above. But the same steps apply for any of the ST boards and MCUs in STM32CubeMX.
   
* Start a new project in STM32CubeMX(in this example we start one for the NUCLEO-G474RE Board)
+
* Start a new project in STM32CubeMX (in this example we start one for the NUCLEO-G474RE Board)
 
* Configure your STM32CubeMX project as usual.
 
* Configure your STM32CubeMX project as usual.
 
* Go to the Project Manager tab in your STM32CubeMX project.
 
* Go to the Project Manager tab in your STM32CubeMX project.
Line 44: Line 44:
 
* In the project folder where the STM32CubeMX project and Embedded Studio project are located at create a new folder e.g. /ES and enter it.
 
* In the project folder where the STM32CubeMX project and Embedded Studio project are located at create a new folder e.g. /ES and enter it.
 
* Now copy the following files from the package folder to the project folder. In this example from /STM32G4xx -> /ES.
 
* Now copy the following files from the package folder to the project folder. In this example from /STM32G4xx -> /ES.
** STM32G4xx/Source/*_Startup.s and STM32G4xx/Source/*_Vectors.s where * is your target devices name/family.
+
** STM32G4xx/Source/<DeviceName>_Startup.s and STM32G4xx/Source/<DeviceName>_Vectors.s
** The linker script from STM32G4xx/Scripts/*_Flash.icf where * is your target devices name/family.
+
** The linker script from STM32G4xx/Scripts/<DeviceFamily>_Flash.icf.
** The memory map from STM32G4xx /XML/*_MemoryMap.xml where * is your target devices name/family.
+
** The memory map from STM32G4xx /XML/<DeviceName>_MemoryMap.xml.
 
[[File:ES_Folder_Result.PNG|thumb|Resulting folder after copying files over|none]]
 
[[File:ES_Folder_Result.PNG|thumb|Resulting folder after copying files over|none]]
 
* Now add that /ES folder via drag and drop to your Embedded Studio project in the Project Explorer window.
 
* Now add that /ES folder via drag and drop to your Embedded Studio project in the Project Explorer window.

Revision as of 09:23, 6 October 2021

This Wiki article describes how to import STM32CubeMX projects into Embedded Studio.

Setup

The following software and hardware has been used to create the following example project and tutorial:

  • STM32CubeMX 6.3.0.
  • NUCLEO-G474RE MB1367C Evalboard
  • SEGGER Embedded Studio V5.62

Reference Project: NUCLEO-G474RE_Blinky_Test.zip

The reference project will blink an LED on the eval board mentioned above.

Import tutorial

This tutorial will show the steps necessary to get the resulting example project from above. But the same steps apply for any of the ST boards and MCUs in STM32CubeMX.

  • Start a new project in STM32CubeMX (in this example we start one for the NUCLEO-G474RE Board)
  • Configure your STM32CubeMX project as usual.
  • Go to the Project Manager tab in your STM32CubeMX project.
  • Set the project name and location.
  • Set the Toolchain/IDE to STM32CubeIDE. All other settings can be kept as is.
STM32CubeMX project manager settings
  • Press the Generate Code button.
  • You will now be prompted if you want to open the projects folder. Select Open Folder and keep that folder open.
  • Open Embedded Studio.
  • Select File -> Import Project... -> Import Eclipse Project
  • Navigate to the folder where the STM32CubeIDE project is located at and select the .project file and press Open.
STM32CubeMX project folder
  • Now select Internal Toolchain and press OK.
Embedded Studio importer settings
  • If everything worked successfully you will be greeted with as success screen.
Embedded Studio import success
  • In Embedded Studio now right click the Core folder in the Project Explorer window and open the folder options.
  • Set the build configuration from Debug Internal to Common in the options window and edit option Folder->Dynamic Folder Exclude.
  • Edit the Exclude Specifications line to Core/;syscalls.c;sysmem.c;startup_*.s and press OK.
Resulting folder exclude options
  • From now on the project should already build successfully, but we are not done yet.
  • Now download your device family's CPU Support Package in Embedded Studio via Tools->Package Manager, select your device family and install the package.
  • In this example we used a STM32G474RE as a device so the package we installed is the STM32G4xx package.
  • Next go to the package folder via File->Open Studio Folder->Packages Folder and open the just installed package folder, in this case /STM32G4xx.
  • In the project folder where the STM32CubeMX project and Embedded Studio project are located at create a new folder e.g. /ES and enter it.
  • Now copy the following files from the package folder to the project folder. In this example from /STM32G4xx -> /ES.
    • STM32G4xx/Source/<DeviceName>_Startup.s and STM32G4xx/Source/<DeviceName>_Vectors.s
    • The linker script from STM32G4xx/Scripts/<DeviceFamily>_Flash.icf.
    • The memory map from STM32G4xx /XML/<DeviceName>_MemoryMap.xml.
Resulting folder after copying files over
  • Now add that /ES folder via drag and drop to your Embedded Studio project in the Project Explorer window.
  • Open project options and change the build config to common. Set the Linker Script file and the memory map file in project options to the .icf file and .xml file just copied from the packages folder.
  • Set the registers file to the Registers.xml file just copied if available.
  • Exclude file Internal Files/Cortex_M_Startup.s from the project by right clicking it and selecting Exclude From Build.
  • Done, now you can add your own code to the application and debug and develop in Embedded Studio.

Troubleshooting

  • The project builds, but debugging is not working properly and unexpected code is being jumped to.
    • Check your debug config settings. Unfortunately most CubeMX projects will have code optimization set to -Os (optimize for size) even for debug builds. Change the code optimization to 'None' instead.