cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U031 OpenOCD target configuration file

ticoune91
Associate II

Hello,

I would like to program the STM32U031 with OpenOCD on the NUCLEO-U031R8. However, I cannot find a proper target configuration in the list provided by /usr/share/openocd/scripts/target/

I tried stm32f0x.cfg, stm32g0x.cfg, stm32l0.cfg and stm32u5.cfg and no one worked... The farther I was able to go was with stm32l0.cfg which crashed at the step:

STM32L0: Enabling HSI16

I tried the interface configuration file stlink.cfg and stlink-v2.cfg and both gave the same results...

I looked online to find the proper stm32u031 target configuration file for openocd but I wasn't able to find it.

Can someone please help me find the proper file ?

Thank you!

5 REPLIES 5
Pavel A.
Evangelist III

Just start debugging a project for this board with CubeIDE and specify OpenOCD as debugger backend. It will create a config file automatically.

Hello Pavel.

Ideally, I want my workflow/toolchain to be STM32CubeMX -> CMAKE -> openOCD -> GDB so I would like to avoid CubeIDE.

Anyways, I installed CubeIDE and I have use the file stm32u0x.cfg found in /opt/st/stm32cubeide_1.15.1/plugins/com.st.stm32cube.ide.mcu.debug.openocd_2.2.0.202401261111/resources/openocd/s
t_scripts/target/stm32u0x.cfg

I tried the following command to program the STM32U031: openocd -s /opt/st/stm32cubeide_1.15.1/plugins/com.st.stm32cube.ide.mcu.debug.openocd_2.2.0.202401261111/resources/openocd/st_scripts/ -f /opt/st/stm32cubeide_1.15.1/plugins/com.st.stm32c
ube.ide.mcu.debug.openocd_2.2.0.202401261111/resources/openocd/st_scripts/interface/stlink.cfg -f /opt/st/stm32cubeide_1.15.1/plugins/com.st.stm32cube.ide.mcu.debug.openocd_2.2.0.202401261111/resources/openocd/s
t_scripts/target/stm32u0x.cfg -c "program hello_world_cmake.elf verify reset exit"

However, this crashed with the following message :

embedded:startup.tcl:1360: Error: Infinite eval recursion
in procedure 'script'  
at file "embedded:startup.tcl", line 28

Any idea to help me out at this point ?

Thank you for your time and patience.

Pavel A.
Evangelist III

Are you using the ST fork of OpenOCD or something else? U0 is a new family, old OpenOCD versions may be not aware of it yet. 

Hi Pavel,

I am on the OpenOCD release found in Fedora repository. Version 0.12. Not the ST Fork of OpenOCD. There are no provided binairies and it looks complicated to build....

 

I was able to make it work using the STMCubeIDE OpenOCD generated command as inspiration : 

/opt/st/stm32cubeide_1.15.1/plugins/com.st.stm32cube.ide.mcu.externaltools.openocd.linux64_2.3.100.202312181736/tools/bin/openocd "-f" "GPIO_IOToggle Debug (1).cfg" "-s" "/home/deck/STM32
CubeIDE/workspace_1.15.1/GPIO_IOToggle/STM32CubeIDE" "-s" "/opt/st/stm32cubeide_1.15.1/plugins/com.st.stm32cube.ide.mcu.debug.openocd_2.2.0.202401261111/resources/openocd/st_scripts" "-s" "/opt/st/stm32cubeide_1
.15.1/plugins/com.st.stm32cube.ide.mpu.debug.openocd_2.1.100.202402161658/resources/openocd/st_scripts" "-c" "gdb_report_data_abort enable" "-c" "gdb_port 3333" "-c" "tcl_port 6666" "-c" "telnet_port 4444" -c "p
rogram hello_world_cmake.elf verify reset exit"

 

The GPIO_IOToggle Debug (1).cfg file was generated by STMCubeIDE and hello_world_cmake.elf is the builded file from the CMAKE project. I am able to program and even debug with GDB remote target on port 3333 if I remove the "exit" word from the command! 

 

It uses the bin of the STM32CubeIDE OpenOCD install instead of my Fedora OpenOCD, but it works and it suits my need for the moment.

 

Thank you for your help and I hope my solution can help someone else.

U0 support patch found on OpenOCD gerrit but in still early stage.
https://review.openocd.org/c/openocd/+/8087

I built patched(and need small fix) version for Windows works well on NUCLEO-U083RC.

If you have interested in ,try this.