Download code to flash memory in non-zero adress

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

Download code to flash memory in non-zero adress

3,025 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Wed Sep 19 01:56:22 MST 2012
I write in "Keil uvision4".
When i download code to flash memory in non-zero adress (for example in 0x00000100) microcontroller does not work.
The place in which i load a code i set follows:
right click on project-->Options for target-->Linker-->R/O base = 0x00000100.
When I look in the HEX-file, I see that it records the addresses starting with 0x00000100.
Downloading this code from LPCXpresso leads to "vectors still have erased values" error.
What i forgot?
Thanks)
0 Kudos
Reply
12 Replies

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Fri Oct 05 03:28:36 MST 2012
Hardware bootloader of lpc11c24 have comand "Go" to restart the microcontroller after download a program to him. But address by which this comand can jump should be on a word boundary. My Reset_handler located by adress 0x01ad. How can i move him to a word boundary adress, for example, to 0x01b0?
I use Keil
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Mon Oct 01 23:31:15 MST 2012
My secondary bootloader for lpc11c24 without using remapping, because:

Quote:
On-chip RAM from address 0x1000 0050 to 0x1000 00B8 is used by the CAN API. This address range should not be used by the application. For applications using the on-chip CAN API, the linker control file should be modified appropriately to prevent usage of this area for application’s variable storage.


Both bootloader and application use the CAN interrupts.
CAN_IRQHandler of "bootloader":

Quote:

__ASM void CAN_IRQHandler_of_application(void)
{
ldr r0, =0x2074
ldr r0, [r0]
bx r0
}

void CAN_IRQHandler(void)
{
if ( *(uint32_t *)0x100001F0 == 0x67 )
{
CAN_IRQHandler_of_application( );
}
else
{
(*rom)->pCAND->isr();
}
}



CAN_IRQHandler of "application":

Quote:

void CAN_IRQHandler (void)
{
(*rom)->pCAND->isr();
}



The value 0x67 in SRAM-memory to 0x100001F0 write "application" when start:

Quote:

uint32_t *ram_vector_table;
ram_vector_table=(uint32_t *)0x100001F0;
*ram_vector_table = 0x67;



It is simple and it is work:)
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Fri Sep 21 03:31:03 MST 2012
I learned how to jump out of the "bootloader" in the "application", if "application" does not use interrupts:

/****************************************************************/
#include "LPC11xx.h"
#include "core_cm0.h"
#include "system_LPC11xx.h"

__ASM void __jump_( )
{
ldr r0, =0x1000
ldr r0, [r0]
mov sp, r0

ldr r0, =0x1004
ldr r0, [r0]
mov pc, r0
}

int main(void)
{
SystemInit();
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
__jump_( );
while(1);
}
/********************************************************************/


But when i try to copy all interrupt vectors table:

/********************************************************************/
#include "LPC11xx.h"
#include "core_cm0.h"
#include "system_LPC11xx.h"

__ASM void __jump_( )
{
ldr r0, =0x1000
ldr r0, [r0]
mov sp, r0

ldr r0, =0x1004
ldr r0, [r0]
mov pc, r0

ldr r0, =0x1008
ldr r0, [r0]
ldr r1, =0x0008
mov [r1], r0

ldr r0, =0x100C
ldr r0, [r0]
ldr r1, =0x000C
ldr r1, [r1]
mov pc, r1

......................
//exactly the same set of commands
......................

ldr r0, =0x10BC
ldr r0, [r0]
ldr r1, =0x00BC
ldr r1, [r1]
mov pc, r1



}

int main(void)
{
SystemInit();
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
__jump_( );
while(1);
}

Is not work.
The set of commands:

ldr r0, =0x10BC
ldr r0, [r0]
ldr r1, =0x00BC
ldr r1, [r1]
mov pc, r1

Don't work. Where I was wrong?
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Thu Sep 20 01:09:04 MST 2012

Quote: whitecoe
As you are running Keil's tools, you might want to consider posting on their forum....

http://www.keil.com/forum/

But you could also check the Keil documentation. The "Errors and Warnings" manual contains details of the error you are encountering...

http://www.keil.com/support/man/docs/armerr/armerr_babdjcci.htm

HTH!



Thanks for advice))

the second link I get advice: This warning is intended as a reminder to consider using the embedded assembler or built-in intrinsics instead of inline assembler.
Using of embedded assembler - not at any price.
remains using the built-in intrinsics.
Consider replacing all the inline assembler functions on built-in intrinsics functions in a piece of code from my last code.
Do you think all the commands in this code have built-in intrinsics analogs?
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by whitecoe on Thu Sep 20 00:24:18 MST 2012

