Tutorial: Running FreeRTOS on NXP i.MX7Dual Cortex-M4F

In my previous article (see “Tutorial: First Steps with NXP i.MX7 and Toradex Colibri Board“) I have booted the i.MX7 on a Toradex CPU module. In this post I’m showing how to run a FreeRTOS application on that board.

UART-A and UART-B Connections

UART-A and UART-B Connections

Outline

The i.MX7 features one or two ARM Cortex-A7, plus a single ARM Cortex-M4. Have a read at this Toradex knowledge base article which describes the overall architecture.

FreeRTOS Git

Next step is to get a FreeRTOS port for the M4. Toradex has a port available on the following git repository:

git://git.toradex.com/freertos-toradex.git freertos-colibri-imx7/

Clone it with your git client.

git clone -b colibri-imx7-m4-freertos-v8 git://git.toradex.com/freertos-toradex.git freertos-colibri-imx7/

💡 Important: do not clone it into a path with spaces, as the make files are *not* space aware!

Or with a client like SourceTree:

Cloning with SourceTree

Cloning with SourceTree

💡 Important: make sure that you use the 1.0.1 branch, see https://www.toradex.com/community/questions/4072/helloworld-demo-doesnt-work-with-freertos-on-colib.html

Below an image how it looks like in SourceTree after cloning:

Toradex FreeRTOS Git

Toradex FreeRTOS Git

💡 As the Git tag indicates, this is an older FreeRTOS V8.0.0 release. I see later how to use the latest V9.0.0 version.

Building FreeRTOS Demo Applications

Inside the repository (freertos-toradex\examples\imx7_colibri_m4\demo_apps), there are several example projects, with subfolders for each IDE supported. To use the armgcc one, it requires cmake installed.

On Linux use the following to get it installed:

sudo apt-get install make cmake

For Windows cmake is available from https://cmake.org/download/. Additionally for Windows the mingw32 package from https://sourceforge.net/projects/mingw-w64/  is needed.

Because I don’t want to change the system paths of my Windows system, I’m using the following batch file which addes the paths and does the example project build:

@ECHO off
ECHO Adding cmake and mingw32 path to PATH
SET CMAKEBIN=C:\nxp\cmake\bin
SET MINGW32BIN=C:\MinGW\bin
ECHO %PATH%|findstr /i /c:"%CMAKEBIN:"=%">nul || set PATH=%PATH%;%CMAKEBIN%
ECHO %PATH%|findstr /i /c:"%MINGW32BIN:"=%">nul || set PATH=%PATH%;%MINGW32BIN%
ECHO %PATH%

@rem set where to find the ARM launchpad compiler and tools
SET ARMGCC_DIR=C:\nxp\KDS_3.2.0\Toolchain

@rem build examples
build_all.bat

Running the build will build the example project.

freertos-demo-example-build

freertos-demo-example-build

Below an example make output:

C:\temp\toradex\freertos-toradex\examples\imx7_colibri_m4\demo_apps\hello_world\armgcc>type build.bat
@ECHO off
ECHO Adding cmake and mingw32 path to PATH
SET CMAKEBIN=C:\nxp\cmake\bin
SET MINGW32BIN=C:\MinGW\bin
ECHO %PATH%|findstr /i /c:"%KDSBIN:"=%">nul || set PATH=%PATH%;%CMAKEBIN%
ECHO %PATH%|findstr /i /c:"%MINGW32BIN:"=%">nul || set PATH=%PATH%;%MINGW32BIN%
ECHO %PATH%

@rem set where to find the ARM launchpad compiler and tools
SET ARMGCC_DIR=C:\nxp\KDS_3.2.0\Toolchain

@rem build examples
build_all.bat
C:\temp\toradex\freertos-toradex\examples\imx7_colibri_m4\demo_apps\hello_world\armgcc>type build.bat
@ECHO off
ECHO Adding cmake and mingw32 path to PATH
SET CMAKEBIN=C:\nxp\cmake\bin
SET MINGW32BIN=C:\MinGW\bin
ECHO %PATH%|findstr /i /c:"%CMAKEBIN:"=%">nul || set PATH=%PATH%;%CMAKEBIN%
ECHO %PATH%|findstr /i /c:"%MINGW32BIN:"=%">nul || set PATH=%PATH%;%MINGW32BIN%
ECHO %PATH%

@rem set where to find the ARM launchpad compiler and tools
SET ARMGCC_DIR=C:\nxp\KDS_3.2.0\Toolchain

