Hi CHO JUNG HUN,
Bootloader:
The define.h file contains
#define dfFLASH_START_ADD 0xFE0000
#define dfAPPLICATION_START_ADD 0xFE0000
#define dfBOOTLOADER_START_ADD 0xFE0000
This is obvious issue – your bootloader erases 252 sectors from address 0xFE0000 for application use.
So, the bootloader must be placed at highest 4 sectors in Flash.
Please update bootloader prm linker file. The ROM segment should start at address 0xFFF800.
Also, SHADOW_ROM_S must not overlap ROM segment and the same is valid for SHADOW_RAM_S and RAM segments.
Application:
Your UserApp S-record file contains 6 interrupt and 1 reset vectors at the area which is already occupied by bootloader (0xFFFE00.. 0xFFFFFF).
You must create vector table somewhere else in Flash or RAM and modify IVBR register at application start.
See attached simple example code with relocated vector table into Flash/RAM for your inspiration.
Since the UserApp will be called from Bootloader, please comment out default reset vector in UserApp linker file:
//VECTOR 0 _Startup
From UserApp S-record file is not clear linker settings. Please do not forget on trim Flash size in UserApp linker file for avoiding any UserApp/Bootloader overlap – up to 0xFFF7FF. This typically doesn’t problem for RAM.
Please be aware, that there may be an issue with default starts12z.c file – the linker typically place DoZeroOut() function as first into Flash. This leads into the situation, that _Startup() position in flash depends on number and sizes of used initialized variables.
There are at least two workarounds. Please select one of them:
1. You may change order of DoZeroOut(), DoCopyDown() and _Startup() functions in starts12z.c file for manage that _Startup() will be the first function placed into flash.
See attached starts12z.c file.
2. You may place jump instruction and vector to _Startup() function as first in UserApp linker file.
See attached example linker file.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------