Skip to main content

Setting Up MCUXpresso SDK and Toolchain for Cortex-M development

Introduction

MCUXpresso SDK is a collection of software responsible for compiling bare metal C and FreeRTOS to Cortex-M on HMP NXP processors. In addition to these base software, it includes many examples of different applications for Cortex-M. Check the MCUXpresso Software Development Kit (SDK) for more information.

Download MCUXpresso SDK

You will need a NXP account to continue with the steps below.

  1. Go to MCUXpresso SDK Builder.

  2. Click on Select Development Board.

    MCUExpresso Select Development Board

  3. Search for the right version based on the processor of your module.

    Below you can see all MCUXpresso SDK based on the module you are using.

    ProductMCUXpresso SDK
    Apalis iMX8QMMIMX8QM6xxxFF
    Apalis iMX8QPMIMX8QM6xxxFF
    Colibri iMX8DXMIMX8UX5xxxFZ
    Colibri iMX8QXPMIMX8QX5xxxFZ
    Colibri iMX7S/iMX7DToradex Github: FreeRTOS-Colibri-iMX7
    Verdin iMX8M Mini DualLiteMIMX8MM3xxxLZ
    Verdin iMX8M Mini DualLite WB ITMIMX8MM3xxxKZ
    Verdin iMX8M Mini QuadMIMX8MM6xxxKZ
    Verdin iMX8M Plus QuadMIMX8ML8xxxKZ
    Verdin iMX8M Plus QuadLiteMIMX8ML4xxxKZ
    info

    SDK for Colibri iMX7 is not available on MCUXpresso SDK website anymore. You will need to clone the repository in your computer to compile the examples.

  4. After selecting your SDK, click on Build MCUXpresso SDK.

    MCUExpresso Search CPU

  5. Select your Host and Toolchain options. For this article, we used Linux as the host and GCC as the toolchain.

  6. Select which configurations you want to add to your SDK. Here we used the multicore and FreeRTOS SDKs, which are the default options. Then, click on DOWNLOAD SDK.

    MCUExpresso Select Options

  7. Accept the software terms and conditions and download the file.

    MCUXpresso Download Final Archive

  8. Extract the downloaded file to a folder in your host machine. For this guide, we extracted the contents to the ~/cortex-m/ directory.

Download the GCC Toolchain

  1. Go to Arm GNU Toolchain Downloads and choose AArch32 bare-metal target (arm-none-eabi) for your host OS. Download the latest version for your OS. In this guide, we used gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz for Linux OS.

    GCC Toolchain Download

  2. Extract the file into a folder on your computer. We used the ~/cortex-m/toolchain/<GCC_TOOLCHAIN_FOLDER>/ folder for this example.

Compile your first binary

Before starting, make sure you have cmake installed in your system. In Debian based OSs, this can be achieved by running

$ sudo apt install cmake
  1. Go to the folder where you extracted your SDK.

    $ cd ~/cortex-m/<SDK_FOLDER>/
  2. [OPTIONAL] Create a git repository inside of it. This will help keep track of any modifications done to the software.

    $ git init
    $ git add .
    $ git commit -m "Initial Commit"

    This .gitignore file will help you with your build files, you can place it inside <SDK_FOLDER>:

    CMakeCache.txt
    build_log.txt
    CMakeFiles
    boards/*/**/armgcc
  3. Go to the build directory of the hello-world project.

    info

    If you are compiling this code for Apalis iMX8, you will see an additional folder to choose for which Cortex-M core you want to build your code. You can choose either core 1 or core 0.

    $ cd ./boards/<PROCESSOR_ID>/demo_apps/hello_world/armgcc/
  4. In this folder there are several build scripts. We will use the build_debug.sh for this tutorial, but you can use the others scripts as well. Before running the script tough, we need to export the ARMGCC_DIR environment variable to <GCC_TOOLCHAIN_FOLDER>. This variable must store the root directory of the GCC toolchain.

    $ export ARMGCC_DIR=~/cortex-m/toolchain/<GCC_TOOLCHAIN_FOLDER>
    $ ./build_debug.sh
  5. The final compiled binary will be inside the armgcc/debug folder. If everything worked, you should this output:

    -- TOOLCHAIN_DIR: /home/user/cortex-m/toolchain/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi
    -- BUILD_TYPE: debug
    -- TOOLCHAIN_DIR: /home/user/cortex-m/toolchain/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi
    -- BUILD_TYPE: debug
    -- The ASM compiler identification is GNU
    -- Found assembler: /home/user/cortex-m/toolchain/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc
    -- The C compiler identification is GNU 11.2.1
    -- The CXX compiler identification is GNU 11.2.1
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/boards/mekmimx8qx/demo_apps/hello_world/armgcc
    Scanning dependencies of target hello_world.elf
    [ 16%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/boards/mekmimx8qx/demo_apps/hello_world/clock_config.c.obj
    [ 16%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/boards/mekmimx8qx/demo_apps/hello_world/pin_mux.c.obj
    [ 16%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/boards/mekmimx8qx/demo_apps/hello_world/hello_world.c.obj
    [ 16%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/boards/mekmimx8qx/demo_apps/hello_world/empty_rsc_table.c.obj
    [ 20%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/utilities/debug_console_lite/fsl_debug_console.c.obj
    [ 24%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/boards/mekmimx8qx/demo_apps/hello_world/board.c.obj
    [ 32%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/drivers/fsl_common.c.obj
    [ 32%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/components/uart/fsl_adapter_lpuart.c.obj
    [ 36%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/drivers/fsl_clock.c.obj
    [ 40%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/scfw_api/main/ipc_imx8qx.c.obj
    [ 44%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/scfw_api/svc/pad/pad_rpc_clnt.c.obj
    [ 48%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/scfw_api/svc/misc/misc_rpc_clnt.c.obj
    [ 60%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/scfw_api/svc/timer/timer_rpc_clnt.c.obj
    [ 60%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/scfw_api/svc/pm/pm_rpc_clnt.c.obj
    [ 60%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/scfw_api/svc/rm/rm_rpc_clnt.c.obj
    [ 64%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/scfw_api/svc/seco/seco_rpc_clnt.c.obj
    [ 68%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/scfw_api/svc/irq/irq_rpc_clnt.c.obj
    [ 72%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/drivers/fsl_lpuart.c.obj
    [ 76%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/utilities/debug_console_lite/fsl_assert.c.obj
    [ 80%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/components/lists/fsl_component_generic_list.c.obj
    [ 84%] Building ASM object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/gcc/startup_MIMX8QX6_cm4.S.obj
    [ 88%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/system_MIMX8QX6_cm4.c.obj
    [ 92%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/drivers/fsl_gpio.c.obj
    [ 96%] Building C object CMakeFiles/hello_world.elf.dir/home/user/cortex-m/SDK_2_9_0_MIMX8QX5xxxFZ/devices/MIMX8QX6/utilities/fsl_sbrk.c.obj
    [100%] Linking C executable debug/hello_world.elf

Now you completed your first build of a hello-world program for the Cortex-M. Follow the next guides to check what modifications are needed to run the examples based on each module.



Send Feedback!