But just for a change, I thought I would give CubeMX a try to see what it is all about. My conclusion after the afternoon below is that CubeMX is interesting, but not CubeIDE. See the next page on using CubeMX to generate a Makefile, which is definitely how I want to do things.
I tripped over this video by Nick Slayter where he shows you how to get started with a F446 Nucleo board.
To get started, you need a Nucleo board and a USB cable.This yields a xxx.dmg.zip file. The Mac is nice about this. I double click on this and it does some kind of unzip on the fly. I can select the dmg from what it displays and do the install without running unzip myself. The dmg then shows the the usual graphic that asks me to drag the "thing" to my Applications directory. After this I can open up "Applications" and down near the bottom, under "S" I find STM32CubeIDE.
I open it and it wants to set up /Users/tom/STM32cubeide/workspace_2.2.0 as a workspace. It shows me RN0114 (a 36 page release note) in a browser. A bunch of marketing parades by telling me about Eclipse and VScode things I can do. They call this the "information center" and I get rid of it.
STM32CubeMX is a second piece of software that is handled independently.
This is somewhat surprising (to me anyway).
As it turns out, this is a wonderful thing.
I am unlikely to have any use for CubeIDE and will use Makefiles instead.
On the other hand, CubeMX looks interesting and useful and can nicely
be used without CubeIDE.
They call CubeMX an "initialization code generator".
I don't see it in my Applications "selector", so I use Finder. I go to Applications -- STMicroelectronics (which is a folder). Inside this folder I find STM32CubeMX and can launch it.
CubeMX offers me a "board selector" under new project. I rattle around with this to find the H747 Nucleo, and now it is offering me two selections and I have no clue which to use. Mine is a ZI2, and after more rattling around I see it, double click, and a bunch of stuff happens with a progress bar to reassure me.
Now a dialog opens. I click "generate demo code" and it shows me that it will exercise the 3 LED, user buttons, and give me a virtual COM port. I say "OK" and now I get a cute image of the chip. It tells me that 102 of 108 GPIO are available!
Pins shown in red are connected to things like the user button or LEDs.
Pins shown in yellow are things like crystals or SWD ports.
Pins shown in pale tan are power and ground.
Pins shown in grey seem to be "available".
You can zoom and pan this screen to more easily read the fine print. You can click on a pin (unless it is locked to some function) and get a menu of functions to assign to it.
The left side has a variety of interesting tools.
Up top are various tabs (including clock setup). The default it comes up with is pinout and configuration.
Finally up at project manager, we give it a name (First) and location (/Users/tom/STM32Cube). Under "toolchain" I select STM32CubeIDE -- but I could have selected "Makefile". I click "generate code" at the upper right. Now it wants to download firmware, so I tell it to do so. This is h7 firmware and it 584M in size, so it takes a while. stm32cube_fw_h7_v1130.zip. Finally it tells me the code has been successfully generated and I select "Open Project".
The project manager shows STM32Cube_FW_H7 V1.13.0 near the bottom. I am pleased that this is handled by CubeMX.
This does not open automatically when I select "Open Project" like it did for the guy in the tutorial video. I find it in the Applications folder and open it from there after closing CubeMX. It tells me there are no projects in my workspace (namely /Users/tom/STM32cubeide/workspace_2.2.0). Probably if I had given this to CubeMX as my project location this would have worked as expected. I tell it to import from /Users/tom/STM32Cube/First.
Now I see "First" in the navigator on the left. I can expand my way to Core/Src/main.c and look at it in the main window. The generated code watches for a button push and toggles all 3 LED when it sees one.
No ST-Link detectedI search and learn that this error is "common" and related to CubeIDE not having /usr/local/bin in the PATH -- this is indeed where st-link is located. The recommended workaround is to launch CubeIDE from the command line via:
/Applications/STM32CubeIDE.app/Contents/MacOS/STM32CubeIDEMore poking around reveals that st-link is the WRONG cpu type (x86), not ARM apple silicon. I delete it and try:
brew install stlinkThis of course is not at all what we are looking for. At this point, ST needs to get busy and provide their ST-link server ready to install and run on Apple silicon.
So, I try it:
cd ~/STM32Cube/First/Debug openocd -f interface/stlink.cfg -f target/stm32h7x.cfg -c "program First.elf verify reset exit"And it works just fine. The code runs. When I press the user button either all 3 LED go on, or they go off.
make clean makeStrangely, typing just "make" does the same as "make clean". When I try "make First.elf" I get:
arm-none-eabi-gcc "../Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c" -mcpu=cortex-m7 -std=gnu11 -g3 -DDEBUG -DUSE_PWR_LDO_SUPPLY -DUSE_HAL_DRIVER -DSTM32H743xx -c -I../Core/Inc -I../Drivers/STM32H7xx_HAL_Driver/Inc -I../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy -I../Drivers/BSP/STM32H7xx_Nucleo -I../Drivers/CMSIS/Device/ST/STM32H7xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.d" -MT"Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.o" arm-none-eabi-gcc: fatal error: cannot read spec file 'nano.specs': No such file or directoryThe file "nano.specs" was not in the Debug directory prior to my running "make clean" and locate does not find it anywhere on disk, so this is perplexing. Apparently the --specs option is a way to redefine the rules that gcc uses to run the various things it runs.
I waste some time here, but using this makefile is apparently hopeless.
VScode is another option, but I don't really want to go in that direction either. It is probably a better choice that CubeIDE.
What I should investigate is CubeMX with the option to generate a makefile project. That could be useful.
Tom's software pages / tom@mmto.org