lpcware

Debugging a program with debugger

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by justmakeit on Thu May 07 01:38:18 MST 2015
Hello,

Currently i'm trying to make a program with a bootloader. But i keep failing with debugging the user application in LPCxpresso. There are a lot of questions and answers on the internet about creating a bootloader, but i cant found how to implement the flash settings in lpcxpresso. i'm using the "lpc link2" as programmer

what i'm doing:
1. program the bootloader the default way.
Debug As-> C/C++ (NXP semiconductors) MCU application

2. the bootloader start the application with the next code:
PROGRAM_ADDRESS_START = 0x3000


void execute_user_code(void)
{
void (*user_code_entry)(void);

unsigned *p;// used for loading address of reset handler from user flash

/* Change the Vector Table to the USER_FLASH_START
in case the user application uses interrupts */

SCB->VTOR = (PROGRAM_ADDRESS_START & 0x1FFFFF80);

// Load contents of second word of user flash - the reset handler address
// in the applications vector table
p = (unsigned *)(PROGRAM_ADDRESS_START +4);

// Set user_code_entry to be the address contained in that second word
// of user flash
user_code_entry = (void *) *p;

// Jump to user application
    user_code_entry();

}

3. replace the user application in flash
properties->c/c++ build->mcu settings->LPC1766->MFlash256 location: 0x3000 size: 0x3d000

4. Debug the user code
Debug As-> C/C++ (NXP semiconductors) MCU application

5. Debugger jumps to the wrong code

Outcomes