Lpc845 app code can't debug after bootloader

cancel
Showing results for 
Search instead for 
Did you mean: 

Lpc845 app code can't debug after bootloader

1,038 Views
lojyunmin
Contributor I

Hi,

I have a problem, my application code can't correct run in debug mode with MCUXpresso IDE.

I used SPI interrupt in my bootloader.

Then, my App code work correct without debug mode, but can't work correct in debug mode.

If I do not use the SPI interrupt, it can work correct in debug mode. Why?

I seem

LPC845 Jumping to secondary Application 

Alice_Yang 員工

In default,  the MCUXpresso IDE can't debug application with start address from 0x3000( only can start from 0x0000).

"In default", are there any other settings missing?

Labels (1)
0 Kudos
6 Replies

677 Views
lpcxpresso_supp
NXP Employee
NXP Employee

I presume it's the bootloader using SPI? You didn't say how SPI is being used. Another possibility is the SYSMEMREMAP register is not setup as you expect. Set the launch configuration Reset Handling entry to SYSRESETREQ and report your results.

Thanks and regards,

MCUXpresso Support

0 Kudos

677 Views
lojyunmin
Contributor I

this is the function before jump

{

USER_ENTRY_PFN user_entry;
NVIC_DisableIRQ(BOD_IRQn); //Enable BOD IRQ
NVIC_DisableIRQ(SPI0_IRQn);
#if defined(WDT_ON)
NVIC_DisableIRQ(WDT_IRQn); //Disable Watch Dog IRQ
#endif
__disable_irq();
SCB->VTOR = APP_CODE_START_ADDR;
user_entry = (USER_ENTRY_PFN)*((uint32_t*)(APP_CODE_START_ADDR + 4));

(user_entry)();

}

and this is the interrupt function, it almost like the spi sample code

void SPI0_IRQHandler(void)
{
Chip_SPI_Int_Cmd(LPC_SPI0, SPI_INTENCLR_TXDYEN | SPI_INTENCLR_RXDYEN | SPI_INTENCLR_RXOVEN | SPI_INTENCLR_TXUREN, DISABLE);/* Disable all interrupt */
if (((gstXfSetup.pRx) && (gstXfSetup.RxCnt < gstXfSetup.Length)) || ((gstXfSetup.pTx) && (gstXfSetup.TxCnt < gstXfSetup.Length)))
{
Chip_SPI_Int_RWFrames(LPC_SPI0, &gstXfSetup);
Chip_SPI_Int_Cmd(LPC_SPI0, SPI_INTENSET_TXDYEN | SPI_INTENSET_RXDYEN | SPI_INTENSET_RXOVEN | SPI_INTENSET_TXUREN, ENABLE);
}
else
{
gbIsXferCompleted = true;
}
}

and the spi read function, it reference lpc824 

void ReadSPIData(uint8_t aucDataLength) // length involve read cts byte
{
gbIsXferCompleted = false; //clear the flag
ConfigSPIStructure(aucDataLength);
Chip_SPI_Int_RWFrames(LPC_SPI0, &gstXfSetup);
Chip_SPI_Int_Cmd(LPC_SPI0, SPI_INTENSET_TXDYEN | SPI_INTENSET_RXDYEN | SPI_INTENSET_RXOVEN | SPI_INTENSET_TXUREN, ENABLE);
while (!gbIsXferCompleted) {}
}

If I use ReadSPIData() function, the jump is going to fail.

any missing?

0 Kudos

677 Views
lpcxpresso_supp
NXP Employee
NXP Employee

I suspect the SPI interrupt handler (in the bootloader) is possibly not setting up the application reset context properly to vector to the application. Note the application startup initialized the VTOR to its own vector table. Until that happens, any active interrupts would vector back into the bootloader. Double check this.

Thanks and regards,

MCUXpresso Support 

0 Kudos

677 Views
lojyunmin
Contributor I

Thanks for your response.

My operation flow situation,

burning my boootloader program at address 0x0~0x2CFF. Then, burning the application program at address 0x3000~(size 0xb000). Where burn the application program by LPCLinkII and debug in MCUXpresso.

In general, when I burn the application code by LPCLinkII, it should startup from the bootloader(0x0) and jump to the application code(0x3000) and stop at the first line of the main() function.

So, If I do not use the SPI interrupt in the bootloader code, it works, it correct jump from bootloader to application main().

But, If I use the SPI interrupt in the bootloader code,  it doesn't jump from bootloader to application main().

By the way, I used the method several MCUs, but I usually use UART in bootloader code, it's my first time use the SPI. 

I used the method with LPC824, but I used the uart in bootloader coed, not spi.

0 Kudos

677 Views
lpcxpresso_supp
NXP Employee
NXP Employee

What do you actually mean by "my App code work correct without debug mode, but can't work correct in debug mode" ?

With regards to "MCUXpresso IDE can't debug application with start address from 0x3000", after programming flash, the IDE will by default reset the device - which causes the ROM bootrom code to run and call into a"valid image" in flash at 0x0. Thus if you have no valid image in flash at 0x0 this is not going to work.

One allow you to debug your application at 0x3000 via a LinkServer / CMSIS-DAP debug connection (assuming you have your boot loader or a "dummy application" at address 0x0) would probably be to change the way that the IDE resets the target after programming flash. To do this, edit the launch configuration (by double clicking on the .launch file that will have been created in your project) and change the "reset handling" option to "SOFT".

pastedImage_1.png

Regards,

MCUXpresso IDE Support

677 Views
lojyunmin
Contributor I

This method solve my issue, but also let the application program work incorrect.

My application has open the optimize.

0 Kudos