4.3. Freedom K64F Build (CMake - Advanced)

For the advanced users and users who are aware of CMake / want to use true potential of CMake, the plug and trust MW supports build system where developers can run exactly the same example on PC/Windows/Linux and embedded targets.

e.g. Using this, developer can develop/extend example on a Windows Machine with visual studio which supports multiple break points, watch points, etc. and then recompile same example for K64F and test it there.

4.3.1. Prerequisite

  • MCUXpresso installed and version correctly updated in scripts/env_setup.bat Refer to Setting up MCUXPresso IDE for details on installation

  • CMake is installed .

  • Python is installed and projects are created using scripts/create_cmake_projects.py

Refer https://www.nxp.com/docs/en/application-note/AN12396-Quick_start_guide_kinetis_k64.pdf for more details on Prerequisite installation steps.

4.3.2. Importing the Project

  • Import a project using the option provided by MCUXPresso. Do not use the “Quickstart Panel” to import project.

../_images/cm_010_import_general_projects.png
  • Import existing projects into Workspace

../_images/cm_015_import_general_projects.png
  • First import the project generated by scripts/create_cmake_projects.py. We are going to use that workarea to build the examples.

    Never select “Copy projects into workspace” for this CMake configuration.

../_images/cm_020_import_cmake_generated_project.png
  • Then import the project from “projects” directory. Import only the project for your board. In this case we import cmake_project_XXXX, where XXXX is the board name. This project is used to debug and download to the target. It’s a manually maintained project.

    Never select “Copy projects into workspace” for this CMake configuration.

../_images/cm_030_import_manual_cmake_project.png
  • You may have to run cmake’s edit_cache to change the configuration of your example. e.g. choice of RTOS, Applet, Board, optimization level, etc.

../_images/cm_040_change_cmake_configuration.png
  • You would mostly have to change the target that you want to build and download. Modify cmake_project_XXXX/Debug/Makefile.

    As you can see, the default selection is se05x_Minimal.

    You can run the help target of this project a shown in next image to see which projects are supported.

../_images/cm_050_change_target_makefile.png
  • cmake_project_XXXX project’s settings also supports helpful target to edit_cache or list supported projects by that configuration.

../_images/cm_090_short_cut_edit_cache.png

4.3.3. Running / Debugging example

  • Click on Build to compile and generate the executables

../_images/mcux_build.png
  • Click on debug to program the binary into the device

../_images/mcux_debug.png
  • Select J-Link OpenSDA and click on OK. For more details on OpenSDA, refer to

https://www.nxp.com/support/developer-resources/run-time-software/kinetis-developer-resources/ides-for-kinetis-mcus/opensda-serial-and-debug-adapter:OPENSDA

../_images/mcux_selectjlinkopensda.png
  • Click on the Resume button to start program execution

../_images/mcux_play.jpg

4.3.4. Logging on console

For UART, a serial terminal application(for e.g Tera Term) on PC for VCOM serial device needs to be configured as follows ( in Tera Term goto Setup –> Serial port)

  • 115200 baud rate

  • 8 data bits

  • No parity

  • One stop bit

  • No flow control

Once the program execution begins, logs are printed on the terminal(e.g. Tera Term) indicating the status of execution and test results. The ATR and the various module versions are printed followed by a SELECT-DONE after which the respective test logs are printed.