The 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.
This tutorial shows how to enable the Cortex-M4 using the MCUXpresso SDK package and loading the binary from the network.
NOTE: It is also possible to load the Cortex-M4 image from the SCFW using the imx-mkimage utility. But now we are going to focus on MCUXpresso.
Setting up the machine
- Install cmake on the host machine:
$ sudo apt-get install cmake
- Download the armgcc toolchain and export the location as ARMGCC_DIR:
$ export ARMGCC_DIR=<your_path_to_arm_gcc>/gcc-arm-none-eabi-9-2020q2/
NOTE: The ARMGCC_DIR variable needs to be exported on the terminal used for compilation.
To setup the TFTP server on the host machine:
Configuring your Host PC for TFTP
The first step is to install all the prerequisite packages for TFTP:
$ sudo apt-get install xinetd tftpd tftp
Create a TFTP folder in your desired location with root owner and the “rwx” permission for all users:
$ sudo mkdir /tftpboot
$ sudo chmod –R 777 /tftpboot
$ sudo chown –R root /tftpboot
Create a configuration file for the TFTP with the following content. (The server_args parameter must match with the folder created above)
$ cat /etc/xinetd.d/tftp
service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
}
Restart the xinetd service:
$ sudo /etc/init.d/xinetd restart
You can place any file at the TFTP folder and load it through U-Boot, you can also create symbolic links from your building directory avoiding to copy and paste your zImage and dtb files every time.
Configuring your Host PC for NFS
Install all the needed packages for NFS:
$ sudo apt-get install nfs-kernel-server
Create a folder for placing your rootfs:
Add the following line in the end of your /etc/exports file:
/tftpboot/rfs *(rw,no_root_squash,no_subtree_check)
Restart the NFS service:
$ sudo service nfs-kernel-server restart
Place your rootfs or create a symbolic link for the NFS folder.
Downloading the SDK
Download the MCUXpresso following these steps:
- Click on “Select Development Board”;
- Select MEK-MIMX8QX under “Select a Device, Board, or Kit” and click on “Build MCUXpresso SDK” on the right;
- Select “Host OS” as Linux and “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 directory <<SDK_dir>>/boards/mekmimx8qx/. This tutorial shows how to build and flash the hello_world demo but similar procedures can be applied for any example (demo, driver, multicore, etc) on the SDK.
- To build the demo, enter the armgcc folder under the demo directory and make sure that the ARMGCC_DIR variable is set correctly.
$ 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-9-2020q2/
- Run the build_release.sh script to build the code.
$ ./build_release.sh
NOTE: If needed, give the script execution permission by running chmod +x build_release.sh.
- This generates the M4 binary (hello_world.bin) under the release folder. Copy this image to the /tftpboot/ directory on the host PC.
NOTE: This procedure shows how to build the M4 image that runs on TCM. To run the image from DDR, use the build_ddr_release.sh script to build the binary under the ddr_release folder.
Flashing the image
- Open two serial consoles, one for /dev/ttyUSB0 for Cortex-A35 to boot Linux, and one for /dev/ttyUSB1 for Cortex-M4 to boot the SDK image.
- 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:
=> dhcp
=> setenv serverip <ip_from_host_pc>
=> tftp 0x88000000 hello_world.bin
=> dcache flush
=> bootaux 0x88000000
Then the M4 core will load the image to the /dev/ttyUSB1 console.