1.. _mimx8mm_phyboard_polis:
2
3PhyBOARD Polis (NXP i.MX8M Mini)
4################################
5
6Overview
7********
8
9The phyBOARD-Polis, either a development platform for the
10phyCORE-i.MX 8M Mini/Nano, or a powerful, industry-compatible single-board
11computer for immediate implementation of your product idea. As a development
12platform, the phyBOARD-Polis serves as reference design for your
13customer-specific application and enables parallel development of the software
14and carrier board for the phyCORE-i.MX 8M Mini/Nano.
15
16
17As a powerful, industrial single-board computer (SBC), the phyBOARD-Polis is
18equipped with a variety of standard interfaces which are available on standard
19or socket/pin header connectors, while interesting extensions of the
20phyCORE-i.MX 8M Mini/Nano features such as CAN FD, WLAN and an integrated
21TPM chip further extend the range of applications that can be developed with
22the phyCORE-i.MX 8M Mini/Nano.
23
24- Board features:
25
26  - RAM: 512MB - 4GB (LPDDR4)
27  - Storage:
28
29    - 4GB - 128GB eMMC
30    - 8MB - 128MB SPI NOR Flash
31    - microSD Interfacce
32    - 4kB EEPROM
33  - Wireless:
34
35    - WiFi: 802.11 b/g/n (ac) 2,4 GHz / 5 GHz
36    - BLE 4.2
37  - USB:
38
39    - 1x USB2.0 OTG
40    - 1x USB2.0
41  - Ethernet: 1x 10/100/1000BASE-T
42  - Interfaces:
43    - 1x RS232 / RS485
44    - 2x UART
45    - 3x I²C
46    - 2x SPI
47    - Up to 4x PWM
48    - 4x SAI
49    - 1x MIPI CSI-2
50    - 1x MIPI DSI-2
51    - 2x MMC/SD/SDIO
52    - 1x PCIe (mini PCIE)
53  - LEDs:
54
55    - 1x Status LED (3 Color LED)
56    - 1x Debug UART LED
57  - Debug
58
59    - JTAG 20-pin connector
60    - MicroUSB for UART debug, two COM ports for A53 and M4
61
62.. image:: img/phyBOARD-Polis.jpg
63   :align: center
64   :alt: PhyBOARD Polis
65   :width: 500
66
67More information about the board can be found at the
68`PHYTEC website`_.
69
70Supported Features
71==================
72
73The Zephyr mimx8mm_phyboard_polis board configuration supports the following
74hardware features:
75
76+-----------+------------+-------------------------------------+
77| Interface | Controller | Driver/Component                    |
78+===========+============+=====================================+
79| NVIC      | on-chip    | nested vector interrupt controller  |
80+-----------+------------+-------------------------------------+
81| SYSTICK   | on-chip    | systick                             |
82+-----------+------------+-------------------------------------+
83| CLOCK     | on-chip    | clock_control                       |
84+-----------+------------+-------------------------------------+
85| PINMUX    | on-chip    | pinmux                              |
86+-----------+------------+-------------------------------------+
87| UART      | on-chip    | serial port-polling;                |
88|           |            | serial port-interrupt               |
89+-----------+------------+-------------------------------------+
90| GPIO      | on-chip    | GPIO output                         |
91|           |            | GPIO input                          |
92+-----------+------------+-------------------------------------+
93
94The default configuration can be found in the defconfig file:
95:zephyr_file:`boards/arm/mimx8mm_phyboard_polis/mimx8mm_phyboard_polis_defconfig`.
96
97It is recommended to disable peripherals used by the M4 core on the Linux host.
98
99Other hardware features are not currently supported with Zephyr on the
100M4-Core.
101
102Connections and IOs
103===================
104
105The following components are tested and working correctly.
106
107UART:
108-----
109
110Zephyr is configured to use UART4 on the PhyBoard Polis by default to minimize
111problems with the A53-Core because UART4 is only accessible from the M4-Core.
112
113+---------------+-----------------+-----------------------------------+
114| Board Name    | SoM Name        | Usage                             |
115+===============+=================+===================================+
116| RS232/485     | UART1           | RS232 / RS485 with flow-control   |
117+---------------+-----------------+-----------------------------------+
118| To WiFi Module| UART2           | UART to WiFi/BLE Module           |
119+---------------+-----------------+-----------------------------------+
120| Debug USB(A53)| UART3           | UART Debug Console via USB        |
121+---------------+-----------------+-----------------------------------+
122| Debug USB(M4) | UART4           | UART Debug Console via USB        |
123+---------------+-----------------+-----------------------------------+
124
125.. note::
126  Please note, that the to UART2 connected Wifi/BLE Module isn't working with
127  Zephyr yet.
128
129.. warning::
130  On Boards with the version number 1532.1 UART4 isn't connected to the Debug
131  USB. UART4 connects to pin 10(RX) and 12(TX) on the X8 pinheader.
132
133
134LEDs:
135-----
136
137Zephyr has the 3-color status LED configured. The led0 alias (the standard
138Zephyr led) is configured to be the blue led. The LED can also light up in red
139and green.
140
141GPIO:
142-----
143
144The pinmuxing for the GPIOs is the standard pinmuxing of the mimx8mm devicetree
145created by NXP. You can find it here:
146
147:zephyr_file:`dts/arm/nxp/nxp_imx8m_m4.dtsi`.
148
149The Pinout of the PhyBOARD Polis can be found here:
150
151`PHYTEC website`_
152
153System Clock
154============
155
156The M4 Core is configured to run at a 400 MHz clock speed.
157
158
159Programming and Debugging
160*************************
161
162The i.MX8MM does not have a separate flash for the M4-Core. Because of this
163the A53-Core has to load the program for the M4-Core to the right memory
164address, set the PC and start the processor.
165This can be done with U-Boot or Phytec's Linux BSP via remoteproc.
166
167Because remoteproc in Phytec's BSP only writes to the TCM memory area,
168everything was tested in this memory area.
169
170You can read more about remoteproc in Phytec's BSP here: `Remoteproc BSP`_
171
172These are the memory mapping for A53 and M4:
173
174+------------+-------------------------+------------------------+-----------------------+----------------------+
175| Region     | Cortex-A53              | Cortex-M4 (System Bus) | Cortex-M4 (Code Bus)  | Size                 |
176+============+=========================+========================+=======================+======================+
177| OCRAM      | 0x00900000-0x0093FFFF   | 0x20200000-0x2023FFFF  | 0x00900000-0x0093FFFF | 256KB                |
178+------------+-------------------------+------------------------+-----------------------+----------------------+
179| TCMU       | 0x00800000-0x0081FFFF   | 0x20000000-0x2001FFFF  |                       | 128KB                |
180+------------+-------------------------+------------------------+-----------------------+----------------------+
181| TCML       | 0x007E0000-0x007FFFFF   |                        | 0x1FFE0000-0x1FFFFFFF | 128KB                |
182+------------+-------------------------+------------------------+-----------------------+----------------------+
183| OCRAM_S    | 0x00180000-0x00187FFF   | 0x20180000-0x20187FFF  | 0x00180000-0x00187FFF | 32KB                 |
184+------------+-------------------------+------------------------+-----------------------+----------------------+
185
186For more information about memory mapping see the
187`i.MX 8M Applications Processor Reference Manual`_  (section 2.1.2 and 2.1.3)
188
189At compilation time you have to choose which RAM will be used. This
190configuration is done in the file ``boards/arm/mimx8mm_evk/mimx8mm_evk.dts``
191with "zephyr,flash" (when CONFIG_XIP=y) and "zephyr,sram" properties.
192The available configurations are:
193
194If you don't want to use the TCM memory area, you can either overwrite the
195boards devicetree in your program or edit the board devicetree located here:
196
197:zephyr_file:`boards/arm/mimx8mm_phyboard_polis/mimx8mm_phyboard_polis.dts`
198
199You also have to set XIP=n or edit the boards defconfig file, if you don't want
200the TCM memory area to be used. You can find the defconf file here:
201
202:zephyr_file:`boards/arm/mimx8mm_phyboard_polis/mimx8mm_phyboard_polis_defconfig`.
203
204The following configurations are possible for the flash and sram chosen nodes
205to change the used memory area:
206
207.. code-block:: none
208
209   "zephyr,flash"
210   - &tcml_code
211   - &ocram_code
212   - &ocram_s_code
213
214   "zephyr,sram"
215   - &tcmu_sys
216   - &ocram_sys
217   - &ocram_s_sys
218
219
220Starting the M4-Core via U-Boot
221===============================
222
223Load the compiled zephyr.bin to memory address 0x4800000.
224This should output something like this:
225
226.. code-block:: console
227
228   u-boot=> tftp 0x48000000 192.168.3.10:zyphr.bin
229   Using ethernet@30be0000 device
230   TFTP from server 192.168.3.10; our IP address is 192.168.3.11
231   Filename 'zepyhr.bin'.
232   Load address: 0x48000000
233   Loading: ##
234            2 KiB/s
235   done
236   Bytes transferred = 27240 (6a68 hex)
237
238Because it's not possible to load directly to the TCM memory area you have to
239copy the binaries. The last argument given is the size of the file in bytes,
240you can copy it from the output of the last command.
241
242.. code-block:: console
243
244   u-boot=> cp.b 0x48000000 0x7e0000 27240
245
246And finaly starting the M4-Core at the right memory address:
247
248.. code-block:: console
249
250   u-boot=> bootaux 0x7e0000
251   ## Starting auxiliary core stack = 0x20003A58, pc = 0x1FFE1905...
252
253
254Starting the M4-Core via remoteproc
255===================================
256
257Copy the zepyhr.elf to ``/lib/firmware`` on the target. Maybe a Zephyr sample
258will be included in a future BSP release.
259
260.. note::
261   In order to use remoteproc you have to add ``imx8mm-phycore-rpmsg.dtbo`` at
262   the end of the line in the ``/boot/bootenv.txt``, then reboot the target.
263
264.. warning::
265   Remoteproc only reads firmware files from the ``/lib/firmware`` directory!
266   If you try to load a binary from another location unexpected errors will
267   occur!
268
269To load and start a firmware use this commands:
270
271.. code-block:: console
272
273   target$ echo /lib/firmware/zepyhr.elf > /sys/class/remoteproc/remoteproc0/firmware
274   target$ echo start > /sys/class/remoteproc/remoteproc0/state
275   [   90.700611] remoteproc remoteproc0: powering up imx-rproc
276   [   90.706114] remoteproc remoteproc0: Direct firmware load for /lib/firmware/zepyhr.elf failed w2
277   [   90.716571] remoteproc remoteproc0: Falling back to sysfs fallback for: /lib/firmware/zepyhr.elf
278   [   90.739280] remoteproc remoteproc0: Booting fw image /lib/firmware/zepyhr.elf, size 599356
279   [   90.804448] remoteproc remoteproc0: remote processor imx-rproc is now up
280
281
282The M4-Core is now started up and running. You can see the output from Zephyr
283on UART4.
284
285Debugging
286=========
287
288The PhyBOARD Polis can be debugged using a JTAG Debugger.
289The easiest way to do that is to use a SEGGER JLink Debugger and Phytec's
290``PEB-EVAL-01`` Shield, which can be directly connected to the JLink.
291You can find the JLink Software package here: `JLink Software`_
292
293.. figure:: img/PEB-EVAL-01.jpg
294   :alt: PEB-EVAL-01
295   :width: 350
296
297   PEB-EVAL-01
298
299To debug efficiently you should use multiple terminals:
300
301(But its also possible to use ``west debug``)
302
303After connecting everything and building with west use this command while in
304the directory of the program you build earlier to start a debug server:
305
306.. code-block:: console
307
308   host$ west debugserver
309
310West automatically connects via the JLink to the Target. And keeps open a
311debug server.
312
313Use another terminal, start gdb, connect to target and load Zephyr on the
314target:
315
316.. code-block:: console
317
318   host$ gdb-multiarch build/zephyr/zephyr.elf -tui
319   (gdb) targ rem :2331
320   Remote debugging using :2331
321   0x1ffe0008 in _vector_table ()
322   (gdb) mon halt
323   (gdb) mon reset
324   (gdb) c
325   Continuing.
326
327The program can be debugged using standard gdb techniques.
328
329.. _PHYTEC website:
330   https://www.phytec.de/produkte/single-board-computer/phyboard-polis-imx8m-mini/
331
332.. _PhyBOARD Polis pinout:
333   https://download.phytec.de/Products/phyBOARD-Polis-iMX8M_Mini/TechData/phyCORE-i.MX8M_MINI_Pin_Muxing_Table.A1.xlsx?_ga=2.237582016.1177557183.1660563641-1900651135.1634193918
334
335.. _Remoteproc BSP:
336   https://wiki.phytec.com/pages/releaseview.action?pageId=472257137#L1002e.A3i.MX8MMini/NanoBSPManual-RunningExamplesfromLinuxusingRemoteproc
337
338.. _i.MX 8M Applications Processor Reference Manual:
339   https://www.nxp.com/webapp/Download?colCode=IMX8MMRM
340
341.. _JLink Software:
342   https://www.segger.com/downloads/jlink/
343