FSL has a great application note AN4379 regarding MSD device bootloader for Kirin3/Flexis JM/Kinetis K60 w/ CW, written by Derek Snell.
Additionally FSL also offers USB source for MSD device for emulated RAM and external SD card (via SPI bus) for multiple platforms.
I am looking for MSD device bootloader for KL25Z for IAR toolchain.
Is there any update for AN4379? I just want to make sure I am not going to re-invent the wheel on bootloader, ‘cause application development is my focus.
解決済! 解決策の投稿を見る。
UPDATE 07
The revised MSD device bootloader has been released on USB MSC device bootloader revision for FRDM-KL25Z (IAR)
The code is developed on USB stack v4.0.3 with reused functions from AN2295/AN4370. Its version has been promoted to v1.0 beta.
I have verified the project by a relocated user application starts from 0x8000. Just download them and try it on your FRDM-KL25Z.
Yours sincerely
Allan K Liu
UPDATE 07
The revised MSD device bootloader has been released on USB MSC device bootloader revision for FRDM-KL25Z (IAR)
The code is developed on USB stack v4.0.3 with reused functions from AN2295/AN4370. Its version has been promoted to v1.0 beta.
I have verified the project by a relocated user application starts from 0x8000. Just download them and try it on your FRDM-KL25Z.
Yours sincerely
Allan K Liu
im having trouble importing and compiling for the kl25 processor
can some one make a CW10.3,4,5 file set .... to upload
im getting al sorts of errors about the audio classes.....
I have not installed CW, so... Maybe you must check the macro definitions (for conditional build).
But I would like to propose you to use the IAR bootloader as is, if you can just use it as a black box.
UPDATE 06
Now code is working and verified. :smileyhappy: Finally !
There is a bug in low-level flash programming for long word. The control loop is controlled by size, which is Nr of byte. So the size = size - 4, rather than -1.
LWord FLASH_ProgramSectionByLongs(LWord destination, LWord* pSource, LWord size)
{
//dumpBuf((unsigned char*)pSource,size,0);
//while(size--)
while(size)
{
if(FLASH_ProgramLongWord(destination, *pSource++) != FLASH_OK)
return FLASH_FAIL;
destination += 4;
size -= 4;
}
printf("\r\n");
return FLASH_OK;
}
In next official release, I will prepare an application note with source code as well as demo firmware and icf file.
I spent a week on porting AN4379 on FRDM-KL25Z with IAR. Although this question was posted 4 months ago.
That is another problem I solve by myself. I did wish any FSL team can help me to accelerate this process. It took too much time than my expectation.
UPDATE 05
There are no code update. Just sharing my latest experiences.
I move printf( ) before running low-level flash programming routines (FCCOB). The buffer dumping seems correct. From very beginning to end.
So far I have collected references manuals for K20/KL25, and I found they are not sharing same code base. There are many parallel releases from FSL teams.
Compare to K20 FTFL and K60 FTFE, KL25 has a simpler flash module called FTFA without RAM based sector programming and some other features.
But most of the basic FCCOB is same. No idea why programming failed anyway.
UPDATE 04 with more questions/bugs
Dear all,
I list you guys on my help list, 'cause I think you are experienced on this topic and can help me on AN4379 USB MSC/MSD bootloader porting to FRDM-KL25Z.
The current code base is:
Current performance:
Bugs:
Attached file:
FSL USB stack is hard to share a single project, I have to zip them all. Please using compare tools carefully to avoid replacing your own version. Especially the common sources have been revised slightly.
UPDATE 3
The previous version fails on USB enumeration. I gave up on debugging low-level USB driver. So I re-create project on USB stack v4.0.3 with bootloader file. Now we can see BOOTLOADER driver now, but downloading firmware with wrong content.
Anyone who is interested on AN4379 on FRDM-KL25Z with IAR?
Please download and help us to remove the bugs together.
The zip file should unzipped into USB stack source tree, in following path:
X:\Freescale\Freescale USB Stack v4.0.3\Source\Device\app\
Thanks.
UPDATE 1
The firmware have been merged based upon original CW for K60 to IAR for KL25Z. Also I reuse code from AN2295 for its flash driver and simple drivers for timer, watchdog and etc.
The source code is built successfully. I attach my very first version here. However, it is not a working bootloader. I have not made it working on FRDM yet.
I put it here just in case someone who need it urgently and want to debug by himself. And don't freak out if you find the source is too messy.
I will release my final code with FSL community. It will be a very simple version without verification, authentication, personalization and other features.
However I have to say. FSL should help us to develop and verify all the bootloaders, including AN2295 serial bootloader, AN4370 USB DFU bootloader, AN4379 USB MSC bootloader, as well as other bootloader including USB host MSC bootloader, SD Card bootloader, Ethernet bootloader, CAN bootloader, I2C/SPI bootloader.
At least, FSL should align a standard driver for bootloaders, including drivers for K/KL flash memories, USB interface, serial com, file parser, FAT File system.
Yours sincerely
Allan K Liu
I spent one day to port this MSC/MSD bootloader to KL25Z with IAR. It is not finished yet.
And I found that it is easy to port from CW to IAR. Porting from K60 to KL25Z takes more time. They have differences in many ways, including registers in GPIO/SIM/FTFA ......
It only matters on time to delivery. It is not so difficult since we can cut and past some sources from AN2295, and it is working for KL25Z anyway.
So, my porting path is:
The source code is messy. Too many macros are used.
Keep tuned.
Hi Kai,
I have contacted to AN4379’s author and he said me that there aren’t plans of updating the application note for supporting KL25 devices.
However, Kinetis L devices are supported on the last version of USB Stack; so, you could use the MSD stack example for KL25 as base, and adding the Bootloader support from the application note similar to the current implementations. If you have troubles with the Flash routines, you could use the C90TFS Flash driver. On the following link you can find an example for KL25 device:
https://community.freescale.com/docs/DOC-94593
Hope this will be useful for you.
Best regards!
/Carlos
Hi Carlos,
I've found AN4379 is a great tool not only for bootloading easily but also a great template for modifying to get another funcionalities. For example, I'm developing an application which will store some sensor data into the own MCF51JM128's flash memory and the goal is to present this few bytes as a plain text file to the PC. With the help of FAT16 documentation I've learned how to "create" directories, files, give attributes, etc...It is all to be defined in the FAT16_RootDirSector variable. So here comes my question: how can I get to "write" the content of the file, for example some simple ascii characters inside some example.txt file and when the PC open file the content can in effect be retrieved and copied to local drive ???
Do I have to look for FAT16 cluster write methods?, And, what could be the structure inside AN4379's FAT16.c source file and SCSI functions?. Of course I understand the given source files are not intented for a complete file system, but for emulation purposes that helps one's application and that's just great :smileyhappy:
Really appreciating your valuable comments and guidance,
Pablo B.
Hello Pablo.
You could refer to application note AN4115, which implements the FAT file system from DEMOFLEXISJMSD board on MM/JE Flexis devices, and create/modify files stored on a SD card. This document is available at the following link:
www.freescale.com/files/microcontrollers/doc/app_note/AN4115.pdf
Hope this will be useful for you.
Best regards!
/Carlos
Hello,
I managed to modify AN4379 code in order to respond to SCSI commands such as sector read, and understand the strategy corresponding to the AN's own code. Now I can generate my own plain and image files for custom applications...Very useful for low memory requirements and fast implementations not relying on additional SD Card! Just be careful with cluster and sector definitions according to FAT16 specification.
If anyone should find it useful or needs help on this, just leave me a message and will be glad to help.
Regards,
Pablo
Hi, Pablo,
It is great if you can share any resources like source code/library or even binary release.
Because my project is too urgent to wait for AN4379, and MSD bootloader has a big ass (about 22KB) to fit into my board. I use AN2295 bootloader from FSL so far.
However, the original design has not been tested on FRDM-KL25Z. As a result, I changed some code and release my own tool, and my paper is here: https://community.freescale.com/docs/DOC-95429
Alternatively, BlackNight has published serial bootloader on github. mcuoneclipse/Examples/FRDM-KL25Z/FRDM_Bootloader at master · ErichStyger/mcuoneclipse · GitHub
Hi Kai, surely I will gladly post my results once I get my code very debugged, structured and documented for you colleagues to use it at best.
Thank you for your feedback.
Pablo
Hello Carlos,
Very useful AN...
Muchas gracias!!
Thanks, Carlos.
I will share my work, anyway.
Hi Kai,
Any update on your work? Curious to know...
Thanks
Bala
Nope, sorry.