Customizing MQX applications on i.MX6SX.

Document created by CarlosCasillas Employee on Jul 3, 2015Last modified by CarlosCasillas Employee on Jul 8, 2015
Version 5Show Document
  • View in full screen mode

The i.MX6SX series of applications processors are powered by two asymmetrical cores: one ARM Cortex-A9 and one Cortex-M4. It allows the coexistence of real-time and non-real-time applications on the same processor (M4 core running an RTOS, and A9 core running Linux or Android).

 

This document will explain how to compile and download a customized MQX application to the QSPI Flash of the IMX6SX-SDB board using a Ubuntu host. The example application will be connecting a 16x2 LCD to GPIO pins of the i.MX6SX. As the IMX6SX-SDB board doesn’t have GPIO header, we will use the pins from SD3 socket, so, it will be required to add the proper pin definitions to the MQX BSP.

First of all, the Yocto image will be used as base to boot the A9 core (BSP L3.14.28_1.0.0), because it is the main core and the M4 core will be held on reset until the A9 removes the reset from it. The Yocto image includes many device tree files on the FAT partition, and the default DTB doesn’t consider the existence of the M4 core (only required when Linux applications would consider the M4 core as a resource), so, for changing the DTB file, launch the following command on U-Boot:

=> setenv fdt_file imx6sx-sdb-m4.dtb

 

We are going to download and uncompress MQX 4.1 for i.MX6SX (Linux hosted) from the following link:

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MQX

In this example, GCC compiler for ARM will be used, so, download and uncompress gcc-arm-none-eabi-4_8-2014q1 from the link below:

https://launchpad.net/gcc-arm-embedded/+download

 

Additional Linux commands consider that MQX and GCC were uncompressed on /home/user folder. In order to avoid compiler error, it will be required to set a couple of environments variables:

$ export TOOLCHAIN_ROOTDIR=/home/user/gcc-arm-none-eabi-4_8-2014q1
$ export PATH=$PATH:/home/user/gcc-arm-none-eabi-4_8-2014q1/bin/

 

Before building any MQX example applications, it is required to build MQX libraries (included BSP and PSP), so, navigate to the next folders and launch the build script in each of them:

$ cd /home/user/ Freescale_MQX_4.1.0_i.MX_6SoloX /mqx/build/make/bsp_imx6sx_sdb_m4/
$ ./build_gcc_arm.sh
$ cd /home/user/ Freescale_MQX_4.1.0_i.MX_6SoloX /mqx/build/make/psp_imx6sx_sdb_m4/
$ ./build_gcc_arm.sh

 

Now we can compile the example applications like the GPIO demo (that will be used as base for our customized application):

/home/user/Freescale_MQX_4.1.0_i.MX_6SoloX/mqx/examples/gpio/

 

Our example application will configure the 6 pins of the SD3 socket (LWGPIO_PIN_SD3_DATA0, LWGPIO_PIN_SD3_DATA1, LWGPIO_PIN_SD3_DATA2, LWGPIO_PIN_SD3_DATA3, LWGPIO_PIN_SD3_CMD, LWGPIO_PIN_SD3_CLK) for using them by the M4 core on MQX; so, it will be required to add the proper definitions on the board’s header file for each pin (in this case, “imx6sx_sdb_m4.h”). The following corresponds to the LWGPIO_PIN_SD3_DATA0 pin (we are naming them as “SD2GPIO0 – SD2GPIO5”):

#define BSP_SD2GPIO0_PROMPT         "SD2GPIO0" 
#define BSP_SD2GPIO0                (LWGPIO_PIN_SD3_DATA0)
#define BSP_SD2GPIO0_MUX_GPIO       (LWGPIO_MUX_SD3_DATA0_GPIO)
#define BSP_SD2GPIO0_MUX_IRQ        (LWGPIO_MUX_SD3_DATA0_GPIO)

 

As this file is part of the BSP, it will be required to recompile the BSP after applying these modifications. The modified header file could be found on the attachments of this document.

Now, we are going to copy the entire folder of the “gpio” example to the same location, and we will rename it as “sd2gpio”. Inside such folder, we should also rename the “gpio.c” file to “sd2gpio.c”. Besides, it is required to edit the “Makefile” file in order to redirect the included paths to the new folder. It is basically done on the following two lines:

NAME = sd2gpio
SOURCES += $(MQX_ROOTDIR)/mqx/examples/sd2gpio/sd2gpio.c

 

The modified “Makefile” file is also available on the attachments.

The “sd2gpio.c” file includes the main MQX task that will initialize the LWGPIOs using the definitions declared on the board’s header file. It also includes the functions used by the 16x2 LCD driver. This file is also included on the attachments of this thread.

With all the modifications done and the BSP recompiled, we can now compile our customized application by launching the command:

$ ./build_gcc_arm.sh

 

Located on the following path:

/home/user/Freescale_MQX_4.1.0_i.MX_6SoloX/mqx/examples/gpio/build/make/ gpio_imx6sx_sdb_m4/

 

The output file (an ELF file) will be located at the following path:

/home/user/Freescale_MQX_4.1.0_i.MX_6SoloX/mqx/examples/gpio/build/make/ gpio_imx6sx_sdb_m4/cd gcc_arm/extflash_debug/

 

Now, we are going to move to this folder, and launching the following command to convert the ELF file to a BIN file. It is required because we will flash the QSPI Flash using the A9 core, and the symbols data of the ELF file is not required (actually, the flashing applications looks for “m4_qspi.bin” file):

$ arm-none-eabi-objcopy -O binary sd2gpio_imx6sx_sdb_m4.elf m4_qspi.bin

 

Next, copy the BIN file to the FAT partition of the SD card (considering it is mounted over /media/ ):

$ cp m4_qspi.bin /media/Boot\ imx6sx/ && sync

 

Now we will place the SD card on the SDB board and boot it. Stop the boot process on U-Boot and launch the following command for flashing the QSPI Flash from the BIN file:

=> run update_m4_from_sd

 

Finally, start the MQX application by releasing the reset of the M4 by launching the following command:

=> run m4boot

 

The figure below shows the LCD with the application working:

CAM00305.jpg

 

Additional tests:

If you want to run the M4 application out of reset you could modify the environment variable ‘bootcmd’. For displaying the default variable value, launch the following command:

=> printenv bootcmd

 

So, for just removing the reset from M4 core without booting Linux, launch the command below:

=> setenv bootcmd=‘run m4boot’

 

If you want to avoid the count-down delay (for a faster boot), you could try the following command:

=> setenv bootdelay 0

 

Finally, if Linux is also boots after the M4, it will change some clock settings, and also mounts the SD3 driver, so, the pin configurations will be overrode. In order to avoid clock issues on the M4, add to boot parameters ‘uart_from_osc' like command below:

=> setenv mmcargs 'setenv bootargs no_console_suspend clk_ignore_unused uart_from_osc console=${console},${baudrate} root=${mmcroot}'

 

Don’t forget to save the environment after changing environments variables and then, reboot:

=> saveenv

Attachments

Outcomes