How to build and flash a bootable image for Cortex-M4 on i.MX 7ULP
The i.MX 7ULP processor aims on reduced power consumption (Ultra Low Power) and for this reason its architecture is a bit different than the other i.MX processors. To guarantee less power consumption, the Cortex-M4 works as the primary core and is responsible for controlling the Cortex-A7 power rails, being able to suspend A7 in run time. With this in mind, to boot an image on A7 all needed power rails must be enabled on the M4 side.
This tutorial shows how to build and flash a demo image for the M4 core in the QSPI flash with all needed configuration that allows booting along with the A7 core.
REL_SDK_ULP1_B0_2.4.0_RFP package provides a prebuilt image ready
to be flashed to the chip (
power_mode_switch.img). If the reader chooses to use
this image, copy
power_mode_switch.img to the boot partition of the SD card and
jump to the last section (Flashing the image).
Setting up the machine
NOTE: This shows the procedure on a Linux environment. For Windows OS, please see the Getting Started documentation on the SDK package.
cmakeon the host machine:
$ sudo apt-get install cmake
- Download the
armgcctoolchain from here and export the location as
$ export ARMGCC_DIR=<your_path_to_arm_gcc>/gcc-arm-none-eabi-5_4-2016q2/
ARMGCC_DIR variable needs to be exported on the terminal used
Downloading the SDK
Download the MCUXpresso SDK following these steps:
Click on “Select Development Board”;
EVK-MCIMX7ULPunder “Select a Device, Board, or Kit” and click on “Build MCUXpresso SDK” on the right;
Select “Host OS” as
Linuxand “Toolchain/IDE” as
GCC ARM Embedded;
Add “FreeRTOS” and all the wanted Middleware and hit “Request Build”;
Wait for the SDK to build and download the package.
Building the image
All demos and code examples available on the SDK package are located in the
<<SDK_dir>>/boards/evkmcimx7ulp/. This tutorial shows how to build
and flash the
power_mode_switch demo which includes all needed configuration on
M4 to boot the A7 core but the same procedure works for any example on the SDK.
- To build the demo, enter the armgcc folder under the demo directory and make
sure that the
ARMGCC_DIRvariable is set correctly.
$ cd <SDK_dir>/boards/evkmcimx7ulp/demo_apps/power_mode_switch/armgcc $ export ARMGCC_DIR=<your_path_to_arm_gcc>/gcc-arm-none-eabi-5_4-2016q2/
- Run the
build_release.shscript to build the code.
This generates the M4 binary (
sdk20-app.bin) under the release folder. To
make this binary bootable, the
imgutil utility is used to add all needed header
to the image.
sdk20-app.binto the evkmcimx7ulp folder under the imgutil tool:
$ cp sdk20-app.bin <SDK_dir>/tools/imgutil/evkmcimx7ulp
- Run the
mkimg.shscript to generate the bootable image appending the linker type used to build the binary. The linker points to the memory region where the M4 image runs and it can be whether
flashdepending on what is defined on the
CMakeLists.txtfile. In this case the image was built for
$ ./mkimg.sh ram
This generates the bootable image
sdk20-app.img. Copy this image to the boot
partition of the SD Card.
Flashing the image in the QSPI flash
Open two serial consoles, one at
/dev/ttyUSB0for A7 to boot Linux and other at
/dev/ttyUSB1for M4 to boot the SDK image.
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:
=> sf probe => sf erase 0x0 0x30000 => fatload mmc 0:1 0x62000000 sdk20-app.img => sf write 0x62000000 0x0 0x30000
NOTE: If the reader is using the prebuilt image (
replace the fatload command above accordingly.
- Reset the board to boot both cores. The M4 core loads the image from QSPI memory with the needed configuration to boot A7 and A7 fully boots Linux.