I have my custom K22 bootloader working from end to end, except it refuses to actually flash any bytes.
Erase comes back ok, as I would expect on a fresh load, but the FLASHprogramlongs() command always returns a fail.
I modified the linker file and flash_config area setup because original did not accomodate a 1M part. Each protect bit is 32k, so I moved the app start vector to 0x8000 and adjusted everything accordingly.
I don't see any protection bits enabled, so don't think this is the problem.
I'm guessing it has something to do with clocks or wait states?
We are using an external xtal, 8.00mhz clocked up to 20.9 mhz. clock rail to FTFE is enabled.
anyone know what I can check or is there something else that needs to be set up?
This is a pretty complicated flash controller and I see lots of workarounds for various parts in the original bootloader source I started with..
If i run this on the debugger does debugging do something to prevent flash operation?
Thanks
Ken
Hi Ken,
Regarding to the issue, the FLASHprogramlongs() fucntion obviously fail to execute the program flash operation, and I don't think the frequency of flash clock cause the issue.
So I was wondering if you can share the code of FLASHprogramlongs() fucntion.
I'm looking forward to your reply.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Jeremy,
the code used is straight from the "Kinetis Bootloader master 1027".
It's the standard flash_kinetis.c driver, basically the same one used in
all the other bootloader distributions.
I have not modified this. I checked the command codes used and
registers, all seem to match the MK22FN1M0 part.
I verified that the clock to the module is enabled, so it must be running.
In this version, the flash commands are copied to ram and executed from
there. I have 1 interrupt running for a timer, but I turn this off
before each flash operation. other than that the only other mods I have
made are to use a different uart and add a simplistic 7 segment display.
I could attach the whole project, but since it is for a custom board you
would have no way to actually run it.
Ken
Hi Ken,
Thanks for your reply.
The FTFE can indicate the error condition through the corresponding bit in the FTFE_FSTAT register.
So I was wondering if you can tell what kind of the error condition rise after execute the flash command.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
The original boot code doesn't return the error just pass/fail..which is
pretty useless IMHO.
I modified it and it is returning a 0x20, ACCERR..
The K22 1M part has a protection granularity of 32k, so only 1 bit set.
0XFFFFFFFE. This also means that App code MUST start at 0x8000. All
items pertaining to this have been modified.
something else curious. Boot code has FLASH_PROGRAM_LONGWORD command as
0x06. Family manual for K22 parts says there is no 0x06 command..
We have working flash code in an MK70 part. It defines this as
0x07..which is listed and this code works in MK70, but it is slightly
different in that it is placed in ram using an __atrribute_ directive,
whereas the bootcode copies the commands into ram using an INIT routine.
I don't see how the released boot code could ever work with these
errors..someone care to Splain it to me cause I clearly don't get it..
Thanks
Ken
Hi Ken,
Thanks for your reply, I'd like highly recommend that you can refer to the C90TFS flash driver for details.
You can download the driver through the link as below.
cache.freescale.com/files/32bit/software/C90TFS_FLASH_DRIVER.exe?fromsite=zh-Hans
And after install, you can find the set of demos which contains the demo for the K22.
Hope it helps.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
here is the table from FRM for FN22 part
As you can see there is NO 0x06 command as used in ALL OF THE BOOTLOADER
distributions CLAIMING to support the Kinetis parts.
NXP I need an direct answer here as to why.
If i use the 0x07 command it works until I try and program only 4 bytes
instead of 8. then it fails even if I pad the other 4 bytes with 0xff.
The sector was erased before hand so it contains ff's and NOT data....
Why? This makes absolutely no sense to me.
Hi Ken,
The set of programming flash command:
Processors will support either the program longword or program phrase command, but not both. So you should refer to the flash module overview table for more information
I've attached an application note and you can learn the more information about the flash programming on Kinetis MCU.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jeremy,
Im working with the C90TFS drivers and a MK22FN1M0AVLL12 and i having problems to erase and program flash sectors which are into block 0 when the running. I mean when i go step by step it works well.
Please could you check the following post i put??
K22 FTFE Erase Sector command failure
From 11-nov-2016 2:36 forward
It is due to "FlashCommandSequence" function for sure, because i have commented its call from erase function and the MCU doesnt go to reset state.
Hope you can help me.
Thanks and best regards.