AN2295 again! Now it stuck on downloading custom firmware

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

AN2295 again! Now it stuck on downloading custom firmware

Jump to solution
3,409 Views
kai_liu
Senior Contributor I

Hello, here comes my questions regarding AN2295 again.

 

Previous

In my previous thread of Something wrong with AN2295 bootloader on FRDM-KL25Z for its reset behaviour . I finally managed to communication with FRDM-KL25Z on 57600bps with short TRIM option.

 

Current

I have prepared my demo software, (a sample code from FSL with modified ICF) but it can not be downloaded into FRDM-KL25Z.

 

Expectation

Since FSL MCU has no bootloader on MCU like other vendor do, AN2295 becomes very important. Other USB bootloader takes too much resources. However, in order to make it work, we have more to do: a good bootloader, a stable PC software, a custom demo software. If anyone can help me out, I will write a dedicated document regarding my experiences to share with you guys.

 

A: Programming failed.

 

After establishment of communication, I can run win_hc08sprg. Erase and BLANK check are all right. The PROGRAM fails on 0x00001080.

 

5696_5696.pngFSL_AN2295_Demo_Program_Failed.PNG.png

First of all, "Can't program block 0 at address 0x00001080", why 0x00001080 belongs to block 0, it should be in block 1 if block size is 128B.

 

The any following actions like ERASE/BLANK check prompt as "NOT ERASE" or "NOT BLANK CHECK". What is it? The client software refuses to erase or fails on erasing?

 

B: AN2295.pdf has not been updated for Kinetis/ColdFire.

 

The original bootloader was designed for HC08, which is an 8-bit micro with 2B address. But for 32-bit micro, it should be 4B, but that protocol parameters have not been updated in AN2295.pdf.

 

Additionally, the communication log is missing in this software, I have no idea what happens on serial communication.

 

C: It is tricky to debug flash programming on FRDM/OpenSDA.

 

The win_hc08sprg refuses to talk with AN2295 bootloader when it is in debug mode. Therefore I have to emulate it with legacy protocol described on FSL document.

 

I found something new to me:

a) After erasing flash, flash configuration byte array from 0x400 to 0x40F is:

     FF FF FF FF FF FF FF FF FF FF FF FF FE FF FF FF

b) The first page of user area (0x00001000~0x0000107F) has been programmed successfully, but it stops on 0x00001080, anyway. I added some LED indicator, which shows the programming is successful.

c) The write buffer is defined as 256B, while flash page (write block) size is 128B. I can not find any special functions to handle two halves.

 

Attachment

 

Kinetis_rev3_programming_fail.zip: my revision of AN2295 (Debug) project for IAR, which adds some LED as mini indicator.

Pflash_32KB_AN2295.icf: my linker ICF for a sample application, changed for AN2295.

DemoApp_4_FC_Bootloader_freedom.srec: my srec for a sample application, linked with modified ICF file.

Original Attachment has been moved to: DemoApp_4_FC_Bootloader_freedom.srec.zip

Original Attachment has been moved to: Kinetis_rev3_programming_fail.zip

Original Attachment has been moved to: Pflash_32KB_AN2295.icf.zip

1 Solution
1,163 Views
kai_liu
Senior Contributor I

Hi, Ma Hui,

My Python script works now. It supports simple work-flow for one shot blank/erase/program in command line.

It has not been fully tested under other boards/MCUs. Up to now it only works on my FRDM-KL25Z, with my revision of AN2295 bootloader and a modified demo application.

It works, FINALLY !

I will prepare a document to describe everything about my experiences. As first step, my Python code will be released under x86 executive for Windows XP.

The related document is shared at FSL community: https://community.freescale.com/docs/DOC-95429


