Road to K64F port

ChibiOS public support forum for topics related to the Freescale Kinetis family of micro-controllers.

Moderator: utzig

User avatar
RoccoMarco
Posts: 557
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 65 times
Been thanked: 50 times
Contact:

Road to K64F port

Postby RoccoMarco » Mon Feb 15, 2016 7:12 pm

Hey there,
I'm trying to port ChibiOS 3.0 on Freescale K64F in order to understand certain mechanisms and take a look deeper in this RTOS. Before to start, I'm configuring ChibiStudio (on Windows) and I have a problem related to the OpenOCD part.

Well, I know this is off-topic but the internet seems to be outdate on this topic,so I hope someone has faced (and solved) the same problem before. I'm using Open-SDA with CMSIS-DAP debug support. I have configured a new entry into external tools launching OpenOCD using as interface "cmsis-dap.cfg" but something goes wrong. It seems like the flash is in a secured state since I have received this reply:

Code: Select all

Open On-Chip Debugger 0.10.0-dev-00200-gdb56a3b (2016-02-10-18:08)
Licensed under GNU GPL v2
For bug reports, read
   http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
Info : add flash_bank kinetis k60.flash
adapter speed: 1000 kHz
none separate
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 100ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 700ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 1500ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 3100ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ef40
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ef44
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe0002000
Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe0001000
Info : k60.cpu: hardware has 0 breakpoints, 0 watchpoints
Warn : MDM: Secured MCU state detected however it may be a false alarm
Warn : MDM: Halting target to detect secured state reliably
Warn : target was in unknown state when halt was requested
Info : SWD IDCODE 0x2ba01477
Warn : MDM: Target not halted, trying reset halt
Info : SWD IDCODE 0x2ba01477
Info : SWD IDCODE 0x2ba01477
Warn : *********** ATTENTION! ATTENTION! ATTENTION! ATTENTION! **********
Warn : ****                                                          ****
Warn : **** Your Kinetis MCU is in secured state, which means that,  ****
Warn : **** with exception for very basic communication, JTAG/SWD    ****
Warn : **** interface will NOT work. In order to restore its         ****
Warn : **** functionality please issue 'kinetis mdm mass_erase'      ****
Warn : **** command, power cycle the MCU and restart OpenOCD.        ****
Warn : ****                                                          ****
Warn : *********** ATTENTION! ATTENTION! ATTENTION! ATTENTION! **********


Now, I have issued the command "kinetis mdm mass_erase" and OpenOCD works...

Code: Select all

Info : SWD IDCODE 0x2ba01477
Error: Failed to read memory at 0xe000ed00
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target k60.cpu failed, trying to reexamine
Info : k60.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : MDM: Chip is unsecured. Continuing.
k60.cpu: target state: halted
target halted due to debug-request, current mode: Thread


Until I disconnect/reconnect the USB: in this case the Flash comes back in a secured state...
Suggestions?

Regards,
RM

User avatar
RoccoMarco
Posts: 557
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 65 times
Been thanked: 50 times
Contact:

Re: Road to K64F port

Postby RoccoMarco » Mon Feb 15, 2016 7:28 pm

Ok, I have solved this problem.
It seems flash went in secure mode because there was no firmware on it. Copying a working firmware on it now it works. On OpenOCD launch I am receiving this message:

Code: Select all

Open On-Chip Debugger 0.10.0-dev-00200-gdb56a3b (2016-02-10-18:08)
Licensed under GNU GPL v2
For bug reports, read
   http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
Info : add flash_bank kinetis k60.flash
adapter speed: 1000 kHz
none separate
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD IDCODE 0x2ba01477
Info : k60.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : MDM: Chip is unsecured. Continuing.

flabbergast
Posts: 71
Joined: Sat Aug 22, 2015 1:22 pm

Re: Road to K64F port

Postby flabbergast » Tue Feb 16, 2016 11:23 pm

The byte at 0x40C of the flash on Freescale chips is the byte which governs whether the chip is un/locked and/or whether the mass erase command is enabled (so it is possible to completely brick the chip if your firmware has a wrong value at that address I think).
See page 662 of K64F reference manual ("Flash configuration field description") and pages 670-671 for the description of the bits of the FSEC byte ("Flash Security Register (FTFE_FSEC)").
I'm writing this just so that you know you should be careful about what you flash onto a Kinetis chip :)

User avatar
RoccoMarco
Posts: 557
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 65 times
Been thanked: 50 times
Contact:

Re: Road to K64F port

Postby RoccoMarco » Tue Feb 16, 2016 11:33 pm

Thanks. Good to know.

jstruebel
Posts: 18
Joined: Sat Oct 17, 2015 5:59 am
Been thanked: 3 times
Contact:

Re: Road to K64F port

Postby jstruebel » Mon Jul 03, 2017 7:54 pm

Hi Rocco,

Did you ever get your K64F port working? I'm trying to do the same, but against the latest development branch of ChibiOS. Somehow, when I compile my version and load it, it causes my debugging to stop working. I can recover the debugging interface if I re-load the default example using the MSD, but if I can have a working port to look at I think it will help me in debugging where I went wrong.

Thanks,
Jonathan

User avatar
RoccoMarco
Posts: 557
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 65 times
Been thanked: 50 times
Contact:

Re: Road to K64F port

Postby RoccoMarco » Mon Jul 03, 2017 9:20 pm

Hi,
I was able to port the kernel and run the generic arm cortex demo but I never continued to develop it. I started to support STM32 and this take all my spare time right now.
Ciao,
RM


Return to “Kinetis Support”

Who is online

Users browsing this forum: No registered users and 1 guest