Boot loader custom, jump to application

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi,
I have developed the custom boot loader on the XMC 1404 with 200 KB flash size.
my boot loader occupies the range address on flash 0x10001000 to 0x10005000
the application occupies the range address on flash 0x10005001 to 0x10033000
the function for jump to application is:

Reboot_Loader PROC
EXPORT Reboot_Loader
LDR R0, =0x10005001
BX R0
ENDP

but this function generate the hard fault error.
any idea?
thanks

U.I.
0 Likes
11 Replies
chismo
Employee
Employee
First like received
Hello,

I found an article from the following link:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka12545.html

In this case, the application should occupy the address range starting from 0x10005000 instead of 0x10005001.
The call to function remains to 0x10005001.
This way, the processor will branch to address 0x10005000 but interpret the instruction found there as a Thumb opcode, due to LSB=1.

Regards,
Min Wei
0 Likes
Not applicable
Hi Min,
I have set start address 0x10005000 but not work, this generate fault hardware.
in the application, the vector table must be set?
Thanks

U.I.
0 Likes
lock attach
Attachments are accessible only for community members.
chismo
Employee
Employee
First like received
Hello U. I.,

The vector table is dependent on the application and should not be a problem.

I have built a simple example to model your use case, please see attached zipped file.


The example consists of 2 projects:
1) a "bootloader" project which
- is defined for the Flash range 0x10001000 - 0x10005000 by modifying the linker script file
- contains just the code:

__asm
(
"LDR r0, =0x10005001\n"
"BLX r0"
);


2) a running LEDs example that
- is defined for the Flash range 0x10005000 - 0x10005001 similarly by modifying the linker script file
- toggles in sequence P4.0, P4.1, P4.2 and P4.3 based on the SysTick interrupt handler

Since there isn't a real bootloader, I downloaded the two hex codes into the XMC1400 device using XMC Flasher tool.
The "bootloader" codes will trigger the branch to 0x10005000 which contains the reset vector of the application program.
The vector table of the application will be set up accordingly and system initializes (system startup).
Finally the running LEDs code executes (application is running).

Is your solution built similarly to the above flow?
If so, could there still be issues with the actual bootloader codes?

Regards,
Min Wei
0 Likes
Not applicable
Hi,
I am using the uVision Keil or DAVE tools, you can program on the demo board?
Regards,
U.I.
0 Likes
Not applicable
Hi,
I loaded with J-Flash Lite your boot and application hex file successfully.
If I load flash my hex files and your boot hex files, do not work.
The my hex file is created (with uVision tools) at start address 0x10005000.
any idea?
Thanks
0 Likes
chismo
Employee
Employee
First like received
Hello,

I tried generating a LED blinking hex file with uVision5 and this works for me (application program can be entered).
For keil, you can directly modify the address from the project properties:
2206.attach

Can you try creating a simple application to see if it works?
Just to be sure the problem is not due to the current application program.

Regards,
Min Wei
0 Likes
lock attach
Attachments are accessible only for community members.
Not applicable
Hi,
yes, I have configurated the address flash in "option for target".
I atteched the my application project.
Can you controller my project?
thanks

U.I.
0 Likes
chismo
Employee
Employee
First like received
Hello,

There is an error when I tried to open the file with WinZip.
It says that the file is not a valid archive file.

Do you think you can attached the zipped file again?
Hopefully it is just a one-time issue.

Regards,
Min Wei
0 Likes
lock attach
Attachments are accessible only for community members.
Not applicable
Hello,
I attached the zipped file again.

U.I.
0 Likes
chismo
Employee
Employee
First like received
Hello,

I have tried your code.
Yes, I am also not able to get the DAVE-generated bootloader and Keil-generated application to work.
However, if I use a Keil-generated bootloader to go with your code, it works fine.
So my suspicion is that the previous problem is related to the different compilers used.

Can you try to create the bootloader program using Keil instead?

I am using the following code with Flash start address at 0x10001000 and size 0x4000

void RunAPP(void);

int main(void)
{

RunAPP();

while(1)
{
/* Infinite loop */
}
}

// run the codes from application flash areas
__asm void RunAPP(void)
{

LDR r0, =0x10005001
BLX r0

}


Regards,
Min Wei
0 Likes
Not applicable
Hello,
I resolved!!!
the problem was in the function for jumping to the application.
In uVision Keil Tools the function for jump to the application is:

JumpToUserApplication
msr msp, r0
msr psp, r0
bx r1
END

is called in the main function:

#define RELOCATED_VECTORS 0x10005000 // Start address of relocated interrutp vector table
void JumpToUserApplication(LWord userSP, LWord userStartup);

/**
****************************************************************************
* Funzione di main
*
* \param nessuno
*
* \return nessuno
*
****************************************************************************
*/
int main ( void )
{

JumpToUserApplication(*((unsigned long*)RELOCATED_VECTORS), *((unsigned long*)(RELOCATED_VECTORS+4)));

while(1)
{
}

}

U.I.
0 Likes