1.. zephyr:board:: frdm_k64f 2 3Overview 4******** 5 6The Freedom-K64F is an ultra-low-cost development platform for Kinetis K64, 7K63, and K24 MCUs. 8 9- Form-factor compatible with the Arduino R3 pin layout 10- Peripherals enable rapid prototyping, including a 6-axis digital 11 accelerometer and magnetometer to create full eCompass capabilities, a 12 tri-colored LED and 2 user push-buttons for direct interaction, a microSD 13 card slot, and connectivity using onboard Ethernet port and headers for use 14 with Bluetooth* and 2.4 GHz radio add-on modules 15- OpenSDAv2, the NXP open source hardware embedded serial and debug adapter 16 running an open source bootloader, offers options for serial communication, 17 flash programming, and run-control debugging 18 19Hardware 20******** 21 22- MK64FN1M0VLL12 MCU (120 MHz, 1 MB flash memory, 256 KB RAM, low-power, 23 crystal-less USB, and 100 Low profile Quad Flat Package (LQFP)) 24- Dual role USB interface with micro-B USB connector 25- RGB LED 26- FXOS8700CQ accelerometer and magnetometer 27- Two user push buttons 28- Flexible power supply option - OpenSDAv2 USB, Kinetis K64 USB, and external source 29- Easy access to MCU input/output through Arduino* R3 compatible I/O connectors 30- Programmable OpenSDAv2 debug circuit supporting the CMSIS-DAP Interface 31 software that provides: 32 33 - Mass storage device (MSD) flash programming interface 34 - CMSIS-DAP debug interface over a driver-less USB HID connection providing 35 run-control debugging and compatibility with IDE tools 36 - Virtual serial port interface 37 - Open source CMSIS-DAP software project 38 39- Ethernet 40- SDHC 41 42For more information about the K64F SoC and FRDM-K64F board: 43 44- `K64F Website`_ 45- `K64F Datasheet`_ 46- `K64F Reference Manual`_ 47- `FRDM-K64F Website`_ 48- `FRDM-K64F User Guide`_ 49- `FRDM-K64F Schematics`_ 50 51Supported Features 52================== 53 54NXP considers the FRDM-K64F as the superset board for the Kinetis K 55series of MCUs. This board is a focus for NXP's Full Platform Support for 56Zephyr, to better enable the entire Kinetis K series. NXP prioritizes enabling 57this board with new support for Zephyr features. The frdm_k64f board 58configuration supports the following hardware features: 59 60+-----------+------------+-------------------------------------+ 61| Interface | Controller | Driver/Component | 62+===========+============+=====================================+ 63| NVIC | on-chip | nested vector interrupt controller | 64+-----------+------------+-------------------------------------+ 65| SYSTICK | on-chip | systick | 66+-----------+------------+-------------------------------------+ 67| PINMUX | on-chip | pinmux | 68+-----------+------------+-------------------------------------+ 69| GPIO | on-chip | gpio | 70+-----------+------------+-------------------------------------+ 71| I2C | on-chip | i2c | 72+-----------+------------+-------------------------------------+ 73| SPI | on-chip | spi | 74+-----------+------------+-------------------------------------+ 75| WATCHDOG | on-chip | watchdog | 76+-----------+------------+-------------------------------------+ 77| ADC | on-chip | adc | 78+-----------+------------+-------------------------------------+ 79| DAC | on-chip | dac | 80+-----------+------------+-------------------------------------+ 81| PWM | on-chip | pwm | 82+-----------+------------+-------------------------------------+ 83| ETHERNET | on-chip | ethernet | 84+-----------+------------+-------------------------------------+ 85| UART | on-chip | serial port-polling; | 86| | | serial port-interrupt | 87+-----------+------------+-------------------------------------+ 88| FLASH | on-chip | soc flash | 89+-----------+------------+-------------------------------------+ 90| USB | on-chip | USB device | 91+-----------+------------+-------------------------------------+ 92| SENSOR | off-chip | fxos8700 polling; | 93| | | fxos8700 trigger | 94+-----------+------------+-------------------------------------+ 95| CAN | on-chip | can | 96+-----------+------------+-------------------------------------+ 97| RTC | on-chip | rtc | 98+-----------+------------+-------------------------------------+ 99| DMA | on-chip | dma | 100+-----------+------------+-------------------------------------+ 101| RNGA | on-chip | entropy; | 102| | | random | 103+-----------+------------+-------------------------------------+ 104| FTFE | on-chip | flash programming | 105+-----------+------------+-------------------------------------+ 106| PIT | on-chip | pit | 107+-----------+------------+-------------------------------------+ 108 109The default configuration can be found in 110:zephyr_file:`boards/nxp/frdm_k64f/frdm_k64f_defconfig` 111 112Other hardware features are not currently supported by the port. 113 114Connections and IOs 115=================== 116 117The K64F SoC has five pairs of pinmux/gpio controllers. 118 119+-------+-----------------+---------------------------+ 120| Name | Function | Usage | 121+=======+=================+===========================+ 122| PTB22 | GPIO | Red LED | 123+-------+-----------------+---------------------------+ 124| PTE26 | GPIO | Green LED | 125+-------+-----------------+---------------------------+ 126| PTB21 | GPIO | Blue LED | 127+-------+-----------------+---------------------------+ 128| PTC6 | GPIO | SW2 / FXOS8700 INT1 | 129+-------+-----------------+---------------------------+ 130| PTC13 | GPIO | FXOS8700 INT2 | 131+-------+-----------------+---------------------------+ 132| PTA4 | GPIO | SW3 | 133+-------+-----------------+---------------------------+ 134| PTB10 | ADC | ADC1 channel 14 | 135+-------+-----------------+---------------------------+ 136| PTB16 | UART0_RX | UART Console | 137+-------+-----------------+---------------------------+ 138| PTB17 | UART0_TX | UART Console | 139+-------+-----------------+---------------------------+ 140| PTB18 | CAN0_TX | CAN TX | 141+-------+-----------------+---------------------------+ 142| PTB19 | CAN0_RX | CAN RX | 143+-------+-----------------+---------------------------+ 144| PTC8 | PWM | PWM_3 channel 4 | 145+-------+-----------------+---------------------------+ 146| PTC9 | PWM | PWM_3 channel 5 | 147+-------+-----------------+---------------------------+ 148| PTC16 | UART3_RX | UART BT HCI | 149+-------+-----------------+---------------------------+ 150| PTC17 | UART3_TX | UART BT HCI | 151+-------+-----------------+---------------------------+ 152| PTD0 | SPI0_PCS0 | SPI | 153+-------+-----------------+---------------------------+ 154| PTD1 | SPI0_SCK | SPI | 155+-------+-----------------+---------------------------+ 156| PTD2 | SPI0_SOUT | SPI | 157+-------+-----------------+---------------------------+ 158| PTD3 | SPI0_SIN | SPI | 159+-------+-----------------+---------------------------+ 160| PTE24 | I2C0_SCL | I2C / FXOS8700 | 161+-------+-----------------+---------------------------+ 162| PTE25 | I2C0_SDA | I2C / FXOS8700 | 163+-------+-----------------+---------------------------+ 164| PTA5 | MII0_RXER | Ethernet | 165+-------+-----------------+---------------------------+ 166| PTA12 | MII0_RXD1 | Ethernet | 167+-------+-----------------+---------------------------+ 168| PTA13 | MII0_RXD0 | Ethernet | 169+-------+-----------------+---------------------------+ 170| PTA14 | MII0_RXDV | Ethernet | 171+-------+-----------------+---------------------------+ 172| PTA15 | MII0_TXEN | Ethernet | 173+-------+-----------------+---------------------------+ 174| PTA16 | MII0_TXD0 | Ethernet | 175+-------+-----------------+---------------------------+ 176| PTA17 | MII0_TXD1 | Ethernet | 177+-------+-----------------+---------------------------+ 178| PTA28 | MII0_TXER | Ethernet | 179+-------+-----------------+---------------------------+ 180| PTB0 | MII0_MDIO | Ethernet | 181+-------+-----------------+---------------------------+ 182| PTB1 | MII0_MDC | Ethernet | 183+-------+-----------------+---------------------------+ 184| PTC16 | ENET0_1588_TMR0 | Ethernet | 185+-------+-----------------+---------------------------+ 186| PTC17 | ENET0_1588_TMR1 | Ethernet | 187+-------+-----------------+---------------------------+ 188| PTC18 | ENET0_1588_TMR2 | Ethernet | 189+-------+-----------------+---------------------------+ 190| PTC19 | ENET0_1588_TMR3 | Ethernet | 191+-------+-----------------+---------------------------+ 192 193.. note:: 194 Do not enable Ethernet and UART BT HCI simultaneously because they conflict 195 on PTC16-17. 196 197System Clock 198============ 199 200The K64F SoC is configured to use the 50 MHz external oscillator on the board 201with the on-chip PLL to generate a 120 MHz system clock. 202 203Serial Port 204=========== 205 206The K64F SoC has six UARTs. One is configured for the console, another for BT 207HCI, and the remaining are not used. 208 209USB 210=== 211 212The K64F SoC has a USB OTG (USBOTG) controller that supports both 213device and host functions through its micro USB connector (K64F USB). 214Only USB device function is supported in Zephyr at the moment. 215 216CAN 217=== 218 219The FRDM-K64F board does not come with an onboard CAN transceiver. In order to 220use the CAN bus, an external CAN bus transceiver must be connected to ``PTB18`` 221(``CAN0_TX``) and ``PTB19`` (``CAN0_RX``). 222 223Programming and Debugging 224************************* 225 226Build and flash applications as usual (see :ref:`build_an_application` and 227:ref:`application_run` for more details). 228 229Configuring a Debug Probe 230========================= 231 232A debug probe is used for both flashing and debugging the board. This board is 233configured by default to use the :ref:`opensda-daplink-onboard-debug-probe`. 234 235Early versions of this board have an outdated version of the OpenSDA bootloader 236and require an update. Please see the `DAPLink Bootloader Update`_ page for 237instructions to update from the CMSIS-DAP bootloader to the DAPLink bootloader. 238 239.. tabs:: 240 241 .. group-tab:: OpenSDA DAPLink Onboard (Recommended) 242 243 Install the :ref:`linkserver-debug-host-tools` and make sure they are in your 244 search path. LinkServer works with the default CMSIS-DAP firmware included in 245 the on-board debugger. 246 247 Linkserver is the default for this board, ``west flash`` and ``west debug`` will 248 call the linkserver runner. 249 250 .. code-block:: console 251 252 west flash 253 254 Alternatively, pyOCD can be used to flash and debug the board by using the 255 ``-r pyocd`` option with West. pyOCD is installed when you complete the 256 :ref:`gs_python_deps` step in the Getting Started Guide. The runners supported 257 by NXP are LinkServer and JLink. pyOCD is another potential option, but NXP 258 does not test or support the pyOCD runner. 259 260 261 .. group-tab:: OpenSDA JLink Onboard 262 263 Install the :ref:`jlink-debug-host-tools` and make sure they are in your search 264 path. 265 266 The version of J-Link firmware to program to the board depends on the version 267 of the DAPLink bootloader. Refer to `OpenSDA Serial and Debug Adapter`_ for 268 more details. On this page, change the pull-down menu for "Choose your board to 269 start" to FRDM-K64F, and review the section "To update your board with OpenSDA 270 applications". Note that Segger does provide an OpenSDA J-Link Board-Specific 271 Firmware for this board, however it is not compatible with the DAPLink 272 bootloader. After downloading the appropriate J-Link firmware, follow the 273 instructions in :ref:`opensda-jlink-onboard-debug-probe` to program to the 274 board. 275 276 Add the arguments ``-DBOARD_FLASH_RUNNER=jlink`` and 277 ``-DBOARD_DEBUG_RUNNER=jlink`` when you invoke ``west build`` to override the 278 default runner to J-Link: 279 280 .. zephyr-app-commands:: 281 :zephyr-app: samples/hello_world 282 :board: frdm_k64f 283 :gen-args: -DBOARD_FLASH_RUNNER=jlink -DBOARD_DEBUG_RUNNER=jlink 284 :goals: build 285 286Configuring a Console 287===================== 288 289Regardless of your choice in debug probe, we will use the OpenSDA 290microcontroller as a usb-to-serial adapter for the serial console. 291 292Connect a USB cable from your PC to J26. 293 294Use the following settings with your serial terminal of choice (minicom, putty, 295etc.): 296 297- Speed: 115200 298- Data: 8 bits 299- Parity: None 300- Stop bits: 1 301 302Flashing 303======== 304 305Here is an example for the :zephyr:code-sample:`hello_world` application. 306 307.. zephyr-app-commands:: 308 :zephyr-app: samples/hello_world 309 :board: frdm_k64f 310 :goals: flash 311 312Open a serial terminal, reset the board (press the SW1 button), and you should 313see the following message in the terminal: 314 315.. code-block:: console 316 317 ***** Booting Zephyr OS v1.14.0-rc1 ***** 318 Hello World! frdm_k64f 319 320Debugging 321========= 322 323Here is an example for the :zephyr:code-sample:`hello_world` application. 324 325.. zephyr-app-commands:: 326 :zephyr-app: samples/hello_world 327 :board: frdm_k64f 328 :goals: debug 329 330Open a serial terminal, step through the application in your debugger, and you 331should see the following message in the terminal: 332 333.. code-block:: console 334 335 ***** Booting Zephyr OS v1.14.0-rc1 ***** 336 Hello World! frdm_k64f 337 338Troubleshooting 339=============== 340 341If pyocd raises an uncaught ``DAPAccessIntf.TransferFaultError()`` exception 342when you try to flash or debug, it's possible that the K64F flash may have been 343locked by a corrupt application. You can unlock it with the following sequence 344of pyocd commands: 345 346.. code-block:: console 347 348 $ pyocd cmd 349 0001915:WARNING:target_kinetis:Forcing halt on connect in order to gain control of device 350 Connected to K64F [Halted]: 0240000026334e450028400d5e0e000e4eb1000097969900 351 >>> unlock 352 0016178:WARNING:target_kinetis:K64F secure state: unlocked successfully 353 >>> reinit 354 0034584:WARNING:target_kinetis:Forcing halt on connect in order to gain control of device 355 >>> load build/zephyr/zephyr.bin 356 [====================] 100% 357 >>> reset 358 Resetting target 359 >>> quit 360 361.. _FRDM-K64F Website: 362 https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/freedom-development-boards/mcu-boards/freedom-development-platform-for-kinetis-k64-k63-and-k24-mcus:FRDM-K64F 363 364.. _FRDM-K64F User Guide: 365 https://www.nxp.com/webapp/Download?colCode=FRDMK64FUG 366 367.. _FRDM-K64F Schematics: 368 https://www.nxp.com/webapp/Download?colCode=FRDM-K64F-SCH-E4 369 370.. _K64F Website: 371 https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/kinetis-cortex-m-mcus/k-seriesperformancem4/k6x-ethernet/kinetis-k64-120-mhz-256kb-sram-microcontrollers-mcus-based-on-arm-cortex-m4-core:K64_120 372 373.. _K64F Datasheet: 374 https://www.nxp.com/docs/en/data-sheet/K64P144M120SF5.pdf 375 376.. _K64F Reference Manual: 377 https://www.nxp.com/docs/en/reference-manual/K64P144M120SF5RM.pdf 378 379.. _DAPLink Bootloader Update: 380 https://os.mbed.com/blog/entry/DAPLink-bootloader-update/ 381 382.. _OpenSDA DAPLink FRDM-K64F Firmware: 383 https://www.nxp.com/downloads/en/snippets-boot-code-headers-monitors/k20dx_frdmk64f_if_crc_legacy_0x5000.bin 384 385.. _OpenSDA Serial and Debug Adapter: 386 https://www.nxp.com/design/microcontrollers-developer-resources/ides-for-kinetis-mcus/opensda-serial-and-debug-adapter:OPENSDA#FRDM-K64F 387