Trouble with FRDM-K22 and Kinetis Flash Tool

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

Trouble with FRDM-K22 and Kinetis Flash Tool

跳至解决方案
4,502 次查看
nkp
Contributor II

I'm trying to use the Kinetis Flash Tool to make my FRDM-K22 board run the bootloader. Everytime i try to connect to to my device via the Kinetis Tool I get the following(see picture attached) error. What am I doing wrong? Any help would be greatly appreciated!

标签 (1)
1 解答
3,570 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Niyanth,

 1  Give me a photo of you board connection with the USB cable.

2 Build your project in release mode.

3. check the application code location: led_demo_freedom_a000.bin in folder:NXP_Kinetis_Bootloader_2_0_0\apps\led_demo\MK22F51212\iar\binaries


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
15 回复数
3,570 次查看
BlackNight
NXP Employee
NXP Employee

Hi Niyanth,

can you check no other application is using your COM port?

Additionally, make sure that your K22 is in the bootloader mode, otherwise it will not be able to connect.

Otherwise, you might try out my port of the bootloader to the FRDM-K22F board on GitHub:

mcuoneclipse/Examples/KDS/FRDM-K22F/FRDM-K22F_KBOOT_bootloader at master · ErichStyger/mcuoneclipse ... 

(attached to this reply too)

I hope this helps,

Erich

3,570 次查看
nkp
Contributor II

Hi Erich,

I'm curious as to how I'd go about flashing your bootloader on my FRDM-K22.

I checked out your git readme and wasn't able to get KDS to compile and create a bin file. (I plan to flash the bin file using the Kinetis Flash Tool) Please advice.

Thank you! 

0 项奖励
回复
3,570 次查看
BlackNight
NXP Employee
NXP Employee

To flash the bootloader you need a JTAG programmer (e.g. SEGGER J-Link or P&E Multilink).

You can use the .srec in that zip file I have uploaded in my reply.

And if you are not able to compile the application with KDS v3.2.0, what is the problem?

An example project to be loaded with the booloader is in mcuoneclipse/Examples/KDS/FRDM-K22F/FRDM-K22F_KBOOT_led_demo_freedom_a000 at master · ErichStyger/mc... 

I hope this helps,

Erich

3,570 次查看
nkp
Contributor II

Hi Erich,

The following is the error I get when I try to build your code in KDS 3.2.0

Please advice.

pastedImage_1.png

Edit:

I was able to compile your code after pasting it in the working directory of KDS. Now I face a new problem.

As your git readme suggested I was able to jump to  bootloader mode when I reset (pressing sw3) the first time I flashed code into the controller. 

When I flash my application (led blink), using the Kinetis flash tool at 0xc000, it updates successfully. However, after the flash tool "reset" is hit the device stays in bootloader mode.(Even after peripheral detect timeout) 

Would you happen to know why it behaves like it does?

Thank you!

P.S. - Thank you for your patient and prompt help!

3,570 次查看
BlackNight
NXP Employee
NXP Employee

I have fixed the build error on GitHub ( mcuoneclipse/Examples/KDS/FRDM-K22F/FRDM-K22F_KBOOT_led_demo_freedom_a000 at master · ErichStyger/mc... ), as the project still had a link to the KBOOT installation folder (thanks for reporting!).

Erich

3,570 次查看
BlackNight
NXP Employee
NXP Employee

>>When I flash my application (led blink), using the Kinetis flash tool at 0xc000, it updates successfully. However, after the flash tool "reset" is hit the device stays in bootloader mode.(Even after peripheral detect timeout) .

As you are able to debug the bootloader (you have built it and you have all the sources), why not halt it with the debugger and see where it stays?

The bootloader scans all available communication channels and if it sees one communicating, it stays in the bootloader. I recommend to only enable the communication channels you need.

