AnsweredAssumed Answered

Custom Bootloader, Debugging and the Cosmic Compiler

Question asked by Aaron Derbyshire on Nov 9, 2017
Latest reply on Nov 10, 2017 by Aaron Derbyshire


I am currently working with the STM8S003K3 and I am attempting to write a bootloader function which will take an S-Record line by line and write the contained data to Flash. I have seen that is common practice to store the bootloader function in the UBC to provide it protection, however, I am currently prototyping and don't require this level of protection just yet.


I am instead storing the bootloader function in the standard program memory area, the location of which is determined by the Cosmic Compiler and Linker. I am utilising the linker command specified under the moveable code section and I can see that this is working correctly from the map file.


There are two main issues which I am struggling with:

1. The first issue is in attempting to use the _fctcpy() function provided in the machine library by Cosmic. Whenever I call the function to copy my bootloader to the RAM space the SWIM Debugger experiences a Comm Timeout.

2. Whenever I flash the MCU and communicate with the device via the UART the device resets upon calling the function.


Are the problems I am experiencing a by-product of the method I am trying to use (i.e the _fctcpy() function operates as thought the bootloader function resides in the UBC and so performs the necessary checks on the option bytes prior to executing the copy function?).


Any help would be greatly appreciated.