I have a TWR-K60F120M and TWR-SER2 and IAR 7.7. I’m using the Kinetis 120MHz bare metal sample code** (KINETIS_120MHZ_SC.zip) downloaded today with only the modifications noted here.
The KINETIS_120MHZ_SC\build\iar\hello_world for the k60 project works fine when it runs from RAM. This makes me believe that my PEMicro configuration is working and my serial port is connected to a terminal correctly.
If I switch to hello_world_k60_tower – FLASH 1M configuration, things begins to go badly. When I compile and download, I get “Missing or malformed flash loader specification file: …Freescale\FlashK70Xxxx.board”
I switched it to $TOOLKIT_DIR$\config\flashloader\NXP\FlashK60Fxxx128K.board
This led to “The flash loader program reported an error” then “A fatal error has occurred. Debugger will terminate.” The Debug Log window had no additional useful information for me:
Thu Jul 28, 2016 10:46:53: Software reset was performed
Thu Jul 28, 2016 10:46:54: 3196 bytes downloaded and verified (2.44 Kbytes/sec)
Thu Jul 28, 2016 10:46:54: Loaded debugee: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.7\arm\config\flashloader\NXP\FlashK60Fxxx128K.out
Thu Jul 28, 2016 10:46:54: Target reset
Thu Jul 28, 2016 10:46:55: The flash loader program reported an error.
Thu Jul 28, 2016 10:46:57: IAR Embedded Workbench 7.70.1 (armproc.dll)
I tried switching the flash loader override board to the more generic $TOOLKIT_DIR$\config\flashloader\NXP\FlashKxxFxxx128K.board. But got the same errors. I even tried the obviously wrong FlashK70Fxxx128K.board because that seemed to be what the example wanted but I got the same errors.
Per Trouble downloading and debugging K22 project using IAR 7.2... Any ideas?, it looks like overriding the default was a good idea (it was also how the example code ware already configured). I tried enable_config_write with FlashK60Fxxx128K.board as the base, as suggested in Using IAR EWARM to program flash configuration field, but that led to exactly the same errors.
I opted to modify Options->Debugger->Download so kept Use flash loader(s) checked but no longer checked Override default .board file. Same errors.
Next, I unchecked Use flash loader(s) per a few posts (https://community.nxp.com/message/341033). This led to a different popup upon loading: “Warning: There were warnings during download, see Log Window.” and in the Debug Log:
Thu Jul 28, 2016 10:55:12: Loaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.7\arm\config\debugger\NXP\Kxx.dmac
Thu Jul 28, 2016 10:55:16: P&E Interface detected - Flash Version 31.21
Thu Jul 28, 2016 10:55:17: Device is NXP_K6x_K60FN1M0M12.
Thu Jul 28, 2016 10:55:17: Mode is In-Circuit Debug.
Thu Jul 28, 2016 10:55:17: Initial reset was performed
Thu Jul 28, 2016 10:55:17: CPU reset by debugger.
Thu Jul 28, 2016 10:55:17:
Thu Jul 28, 2016 10:55:17: Software reset was performed
Thu Jul 28, 2016 10:55:20: 7496 bytes downloaded and verified (2.62 Kbytes/sec)
Thu Jul 28, 2016 10:55:20: Warning: Target inconsistency detected in Memory range 0x00000000-0x00001D47
Thu Jul 28, 2016 10:55:32: Warning: There were warnings during download, see Log Window
Thu Jul 28, 2016 10:55:32: Loaded debugee: C:\Freescale\KINETIS_120MHZ_SC\build\iar\hello_world\FLASH_1M\Exe\hello_world_k60_tower.out
Thu Jul 28, 2016 10:55:32: CPU reset by debugger.
Thu Jul 28, 2016 10:55:32:
Thu Jul 28, 2016 10:55:32: Software reset was performed
Thu Jul 28, 2016 10:55:32: Target reset
Thu Jul 28, 2016 10:55:32: There was 1 warning during the initialization of the debugging session.
However, it would seem that the flash did not actually get programmed. The initial PC doesn’t get set correctly, my __startup is at 0x411 but memory address 0x00000000 has 0x1FFF2670 as the SP and 0x00004A69 as the initial PC. This does not run, of course.
Note that Trouble downloading and debugging K22 project using IAR 7.2... Any ideas? mentioned that there is flashloader source code. It is not in 7.7 (C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.7\arm\src\flashloader); there is no entry for NXP or Freescale. I do have code from a 7.4 version of IAR (which, by the way, gives all the same flash errors during download described here though the paths the .board files were all in that EWARM directory instead). The source code lets me choose between MK60X256VMD100 and MK60N512VMD100 when I have an MK60F120Mx. I don’t think this is a useful path.
Does anyone have a working example and flash loader? Should I be concerned about this TWR-K60 board? Is using IAR going to cost me all sorts of time and I really must switch to CodeWarrior or I’ll regret it? (The rest of the company uses IAR so that's an uphill battle.)
** Note: I want to use the Freescale USB Stack v4.1.1 example code but those are K70 and I want to simplify my issue here. I have seen How to add support for K60 120MHz part in USB stack ver 4.1.1 and worry that doesn’t show how to use the USBHS mode but none of that matters unless I can program the flash.