The code crashes in the sprintf, into one of the illegal instruction traps. However I found that shortly before it, data which is supposed to be initialised on the stack, isn't. AIUI, if you do say int x=2; inside a function, the compiler generates some code which sets up that data, and it puts it on the stack (unless it is declared "static" in which case it goes into, IIRC, BSS).
Here the bytes remain 0xFF. Does this make any sense to anybody?
The code runs fine when loaded with the STLINK debugger, and has done so for ages. It crashes when loaded from a serial FLASH device, into the CPU FLASH. Then the system reboots (as is necessary) and promptly crashes. Could this data be stored at the very end of the file, and I am failing to load the entire image?
Where in the binary would the string MonTue... be stored - for stuff destined for the stack? I guess it is missing. The 0xFF bytes are indicative of an erased FLASH device. SP and PC look good; the stack is at the top of the 128k RAM.