AM263Px MCU+ SDK: Flash a Hello World example

| AM263Px MCU+ SDK 26.00.00 |

Flash a Hello World example

Attention
  Flashing a application will overwrite the SOC init application that was flashed earlier. So if you want to load and run from CCS again, you will need to do the SOC init steps again. See SOC Initialization for more details.

Note
  See also Flashing Tools for more details on the flashing tools.

# Introduction

In this step we will flash the application that we have build and run using CCS to the EVM flash. We can then boot this application without being connected to CCS via JTAG.

# Getting ready to flash the application

- A quick recap of steps done so far that are needed for the flashing to work
  - Make sure the UART port used for terminal is identified as mentioned in Setup UART Terminal
  - Make sure python3 is installed as mentioned in Python3
  - Make sure you have the EVM power cable and UART cable connected as shown in Cable Connections
- Build the hello world application as mentioned in Build a Hello World example
- As part of the build process in the final step, files with extension `.mcelf` and `.mcelf_xip` are generated. These are the files we need to flash.

  - When building with makefiles and single-core projects, this file can be found here (shown for hello world example),

    ${SDK_INSTALL_PATH}/examples/hello_world/{board}/r5fss0-0_freertos/ti-arm-clang/hello_world.release.mcelf ${SDK_INSTALL_PATH}/examples/hello_world/{board}/r5fss0-0_freertos/ti-arm-clang/hello_world.release.mcelf_xip

  - When building with CCS and single-core projects, this file can be found here (shown for hello world example),

        ${CCS_WORKSPACE_PATH}/hello_world_{board}_r5fss0-0_freertos_ti-arm-clang/Release/hello_world_{board}_r5fss0-0_freertos_ti-arm-clang.mcelf
        ${CCS_WORKSPACE_PATH}/hello_world_{board}_r5fss0-0_freertos_ti-arm-clang/Release/hello_world_{board}_r5fss0-0_freertos_ti-arm-clang.mcelf_xip

  - When building with makefiles and multi-core system projects, this file can be found here (shown for IPC Notify example),

        ${SDK_INSTALL_PATH}/examples/drivers/ipc/ipc_notify_echo/{board}/system_freertos_nortos/ipc_notify_echo_system.release.mcelf
        ${SDK_INSTALL_PATH}/examples/drivers/ipc/ipc_notify_echo/{board}/system_freertos_nortos/ipc_notify_echo_system.release.mcelf_xip

  - When building with CCS and multi-core system projects, this file can be found here (shown for IPC Notify example),

        ${CCS_WORKSPACE_PATH}/ipc_notify_echo_{board}_system_freertos_nortos/Release/ipc_notify_echo_system.mcelf
        ${CCS_WORKSPACE_PATH}/ipc_notify_echo_{board}_system_freertos_nortos/Release/ipc_notify_echo_system.mcelf_xip

  - NOTE: The folder name and file name in path can have "release", "Release" or "debug", "Debug" based on the profile that the application is built with.
- Next, we need to list the files to flash in a flash configuration file. A default configuration file can be found at below path. You can edit this file directly or take a copy and edit this file.

Configuration file is `mcelf_sbl_ospi.cfg`

- Edit below line in the config file to point to your application `.mcelf` file. Give the absolute path to the `.mcelf` file or path relative to `${SDK_INSTALL_PATH}/tools/boot`. Make sure to use forward slash `/` in the filename path.

        --file=../../examples/drivers/ipc/ipc_notify_echo/{board}/system_freertos_nortos/ipc_notify_echo_system.release.mcelf --operation=flash-sector-write --flash-offset=0x81000

- Edit below line in the config file to point to your application `.mcelf_xip` file. Give the absolute path to the `.mcelf_xip` file or path relative to `${SDK_INSTALL_PATH}/tools/boot`. Make sure to use forward slash `/` in the filename path.

        --file=../../examples/drivers/ipc/ipc_notify_echo/{board}/system_freertos_nortos/ipc_notify_echo_system.release.mcelf_xip --operation=flash-mcelf-xip

- This file will additionally also list the flashing application that is run on the EVM and a OSPI flash bootloader that also needs to be flashed. You can keep this unchanged if you have not modified these applications.
- Save and close the config file.

# Flashing the application

- POWER-OFF the Evaluation board
- The boot mode should be UART BOOT MODE
- POWER-ON the Evaluation board
- You should see character "C" getting printed on the UART terminal every 1-2 seconds as shown below

UART output in UART BOOT MODE

- Close the UART terminal as shown below. This is important, else the UART script in next step wont be able to connect to the UART port.

Close UART terminal

- Open a command prompt and run the below command to flash the SOC initialization binary to the EVM.

        cd ${SDK_INSTALL_PATH}/tools/boot

        python uart_uniflash.py -p COM<x> --cfg=sbl_prebuilt/am263px-cc/mcelf_sbl_ospi.cfg

  - Here COM<x> is the port name of the identified UART port in Windows.
  - On Linux,
    - The name for UART port is typically something like `/dev/ttyACM0`
    - On some Linux systems, one needs to use `python3` to invoke python3.x, just `python` command may invoke python 2.x which will not work with the flashing script.
- When the flashing is in progress you will see something like below
  Flash in progress
- After all the flashing is done, you will see something like below
  Flashing successful
- If flashing has failed, see Flash tool error messages and solutions, and resolve the errors.
- If flashing is successful, do the next steps ...

# Running the flashed application

- POWER-OFF the EVM
- Change the boot mode to OSPI BOOT MODE
- POWER-ON the EVM
- Re-connect the UART terminal in CCS window as shown in Setup UART Terminal
- Press the reset button on the board as shown in Cable Connections