@rem build examples
build_all.bat
C:\temp\toradex\freertos-toradex\examples\imx7_colibri_m4\demo_apps\hello_world\armgcc>build.bat
Adding cmake and mingw32 path to PATH
C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Users\Erich Styger\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;C:\Program Files\IVI Foundation\VISA\Win64\Bin\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Windows\twain_32\CNQL60;C:\CooCox\CoIDE_V2Beta\gcc\bin;C:\CooCox\CoIDE_V2Beta\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\MinGW\bin;C:\nxp\cmake\bin
-- TOOLCHAIN_DIR: C:/nxp/KDS_3.2.0/Toolchain
CMake Deprecation Warning at C:/nxp/cmake/share/cmake-3.7/Modules/CMakeForceCompiler.cmake:69 (message):
 The CMAKE_FORCE_C_COMPILER macro is deprecated. Instead just set
 CMAKE_C_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
 C:/temp/toradex/freertos-toradex/tools/cmake_toolchain_files/armgcc.cmake:38 (CMAKE_FORCE_C_COMPILER)
 C:/nxp/cmake/share/cmake-3.7/Modules/CMakeDetermineSystem.cmake:85 (include)
 CMakeLists.txt


CMake Deprecation Warning at C:/nxp/cmake/share/cmake-3.7/Modules/CMakeForceCompiler.cmake:83 (message):
 The CMAKE_FORCE_CXX_COMPILER macro is deprecated. Instead just set
 CMAKE_CXX_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
 C:/temp/toradex/freertos-toradex/tools/cmake_toolchain_files/armgcc.cmake:39 (CMAKE_FORCE_CXX_COMPILER)
 C:/nxp/cmake/share/cmake-3.7/Modules/CMakeDetermineSystem.cmake:85 (include)
 CMakeLists.txt


-- BUILD_TYPE: Debug
-- TOOLCHAIN_DIR: C:/nxp/KDS_3.2.0/Toolchain
CMake Deprecation Warning at C:/nxp/cmake/share/cmake-3.7/Modules/CMakeForceCompiler.cmake:69 (message):
 The CMAKE_FORCE_C_COMPILER macro is deprecated. Instead just set
 CMAKE_C_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
 C:/temp/toradex/freertos-toradex/tools/cmake_toolchain_files/armgcc.cmake:38 (CMAKE_FORCE_C_COMPILER)
 CMakeFiles/3.7.0-rc2/CMakeSystem.cmake:6 (include)
 CMakeLists.txt


CMake Deprecation Warning at C:/nxp/cmake/share/cmake-3.7/Modules/CMakeForceCompiler.cmake:83 (message):
 The CMAKE_FORCE_CXX_COMPILER macro is deprecated. Instead just set
 CMAKE_CXX_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
 C:/temp/toradex/freertos-toradex/tools/cmake_toolchain_files/armgcc.cmake:39 (CMAKE_FORCE_CXX_COMPILER)
 CMakeFiles/3.7.0-rc2/CMakeSystem.cmake:6 (include)
 CMakeLists.txt


