Note: This guide is specifically for use with Segger software. For steps to use with the MCUXpresso extension for VSCode please refer to How to Use Segger J-Link Plus with i.MX 8M Process... - NXP Community
This guide aims to be a technical reference to start using the SEGGER J-Link Plus debug probe on the i.MX 8M Family processors. The board used for this guide specifically is the i.MX 8M Nano EVK, but it also applies to all processors of the i.MX 8M Family.
Here we will describe the process using the following structure:
- Hardware requirements
- Software requirements
- How to find, build, and download the i.MX SDK
- Host setup
- Build an example application
- Target setup
- Run an example application
Hardware requirements
Software requirements
How to find, build, and download the i.MX 8M Nano SDK
- Enter Welcome | MCUXpresso SDK Builder (nxp.com)
- Click on "Select Development Board"
- Select EVK-MIMX8MN (MIMX8MN6xxxJZ) from Boards -> i.MX -> EVK-MIMX8MN
- Click on the Build MCUXpresso SDK button
- Click on Download SDK, you'll be redirected to the MCUXpresso SDK Dashboard
- Look for the i.MX 8M Nano SDK and click on Download SDK
- Click on Download SDK archive and documentation, accept the Software Terms and Conditions and the .zip file for the SDK will be downloaded.
Host Setup
- J-Link Software and Documentation Pack for Windows
- Download J-Link Software and Documentation Pack for Windows (https://www.segger.com/products/debug-probes/j-link/models/j-link-plus/)
- Execute .exe file downloaded and then click on "Next"
- Follow the installation wizard with default parameters and click on "Finish".
- MinGW
- Download the MinGW installer from MinGW - Minimalist GNU for Windows - Browse /Installer at SourceForge.net. Follow the installer instructions leaving all options in their default values.
- Click on Continue when the installer finishes.
- A MinGW Installation Manager window will pop up, select mingw32-base and msys-base from basic setup. Click on the Installation menu and select Apply Changes.
- On the next window, click on Apply and wait for the package to finish downloading.
- Add the appropriate item to the Windows operating system path environment variable. It can be found under Control Panel->System and Security->System->Advanced System Settings in the Environment Variables... section. The path is: \bin. Assuming the default installation path, "C:\MinGW". If the path is not set correctly, the toolchain does not work. Note: If you have C:\MinGW\msys\x.x\bin in your PATH variable (as required by KSDK 1.0.0), remove it to ensure that the new GCC build system works correctly.
- CMake
- Download CMake Windows x64 Installer from Download CMake. Scroll down to find the latest release for the installer:
- Run the installer and follow the instructions. Make sure to check the Add CMake to system PATH for all users option during the installation process.
- Restart your PC to apply changes.
- GNU ARM Embedded Toolchain
- Download the GNU ARM Embedded Toolchain installer from Downloads | GNU Arm Embedded Toolchain Downloads – Arm Developer, scroll down to find the latest release for the installer:
- Follow the installer instructions and check the Add to PATH option at the end of the process.
- Add a new system environment variable named ARMGCC_DIR with the GNU ARM embedded Toolchain installation path as its value
ARMGCC_DIR=ARMGCC_DIR=C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10
Build and example application
- Press the Windows Key and search for GCC Command Prompt and run it.
- Change the directory to the example application project directory (inside the armgcc folder), for example:
C:\Users/<user>\Documents\8MNANO\boards\evkmimx8mn\demo_apps\hello_world\armgcc
- Type build_debug.bat on the command line or double click the build_debug.bat file (inside the armgcc folder of the application project) through Windows Explorer
- Wait for the building process to end and make sure no error messages are shown.
Target Setup
- Connect the debug cable (USB-UART) to the board and the other end to your PC.
- Connect the power cable to the second USB-C port and to a wall socket. Don't turn on the board yet.
- Connect the JLink Plus to your PC with the USB cable.
- Connect the JLink Plus to the JTAG of the i.MX 8M Nano EVK board
In this part we will need to identify pin number 1 from the 9 Pin Cortex-M adapter and from the i.MX 8M Nano EVK board. For the first one identify pin 7 identifiable by a "Non-connect pin".
For the i.MX 8M Nano, you can identify easily with a number 1 in one corner of the connectors.
- The whole setup should look similar to this:
Run an example application
- Open a terminal application (TeraTerm, PuTTY, etc.) on your host PC and set it to the serial debug port with the lowest numbered port with the following settings:
Speed: 115200
Data: 8-bit
Parity: none
Stop bits: 1 bit
Flow Control: none
- Start SEGGER J-Link GDB Server.
- On section “Target Device” select MIMX8MN6_M7 and click “OK”.
- You will see the following window.
- Open a new instance of GCC Command Prompt.
- Change to the directory with the example previously compiled. Here is the path to folder that contains the files:
<install_dir>/boards/<boad_name>/<example_type>/<application_name>/armgcc/debug
- Run the command:
arm-none-eabi-gdb.exe <application_name>.elf.
Example:
- At this point you are in the GDB Command Prompt, run the following commands:
target remote localhost:2331
monitor reset
monitor halt
load
monitor go
- The application will be now running and you can see the “hello world” on your terminal (PuTTY,Tera Term, etc.).