Cubemx -> Makefile utility

Cores are the underlying magic that make the Arduino API possible
User avatar
Rick Kimball
Posts: 679
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Cubemx -> Makefile utility

Postby Rick Kimball » Tue Jun 16, 2015 7:39 pm

Inspired by @sheepdolls successes I decided to take another look at the latest cubemx and the HAL API. I tried the openstm32 thing... and man what a mess that is on linux at this point. It still needs to simmer some more. However, I came across a useful utility:

http://www.ba0sh1.com/stm32cubemx-gcc-makefile/
https://github.com/baoshi/CubeMX2Makefile

You use the cubemx IDE, create your configuration and then generate source code. You must target the TrueStudio IDE. This python utility reads the TrueStudio config files and spews out a makefile for arm-none-eabi-gcc. You just changed to the source directory and type make .. bingo bango .. it compiles. It is useful even if you aren't planning to use command line make. The best thing it does for you, is to identify all the include directories and define flags needed for a command line compile.. say like what you do in the platform.txt. Also, if you use the Eclipse IDE it can create a new project from a makefile. I used that feature fairly painlessly to import the cubemx files into standard eclipse and compile them.

The only downside for use linux users .. the current version of cubemx fails to create some of the required files needed for the TrueStudio code generation. I had to run to windows cubemx version to generate the files but then I used the python script from linux to do all the conversion.

* more info here *
https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Java%2FCubeMX%20project%20generation%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=291

-rick
Last edited by Rick Kimball on Tue Jun 16, 2015 11:37 pm, edited 3 times in total.

User avatar
martinayotte
Posts: 1122
Joined: Mon Apr 27, 2015 1:45 pm

Re: Cubemx -> Makefile utility

Postby martinayotte » Tue Jun 16, 2015 7:45 pm

Interesting !
What is exactly failing on Linux ? Can it be fixed ?

User avatar
Rick Kimball
Posts: 679
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Cubemx -> Makefile utility

Postby Rick Kimball » Tue Jun 16, 2015 7:49 pm

It generates a zero length ldscript file. You could generate it on windows and save it. The file is going to be the same regardless of OS.

User avatar
sheepdoll
Posts: 202
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Re: Cubemx -> Makefile utility

Postby sheepdoll » Tue Jun 16, 2015 11:30 pm

I noticed the link to the STM discussion in the OP, is a bit dated at 2014. The version discussed is CubeMX (4.5.0) The version I am running is (4.8.0) which seems to work on the mac. The only issue I have found so far is it is not possible to edit the some fields in the configuration tab.

I did a compare between the True Studio ld file and the SW4STM32 I chose to use. There are no differences other than the boilerplate header at the top.

Last I saw in the ST forums, was that there are issues with case sensitivity on the non windows OS platforms. This may not be allowing some paths to be generated.
As I noted in the wall-o-text thread, I find that if I generate all libraries first, then switch to only include libraries, I get some of the missing sections like the gcc startup paths with the small s type that has to be made to a large S for the Arduino build system to find.

I have not tried eclipse or the OpenSTM32 yet. OSTM does not seem to have a lot of traffic, and you have to register to browse. There is an older thread regarding OSX and the installer seems to want to run as windows binary. Eventually I may want to use OSTM for more serious project. For now I can blink LEDs and send serial strings with the ArduinoIDE.

The utility does look interesting. I do miss having a GUI debugger, although I think these are 3rd party plug-ins under eclipse.

User avatar
sheepdoll
Posts: 202
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Re: Cubemx -> Makefile utility

Postby sheepdoll » Thu Jun 18, 2015 2:42 am

I had better luck with this than the eclipse/openOCD.

the TRUEStudio is creating a zero sized .ld file under OSX.
I option copied the .ld from SW4STM32 and renamed it. From my experiments on windows (I thought I made this on the mac) The files are identical other than boilerplate.

The python script complained about 'Unknow source file type: Drivers/CMSIS/null' so I hacked it out with comments. The makefile and ld were generated. Both look reasonable. May attempt an import into my crippled eclipse.

Will see what happens next.

User avatar
Rick Kimball
Posts: 679
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Cubemx -> Makefile utility

Postby Rick Kimball » Thu Jun 18, 2015 3:44 am

After you have generated the Makefile, does it work on OS/X ?

User avatar
sheepdoll
Posts: 202
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Re: Cubemx -> Makefile utility

Postby sheepdoll » Thu Jun 18, 2015 6:13 am

Rick Kimball wrote:After you have generated the Makefile, does it work on OS/X ?

It seems to. If I run make it creates a build folder with an .elf file and the other files in it.

I can not tell what is happening with eclipse. When I open existing c/c++ makefile project it includes everything in the folder. Eclipse goes through the process of making, but I can not find the folder it is making into. Most of the eclipse tutorials are out of date for a version called kepler. The one I installed is supposedly the latest Luna. As I noted in the other thread, I had a lot of problems installing eclipse on 10.7.5 The online tutorials have the user making symlinks and overriding important stuff.

I gave up attempting to install a second set of ARM GCC tools and just pointed the Eclipse settings at the Arduino.cc tools that seem to work.

User avatar
sheepdoll
Posts: 202
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Re: Cubemx -> Makefile utility

Postby sheepdoll » Thu Jun 18, 2015 9:09 pm

I finally got a makefile to run under eclipse.

I had to manually check and set the paths in about half a dozen locations by right clicking on the various project files to open various different properties dialogs, which do not always reflect the same values of the properties or preferences dialogs. Similar things will need to be done with OpenOCD and gdb connections.

I am probably confounded in that I am running this under OSX 10.7.5 and chose to point things to the Arduino.cc installed tools rather than download a second set of tools. The Arduino.cc tools still seem to be built with compatibility back to 10.7.5.

(OT) I am trying to stay with 10.7.5 as long as I can as Apple pulled MIDI support from QuickTime (should really be now called Quartz graphic GPUTime) in the newer OS revisions. This breaks being able to play MIDI from the finder by just hitting a space bar. With 10,000+ midi files on my drive, I like being able to browse MIDI from coverflow/Quicklook.(/OT)

madias
Posts: 811
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Cubemx -> Makefile utility

Postby madias » Thu Jun 18, 2015 9:55 pm

Code: Select all

 This breaks being able to play MIDI from the finder

Wow. I didn't mentioned it, before you post it... (ok, I'm not active in music at the moment (except of building analog/digital hybrid synth from the core) , but my ~10000 drum loops want be easy to preview anymore). Shame on apple again, they really lost bit per bit the focus of their formally target audience (graphic artist and musician) :/


Return to “Cores”

Who is online

Users browsing this forum: No registered users and 1 guest