1.. _colibri_imx7d_m4: 2 3NXP i.MX 7 Computer on Module - Colibri iMX7 4############################################ 5 6Overview 7******** 8 9The i.MX7 SoC is a Hybrid multi-core processor composed by Single/Dual Cortex A7 10core and Single Cortex M4 core. 11Zephyr was ported to run on the M4 core. In a later release, it will also 12communicate with the A7 core (running Linux) via RPmsg. 13 14 15.. image:: colibri_imx7d_m4.jpg 16 :align: center 17 :alt: Colibri-iMX7 18 19Hardware 20******** 21 22- i.MX7 Single/Dual Cortex A7 (800MHz/1.0GHz) core and Single Cortex M4 (200MHz) core 23 24- Memory 25 26 - RAM -> A7: 256MB, 512MB and 1GB 27 - RAM -> M4: 3x32KB (TCML, TCMU, OCRAM_S), 1x128KB (OCRAM) and 1x256MB (DDR) 28 - Flash -> A7: 4Gb eMMC and 512Mb NAND 29 30- Display 31 32 - RGB 1920x1080x24bpp 33 - 4-wire Resistive touch 34 35- Multimedia 36 37 - 1x Camera Parallel Interface 38 - 1x Analog Audio Line in (Stereo) 39 - 1x Analog Audio Mic in (Mono) 40 - 1x Analog Audio Headphone out (Stereo) 41 42- Connectivity 43 44 - USB 2.0 OTG (High Speed) 45 - USB 2.0 host (High Speed) 46 - 10/100 Mbit/s Ethernet PHY 47 - 4x I2C 48 - 4x SPI 49 - 7x UART 50 - 1x IrDA 51 - 20x PWM 52 - Up to 125 GPIO 53 - 4x Analog Input (12 Bit) 54 - 2x SDIO/SD/MMC (8 Bit) 55 - 2x CAN 56 57For more information about the i.MX 7 SoC, Colibri iMX7 Computer on Module 58and Colibri Evaluation Board, see these references: 59 60- `i.MX 7 Series Website`_ 61- `i.MX 7 Dual Datasheet`_ 62- `i.MX 7 Dual Reference Manual`_ 63- `Colibri iMX7 Website`_ 64- `Colibri iMX7 User Guide`_ 65- `Colibri iMX7 Datasheet`_ 66- `Colibri Evaluation Board Website`_ 67- `Colibri Evaluation Board Datasheet`_ 68 69Supported Features 70================== 71 72The Colibri iMX7D Computer on Module with Colibri Evaluation Board configuration 73supports the following hardware features on the Cortex M4 Core: 74 75+-----------+------------+-------------------------------------+ 76| Interface | Controller | Driver/Component | 77+===========+============+=====================================+ 78| NVIC | on-chip | nested vector interrupt controller | 79+-----------+------------+-------------------------------------+ 80| SYSTICK | on-chip | systick | 81+-----------+------------+-------------------------------------+ 82| GPIO | on-chip | gpio | 83+-----------+------------+-------------------------------------+ 84| I2C | on-chip | i2c | 85+-----------+------------+-------------------------------------+ 86| PWM | on-chip | pwm | 87+-----------+------------+-------------------------------------+ 88| UART | on-chip | serial port-polling; | 89| | | serial port-interrupt | 90+-----------+------------+-------------------------------------+ 91 92The default configuration can be found in the defconfig file: 93 94 ``boards/arm/colibri_imx7d_m4/colibri_imx7d_m4_defconfig`` 95 96Other hardware features are not currently supported by the port. 97 98Connections and IOs 99=================== 100 101The Colibri iMX7D Computer on Module with Colibri Evaluation Board 102was tested with the following pinmux controller configuration. 103 104+---------------+-----------------+---------------------------+ 105| Board Name | SoC Name | Usage | 106+===============+=================+===========================+ 107| UART_B RXD | UART2_TXD | UART Console | 108+---------------+-----------------+---------------------------+ 109| UART_B TXD | UART2_RXD | UART Console | 110+---------------+-----------------+---------------------------+ 111| SODIMM_135 | GPIO1_IO02 | LED0 | 112+---------------+-----------------+---------------------------+ 113| SODIMM_133 | GPIO2_IO26 | SW0 | 114+---------------+-----------------+---------------------------+ 115| SODIMM_194 | I2C4_SDA | I2C_SDA | 116+---------------+-----------------+---------------------------+ 117| SODIMM_196 | I2C4_SCL | I2C_SCL | 118+---------------+-----------------+---------------------------+ 119| SODIMM_59 | PWM1/GPIO1_IO08 | PWM | 120+---------------+-----------------+---------------------------+ 121 122System Clock 123============ 124 125The M4 Core is configured to run at a 200 MHz clock speed. 126 127Serial Port 128=========== 129 130The iMX7D SoC has seven UARTs. The number 2 is configured for the console and 131the remaining are not used/tested. 132 133Programming and Debugging 134************************* 135 136The Colibri iMX7D doesn't have QSPI flash for the M4 and it needs to be started by 137the A7 core. The A7 core is responsible to load the M4 binary application into the 138RAM, put the M4 in reset, set the M4 Program Counter and Stack Pointer, and get 139the M4 out of reset. 140The A7 can perform these steps at bootloader level or after the Linux system has 141booted. 142 143The M4 can use up to 5 different RAMs. These are the memory mapping for A7 and M4: 144 145+------------+-----------------------+------------------------+-----------------------+----------------------+ 146| Region | Cortex-A7 | Cortex-M4 (System Bus) | Cortex-M4 (Code Bus) | Size | 147+============+=======================+========================+=======================+======================+ 148| DDR | 0x80000000-0xFFFFFFFF | 0x80000000-0xDFFFFFFF | 0x10000000-0x1FFEFFFF | 2048MB (less for M4) | 149+------------+-----------------------+------------------------+-----------------------+----------------------+ 150| OCRAM | 0x00900000-0x0091FFFF | 0x20200000-0x2021FFFF | 0x00900000-0x0091FFFF | 128KB | 151+------------+-----------------------+------------------------+-----------------------+----------------------+ 152| TCMU | 0x00800000-0x00807FFF | 0x20000000-0x20007FFF | | 32KB | 153+------------+-----------------------+------------------------+-----------------------+----------------------+ 154| TCML | 0x007F8000-0x007FFFFF | | 0x1FFF8000-0x1FFFFFFF | 32KB | 155+------------+-----------------------+------------------------+-----------------------+----------------------+ 156| OCRAM_S | 0x00180000-0x00187FFF | 0x20180000-0x20187FFF | 0x00000000-0x00007FFF | 32KB | 157+------------+-----------------------+------------------------+-----------------------+----------------------+ 158| QSPI Flash | | | 0x08000000-0x0BFFFFFF | 64MB | 159+------------+-----------------------+------------------------+-----------------------+----------------------+ 160 161 162References 163========== 164 165- `i.MX 7 Dual Reference Manual`_ from page 190 (section 2.1.2 and 2.1.3) 166- `Toradex Wiki`_ 167 168 169At compilation time you have to choose which RAM will be used. This configuration is 170done in the file ``boards/arm/colibri_imx7d_m4/colibri_imx7d_m4.dts`` with "zephyr,flash" (when CONFIG_XIP=y) and "zephyr,sram" 171properties. The available configurations are: 172 173.. code-block:: none 174 175 "zephyr,flash" 176 - &ddr_code 177 - &tcml_code 178 - &ocram_code 179 - &ocram_s_code 180 - &ocram_pxp_code 181 - &ocram_epdc_code 182 183 "zephyr,sram" 184 - &ddr_sys 185 - &tcmu_sys 186 - &ocram_sys 187 - &ocram_s_sys 188 - &ocram_pxp_sys 189 - &ocram_epdc_sys 190 191 192Below you will find the instructions to load and run Zephyr on M4 from A7 using u-boot. 193 194Copy the compiled zephyr.bin to the first EXT partition of the SD card and plug into the 195board. Power it up and stop the u-boot execution. 196Set the u-boot environment variables and run the zephyr.bin from the appropriated memory 197configured in the Zephyr compilation: 198 199.. code-block:: console 200 201 setenv bootm4 'ext4load mmc 0:1 $m4addr $m4fw && dcache flush && bootaux $m4addr' 202 # TCML 203 setenv m4tcml 'setenv m4fw zephyr.bin; setenv m4addr 0x007F8000' 204 setenv bootm4tcml 'run m4tcml && run bootm4' 205 run bootm4tcml 206 # TCMU 207 setenv m4tcmu 'setenv m4fw zephyr.bin; setenv m4addr 0x00800000' 208 setenv bootm4tcmu 'run m4tcmu && run bootm4' 209 run bootm4tcmu 210 # OCRAM 211 setenv m4ocram 'setenv m4fw zephyr.bin; setenv m4addr 0x00900000' 212 setenv bootm4ocram 'run m4ocram && run bootm4' 213 run bootm4ocram 214 # OCRAM_S 215 setenv m4ocrams 'setenv m4fw zephyr.bin; setenv m4addr 0x00180000' 216 setenv bootm4ocrams 'run m4ocrams && run bootm4' 217 run bootm4ocrams 218 # DDR 219 setenv m4ddr 'setenv m4fw zephyr.bin; setenv m4addr 0x80000000' 220 setenv bootm4ddr 'run m4ddr && run bootm4' 221 run bootm4ddr 222 223 224Debugging 225========= 226 227Download and install `J-Link Tools`_ and `NXP iMX7D Connect CortexM4.JLinkScript`_. 228 229To run Zephyr Binary using J-Link create the following script in order to 230get the Program Counter and Stack Pointer from zephyr.bin. 231 232get-pc-sp.sh: 233 234.. code-block:: console 235 236 #!/bin/sh 237 238 firmware=$1 239 240 pc=$(od -An -N 8 -t x4 $firmware | awk '{print $2;}') 241 sp=$(od -An -N 8 -t x4 $firmware | awk '{print $1;}') 242 243 echo pc=$pc 244 echo sp=$sp 245 246 247Get the SP and PC from firmware binary: ``./get-pc-sp.sh zephyr.bin`` 248 249.. code-block:: console 250 251 pc=00900f01 252 sp=00905020 253 254Plug in the J-Link into the board and PC and run the J-Link command line tool: 255 256.. code-block:: console 257 258 /usr/bin/JLinkExe -device Cortex-M4 -if JTAG -speed 4000 -autoconnect 1 -jtagconf -1,-1 -jlinkscriptfile iMX7D_Connect_CortexM4.JLinkScript 259 260The following steps are necessary to run the zephyr.bin: 2611. Put the M4 core in reset 2622. Load the binary in the appropriate addr (TMCL, TCMU, OCRAM, OCRAM_S or DDR) 2633. Set PC (Program Counter) 2644. Set SP (Stack Pointer) 2655. Get the M4 core out of reset 266 267Issue the following commands inside J-Link commander: 268 269.. code-block:: console 270 271 w4 0x3039000C 0xAC 272 loadfile zephyr.bin,0x00900000 273 w4 0x00180000 00900f01 274 w4 0x00180004 00905020 275 w4 0x3039000C 0xAA 276 277With these mechanisms, applications for the ``colibri_imx7d_m4`` board 278configuration can be built and debugged in the usual way (see 279:ref:`build_an_application` and :ref:`application_run` for more details). 280 281References 282========== 283 284- `Loading Code on Cortex-M4 from Linux for the i.MX 6SoloX and i.MX 7Dual/7Solo Application Processors`_ 285- `J-Link iMX7D Instructions`_ 286 287.. _Colibri Evaluation Board Website: 288 https://www.toradex.com/products/carrier-board/colibri-evaluation-carrier-board 289 290.. _Colibri Evaluation Board Datasheet: 291 https://docs.toradex.com/102284-colibri-evaluation-board-datasheet.pdf 292 293.. _Colibri iMX7 Website: 294 https://www.toradex.com/computer-on-modules/colibri-arm-family/nxp-freescale-imx7 295 296.. _Colibri iMX7 User Guide: 297 https://developer.toradex.com/products/colibri-imx7 298 299.. _Colibri iMX7 Datasheet: 300 https://docs.toradex.com/103125-colibri-arm-som-imx7-datasheet.pdf 301 302.. _i.MX 7 Series Website: 303 https://www.nxp.com/products/processors-and-microcontrollers/applications-processors/i.mx-applications-processors/i.mx-7-processors:IMX7-SERIES?fsrch=1&sr=1&pageNum=1 304 305.. _i.MX 7 Dual Datasheet: 306 https://www.nxp.com/docs/en/data-sheet/IMX7DCEC.pdf 307 308.. _i.MX 7 Dual Reference Manual: 309 https://www.nxp.com/webapp/Download?colCode=IMX7DRM 310 311.. _J-Link Tools: 312 https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack 313 314.. _NXP iMX7D Connect CortexM4.JLinkScript: 315 https://wiki.segger.com/images/8/86/NXP_iMX7D_Connect_CortexM4.JLinkScript 316 317.. _Loading Code on Cortex-M4 from Linux for the i.MX 6SoloX and i.MX 7Dual/7Solo Application Processors: 318 https://www.nxp.com/docs/en/application-note/AN5317.pdf 319 320.. _J-Link iMX7D Instructions: 321 https://wiki.segger.com/IMX7D 322 323.. _Toradex Wiki: 324 https://developer.toradex.com/knowledge-base/freertos-on-the-cortex-m4-of-a-colibri-imx7#Memory_areas 325