Part 1
요약·해설
K22F의 peripheral과 pin 연결, 72 MHz clock·USB device 제약을 정리하고, DAPLink 또는 J-Link firmware로 OpenSDA를 구성해 hello_world를 flash·debug하는 전 과정을 설명합니다.
MK22FN512VLH12 · 120 MHz
512 KB Flash · 128 KB RAM
OpenSDAv2 · DAPLink · J-Link
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
6B26D7CB1A4B7419C56CAC88D12DA8C2BFEEAE4C261A5883DF0106C3CFD4BCA6
.. _frdm_k22f:
NXP FRDM-K22F
##############
Overview
********
The Freedom-K22F is an ultra-low-cost development platform for Kinetis K22
MCUs.
- Form-factor compatible with the Arduino R3 pin layout
- Peripherals enable rapid prototyping, including a 6-axis digital
accelerometer and magnetometer to create full eCompass capabilities, a
tri-colored LED and 2 user push-buttons for direct interaction, a optional
microSD card slot, and headers for use with Bluetooth* and 2.4 GHz radio
add-on modules
- OpenSDAv2, the NXP open source hardware embedded serial and debug adapter
running an open source bootloader, offers options for serial communication,
flash programming, and run-control debugging
.. image:: ../../../../../../../boards/nxp/frdm_k22f/doc/frdm_k22f.jpg
:align: center
:alt: FRDM-K22F
Hardware
********
- MK22FN512VLH12 (120 MHz, 512 KB flash memory, 128 KB RAM, low-power,
crystal-less USB, and 64 pin Low profile Quad Flat Package (LQFP))
- Dual role USB interface with micro-B USB connector
- RGB LED
- FXOS8700CQ accelerometer and magnetometer
- Two user push buttons
- Flexible power supply option - OpenSDAv2 USB, Kinetis K22 USB, and external source
- Easy access to MCU input/output through Arduino* R3 compatible I/O connectors
- Programmable OpenSDAv2 debug circuit supporting the CMSIS-DAP Interface
software that provides:
- Mass storage device (MSD) flash programming interface
- CMSIS-DAP debug interface over a driver-less USB HID connection providing
run-control debugging and compatibility with IDE tools
- Virtual serial port interface
- Open source CMSIS-DAP software project
- Optional SDHC
For more information about the K22F SoC and FRDM-K22F board:
- `K22F Website`_
- `K22F Datasheet`_
- `K22F Reference Manual`_
- `FRDM-K22F Website`_
- `FRDM-K22F User Guide`_
- `FRDM-K22F Schematics`_
Supported Features
==================
The frdm_k22f board configuration supports the hardware features listed
below. For additional features not yet supported, please also refer to the
:ref:`frdm_k64f`, which is the superset board in NXP's Kinetis K series.
NXP prioritizes enabling the superset board with NXP's Full Platform Support for
Zephyr. Therefore, the frdm_k64f board may have additional features
already supported, which can also be re-used on this frdm_k22f board:
+-----------+------------+-------------------------------------+
| Interface | Controller | Driver/Component |
+===========+============+=====================================+
| NVIC | on-chip | nested vector interrupt controller |
+-----------+------------+-------------------------------------+
| SYSTICK | on-chip | systick |
+-----------+------------+-------------------------------------+
| PINMUX | on-chip | pinmux |
+-----------+------------+-------------------------------------+
| GPIO | on-chip | gpio |
+-----------+------------+-------------------------------------+
| I2C | on-chip | i2c |
+-----------+------------+-------------------------------------+
| SPI | on-chip | spi |
+-----------+------------+-------------------------------------+
| WATCHDOG | on-chip | watchdog |
+-----------+------------+-------------------------------------+
| ADC | on-chip | adc |
+-----------+------------+-------------------------------------+
| PWM | on-chip | pwm |
+-----------+------------+-------------------------------------+
| UART | on-chip | serial port-polling; |
| | | serial port-interrupt |
+-----------+------------+-------------------------------------+
| FLASH | on-chip | soc flash |
+-----------+------------+-------------------------------------+
| USB | on-chip | USB device |
+-----------+------------+-------------------------------------+
| SENSOR | off-chip | fxos8700 polling; |
| | | fxos8700 trigger |
+-----------+------------+-------------------------------------+
| RNGA | on-chip | entropy; |
| | | random |
+-----------+------------+-------------------------------------+
| FTFE | on-chip | flash programming |
+-----------+------------+-------------------------------------+
The default configuration can be found in the defconfig file:
:zephyr_file:`boards/nxp/frdm_k22f/frdm_k22f_defconfig`
Other hardware features are not currently supported by the port.
Connections and IOs
===================
The K22F SoC has five pairs of pinmux/gpio controllers.
+-------+-----------------+---------------------------+
| Name | Function | Usage |
+=======+=================+===========================+
| PTA1 | GPIO | Red LED |
+-------+-----------------+---------------------------+
| PTA2 | GPIO | Green LED |
+-------+-----------------+---------------------------+
| PTD5 | GPIO | Blue LED |
+-------+-----------------+---------------------------+
| PTC1 | GPIO | SW2 |
+-------+-----------------+---------------------------+
| PTD0 | GPIO | FXOS8700 INT1 |
+-------+-----------------+---------------------------+
| PTD1 | GPIO | FXOS8700 INT2 |
+-------+-----------------+---------------------------+
| PTB17 | GPIO | SW3 |
+-------+-----------------+---------------------------+
| PTE1 | UART1_RX | UART Console |
+-------+-----------------+---------------------------+
| PTE0 | UART1_TX | UART Console |
+-------+-----------------+---------------------------+
| PTD2 | UART2_RX | UART BT HCI |
+-------+-----------------+---------------------------+
| PTD3 | UART2_TX | UART BT HCI |
+-------+-----------------+---------------------------+
| PTC4 | SPI0_PCS0 | SPI |
+-------+-----------------+---------------------------+
| PTD1 | SPI0_SCK | SPI |
+-------+-----------------+---------------------------+
| PTD2 | SPI0_SOUT | SPI |
+-------+-----------------+---------------------------+
| PTD3 | SPI0_SIN | SPI |
+-------+-----------------+---------------------------+
| PTB2 | I2C0_SCL | I2C / FXOS8700 |
+-------+-----------------+---------------------------+
| PTB3 | I2C0_SDA | I2C / FXOS8700 |
+-------+-----------------+---------------------------+
System Clock
============
The K22F SoC is configured to use the 8 MHz crystal oscillator on the board
with the on-chip PLL to generate a 72 MHz system clock in its RUN mode. This
clock was selected to allow for the maximum number of peripherals to be used
with the crystal and PLL clocks. Other clock configurations are possible
through NXP SDK currently.
Serial Port
===========
The K22F SoC has three UARTs. One is configured for the console, another for BT
HCI, and the remaining are not used.
USB
===
The K22F SoC has a USB OTG (USBOTG) controller that supports both
device and host functions through its micro USB connector (K22F USB).
Only USB device function is supported in Zephyr at the moment.
Programming and Debugging
*************************
Build and flash applications as usual (see :ref:`build_an_application` and
:ref:`application_run` for more details).
Configuring a Debug Probe
=========================
A debug probe is used for both flashing and debugging the board. This board is
configured by default to use the :ref:`opensda-daplink-onboard-debug-probe`.
Early versions of this board have an outdated version of the OpenSDA bootloader
and require an update. Please see the `DAPLink Bootloader Update`_ page for
instructions to update from the CMSIS-DAP bootloader to the DAPLink bootloader.
Option 1: :ref:`opensda-daplink-onboard-debug-probe` (Recommended)
------------------------------------------------------------------
Install the :ref:`pyocd-debug-host-tools` and make sure they are in your search
path.
Follow the instructions in :ref:`opensda-daplink-onboard-debug-probe` to program
the `OpenSDA DAPLink FRDM-K22F Firmware`_.
Option 2: :ref:`opensda-jlink-onboard-debug-probe`
--------------------------------------------------
Install the :ref:`jlink-debug-host-tools` and make sure they are in your search
path.
Follow the instructions in :ref:`opensda-jlink-onboard-debug-probe` to program
the `Segger J-Link OpenSDA V2.1 Firmware`_. Note that Segger
does provide an OpenSDA J-Link Board-Specific Firmware for this board, however
it is not compatible with the DAPLink bootloader.
Add the arguments ``-DBOARD_FLASH_RUNNER=jlink`` and
``-DBOARD_DEBUG_RUNNER=jlink`` when you invoke ``west build`` to override the
default runner from pyOCD to J-Link:
.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: frdm_k22f
:gen-args: -DBOARD_FLASH_RUNNER=jlink -DBOARD_DEBUG_RUNNER=jlink
:goals: build
Configuring a Console
=====================
Regardless of your choice in debug probe, we will use the OpenSDA
microcontroller as a usb-to-serial adapter for the serial console.
Connect a USB cable from your PC to J26.
Use the following settings with your serial terminal of choice (minicom, putty,
etc.):
- Speed: 115200
- Data: 8 bits
- Parity: None
- Stop bits: 1
Flashing
========
Here is an example for the :ref:`hello_world` application.
.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: frdm_k22f
:goals: flash
Open a serial terminal, reset the board (press the SW1 button), and you should
see the following message in the terminal:
.. code-block:: console
***** Booting Zephyr OS v2.0.0 *****
Hello World! frdm_k22f
Debugging
=========
Here is an example for the :ref:`hello_world` application.
.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: frdm_k22f
:goals: debug
Open a serial terminal, step through the application in your debugger, and you
should see the following message in the terminal:
.. code-block:: console
***** Booting Zephyr OS v2.0.0 *****
Hello World! frdm_k22f
.. _FRDM-K22F Website:
https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/freedom-development-boards/mcu-boards/nxp-freedom-development-platform-for-kinetis-k22-mcus:FRDM-K22F
.. _FRDM-K22F User Guide:
https://www.nxp.com/webapp/Download?colCode=FRDMK22FUG
.. _FRDM-K22F Schematics:
https://www.nxp.com/webapp/Download?colCode=FRDM-K22F-SCH
.. _K22F Website:
https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/kinetis-cortex-m-mcus/k-seriesperformancem4/k2x-usb/kinetis-k22-120-mhz-cost-effective-full-speed-usb-microcontrollers-mcus-based-on-arm-cortex-m4-core:K22_120
.. _K22F Datasheet:
https://www.nxp.com/docs/en/data-sheet/K22P121M120SF7.pdf
.. _K22F Reference Manual:
https://www.nxp.com/docs/en/reference-manual/K22P121M120SF7RM.pdf
.. _OpenSDA DAPLink FRDM-K22F Firmware:
https://www.nxp.com/downloads/en/snippets-boot-code-headers-monitors/k20dx_frdmk22f_if_crc_legacy_0x8000.bin
.. _DAPLink Bootloader Update:
https://os.mbed.com/blog/entry/DAPLink-bootloader-update/
.. _Segger J-Link OpenSDA V2.1 Firmware:
https://www.segger.com/downloads/jlink/OpenSDA_V2_1.bin
Part 3
한국어 전문 번역
개요
Freedom-K22F는 Kinetis K22 MCU를 위한 초저가 development platform입니다.
- Arduino R3 pin layout과 호환되는 form factor
- 빠른 prototype 제작을 위한 peripheral: 완전한 eCompass 기능을 구성하는 6-axis digital accelerometer와 magnetometer, tri-color LED, 직접 조작용 user push button 2개, 선택 사양 microSD card slot, Bluetooth 및 2.4 GHz radio add-on module용 header
- OpenSDAv2: open-source bootloader를 실행하는 NXP open-source hardware embedded serial/debug adapter로, serial communication, flash programming, run-control debugging 선택지를 제공

