Application hangs when runs from 0x10000

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

Application hangs when runs from 0x10000

414 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabriolin on Mon Aug 11 12:53:19 MST 2014
Hi,

I'am currently working on a robotics system running on some custom 1769 boards.
The system is stable and running during developpment for months now. And a new step is comming: uploading new releases by bootloader.
So the bootloader is working fine from USB and from RS485 bus. A simple application can be uploaded and lunched by the bootloader very well.
But the real one (and bigger, about 50ko) can be uploaded, but hangs when running, when the same code running from 0x0 runs very well.
So i've commented some parts of the code, is runs (from 0x10000), un-commented them, its hangs, commented some other, it's runs....

So i've uploaded the code (that hangs) with the lpc-link from 0x10000 to see what happens, and it goes to the hardfault handler with differents errors and from differents parts of the code, with corrupted registers.

Does anyone have any idea?
Thanks
Labels (1)
0 Kudos
6 Replies

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabriolin on Wed Aug 13 09:56:37 MST 2014
Hi,

Thanks for your time you spend on this.

But nothing has change
I've added this to the start_user_code:
__disable_irq();

unsigned int stackadr = USER_FLASH_START;
stackadr = *(unsigned int*)stackadr;
__set_MSP(stackadr);


But still in hardfault:
Faults     = ImpreciseErr
Fault PC   = 0x000166D2
           = prvInsertBlockIntoFreeList + 166 in section .text
           = File: ../FreeRTOS_portable/MemMang/heap_4.c  Line: 454

Fault status registers:
IPSR       = 0x1000003: 3  (HardFault)
CFSR       = 00000400 (Configurable Fault Status Register)
HFSR       = 40000000 (Hard Fault Status Register)
DFSR       = 00000000 (Debug Fault Status Register)
MMAR       = e000edf8 [INVALID] (MemManage Fault Address Register)
BFAR       = e000edf8 [INVALID] (Bus Fault Address Register)
AFSR       = 00000000 (Auxiliary Fault Status Register)

Stacked registers:
R0         = 10003cf8
R1         = 00000000
R2         = 10003cf8
R3         = 00000000
R12        = 10002a98
LR         = 000164d3
PC         = 000166d2
PSR        = 01000000
SP         = 10003c40
0 Kudos

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Wed Aug 13 00:02:16 MST 2014
Check your stack pointer…

http://www.lpcware.com/content/forum/lpc1768-secondary-usb-bootloader-lock#comment-1133905

Regards,
LPCXpresso Support
0 Kudos

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabriolin on Tue Aug 12 10:01:34 MST 2014
I'm using this part of code to jump to user application, with the "VTOR" register initialized to the vector table offset:
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 = (USER_FLASH_START & 0x1FFFFF80);

// 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;

// Jump to user application
user_code_entry();
0 Kudos

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabikov on Tue Aug 12 04:25:10 MST 2014
Hi,

I assume that you correctly do remap of interrupts. In this case you should carefully reset to default all devices on chip, turn off IRQ that you used in your bootloader and so on. Other reason for hardfault may be optimization at link time, -fPIC and all other optimization settings.
0 Kudos

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabriolin on Mon Aug 11 23:37:19 MST 2014
Hi,
It's at its initial position, i hadn't change it.
Bootloader is using interrupts and runs.
0 Kudos

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Mon Aug 11 13:42:02 MST 2014
At which address is your interrupt vector table?
0 Kudos