Orange LED of hell

I am trying to avoid the MBED OS tools and associated debugger because it feels like I'm getting sucked into some hole that will limit what I can do. The tools that pretty much any embedded OS vendors use are Eclipse based. So, I prefer to use STM32CubeIDE which is Eclipse based, and integrate the Arduino build into a makefile project that leverages the ST-Link V2 features that the Cube IDE supports.

Moving the Arduino functionality into a makefile project has the advantage that you can control the build and cache directories that are normally in some temp directory and reuse it instead of rebuilding the whole shebang all the time. It is still not superfast but tolerable. What I did was to copy the first 2 lines of the Arduino 1.8 build (that's what I started with - their 2.x build is quite different, and I decided to stick with what I've got) and edit those lines a bit with some installation related variables into a sensible makefile. After a bit of regular Eclipse grunt work you can get it to build - not in the temp directory but one of your choice, in a fixed place. The download can be done by adding a makefile target using the download lines in a Cube project that you can simply copy and paste from the build configuration GUI of a Cube project. You can make the makefile target show up as an icon under the project node then all you need to do is double-click to build. You can also debug the target using ST-Link V2 by copying the debug setup of a Cube project into your makefile project. If you want the details let me know but you will have to learn some Eclipse gymnastics so, why not take the first shot yourself.

Regarding the debug functionality, the only downside is that I have not been able to figure out how to get a zero-optimized build, so the debugger makes weird jumps - but good enough in most cases to do what I need. There are JSON config files to change the optimization level but when applying -O0 it fails in some file. Maybe I could figure out how to run the user files with -O0 and the rest with the default -Os but I have been able to work with it as described, frustrating as it is sometimes. But at least I can work exclusively with an Eclipse makefile project for my integration build and debugging, and once in a while if I have to figure out the hardware, use an STM32CubeIDE project then copy and paste the changes into the integration build.

The Portenta has 2 boot loaders; one from Arduino that is easily overwritten by downloading a Cube project on it. This boot loader has some code that initializes the PMIC chip so if that does not happen you get no power, and it is "bricked". So, use the Arduino GUI to burn the boot loader before you power it down each time after you used a Cube IDE project. Otherwise, there is the STM32 boot loader that cannot be erased AFAIK that will save you so long as you can get power. It's probably irresponsible but I applied 3.3V many times to get it back to life. In doing so I had to use the dip switches on the breakout board to run the boot loader as I described in the link that I posted, it was a matter of some random trial and error and once I knew how to I never felt the need to figure out why it worked. Once it is back to life, burn the boot loader from the Arduino GUI and resume your work.

HTH, let me know if you need an Eclipse makefile project copy.

1 Like