See as well Getting Started: ROM Bootloader on the NXP FRDM-KL03Z Board | MCU on Eclipse  (it is for a different board and for a ROM bootloader, but the same principles apply for the K22F Flash bootloader.

I hope this helps,

Erich

3,570 次查看
nkp
Contributor II

Thank you very much for your help Erich!

--Niyanth

0 项奖励
回复
3,570 次查看
nkp
Contributor II

Hi Erich!

Thank you very much for the new build! I have been able to flash your bootloader, flash the led demo on it and again jump back to bootloader mode (using the sw3 boot pin). 

My next step was to push any other application using other than the LED one. I am using the bubble demo application as my test case. 

As I understand it right, the bubble demo application should also be memory configured using the linker file starting from address 0xc000 (your bootloader was customized for 0xc000 i.e, the #define BL_APP_VECTOR_TABLE_ADDRESS 0xc000).  

So, I made a new linker file that has the new starting address as attached with this message. 

pastedImage_14.png

I used this linker file and generated a binary for the project and flashed it using the Kinetis Flash Tool after switching to bootloader mode.The update is successful but the desirable outcome is not observed. 

For the other task of disabling other peripherals, I use the bootloader_config.h file and defined macros such as:

define BL_CONFIG_SCUART (0)

#define BL_CONFIG_I2C (0)

#define BL_CONFIG_DSPI (0)

which brought down the bootloader size from 0xB204 to 0xA128 :smileyhappy:

Please advice.

3,570 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Customer,

   If you want to use the kinetis flash tool to download the application code to the bootloader, you need to use the debugger to download the freddeom_bootloader to your chip at first.

I don't know what the IDE you are using, now take KBOOT2.0 IAR project as an example.

   You can download the KBOOT2.0 from this link:

NXP_Kinetis_Bootloader_2.0.0 package

  1. Download the freedom bootloader, you can find it in folder:

NXP_Kinetis_Bootloader_2_0_0\targets\MK22F51212

 Choose the project freedom_bootloader, build an download it to your chip.

pastedImage_2.png

If you are using KDS project.

   Add this below code in bootloader_config.h

 #define BL_TARGET_FLASH 1

2. Application code prepare.

From the freedom_bootloader file bootloader_config.h.

#if !defined(BL_APP_VECTOR_TABLE_ADDRESS)
#define BL_APP_VECTOR_TABLE_ADDRESS 0xa000
#endif

So, you need to relocate the application code to address 0xa000.

You can use led_demo_freedom_a000.bin in folder:NXP_Kinetis_Bootloader_2_0_0\apps\led_demo\MK22F51212\iar\binaries

3. open KinetisFlash Tool

Configure it like the following picture.

Before you click the connect button in the kinetisFlash tool, please press the on board reset button at first.

pastedImage_3.png

After connect successfully, press the updated button.

You will find it download successfully.

pastedImage_4.png

Then the on board LED will binking.

Please try it on your side.

If you still have question, please let me know!


Have a great day,
Kerry

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

3,570 次查看
nkp
Contributor II

Hi Kerry,

I followed your instructions and wasn't able to flash the program successfully. Here is the screenshot;

pastedImage_1.png

Please advice.

Thanks!

Niyanth.

3,571 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Niyanth,

 1  Give me a photo of you board connection with the USB cable.

2 Build your project in release mode.

3. check the application code location: led_demo_freedom_a000.bin in folder:NXP_Kinetis_Bootloader_2_0_0\apps\led_demo\MK22F51212\iar\binaries


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
3,570 次查看
nkp
Contributor II

Hi Kerry,

I was able to put multiple applications using the changes you mentioned on the Freedom_bootloader. 

Thank you!

I have created my LED application using processor expert. I changed the memory section addresses to match with the bootloader bl_vector address to make it work. If I am not using the processor expert how can I make the demo application (the bubble demo) change its memory addresses so that I can push that binary using this method.

(Aim: I want to make my user application without using processor expert and push it to the device)

 

Please advice.

--Niyanth

0 项奖励
回复
3,570 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Niyanth Krishna Polisetty,

    Even you don't use the PE, just use the bare application project, you still can refer to the kboot app relocate method, just modify the link file like this:

pastedImage_1.png

You can refer to KBOOT app kds project:NXP_Kinetis_Bootloader_2_0_0\apps\led_demo\MK22F51212\kds\led_demo_freedom_a000


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
3,570 次查看
nkp
Contributor II

Hi Kerry!

Thank you very much for your reply. As per your instructions

>> I defined the macro BL_TARGET_FLASH to 1 inside my bootloader_config.h file. 

>> I programmed my K22 with this bootloader application

>> The device appeared as "FSL_Loader" when connected via usb on my PC

>> On the Kinetis Flash Tool, I used the USB-HID option (in the picture) instead of UART

>> I was able to connect with the device

>> However, I wasn't able to flash the bin file 

>> The error is shown in the picture attached

Inline image 1

Also,

Let's say I successfully programmed the bootloader and the application at oxa000 then I'd like to go to bootloader mode again. I think by pressing the boot pin i.e. the sw3 on the FRDM-K22, I should be able to jump into bootloader mode. (I tried this method multiple times using the flashloader_loader and it doesn't work). 

Please advice.

Thank you!

0 项奖励
回复
3,570 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Niyanth Krishna Polisetty,

   It seems you are using KDS project, but you still didn't confirm it.

  Now, take KDS project as an example: NXP_Kinetis_Bootloader_2_0_0\targets\MK22F51212\kds\freedom_bootloader

  1. take care, using freedom_bootloader, not flash loader loader.

  2. You need to add the following code in bootloader_config.h

     #define BL_TARGET_FLASH 1

pastedImage_1.png

3. Use the USB cable to connect J16 interface on the FRDM-K22 board.

4. Open KinetisFlash Tool, choose USB-HID.

  Press on board SW1, then press the connect button in the kinetisFlash Tool.

pastedImage_2.png

   You can find I can connect successfully.

5. Update the application code

pastedImage_3.png

You can find I can update it successfully.

After download the application code, wait about 6 seconds, you will find the on board led is blinking.

BTW, your picture link, I can't open it.

Have a great day,
Kerry

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------