2023-09-22 07:24 AM
Hello,
is it possible to add a command in the startup tab of the debug configuration, to erase a group of selected sectors, before programming?
For example I want to erase sectors [16..63], but not sectors [0..15].
I have only found the "monitor flash mass_erase" command, but it erase all flash.
Thank you,
Carlo
Solved! Go to Solution.
2023-10-09 12:37 AM - edited 2023-10-09 01:28 AM
Hello @Pavel A.,
cmd /c "${cubeide_cubeprogrammer_path}\STM32_Programmer_CLI.exe -e [16 63]" seems to be the correct way to invoke STM32_Programmer_CLI.exe.
Now the tool is launched, but it doesn't perform the erase operation because of the following error:
cmd /c "C:\ST\STM32CubeIDE_1.11.2\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.500.202209151145\tools\bin//STM32_Programmer_CLI.exe -e [16 63]"
make[1]: *** [makefile:93: pre-build] Error -1073741819
Even if I don't know what this return code indicates (I cannot find a return code list in UM2237), I guess that one of the problems is that I need also to specify the connection port.
So I have added the -c port=SWD option in the command line and now the erase operation seems to be performed correctly, as suggested by the output dumped on the console:
make -j7 all
cmd /c "C:\ST\STM32CubeIDE_1.11.2\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.500.202209151145\tools\bin\STM32_Programmer_CLI.exe -c port=SWD -e [16 63]"
-------------------------------------------------------------------
STM32CubeProgrammer v2.12.0
-------------------------------------------------------------------
ST-LINK SN : 001D0008544B500520343637
ST-LINK FW : V3J10M3B5S1
Board : STLINK-V3SET
Voltage : 3.28V
SWD freq : 24000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x460
Revision ID : Rev B
Device name : STM32G07x/STM32G08x
Flash size : 128 KBytes
Device type : MCU
Device CPU : Cortex-M0+
BL Version : 0xB2
Debug in Low Power mode enabled
Erase sector(s) ...
Existing specified sectors are erased successfully
Protected sectors are not erased
Is it right?
Regards,
Carlo
2023-09-22 08:05 AM
Hello @CTabo.1
I am not sure if there is initialization command for sector erase but you can do that using CubeProgrammer. Otherwise I suggest you similar posts : Solved: How to erase flash before programming with STM32Cu... - STMicroelectronics Community
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-09-22 08:57 AM
Typically it just erases the span of the application.
Your application could also facilitate erasure of non-application spaces via diagnostic or monitor type console.
2023-09-25 12:25 AM
Hello @FBL,
if I try to add the following pre-build step, as indicated in the post:
STM32CubeProgrammer is launched correctly, but only dumps the cli usage syntax.
make -j7 all
C:\ST\STM32CubeIDE_1.11.2\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.500.202209151145\tools\bin/STM32_Programmer_CLI.exe
-------------------------------------------------------------------
STM32CubeProgrammer v2.12.0
-------------------------------------------------------------------
Usage :
STM32_Programmer_CLI.exe [command_1] [Arguments_1][[command_2] [Arguments_2]...]
Generic commands:
-?, -h, --help : Show this help
-c, --connect : Establish connection to the device
...
However, if I append the command to erase selected sectors of flash
I have the following error:
make -j7 all
C:\ST\STM32CubeIDE_1.11.2\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.500.202209151145\tools\bin\STM32_Programmer_CLI.exe -e [16 63]
c:/st/stm32cubeide_1.11.2/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.make.win32_2.0.100.202202231230/tools/bin/sh: C:STSTM32CubeIDE_1.11.2STM32CubeIDEpluginscom.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.500.202209151145toolsbinSTM32_Programmer_CLI.exe: not found
make[1]: *** [makefile:93: pre-build] Error 127
make: *** [makefile:61: all] Error 2
"make -j7 all" terminated with exit code 2. Build might be incomplete.
What am I doing wrong?
Thank you,
Carlo
2023-10-06 08:13 AM
Hello,
any suggestion about it?
Why if I launch STM32_Programmer_CLI.exe as a pre-build step, without command line options, it is launched correctly (but do nothing), and if I launch it with the desired command line options, like -e[16 63], I have an error saying that STM32_Programmer_CLI.exe is not found?
Thank you,
Carlo
2023-10-06 11:48 AM - edited 2023-10-06 11:53 AM
From the log above, the built-in "sh" utility (busybox) does not like backslashes. Try somehow to replace all \ to \\ or to / or use cmd in the command: cmd /c "${cubeide_programmer_path}\STM32_Programmer_CLI.exe -e [16 63] "
Maybe the new CubeIDE has a bug in handling of / and \ on Windows - it used to do the right thing.
2023-10-09 12:37 AM - edited 2023-10-09 01:28 AM
Hello @Pavel A.,
cmd /c "${cubeide_cubeprogrammer_path}\STM32_Programmer_CLI.exe -e [16 63]" seems to be the correct way to invoke STM32_Programmer_CLI.exe.
Now the tool is launched, but it doesn't perform the erase operation because of the following error:
cmd /c "C:\ST\STM32CubeIDE_1.11.2\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.500.202209151145\tools\bin//STM32_Programmer_CLI.exe -e [16 63]"
make[1]: *** [makefile:93: pre-build] Error -1073741819
Even if I don't know what this return code indicates (I cannot find a return code list in UM2237), I guess that one of the problems is that I need also to specify the connection port.
So I have added the -c port=SWD option in the command line and now the erase operation seems to be performed correctly, as suggested by the output dumped on the console:
make -j7 all
cmd /c "C:\ST\STM32CubeIDE_1.11.2\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.500.202209151145\tools\bin\STM32_Programmer_CLI.exe -c port=SWD -e [16 63]"
-------------------------------------------------------------------
STM32CubeProgrammer v2.12.0
-------------------------------------------------------------------
ST-LINK SN : 001D0008544B500520343637
ST-LINK FW : V3J10M3B5S1
Board : STLINK-V3SET
Voltage : 3.28V
SWD freq : 24000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x460
Revision ID : Rev B
Device name : STM32G07x/STM32G08x
Flash size : 128 KBytes
Device type : MCU
Device CPU : Cortex-M0+
BL Version : 0xB2
Debug in Low Power mode enabled
Erase sector(s) ...
Existing specified sectors are erased successfully
Protected sectors are not erased
Is it right?
Regards,
Carlo
2023-10-09 02:59 AM
Looks much better. do you see the sectors actually erased with other tool such as CubeProgrammer GUI?
2023-10-11 06:35 AM
Hello @Pavel A.,
yes I have verified with CubeProgrammer that the sectors are actually erased.
Thank you,
Carlo