LPC1347 - Help with Invoke ISP from user code (autoisp)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC1347 - Help with Invoke ISP from user code (autoisp)

1,422 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by BPC on Wed Jan 23 09:31:15 MST 2013
Hello Everyone,

I am migrating from the LPC1343 to the LPC1347.  Everything has been smooth so far, but I ran into a snag in implementing "Auto ISP" or ISP from user code using command 57.  I have taken the LPC1343 example, and based on the User Manual for the LPC1347, it appears these function should be cross compatible.  Below is the function I am using.

[COLOR=blue]/* This data must be global so it is not read from the stack */
typedef void (*IAP)(uint32_t [], uint32_t []);
IAP iap_entry = (IAP)0x1fff1ff1;
uint32_t command[5], result[4];[/COLOR]
[COLOR=blue][/COLOR]
[COLOR=blue]void ReinvokeISP(void)
{
  /* make sure USB clock is turned on before calling ISP */
  LPC_SYSCON->SYSAHBCLKCTRL |= 0x04000;
  /* make sure 32-bit Timer 1 is turned on before calling ISP */
  LPC_SYSCON->SYSAHBCLKCTRL |= 0x00400;
  /* make sure GPIO clock is turned on before calling ISP */
  LPC_SYSCON->SYSAHBCLKCTRL |= 0x00040;
  /* make sure IO configuration clock is turned on before calling ISP */
  LPC_SYSCON->SYSAHBCLKCTRL |= 0x10000;
  /* make sure AHB clock divider is 1:1 */
  LPC_SYSCON->SYSAHBCLKDIV = 1;[/COLOR]
[COLOR=blue]  /* Send Reinvoke ISP command to ISP entry point*/
  command[0] = 57;[/COLOR]
[COLOR=blue]  /* Set stack pointer to ROM value (reset default) This must be the last
     piece of code executed before calling ISP, because most C expressions
     and function returns will fail after the stack pointer is changed. */
  __set_MSP(*((uint32_t *)0x1FFF0000)); /* inline asm function */[/COLOR]
[COLOR=blue]  /* Enter ISP. We call "iap_entry" to enter ISP because the ISP entry is done
     through the same command interface as IAP. */
  iap_entry(command, result);
  // Not supposed to come back!
}[/COLOR]

Prior to calling this function, I disable the SYSTICK timer and interrupt.

Once iap_entry is executed, "nothing" happens, except the debugger "disconnects" as it should.  I cannot get the Mass Storage Device to pop up on my computer as it did with the LPC1343.  I have the "Soft USB Connection" circuit implemented on my board with an LED to show if the USB is connected, once iap_entry is executed, this LED turns off (as it should), but never turns back on.

I have tried doing a soft disconnect using pUsbApi->hw->Connect(hUsb, 0); prior to calling ReinvokeISP();.  I also tried a USB reset pUsbApi->hw->Reset(hUsb); prior to calling ReinvokeISP();.

Any help would be much appreciated.

Thank you.
0 项奖励
回复
5 回复数

1,298 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ECamino on Thu Jan 31 13:56:48 MST 2013
Hi,

I'm having the same trouble today.  I tried using the code from CR project autoisp_main.c:  It's very similar to yours, but for now I have commented out the WDT stuff.  Also, the code I used had a macro called inti_msdstate().
I see in the manual for LPC1347 says IAP_LOCATION should be correct.   I changed command and result to how they're defined in the manual. 

What I don't know is if I need init_msdstate() or if the values are correct for it, and how do I know if 0x1fff0000 is the right value for __set_MSP?

/* This data must be global so it is not read from the stack */

#define IAP_LOCATION 0x1fff1ff1
#define init_msdstate() *((uint32_t *)(0x10000054)) = 0x0
unsigned long command[5];
unsigned long result[4];
typedef void (*IAP)(unsigned long [], unsigned long []);
IAP iap_entry;
IAP iap_entry = (IAP) IAP_LOCATION;

void ReinvokeISP(void)
{
/*commented all WDT setup...I just want to see "CRP_DISABLED" before
I worry about getting a reset... */

/* Send Reinvoke ISP command to ISP entry point*/
  command[0] = 57;
  init_msdstate();           /* Initialize Storage state machine */

  /* Set stack pointer to ROM value (reset default) This must be the last
     piece of code executed before calling ISP, because most C expressions
     and function returns will fail after the stack pointer is changed. */
 
  __set_MSP(*((uint32_t *)0x1FFF0000));     /* inline asm function */

  /* Enter ISP. We call "iap_entry" to enter ISP because the ISP entry is done
     through the same command interface as IAP. */

   iap_entry(command, result);
// Not supposed to come back! (but can't get there in the first place)
}

Any ideas?

EC
0 项奖励
回复

1,298 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by BPC on Tue Jan 29 11:00:06 MST 2013
Hi Zero,

I have PIO0_3 connected to USB_VBUS (and PIO0_1 pulled up). I do not have UART in my system and need to have the device pop up as a Mass Storage Device (upon request) in order to update the firmware via USB.

Thanks,

BPC
0 项奖励
回复

1,298 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Jan 29 10:54:07 MST 2013

Quote: BPC
I believe the command 57 (Reinvoke ISP) is being properly executed...



Use PIO0_3 to select UART bootloader. If FlashMagic is working then, your IAP 57 is working  ;)
0 项奖励
回复

1,298 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by BPC on Tue Jan 29 09:23:08 MST 2013
I believe the command 57 (Reinvoke ISP) is being properly executed, however, the USB Connect signal never goes low, which in turn makes the device invisible to the CPU.  Is there any way to see what state the device is in during this time?
0 项奖励
回复

1,298 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by BPC on Sat Jan 26 15:54:38 MST 2013
All other IAP commands are working properly (i.e. Read Part ID, Read UID, Read Boot code version).  Any ideas would be greatly appreciated.  Thanks again.
0 项奖励
回复