I have the following code so I can restart the ISP and re-write flash after I have loaded valid application.
My code is
uint32_t res_status; //
const uint32_t USART_ISP_1 = 1;
IAP_ReinvokeISP(USART_ISP_1, &res_status);
UM11064
Command code: 57 (decimal)
Param0(mode): ISP interface selection
1 - USART ISP <----- apparently this means that the constant 1 is the only valid parameter?
IAP_ReinvokeISP on my MCUXpresso the #define FSL_FEATURE_SYSCON_IAP_REINVOKE_ISP_PARAM_POINTER is not defined so the IAP_ISP_TYPE_XXX ##defines have no effect on the IDE supplied wrapper function (IAP_ReinvokeISP).
When I break point to one past this command I get the following error.
----
Break at address "0xdeadbeee" with no debug information available, or outside of program code.
----
What else does this command need?
解決済! 解決策の投稿を見る。
Tried to invalidate the checksum at VTOR[7] based on the following statement from UM11065 with the following code:
uint32_t shadow_vector[16];
memcpy (shadow_vector, (uint8_t)0, 64 );
shadow_vector[7] = 0xffffffff;
IAP_PrepareSectorForWrite( 0 , 0); // prepare sector 0 for write
volatile status_t res2 =
// dst src num clk
IAP_CopyRamToFlash ( 0, shadow_vector, 64, SystemCoreClock );
but break pointing beyond this (and before the IAP_ReinvokeISP call).
the reading the memory tab at location 0 shows the values unchanged. (reasonable since they were not erased first.)
but previous attempts to erase the memory (64 bytes starting at address 0, with prep first) resulted in a FFFFFFF9 error.
Tried to invalidate the checksum at VTOR[7] based on the following statement from UM11065 with the following code:
uint32_t shadow_vector[16];
memcpy (shadow_vector, (uint8_t)0, 64 );
shadow_vector[7] = 0xffffffff;
IAP_PrepareSectorForWrite( 0 , 0); // prepare sector 0 for write
volatile status_t res2 =
// dst src num clk
IAP_CopyRamToFlash ( 0, shadow_vector, 64, SystemCoreClock );
but break pointing beyond this (and before the IAP_ReinvokeISP call).
the reading the memory tab at location 0 shows the values unchanged. (reasonable since they were not erased first.)
but previous attempts to erase the memory (64 bytes starting at address 0, with prep first) resulted in a FFFFFFF9 error.
Hi, Oxolotol:
After reading your solution, it seems that you, instead of calling IAP command 57 to reinvoke ISP, took a different approach, i.e. to corrupt the interrupt vector table so that the next time cpu is reset, it will get into isp mode. Am I reading it correctly? After that, how do you make cpu reset to happen?
Thanks.
I have played with LPC845 and LPC804 related to the reinvokeISP issue.
With the following code, I can enter ISP mode with LPC845, tested with LPC845-BRK board OK.
-------------------
void start_isp() {
// IAP iap_entry = (IAP)IAP_ENTRY;
__disable_irq();
// Set clock to internal osc
LPC_SYSCON->MAINCLKSEL = MAINCLKSEL_VAL0;
LPC_SYSCON->MAINCLKUEN = MAINCLKUEN_UPDATE; // Update clock source
LPC_SYSCON->MAINCLKUEN = MAINCLKUEN_DISABLE; // Toggle update register once
LPC_SYSCON->MAINCLKUEN = MAINCLKUEN_UPDATE;
// Wait until the clock is updated
while (!(LPC_SYSCON->MAINCLKUEN & MAINCLKUEN_UPDATE));
// Set system AHB clock
LPC_SYSCON->SYSAHBCLKDIV = 1; // Divide by 1 == SYSAHBCLKDIV_DIV1;
// Enabled IOCON clock for I/O related peripherals
LPC_SYSCON->SYSAHBCLKCTRL[0] |= IOCON;
cmd[0] = IAP_CMD_REINVOKE_ISP;
cmd[1] = 1; // select USART_ISP mode
//iap_entry(cmd,stat);
IAP_Call(cmd,stat);
// shouldn't return
}
-----------------
After the above code was executed in the LPC845, I can use FlashMagic to read signature. That proves the chip is in the ISP mode.
However, the above code does not work with LPC804. I tested with OM40001 dev kit.
Can NXP support engineer to confirm that the LPC804 does or does not support reinvoke ISP command?
Thanks.
Hi, Oxolotol:
Since I couldn't use the IAP command Reinvoke_ISP to put LPC804 into ISP mode, I tried your suggestion, and it works properly. Thanks a lot.
Kang-sen
We can break point before the
iap_entry(command, result);
call, but not after it (as expected). but
-- it does not respond to ISP commands
-- it does not respond to IDE debugger pause button
-- it *does* respond to *application* USART0 commands as if it restarted the embedded code and did not stay in the ISP code
hhhmmm...
// set these to reset values per UM11065 4.6.8
SYSCON_MAINCLKSEL_SEL(0);
SYSCON_MAINCLKUEN_ENA(0);
SYSCON_SYSAHBCLKDIV_DIV(1);
I added these lines to match the reset values defined for the clock registers in UM11065 LPC804 User Manual.
This stopped the DEADBEEE, breakpoint, and breakpoints after the call don't occur (which is correct behavior)
but we are not able to get an ISP response on the USART0.
The UM11065 Table 35 (4.6.8) only mentions USART ISP, but not which USART. we are using USART0.
I noticed that with my LPC804UK the "FSL_FEATURE_SYSCON_IAP_REINVOKE_ISP_PARAM_POINTER" is not enabled, so so all the IAP_ISP_TYPE_I2C style choices are not available for the ispType parameter. Likely because they are not available for this chip.