cancel
Showing results for 
Search instead for 
Did you mean: 

STM32_Programmer_CLI should handle more situations

DavidEGrayson
Associate II

I'm using STM32_Programmer_CLI software v.2.20.0 to program an ST Nucleo board (NUCLEO-C071RB).

I wish the software were better at automatically handling situations that make it fail.

For example, this command does work normally for uploading firmware to the board:

STM32_Programmer_CLI --connect port=swd --download firmware.elf --start

However, if you have enabled read-out protection (RDP) by setting RDP=0 in the option bytes, then it fails with "Error: failed to erase memory"  (and for some reason, it prints that message twice).  If read-out protection truly does prevent you from erasing, the software should be smart enough to detect that RDP is on and then turn it off temporarily.  Instead, we have to manually ask the software to do that:

STM32_Programmer_CLI --connect port=swd -ob RDP=0xAA --download firmware.elf --start

Next, if you have enabled write protection for a relevant portion of flash, the software fails with the same "Error: failed to erase memory" error messages. It seems like it should be smart enough to temporarily disable write protection in order to make the download succeed. Instead, we have to manually ask the software to do that:

STM32_Programmer_CLI --connect port=swd -ob RDP=0xAA -ob WRP1A_STRT=0x3F -ob WRP1B_STRT=0x3F --download firmware.elf --start

Next, if your firmware disabled debugger access to the core by setting DBG_SWEN in FLASH->ACR, the software will fail with the error messages "Error: Unable to get core ID" and "Error: No STM32 target found! If your product embeds Debug Authentication, please perform a discovery using Debug Authentication". The software should just automatically use its connection to the target's RST pin to work around this, but it does not. I tried using "--hardRst" and/or "--rst" right after "port=swd", but it did not help. Instead, the workaround for this problem is that you must hold the Nucleo's RESET button down with your finger while starting the software, then release it after the software has started running and is waiting.

It kind of feels like the STM32_Programmer_CLI is a scripting language with some useful commands in them, but to achieve my end goals I need specialized knowledge of how STM32 chips are programmed, in order to figure out which commands to use and which order to put them in. I feel like the software would be more useful and enjoyable to use if it were a high-level program that allowed you to specify your goals in terms of the state of the microcontroller and its memory and then it takes care of all the details of making those goals happen, automatically handling situations that might interfere with that process.

I hope this post is useful to others working around these issues, and also that someone on the STM32CubeProgrammer team with decision-making authority sees it. Thanks!

0 REPLIES 0