How to make KBOOT jump to main()?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to make KBOOT jump to main()?

跳至解决方案
1,747 次查看
laszlomonda
Contributor V

Hi there,

I'd like to use the "execute <address> <arg> <stackpointer>" blhost command to make KBOOT jump to the main() function of my application firmware, but I'm not sure how to retrieve the exact addresses to pass. How can I do that?

Thanks in advance!

- Laci

1 解答
1,218 次查看
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi Laci,

My apologies for your unattended question.

The values you are looking for are the reset vector (application's entry point) and the Initial Stack Pointer value. These values are the first and second entries in the vector table (4-bytes each). For KL03 which has a ROM bootloader, the application's vector table does not need an offset so it is placed at the start of flash (address 0). In the parameter "arg" you can simply use 0 if you don't need to pass any data from the bootloader to the application.

To get the actual values you can look at the generated project files (e.g. map file or binary file). Below an example for a KDS project:

pastedImage_3.png

pastedImage_5.png

This is a manual procedure, but you can try to automate it by reading values at address 0x0 (initial stack pointer) and address 0x4 (initial PC / reset vector) either from the project's binary file or directly from the MCU's memory once the application is loaded.

Regards!

Jorge Gonzalez

在原帖中查看解决方案

5 回复数
1,218 次查看
harshpatel
Contributor IV

Hello

We have to just use following commands:

1] get-property

2] flash-erase-region

3] write-memory

4] reset

KBoot will automatically jump to application after BL_DEFAULT_PERIPHERAL_DETECT_TIMEOUT (By default it is 5 sec).

Hope it may Help

Let me know if any..

Thanks & regards

Harsh Patel

0 项奖励
回复
1,218 次查看
laszlomonda
Contributor V

Hi Patel,

Your suggestion doesn't work for me. The reason is that there's constant traffic on the I2C bus which makes the bootloader not time out. I cannot disable I2C in the BCA because I occasionally use the bootloader to update the firmware. I can explain my situation in more detail, but the bottom line is that I need an answer to my original question.

Thanks!

- Laci

0 项奖励
回复
1,219 次查看
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi Laci,

My apologies for your unattended question.

The values you are looking for are the reset vector (application's entry point) and the Initial Stack Pointer value. These values are the first and second entries in the vector table (4-bytes each). For KL03 which has a ROM bootloader, the application's vector table does not need an offset so it is placed at the start of flash (address 0). In the parameter "arg" you can simply use 0 if you don't need to pass any data from the bootloader to the application.

To get the actual values you can look at the generated project files (e.g. map file or binary file). Below an example for a KDS project:

pastedImage_3.png

pastedImage_5.png

This is a manual procedure, but you can try to automate it by reading values at address 0x0 (initial stack pointer) and address 0x4 (initial PC / reset vector) either from the project's binary file or directly from the MCU's memory once the application is loaded.

Regards!

Jorge Gonzalez

1,218 次查看
mohsenchamanira
Contributor I

So I looked at the first 8 bytes of my binary file. it is "00 80 00 20 C1 B1 00 00"

So I am guessing the start address is B1C1+1=B1C2 and the stack pointer is 20008000

However when I excecute the command in blhost "blhost -V -u 0x15a2,0x0073 execute 0xb1c2 0x0 0x20008000" the microcontroller completely restarts instead of jumping directly to the code. is that normal?

0 项奖励
回复
1,218 次查看
laszlomonda
Contributor V

Hi Jorge,

Thank you so much for the detailed answer! Makes sense, and very much appreciated!

- Laci

0 项奖励
回复