Tuesday, August 18, 2015

Working with STM32CubeMX in Linux

I recently discovered STM32CubeMX, it's a great way to quickly get something running on any of the STM32 MCU's. I got it to work with the MDK-ARM and TrueSTUDIO demo versions in Windows. I prefer Linux for development work and don't have the budget (hobbyist) for full versions.

System Workbench for STM32 (SW4STM32) beta is available and can be made to work on Linux but is not in sync with cube. Both STM32CubeMX and SW4STM32 are evolving at a good pace (Aug 2015) and have been for some time. Currently Cube projects imported into SW4STM32 will not build even if the instructions on the System Workspace are followed.

To get around these problems I have created a makefile that builds Cube output for SW4STM32.





Setting up STM32CubeMX on Linux

Get stm32cubemx.zip from:
http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF259242
  1. Extract SetupSTM32CubeMX.exe from stm32cubemx.zip.
  2. sudo java -jar SetupSTM32CubeMX-4.9.0.exe
  3. Install in /usr/local/STMicroelectronics/STM32Cube/STM32CubeMX
  4. In that directory there will be a file STM32CubeMX.exe
  5. Do not be fooled by the exe extension, it's actually a jar file. Run it like so: java -jar STM32CubeMX.exe

Running STM32CubeMX

Make sure you select SW4STM32 as your Toolchain/IDE when generating code. Then create a subdirectory (the name of the subdirectory does not matter, I'm partial to Debug or Release) and place the following Makefile into it.

Run the makefile from within your new directory. All it's output (elf, hex, object files, ...) will be in that directory.

Makefile:

Customizing The Makefile

If you create a new project using"Middleware"s, just add the necessary subdirectorys to C_SUBDIRS and H_SUBDIRS.



No comments: