05 - SW4STM32 - Tips and Tricks
05 - SW4STM32 - Tips and Tricks
T.O.M.A.S Team
2
• There are two ways how to generate project files for SW4STM32 from STM32CubeMX application:
1. Generate the toolchain project files in STM32CubeMX user project root folder (Generate under root
checkbox should be selected) -> we will use this option during this session
2. Generate the toolchain project files in dedicated toolchain folder (Generate under root checkbox should
be not selected)
• Warning: Choosing to copy the project into workspace will prevent any further synchronization
between changes done in Eclipse and changes done in STM32CubeMX as there will be 2 different
copies of the project.
Useful project settings in SW4STM32
configuring C dialect and parallel build 6
Project->Properties
C/C++ Build->Settings->Tools Settings tab MCU GCC Compiler->Dialect
1. Configure C standard
to C99 to avoid
possible compilation
errors
1
• The indexer uses the parser to create a database of project files that provides the
basis for search, navigation features and parts of content assist (Ctrl+Space
feature).
• The indexer runs on a background and reacts to resource change like:
Project creation/deletion
Source files creation/deletion
File imports
Source file content changes
• It is possible to customize the behavior of the indexer (or turn it off) for each project
within the workspace separately.
Compiler optimization levels 8
• Optimization levels are accessible within project properties (right click the project name)
• Within project Properties select:
C/C++ Build -> Settings ->Tool Settings->MCU GCC Compiler->Optimization From
• From drop-down menu select required optimization level
• Click Apply->OK buttons when completed
Issue with missing _IRQn 9
Example: How to erase Flash memory using command line STLink Utility application from SW4STM32
1
2
1. Select External Tools Configuration from Run
configuration option 3
2. Double click Program to create new configuration
3. Browse ST-LINK_CLI.exe within File System
4
4. Add –c SWD UR –ME arguments
• -c SWD use SWD to connect to the target
• UR connect under reset
• -ME mass erase of the FLASH memory
General->Workspace
Run/Debug->Launching
Adding files to the project 12
3
5
File linked to the folder
4
File will be imported
as link if selected (by
default not selected)
2
Importing projects into workspace
import from archive file
1. Select File->Import from SW4STM32 main menu
1
2
Auto completion of the generic C code 17
}
Managing output files
18
useful modifications in post-build steps
• Open properties window for the project (ProjectProperties)
• Select C/C++BuildSettingsBuild Steps
• Modify Command field using below information
(this is possible to add new commands after a && string)
arm-none-eabi-size “out_file”
Restoring default configuration
19
resetting the perspective
• Perspective is a configuration of the windows and toolbars within current SW4STM32 workspace.
• There are different perspectives for editing, debugging, file sharing etc.
• Perspectives can by modified by the user (WindowPerspective)
• There is a function available to reset the perspective to its default view.
• This option is available in WindowPerspectiveReset Perspective
Example:
There are few typical root causes of the issues when entering debug mode:
• Wrong version of the HW debugger selected: i.e. STLinkV2-1 instead of STLinkV2 or vice versa
• Already running debug session(s)
• STLink owned by other debug/programming application (i.e. STMStudio, STLink Utility)
• A “ghost” GDB process existing in PC memory and locking an access to the debug port
• Wrong connection type selected. Debugged MCU requires connect under reset option – it can be
corrected within .cfg configuration file or by erasing the memory by STLink Utility application
Some PC oriented issues can be verified by connection trial using STLink Utility. Those are typically:
• Bad quality USB cable (especially when we use board with high current consumption)
• An issue with USB port (some USB3.0 ports show problems with correct operation with STLink)
In most of the cases root cause can be tracked by turn-on more verbose debug session
(please refer to the next slide)
Issues with entering debug session
22
more verbose debug session
Closed projects
Managing debug session
27
multiproject workspace
www.st.com/mcu