I am developing an application that is making use of a second boot loader and I want to prevent access to the SWD interface and also protect the 4 first sectors of the flash to protect the bootloader.
Programming the ECRP in the startup file of my project with value 0x0001583B works fine, but if I try to activate the IAP erase/write protection with 0x0001583B, then the programming of the image fails and the lpc546xx is ruined.
I understand that after loading the image, then writing to the first 4 sectors will no longer be possible, but why is this happening on first image writing?
How can I program the IAP erase/write protection bits of ECRP if I cannot do it at compile time in the start up code?
Is anything wrong with the following?
void (* const g_pfnVectors[])(void) = {
// Core Level - CM4
&_vStackTop, // The initial stack pointer
ResetISR, // The reset handler
NMI_Handler, // The NMI handler
HardFault_Handler, // The hard fault handler
MemManage_Handler, // The MPU fault handler
BusFault_Handler, // The bus fault handler
UsageFault_Handler, // The usage fault handler
__valid_user_code_checksum, // LPC MCU checksum
(void (*)()) 0x0001543B, // ECRP
0, // Reserved
0, // Reserved
SVC_Handler, // SVCall handler
DebugMon_Handler, // Debug monitor handler
0, // Reserved
PendSV_Handler, // The PendSV handler
SysTick_Handler, // The SysTick handler
What am I doing wrong?