Mark, problem solved! Thank you very much.
I was absorbed on OpenOCD and I've read your suggestion too late. By the way, good stuff! I'll try it asap.
About the flash erasing with OpenOCD, it is possible that the kinetis driver of OpenOCD is not able to automatically recognizes the second flash bank.
I'm not sure. I'll try to describe my experience, maybe it'll help somebody.
The chip on demoboard is a MK64FN1M0VLL12, it has 1M bytes flash in 2 blocks of 512K bytes.
This article from Erich Styger was very useful, especially the comment by Joakim Fernstad.
Following Erich's guide, to fill everything (except m_flash_config) with 0xFF we need to write:
.space 0x000FFBF0, 0xff
this compiles but gives an OpenOCD error, but if I change the length to 0x00080000 (512Kb) it works (unfortunately it is very slow).
After connecting with telnet to the debugger, you can list the banks:
> flash banks
#0 : kinetis.flash (kinetis) at 0x00000000, size 0x00080000, buswidth 0, chipwidth 0
So or this list is not updated after the automatic recognization or OpenOCD recognizes only the first 512Kb flash bank.
How to configure both the two banks of the FDRM-K64F (based on this):
- go to <KDS folder>\openocd\scripts
- make a copy of 'kinetis.cfg' and rename it to 'kinetis_k64.cfg'
- open the 'kinetis_k64.cfg' change:
# Flash size is detected automatically.
flash bank $_CHIPNAME.flash kinetis 0 0 0 0 $_TARGETNAME
to:
# Configure flash banks
flash bank $_CHIPNAME.flash1 kinetis 0 0x80000 0 0 $_TARGETNAME
flash bank $_CHIPNAME.flash2 kinetis 0x80000 0x80000 0 0 $_TARGETNAME
Test:
- go to <KDS folder>\openocd\bin
- launch the debugger with:
openocd.exe -f kinetis_k64.cfg
- the last line should be (with no errors):
Info : kinetis.cpu: hardware has 6 breakpoints, 4 watchpoints
- open telnet with (probably you need to install it first, see 'enable disable windows features' or use Putty):
telnet localhost 4444
- you should see:
Open On-Chip Debugger
>
- type 'flash bank'
> flash banks
#0 : kinetis.flash1 (kinetis) at 0x00000000, size 0x00080000, buswidth 0, chipwidth 0
#1 : kinetis.flash2 (kinetis) at 0x00080000, size 0x00080000, buswidth 0, chipwidth 0
- if everything is ok, open your project and in the 'Config options' of the OpenOCD debugger (Debug Configurations window) change '-f kinetis.cfg' to '-f kinetis_k64.cfg'
How to erase the second bank:
- in telnet type 'flash erase_sector 1 0 last':
> flash erase_sector 1 0 last
Probing flash info for bank 1
Any changes to flash configuration field will not take effect until next reset
erased sectors 0 through 127 on flash bank 1 in 3.601000s
Warning! If you erase the first bank, the MCU will be secured and you need to do a mass erase to unsecure it (or drag and drop a working .bin example on the MBED drive or use Mark's tools!).
On a side note, this has also solved my previous problem.
Best regards,
Gabriele