lpc1768 flash and vector table for an application

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

lpc1768 flash and vector table for an application

2,176 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Tue Sep 16 22:41:41 MST 2014
hello ,
I want to jump to an address ( for example 0xa000)( sector 10 in lpc1768)
I use this code but it it;s not working! what is the reason?
asm("MOV R2 , #0Xa000");

         asm("BLX R2");
Labels (1)
0 Kudos
36 Replies

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Sat Oct 04 01:18:02 MST 2014

Quote: dariush_abbasi868
Can you help me what I have to do ?



No, I don't use IAR. Looking in your user manual or asking in IAR forum may help...

If you change the start address correct, your generated bin file should include a new vector table with exception start adresses above 0x0000A000...

That's easy to control  :)
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Sat Oct 04 00:44:50 MST 2014
thanks again I see it
that 's grate ,
now I want to use my rom stat application address at 0xa000.
I use IAR , and I think I have to change at this points:

[img=220x150]http://i59.tinypic.com/2d8nu5v.jpg[/img]


[img=220x150]http://i62.tinypic.com/2r5u8h0.jpg[/img]

[img=220x150]http://i62.tinypic.com/122292b.jpg[/img]

Can you help me what I have to do ?

0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Fri Oct 03 23:06:52 MST 2014

Quote: dariush_abbasi868
I havnot any usefull thing in 0x2038 or I am in wrong .



Then look in your MAP file...
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Fri Oct 03 22:37:42 MST 2014
Hello , thank you for your replies ,
can you compare this 0x2038 by my original file that I attached ?
you can open it by winhex and see  it's contains .
I havnot any usefull thing in 0x2038 or I am in wrong .
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Wed Oct 01 09:13:06 MST 2014

Quote: dariush_abbasi868
in fact the frimawre will start at which address?



Vector table entries are WORDs (4 byte, little endian)...

Sample (LPC1549):

