Status: Text content finished, to be updated with more diagrams/images.
First of all. I have to say sorry for my English since I am not a native speaker.
This is my personal experience of using AN2295 on FRDM-KL25Z. I want to share it with anyone who is suffering on it, since the existing release from FSL has not been fully tested on FRDM-KL25Z. (I can figure it out in many ways.)
The lastest microcontrollers always have some kind of bootloader to download user code to the flash memory. FSL does offer many bootloaders for various mcu families. Among them, AN2295 bootloader is general purpose for most of these families, since it only requires an UART, either hardware or software UART.
To make AN2295 work for a system, the developer must have three components:
UPDATE
Add an2295_programmer_v1.zip for Python source code, you need install PySerial module for Python 2.5.
Please visit following URLs to download necessary files:
http://www.freescale.com/files/microcontrollers/doc/app_note/AN2295.pdf
http://cache.freescale.com/files/32bit/doc/app_note/AN4767.pdf
AN4767: UART Boot Loader Design on the Kinetis E Series, a more detail application note for AN2295 on E series.
The released AN2295 has to be updated before downloading into FRDM. When you open the AN2295_Kinetis project in IAREW, please update the following setup items in IDE.
We can conclude a fact that AN2295 is good enough as a bootloader as it has been tested on many MCU families. The source code is open, so you can custom it for your own specific purposes. However, you have to do it yourself.
The reason why I change baudrate is I found VCP of OpenSDA will decode 0x00 send from KL25Z as 0x80. So I slow down to 57600.
Unfortunately, The released (10.0.12.0) and updated (10.0.16.0) versions of bootloader PC software don't work with my bootloader. The released PC software of AN2295 is open source as well. However I am not fan for VC++. I prefer to make my own programmer software with Python, as knows as a clue language.
The programmer software is released in Windows exe format and works in command line prompt. The user don't bother to install Python/PySerial and other components.
The programmer software works in a simple single shot mode, blank/erase/program actions.
D:\an2295_programmer>FcBootloaderProgrammer --help ################################################## FC Booloader Programmer v0.1-alpha - An alternative to Freescale AN2295 on FRDM-KL25Z by Allan K Liu (C)2013 Ennovation LLC ################################################## Usage: -h, --help : This help information -p, --port : Serial port setting in Windows, like COMxx, depends on your VCP installation -b, --baudrate : Baud rate setup from 9600/19200/38400/57600/152000 -f, --file : Hex file (Motorola SREC or Intel HEX) -a, --action : Action [blank/erase/program] -d, --debug : Debug [0:1]
In order to make it simpler, I prepare some DOS batch files.
FcBootloaderProgrammer --port=COM14 --baudrate=57600 --debug=1 --action=blank
FcBootloaderProgrammer --port=COM14 --baudrate=57600 --debug=1 --action=erase
FcBootloaderProgrammer --port=COM14 --baudrate=57600 --debug=1 --action=program --file=DemoApp_4_FC_Bootloader_freedom.srec
You can disable debug output optionally.
In order to run a user application with AN2295 bootloader, you have to rebuild it with modified linker script.
You can generate a new app based upon Kinetis L Sample Codeby following steps.
The major changes are:
define symbol __ICFEDIT_region_ROM_start__ = 0x00001000; define symbol __ICFEDIT_region_ROM_end__ = 32*1024; define exported symbol __VECTOR_TABLE = 0x00001000; define symbol __code_start__ = 0x00001410;
After building the project, we can get similiar srec file, which has start address at 0x1000.
S027000044656D6F4170705F345F46435F426F6F746C6F616465725F66726565646F6D2E7372656331 S1131000F80B0020111400002929000029290000F0 S11310102929000029290000292900002929000084 ...... S1132B200A0D4B4C300000000A0D4B4C31000000E4 S1132B300A0D4B4C320000000A0D4B4C33000000D0 S10B2B400A0D4B4C34000000A7 S9032B0DC4
According to SREC file format, its filename: DemoApp_4_FC_Bootloader_freedom.srec. And it ranges from 0x1000 to 0x1B47
Finally, run "erase.bat", then "blank.bat", then "program.bat"
Simple!
During my development for AN2295, I used some other tools, especially PC terminal to monitor events/traffics on RS232/UART.
Here are my plan.
I have no idea why ICF and SREC files are in zip format. Anyway, I have verified the integrity of attached files.
Known Limitation:
FcBootloaderProgrammer only works on linear and complete memory SREC file. I am working on it. By now, you can manually fill up memory holes/gaps between memories blocks.
For example:
S1131190000000000000000000000000000000004B S11311A0FFFFFFFFFFFFFFFF0A0000000100000038 S113141000B51149002003E000220A71401C10317C S11314200A28F9D300BD10B5010000240A4800229F
It has a memory gap between 0x11B0 and 0x140F, takes up about 6 flash blocks:
Just an alert.
Update
By using above skill, I have downloaded my ADB board via AN2295 bootloader. And it works. I know manually fill up is a bad approach. Keep tune for the next release for FcBootloaderProgrammer.
Hi.
Excuse me please for my ignorance (and for my english too), but I think that in the ICF file modifications specifically at the line:
define symbol __ICFEDIT_region_ROM_end__ = 32*1024;
you must write:
define symbol __ICFEDIT_region_ROM_end__ = 128*1024;
if you're using a MKL25Z128VLK4 MCU, because it has a 128Kb flash.
Correct me if I'm wrong please.
Best regards!