-- BUILD_TYPE: Debug
-- The ASM compiler identification is GNU
-- Found assembler: C:/nxp/KDS_3.2.0/Toolchain/bin/arm-none-eabi-gcc.exe
-- Configuring done
-- Generating done
-- Build files have been written to: C:/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc
Scanning dependencies of target hello_world
[ 4%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c.obj[ 8%]
Building ASM object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S.obj
[ 13%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/portable/MemMang/heap_2.c.obj
[ 17%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/demo_apps/hello_world/main.c.obj
[ 21%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/uart_imx.c.obj
[ 26%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/croutine.c.obj
[ 30%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/event_groups.c.obj
[ 34%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/list.c.obj
[ 39%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/queue.c.obj
[ 43%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/tasks.c.obj
[ 47%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/timers.c.obj
[ 52%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/ccm_analog_imx7d.c.obj
[ 56%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/ccm_imx7d.c.obj
[ 60%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/rdc.c.obj
[ 65%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/wdog_imx.c.obj
[ 69%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/utilities/src/debug_console_imx.c.obj
[ 73%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/utilities/src/print_scan.c.obj
[ 78%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c.obj
[ 82%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/pin_mux.c.obj
[ 86%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/board.c.obj
[ 91%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/clock_freq.c.obj
[ 95%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/demo_apps/hello_world/hardware_init.c.obj
[100%] Linking C executable debug\hello_world.elf
[100%] Built target hello_world
-- TOOLCHAIN_DIR: C:/nxp/KDS_3.2.0/Toolchain
CMake Deprecation Warning at C:/nxp/cmake/share/cmake-3.7/Modules/CMakeForceCompiler.cmake:69 (message):
 The CMAKE_FORCE_C_COMPILER macro is deprecated. Instead just set
 CMAKE_C_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
 C:/temp/toradex/freertos-toradex/tools/cmake_toolchain_files/armgcc.cmake:38 (CMAKE_FORCE_C_COMPILER)
 CMakeFiles/3.7.0-rc2/CMakeSystem.cmake:6 (include)
 CMakeLists.txt


CMake Deprecation Warning at C:/nxp/cmake/share/cmake-3.7/Modules/CMakeForceCompiler.cmake:83 (message):
 The CMAKE_FORCE_CXX_COMPILER macro is deprecated. Instead just set
 CMAKE_CXX_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
 C:/temp/toradex/freertos-toradex/tools/cmake_toolchain_files/armgcc.cmake:39 (CMAKE_FORCE_CXX_COMPILER)
 CMakeFiles/3.7.0-rc2/CMakeSystem.cmake:6 (include)
 CMakeLists.txt


-- BUILD_TYPE: Release
-- Configuring done
-- Generating done
CMake Warning:
 Manually-specified variables were not used by the project:

 CMAKE_TOOLCHAIN_FILE


-- Build files have been written to: C:/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc
[ 4%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c.obj
[ 8%] Building ASM object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S.obj
[ 13%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/portable/MemMang/heap_2.c.obj
[ 17%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/demo_apps/hello_world/main.c.obj
[ 21%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/uart_imx.c.obj
[ 26%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/croutine.c.obj
[ 30%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/event_groups.c.obj
[ 34%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/list.c.obj
[ 39%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/queue.c.obj
[ 43%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/tasks.c.obj
[ 47%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/rtos/FreeRTOS/Source/timers.c.obj
[ 52%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/ccm_analog_imx7d.c.obj
[ 56%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/ccm_imx7d.c.obj
[ 60%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/rdc.c.obj
[ 65%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/drivers/src/wdog_imx.c.obj
[ 69%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/utilities/src/debug_console_imx.c.obj
[ 73%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/utilities/src/print_scan.c.obj
[ 78%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c.obj
[ 82%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/pin_mux.c.obj
[ 86%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/board.c.obj
[ 91%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/clock_freq.c.obj
[ 95%] Building C object CMakeFiles/hello_world.dir/C_/temp/toradex/freertos-toradex/examples/imx7_colibri_m4/demo_apps/hello_world/hardware_init.c.obj
[100%] Linking C executable release\hello_world.elf
[100%] Built target hello_world
Press any key to continue . . .

C:\temp\toradex\freertos-toradex\examples\imx7_colibri_m4\demo_apps\hello_world\armgcc>

The subfolders contain the build output files:

demo-example-output

demo-example-output

FreeRTOS Hello World Application

The FreeRTOS Hello World application is very simple: It starts a single task (HelloTask) which prints a “Hello World!”, and then it waits for input characters from the UART which then get printed back on the same UART:

#include "FreeRTOS.h"
#include "task.h"
#include "board.h"
#include "debug_console_imx.h"

/*!
 * @brief A basic user-defined task
 */
void HelloTask(void *pvParameters)
{
 uint8_t receiveBuff;

 // Print the initial banner
 PRINTF("\r\nHello World!\n\n\r");

 while(1)
 {
 // Main routine that simply echoes received characters forever

 // First, get character
 receiveBuff = GETCHAR();

 // Now echo the received character
 PUTCHAR(receiveBuff);
 }
}

/*!
 * @brief Main function
 */
int main(void)
{
 // Initialize demo application pins setting and clock setting.
 hardware_init();

 // Create a demo task which will print Hello world and echo user's input.
 xTaskCreate(HelloTask, "Print Task", configMINIMAL_STACK_SIZE,
 NULL, tskIDLE_PRIORITY+1, NULL);

 // Start FreeRTOS scheduler.
 vTaskStartScheduler();

 // Should never reach this point.
 while (true);
}

The demo uses UART-B for the input/output. UART-A is used by u-boot and Linux for debug console messages (see (“Tutorial: First Steps with NXP i.MX7 and Toradex Colibri Board“), so I attach two terminals to the Iris Carrier board: UART-A for the debug messages and UART-B for the M4 FreeRTOS UART-B:

UART-A and UART-B Connections

UART-A and UART-B Connections

UART-B is available on the expansion header on pin 31 and 32:

UART-B Connection Details

UART-B Connection Details

I connect a terminal program to both UARTs with 115200 baud.

Putting FreeRTOS Application on SD Card

Copy the .bin file on a micro SD card (e.g. on a boot image created for i.MX7):

Hello World binary for Cortex-M4 on micro SD card

Hello World binary for Cortex-M4 on micro SD card

U-Boot

Then reboot the i.MX7 board with the SD card inserted. If it already has booted, login with ‘root’ and issue a ‘reboot’ command:

colibri-imx7 login: root
reboot

During the boot sequence, there is a message

Normal Boot

Hit any key to stop autoboot:  1

Hit a key in the terminal at that time, and it will abort the normal boot process.

With the ‘ls’ command check that the content of the SD card:

ls mmc 0:1

It should show the binary file we have stored on it among other files:

...
    13272   hello_world.bin 
15 file(s), 1 dir(s)

Use the fatload command to load the binary at address 0x7F8000

fatload mmc 0:1 0x7F8000 hello_world.bin

U-boot reports loading the file:

Colibri iMX7 # fatload mmc 0:1 0x7F8000 hello_world.bin
fatload mmc 0:1 0x7F8000 hello_world.bin
reading hello_world.bin
13272 bytes read in 27 ms (479.5 KiB/s)

Then flush the data cache:

dcache flush

Followed by the command to boot the auxiliary M4 core:

bootaux 0x7F8000

FreeRTOS Demo Application on M4

With the terminal connected to UART-B, I should see the ‘hello’ message. And the FreeRTOS task will echo whatever I submit on that UART from the terminal:

FreeRTOS running on M4 on i.MX7

FreeRTOS running on M4 on i.MX7

Success! I have a FreeRTOS application running on the M4 core of the i.MX7 :-).

Summary

I’m ending my current week-end project with first steps on the NXP i.MX7 and running a FreeRTOS application on the M4 core. The combination of a Linux running on one or two A7 plus having a Cortex-M4 for realtime aspects has huge potential to me. I have the module with Linux running, and I have a simple hello world application on the M4 working.

Running a simple FreeRTOS application on the M4 core of the i.MX7 requires several steps, but they should not be too difficult. The above steps currently require manual steps and are using the pre-installed Linux on the Colibri board. It is possible to automatically load and start the code for the M4, but for this it is better that I update the Linux on the Colibri module, as there can be issues with clocks and UARTs:

Note: In V2.6 Alpha 1, there is an issue rendering the Linux clock driver useless when the Cortex-M4 is started. Due to a second bug, this only manifests on Colibri iMX7D. Use the latest 3.14.52 kernel available in the -next branch to avoid those issues.

Some examples seem also to interfere with SPI, therefor the node ecspi3 might need to be disabled as well.

So in a future article I’m exploring how to update the Linux on the module. And as an ultimate goal I want to use JTAG debugging for the Cortex-M4 too.

Happy FreeRTOSing 🙂

Links

37 thoughts on “Tutorial: Running FreeRTOS on NXP i.MX7Dual Cortex-M4F

  1. Great ! I was just thinking about to order Colibri. But there is also the Warp7
    available on Farnell Element14. What do you think about Warp7 ?

    Like

  2. Great article. Just had the chance myself to play with this at the NXP FTF Connects Toronto about 2 weeks ago. I was very much interested in the interaction between the i.MX7 and the M4 core.

    We had a hands-on session with the NXP SABRE board. Briefly played with the MU (Messaging Unit) and semaphore unit to coordinate comms between the A7 and M4 core complexes. Very valuable addition for inter-process communications.

    We too used UBOOT to lauch (automatically or manually) a custom image. Unfortunately not enough time to go into details. This left me wondering: how can this be done via the eclipse IDE and how do you debug an application running on the M4?

    I had a nice chat with Toradex during the lunch break. This coupled with your articles has me checking their website right now.

    Like

    • Hi Ralf,
      thanks :-). I think you attended the same training I attended at FTF in Austin/TX this year. I’m trying to replicate the same kind of thing with the Toradex Colibri board, and I’m right now in the process or building the project with Kinetis Design Studio. This works so far. What is missing is to be able to debug it over JTAG. I would like to use either a P&E Multilink or Segger J-Link for this, but on the Iris and Viola board the JTAG connector is not available on the board, I have to check out the full evaluation board. I have the SABRE board too which I need to look at: this one has the connector available.

      Like

  3. Dear Erich,
    I will begin to work with iMX7 Toradex. I am curious is there support of IDE for Baremetal project on M4? Until now I was working with Kinetis M4 (CodeWarrior, KDS, PEx). There are cases when is suitable to transfer project to iMX7 (original project iMX6 + Kinetis M4). Linux on A7 will handle ethernet, USB and SD Card so there is no need for using RTOS on M4. Is it possible to set up new project for M4 on iMX7 in these variants: RTOS, RTOS + Baremetal (motor driver) or baremetal project only? Is there processor expert support for A7 (BSP) and M4 on iMX7? It would be nice if there would be an article about IDE + JTAG, what projects could be set up, ups/downs. Such options review I am missing. In every forum is discussed only selected option but choosing the right one is hard.
    Is there any IDE and project example for embedded linux for A7 or how is usually done linux development for A7? Is necessarily to modify kernel in oder to run ethernet, USB, AUDIO or these peripherals are enabled in preinstalled linux image?

    Thank you.
    Jaroslav

    Like

    • Hi Jaroslav,
      lots of questions 🙂
      I’m using Eclipse with GNU ARM Eclipse and the launchpad (actuall Kinetis Design Studio V3.2.0) to build baremetal and RTOS projects for the M4. I’ll plan to publish an article about this probably next weekend (if time permits).
      Using FreeRTOS (or any other RTOS) on the M4 is optional, but gives a very nice environment. I have motor applications running with FreeRTOS nicely, because FreeRTOS is is able to work nicely with the interrupts, see my other articles around the ARM Cortex interrupts (https://mcuoneclipse.com/2016/08/14/arm-cortex-m-interrupts-and-freertos-part-1/).
      There is no Processor Expert for the Cortex A (well, there is the Pin Muxing for it, see https://mcuoneclipse.com/2016/06/08/tutorial-muxing-with-the-new-nxp-pins-tool/), but not for the drivers.
      About IDE and JTAG debugging: I’m not there yet (facing some issues), but that’s definitely my goal, and I will write about it as soon as I have it working.
      As for the Linux part: the usual way is to use a pre-built image and flash it to the board (I plan to write an article about this too on the week-end), and then you have pretty much everything in it. But of course you are free to build your own linux image if you want.

      I hope this helps,
      Erich

      Like

  4. Hi Erich!
    Can you make a post or tutorial (somewhen in future) about bootloader in kinetis boards? I’m getting interested in this area but I can’t even start, it’s so complicated.

    Like

  5. Pingback: Tutorial: Updating Embedded Linux on Toradex i.MX7 Colibri Module using SD Card | MCU on Eclipse

  6. Pingback: Tutorial: First Steps with NXP i.MX7 and Toradex Colibri Board | MCU on Eclipse

  7. Pingback: Tutorial: Building FreeRTOS Applications for ARM Cortex-M4 on i.MX7 with Eclipse | MCU on Eclipse

  8. Hi Erich,

    Thank you for these articles which are very helpful!
    I’m newbie for Linux-Arm and probably missed something.

    I fatload .bin file and dcache flush, everything normal, then
    under the prompt “colibri iMX7 #” (it’s u-boot 2016.11-2.7.4 )
    when I input : bootaux 0x7F8000
    response:
    ##No elf image at address 0x007f8000
    ## Starting auxiliary core at 0x1FFF8311 …

    I guess there must be something wrong with the bin file, so I downloaded pre-compiled ones from Toradex. All the same!
    But when I fatload and bootaux .elf file, it works!
    response:
    ## Starting auxiliary core at 0x1FFF8311 …

    could you please help me with this problem?

    Thank you!
    PingQi

    Like

      • Not yet, it’s weekend and I’ll ask the dealers for it the day after tomorrow(Monday) and update here.
        I post it here because I thought there could be a obviously answer for a beginner’s question.
        Another question (not relevant and probably meaningless) : Does the U-boot print address both in upper case and lower case for purpose? like 0x007f8000 vs 0x1FFF8311 in my last question.
        Thank you!

        Like

    • “when I input : bootaux 0x7F8000
      response:
      ##No elf image at address 0x007f8000
      ## Starting auxiliary core at 0x1FFF8311 …”

      It actually works! I made a stupid mistake that I unconsciously used USB-RS232 instead of USB-UART and received garbage through M4-UART. And luckily nothing is fried.

      I checked data read out by J-link after bin file is downloaded into M4’s TCM.
      0x1FFF8311 is somewhere inside Reset_Handler and 0x1FFF8000 is the isr_vector。
      So the U-boot feedback is slightly different to the document from Toradex but still normal and make sense to me.
      So far so good!

      Like

  9. Now my issue is:Kernel panic – not syncing: Attempted to kill init! exitcode=0x0000000b (with Yocto Sumo uboot 2018 Not Hardknott uboot 2021) .gist table { margin-bottom: 0; } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters U-Boot SPL 2018.03-ce1e3c9d29948853203c8a5805e93908daa8fa2a+gce1e3c9d29 (Mar 11 2022 – 02:30:30 +0000) Trying to boot from MMC1 U-Boot 2018.03-ce1e3c9d29948853203c8a5805e93908daa8fa2a+gce1e3c9d29 (Mar 11 2022 – 02:30:30 +0000) CPU: Freescale i.MX7D rev1.2 1000 MHz (running at 792 MHz) CPU: Commercial temperature grade (0C to 95C) at 49C Reset cause: POR Board: PICO-IMX7D Compatible baseboard: dwarf, hobbit, nymph, pi I2C: ready DRAM: 512 MiB PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x11 MMC: FSL_SDHC: 0, FSL_SDHC: 1 Loading Environment from MMC… OK Display: MCIMX28LCD (800×480) Video: 800x480x24 In: serial Out: serial Err: serial flash target is MMC:0 Net: FEC0 Error: FEC0 address not set. Fastboot: Normal Normal Boot Hit any key to stop autoboot: 0 switch to partitions #0, OK mmc0(part 0) is current device 233 bytes read in 8 ms (28.3 KiB/s) Loaded environment from uEnv.txt Importing environment from mmc … Running uenvcmd … 7116080 bytes read in 178 ms (38.1 MiB/s) Booting from mmc … 10592 bytes read in 14 ms (738.3 KiB/s) ## Starting auxiliary core at 0x007F8000 … baseboard is pi 60876 bytes read in 16 ms (3.6 MiB/s) ## Flattened Device Tree blob at 83000000 Booting using the fdt blob at 0x83000000 Using Device Tree in place at 83000000, end 83011dcb Starting kernel … Booting Linux on physical CPU 0x0 Linux version 4.14.98-2.0.0-ga-next+gaa8b26b7ca09 (oe-user@oe-host) (gcc version 7.3.0 (GCC)) #1 SMP PREEMPT Fri Mar 11 01:40:41 UTC 2022 CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d CPU: div instructions available: patching division code CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache OF: fdt: Machine model: TechNexion PICO-IMX7D with QCA WLAN module and PI baseboard Memory policy: Data cache writealloc Reserved memory: created CMA memory pool at 0x8a000000, size 320 MiB OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool percpu: Embedded 16 pages/cpu @9fa13000 s35468 r8192 d21876 u65536 Built 1 zonelists, mobility grouping on. Total pages: 129794 Kernel command line: console=ttymxc4,115200 root=/dev/mmcblk2p2 rootwait rw video=mxcfb0:dev=lcd,800×480@60,if=RGB24 PID hash table entries: 2048 (order: 1, 8192 bytes) Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) Memory: 174704K/523264K available (9216K kernel code, 589K rwdata, 3072K rodata, 1024K init, 440K bss, 20880K reserved, 327680K cma-reserved, 0K highmem) Virtual kernel memory layout: vector : 0xffff0000 – 0xffff1000 ( 4 kB) fixmap : 0xffc00000 – 0xfff00000 (3072 kB) vmalloc : 0xa0000000 – 0xff800000 (1528 MB) lowmem : 0x80000000 – 0x9ff00000 ( 511 MB) pkmap : 0x7fe00000 – 0x80000000 ( 2 MB) modules : 0x7f000000 – 0x7fe00000 ( 14 MB) .text : 0x80008000 – 0x80a00000 (10208 kB) .init : 0x80e00000 – 0x80f00000 (1024 kB) .data : 0x80f00000 – 0x80f937e0 ( 590 kB) .bss : 0x80f95000 – 0x810031b0 ( 441 kB) SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 Preemptible hierarchical RCU implementation. RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2. Tasks RCU enabled. RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2 NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 arch_timer: cp15 timer(s) running at 8.00MHz (phys). clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 440795202120 ns sched_clock: 56 bits at 8MHz, resolution 125ns, wraps every 2199023255500ns Switching to timer-based delay loop, resolution 125ns Ignoring duplicate/late registration of read_current_timer delay clocksource: mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns Console: colour dummy device 80×30 Calibrating delay loop (skipped), value calculated using timer frequency.. 16.00 BogoMIPS (lpj=80000) pid_max: default: 32768 minimum: 301 Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) CPU: Testing write buffer coherency: ok CPU0: update cpu_capacity 1024 CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 Setting up static identity map for 0x80100000 – 0x80100060 Hierarchical SRCU implementation. smp: Bringing up secondary CPUs … CPU1: update cpu_capacity 1024 CPU1: thread -1, cpu 1, socket 0, mpidr 80000001 smp: Brought up 1 node, 2 CPUs SMP: Total of 2 processors activated (32.00 BogoMIPS). CPU: All CPU(s) started in SVC mode. devtmpfs: initialized OF: Duplicate name in lcdif@30730000, renamed to "display#1" random: get_random_u32 called from bucket_table_alloc+0x114/0x23c with crng_init=0 VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5 clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns futex hash table entries: 512 (order: 3, 32768 bytes) pinctrl core: initialized pinctrl subsystem NET: Registered protocol family 16 DMA: preallocated 256 KiB pool for atomic coherent allocations cpuidle: using governor menu vdd1p0d: supplied by regulator-dummy vdd1p2: supplied by regulator-dummy DDR type is DDR3! hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers. hw-breakpoint: maximum watchpoint size is 8 bytes. imx7d-pinctrl 302c0000.iomuxc-lpsr: initialized IMX pinctrl driver imx7d-pinctrl 30330000.iomuxc: initialized IMX pinctrl driver MU is ready for cross core communication! platform 30800000.aips-bus: coherent DMA mask is unset virtio_rpmsg_bus virtio0: rpmsg host is online imx rpmsg driver is registered. MU is ready for cross core communication! vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb usb_phy_generic 30800000.aips-bus:usbphynop1: 30800000.aips-bus:usbphynop1 supply vcc not found, using dummy regulator usb_phy_generic 30800000.aips-bus:usbphynop2: 30800000.aips-bus:usbphynop2 supply vcc not found, using dummy regulator i2c i2c-0: IMX I2C adapter registered i2c i2c-0: can't use DMA, using PIO instead. i2c i2c-1: IMX I2C adapter registered i2c i2c-1: can't use DMA, using PIO instead. i2c i2c-3: IMX I2C adapter registered i2c i2c-3: can't use DMA, using PIO instead. Linux video capture interface: v2.00 pps_core: LinuxPPS API ver. 1 registered pps_core: Software ver. 5.3.6 – Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it> PTP clock support registered MIPI CSI2 driver module loaded Advanced Linux Sound Architecture Driver Initialized. Bluetooth: Core ver 2.22 NET: Registered protocol family 31 Bluetooth: HCI device and connection manager initialized Bluetooth: HCI socket layer initialized Bluetooth: L2CAP socket layer initialized Bluetooth: SCO socket layer initialized clocksource: Switched to clocksource arch_sys_counter VFS: Disk quotas dquot_6.6.0 VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) NET: Registered protocol family 2 TCP established hash table entries: 4096 (order: 2, 16384 bytes) TCP bind hash table entries: 4096 (order: 3, 32768 bytes) TCP: Hash tables configured (established 4096 bind 4096) UDP hash table entries: 256 (order: 1, 8192 bytes) UDP-Lite hash table entries: 256 (order: 1, 8192 bytes) NET: Registered protocol family 1 RPC: Registered named UNIX socket transport module. RPC: Registered udp transport module. RPC: Registered tcp transport module. RPC: Registered tcp NFSv4.1 backchannel transport module. Bus freq driver module loaded workingset: timestamp_bits=30 max_order=17 bucket_order=0 NFS: Registering the id_resolver key type Key type id_resolver registered Key type id_legacy registered io scheduler noop registered io scheduler deadline registered io scheduler cfq registered (default) io scheduler mq-deadline registered io scheduler kyber registered pwm-backlight backlight: backlight supply power not found, using dummy regulator mxc_sdc_fb fb@0: NO mxc display driver found! Console: switching to colour frame buffer device 100×30 sii902x bound to mxs-lcdif from 30730000.lcdif mxsfb 30730000.lcdif: initialized imx-sdma 30bd0000.sdma: no iram assigned, using external mem imx-sdma 30bd0000.sdma: Falling back to user helper mxs-dma 33000000.dma-apbh: initialized pfuze100-regulator 3-0008: Full layer: 1, Metal layer: 1 pfuze100-regulator 3-0008: FAB: 0, FIN: 0 pfuze100-regulator 3-0008: pfuze3000 found. 30a70000.serial: ttymxc4 at MMIO 0x30a70000 (irq = 61, base_baud = 500000) is a IMX console [ttymxc4] enabled Unhandled fault: imprecise external abort (0x1c06) at 0xf5a80090 pgd = 80004000 [f5a80090] *pgd=30a11452(bad) Internal error: : 1c06 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.14.98-2.0.0-ga-next+gaa8b26b7ca09 #1 Hardware name: Freescale i.MX7 Dual (Device Tree) task: 88060000 task.stack: 8805c000 PC is at serial_imx_probe+0x428/0x59c LR is at _raw_spin_unlock_irqrestore+0x28/0x54 pc : [<8048676c>] lr : [<809909b8>] psr: 60000013 sp : 8805de40 ip : 88060000 fp : 8831ce00 r10: fffffffa r9 : fffffffa r8 : 0000003e r7 : 8816e010 r6 : 8816e000 r5 : ffffffff r4 : 882c9810 r3 : 00000001 r2 : f5a80000 r1 : 00000001 r0 : 00000000 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none Control: 10c53c7d Table: 8000406a DAC: 00000051 Process swapper/0 (pid: 1, stack limit = 0x8805c210) Stack: (0x8805de40 to 0x8805e000) de40: 00000000 8816bae0 80c9d754 8831d9c0 00000001 8816e010 fffffffe 80f2b534 de60: fffffdfb 80f2b534 00000000 00000000 00000000 804d3b48 8816e010 80ff29b8 de80: 80ff29bc 00000000 80f2b534 804d233c 8816e010 80f2b534 8816e044 00000000 dea0: 00000007 00000130 80e61bfc 804d24ac 00000000 80f2b534 804d2408 804d08b8 dec0: 8804c758 8815ae34 80f2b534 8831a600 80f2c2f8 804d18c0 80c38c94 00000000 dee0: 80e2dd44 80f2b534 00000000 80e2dd44 80e4e83c 804d2d54 00000000 00000000 df00: 80e2dd44 80e2dd68 ffffe000 801019bc 9feffab7 9feffab4 80cff200 00000130 df20: 00000130 80148dc0 00000000 80c64b50 00000006 00000006 80c01460 00000000 df40: 80c0a508 80c014d4 9feffab7 9feffabd 00000000 80f95000 80f95000 80f95000 df60: 80e4e834 00000007 00000130 80e61bfc 00000000 80e00dac 00000006 00000006 df80: 00000000 80e005a8 00000000 8098accc 00000000 00000000 00000000 00000000 dfa0: 00000000 8098acd4 00000000 801079e8 00000000 00000000 00000000 00000000 dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 [<8048676c>] (serial_imx_probe) from [<804d3b48>] (platform_drv_probe+0x50/0xac) [<804d3b48>] (platform_drv_probe) from [<804d233c>] (driver_probe_device+0x210/0x2dc) [<804d233c>] (driver_probe_device) from [<804d24ac>] (__driver_attach+0xa4/0xa8) [<804d24ac>] (__driver_attach) from [<804d08b8>] (bus_for_each_dev+0x4c/0x9c) [<804d08b8>] (bus_for_each_dev) from [<804d18c0>] (bus_add_driver+0x188/0x20c) [<804d18c0>] (bus_add_driver) from [<804d2d54>] (driver_register+0x78/0xf4) [<804d2d54>] (driver_register) from [<80e2dd68>] (imx_serial_init+0x24/0x40) [<80e2dd68>] (imx_serial_init) from [<801019bc>] (do_one_initcall+0x44/0x168) [<801019bc>] (do_one_initcall) from [<80e00dac>] (kernel_init_freeable+0x144/0x1d0) [<80e00dac>] (kernel_init_freeable) from [<8098acd4>] (kernel_init+0x8/0x114) [<8098acd4>] (kernel_init) from [<801079e8>] (ret_from_fork+0x14/0x2c) Code: e34810c3 eb011f66 eaffff90 e5925090 (f57ff04f) —[ end trace d40066c75a3b7f3d ]— Kernel panic – not syncing: Attempted to kill init! exitcode=0x0000000b CPU1: stopping CPU: 1 PID: 0 Comm: swapper/1 Tainted: G D 4.14.98-2.0.0-ga-next+gaa8b26b7ca09 #1 Hardware name: Freescale i.MX7 Dual (Device Tree) [<8010f784>] (unwind_backtrace) from [<8010b410>] (show_stack+0x10/0x14) [<8010b410>] (show_stack) from [<809772c4>] (dump_stack+0x78/0x8c) [<809772c4>] (dump_stack) from [<8010e5d8>] (handle_IPI+0x198/0x1ac) [<8010e5d8>] (handle_IPI) from [<80101488>] (gic_handle_irq+0x8c/0x90) [<80101488>] (gic_handle_irq) from [<8010bf4c>] (__irq_svc+0x6c/0xa8) Exception stack(0x88085f78 to 0x88085fc0) 5f60: 00000001 00000000 5f80: 00000000 80118400 ffffe000 80f04db8 80f04d6c 80e6a520 80c17af4 00000000 5fa0: 00000000 00000000 00000001 88085fc8 80108470 80108474 60000013 ffffffff [<8010bf4c>] (__irq_svc) from [<80108474>] (arch_cpu_idle+0x38/0x3c) [<80108474>] (arch_cpu_idle) from [<80162910>] (do_idle+0x174/0x208) [<80162910>] (do_idle) from [<80162c5c>] (cpu_startup_entry+0x18/0x1c) [<80162c5c>] (cpu_startup_entry) from [<8010178c>] (__enable_mmu+0x0/0x14) —[ end Kernel panic – not syncing: Attempted to kill init! exitcode=0x0000000b imx-sdma 30bd0000.sdma: external firmware not found, using ROM firmware view raw kernel pani in RPMsg with Yocto Sumo in imx7d-pico hosted with ❤ by GitHub LikeLiked by 1 person

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.