Jekyll2023-08-11T15:05:40-03:00https://imxdev.gitlab.io/feed.xmli.MXDev BlogA collection of tutorials and announcements for imx.imxdevblog@gmail.comUnderstanding how to burn eFuses on i.MX8 and i.MX8x families2018-11-13T16:26:56-02:002018-11-13T16:26:56-02:00https://imxdev.gitlab.io/tutorial/Burning_eFuses_on_i.MX8_and_i.MX8x_families<p>On the i.MX8 and i.MX8x families the OTP (One Time Programmable) memory is part
of the security subsystem and is controlled by the SCU (System Controller Unit)
and SECO (Security Controller) only.</p>
<p>This blog post provides a quick overview on the new architecture and explains
how users can read and write eFuses using the NXP <em>L4.14.62_1.0.0</em> BSP beta
release.</p>
<aside class="sidebar__right">
<nav class="toc">
<header><h4 class="nav__title"><i class="fas fa-lightbulb-o"></i> Burning eFuses on i.MX8/8x families</h4></header>
<ul class="toc__menu" id="markdown-toc">
<li><a href="#understanding-the-new-architecture" id="markdown-toc-understanding-the-new-architecture">Understanding the new architecture</a> <ul>
<li><a href="#the-fuses-arrays" id="markdown-toc-the-fuses-arrays">The fuses arrays</a></li>
<li><a href="#ecc-and-redundancy-bits" id="markdown-toc-ecc-and-redundancy-bits">ECC and Redundancy bits</a></li>
<li><a href="#the-scfw-api-functions" id="markdown-toc-the-scfw-api-functions">The SCFW API functions</a></li>
</ul>
</li>
<li><a href="#the-current-bsp-implementation" id="markdown-toc-the-current-bsp-implementation">The current BSP implementation</a> <ul>
<li><a href="#programing-efuses-using-u-boot" id="markdown-toc-programing-efuses-using-u-boot">Programing eFuses using U-Boot</a></li>
<li><a href="#programing-efuses-using-uuu-universal-update-utility" id="markdown-toc-programing-efuses-using-uuu-universal-update-utility">Programing eFuses using UUU (Universal Update Utility)</a></li>
<li><a href="#understanding-the-current-bsp-implementation" id="markdown-toc-understanding-the-current-bsp-implementation">Understanding the current BSP implementation</a></li>
</ul>
</li>
</ul>
</nav>
</aside>
<h1 id="understanding-the-new-architecture">Understanding the new architecture</h1>
<h2 id="the-fuses-arrays">The fuses arrays</h2>
<p>The OTP memory is controlled by the OCOTP CTRL (On-Chip One Time Programmable
Controller) block, differently from the <a href="https://imxdev.gitlab.io/tutorial/Burning_eFuses_on_i.MX/">i.MX6 and i.MX7 families</a> on i.MX8
and i.MX8x the OCOTP CTRL organizes the OTP memory in fuse arrays instead of
fuse banks and words.</p>
<p>Each fuse module has a certain size and an associated supplementary array
of 16 Words, this determines the number of words available on each device.</p>
<p>The i.MX8QXP has one fuse module of 16K, this module consists of a 16 words
supplementary array and a 512 words (16x1024 bits) main array, a total of 528
words.</p>
<table>
<thead>
<tr>
<th style="text-align: center">Fuse Row Index</th>
<th style="text-align: center">Array</th>
<th style="text-align: center">Number of words</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center">0 - 15</td>
<td style="text-align: center">16k Supplementary Array</td>
<td style="text-align: center">16</td>
</tr>
<tr>
<td style="text-align: center">16 - 271</td>
<td style="text-align: center">16k Main array</td>
<td style="text-align: center">256</td>
</tr>
<tr>
<td style="text-align: center">272 - 543</td>
<td style="text-align: center">Not being used</td>
<td style="text-align: center">0</td>
</tr>
<tr>
<td style="text-align: center">544 - 799</td>
<td style="text-align: center">16K Main array</td>
<td style="text-align: center">256</td>
</tr>
</tbody>
</table>
<h2 id="ecc-and-redundancy-bits">ECC and Redundancy bits</h2>
<p>The eFuses in i.MX8 and i.MX8x families includes the ECC and Redundancy features
which are used to verify if the fuse has been correctly programmed.</p>
<p>On each eFuse programming an ECC is calculated in a word by word basis, this
means that all words covered by this feature can be only programmed once,
individual bits cannot be programmed independently.</p>
<p>For words that have to be programmed each efuse at a time (e.g. Monotonic Array)
the redundancy feature is used instead, the mechanism is based on a bit by bit
basis allowing the word to be programmed multiple times.</p>
<p>The table below lists the words supporting the redundancy feature on i.MX8QXP,
hence the words can be programmed more than one time:</p>
<table>
<thead>
<tr>
<th style="text-align: center">Fuse Row Index</th>
<th style="text-align: center">Array</th>
<th style="text-align: center">Fuse</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center">0 - 15</td>
<td style="text-align: center">16k Supplementary Array</td>
<td style="text-align: center">All Words</td>
</tr>
<tr>
<td style="text-align: center">544 - 663</td>
<td style="text-align: center">16K Main array</td>
<td style="text-align: center">Monotonic Array</td>
</tr>
<tr>
<td style="text-align: center">664 - 669</td>
<td style="text-align: center">16K Main array</td>
<td style="text-align: center">SCU SW Version</td>
</tr>
</tbody>
</table>
<p>Details regarding redundancy and ECC features can be found in section
“Bank redundancy vs ECC section” in processors reference manual.</p>
<h2 id="the-scfw-api-functions">The SCFW API functions</h2>
<p>As mentioned in the introduction only SECO and SCU can program eFuses, the
System Controller Firmware (SCFW) provides API functions which are used to
interact with OCOTP CTRL block. The read and write API functions are listed
below:</p>
<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cm">/* This function writes a given fuse word index */</span>
<span class="n">sc_misc_otp_fuse_write</span> <span class="p">(</span> <span class="n">sc_ipc_t</span> <span class="n">ipc</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">word</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">val</span> <span class="p">)</span>
<span class="cm">/* This function reads a given fuse word index */</span>
<span class="n">sc_misc_otp_fuse_read</span> <span class="p">(</span> <span class="n">sc_ipc_t</span> <span class="n">ipc</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">word</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">val</span> <span class="p">)</span>
<span class="cm">/* This function securely writes a group of fuse words */</span>
<span class="n">sc_err_t</span> <span class="n">sc_misc_seco_fuse_write</span> <span class="p">(</span> <span class="n">sc_ipc_t</span> <span class="n">ipc</span><span class="p">,</span> <span class="n">sc_faddr_t</span> <span class="n">addr</span> <span class="p">)</span>
</code></pre></div></div>
<p>The user should call the SCFW API functions in order to read and write in
the OTP memory, the <em>Fuse Row Index</em> should be provided as the word parameter.</p>
<p>The list of programmable eFuses and their respective indexes are available
in fusemap section on the processors Reference Manual.</p>
<ul>
<li>
<p><code class="highlighter-rouge">sc_misc_otp_fuse_write()</code>:
This API function is used to program eFuses using SCU, and can be only called by
the owner of the <em>SC_R_SYSTEM</em> resource. Details about ownership can be seen in
SCFW API Reference guide available in <a href="https://www.nxp.com/pages/alpha-beta-bsps-for-microprocessors:IMXPRERELEASES">SCFW porting kit</a>.</p>
</li>
<li>
<p><code class="highlighter-rouge">sc_misc_otp_fuse_read()</code>:
This API function is used to read eFuses using SCU, and can be called by all
execution environments.</p>
</li>
<li>
<p><code class="highlighter-rouge">sc_err_t sc_misc_seco_fuse_write()</code>:
A group of fuses can be programmed by SECO, the address provided in the
function must be a pointer into secure RAM containing a signed fuse command
message block.</p>
</li>
</ul>
<p>Please refer to the <a href="https://imxdev.gitlab.io/tutorial/System_Controller_Unit_(SCU)_Introduction_for_i.MX_8QXP_MEK/">System Controller Unit (SCU) Introduction</a> blog post for
additional details.</p>
<h1 id="the-current-bsp-implementation">The current BSP implementation</h1>
<h2 id="programing-efuses-using-u-boot">Programing eFuses using U-Boot</h2>
<p>Starting in <a href="https://source.codeaurora.org/external/imx/uboot-imx/?h=imx_v2018.03_4.14.62_1.0.0_beta">L4.14.62_1.0.0 Beta release</a> the U-Boot <em>fuse</em> command is
capable of reading and writing the efuses using the SCFW API functions, the
process is similar as in i.MX6 and 7 families. The U-Boot source code is
already programmed in such a way that all API calls are transparent to the user.</p>
<div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code>=> fuse
fuse - Fuse sub-system
Usage:
fuse read <span class="nt"><bank></span> <span class="nt"><word></span> <span class="p">[</span><span class="nv"><cnt></span><span class="p">]</span> - read 1 or 'cnt' fuse words,
starting at 'word'
fuse sense <span class="nt"><bank></span> <span class="nt"><word></span> <span class="p">[</span><span class="nv"><cnt></span><span class="p">]</span> - sense 1 or 'cnt' fuse words,
starting at 'word'
fuse prog <span class="p">[</span><span class="nv">-y</span><span class="p">]</span> <span class="nt"><bank></span> <span class="nt"><word></span> <span class="nt"><hexval></span> <span class="p">[</span><span class="nv"><hexval>...</span><span class="p">]</span> - program 1 or
several fuse words, starting at 'word' (PERMANENT)
fuse override <span class="nt"><bank></span> <span class="nt"><word></span> <span class="nt"><hexval></span> <span class="p">[</span><span class="nv"><hexval>...</span><span class="p">]</span> - override 1 or
several fuse words, starting at 'word'
=>
</code></pre></div></div>
<p>As mentioned in this post, on i.MX8 and i.MX8x families, the fuses are organized
in fuse arrays instead of fuse banks and words, in this case, the bank parameter
should be set to zero and the word should match the <em>Fuse row Index</em> in the
processors fusemap.</p>
<p>The command line below can be used as an example to program the MAC1_ADDR[31:00]
fuses in i.MX8QXP:</p>
<div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code>=> fuse prog 0 708 0xa295fc11
Programming bank 0 word 0x000002c4 to 0xa295fc11...
Warning: Programming fuses is an irreversible operation!
This may brick your system.
Use this command only if you are sure of what you are doing!
Really perform this fuse programming? <span class="nt"><y</span><span class="err">/</span><span class="na">N</span><span class="nt">></span>
y
</code></pre></div></div>
<p>u-boot adds another confirmation layer for Fuses protected by ECC,
and will ask you twice if you are really sure you want to burn the
fuses. Below an example, setting boot mode fuse to eMMC boot.</p>
<div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code>=> fuse prog 0 18 0x00000042
Programming bank 0 word 0x00000012 to 0x00000042...
Warning: Programming fuses is an irreversible operation!
This may brick your system.
Use this command only if you are sure of what you are doing!
Really perform this fuse programming? <span class="nt"><y</span><span class="err">/</span><span class="na">N</span><span class="nt">></span>
y
Warning: Words in this index range have ECC protection
and can only be programmed once per word. Individual bit
operations will be rejected after the first one.<span class="sb">
</span> Really program this word? <span class="nt"><y</span><span class="err">/</span><span class="na">N</span><span class="nt">></span>
y
</code></pre></div></div>
<p>In order to bypass the second confirmation (useful for uuu scripts,
see below), one has to first set the <code class="highlighter-rouge">force_prog_ecc</code> variable to y (or 1):</p>
<div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code>=> setenv force_prog_ecc y
=> fuse prog 0 18 0x00000042
Programming bank 0 word 0x00000012 to 0x00000042...
Warning: Programming fuses is an irreversible operation!
This may brick your system.
Use this command only if you are sure of what you are doing!
Really perform this fuse programming? <span class="nt"><y</span><span class="err">/</span><span class="na">N</span><span class="nt">></span>
y
=>
</code></pre></div></div>
<h2 id="programing-efuses-using-uuu-universal-update-utility">Programing eFuses using UUU (Universal Update Utility)</h2>
<p>The UUU (Universal Update Utility) is a SDP protocol flash programming tool,
additional details can be found on the blog post <a href="https://imxdev.gitlab.io/tutorial/How_to_use_UUU_to_flash_the_iMX_boards/">How to use UUU to flash the iMX boards</a>.</p>
<p>The <code class="highlighter-rouge">uuu.auto</code> file contains a set of commands used for properly flashing the
targeted device, users can add U-Boot commands to program a set of eFuses
depending on their specific use case. The command lines below added in
i.MX8QXP <code class="highlighter-rouge">uuu.auto</code> file can be used as an example on how to program the
MAC1_ADDR[47:00] fuses in i.MX8QXP:</p>
<div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code> SDPS: boot -f imx-boot-imx8qxpmek-sd.bin-flash
+FB: ucmd fuse prog -y 0 708 0xa295fc11
+FB: ucmd fuse prog -y 0 709 0x000017b4
FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev ${emmc_dev}
FB: ucmd mmc dev ${emmc_dev}
</code></pre></div></div>
<p>or for ECC-protected fuses:</p>
<div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code> SDPS: boot -f imx-boot-imx8qxpmek-sd.bin-flash
+FB: ucmd setenv force_ecc_prog y
+FB: ucmd fuse prog -y 0 18 0x00000042
FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev ${emmc_dev}
FB: ucmd mmc dev ${emmc_dev}
</code></pre></div></div>
<h2 id="understanding-the-current-bsp-implementation">Understanding the current BSP implementation</h2>
<p>The <code class="highlighter-rouge">sc_misc_otp_fuse_write()</code> API function can be only called by the owner of
the <em>SC_R_SYSTEM</em> resource, in the current BSP implementation this resource is
owned by the <a href="https://source.codeaurora.org/external/imx/imx-atf/?h=imx_4.14.62_1.0.0_beta">ARM Trusted Firmware</a> running on <em>EL3 Secure</em> exception level.</p>
<p>The U-Boot is running in <em>EL2 Non-Secure</em> exception level and cannot call the
<code class="highlighter-rouge">sc_misc_otp_fuse_write()</code> API function directly, the U-Boot is using the SIP
services and calling the SCFW API in ATF.</p>
<p>The diagram below provides a high-level overview of the process for writing
a fuse:</p>
<center><img src="/images/otp_write.png" width="100%" /></center>
<p><br /></p>
<p>For additional details regarding Secure Monitor Call (SMC) and Exception
Levels (EL), please refer to the <a href="https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile">ARMv8 Architecture Reference Manual</a>.</p>Breno Matheus Limabrenomatheus@gmail.comOn the i.MX8 and i.MX8x families the OTP (One Time Programmable) memory is part of the security subsystem and is controlled by the SCU (System Controller Unit) and SECO (Security Controller) only.How to use UUU to flash the iMX boards2018-11-13T11:06:15-02:002018-11-13T11:06:15-02:00https://imxdev.gitlab.io/tutorial/How_to_use_UUU_to_flash_the_iMX_boards<p>UUU is the next version of MFGTools, a tool used to load the software on the
RAM or flash it to a list of boot media supported by several i.MX boards.
UUU is helpful for development or production environment.</p>
<aside class="sidebar__right">
<nav class="toc">
<header><h4 class="nav__title"><i class="fas fa-file-alt"></i> On This Page</h4></header>
<ul class="toc__menu" id="markdown-toc">
<li><a href="#introduction" id="markdown-toc-introduction">Introduction</a></li>
<li><a href="#installation" id="markdown-toc-installation">Installation</a></li>
<li><a href="#how-to-use-uuu-for-imx-8qxp-mek" id="markdown-toc-how-to-use-uuu-for-imx-8qxp-mek">How to use UUU for i.MX 8QXP MEK</a> <ul>
<li><a href="#connect-the-board" id="markdown-toc-connect-the-board">Connect the board</a></li>
<li><a href="#serial-download-mode" id="markdown-toc-serial-download-mode">Serial download mode</a></li>
<li><a href="#download-the-image" id="markdown-toc-download-the-image">Download the image</a></li>
<li><a href="#uuu" id="markdown-toc-uuu">UUU</a></li>
<li><a href="#boot-the-board" id="markdown-toc-boot-the-board">Boot the board</a></li>
</ul>
</li>
</ul>
</nav>
</aside>
<h1 id="introduction">Introduction</h1>
<p>UUU stands for <strong>Universal Update Utility</strong> - also known as mfgtools 3.0.</p>
<p>It runs on Windows or Linux with the same look and feel, the source code is
available on
<a href="https://github.com/NXPmicro/mfgtools">GitHub</a> along with the
<a href="https://github.com/NXPmicro/mfgtools/wiki">documentation</a>, the
<a href="https://github.com/NXPmicro/mfgtools/issues">issue tracking system</a> and the
<a href="https://github.com/NXPmicro/mfgtools/releases">release artifacts</a>.</p>
<h1 id="installation">Installation</h1>
<p>The installation only requires copying the right set of files to one directory.
The next table shows the minimum files needed to get UUU running on Linux or
Windows.</p>
<table>
<thead>
<tr>
<th>Linux</th>
<th>Windows</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="highlighter-rouge">uuu</code></td>
<td><code class="highlighter-rouge">uuu.exe</code></td>
</tr>
<tr>
<td> </td>
<td><code class="highlighter-rouge">libusb-1.0.dll</code></td>
</tr>
</tbody>
</table>
<h1 id="how-to-use-uuu-for-imx-8qxp-mek">How to use UUU for i.MX 8QXP MEK</h1>
<p>The i.MX 8QXP MEK is shown in the following picture:</p>
<center><img src="/images/imx8qxp-top.jpg" width="80%" /></center>
<h2 id="connect-the-board">Connect the board</h2>
<p>The first step is to connect all the needed cables to the board and power on
the board.</p>
<ul>
<li>Connect the 12V/8.3A universal power supply between the outlet and connector <code class="highlighter-rouge">J9</code></li>
<li>Connect a USB type B cable between the computer and connector <code class="highlighter-rouge">J11</code></li>
<li>Connect a USB type C cable between the computer and connector <code class="highlighter-rouge">J10</code></li>
</ul>
<p>The power indication led is <code class="highlighter-rouge">D2</code>. To verify if the USB connections are right use
the Linux command <code class="highlighter-rouge">lsusb</code> or
<a href="https://www.ftdichip.com/Support/Utilities/usbview.zip">USBView</a> on Windows.</p>
<p>The USB devices created are as in the following table:</p>
<table>
<thead>
<tr>
<th>USB Type</th>
<th>Connector</th>
<th>Use</th>
<th>USB device recognized by OS</th>
</tr>
</thead>
<tbody>
<tr>
<td>micro</td>
<td><code class="highlighter-rouge">J11</code></td>
<td>Serial Console</td>
<td><code class="highlighter-rouge">Bus 001 Device 006: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC</code></td>
</tr>
<tr>
<td>Type C</td>
<td><code class="highlighter-rouge">J10</code></td>
<td>Serial Download</td>
<td><code class="highlighter-rouge">Bus 003 Device 003: ID 1fc9:012f NXP Semiconductors </code></td>
</tr>
</tbody>
</table>
<p>If using on Windows, additional drivers may be needed. This
<a href="https://github.com/NXPmicro/mfgtools/wiki/How-to-install-USB-to-serial-driver-on-Windows">link</a>
may help.</p>
<h2 id="serial-download-mode">Serial download mode</h2>
<p>The serial download mode is used to enable UUU to communicate with the i.MX SoC.
The SoC enters serial download mode every time a boot media is not found. For
example, if the board is configured to boot from SDCard, but there is no SDCard
connected or the boot media does not have a valid bootloader copied into it.</p>
<p>In this example, the <code class="highlighter-rouge">SW2</code> dip switch is set to <code class="highlighter-rouge">1100</code> (follow the instructions
written on the board).</p>
<h2 id="download-the-image">Download the image</h2>
<p>In this example the image used is from L4.14.62_1.0.0_Beta release. For i.MX
8QXP MEK download the pre-built image from <a href="https://www.nxp.com/webapp/Download?colCode=L4.14.62_1.0.0_Beta_MX8QXp&appType=license&location=null&Parent_nodeId=1454108179417712493862&Parent_pageType=product">here</a>
(you must read and decide if you accept the license).</p>
<h2 id="uuu">UUU</h2>
<p>UUU uses scripts with the same API used in MFGTools. The L4.14.62_1.0.0_beta
release pre-built image already includes some script examples, a README file for
UUU and the default script <code class="highlighter-rouge">uuu.auto</code> which flashes the default pre-built
<code class="highlighter-rouge">fsl-image-validation-imx-imx8qxpmek.sdcard</code> to eMMC.</p>
<p>The files related to UUU are listed with the following command:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ unzip -l ~/Download/L4.14.62_1.0.0_beta_images_MX8QXPMEK.zip | grep uuu
160 2018-10-18 05:40 README.uuu
1775 2018-10-30 03:25 samples/uuu.xen
526 2018-10-30 03:25 samples/example_spinor.uuu
3171 2018-10-30 03:25 samples/example_kernel_emmc.uuu
546 2018-10-30 03:25 samples/example_weimnor.uuu
454 2018-10-30 03:25 samples/uuu.auto
2795 2018-10-30 03:25 samples/example_kernel_nand.uuu
434 2018-10-30 03:25 samples/example_sata.uuu
591 2018-10-30 03:25 samples/uuu_sd_m4.auto
570 2018-10-18 05:41 uuu.auto
</code></pre></div></div>
<p>The default use of UUU is to flash the eMMC using the pre-built image is show
bellow:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cp ~/Download/uuu .
$ chmod a+x uuu
$ sudo ./uuu ~/Download/L4.14.62_1.0.0_beta_images_MX8QXPMEK.zip
uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.1.108-0-g5a7bfd2
Success 1 Failure 0
3:2 7/ 7 [Done ] FB: done
</code></pre></div></div>
<p>This command follows the instructions from <code class="highlighter-rouge">uuu.auto</code> automatically to flash the
board.</p>
<p>The progress can be followed in the board console:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>U-Boot 2018.03-imx_v2018.03_4.14.62_1.0.0_beta+g7fac6b9 (Oct 16 2018 - 07:03:51 +0000)
CPU: Freescale i.MX8QXP revB A35 at 1200 MHz at 27C
Model: Freescale i.MX8QXP MEK
Board: iMX8QXP MEK
Boot: USB
DRAM: 3 GiB
TCPC: Vendor ID [0x1fc9], Product ID [0x5110], Addr [I2C1 0x50]
MMC: FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... Card did not respond to voltage select!
*** Warning - No block device, using default environment
Failed (-5)
[pcie_ctrlb_sata_phy_init_rc] LNK DOWN 8600000
In: serial
Out: serial
Err: serial
BuildInfo:
- SCFW 07a6cccf, SECO-FW 31fabbff, IMX-MKIMAGE 7f7b5b25, ATF 30d73be
- U-Boot 2018.03-imx_v2018.03_4.14.62_1.0.0_beta+g7fac6b9
Card did not respond to voltage select!
Detect USB boot. Will enter fastboot mode!
Net:
Warning: ethernet@5b040000 (eth0) using random MAC address - 46:98:d2:ce:23:f0
eth0: ethernet@5b040000 [PRIME]
Warning: ethernet@5b050000 (eth1) using random MAC address - d2:ce:c7:57:a3:43
, eth1: ethernet@5b050000
Fastboot: Normal
Boot from USB for mfgtools
Use default environment for mfgtools
Run bootcmd_mfg: run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr} ${initrd_addr} ${fdt_addr}; else booti ${loadaddr} ${initrd_addr};
Hit any key to stop autoboot: 0
## Checking Image at 83100000 ...
Unknown image format!
Run fastboot ...
1 setufp mode 0
1 cdns3_uboot_initmode 0
Detect USB boot. Will enter fastboot mode!
flash target is MMC:1
Card did not respond to voltage select!
MMC card init failed!
Card did not respond to voltage select!
** Block device MMC 1 not supported
Detect USB boot. Will enter fastboot mode!
flash target is MMC:0
switch to partitions #0, OK
mmc0(part 0) is current device
status: -104 ep 'ep1in' trans: 0
Detect USB boot. Will enter fastboot mode!
Starting download of 16776232 bytes
..........................................................................
.....................................................
downloading of 16776232 bytes finished
writing to partition 'all'
sparse flash target is mmc:0
writing to partition 'all' for sparse, buffer size 16776232
Flashing sparse image at offset 0
Flashing Sparse Image
........ wrote 16776192 bytes to 'all'
status: -104 ep 'ep1in' trans: 0
Starting download of 16776244 bytes
..........................................................................
.....................................................
downloading of 16776244 bytes finished
writing to partition 'all'
sparse flash target is mmc:0
writing to partition 'all' for sparse, buffer size 16776244
Flashing sparse image at offset 0
Flashing Sparse Image
........ wrote 16776192 bytes to 'all'
Starting download of 16776244 bytes
..........................................................................
.....................................................
downloading of 16776244 bytes finished
writing to partition 'all'
</code></pre></div></div>
<h2 id="boot-the-board">Boot the board</h2>
<p>Change the <code class="highlighter-rouge">SW1</code> to <code class="highlighter-rouge">0010</code>, reset the board, follow the output of serial console.</p>Daiane Angolinidaiane.list@gmail.comUUU is the next version of MFGTools, a tool used to load the software on the RAM or flash it to a list of boot media supported by several i.MX boards. UUU is helpful for development or production environment.System Controller Unit (SCU) Introduction for i.MX 8QXP MEK2018-11-13T09:04:56-02:002018-11-13T09:04:56-02:00https://imxdev.gitlab.io/tutorial/System_controller_unit_introduction_for_imx_8qxp_mek<p>The newly released i.MX 8QXP introduces a new concept for manipulating resource allocation, power, clocking and IO configuration and muxing. Due to the architecture complexity of this new chip, a System Controller Unit (SCU) has been added to the system. The SCU is a Arm Cortex-M4 core and is the first processor to boot in the i.MX 8QXP design.</p>
<p>It is the responsability of the SCU to control:</p>
<ul>
<li>Boot management</li>
<li>Power management</li>
<li>Clock</li>
<li>IO and reset management configuration and muxing</li>
<li>Resource partitioning / access control</li>
<li>DDR Management</li>
<li>Temperature monitoring</li>
<li>AP watchdog services</li>
<li>Low power wakeup</li>
</ul>
<p>All those subsystems are abstracted thanks to the System Controller Firmware (SCFW) running in the SCU. Other software components communicate with SCU via an Application Programming Interface (API).</p>
<p>This API makes Remote Procedure Calls (RPC) via an underlying Inter-Processor Communication (IPC) mechanism. Each OS distributed by NXP features a library that allows it to interact with the SCFW running on the SCU.</p>
<p><img src="https://imxdev.gitlab.io/images/ipc-calls.png" /></p>
<h2 id="scu-architecture">SCU Architecture</h2>
<p>The SCU sub-system is made out of:</p>
<ul>
<li>1x Arm Cortex-M4 processor running at 266MHz with 256KB of Tightly Coupled Memory (TCM)</li>
</ul>
<p><img src="https://imxdev.gitlab.io/images/scu-architecture.png" /></p>
<p>It includes the following set of peripherals:</p>
<ul>
<li>1x TPM</li>
<li>1x UART</li>
<li>1x I2C</li>
<li>8x GPIOs</li>
<li>4x MUs</li>
</ul>
<h2 id="system-controller-firmware-scfw">System Controller Firmware (SCFW)</h2>
<p>In order to control all the functionality of the SCU, NXP has created the SCFW. The SCFW is distributed in a porting kit from.</p>
<p>NXP only releases packages in a majority object code form, however a board.c file is provided in which most of the configuration of the SCFW can be done.</p>
<p>The first main step from SCFW to configure the DDR and start all other cores in the system. The boot flow is described in the image below:</p>
<p><img src="https://imxdev.gitlab.io/images/boot-flow-imx8.png" /></p>
<p>The i.MX8 boot sequence involves SCU ROM, SCFW, Security Controller (SECO) ROM, and SECO FW:</p>
<ul>
<li>At reset, the SCU ROM and SECO ROM both start execution</li>
<li>The SCU ROM reads boot mode pins</li>
<li>SCU ROM loads the first container from the boot media; this container always has the SECO FW, signed using the NXP key</li>
<li>The SECO FW is loaded into SECO Tightly Coupled Memory (TCM)</li>
<li>A message is sent by the SCU via private MU to the SECO ROM to authenticate and run SECO FW</li>
<li>The SCU ROM loads the second container from the boot media; this container always has the SCFW and can be signed using the customer key</li>
<li>SCFW is loaded to SCU TCM</li>
<li>SCU ROM will then configure the DDR</li>
<li>SCU ROM will start the SCFW</li>
</ul>
<p>From this point SCFW takes over and loads any image to the Arm Cortex-M or Cortex-A cores.</p>
<h3 id="downloading-and-building-scfw">Downloading and building SCFW</h3>
<p>Download the Arm GCC toolchain from here:</p>
<p><a href="https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads">https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads</a></p>
<p>Export the toolchain to compile SCFW:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="go">mkdir ~/gcc_toolchain
cp ~/Downloads/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2 ~/gcc_toolchain/
cd ~/gcc_toolchain/
tar -xvjf gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2
export TOOLS=~/gcc_toolchain/
</span></code></pre></div></div>
<p>The latest porting kit can be found here:</p>
<p>https://www.nxp.com/webapp/sps/download/license.jsp?colCode=L4.14.62_1.0.0_Beta_SCFWKIT&appType=file2&location=null&DOWNLOAD_ID=null&lang_cd=en</p>
<p>After the SCFW porting kit is downloaded and un-tar, navigate into <code class="highlighter-rouge">packages</code> and run the binary file inside:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">cd</span> <download-dir>/packages/
<span class="gp">$</span><span class="w"> </span><span class="nb">chmod </span>a+x imx-scfw-porting-kit-1.0.bin
<span class="gp">$</span><span class="w"> </span>./imx-scfw-porting-kit-1.0.bin
</code></pre></div></div>
<p>Navigate inside the newly created “imx-scfw-porting-kit-0.7” and into “src”. Extract the desired SCFW porting kit.</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">cd </span>imx-scfw-porting-kit-1.0/
<span class="gp">$</span><span class="w"> </span><span class="nb">tar</span> <span class="nt">-xvf</span> src/scfw_export_mx8qx_b0.tar.gz
<span class="gp">$</span><span class="w"> </span><span class="nb">cd </span>scfw_export_mx8qx_b0/
</code></pre></div></div>
<p class="notice--info">The tar file extracted will be different depending on which board is being used.</p>
<p>All the code that is specific to a board configuration is under “platform/board/mx8qxp_mek/board.c”</p>
<p>To compile SCFW type the following command:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>make qx <span class="nv">B</span><span class="o">=</span>mek <span class="nv">R</span><span class="o">=</span>B0
</code></pre></div></div>
<p>All the files resulting from compilation can be found inside build_mx8qx/</p>Andres Lopez de VergaraThe newly released i.MX 8QXP introduces a new concept for manipulating resource allocation, power, clocking and IO configuration and muxing. Due to the architecture complexity of this new chip, a System Controller Unit (SCU) has been added to the system. The SCU is a Arm Cortex-M4 core and is the first processor to boot in the i.MX 8QXP design.Enabling Cortex-M4 on i.MX 8QXP MEK2018-11-08T14:48:19-02:002018-11-08T14:48:19-02:00https://imxdev.gitlab.io/tutorial/Enabling_Cortex-M4_on_i.MX_8QXP_MEK<p>The <code class="highlighter-rouge">i.MX 8QuadXPlus Multisensory Enablement Kit (MEK)</code> is a NXP development
platform based on Cortex A-35 + Cortex-M4 cores. Built with high-level integration
to support graphics, video, image processing, audio, and voice functions, the i.MX
8X processor family is ideal for safety-certifiable and efficient performance
requirements.</p>
<p>This tutorial shows how to enable the Cortex-M4 using the MCUXpresso SDK package
and loading the binary from the network.</p>
<p class="notice--info"><strong>NOTE</strong>: It is also possible to load the Cortex-M4 image from the SCFW using the
<code class="highlighter-rouge">imx-mkimage</code> utility. Please see next blog posts for this tutorial.</p>
<h1 id="setting-up-the-machine">Setting up the machine</h1>
<p class="notice--info"><strong>NOTE</strong>: This shows the procedure for a Linux environment. For the Windows OS,
please see the <strong>Getting Started</strong> documentation on the SDK package.</p>
<ul>
<li>Install <code class="highlighter-rouge">cmake</code> on the host machine:</li>
</ul>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo apt-get install cmake
</code></pre></div></div>
<ul>
<li>Download the <code class="highlighter-rouge">armgcc</code> toolchain from
<a href="https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2">here</a>
and export the location as <code class="highlighter-rouge">ARMGCC_DIR</code>:</li>
</ul>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ export ARMGCC_DIR=<your_path_to_arm_gcc>/gcc-arm-none-eabi-5_4-2016q2/
</code></pre></div></div>
<p class="notice--info"><strong>NOTE</strong>: The <code class="highlighter-rouge">ARMGCC_DIR</code> variable needs to be exported on the terminal used
for compilation.</p>
<p>To setup the TFTP server on the host machine, follow the first two sections on
<a href="https://imxdev.gitlab.io/tutorial/How_to_boot_Kernel_and_File_System_from_the_network/">this</a>
blog post (<em>Configuring your Host PC for TFTP</em> and <em>Configuring your Host PC for NFS</em>).</p>
<h1 id="downloading-the-sdk">Downloading the SDK</h1>
<p>Download the <a href="https://mcuxpresso.nxp.com/en/welcome">MCUXpresso SDK</a> following
these steps:</p>
<ul>
<li>
<p>Click on “<em>Select Development Board</em>”;</p>
</li>
<li>
<p>Select <code class="highlighter-rouge">MEK-MIMX8QX</code> under “<em>Select a Device, Board, or Kit</em>” and click on
“<em>Build MCUXpresso SDK</em>” on the right;</p>
</li>
<li>
<p>Select “<em>Host OS</em>” as <code class="highlighter-rouge">Linux</code> and “<em>Toolchain/IDE</em>” as <code class="highlighter-rouge">GCC ARM Embedded</code>;</p>
</li>
<li>
<p>Add “FreeRTOS” and all the wanted Middleware and hit “<em>Request Build</em>”;</p>
</li>
<li>
<p>Wait for the SDK to build and download the package.</p>
</li>
</ul>
<h1 id="building-the-image">Building the image</h1>
<p>All demos and code examples available on the SDK package are located in the
directory <code class="highlighter-rouge"><<SDK_dir>>/boards/mekmimx8qx/</code>. This tutorial shows how to build
and flash the <code class="highlighter-rouge">hello_world</code> demo but similar procedures can be applied for any
example (demo, driver, multicore, etc) on the SDK.</p>
<ul>
<li>To build the demo, enter the <em>armgcc</em> folder under the demo directory and make
sure that the <code class="highlighter-rouge">ARMGCC_DIR</code> variable is set correctly.</li>
</ul>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cd ~/SDK_2.3.0_MEK-MIMX8QX/boards/mekmimx8qx/demo_apps/hello_world/armgcc
$ export ARMGCC_DIR=<your_path_to_arm_gcc>/gcc-arm-none-eabi-5_4-2016q2/
</code></pre></div></div>
<ul>
<li>Run the <code class="highlighter-rouge">build_release.sh</code> script to build the code.</li>
</ul>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ./build_release.sh
</code></pre></div></div>
<p class="notice--info"><strong>NOTE</strong>: If needed, give the script execution permission by running <code class="highlighter-rouge">chmod +x build_release.sh</code>.</p>
<ul>
<li>This generates the M4 binary (<code class="highlighter-rouge">hello_world.bin</code>) under the <em>release</em> folder. Copy
this image to the <em>/tftpboot/</em> directory on the host PC.</li>
</ul>
<p class="notice--info"><strong>NOTE</strong>: This procedure shows how to build the M4 image that runs on TCM. To run
the image from DDR, use the <code class="highlighter-rouge">build_ddr_release.sh</code> script to build the binary under
the <em>ddr_release</em> folder.</p>
<h1 id="flashing-the-image">Flashing the image</h1>
<ul>
<li>
<p>Open two serial consoles, one for <code class="highlighter-rouge">/dev/ttyUSB0</code> for Cortex-A35 to boot Linux,
and one for <code class="highlighter-rouge">/dev/ttyUSB1</code> for Cortex-M4 to boot the SDK image.</p>
</li>
<li>
<p>On the A35 console, with a SD Card with U-Boot, stop the booting process and
enter the following commands to load the M4 binary to TCM:</p>
</li>
</ul>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>=> dhcp
=> setenv serverip <ip_from_host_pc>
=> tftp 0x88000000 hello_world.bin
=> dcache flush
=> bootaux 0x88000000
</code></pre></div></div>
<p>Then the M4 core will load the image to the <code class="highlighter-rouge">/dev/ttyUSB1</code> console.</p>Vanessa Ayumi MaegimaThe i.MX 8QuadXPlus Multisensory Enablement Kit (MEK) is a NXP development platform based on Cortex A-35 + Cortex-M4 cores. Built with high-level integration to support graphics, video, image processing, audio, and voice functions, the i.MX 8X processor family is ideal for safety-certifiable and efficient performance requirements.i.MX 8QXP MEK launch and preview2018-11-07T13:34:56-02:002018-11-07T13:34:56-02:00https://imxdev.gitlab.io/tutorial/imx_8qxp_launch_and_preview<p>The i.MX 8QXP MEK is the latest release from NXP’s i.MX 8 family. This is the most powerful i.MX to date and promises capabilities directed to the industrial and automotive industries.</p>
<p>The i.MX 8QXP MEK has CPU board has the following characteristics:</p>
<ul>
<li>NXP i.MX8QXP (4X ARM Cortex A35 + 1 ARM Cortex M4)</li>
<li>32-bit LPDDR4 memory (DDR3L w/ ECC option available)</li>
<li>1 x GC7000Lite</li>
<li>NXP PF8100 PMIC</li>
<li>1 x USB3 OTG w/PHY</li>
<li>Tensilica HiFi4 DSP</li>
<li>VPU 4K h.265 decode</li>
<li>VPU 1080p h.264 enconde</li>
<li>2 x MIPI DSI/LVDS combo output (required daughter card)</li>
<li>1 x MIPI CSI input</li>
</ul>
<p><img src="https://imxdev.gitlab.io/images/imx8qxp-top.jpg" /></p>
<p>Additionally the i.MX 8QXP MEK can be connected to the MCIMX8-8X-BB baseboard. This baseboard provides the following expansions devices:</p>
<ul>
<li>1 x I2C auxiliary connector</li>
<li>1 x tamper header</li>
<li>1 x parallel CSI connector</li>
<li>1 x UART</li>
<li>2 x CAN connectors</li>
<li>1 x Audio in/out connector (CS42888 audio card required)(bundled)</li>
<li>1 x 10/100/1000 ethernet connector (muxed w/ audio port)</li>
<li>1 x MikroBUS™ interface</li>
<li>1 x Arduino connector</li>
</ul>
<p><img src="https://imxdev.gitlab.io/images/imx8qxp-baseboard.jpg" /></p>
<p>Full block diagram below:</p>
<p><img src="https://imxdev.gitlab.io/images/8qxp_block_diagram.png" /></p>Andres Lopez de VergaraThe i.MX 8QXP MEK is the latest release from NXP’s i.MX 8 family. This is the most powerful i.MX to date and promises capabilities directed to the industrial and automotive industries.How to dump the SDCard content to an image file2018-08-22T06:58:50-03:002018-08-22T06:58:50-03:00https://imxdev.gitlab.io/tutorial/How_to_dump_the_SDCard_content_to_an_image_file<p>This post shows a way to dump the content of a booting SDCard to an image file
with purpose of duplicating the SDCard or sharing its image.</p>
<h1 id="determine-the-origin-sdcard-blocksize-and-the-number-of-sectors-to-be-copied">Determine the origin SDCard blocksize and the number of sectors to be copied</h1>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 7.3 GiB, 7780433920 bytes, 15196160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 34815 32768 16M 53 OnTrack DM6 Aux3
/dev/sdb2 * 34816 67583 32768 16M c W95 FAT32 (LBA)
/dev/sdb3 67584 190463 122880 60M 83 Linux
</code></pre></div></div>
<p>The line <code class="highlighter-rouge">Units: sectors of 1 * 512 = 512 bytes</code> describes the size of a sector
on this SDCard. In this example, it’s <strong>512</strong> bytes.</p>
<p>In this example, the total number of used sectors is it’s <strong>32768</strong> for <code class="highlighter-rouge">/dev/sdb1</code> plus <strong>32768</strong> for <code class="highlighter-rouge">/dev/sdb2</code> plus <strong>122880</strong> for <code class="highlighter-rouge">/dev/sdb3</code>, a total of <strong>188416</strong> sectors.</p>
<h1 id="dump-it-in-an-image-file">Dump it in an image file</h1>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo dd if=/dev/sdb of=dump.sdcard bs=512 count=188416
</code></pre></div></div>
<h1 id="duplicate-the-image-in-another-sdcard">Duplicate the image in another SDCard</h1>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo dd if=dump.sdcard of=/dev/sdX
</code></pre></div></div>Daiane Angolinidaiane.list@gmail.comThis post shows a way to dump the content of a booting SDCard to an image file with purpose of duplicating the SDCard or sharing its image.How to run and debug the Cortex-M4 on i.MX 7ULP using IAR Embedded Workbench2018-08-20T11:29:02-03:002018-08-20T11:29:02-03:00https://imxdev.gitlab.io/tutorial/How_to_run_and_debug_the_Cortex-M4_on_i.MX_7ULP_using_IAR_Embedded_Workbench<p>This post covers the required steps to setup the MCUXpresso BSP and IAR toolchain to
run and debug the Cortex-M4 on the i.MX 7ULP SoC.</p>
<h1 id="hardware-needed">Hardware needed</h1>
<p><img src="/images/imx7ulp_j-link.jpg" align="middle" width="800" /></p>
<p>The picture above shows the hardware used in this tutorial. It contains the
MCIMX7ULP-EVK board and <a href="https://www.segger.com/products/debug-probes/j-link/">J-Link</a>
JTAG probe. Equivalent JTAG probes should also work.
The MCIMX7ULP-EVK board uses the low wire count SWD (Serial Wire Debug) configuration for accessing
the Cortex-M4.</p>
<h1 id="toolchain">Toolchain</h1>
<p>The <a href="https://www.iar.com/iar-embedded-workbench/#!?architecture=Arm">IAR Embedded Workbench IDE</a>
needs to be installed in a Windows machine.</p>
<p class="notice--info">Note this software is not free and you need to pay attention on the limitations
of the evaluation license.</p>
<h1 id="board-support-package">Board Support Package</h1>
<p>The BSP for Cortex-M4 is called “SDK” (Software Development Kit) and it can be
downloaded at <a href="https://mcuxpresso.nxp.com/en/welcome">MCUXpresso</a> website.</p>
<p>The steps to download the SDK and middleware source codes are explained on the
section “Downloading the SDK” in
<a href="http://imxdev.gitlab.io/tutorial/How_to_build_and_flash_a_bootable_image_for_Cortex-M4_on_i.MX_7ULP/">this post</a>:</p>
<p>The previous link explains how to build the image using GCC in a Linux
machine, so this method is not covered here.</p>
<p>After downloading the SDK, extract the zip file. The folder structure is shown below:</p>
<p><img src="/images/imx7ulp_sdk_folder.jpg" align="middle" /></p>
<h1 id="opening-projects-on-iar-embedded-workbench-ide">Opening projects on IAR Embedded Workbench IDE</h1>
<p>The application examples are stored in the folder below:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><sdk dir>\EVK-MCIMX7ULP\boards\evkmcimx7ulp\demo_apps
</code></pre></div></div>
<p>At the time of the writing of this post, the SDK version is 2.4.0 and there are 9 demo
examples on SDK. The example <code class="highlighter-rouge">power_mode_switch</code> and <code class="highlighter-rouge">wireless_uart_bridge</code> so far
are the only ones capable to boot properly the Cortex-A7 core (Linux). To know if the
application example provides the required PMIC (Power Management IC) commands to
fully initialize the Cortex-A7 core, refer to demo’s <code class="highlighter-rouge">readme.txt</code> file. The section
“Board Settings” inside the readme file details if the example is supported by the Linux BSP.</p>
<p>To open the project, double click the workspace file <code class="highlighter-rouge">*.eww</code>.</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><sdk dir>\EVK-MCIMX7ULP\boards\evkmcimx7ulp\demo_apps\power_mode_switch\iar\power_mode_switch.eww
</code></pre></div></div>
<p>There are 2 ways for loading the code to the Cortex-M4, the first method is to
load the code to the RAM (TCM RAM), the second is to program the external QuadSPI
flash memory.</p>
<p>Loading the code to the RAM is faster for rapid debugging when several compile-debug
interactions are needed, but it’s limited to 256kB for the code size, including stack.</p>
<p>To run the code from the RAM follow steps below:</p>
<p>1: Right click on <strong>project name -> Options:</strong></p>
<p><img src="/images/imx7ulp_IAR_option.jpg" align="middle" /></p>
<p>2: Click on <strong>Linker</strong> category, browse for the linker file to compile for the RAM memory:</p>
<p><img src="/images/imx7ulp_IAR_linker.jpg" align="middle" /></p>
<p>3: Click on <strong>Debugger</strong> category and select the JTAG probe model attached to the board:</p>
<p><img src="/images/imx7ulp_IAR_debugger.jpg" align="middle" /></p>
<p>4: Click on the model of your debugger probe and at sub-category <strong>Setup</strong>, configure the
parameters for the probe.
For this particular example it’s being used the J-Link, so click on J-Link/J-trace:</p>
<p><img src="/images/imx7ulp_IAR_jlink_1.jpg" align="middle" /></p>
<p>On <strong>Connection</strong> tab, make sure to select SWD instead of JTAG, as MCIMX7ULP-EVK uses SWD.</p>
<p><img src="/images/imx7ulp_IAR_jlink_2.jpg" align="middle" /></p>
<p>On <strong>Breakpoints</strong> tab leave as below:</p>
<p><img src="/images/imx7ulp_IAR_jlink_3.jpg" align="middle" /></p>
<h1 id="compiling-and-downloading-the-code-to-the-ram">Compiling and downloading the code to the RAM</h1>
<p>To compile and download the code, click on the green arrow <code class="highlighter-rouge">Download and Debug (CTRL+D)</code></p>
<p><img src="/images/imx7ulp_IAR_download_debug.jpg" align="middle" /></p>
<p>If the project doesn’t have the ARM core selected, just for the first time,
select the Cortex-M4 as shown below:</p>
<p><img src="/images/imx7ulp_IAR_jlink_cortex-m4.jpg" align="middle" /></p>
<p>Code is then compiled, downloaded to the RAM and stops at the beginning of <code class="highlighter-rouge">main()</code>
routine. By pressing the arrow <code class="highlighter-rouge">GO (F5)</code>, the code is executed.</p>
<p><img src="/images/imx7ulp_IAR_main.jpg" align="middle" /></p>
<p>The <code class="highlighter-rouge">power_mode_switch</code> example communicates though SCI @ 115200 8N1 (115200 baud rate;
8 data bits; No parity; One stop bit; No flow control). By pressing
“GO (F5)” the terminal receives data from Cortex-M4 SCI.</p>
<p>To add Breakpoints, right click on the line from C code you want to break at and
select <code class="highlighter-rouge">Toggle Breakpoint (code)</code></p>
<p class="notice--info">If any power cycle occurs, the code is lost, as data in RAM is not retained.</p>
<h1 id="running-the-code-from-the-quadspi-external-flash">Running the code from the QuadSPI external flash</h1>
<p>Since the JTAG probe can’t communicate directly to the QuadSPI flash memory,
the process to program this non volatile memory follows a different procedure.
The binary needs to be copied to the MicroSD FAT Linux partition and then flash
to QuadSPI memory using U-boot.</p>
<p>The instructions can also be viewed on the “Getting Started with MCUXpresso
SDK for i.MX 7ULP.pdf”. The file can be found inside the <code class="highlighter-rouge"><sdk dir>\EVK-MCIMX7ULP\docs</code>
folder. Refer to section: “6 Running an application from QSPI flash” for details.</p>
<p>In summary, the procedures are:</p>
<p>1: Similar as explained previously, go to <strong>Options -> Linker</strong> and
select the flash linker file, as shown below:</p>
<p><img src="/images/imx7ulp_IAR_linker_flash.jpg" align="middle" /></p>
<p>2: Click on <strong>Make (F7)</strong>. After the code compiles, the <code class="highlighter-rouge">sdk20-app.bin</code> file is
created in the folder:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><sdk dir>\EVK-MCIMX7ULP\boards\evkmcimx7ulp\demo_apps\power_mode_switch\iar\debug
</code></pre></div></div>
<p>This file needs to be converted to a specific format before downloading to QuadSPI
memory and this is done by the <code class="highlighter-rouge">imgutil</code> script that comes with the SDK package located at:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><sdk dir>\EVK-MCIMX7ULP\tools\imgutil
</code></pre></div></div>
<p>The <code class="highlighter-rouge">imgutil</code> script must be executed using Bash on a native Linux machine or
using Bash emulated in Windows.</p>
<h2 id="converting-the-binary-to-image-file-using-a-native-windows-machine">Converting the binary to image file using a native Windows machine</h2>
<p>In case you want to do all the procedures in a native Windows 10 machine, the
Linux bash must be installed in Windows. There are several options to run Linux
over Windows. This example covers the Ubuntu Bash in Windows 10. To install Ubuntu
Bash on Windows 10 follow <a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10">this procedure</a>.</p>
<p>In case you want to run this procedure in a Linux machine, refer to <strong>append</strong> of this post.</p>
<p>To convert the <code class="highlighter-rouge">sdk20-app.bin</code> to <code class="highlighter-rouge">sdk20-app.img</code> follow these steps:</p>
<p>1: Copy the binary file <code class="highlighter-rouge">sdk20-app.bin</code> generated by IAR to the folder
<code class="highlighter-rouge"><sdk dir>\EVK-MCIMX7ULP\tools\imgutil\evkmcimx7ulp</code></p>
<p>2: Using the Ubuntu Bash, navigate to the board folder:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cd /mnt/c/<sdk dir>/EVK-MCIMX7ULP/tools/imgutil/evkmcimx7ulp
</code></pre></div></div>
<p>3: Execute the mkimg.sh script:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ./mkimg.sh flash
</code></pre></div></div>
<p>4: Copy the <code class="highlighter-rouge">sdk20-app.img</code> file to the MicroSD card containing the Embedded Linux image.
The file needs to be copied to the FAT partition <code class="highlighter-rouge">Boot</code> root folder (where <code class="highlighter-rouge">zImage</code>
resides).</p>
<p>5: Remove the MicroSD from the computer.</p>
<h2 id="flashing-the-quadspi-memory">Flashing the QuadSPI Memory</h2>
<p>Insert the MicroSD into the MCIMX7ULP-EVK board and connect the USB cable to the
Debug USB connector. 2 virtual <code class="highlighter-rouge">COM</code> ports should be mounted. One for the Cortex-A7
and other for the Cortex-M4. Both <code class="highlighter-rouge">COM</code> ports must be configured @115200 8N1 baud.</p>
<p>On the <code class="highlighter-rouge">COM</code> prompt for Cortex-A7 (Linux) press any key within 3 seconds after
power up to stop auto boot and enable the U-boot prompt. In this step you should
have this screen:</p>
<p><img src="/images/imx7ulp_prompt_A7.jpg" align="middle" /></p>
<p>Execute below 4 commands to download the <code class="highlighter-rouge">*.img</code> file from MicroSD card
to the QuadSPI memory:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>=> sf probe
=> sf erase 0x0 0x20000
=> fatload mmc 0:1 0x62000000 sdk20-app.img
=> sf write 0x62000000 0x0 0x20000
</code></pre></div></div>
<p>Done, you have completed the QuadSPI programming.</p>
<p>Now you can power cycle the board and the 2 cores send data to its respective
<code class="highlighter-rouge">COM</code> port. The M4 loads the application <code class="highlighter-rouge">Power Mode Switch Task</code>, and Cortex-A7
loads the Linux, like below:</p>
<p><img src="/images/imx7ulp_prompt_A7_M4.jpg" align="middle" /></p>
<p>If the Cores can’t communicate to console, remember to disconnect the JTAG flat
cable, or press <code class="highlighter-rouge">RUN</code> on the IAR IDE.</p>
<h1 id="running-and-debugging-the-code-from-quadspi">Running and Debugging the code from QuadSPI</h1>
<p>Attach the J-Link probe to the board, power on and press the IAR button
<code class="highlighter-rouge">Debug without Downloading</code>. The code from QuadSPI is executed and stops
at <code class="highlighter-rouge">main()</code> routine. Note that if the “standard” <code class="highlighter-rouge">Download and Debug (Ctrl+D)</code>
button is pressed instead, it will also work, but warnings will be shown informing
the flash could not be programmed. This is caused by the IAR flashloader not being
able to program the QuadSPI memory.</p>
<p>If a new software version needs to be loaded to the Cortex-M4 QuadSPI memory, all the
procedures to compile, convert the binary file and flash using U-boot must be
executed again.</p>
<h2 id="append-converting-the-binary-to-image-file-using-a-native-linux-machine">Append: Converting the binary to image file using a native Linux machine</h2>
<p>To convert the <code class="highlighter-rouge">sdk20-app.bin</code> to <code class="highlighter-rouge">sdk20-app.img</code> using a Linux machine, follow
these steps:</p>
<p>1: In Windows, copy the folder imgutil <code class="highlighter-rouge"><sdk dir>\EVK-MCIMX7ULP\tools\imgutil</code>
to a memory stick:</p>
<p>2: Copy the binary file <code class="highlighter-rouge">sdk20-app.bin</code> generated by IAR to the folder “evkmcimx7ulp”
to the memory stick. Remove the memory stick from Windows.</p>
<p>3: Attach the memory stick to a Linux Machine</p>
<p>4: Copy the folder <code class="highlighter-rouge">imgutil</code> to your Linux PC.</p>
<p>4.1: Navigate to the evkmcimx7ulp folder and execute the mkimg.sh script:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ./mkimg.sh flash
</code></pre></div></div>
<p>By executing this script, the file <code class="highlighter-rouge">sdk20-app.img</code> is generated.
In case issues occur, verify the files permissions, If needed, give full permissions
to all <code class="highlighter-rouge">imgutil</code> folder by executing <code class="highlighter-rouge">$ chmod 777 -R imgutil</code>.</p>
<p>5: Copy the <code class="highlighter-rouge">sdk20-app.img</code> file to the MicroSD card containing the Embedded Linux image.
The file needs to be copied to the FAT partition <code class="highlighter-rouge">Boot</code> root folder (where <code class="highlighter-rouge">zImage</code>
resides).</p>
<p>6: Remove the MicroSD from the computer. Go to section <strong>Flashing the QuadSPI Memory</strong>.</p>Marcelo Macedompmacedo@gmail.comThis post covers the required steps to setup the MCUXpresso BSP and IAR toolchain to run and debug the Cortex-M4 on the i.MX 7ULP SoC.How to use dual display on i.MX8 including 4k decoding2018-06-13T10:34:49-03:002018-06-13T10:34:49-03:00https://imxdev.gitlab.io/tutorial/How_to_use_dual_display_on_i.MX8_including_4k_decoding<p>In this first post about <code class="highlighter-rouge">i.MX 8M</code> SoCs, you can check how easy is to use one or two HDMI displays and decoding 4k video file at 60fps in the <a href="https://www.nxp.com/products/processors-and-microcontrollers/applications-processors/i.mx-applications-processors/i.mx-8-processors/i.mx-8m-family-armcortex-a53-cortex-m4-audio-voice-video:i.MX8M">i.MX 8MQ EVK</a>.</p>
<h1 id="4k-video-playback">4k video playback</h1>
<p>The i.MX8MQ has the capability to decoder H.264 and H.265 4k videos at 60 FPS with HDR support.
For this, let’s start <a href="https://www.nxp.com/webapp/Download?colCode=L4.9.51_IMX8MQ_GA&appType=license&location=null&Parent_nodeId=1337699481071706174845&Parent_pageType=product">downloading</a> and deploying the <code class="highlighter-rouge">Linux 4.9.51_1.0.0_GA</code> image from the NXP web site to the SDCard:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo dd if=fsl-image-validation-imx-xwayland-imx8mqevk.sdcard of=/dev/sbX
</code></pre></div></div>
<p>Download a 4k video sample for the test. I would like to suggest the <a href="http://4kmedia.org">4kmedia.org</a> website and copy it to the SDCard:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo cp Download/4k_video_sample /media/USER/ROOTFS_PATH/home/root; sync
</code></pre></div></div>
<p class="notice--warning">Depending of the 4k video size, it may be necessary to change the SDCard free space in order to copy the file to the SDCard. I recommend to use the GParted for it.</p>
<p>The HDMI output is configured to support the 3820x2160 size by default. So, boot the board and enter with the GStreamer pipeline below. Do not forget to use the <code class="highlighter-rouge">force-hantrotile=true</code> property to enable the video framebuffer compression (DTRC):</p>
<h3 id="for-h265-with-hdr-container-on-mp4-format">For H.265 with HDR container on .mp4 format</h3>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gst-launch-1.0 filesrc location=4k_video_sample.mp4 ! video/quicktime ! qtdemux ! queue ! vpudec ! queue ! kmssink force-hantrotile=true
</code></pre></div></div>
<iframe width="560" height="315" src="https://www.youtube.com/embed/XOMrtr1ripI" frameborder="0" allowfullscreen=""></iframe>
<h1 id="dual-display">Dual display</h1>
<p>The i.MX 8MQ has also the capability to use up to two HDMI displays output(4k@60 + 720p@60). In order to accomplish that, the board uses the <code class="highlighter-rouge">MIPI-DSI</code> connector with the <a href="https://www.nxp.com/part/IMX-MIPI-HDMI">IMX-MIPI-HDMI</a> adapter:</p>
<center><img src="/images/IMX-MIPI-HDMI.png" alt="IMX-MIPI-HDMI adapter" align="middle" width="800" /></center>
<p>Using the same image from the last section, just download a HD video and copy it to the board too. I could found a 720p@60fps sample video in the <a href="https://kodi.wiki/view/Samples">kodi wiki</a>:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo cp Download/720p_video_sample /media/USER/ROOTFS_PATH/home/root
</code></pre></div></div>
<p>The last point you need to use the dual display mode is by changing the <code class="highlighter-rouge">.dtb</code> file. So start the board and change the U-Boot <code class="highlighter-rouge">fdt_file</code> variable:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">=></span><span class="w"> </span>setenv fdt_file fsl-imx8mq-evk-dual-display.dtb
<span class="gp">=></span><span class="w"> </span>saveenv
</code></pre></div></div>
<p>Reset the board and enter with the GStreamer pipelines below:</p>
<h3 id="for-h265-container-on-mp4-format">For H.265 container on .mp4 format</h3>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gst-launch-1.0 filesrc location=4k_video_sample.mp4 typefind=true ! video/quicktime ! qtdemux ! queue max-size-time=0 ! vpudec ! queue max-size-time=0 ! kmssink force-hantrope=true sync=false &
</code></pre></div></div>
<h3 id="for-h264-container-on-ts-format">For H.264 container on .ts format</h3>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gst-launch-1.0 filesrc location=720p_video_sample.ts typefind=true ! video/mpegts ! tsdemux ! queue max-size-time=0 ! vpudec ! queue max-size-time=0 ! waylandsink
</code></pre></div></div>
<iframe width="560" height="315" src="https://www.youtube.com/embed/ZvUFS4l9txQ" frameborder="0" allowfullscreen=""></iframe>Marco Antonio Franchimarcofrk@gmail.comIn this first post about i.MX 8M SoCs, you can check how easy is to use one or two HDMI displays and decoding 4k video file at 60fps in the i.MX 8MQ EVK.i.MX 7ULP possible fix for U-Boot hang on “Starting kernel”2018-06-11T09:23:24-03:002018-06-11T09:23:24-03:00https://imxdev.gitlab.io/tutorial/i.MX_7ULP_possible_fix_for_U-Boot_hang_on_Starting_kernel<p>Sometimes when working with i.MX 7ULP the Cortex-A7 loading process can get stuck
in the “Starting kernel” message. This can happen for many reasons, but a very
common cause for this hang is the lack of the Cortex-M4 image that enables all
needed power rails for Cortex-A7 to boot correctly on i.MX 7ULP.</p>
<p><img src="/images/ulp_hang.png" /></p>
<p>The picture above shows the A7 booting process stuck when there is no content on
QSPI flash.</p>
<p>This post shows how to flash the bootable M4 image to QSPI and enable booting the
A7 core.</p>
<h1 id="getting-the-m4-bootable-image">Getting the M4 bootable image</h1>
<p>The SDK package for the i.MX 7ULP Cortex-M4 can be found at
<a href="https://mcuxpresso.nxp.com/en/welcome">MCUXpresso</a>.</p>
<ul>
<li>Copy the bootable M4 image <code class="highlighter-rouge">power_mode_switch.img</code> to the boot partition of the
SD card.</li>
</ul>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cp <SDK_dir>/boards/evkmcimx7ulp/demo_apps/power_mode_switch/power_mode_switch.img \
<path_to_boot_partition>
</code></pre></div></div>
<p class="notice--info">To learn how to download and build the SDK package for M4, please see
<a href="https://imxdev.gitlab.io/tutorial/How_to_build_and_flash_a_bootable_image_for_Cortex-M4_on_i.MX_7ULP/">this</a> post.</p>
<h1 id="flashing-the-m4-image-to-qspi">Flashing the M4 image to QSPI</h1>
<ul>
<li>
<p>Open two serial consoles, one at <code class="highlighter-rouge">/dev/ttyUSB0</code> for A7 to boot Linux and other
at <code class="highlighter-rouge">/dev/ttyUSB1</code> for M4 to boot the SDK image.</p>
</li>
<li>
<p>On the A7 console, stop U-Boot and enter the following commands to load the
M4 binary to RAM and flash it in the QSPI memory:</p>
</li>
</ul>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>=> sf probe
=> sf erase 0x0 0x20000
=> fatload mmc 0:1 0x62000000 sdk20-app.img
=> sf write 0x62000000 0x0 0x20000
</code></pre></div></div>
<p>After flashing the M4 image to QSPI, reboot the board to boot both cores. This
fixes the loading hang on Cortex-A7.</p>
<p>This procedure works for booting on ‘Dual Boot’ mode (Cortex-M4 as the primary
core and Cortex-A7 as the auxiliary core). For details about different boot modes
and how to boot in each one of them check <a href="https://imxdev.gitlab.io/tutorial/i.MX_7ULP_Heterogeneous_Architecture_and_Different_Boot_Modes/">this</a>
post.</p>Vanessa Ayumi MaegimaSometimes when working with i.MX 7ULP the Cortex-A7 loading process can get stuck in the “Starting kernel” message. This can happen for many reasons, but a very common cause for this hang is the lack of the Cortex-M4 image that enables all needed power rails for Cortex-A7 to boot correctly on i.MX 7ULP.i.MX 7ULP Heterogeneous Architecture and Different Boot Modes2018-06-08T09:03:40-03:002018-06-08T09:03:40-03:00https://imxdev.gitlab.io/tutorial/i.MX_7ULP_Heterogeneous_Architecture_and_Different_Boot_Modes<p>The i.MX 7ULP is an heterogeneous SoC that presents a power domain architecture
different than the other i.MX SoCs. In this architecture, both cores have control
of the system power and this allows booting in different modes by changing the
primary and auxiliary cores according to the power saving strategy.</p>
<p>This post presents the three boot modes supported by i.MX 7ULP and how to boot in
each one of them.</p>
<h1 id="boot-modes">Boot modes</h1>
<ul>
<li>
<p><strong>Dual Boot</strong>: M4 works as the primary core, loading from QSPI flash and booting
A7 as the auxiliary core from eMMC/SD. This is the <strong>default</strong> boot mode for i.MX
7ULP.</p>
</li>
<li>
<p><strong>Low Power Boot</strong>: M4 works as the primary core, loading from QSPI flash and
booting A7 on demand.</p>
</li>
<li>
<p><strong>Single Boot</strong>: A7 works as the primary core controlling the whole system and
booting M4. This is <strong>not</strong> the typical boot mode for the i.MX 7ULP.</p>
</li>
</ul>
<h1 id="source-code">Source code</h1>
<p>The U-Boot source code for i.MX 7ULP can be found at
<a href="https://source.codeaurora.org/external/imx/uboot-imx/log/?h=imx_v2017.03_4.9.88_2.0.0_ga">uboot-imx</a>.</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ git clone https://source.codeaurora.org/external/imx/uboot-imx
$ cd uboot-imx
$ git checkout imx_v2017.03_4.9.88_2.0.0_ga
</code></pre></div></div>
<p>The SDK package for the i.MX 7ULP Cortex-M4 can be found at
<a href="https://mcuxpresso.nxp.com/en/welcome">MCUXpresso</a>.</p>
<p class="notice--info">To learn how to download and build the SDK package for M4, please see
<a href="https://imxdev.gitlab.io/tutorial/How_to_build_and_flash_a_bootable_image_for_Cortex-M4_on_i.MX_7ULP/">this</a> post.</p>
<h2 id="dual-boot">Dual Boot</h2>
<p>To boot on <code class="highlighter-rouge">Dual Boot</code> (<strong>default</strong>), make sure that <code class="highlighter-rouge">SW1</code> is set as <code class="highlighter-rouge">1001</code>.</p>
<p><img src="/images/ulp_dual_boot.jpg" /></p>
<p>M4 loads from QSPI flash and A7 loads from SD card.</p>
<h2 id="low-power-boot">Low Power Boot</h2>
<p>To boot on <code class="highlighter-rouge">Low Power Boot</code>, make sure that <code class="highlighter-rouge">SW1</code> is set as <code class="highlighter-rouge">101x</code>.</p>
<p><img src="/images/ulp_lp_boot.jpg" /></p>
<p>Only M4 boots on this mode and M4 can be programmed to boot A7 if needed (on
demand). In this boot mode, the M4 image must be already flashed to QSPI.</p>
<h2 id="single-boot">Single Boot</h2>
<p>To boot on <code class="highlighter-rouge">Single Boot</code>, make sure that <code class="highlighter-rouge">SW1</code> is set as <code class="highlighter-rouge">1000</code>.</p>
<p><img src="/images/ulp_single_boot.jpg" /></p>
<p>In this boot mode, the M4 image is loaded from U-Boot. To build the U-Boot image
with the M4 content, follow these commands:</p>
<ul>
<li>First, copy the the M4 bootable image (<code class="highlighter-rouge">.img</code> file) to the <code class="highlighter-rouge">uboot-imx</code>
directory and rename it to <code class="highlighter-rouge">ulp_m4.bin</code>.</li>
</ul>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cp <sdk_dir>/boards/evkmcimx7ulp/demo_apps/power_mode_switch/power_mode_switch.img \
<uboot-imx_dir>/ulp_m4.bin
</code></pre></div></div>
<p class="notice--info">For details on how to get the bootable image for M4, please see
<a href="https://imxdev.gitlab.io/tutorial/How_to_build_and_flash_a_bootable_image_for_Cortex-M4_on_i.MX_7ULP/">this</a> post.</p>
<ul>
<li>Build U-Boot with the following configuration:</li>
</ul>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ export ARCH=arm
$ export CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-
$ make mx7ulp_evk_m4boot_defconfig
$ make
</code></pre></div></div>
<p>This generates <code class="highlighter-rouge">u-boot-dtb.imx</code>. Flash it to the SD Card and boot the board. The
board will boot on Single Boot.</p>Vanessa Ayumi MaegimaThe i.MX 7ULP is an heterogeneous SoC that presents a power domain architecture different than the other i.MX SoCs. In this architecture, both cores have control of the system power and this allows booting in different modes by changing the primary and auxiliary cores according to the power saving strategy.