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