The i.MX6 SoloX processor is the first of a kind, coupling a Cortex-A9 with a Cortex-M4 core inside one chip to offer the best of both MPU and MCU worlds. The MCU is perfect for all the real-time tasks whereas the MPU can provide a great UI experience with non real-time OS such as GNU/Linux.
This blog post will detail how to build and run source code on the MCU using our Nit6_SoloX.
Before getting any further, here is a list of terms that will be used in this post:
MCC: Multi-Core Communication: protocol offered by Freescale for the MCU and MPU to exchange data
MCU: Microcontroller Unit such as the ARM Cortex-M series, here referring to the Cortex-M4
MPU: Microprocessor Unit such as the ARM Cortex-A series, here referring to the Cortex-A9
MQX: RTOS provided by Freescale to run their MCUs
RTOS: Real-Time Operating System such as MQX or FreeRTOS
Your machine is now ready to build applications for the MCU!
This section explains how to build the BSP as well as the applications for the MCU only. In order to build the BSP for the MPU, please refer to other blog posts on either Yocto or Buildroot.
~$ cd ~/mqx/
~/mqx$ export TOP=$PWD
~/mqx$ export TOOLCHAIN_ROOTDIR=$HOME/toolchains/gcc-arm-none-eabi-4_8-2014q1/
~/mqx$ cd $TOP/build/imx6sx_nit6sx_m4/make
As the BSP for our board is now built, we can build any example application provided in the MQX package. In order to have an interaction between the MPU and the MCU, you need to build a MCC application.
Below are the instructions to build the pingpong application which sends data back and forth between the cores.
Some might be interested in using an IDE to browse/modify/build the source code, note that Freescale provides instructions to use IAR Workbench (Windows only). It seems that there isn't any plan to support the SoloX MQX release inside the KSDK (Kinetis SDK) as explained in a community forum post.
Run the demo
First you need to copy the image (20150814-buildroot-nitrogen6x-mcu-demo.img.gz) provided at the beginning of this post to an SD Card. Then copy the m4_fw.bin binary to the root directory of the SD Card.
The SD Card contains the U-Boot version that enables the use of the Cortex-M4, the bootloader inside your NOR must therefore be upgraded.
U-Boot > setenv bootfile u-boot.imx U-Boot > run upgradeu
Once the upgrade is complete and the board restarted, make sure to have a clean environment:
U-Boot > env default -a
## Resetting to default environment
U-Boot > saveenv
By default, the M4 must be flashed in NOR memory, a U-Boot command has been added to look for the m4_fw.bin as the root of any external storage (SD, USB, SATA):
U-Boot > run m4update
This command will download the firmware from external storage to RAM and flash it at the offset 0x1E0000 of the NOR.
While debugging on the MCU, you might wish not to write every firmware into NOR so we've added a command that loads the M4 firmware directly from external storage.
U-Boot > setenv m4boot 'run m4boot_ext'
Before going any further, make sure to hook up the second serial port to your machine as the one marked as "console" will be used for U-Boot and the other one will display data coming from the MCU. In order to start the MCU at boot up, we need to set a variable that will tell the 6x_bootscript to load the firmware into OCRAM. If you wish to start the MCU at every boot, make sure to save this variable.
U-Boot > setenv m4enabled 1 U-Boot > boot
While the kernel is booting, you should see the following prompt on the MCU serial output:
***** MCC PINGPONG EXAMPLE *****
Please wait :
1) A9 peer is ready
Then press "S" to start the demo
Press "S" to start the demo :
Press the S key as requested above on the MCU serial console and then log into Buildroot on the MPU serial output (login is root, no password). You now need to enable the MPU side of the communication before starting the demo:
# echo 1 > /sys/bus/platform/drivers/imx6sx-mcc-test/mcctest.15/pingpong_en &
A9 mcc prepares run, MCC version is 002.000
# Main task received a msg from [1, 0, 2] endpoint
Message: Size=0x00000004, data = 0x00000002
Main task received a msg from [1, 0, 2] endpoint
Message: Size=0x00000004, data = 0x00000004 ...
That's it, you've built a MCU application from scratch and can now start exploring all the examples provided inside the MQX SoloX release.