There is a path bug in STM32CubeProgrammer v2.2.1 causing "Error: unknown or unsupported device (DevID = 0x0000)"
The command line STM32_Programmer_CLI looks for a database file using a relative path "../Data_Base/STM32_Prog_DB.xml". This causes the "Error: unknown or unsupported device (DevID = 0x0000)" and a segfault.
The command line tool should look for this "STM32_Prog_DB.xml" relative to the executables path rather than the current working directory.
To demonstrate this issue I have created the following example:
Here I am calling the command directly from the $PATH and you see the error
(Alans-MacBook-Pro)-(alan)-(~/projects/test)
(! 783)-> STM32_Programmer_CLI -c port=swd
-------------------------------------------------------------------
STM32CubeProgrammer v2.2.1
-------------------------------------------------------------------
ST-LINK SN : 36FF72064D59303629401543
ST-LINK FW : V2J33S7
Voltage : 3.21V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Cannot identify the device
Error: unknown or unsupported device (DevID = 0x0000)
Segmentation fault: 11Now I move into the application directory and run the command in it's installed location:
Alans-MacBook-Pro)-(alan)-(~/projects/test)
(! 785)-> cd /Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin/
(Alans-MacBook-Pro)-(alan)-(/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin)
(! 786)-> ./STM32_Programmer_CLI -c port=swd
-------------------------------------------------------------------
STM32CubeProgrammer v2.2.1
-------------------------------------------------------------------
ST-LINK SN : 36FF72064D59303629401543
ST-LINK FW : V2J33S7
Voltage : 3.21V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x468
Device name : STM32G43x/G44x
Flash size : 128 KBytes
Device type : MCU
Device CPU : Cortex-M4It works as expected and no segfault.
Now I will add a symlink to the "STM32_Prog_DB.xml" relative to my test folder and show it works as expected indicating a bug:
(Alans-MacBook-Pro)-(alan)-(~/projects/test)
(! 790)-> ln -s /Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/Data_Base/ ../.
.././Data_Base -> /Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/Data_Base/
(Alans-MacBook-Pro)-(alan)-(~/projects/test)
(! 794)-> STM32_Programmer_CLI -c port=swd
-------------------------------------------------------------------
STM32CubeProgrammer v2.2.1
-------------------------------------------------------------------
ST-LINK SN : 36FF72064D59303629401543
ST-LINK FW : V2J33S7
Voltage : 3.21V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x468
Device name : STM32G43x/G44x
Flash size : 128 KBytes
Device type : MCU
Device CPU : Cortex-M4And it works just fine. Could someone at ST please look at fixing this bug, as it's nasty to have relative paths hardcoded into the util.
Thanks,
-A.
