Communication between A9 and M4 cores
This tutorial will explain how to test the communication between ARM Cortex-A9 and ARM Cortex-M4 cores using the pinpong application.
Both cores applications run on DDR so we need to partition the DDR space available.
The first 16MB will be assigned to the M4 core and the rest will be assigned to the A9 core.
-
A9 Core: Use the recipe <TBD> and build the core-image-minimal
-
bitbake core-image-minimal
-
M4 Core:
-
Download the last MQX source code from Freescale's website at http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MQX#. We have used the 4.1.0 version in the tests. Do not forget to download the Linux version (*.gz).
-
Create a directory and decompress the source code:
export IMX6SOLOX=~/imx6solox
mkdir -p $IMX6SOLOX
cd $IMX6SOLOX
mkdir -p mqx
cd mqx
tar xfv ~/Downloads/Freescale\MQX\RTOS\4.1.0\for\i.MX\6SoloX\Linux\Base.gz
-
Download and install the required toolchain to compile the MQX application:
cd $IMX6SOLOX
mkdir -p toolchain
cd toolchain
wget https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2
tar xfv gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2
rm gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2
-
Now compile the MQX and related libraries:
cd $IMX6SOLOX/mqx/build/imx6sx_sdb_m4/make
export TOOLCHAIN_ROOTDIR=$IMX6SOLOX/toolchain/gcc-arm-none-eabi-4_8-2014q1
./build_gcc_arm.sh
-
Now we have to change the memory address where the application will be loaded (from the QSPI2 Flash, absent in our board to the DDR RAM).
To do this we need to change the line 'text (RX): ORIGIN = 0x78000000, LENGTH = 0x00040000' with ' text (RX): ORIGIN = 0x80000000, LENGTH = 0x00FFFFFF' in the file $IMX6SOLOX/mqx/source/bsp/imx6sx_sdb_m4/gcc_arm/extflash.ld
-
And compile the pingpong application:
cd $IMX6SOLOX/mqx/mcc/examples/pingpong/build/make/pingpong_example_imx6sx_sdb_m4
./build_gcc_arm.sh
-
Convert the ELF application to a binary format:
arm-none-eabi-objcopy -O binary gcc_arm/extflash_release/pingpong_example_imx6sx_sdb_m4.elf m4_ddr.bin
-
Save the m4_ddr.bin file in the first sdcard partition
-
Modify u-boot environment:
The U-Boot bootloader will be responsible to read the MQX firmware from the SDCARD, write in the DDR RAM, and start the application on the Cortex-M4.
You must stop the machine in U-Boot (press a key on startup) and change/add the u-boot variables as shown below:
bootargsy_mmc=setenv bootargs ${bootargs} ${mtdparts_yocto} root=/dev/mmcblk0p2 rootwait rw uart_from_osc
loadaddr=0x81800000
fdt_file=imx6sx-icore-m4.dtb
boot_m4=fatload mmc 0:1 0x80000000 m4_ddr.bin; bootaux 0x80000000
-
Device Tree
-
To run the test we need to load the special device tree imx6sx-icore-m4.dtb where all the shared peripherals are disabled in the A9 core. To manage the shared peripherals between cores please referer to the document “Getting Started with Multicore Programming for i.MX 6SoloX” https://community.freescale.com/docs/DOC-329540-
-
-
Run the test
Open the terminal on the second tty and, when you give 'run boot_m4' (in the u-boot console), You should see the message below:
***** MCC PINGPONG EXAMPLE *****
Please wait :
1) A9 peer is ready
Then press "S" to start the demo
********************************
Press "S" to start the demo :
Wait for the Linux boot process to finish (A9 core) and press "S" to start the demo application.
In the Linux terminal, start the communication with the pingpong application:
echo 1 > /sys/devices/soc0/soc.0/2200000.aips-bus/mcctest.15/pingpong_en &
You should see the log of messages sent and received on both terminals below