Hi Derek,
I am working on a serial bootloader project using uTasker's Serial Loader (a really GREAT product with excellent support, by the way).
I am using IAR 7.40.3, and a Segger J-Link JTAG pod. I have the configuration protection bits programmed as:
#define KINETIS_FLASH_CONFIGURATION_PROGRAM_PROTECTION (0xfffffffc) // PROT[24:31]:PROT[23:16]:PROT[15:8]:PROT[7:0] - no protection when all are '1'
which should protect to two lowest blocks. My application code is linked above these two blocks, and I download it via the serial loader.
I followed your instructions, and added --enable_config_write to a .board file. Here is the content:
<?xml version="1.0" encoding="iso-8859-1"?>
<flash_board>
<pass>
<loader>$TOOLKIT_DIR$\config\flashloader\Freescale\FlashK60Dxxx128K.flash</loader>
<range>CODE 0x0 0xfffffff</range>
<args>--enable_config_write</args>
</pass>
<pass>
<loader>$TOOLKIT_DIR$\config\flashloader\Freescale\DFlashK60Dxxx128K.flash</loader>
<range>CODE 0x10000000 0x13ffffff</range>
<rel_offset>0xf0800000</rel_offset>
</pass>
</flash_board>
The first time, I am able to Download and Debug the application with no problem. However, if I try to Download and Debug again, I get the following errors back via dialog boxes:
"The flash loader program reported an error." I click OK, then get:
"A fatal error has occurred. The debugger will terminate.". I click OK, but am stuck not being able to program my project into Flash.
Using the same .board file, I tried using Project/Download/Erase Memory, and selected Erase All.
The Debug Log reports that Flash memory was erased:
Fri Nov 20, 2015 18:07:50: Loaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.40\arm\config\debugger\Freescale\Kxx.dmac
Fri Nov 20, 2015 18:08:19: Loaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.40\arm\config\flashloader\Freescale\FlashK60Xxxx128K.mac
Fri Nov 20, 2015 18:08:20: JLINK command: ProjectFile = C:\Natus-EACS\SignalController\uTasker\Kinetis_14-9-2015\Applications\uTaskerSerialBoot\IAR7_Kinetis\settings\uTaskerSerialBoot_FLASH.jlink, return = 0
Fri Nov 20, 2015 18:08:20: Device "MK60DN512XXX10" selected.
Fri Nov 20, 2015 18:08:20: DLL version: V4.98e, compiled May 5 2015 11:00:52
Fri Nov 20, 2015 18:08:20: Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Fri Nov 20, 2015 18:08:20: JTAG speed is initially set to: 32 kHz
Fri Nov 20, 2015 18:08:20: TotalIRLen = 4, IRPrint = 0x01
Fri Nov 20, 2015 18:08:20: TotalIRLen = 4, IRPrint = 0x01
Fri Nov 20, 2015 18:08:20: Found Cortex-M4 r0p1, Little endian.
Fri Nov 20, 2015 18:08:20: FPUnit: 6 code (BP) slots and 2 literal slots
Fri Nov 20, 2015 18:08:20: CoreSight components:
Fri Nov 20, 2015 18:08:20: ROMTbl 0 @ E00FF000
Fri Nov 20, 2015 18:08:20: ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB000 SCS
Fri Nov 20, 2015 18:08:20: ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 003BB002 DWT
Fri Nov 20, 2015 18:08:20: ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 002BB003 FPB
Fri Nov 20, 2015 18:08:20: ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 003BB001 ITM
Fri Nov 20, 2015 18:08:20: ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 000BB9A1 TPIU
Fri Nov 20, 2015 18:08:20: ROMTbl 0 [5]: FFF42000, CID: B105900D, PID: 000BB925 ETM
Fri Nov 20, 2015 18:08:20: ROMTbl 0 [6]: FFF43000, CID: B105900D, PID: 003BB907 ETB
Fri Nov 20, 2015 18:08:20: ROMTbl 0 [7]: FFF44000, CID: B105900D, PID: 001BB908 CSTF
Fri Nov 20, 2015 18:08:22: Hardware reset with strategy 2 was performed
Fri Nov 20, 2015 18:08:22: Initial reset was performed
Fri Nov 20, 2015 18:08:22: Found 1 JTAG device, Total IRLen = 4:
Fri Nov 20, 2015 18:08:22: #0 Id: 0x4BA00477, IRLen: 4, IRPrint: 0x1 CoreSight JTAG-DP
Fri Nov 20, 2015 18:08:22: ----- Prepare hardware for Flashloader -----
Fri Nov 20, 2015 18:08:22: 2560 bytes downloaded and verified (20.00 Kbytes/sec)
Fri Nov 20, 2015 18:08:22: Loaded debugee: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.40\arm\config\flashloader\Freescale\FlashK60Dxxx128K.out
Fri Nov 20, 2015 18:08:22: Target reset
Fri Nov 20, 2015 18:08:23: Unloaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.40\arm\config\flashloader\Freescale\FlashK60Xxxx128K.mac
Fri Nov 20, 2015 18:08:23: Loaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.40\arm\config\flashloader\Freescale\FlashK60Xxxx128K.mac
Fri Nov 20, 2015 18:08:23: ----- Prepare hardware for Flashloader -----
Fri Nov 20, 2015 18:08:23: 2560 bytes downloaded and verified (2.54 Kbytes/sec)
Fri Nov 20, 2015 18:08:23: Loaded debugee: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.40\arm\config\flashloader\Freescale\FlashK60Dxxx128K.out
Fri Nov 20, 2015 18:08:23: Target reset
Fri Nov 20, 2015 18:08:23: Unloaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.40\arm\config\flashloader\Freescale\FlashK60Xxxx128K.mac
Fri Nov 20, 2015 18:08:23: Flash memory has been erased.
Note that it "claims" that Flash memory has been erased. However, if I try to Download and Debug again, I get the same error "The flash loader program reported an error."
Partly out of desperation, I tried the J-Flash Lite utility provided by Segger. Under Target device selection, I selected Freescale, then MK60DN512xxx10 (allow security) and clicked OK. I selected JTAG as the interface, and left Speed at the default of 1000. I then clicked OK.
At the next dialog box, I clicked "Erase Chip". I received a dialog box that said "Active Kinetis write protection detected. This could cause problems during flash download Do you want to perform a mass erase of the device in order to remove flash write protection? If "Do not show this message again" is selected, mass erase will be performed automatically in the future." I clicked Yes to erase the chip, which appeared to work successfully, and then exited J-Flash Lite.
I was then able to go back into IAR and Download and Debug - again, only the first attempt was successful. It appears that the --enable_config_write option is not working as expected.
Can you think of any reason why this would not work, or some setting that I might have missed? Having to go to an external program to erase the chip is painful and seems unnecessary, since that apparently is the purpose of the --enable_config_write parameter.
Thanks for any help you can provide!
Scott