lpcware

LPC1756 secondary boot loader fails when jumping into application

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by robertpalmerjr on Wed Jan 14 09:07:35 MST 2015
I am using the AN11258 I2C secondary boot loader as the reference for my development.

I have successfully implemented the core boot loader, my problem occurs when I jump to the application.  The application is built using the RedLib library.  I have traced the problem to the following extent:

- boot loader jumps into app's entry point (ResetISR in cr_startup_lpc176x.c)
- ResetISR calls __main
- __main (inside redlib doing some kind of "magic" that I can't see or modify) calls _initio
- _initio calls _Csys_alloc requesting 192 bytes
- _Csys_alloc calls malloc requesting 192 bytes
--- FAIL --- malloc returns 0
- Csys_alloc calls __sys_write then __sys_appexit (infinite loop)

I have read every thread on this forum that I can find related to boot loaders.  Before I call my application, I reset the SP and set the VTOR to point to my application's vector table.  The application's ResetISR routine run's successfully until the memory allocation request.  It's not "crashing" - i.e. not a memory bus exception dropping into one of the exception vector routines.

The application works fine if I compile it with a base address of 0x00 instead of 0x1000

Is there a bug in RedLib????

I do not want to switch libraries (though I guess I could for testing purposes) because one module of my code has been through certification and changing the stdC library for the app will mean I have to change the stdC lib for the module as well, which would require recertification. 

Here is the memory table for my boot loader:
FLASH  loc: 0x00  size 0x1000
RAM  loc: 0x10000000 size 0x3c00
RAM2 loc 0x10003c00 size 0x400
RAM3 loc 0x2007c000 size 0x4000

and for my application:
FLASH  loc: 0x1000  size 0x1f800
FLASH2 loc: 0x3fffc size 0x4
RAM  loc: 0x10000000 size 0x3c00
RAM2 loc 0x10003c00 size 0x400
RAM3 loc 0x2007c000 size 0x4000

Any assistance in figuring out why this isn't working would be greatly appreciated

Outcomes