Problem invoking ISP from application code on LPC1857

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem invoking ISP from application code on LPC1857

1,745 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by smalouin on Thu May 01 11:07:12 MST 2014
Hello bunch...

as we are doing with a lot of other product here (running LPC1227 and LPC810 mainly) we are trying to re-invoke the ISP from the user code. This will allow the units to be reflashed from the serial port. We have a a DB9 with everything (max232, etc) on USART0.

What we know works:
 
 if ((temp==CTRLPROT_BOOT_START)&&(nbytes==CTRLPROT_BOOT_NBYTES)){     /* Validate parameter            */
      ctrlprotTxAck(CTRLPROT_BOOT_CMD);            /* Transmit command acknowledge response              */
      while (!gCtrlprot.flags.rxReady);          /* Wait for UART to be ready                          */
                           
      printf("\nPID [0x%08X]\n",Chip_IAP_ReadPID());
      printf("\nBootCodeVer [%d]\n",Chip_IAP_ReadBootCode());
      Chip_IAP_ReinvokeISP();
   }


This gives us on the proper PID (0xF001DA30) ... so we know we can call the IAP functions properly.

But right after the Chip_IAP_Reinvoke has been called, we expect the MCU to responds "synchronize" to a "?"... but it doesn't.
We have the same behavior with the same code on both our own product and the MCP1800 board (with an LPC1857) from keil.
(Pressing ISP/Reset button on the MCB1857 works, I get synchronize back to my ?)

We use "lpcopen_2_09_keil_iar_keil_mcb_1857"

I tried enabling the autobaud with Chip_UART_ABCmd(UART_SELECTION,UART_ACR_MODE0,true,ENABLE); ... that didn't help.



..............
just FYI, we had "lpcopen_2_04_keil_iar_keil_mcb_1857" before, so we had to use our own "Invoke ISP from user code" and it didn't work either... here it is:

#define IAP_ADDRESS         0x10400100
#define REINVOKE_ISP        57

static unsigned int command[6];
static unsigned int result[5];

#define IAP_LOCATION *(volatile unsigned int *)(0x10400100);
typedef unsigned (*IAP)(unsigned int [],unsigned int[]);
static const IAP bspIapEntry= (IAP) IAP_ADDRESS;

/* from http://www.lpcware.com/content/blog/reinvoke-isp-user-code-example-lpc177x-lpc178x*/
void bspReinvokeIsp(void) {
   /* Set stack pointer to ROM value (reset default) */
   __set_MSP(*((uint32_t *) 0x10400000));
   
   command[0] = REINVOKE_ISP;
     
   bspIapEntry(command, result);

   /* Never return from here */
}


we added the __set_MSP while trying to get it to work... but it didn't help.

Our chip runs on a 12MHz crystal and we run at 72MHz from it. We tried to run from the internal RC clock,
(using
Chip_Clock_SetBaseClock(CLK_BASE_MX,CLKIN_IRC,true,false);
but that didn't help.


On this LPC1857 quite elusive! Anybody had seen that and/or has any kind of lead for us?
Labels (1)
0 Kudos
Reply
2 Replies

1,578 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by smalouin on Fri May 02 10:30:27 MST 2014
OK... Found my problem...by comparing what I have done with another post on the same problem:

the other post

Because I run with an RTOS, I needed to [u]disable all interrupt [/u]before getting into the re-invoking of the ISP, (easy once you know it).

so both my implentations are working:

with lpcCore 2.09:
if ((temp==CTRLPROT_BOOT_START)&&(nbytes==CTRLPROT_BOOT_NBYTES)){     /* Validate parameter            */
    while (!gCtrlprot.flags.rxReady);          /* Wait for UART to be ready                          */
    __disable_irq();
    Chip_IAP_ReinvokeISP();
}



and with lpcCore 2.04

#define IAP_ADDRESS         0x10400100
#define IAP_REINVOKE_ISP    57
static unsigned int command[5];
static unsigned int result[4];

#define IAP_LOCATION *(volatile unsigned int *)(0x10400100);
typedef void (*IAP)(unsigned int [],unsigned int[]);

void bspReinvokeIsp(void) {
   IAP bspIapEntry=(IAP)IAP_LOCATION;
   
   __disable_irq();
   command[0] = IAP_REINVOKE_ISP;
     
   bspIapEntry(command, result);

   /* Never return from here */
}



I hope this helps anybody who might be stuck on the same hurdle
0 Kudos
Reply

1,578 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by smalouin on Fri May 02 06:25:43 MST 2014
A bit more digging into it leaves me even more clueless...

I step through the whole process in assembler and I don't know where to go next.

When the IAPEntry function is called I see this:
[list=1]
  [*] the program jumps to the IAP code (PC=0x10400100 as expected  ---> So I am calling IAPentry correctly?
  [*] R0 contains 0x100000E0 which is my command array location (I see {0x39,0x00,0x00,0x00,0x00,0x00} there)     ---> that tells me the command *IS* 57d as expected for ISP re-entry?
  [*] R1 contains 0x100000F4 which is my result array location(I see {0x00,0x00,0x00,0x00,0x00,0x00, 0x00} there )     ---> and my result is empty as it should?
  [*] If I step linearly from there (0x10400100) it goes step by step straight until 0x1040012A and then... hardfault
[/list]

!?

eeprom code error? Or I am missing something like setting the SP to something (I tried __set_MSP(*((uint32_t *) 0x10400000))... but that didn't help.
0 Kudos
Reply