My Plan

  1. Release an application note regarding AN2295 on FRDM-KL25Z, including AN2295 project, DemoApp project, Python script (FcBootloaderProgrammer.py)
  2. Reduce codesize in bootloader and DemoApp to support smaller MCU.
  3. Modify my ADB/USB_Host project on AN2295 to support my GAP board
  4. Integrate AN2295 bootloader with my IDE (Kirin IDE, based upon wxPython GUI)
  5. Modify AN4379 MSD bootloader with FRDM-KL25Z, which comes from FSL USB MSD demo and flash driver from AN2295.
  6. Modify AN2295 FC bootloader with built-in SREC parser, discard PC side software.

View solution in original post

0 Kudos
8 Replies
1,163 Views
ganeshramachand
Contributor IV

Hi I am using MKE02Z64VLD2 microcontroller in KDS 2.0 IDE.. For me memory is getting Erased and Programmed perfectly.

My application code name is TestBeta which is a simple code to blink LED. I converted this Application file into S19 file and I included it under s19 file section.

Memory is Erased

BL erase.jpg

Memory is programmed

BL Program.jpg

But the LED is not blinking.

What is the problem ?

OR

I have to do something else to run the application file ?

0 Kudos
1,163 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Kai,

I check AN2295 bootloader programmed code size is about 8KB (check from bootloader generated S19 file).
For KL25 Flash size is 128KB and in [kinetis_params.h] file with below definition:
//  size of one protection section depends on flash size in Bytes (protected block = flash size / 32)
#define FLASH_PROT_SECTION ((KINETIS_FLASH/32) * 1024)

The Flash protected section size is 4KB for KL25 chip if you have modified Flash size in [bootloader_cfg.h] file with below definition:
/** Kinetis Flash memory size */
#define KINETIS_FLASH FLASH_128K
/* Flash end address */
#define USER_FLASH_END 0x0001FFFF

If you are set application code, it need set application icf file with Flash start address at 0x2000
define symbol __ICFEDIT_region_ROM_start__ = 0x00002000;
define symbol __code_start__ = 0x00002410;//********

KL25 flash only with 1 block and each sector size is 1KB.

Wish it helps.

B.R.

Ma Hui

1,163 Views
kai_liu
Senior Contributor I

Hi Ma Hui, thanks for your quick response.

I have rebuilt my AN2295 bootloader in IAR, I got following information:

  1 524 bytes of readonly  code memory

    116 bytes of readonly  data memory

    412 bytes of readwrite data memory

So my version is not 8KB, but less than 2KB. Here is clip of my an2295.srec (enclosed attachment, pls).

S0160000414E323239355F4B696E657469732E7372656377

S1130000F801002041050000110400001104000063

S11300101104000011040000110400001104000088

...

S113082004A0064024800440F80100000C010020CC

S1130830100100200000002048F00F4044F00F4059

S10F084003A0064008ED00E004100000D6

S9030541B6

According to Motorola's srec file. The beginning is 0x00000000, the end is 0x0000084F (around), about 2128B. So I think user space starts from 0x00001000 is right. Also I have verified that on debugger-memory window after downloading my bootloader into FRDM.

(PS, that leads to another issue, the bootloader should be thrinked anyway to fit into smalled micro like KL01/02/05).


Update

Good news: AN2295 works for downloading now,

Bad news: It only works under terminal window, we need update client software.

I have no other solution, so I have to use my barehand tool, SSCOM32 to emulate traffic between bootloader and win_hc8sprg. The following traffic is good.

