After making a small change and rebuilding the serial bootloader for the Kinetis K60 I had problems programming it in to the target (using the Flash Programmer utility from within CodeWarrior, with a P&E Micro Multilink Universal FX). I had consistent errors programming the third segment, even after a full erase:
cmdwin::fl::write
Beginning Operation ...
-------------------------
Using restricted address range 0x00000000 to 0x000FFFFF
Programming file C:\Users\mdkendall.ELEMENTS\Documents\SCU-Bootloader\Applications\uTaskerSerialBoot\KinetisCodeWarrior\uTaskerSer
ialBoot_FLASH\uTaskerSerialBoot.srec
Auto-detection is successful.
File is of type Motorola S-Record Format.
Downloading Flash Device Driver ...
Reading flash ID ...
Auto-detection is successful.
File is of type Motorola S-Record Format.
Downloading 0x00000008 bytes to be programmed at 0x00000000
Executing program ....
Program Command Succeeded
Downloading 0x00004D4B bytes to be programmed at 0x00000400
Executing program ....
Program Command Succeeded
Downloading 0x00000023 bytes to be programmed at 0x0000514C
Executing program ....
Error: Program failed. Flash driver reports the following error(s): Chip reported error during program. Please check that the sector you are programming is erased.
After a bit of Googling I found a post on the Freescale forums that indicates an alignment of 8 is required.
https://community.freescale.com/thread/312328The segment that failed to program was on a 4-byte boundary. I edited the linker file (\Applications\uTaskerV1.4\KinetisCodeWarrior\Linker_Files\K_1M_128.ld) to change all the ALIGN(foo, 4) directives to ALIGN(foo, 8 ) and that has fixed my problem:
cmdwin::fl::write
Beginning Operation ...
-------------------------
Using restricted address range 0x00000000 to 0x000FFFFF
Programming file C:\Users\mdkendall.ELEMENTS\Documents\SCU-Bootloader\Applications\uTaskerSerialBoot\KinetisCodeWarrior\uTaskerSer
ialBoot_FLASH\uTaskerSerialBoot.srec
Auto-detection is successful.
File is of type Motorola S-Record Format.
Downloading Flash Device Driver ...
Reading flash ID ...
Auto-detection is successful.
File is of type Motorola S-Record Format.
Downloading 0x00000008 bytes to be programmed at 0x00000000
Executing program ....
Program Command Succeeded
Downloading 0x0000474C bytes to be programmed at 0x00000400
Executing program ....
Program Command Succeeded
Downloading 0x000005FF bytes to be programmed at 0x00004B50
Executing program ....
Program Command Succeeded
Downloading 0x00000023 bytes to be programmed at 0x00005150
Executing program ....
Program Command Succeeded
I haven't investigated this in any detail, but it has solved my problem.