1.. _target-mimxrt595-evk: 2 3------------- 4mimxrt595-evk 5------------- 6The NXP MIMXRT595-EVK_ evaluation board is a demonstration target for on-device 7Pigweed development 8 9.. _MIMXRT595-EVK: https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/i-mx-rt595-evaluation-kit:MIMXRT595-EVK 10 11Configuring 12=========== 13Step 1: Download SDK 14-------------------- 15To configure this Pigweed target you will first need to download an NXP 16`MCUXpresso SDK`_ for your device and unpack it within your project source tree. 17 18.. _MCUXpresso SDK: https://mcuxpresso.nxp.com/en/welcome 19 20Step 2: Create SDK source set 21----------------------------- 22You'll next need to create a source set based on the downloaded SDK, and set 23the ``pw_third_party_mcuxpresso_SDK`` build arg to the name of the source set 24you create. See :ref:`module-pw_build_mcuxpresso` for more details. 25 26Alternatively to get started you can start with the basic project template by 27setting the ``pw_target_mimxrt595_evk_MANIFEST`` build arg to the location of 28the manifest file within the unpacked SDK, and then setting the 29``pw_third_party_mcuxpresso_SDK`` to the ``sample_sdk`` source set within the 30Pigweed target directory. 31 32.. code-block:: sh 33 34 $ gn args out 35 # Modify and save the args file to use the sample SDK. 36 pw_target_mimxrt595_evk_MANIFEST = "//third_party/mcuxpresso/sdk/EVK-MIMXRT595_manifest_v3_13.xml" 37 pw_third_party_mcuxpresso_SDK = "//targets/mimxrt595_evk:sample_sdk" 38 39Building 40======== 41Once configured, to build for this Pigweed target, simply build the top-level 42"mimxrt595" Ninja target. 43 44.. code-block:: sh 45 46 $ ninja -C out mimxrt595 47 48Running and Debugging 49===================== 50First Time Setup 51---------------- 52The MIMXRT595-EVK comes with an integrated Link2 debug probe that can operate in 53either CMSIS-DAP or SEGGER J-Link mode. CMSIS-DAP is how the board will likely 54come by default, but J-Link is the mode that is currently known to work, so 55you'll need to flash the Link2 with the correct firmware. 56 571. Download and install the LPCScrypt_ utility from the NXP website. 58 592. Place a jumper over **JP1** (not **J1**). If you're having trouble locating 60 this, it's in the top-right of the board in a block of four jumpers closest 61 to the USB ports. 62 633. Connect a USB cable into the top-right USB port (**J40**) and your computer. 64 654. Run ``scripts/boot_lpcscrypt`` from the LPCScrypt installation. 66 675. Run ``scripts/program_JLINK`` from the LPCScrypt installation, press the 68 *SPACE* key to update the firmware. 69 706. Unplug the USB cable and remove the **JP1** jumper. 71 72Now is also a good time to download and install the J-Link_ package from the 73SEGGER website. 74 75.. _LPCScrypt: https://www.nxp.com/design/microcontrollers-developer-resources/lpcscrypt-v2-1-2:LPCSCRYPT 76.. _J-Link: https://www.segger.com/downloads/jlink/ 77 78General Setup 79------------- 80Each time you prepare the MIMXRT595-EVK for use, you'll need to do a few steps. 81You don't need to repeat these if you leave everything setup and don't 82disconnect or reboot. 83 841. Ensure the **SW7** DIP switches are set to Off-Off-On (boot from QSPI Flash). 85 862. Connect a USB cable into the top-right USB port (**J40**) and your computer. 87 883. Start the J-Link GDB Server and leave this running: 89 90 .. code-block:: sh 91 92 JLinkGDBServer -select USB -device MIMXRT595S -endian little -if SWD -speed 4000 -noir 93 94On Linux, you may need to install the `libncurses5` library to use the tools: 95 96.. code-block:: sh 97 98 sudo apt install libncurses5 99 100Running and Debugging 101--------------------- 102Use ``arm-none-eabi-gdb`` to load an executable into the target, debug, and run 103it. 104 105.. code-block:: 106 :emphasize-lines: 1,6,10,12,20 107 108 (gdb) target remote :2331 109 Remote debugging using :2331 110 warning: No executable has been specified and target does not support 111 determining executable automatically. Try using the "file" command. 112 0x08000000 in ?? () 113 (gdb) file out/mimxrt595_evk_debug/obj/pw_status/test/status_test.elf 114 A program is being debugged already. 115 Are you sure you want to change the file? (y or n) y 116 Reading symbols from out/mimxrt595_evk_debug/obj/pw_status/test/status_test.elf... 117 (gdb) monitor reset 118 Resetting target 119 (gdb) load 120 Loading section .flash_config, size 0x200 lma 0x8000400 121 Loading section .vector_table, size 0x168 lma 0x8001000 122 Loading section .code, size 0xb34c lma 0x8001180 123 Loading section .ARM, size 0x8 lma 0x800c4d0 124 Loading section .static_init_ram, size 0x3c8 lma 0x800c4d8 125 Start address 0x080048d0, load size 47748 126 Transfer rate: 15542 KB/sec, 6821 bytes/write. 127 (gdb) monitor reset 128 Resetting target 129 130You can now set any breakpoints you wish, and ``continue`` to run the 131executable. 132 133To reset the target use ``monitor reset``. 134 135To load an updated version of the same file, after resetting the target, 136use ``load`` and a second ``monitor reset`` as shown above. 137 138To debug a new file, use ``file`` before ``load``. 139 140Debug console is available on the USB serial port, e.g. ``/dev/ttyACM0`` 141(Linux) or ``/dev/tty.usbmodem*`` (Mac). 142