DFU bootloader switch mode?

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

DFU bootloader switch mode?

2,059 次查看
danielchai
Senior Contributor I

Hi All,

I read the AN4370.pdf for DFU boot-loader. When I read the code, I notice that there is a Swicth_mode() function. In this function, there is a variable called temp, but I did not find which function change this variable. My question is how does the bootloader achieve switching from bootloader to main application in this code.  And when does it check if there is valid main application in flash?

Thank you.

-Daniel

0 项奖励
回复
6 回复数

1,799 次查看
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Daniel,

The "temp" variable stores the value read from a GPIO which depends on the supported tower board, it will reflect the state whether the GPIO is pulled up or down by the user so that the application gets to know how to switch the mode. This operation is done before USB enumeration , and the application check if there is a valid user application in flash when mode is switched to the application mode, if not available, it will switch back to boot loader mode automatically and start to enumerate as DFU device.

Hope that helps,

B.R

Kan

1,799 次查看
danielchai
Senior Contributor I

Hi Kan,

Thank you for you answer.

I read the code, but I didn't get which part and which  function is used for check valid user application code.

The reason why I want to check this is because I followed the AN4370 instruction download a user application code, but after I press the reset button, it can not run the user application code. The weird thing is that it also doesn't enter the bootloader mode either. (I am using CW2, K60N512.)

Thanks.

-Daniel

0 项奖励
回复

1,799 次查看
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Daniel,

The part used for check valid user application code is shown in the following snapshot. Please kindly refer to it for details.

1.PNG

Hope that helps,

B.R

Kan

0 项奖励
回复

1,799 次查看
danielchai
Senior Contributor I

Hi Kan,

In my project, this part is commended out by default. Then if I want to use K60, do I have to add the check application part myself?

3.bmp

Thank you.

-Daniel

0 项奖励
回复

1,799 次查看
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Daniel,

Seems you are using CW 10.4, so that part enclosed by __CWCC__ would be used in the application, you know, it is a predefined macro, so the text viewer would treats it as undefined while viewing. Sorry for the confusion that has caused. Please kindly refer to the following for more details.

1.PNG.png

Hope that helps,

B.R

Kan

0 项奖励
回复

1,799 次查看
dereksnell
NXP Employee
NXP Employee

Hi Daniel,

The function Switch_mode() in Boot_loader_task.c checks if there is a valid application, and will jump to it if present.  It looks for a non-erased flash location at the initial PC and SP location in the application vector table.  In the K60 example, it reads address 0xA000 and 0xA004 for these values, using the pointer IMAGE_ADDR. 

With the TWR-K60N512, you can test the bootloader using the example \AN4370SW\Source\Device\app\dfu_bootloader\cw10\kinetis_k60.  By default, this example has no application programmed in flash, and the bootloader will load.  Then you can use the DFU to program one of the example applications in \AN4370SW\image_files\K60.

NOTE: be sure your TWR-SER board is setup in USB Device mode for this to work.  Jumper J16 needs to short pins 3-4; the middle pair.

0 项奖励
回复