하드웨어
MK22FN512VLH12: 120 MHz, 512 KB flash memory, 128 KB RAM, low-power, crystal-less USB, 64-pin LQFP- micro-B USB connector를 사용하는 dual-role USB interface
- RGB LED
FXOS8700CQaccelerometer와 magnetometer- user push button 2개
- 유연한 전원 선택: OpenSDAv2 USB, Kinetis K22 USB, external source
- Arduino R3 compatible I/O connector를 통해 MCU I/O에 쉽게 접근
- CMSIS-DAP interface software를 지원하는 programmable OpenSDAv2 debug circuit
OpenSDAv2는 MSD flash programming interface, driver가 필요 없는 USB HID 기반 CMSIS-DAP debug interface, run-control debugging과 IDE 호환성, virtual serial port interface, open-source CMSIS-DAP software project를 제공합니다. SDHC는 선택 사양입니다.
자세한 자료는 아래 K22F 및 FRDM-K22F reference 링크에서 확인할 수 있습니다.
지원 기능
frdm_k22f board configuration이 지원하는 기능은 다음과 같습니다. 아직 지원되지 않은 기능은 NXP Kinetis K series의 superset board인 frdm_k64f도 참고하십시오. NXP는 Zephyr Full Platform Support를 위해 superset board를 우선 활성화하므로, FRDM-K64F에서 이미 지원되는 기능을 FRDM-K22F에 재사용할 수 있습니다.
| 인터페이스 | 컨트롤러 | 드라이버/컴포넌트 |
|---|---|---|
NVIC | on-chip | nested vector interrupt controller |
SYSTICK | on-chip | systick |
PINMUX | on-chip | pinmux |
GPIO | on-chip | gpio |
I2C | on-chip | i2c |
SPI | on-chip | spi |
WATCHDOG | on-chip | watchdog |
ADC | on-chip | adc |
PWM | on-chip | pwm |
UART | on-chip | serial port-polling; serial port-interrupt |
FLASH | on-chip | soc flash |
USB | on-chip | USB device |
SENSOR | off-chip | fxos8700 polling; fxos8700 trigger |
RNGA | on-chip | entropy; random |
FTFE | on-chip | flash programming |
기본 구성은 boards/nxp/frdm_k22f/frdm_k22f_defconfig에 있습니다. 그 밖의 하드웨어 기능은 현재 이 port에서 지원되지 않습니다.
연결과 입출력
K22F SoC에는 pinmux/GPIO controller 쌍이 5개 있습니다.
| 이름 | 기능 | 용도 |
|---|---|---|
PTA1 | GPIO | Red LED |
PTA2 | GPIO | Green LED |
PTD5 | GPIO | Blue LED |
PTC1 | GPIO | SW2 |
PTD0 | GPIO | FXOS8700 INT1 |
PTD1 | GPIO | FXOS8700 INT2 |
PTB17 | GPIO | SW3 |
PTE1 | UART1_RX | UART Console |
PTE0 | UART1_TX | UART Console |
PTD2 | UART2_RX | UART BT HCI |
PTD3 | UART2_TX | UART BT HCI |
PTC4 | SPI0_PCS0 | SPI |
PTD1 | SPI0_SCK | SPI |
PTD2 | SPI0_SOUT | SPI |
PTD3 | SPI0_SIN | SPI |
PTB2 | I2C0_SCL | I2C / FXOS8700 |
PTB3 | I2C0_SDA | I2C / FXOS8700 |
System clock
K22F SoC는 보드의 8 MHz crystal oscillator와 on-chip PLL을 사용해 RUN mode에서 72 MHz system clock을 생성하도록 구성됩니다. crystal 및 PLL clock으로 가능한 한 많은 peripheral을 사용할 수 있도록 이 clock을 선택했습니다. 현재 NXP SDK를 통해 다른 clock configuration도 사용할 수 있습니다.
Serial port
K22F SoC에는 UART가 3개 있습니다. 하나는 console, 하나는 BT HCI로 구성되고 나머지는 사용하지 않습니다.
USB
K22F SoC의 USB OTG(USBOTG) controller는 K22F USB micro USB connector를 통해 device와 host 기능을 모두 지원합니다. 현재 Zephyr에서는 USB device 기능만 지원됩니다.
프로그래밍과 디버깅
일반적인 Zephyr application과 같은 방식으로 build하고 flash합니다.
Debug probe 구성
debug probe는 보드의 flash와 debug에 모두 사용됩니다. 이 보드는 기본적으로 OpenSDA DAPLink on-board debug probe를 사용하도록 구성되어 있습니다.
선택 1: OpenSDA DAPLink on-board probe(권장)
pyOCD debug host tool을 설치하고 search path에 포함했는지 확인합니다. OpenSDA DAPLink on-board probe 지침에 따라 OpenSDA DAPLink FRDM-K22F Firmware를 program하십시오.
선택 2: OpenSDA J-Link on-board probe
J-Link debug host tool을 설치하고 search path에 포함했는지 확인합니다. OpenSDA J-Link on-board probe 지침에 따라 SEGGER J-Link OpenSDA V2.1 Firmware를 program하십시오. SEGGER가 이 보드용 OpenSDA J-Link board-specific firmware도 제공하지만 DAPLink bootloader와 호환되지 않습니다.
west build를 호출할 때 -DBOARD_FLASH_RUNNER=jlink와 -DBOARD_DEBUG_RUNNER=jlink를 추가하면 기본 runner를 pyOCD에서 J-Link로 바꿀 수 있습니다.
west build -b frdm_k22f samples/hello_world -- \
-DBOARD_FLASH_RUNNER=jlink -DBOARD_DEBUG_RUNNER=jlink
Console 구성
선택한 debug probe와 관계없이 OpenSDA microcontroller를 serial console용 USB-to-serial adapter로 사용합니다. PC에서 J26으로 USB cable을 연결하십시오.
- Speed:
115200 - Data:
8 bits - Parity:
None - Stop bits:
1
Flash
hello_world application을 build하고 flash합니다.
west build -b frdm_k22f samples/hello_world
west flash
serial terminal을 열고 SW1 button을 눌러 보드를 reset하면 다음 메시지가 표시됩니다.
***** Booting Zephyr OS v2.0.0 *****
Hello World! frdm_k22f
Debug
hello_world application을 build하고 debug합니다.
west build -b frdm_k22f samples/hello_world
west debug
serial terminal을 열고 debugger에서 application을 한 단계씩 실행하면 다음 메시지가 표시됩니다.
***** Booting Zephyr OS v2.0.0 *****
Hello World! frdm_k22f
참고 자료
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.