Restoring SW4STM32 Project Properties Settings with STM32CubeMX

For STM32 development I use STM32CubeMX to generate the project and the initialisation code, and then I load it in SW4STM to edit and compile the code. One of the main attractions of STM32CubeMX is that it sets up all the of the dependencies and middleware in your project configuration.

I was modifying my Post-Build steps in Project->Properties->C/C++ Build->Settings when I accidentally deleted all of the entries in my configuration by clicking “Restore Defaults”. This cleared all of my compiler, linker and assembler settings that STM32CubeMX generates.


That “Restore Defaults” button in the bottom right deletes more than than it implies


The result of this is a bunch of build-errors.


Normally if you mess up something, you can just regenerate the project using STM32CubeMX and, as long as you put your user code in the right places, it will regenerate the auto-generated part of the project without touching your code. However it turns out that it doesn’t necessarily regenerate your project settings. Of course you could manually re-enter the settings yourself, however the whole appeal of STM32CubeMX is that I don’t need to know this stuff – so I don’t.

I found a solution after a few hours of trying stuff out:

  1. Close the project in System Workbench (SW4STM32): Right click on your project, delete, OK. (This  does not actually delete from disk as the name implies).
  2. Open a terminal and cd to your workspace. Delete the .settings folder and the .cproject file using the command: rm .cproject; rm -rf .settings/
  3. Regenerate your project in STM32CubeMX
  4. Reopen the project in System Workbench (SW4STM32)

The project properties should have been restored and those build errors gone.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s