lpcware

Application and vector offset

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by tjoAG on Fri Nov 02 01:21:32 MST 2012
Hi

I'm making our application ready so it can be used with the bootloader.

The bootloader will be placed from flash address 0x0000 - 0x8000
The application will then start from address 0x8000.

I'm trying to get the application running from flash address 0x8000, just to see if it works. But if I do that, the debugger looses its connection. (Using KEIL and ULINK2). I have to force the CPU into internal bootloader before I can get my debugger connect again.

What I have done so far in my application to make it run from address 0x8000

In the scatter file I have offset the RO space to 0x8000:

<code>
; Load region is in internal FLASH, 512KBytes
FLASH 0x00000000 0x78000 {
  ; All code and RO data in in FLASH
  ER_RO 0x00000000 0x78000 {
    ;startup_LPC177x_8x.o (RESET, +FIRST)
startup_ea1788.o (RESET, +FIRST)
    *.o (+RO)
  }
</code>

In the SystemInit function I move the VTOR to address 0x8000:
<code>
SCB->VTOR  = 0x00000000 & 0x3FFFFF80;
</code>
In the uVision debug setup I add a ini script for the debugger to jump the SP and PC to the flash address 0x8000:
<code>
FUNC void Setup (void) {
  SP = _RDWORD(0x00008000);          // Setup Stack Pointer
  PC = _RDWORD(0x00008004);          // Setup Program Counter
// _WDWORD(0xE000ED08, 0x00000000);   // Setup Vector Table Offset Register
}

Setup();                             // Setup for Running
</code>

When I download the code and execute the debugger I get a connection lost and the ULINK cant connect to the CPU.

Am I missing something? Something todo with the Memory Mapping Control register (MEMMAP register) loading some boot code?
Or do I have to have the bootloader code in the target for the debugger to connect?

Thomas

Outcomes