Hi Yu,
1) this part of code write just application reset vector = address where the main application starts. The application vector table must be created in application project at non-default position (+ write into IVBR register). Since the application interrupt vector table is out of bootloader control, the application reset vector and application vector table must be handled separately.
This code takes last 8 bytes (minimum programmable size) with default reset vector from application project (= range 0xFFF8~0xFFFF, reset vector is at address 0xFFFE) and writes them at RESET_VEC_DST address somewhere in Flash dedicated for an application (out of Flash allocated for the bootloader).
2) The first 24 bytes (range 0xFFE0~0xFFF7) are irrelevant because the application must already contain own vector table at a final position. These data should be 0xFFFF values anyway. Important is only last word with application reset vector.
3) the RESET_VEC_SRC value is the default and you shouldn’t change it. It points to the last 32 bytes S-record with default reset vector generated by application project linker in the last word.
The RESET_VEC_DST should be somewhere in the application’s Flash range. Since this reset vector is handled separately, the whole phrase (8 bytes) must be excluded from application use (due to ECC – for avoiding cumulative writes). So, the optimal position is the last 8 bytes from Flash allocated for the application. In such case, you do not need to split Flash range in application’s linker file (just strip out these last 8 bytes).
The application example in AN4258 defined last ROM_C000 segment as 0xC000 TO 0xEFDF. Here we excluded whole 32bytes (0xEFE0~0xEFFF) just for sure. The bootloader starts at address 0xF000.
So, if you modify bootloader to start at a different address, you should change also RESET_VEC_DST value.
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!
-----------------------------------------------------------------------------------------------------------------------