Quote: Almaz

I get the error:
aplication\main.c(34): error:  #1113: Inline assembler not permitted when generating Thumb code



As you are running Keil's tools, you might want to consider posting on their forum....

http://www.keil.com/forum/

But you could also check the Keil documentation. The "Errors and Warnings" manual contains details of the error you are encountering...

http://www.keil.com/support/man/docs/armerr/armerr_babdjcci.htm

HTH!
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Wed Sep 19 23:59:27 MST 2012
used microcontroller is lpc11c24 (processor Cortex-m0).
When i use inline assembly from "NXP secondary bootloader" example:

__asm volatile("ldr r0, =0x103C");
__asm volatile("ldr r0, [r0]");
__asm volatile("mov pc, r0");

I get the error:
aplication\main.c(34): error:  #1113: Inline assembler not permitted when generating Thumb code

But i can't set the arm mode, because Cortex-m0 is Thumb-only processor!
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Wed Sep 19 04:12:01 MST 2012
&#1057;&#1087;&#1072;&#1089;&#1080;&#1073;&#1086; &#1079;&#1072; &#1089;&#1089;&#1099;&#1083;&#1082;&#1091;)) &#1041;&#1091;&#1076;&#1091; &#1088;&#1072;&#1079;&#1073;&#1080;&#1088;&#1072;&#1090;&#1100;&#1089;&#1103;(&#1050;&#1072;&#1082; &#1103; &#1085;&#1072; &#1085;&#1077;&#1077; &#1087;&#1086;&#1080;&#1089;&#1082;&#1086;&#1084; &#1085;&#1077; &#1085;&#1072;&#1090;&#1082;&#1085;&#1091;&#1083;&#1089;&#1103;?).
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArtjomGromak on Wed Sep 19 03:42:09 MST 2012

Quote: ArtjomGromak
&#1044;&#1072;, &#1085;&#1091;&#1078;&#1085;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1072;&#1090;&#1100; &#1076;&#1074;&#1077; &#1087;&#1088;&#1086;&#1075;&#1088;&#1072;&#1084;&#1084;&#1099; &#1074;&#1086; flash. &#1082;&#1072;&#1078;&#1076;&#1072;&#1103; &#1087;&#1086; &#1089;&#1074;&#1086;&#1077;&#1084;&#1091; &#1089;&#1084;&#1077;&#1097;&#1077;&#1085;&#1080;&#1102;.



Post http://knowledgebase.nxp.com/showthread.php?t=3615 about boot
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArtjomGromak on Wed Sep 19 03:35:08 MST 2012

Quote: Almaz
How to be.
It turns out that i can not download two programs into one microcontroller (for example "application_1" program in first sector and "application_2" program in second sector)?



&#1044;&#1072;, &#1085;&#1091;&#1078;&#1085;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1072;&#1090;&#1100; &#1076;&#1074;&#1077; &#1087;&#1088;&#1086;&#1075;&#1088;&#1072;&#1084;&#1084;&#1099; &#1074;&#1086; flash. &#1082;&#1072;&#1078;&#1076;&#1072;&#1103; &#1087;&#1086; &#1089;&#1074;&#1086;&#1077;&#1084;&#1091; &#1089;&#1084;&#1077;&#1097;&#1077;&#1085;&#1080;&#1102;.
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed Sep 19 03:29:35 MST 2012
If you want two programs, you must also have a boot loader that will switch between them. As you have been told, you must (as a minimum) provide an SP and a Reset Handler in the first two locations.
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Wed Sep 19 03:20:50 MST 2012

Quote: ArtjomGromak
Your program must have stack_pointer_value in address 0x0 and Reset_Handler placed in 0x4.
Now your program can't work.



How to be.
It turns out that i can not download two programs into one microcontroller (for example "application_1" program in first sector and "application_2" program in second sector)?
0 Kudos
Reply

2,870 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArtjomGromak on Wed Sep 19 03:06:01 MST 2012

Quote: Almaz
I write in "Keil uvision4".
When i download code to flash memory in non-zero adress (for example in 0x00000100) microcontroller does not work.
The place in which i load a code i set follows:
right click on project-->Options for target-->Linker-->R/O base = 0x00000100.
When I look in the HEX-file, I see that it records the addresses starting with 0x00000100.
Downloading this code from LPCXpresso leads to "vectors still have erased values" error.
What i forgot?
Thanks)



Your program must have stack_pointer_value in address 0x0 and Reset_Handler placed in 0x4.
Now your program can't work.
0 Kudos
Reply