[color=#33f]0x00000000[/color]  02003FE0 00000191 00000139 0000013D
[color=#30f]0x00000010[/color]  00000141 00000145 00000149 FDFFB84A

The vector table contains the reset value of the stack pointer, and the start addresses,
also called exception vectors, for all exception handlers.

The first word is the stack pointer (StackTop):  0x02003FE0

In this sample (LPC1549) this value is the result of  RAM0_END – STACK_OFFSET.

StackTop = RAM0_END – STACK_OFFSET = StackTop = 0x0200400 – 0x20 = 0x02003FE0

The following words are the exception vectors (=start addresses) for all exception handlers.
The first exception vector at 0x0004 is Reset. In this sample (LPC1549) this value is 0x00000191.
LSB is indicating Thumb mode, so the processor is switching to Thumb mode before executing the
new address 0x00000190, where Reset ISR is starting.

So your vector table is starting at 0x2038  :O
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Wed Oct 01 07:40:39 MST 2014
I think the other way round (endian):
SP=0x10002800 (must point to RAM)
PC=0x00002039 (must point to FLASH)
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Wed Oct 01 06:58:06 MST 2014
\x00\x28\x00\x10\x39\x20\x00\x00\x17\x20\x00\x00\x17\x20\x00\x00\x17\x20\x00\x00\x17\x20\x00\x00\x17\x20\x00\x00\x54\x17\xFF\xEF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x20\x00\x00\x17\x20\x00\x00\x00\x00\x00\x00\x17\x20\x00\x00\x17\x20\x00\x00\x17\x20\x00\x00\x37\x1F\x00\x00\x2F\x1F\x00\x00\x85\x1F\x00\x00\x17\x20\x00\x00\x09\x1F\x00\x00\x2D\x1F\x00\x00\x2B\x1F\x00\x00\x29\x1F\x00\x00\x17\x20\x00\x00\x17\x20\x00\x00\x17\x20\x00\x00

this is at starting of one of my output file of my project .
this show  pc and sp?
is sp =00280010  and pc= 39200000  ????

in fact the frimawre will start at which address?
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Tue Sep 30 05:15:51 MST 2014

Quote:

After every reset, vector table will be mapped at 0x00 location and you do not have control on this. Once execution starts from here you can relocate your vector table to 0xa000 using vector table offset register as mentioned before in other posts. And then you can jump to 0xA000 location. Do not forget to set stack pointer.

Now you can have a simple application in sector 0xA000 which toggles LED. It will tell you that whether this approach is working or not.



this is for boot loader , but my point is application !


please reply to me.
did any one saw my linker setting in my project ?
is it ok? or not?
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Mon Sep 29 23:27:33 MST 2014
Hello again
In the attached file you can see my application project that I want to be for 0xa000 but it is not!!
can you tell me where is wrong?

0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Sun Sep 28 22:16:39 MST 2014
actually my plan is:
application will start at sectore 10 (0xa000)
bootloader start at 00
in boot loader if any new application at start up comes replace to old application by IAP commands and go to a000 and if doesnot come go to start of application address 0xa000 .
I think my bootloader is ok and it jump and do any thing i need .
but my point is in application as I told you I am working with IAR workbench compiler and how I can make an appliction for a000 address ?
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Wed Sep 24 07:00:15 MST 2014
I send my binarry output file my second dword file is ok?
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabikov on Wed Sep 24 05:56:50 MST 2014
You want something strange and malfunction by design.
Ok. Good news for everyone! I having the recipe.
1. Open your bin file in hex file editor
2. Look at second DWORD it will be smth like 0x00008XXX (0x00008117 in my case)
2.1 Clear first bit in XXX if you use THUMB instructions set as I am.
3. Substract in calculator in hex mode 0x8000 - 0xXXX = 0x7YYY
4. Goto your settings and set your base address 0x7YYY
5. Test if your new start pointer is 0x8000, repeat 2-5 if need it
5.1 0x8001 for THUMB
6. That's all folks. If you come to this then you do very bad things.
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Tue Sep 23 23:57:53 MST 2014
HELLO
In bootloader I will jump to 0xa000 to start application  and I write my binarry file by iap function in this address to end so I jump to this address of course for this jump I do this :

//****************
void boot_jump(WORD address)
{
    asm("LDR SP,[R0]"); //Load new stack pointer address
    asm("LDR PC,[R0,#4]");//Load new program counter address
}
//************************************
void execute_user_code(void)
{
   SCB->VTOR = USER_FLASH_START & 0x1FFFFF80;
    boot_jump(USER_FLASH_START);
}

but my application should be stated at 0xa000 and my point is in this point!
when I want to make an application that it's binarry output file should be empty untill 0xa000 and after this position data should be started, I cannot make it .
I use IAR compiler and in it's setting  in linker config set vector table start at 0xa000 and also in memory regions rom address at 0xa000 .
but in binarry output file before 0xa000 there is some datas !!!!
:((
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Tue Sep 23 06:37:15 MST 2014
Hi Dariush,
After every reset, vector table will be mapped at 0x00 location and you do not have control on this. Once  execution starts from here you can  relocate your vector table to 0xa000 using vector table offset register as mentioned before in other posts. And then you can jump to 0xA000 location. Do not forget to set stack pointer.

Now you can have a simple application in sector 0xA000 which toggles LED. It will tell you that whether this approach is working or not.
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Tue Sep 23 06:23:19 MST 2014
An image starts with a Vector table. The layout of the vector table is as follows:

[base_address+0]   Stack Pointer
[base_address+4]   Address of Reset_Handler
[base_address+8]   Address of NMI_Handler
... more exception handlers
etc

So, if you try to 'jump' to [base_address+0] you will try to execute garbage.

What you need to do (as has been explained in this thread) is
1. Load the Stack Pointer (SP) with the value read from [base_address+0]
2. Jump the the CONTENTS OF [base_address+4]. For the avoidance of doubt DO NOT JUMP TO [base_address+4]. [base_address+4] contains a pointer and you want to jump to that pointer.

This must be done in your boot loader.

If you still don't understand, by yourself a book on Cortex-M. The Joseph Yiu books are very good.
0 Kudos

1,364 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Tue Sep 23 06:06:45 MST 2014

Quote:
You can't start from 0xA000 without own bootloater.


you means that its not working ?

I just want to find out my bootloader binnary file is ok(binarry output file from IAR compiler ) and everything stated at 0xa000.
so  it is ok , I use this application in the bootloder and jump to 0xa000.
is it ok?
0 Kudos

1,366 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabikov on Tue Sep 23 03:05:24 MST 2014
You can't start from 0xA000 without own bootloater.
0 Kudos

1,367 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Mon Sep 22 23:32:53 MST 2014
thank you kabiko !
first and at time point I want to make a application that start from 0xa000( without any bootloader)
i have this application , and it's working in the address 00, in the pictures i attached what i have to do to it start from 0xa000 (every thing in .bin output file such as vectores and rom )
what i have to do for this ?

after that I am going to add this application to my bootloader .
first pls help me to make my application alone.
0 Kudos

1,367 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabikov on Mon Sep 22 09:24:46 MST 2014
You say jump to 0xA000... But this is stack pointer for your firmware. Do you set new stack pointer from 0xA000? You should jump to address contains in 0xA004. Are you sure that your bootloader upload firmware correctly (CRC)? Are you reserve memory for IAP as described?
May be you post your code?
0 Kudos

1,367 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Mon Sep 22 06:04:18 MST 2014
hello
my own boot loader stat at 00 and in this program i will jump to 0xa000 ( in this part I havenot any problem )
my problem is in my application .
when i use application in 00 address and also it's vectors is is working by itself ( without bootloader)
when I want to use it for application I have to set its start address at 0xa00 and also it's vector address because I have to use 00 address for bootlaoder.
how I can set all of my application  program in a000 (rom and vectors ) and when i jump to this address application run .   
0 Kudos