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