PC->MCUMCU->PC
FC FC FC FC (keep sending out FC, cause warning locking 0xFC on win_hc8sprg.
FCFC (ACK)
'I'88 14 86 00 00 00 01 00 00 10 00 00 00 FF FF 00 00 10 00 00 00 00 00 00 00 04 00 00 00 00 80 4B 4C 32 00 00 (Identification)
45 00 00 10 00FC (ACK, erasing done)
57 00 00 10 80 80 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 50 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7FFC (ACK, programming done)
52 00 00 10 80 80

00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 50 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F

(Readout content, good)

'Q'(No response), drops into sending FC on and on...
FC FC FC

Interesting! It works on AN2295 + SSCOM32.

AN2295_SSCOM32.PNG.png

Maybe we can draw a conclusion. The win_hc08sprog has not updated to support Kinetis? Well that is a problem, who can solve that? That's a part of bootloader package.

For debug and test purpose, I can write a Python script w/ SREC parser to download custom firmware dedicated for KL25Z. But a stable general purpose bootloader software takes more time.

Even the PC client software is done, we need more time to validate the demo application with icf file.

Ma Hui,

I am very appreciated if you can get more resources internally from FSL to update it and make it work. It save us a lot of time. I can not image if my bootloader can not work on customers' sites. What a disaster.

1,163 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I have got a updated version of [win_hc08sprg.exe], please check if attached tool works for your application.

Wish it helps.

B.R.

Ma Hui

0 Kudos
1,164 Views
kai_liu
Senior Contributor I

Hi, Ma Hui,

My Python script works now. It supports simple work-flow for one shot blank/erase/program in command line.

It has not been fully tested under other boards/MCUs. Up to now it only works on my FRDM-KL25Z, with my revision of AN2295 bootloader and a modified demo application.

It works, FINALLY !

I will prepare a document to describe everything about my experiences. As first step, my Python code will be released under x86 executive for Windows XP.

The related document is shared at FSL community: https://community.freescale.com/docs/DOC-95429


My Plan

  1. Release an application note regarding AN2295 on FRDM-KL25Z, including AN2295 project, DemoApp project, Python script (FcBootloaderProgrammer.py)
  2. Reduce codesize in bootloader and DemoApp to support smaller MCU.
  3. Modify my ADB/USB_Host project on AN2295 to support my GAP board
  4. Integrate AN2295 bootloader with my IDE (Kirin IDE, based upon wxPython GUI)
  5. Modify AN4379 MSD bootloader with FRDM-KL25Z, which comes from FSL USB MSD demo and flash driver from AN2295.
  6. Modify AN2295 FC bootloader with built-in SREC parser, discard PC side software.
0 Kudos
1,163 Views
kai_liu
Senior Contributor I

Hello, Ma Hui.

Thanks for your update software. My previous one is v10.0.12.0. Now I got a version promotion to v10.0.16.0. I have no idea why its size grows from 1.8MB to 6.1MB.

FSL_AN2295_Update_Fail.PNG.png

You can see, the programming still fails. The highlight is that it reveals everything on console. So we can find following information.

prg_blk: 0x00001080-0x000010ff

wb(57,) returned 0 (programming success of last block returns as 1)

Can't program block 0 at address 0x00001080

I checked the return value, which is a byte count of being sent out. No a response from bootloader. That means something wrong in software which can not send out on serial communication.

The software is making progress, we are very close to success. That's really good.

Anyway, we still need to remove the bug.

I am working on a simple Python script as plan B, no sure when I can finish it.

0 Kudos
1,163 Views
kai_liu
Senior Contributor I

Obviously, FSL AN2295 has not been fully validated on FRDM-KL25Z, which can be found in IAR project files, and protocol itself.

In Kinetis, SDID is 32bit, while AN2295 only has 16bit.

In Kinetis, the flash memory range should be 0x0000(or 0x1000)~0x1FFFF, but AN2295 only supports to 0xFFFF. which means the user application only can use 60KB (= 64K-4K), and the upper half is missed. We can change it in source code, anyway. But ......

And its protocol version is v8 (from 0x88 for its first byte return from ident command), which is not documented in AN2295.pdf.

It is a better approach to release a self-contained bootloader, which allows user to use regular terminal software to download hex/srec file directly. The client software is unnecessary.

FYI, my Python script can erase, blank check now. Now I am trying to download an SREC file.

0 Kudos
1,163 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Kai,

I am checking this issue, I will let you know when I got any updaed info.

Thank you for the patience.

B.R.

Ma Hui

0 Kudos