I have a hex file that contains a bootloader and an application image along with flash option data to write protect the bootloader. In order to be able to program the write protection I have added the "STM32F10x Flash Options" programming algorithm, and configured the download to "Erase Sectors" instead of "Erase Full Chip" as per Keil instructions. This works perfectly on a previoulsy unprogrammed target and I can automate this in the standard way by passing the project file to UV4 on the command line with the -f switch.
However, if I try to reprogram a target device that already has protection it fails. The only way I can successfully reprogram a device is to perform a full chip erase using the "Flash | Erase" menu (which gives me a "Full Chip Erase Failed!" error) , followed by a normal Download operation (using sector erase).
Questions:
1) Is there a better way of doing this that doesn't require two separate operations?
2) If not, is there a nice way of automating the above procedure? I could have two separately configured projects and run one after the other, ignoring errors thrown by the first but I'm hoping there is a way of achieving this without restoring to such kludges. A command line utility for the ULINK would be very useful...
Forgot to add - if the two project solution really is the only way to go, how do I stop the "Erase failed" dialog box popping up during the first chip erase operation?