LPC1113/302 Secondary Bootloader based on AN10995

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by lucastakejame on Wed Feb 11 15:26:50 MST 2015
Hi guys, this is my first post. It's been a while since i'm trying to troubleshoot my situation here so i thought i should ask.
I'm using a LPC1113/302, LPC-link v1.1 jtag debugger and LPCXPRESSO v7.5 .
I'm trying to use a second bootloader , based on this application note : http://www.lpcware.com/content/nxpfile/an10995-lpc1100-secondary-bootloader-software-v13
I had to make some tweaks because the the AN10995 is aimed for lpc1114, so I changed the linker scripts AND the application example.
These are the changes that I made on application_Release_mem.ld

  /* Define each memory region */
  MFlash24 (rx) : ORIGIN = 0x1000, LENGTH = 0x5000 /* 20K bytes */
  RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x1FE0 /* 8K bytes */

  /* Define a symbol for the top of each memory region */
  __top_MFlash24 = 0x1000 + 0x5000;
  __top_RamLoc8 = 0x10000000 + 0x1FE0;

The application was changed to blink a led using SysTick_Handler():

int main(void)

    LPC_IOCON->PIO2_9 &= ~0x1F;         // PIO2_9, NO PULLUP/PULLDOW
    LPC_GPIO2->DIR |= (0x1 << 9);       // 1 - OUTPUT

    SysTick_Config(SystemCoreClock / 100000000UL);

    return 0 ;

void SysTick_Handler(void)
    if (u8LedOn)
        (LPC_GPIO2->MASKED_ACCESS[(1 << 9)] = ((1) << 9));    }
        (LPC_GPIO2->MASKED_ACCESS[(1 << 9)] = ((0) << 9));
    u8LedOn = !u8LedOn;

I followed AN10995 instructions, flashed the bootloader at 0x0000 (apparently works fine) and flashed the Application.bin via IAP instructions on 0x1000 (through the bootloader and XMODEM-1k). The problem happens when the execution jumps from the bootloader to the application, following this code (from bootloader main):

                /* Load main stack pointer with application stack pointer initial value,
   stored at first location of application area */
                asm volatile("ldr r0, =0x1000");
asm volatile("ldr r0, [r0]");
asm volatile("mov sp, r0");

/* Load program counter with application reset vector address, located at
   second word of application area. */
asm volatile("ldr r0, =0x1004");
asm volatile("ldr r0, [r0]");
asm volatile("mov pc, r0");

I believe 0x1004 should contain the address to a ResetISR handler, but it seems to go to a place with no valid instructions.
I checked if the .bin I sent and the content in memory were identical and it seems that the content in memory is bigger, maybe some padding, i don't know...
The application vector table looks ok but the handling don't. I'm out of ideas , hope someone can help me =)! Heres the repo i'm storing the files : https://github.com/lucastakejame/mod-bootloader