.. _run-app-hello: Hello-world on the Cortex-M coprocessor ======================================= This example builds and runs a simple hello-world application on the Cortex-M coprocessor of NXP i.MX8 (8M Mini/Nano/Plus) and i.MX9 (93) modules, while Linux runs on the Cortex-A cores. Please also read the chapter 'Run a demo using Arm GCC' in the 'Getting Started with MCUXpresso SDK' document shipped with the SDK (see :doc:`setup`). Building the firmware --------------------- Open a terminal and change into the example's ``armgcc`` directory inside the SDK, which has a path similar to: .. code-block:: text /boards////armgcc For the hello-world sample on i.MX8M Mini that is: .. code-block:: text /boards/evkmimx8mm/demo_apps/hello_world/armgcc Run one of the available build scripts, e.g.: .. prompt:: :prompts: $ build_debug.sh The script should end with: .. code-block:: text [100%] Linking C executable debug/hello_world.elf [100%] Built target hello_world.elf Deploying the firmware to the target ------------------------------------ The firmware binary (``hello_world.bin``) can be stored in the bootfs partition of the eMMC. After building the Yocto Linux image and flashing it with uuu, examine the partitions in U-Boot: .. prompt:: :prompts: U-Boot> part list mmc ${mmcdev} Use the U-Boot USB mass-storage function to mount the boot partition on your host PC: .. prompt:: :prompts: U-Boot> ums 0 mmc ${mmcdev}:1 .. prompt:: :prompts: $ sudo mount /dev/sdX /mnt Copy ``hello_world.bin`` to the mounted boot partition, unmount it and stop the ums device with :kbd:`CTRL` + :kbd:`C` in U-Boot. Check from U-Boot: .. prompt:: :prompts: U-Boot> ls mmc ${mmcdev}:1 Starting the firmware --------------------- The firmware uses a dedicated UART for its output (on i.MX8M this is UART4, available on the module pins; note these are 3.3 V pins — use a second TTL-to-USB adapter and a serial terminal at 115200 8N1). The Cortex-M firmware sets up its pinmux itself, so make sure the devices used by the firmware are disabled in the Linux devicetree. Three steps start the firmware from U-Boot: 1. copy the firmware from the mmc device into local memory 2. copy it from local memory into the coprocessor's Tightly-Coupled Memory (TCM) 3. start it with the **bootaux** command The TCM addresses differ per SoC: .. list-table:: :header-rows: 1 :widths: 30 25 45 * - SoC (coprocessor) - copy to (TCM) - bootaux address * - i.MX 8M Mini/Nano (Cortex-M4) - ``0x7e0000`` - ``bootaux 0x7e0000`` * - i.MX 8M Plus (Cortex-M7) - ``0x7e0000`` - ``bootaux 0x7e0000`` * - i.MX 93 (Cortex-M33) - ``0x201e0000`` - ``bootaux 0x1ffe0000 0`` Example (i.MX 8M Mini): .. prompt:: :prompts: U-Boot> load mmc ${mmcdev}:1 ${loadaddr} hello_world.bin cp.b ${fileaddr} 0x7e0000 0x20000 bootaux 0x7e0000 .. code-block:: text ## Starting auxiliary core stack = 0x20020000, pc = 0x1FFE030D... "hello world." is printed on the coprocessor's debug UART: .. figure:: images/SDKXpresso-hello-world.png :scale: 35 % :align: left :figwidth: 100%