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: 655
Joined: Wed Apr 24, 2013 4:11 pm
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 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: 655
Joined: Wed Apr 24, 2013 4:11 pm
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 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: 655
Joined: Wed Apr 24, 2013 4:11 pm
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 times
Contact:

Re: Road to K64F port

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

Thanks. Good to know.

jstruebel
Posts: 19
Joined: Sat Oct 17, 2015 5:59 am
Has thanked: 2 times
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: 655
Joined: Wed Apr 24, 2013 4:11 pm
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 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

wiml
Posts: 7
Joined: Fri Dec 08, 2017 6:52 am
Location: Seattle, USA
Has thanked: 2 times
Been thanked: 5 times

Re: Road to K64F port

Postby wiml » Fri Dec 08, 2017 7:41 am

For what it's worth, I've also been working on a K64F port, for the Teensy3.5. I'm at the point where the basic ChibiOS/RT tests run, and I'm working on the one or two drivers I need.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Road to K64F port

Postby Giovanni » Fri Dec 08, 2017 8:53 am

Hi,

That is great, what is needed now is a developer or group of developers willing to maintain the port.

Giovanni

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

Re: Road to K64F port

Postby jstruebel » Fri Dec 08, 2017 5:39 pm

I'm willing to help where I can, but my ability to support is limited due to other commitments in my life.
I wasn't able to get back to debugging this, so it's great to know someone got it working. Do you have a GitHub repository or set of patches that I can pull to try it out?

wiml
Posts: 7
Joined: Fri Dec 08, 2017 6:52 am
Location: Seattle, USA
Has thanked: 2 times
Been thanked: 5 times

Re: Road to K64F port

Postby wiml » Fri Dec 08, 2017 11:16 pm

I haven't published anything. I assume the best way to do so would be to make a fork of the contrib repository on github so that it can be merged in at some point. I am unlikely to have the time to maintain this port once I'm done with this project, but there seem to be many people who have some interest in running ChibiOS on the K64F, so perhaps if a basic port is in contrib then there will be enough interest to keep it going.

I have one question, for Giovanni — I needed register definitions, so I found a CMSIS file from Freescale and hacked it a little to be in the form that the existing K20x LLDs wanted. Is there any copyright or other concern with dropping that modified CMSIS file into ChibiOS-Contrib? Would it be better to write a script to generate a CMSIS-like header from the SVD file?


Return to “Kinetis Support”

Who is online

Users browsing this forum: No registered users and 5 guests