AM261x MCU+ SDK: Additional Details

| AM261x MCU+ SDK 26.00.00 |

Additional Details

## Alternate Method to Build and Run the examples

Note
  These steps are optional.

Below method cab be used for running examples built with makefiles

- Step 1: Build a "hello world" example for the EVM, see Build a Hello World example
- Step 2: Load and run the "hello world" example on the EVM, see CCS Launch, Load and Run and IAR Launch, Load and Run
- Step 3: Flash the "hello world" example on the EVM and boot without CCS, see Flash a Hello World example

### SOC Initialization

Before any program can be loaded and run on the EVM, the SOC needs to be initialized. Below sections describes the various options available for SOC initialization.

### SOC Initialization Using CCS Scripting

#### Set Environment Variable

Note
  This step needs to be done once and is needed for the SOC initialization script `load_sbl.js` to find certain initialization files within the SDK folder. This variable is not used otherwise in the build process. If you dont like adding variables in the environment, then you need to edit the file `${SDK_INSTALL_PATH}/tools/ccs_load/am261x/load_sbl.js` and specify the SDK path in the file itself.

- Add path to the SDK folder as a environment variable in the host machine.
- In windows, goto "Windows Task Bar Search" and search for "environment variables for your account"
  Environment Variables For Your Account
- Add a new variable named `MCU_PLUS_SDK_AM261X_PATH` and point it to the path where the SDK is installed

Add New Environment Variable For Your Account

- In Linux, usually you need to add a line as below in the ${HOME}/.bashrc,

        export MCU_PLUS_SDK_AM243X_PATH=${HOME}/ti/mcu_plus_sdk_am261x_{sdk version}/

- If CCS is open, close and reopen CCS for the CCS to be able to see the updated environment variable

#### Run the SOC Initialization Script

##### AM261X-LP

Attention
  This step needs to be done every time the AM261X-LP is power-cycled.

- POWER-OFF the AM261X-LP
- Make sure below cables are connected as shown in Cable Connections
  - Power cable
  - JTAG cable
- Set AM261X-LP in DEVBOOT mode as shown below

DEVBOOT MODE

- POWER-ON the AM261X-LP
- Launch the target configuration created with Create Target Configuration

Launch Target Configuration

- You will see the AM261X target configuration in the "Debug" window as shown below

Target Configuration After Launch

- Goto "CCS Toolbar > View > Scripting Console"
- Type the below command in the scripting console and press "enter", to load DMSC FW and initialize the SOC
  - In Windows, assuming the SDK is installed at `C:/ti/mcu_plus_sdk_{soc}_{sdk version}`

        loadJSFile "C:/ti/mcu_plus_sdk_{soc}_{sdk version}/tools/ccs_load/am261x/load_sbl.js"

Scripting Console

- In Linux, run the same command, only the path would be a Linux path like `/home/{username}/ti/mcu_plus_sdk_{soc}_{sdk version}/tools/ccs_load/am261x/load_sbl.js`
- After successful execution of this script one would see logs as below
  - In the scripting console, this is log from the script itself.
    Scripting Console Log
- In case of success, there should be no error logs in the scripting console. The core will continue to run and the user can halt and reset the core.
- If the script is run without providing power to the AM261X-LP or if the AM261X-LP BOOTMODE is not set to DEVBOOT MODE then you will see errors in the console and/or unexpected behaviour and error messages.
  - SOLUTION: Power cycle AM261X-LP and repeat the steps.

##### AM261X-SOM

Attention
  This step needs to be done every time the AM261X-SOM is power-cycled.

- POWER-OFF the AM261X-SOM
- Make sure below cables are connected as shown in Cable Connections
  - Power cable
  - JTAG cable
- Set AM261X-SOM in DEVBOOT mode as shown below

DEVBOOT MODE

- POWER-ON the AM261X-SOM
- Launch the target configuration created with Create Target Configuration

Launch Target Configuration

- You will see the AM261X target configuration in the "Debug" window as shown below

Target Configuration After Launch

- Goto "CCS Toolbar > View > Scripting Console"
- Type the below command in the scripting console and press "enter", to load DMSC FW and initialize the SOC
  - In Windows, assuming the SDK is installed at `C:/ti/mcu_plus_sdk_{soc}_{sdk version}`

        loadJSFile "C:/ti/mcu_plus_sdk_{soc}_{sdk version}/tools/ccs_load/am261x/load_sbl.js"

Scripting Console

- In Linux, run the same command, only the path would be a Linux path like `/home/{username}/ti/mcu_plus_sdk_{soc}_{sdk version}/tools/ccs_load/am261x/load_sbl.js`
- After successful execution of this script one would see logs as below
  - In the scripting console, this is log from the script itself.
    Scripting Console Log
- In case of success, there should be no error logs in the scripting console. The core will continue to run and the user can halt and reset the core.
- If the script is run without providing power to the AM261X-SOM or if the AM261X-SOM BOOTMODE is not set to DEVBOOT MODE then you will see errors in the console and/or unexpected behaviour and error messages.
  - SOLUTION: Power cycle AM261X-SOM and repeat the steps.

### SOC Initialization using the Binary Flashed in OSPI memory

## AM261X-SOM

The `sbl_null` is a secondary bootloader which doesn't load any application binary, but just does the SOC initialization and puts all the cores in WFI (Wait For Interrupt) mode.

- This is a recommended one time step that needs to be done before you can load and run programs via CCS
- If this step fails, maybe due to bad flash in EVM, then try one of the other SOC initialization steps mentioned at SOC Initialization
- This step needs to be done once unless the OSPI flash has been erased or some other application has been flashed
- 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
- POWER-OFF the EVM
- Set boot mode to UART BOOTMODE as shown in below image

UART BOOT MODE

- POWER-ON the EVM
- You should see character "C" getting printed on the UART terminal every 2-3 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/am261x-som/default_sbl_null.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/ttyUSB0`
    - 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 ...
- POWER-OFF the EVM
- Switch the EVM boot mode to OSPI mode as shown below,

OSPI BOOT MODE

- Re-connect the UART terminal in CCS window as shown in Setup UART Terminal
- POWER-ON the EVM

## AM261X-LP

The `sbl_null` is a secondary bootloader which doesn't load any application binary, but just does the SOC initialization and puts all the cores in WFI (Wait For Interrupt) mode.

- This is a recommended one time step that needs to be done before you can load and run programs via CCS
- If this step fails, maybe due to bad flash in EVM, then try one of the other SOC initialization steps mentioned at SOC Initialization
- This step needs to be done once unless the OSPI flash has been erased or some other application has been flashed
- 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
- POWER-OFF the EVM
- Set boot mode to UART BOOTMODE as shown in below image

UART BOOT MODE

- POWER-ON the EVM
- You should see character "C" getting printed on the UART terminal every 2-3 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/am261x-lp/default_sbl_null.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/ttyUSB0`
    - 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 ...
- POWER-OFF the EVM
- Switch the EVM boot mode to OSPI mode as shown below,

OSPI BOOT MODE

- Re-connect the UART terminal in CCS window as shown in Setup UART Terminal
- POWER-ON the EVM

### Run the example

- Now you can run the example built (see CCS Launch, Load and Run IAR Launch, Load and Run)
- Connect to any of the Cortex_R5_0/Cortex_R5_1 cores, load programs and run (see Load and run example binaries in CCS, Load and run example binaries in IAR Embedded Workbench)