I'm developing a flash programming tool. Currently it targets only a few chips, but I'd like to consider how to make it more general and possibly support all Kinetis parts.
Once I've established a debug connection, is there a recommended way to detect if the flash controller is FTFA vs FTFL vs FTFE (or something else)?
Is there a best practice to determine which Flash Commands are supported, and what parameters they require? For example, the FTFA and FTFL controllers in the chips I'm using support the Program Longword (0x06) command, but the FTFE controller does not. It has Program Phrase (0x07). FTFA lacks Program Section (0x0B), but even on the FTFL and FTFE controllers which do support it, the FFCOB4/5 parameter specifies the block size differently, in longwords on some chips, phases on others, and double-phases on still other parts.
Currently, I'm reading the ARM CPUID register to detect Cortex-M0+ versus Cortex-M4. The assumption is M0+ always has FTFA, and M4 always has FTFL and FTFE. Maybe?
Can I use SIM_FCFG1[PFSIZE] to distinguish between FTFL and FTFE? Is there some specific size where FTFE is always used?
Does each flash controller always support the same command set, at least for the types of memory the chip has? Or will a FTFE, for example, sometimes have different commands available (and others unavailable)?
Even when I figure out which flash controller is present, how can I detect differences, like FTFL sometimes using the number of longwords on Program Section (0x0B) for some chips versus the number of phrases on other parts?