LPC1788 USB bootloader - Issue with user program

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1788 USB bootloader - Issue with user program

1,613 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by zou9a on Thu Apr 07 06:21:50 MST 2016
Peace be upon all of you,

I have recently searched for an USB bootloader for LPC1788 to use it with my application, but I have never found an exemple. Starting from the code Red exemple (1) based on LPC1768, and following the application note (2) and the user manual to well understand what I'm doing, I have write a bootloader for the LPC1788. I can update firmware (user app) and execute some user application like a blinky without any problems. Now, I'm trying to execute my application (LCD+EMC_SDRAM+TS+RS485+GPIO...) and updated if necessary using this boot loader. Briefly: It doesn't work.
Last work I have done: I debug (with my firmware on flash starting at sector 16 0x10000) the USB bootloader. The bootloader detect that code is present, and when trying to execute it, I got IntDefaultHandler (pic 1). I have no idea why I get this interrupt, so I thak you for help.
Code that execute firmware and remapp vector table:
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
According to UM: 5.4 Vector table remapping */
SCB->VTOR = USER_FLASH_START;
// Load contents of second word of user flash - the reset handler address
// in the applications vector table
p = (unsigned *)(USER_FLASH_START + 4);
// Set user_code_entry to be the address contained in that second word
// of user flash
user_code_entry = (void *) *p;
    user_code_entry();
}

Why to execute user code we must point to the second word of USER_FLASH_START and not the first? Where can I find an explanation of the structuration of a code (the BIN file)?
When I try to read the firmware.bin (all user memory) with an HEXEditor, last address is 0x60FF and not 0x7FFFF? But windows show that space of flash is 448KB (that correct 0x70000).

(1). http://www.support.code-red-tech.com/CodeRedWiki/RDB1768cmsisExampleProjects
(2). http://www.nxp.com/documents/application_note/AN10866.pdf
Labels (1)
0 Kudos
Reply
5 Replies

1,169 Views
lpcware
NXP Employee
NXP Employee
bump
0 Kudos
Reply

1,169 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by zou9a on Mon Apr 11 04:41:19 MST 2016
Finally, I have a better result. I disable all IRQ (__diseable_irq()) before jumping to the user app. My application run but the problem is I cant use interrupts like touching screen... when I tried to enable IRQ in my user code, I get hardfault_interrupt. Am I doing somthing wrong?
0 Kudos
Reply

1,169 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by zou9a on Mon Apr 11 03:43:06 MST 2016
Hi,
I cant make my user program RUN. I have tried anything, what could be the problem

Thx
0 Kudos
Reply

1,169 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Thu Apr 07 07:05:01 MST 2016

Quote: zou9a

Why to execute user code we must point to the second word of USER_FLASH_START and not the first? Where can I find an explanation of the structuration of a code (the BIN file)?



Because that's the vector table  :)

As explained in #1 of https://www.lpcware.com/content/forum/jump-bootloader-actual-firmware

...and your User manual...
0 Kudos
Reply

1,169 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by zou9a on Thu Apr 07 06:46:39 MST 2016
PS: linkscript of user application
MFlash512 (rx) : ORIGIN = 0x10000, LENGTH = 0x70000 /* 512K bytes (alias Flash) */  
  RamLoc64 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x10000 /* 64K bytes (alias RAM) */  
  RamPeriph32 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32K bytes (alias RAM2) */  
  extSDRAM32768 (rwx) : ORIGIN = 0xa0000000, LENGTH = 0x2000000 /* 32M bytes (alias RAM3) */  
0 Kudos
Reply