/
Running Zephyr on NXP i.MX RT

Running Zephyr on NXP i.MX RT

This application note has been explicitly tested on the NXP MIMXRT1060-EVKB board, however, it should apply to the other NXP EVK boards in the i.MX RT family as well, perhaps, with some minor changes to the software.

Connecting MIMXRT1060-EVKB Board to the NAVQ+ Kit

The following hardware setup is required for installing and running a Zephyr sample on the NXP MIMXRT1060-EVKB board:

  1. Remove jumpers J9 and J10, to disconnect the SWD signals from onboard debug circuit.  These jumpers are installed by default.

  2. Use default power selection on J40 with pins 5-6 shorted (power supply via J1).

  3. Connect the external J-Link probe to J2, 20-pin dual-row 0.1" header.

  4. Connect the Ethernet cable to the RJ45 connector (J43) and to the local network.

  5. Connect a USB hub to the NAVQ+ kit.

  6. Connect a USB cable from the USB hub to J1. The USB connector J1 is used to power the board, and provides a UART/USB bridge through the onboard debug circuit (serial console). It is important to power up the board before powering up J-Link.

  7. Connect a USB cable from the USB hub to the J-Link probe. It is important to do so after the board has been powered up, otherwise, the J-Link probe won't be able to detect the MCU.

Connecting MIMXRT1060-EVKB Board to a Linux PC

The MIMXRT1060-EVKB Board can be connected to any Linux PC the same way as it is connected to the NAVQ+ kit. Note that the USB hub is not necessary if the Linux PC has more than one USB port.

Building Zephyr for MIMXRT1060-EVKB Board

Zephyr samples can be built as described in the Zephyr Project documentation:

https://docs.zephyrproject.org/latest/develop/getting_started/index.html

For example, use the following command to build the hello_world sample for the MIMXRT1060-EVKB board:

cd zephyr west build -p always -b mimxrt1060_evkb samples/hello_world

Installing Zephyr on MIMXRT1060-EVKB Board from the NAVQ+ Kit

Use west to install Zephyr from the NAVQ+ Kit:

user@imx8mpnavq:~/work/zephyrproject/zephyr$ west flash -- west flash: rebuilding ninja: no work to do. -- west flash: using runner jlink -- runners.jlink: JLink version: 7.92g -- runners.jlink: Flashing file: /mnt/sdcard/work/zephyrproject/zephyr/build/zephyr/zephyr.bin

Installing Zephyr on MIMXRT1060-EVKB Board from a Linux PC

If the J-Link probe is directly connected to the build machine then the “west flash" command can be used to flash the sample as described in the Zephyr Project documentation:

https://docs.zephyrproject.org/latest/develop/getting_started/index.html

However, it is not always convenient to use the same PC for building and flashing. It is actually enough to install the J-Link software

https://www.segger.com/downloads/jlink/

on the host PC to be able to Flash the boards over the J-Link probe. After installing the J-Link software, verify that the J-Link probe is detected by the SEGGER J-Link Commander and identifies the MCU successfully:

$ JLinkExe -nogui 1 -if swd -speed auto -device MIMXRT1062xxx6A SEGGER J-Link Commander V7.92c (Compiled Aug 30 2023 14:58:04) DLL version V7.92c, compiled Aug 30 2023 14:57:42 Connecting to J-Link via USB...O.K. ... J-Link>connect ... Cortex-M7 identified. J-Link>

Create the J-Link Commander script for flashing Zephyr onto the MIMXRT1060-EVKB board:

$ cat runner.jlink ExitOnError 1 r loadfile "zephyr.bin" 0x60000000 g writeDP 1 0 readDP 1 q $

Put the build/zephyr/zephyr.bin file into the current directory and run the following command:

$ JLinkExe -nogui 1 -if swd -speed auto \ > -device "MIMXRT1062xxx6A?BankAddr=0x60000000&Loader=QSPI" \ > -CommanderScript runner.jlink ... Downloading file [zephyr.bin]... Comparing flash [100%] Done. Erasing flash [100%] Done. Programming flash [100%] Done. Verifying flash [100%] Done. J-Link: Flash download: Bank 0 @ 0x60000000: 1 range affected (65536 bytes) J-Link: Flash download: Total: 1.118s (Prepare: 0.325s, Compare: 0.148s, Erase: 0.107s, Program: 0.249s, Verify: 0.144s, Restore: 0.142s) J-Link: Flash download: Program speed: 257 KB/s O.K. ... Script processing completed. $

As soon as a Zephyr image is flashed, it can be started by resetting the board using the reset button or the “reset/go" command sequence of the J-Link Commander:

$ JLinkExe -nogui 1 -if swd -speed auto -device MIMXRT1062xxx6A ... J-Link>connect ... J-Link>reset ... J-Link>go J-Link>

Now you can connect to the target serial console using a terminal program on your Linux PC, for example:

$ picocom -b 115200 /dev/ttyACM0 ... Type [C-a] [C-h] to see available commands Terminal ready

Depending on the installed Zephyr application, you will see some output on the serial console after reset. The Zephyr banner is usually printed:

*** Booting Zephyr OS build emcraft-ef041c6-2-gdaa341a973af ***

Controlling MIMXRT1060-EVKB Board LEDs from the NAVQ+ Kit

Emcraft provides the simple Zephyr demo (emcraft/app/led_network_control) that allows to control the board LEDs from the NAVQ+ kit over the local network.

  1. Before building the demo, choose a static IP address for your target board and configure the demo appropriately, for example:

$ grep CONFIG_NET_CONFIG_MY_IPV4_ADDR emcraft/app/led_network_control/prj.conf CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.11" $
  1. Build the led_network_control sample for the MIMXRT1060-EVKB board:

cd zephyr west build -p always -b mimxrt1060_evkb emcraft/app/led_network_control
  1. Install the demo on the target board as described above. If you connect to the target serial console, you will see the following output after reset:

*** Booting Zephyr OS build emcraft-ef041c6-2-gdaa341a973af *** led-1: ready Single-threaded TCP server waits for a connection on address 192.168.1.11 port 4242...
  1. From the NAVQ+ console, connect to the target board using telnet:

user@imx8mpnavq:~$ telnet 192.168.1.11 4242 Trying 192.168.1.11... Connected to 192.168.1.11. Escape character is '^]'. list: print supported LEDs <LED> on: turn on the specified LED <LED> off: turn off the specified LED
  1. Type “list" to see the available LEDs on the target board:

list led-1
  1. Turn led-1 on and off:

led-1 on OK led-1 off OK