AM261x MCU+ SDK: APIs for BOOTLOADING CPUs

| AM261x MCU+ SDK 26.00.00 |

Data Structures | Functions | Typedefs | Macros
APIs for BOOTLOADING CPUs
APIs for SOC Specific Device Drivers

## Introduction

See BOOTLOADER for more details.

## Data Structures
struct | Bootloader_Params
| Parameters passed during Bootloader_open() More...
struct | Bootloader_Fxns
| Driver implementation callbacks. More...
struct | Bootloader_Config
| Bootloader driver configuration, these are filled by SysCfg based on the boot media selected. More...
struct | Bootloader_CpuInfo
| Data structure containing information related to a particular CPU, required for RPRC loading. More...
struct | Bootloader_BootImageInfo
| Data structure containing information related all CPUs, this will be filled by Bootloader_parseMultiCoreAppImage. More...

## Functions
void | Bootloader_Params_init (Bootloader_Params *params)
| Initialize Bootloader params. More...
void | Bootloader_BootImageInfo_init (Bootloader_BootImageInfo *bootImageInfo)
| Initialize BootImage info. More...
void | Bootloader_CpuInfo_init (Bootloader_CpuInfo *cpuInfo)
| Initialize CPU info. More...
Bootloader_Handle | Bootloader_open (uint32_t instanceNum, Bootloader_Params *openParams)
| Open bootloader driver. More...
void | Bootloader_close (Bootloader_Handle handle)
| Close bootloader driver. More...
int32_t | Bootloader_initCpu (Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
| API to initialize a non-self CPU. More...
int32_t | Bootloader_loadCpu (Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
| API to load a non-self CPU. More...
int32_t | Bootloader_loadSelfCpu (Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo, uint32_t skipLoad)
| API to load self CPU. More...
int32_t | Bootloader_runCpu (Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
| API to run a non-self CPU. More...
int32_t | Bootloader_runSelfCpu (Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
| API to boot self CPU. More...
int32_t | Bootloader_bootCpu (Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
| API to boot a non-self CPU. More...
int32_t | Bootloader_bootSelfCpu (Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
| API to boot self CPU. More...
int32_t | Bootloader_parseMultiCoreAppImage (Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
| Parse Multicore Appimage. More...
int32_t | Bootloader_cpuSetAppEntryPoint (Bootloader_BootImageInfo *bootImageInfo, uint32_t bDualSelfR5F)
| Set Application entry point for self CPU in the AM65x SOC from reset. More...
int32_t | Bootloader_rprcImageParseEntryPoint (Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
| Parse entrypoint from RPRC. More...
int32_t | Bootloader_rprcImageLoad (Bootloader_Handle handle, Bootloader_CpuInfo *cpuInfo)
| Load application binaries into SOC memory. More...
int32_t | Bootloader_parseAndLoadLinuxAppImage (Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
| Parse and load linux Appimage, containing linux binaries(ATF, OPTEE, SPL) More...
int32_t | Bootloader_runSelfCpuWithLinux (void)
| API to boot self CPU with Linux. More...
uint32_t | Bootloader_getMulticoreImageSize (Bootloader_Handle handle)
| API to fetch the size of the multicore image. More...
uint32_t | Bootloader_isCorePresent (Bootloader_Handle handle, uint32_t cslCoreId)
| API to check if a particular core's image is present in the multicore image. More...
uint32_t | Bootloader_getBootMedia (Bootloader_Handle handle)
| API to get the selected boot media in the bootloader instance. More...
int32_t | Bootloader_parseAndLoadMultiCoreELF (Bootloader_Handle handle, Bootloader_BootImageInfo *bootImageInfo)
| API to parse and load MCELF image. More...
uint32_t | Bootloader_getX509CertLen (uint8_t *x509_cert_ptr)
| API to get the length of an x509 certificate. More...
uint32_t | Bootloader_getMsgLen (uint8_t *x509_cert_ptr, uint32_t x509_cert_size)
| API to get image length from a x509 certificate. More...

## Typedefs
typedef void * | Bootloader_Handle
| Handle to the Bootloader driver returned by Bootloader_open() More...

## Macros
#define | BOOTLOADER_INVALID_ID (0xDEADBABE)
| Invalid ID magic number to be used for initializations. More...
#define | BOOTLOADER_OPMODE_LOCKSTEP (0U)
| Operating mode type. More...
#define | BOOTLOADER_OPMODE_STANDALONE (1U)
#define | BOOTLOADER_MEDIA_MEM (0xB0070001)
| Boot media IDs. More...
#define | BOOTLOADER_MEDIA_FLASH (0xB0070002)
#define | BOOTLOADER_MEDIA_EMMC (0xB0070003)
#define | BOOTLOADER_MEDIA_SD (0xB0070004)
#define | BOOTLOADER_MEDIA_BUFIO (0xB0070005)
#define | BOOTLOADER_MEDIA_PCIE (0xB0070006)
#define | BOOTLOADER_MEDIA_USB (0xB0070007)
#define | BOOTLOADER_MEDIA_UART (0xB0070008)
#define | BOOTLOADER_SCRATCH_MEM_ENABLE (1U)
| Bootloader buffer enable. More...
#define | LINUX_LOAD_ONLY_IMAGE_ID (21U)
| RPRC image ID for linux load only images. More...

## Bootloader driver implementation callbacks
typedef int32_t(* | Bootloader_imgOpenFxn) (void *args, Bootloader_Params *params)
| Driver implementation to open a specific bootloader driver - Memory, OSPI, UART, MMCSD etc. More...
typedef int32_t(* | Bootloader_imgReadFxn) (void *dstAddr, uint32_t length, void *args)
| Driver implementation to read from boot media using a specific bootloader driver - Memory, OSPI, UART, MMCSD etc. More...
typedef uint32_t(* | Bootloader_imgOffsetFxn) (void *args)
| Driver implementation to get the current offset in the boot media. More...
typedef void(* | Bootloader_imgSeekFxn) (uint32_t location, void *args)
| Driver implementation to read from boot media using a specific bootloader driver - Memory, OSPI, UART, MMCSD etc. More...
typedef void(* | Bootloader_imgCloseFxn) (void *handle, void *args)
| Driver implementation to close a specific bootloader driver - Memory, OSPI, UART, MMCSD etc. More...
typedef int32_t(* | Bootloader_imgCustomFxn) (void *args)
| Driver implementation to enable a custom function for a specific bootloader driver - Memory, OSPI, UART, MMCSD etc. More...

## Macro Definition Documentation

## ◆ BOOTLOADER_INVALID_ID

#define BOOTLOADER_INVALID_ID (0xDEADBABE)

Invalid ID magic number to be used for initializations.

## ◆ BOOTLOADER_OPMODE_LOCKSTEP

#define BOOTLOADER_OPMODE_LOCKSTEP (0U)

Operating mode type.

## ◆ BOOTLOADER_OPMODE_STANDALONE

#define BOOTLOADER_OPMODE_STANDALONE (1U)

## ◆ BOOTLOADER_MEDIA_MEM

#define BOOTLOADER_MEDIA_MEM (0xB0070001)

Boot media IDs.

## ◆ BOOTLOADER_MEDIA_FLASH

#define BOOTLOADER_MEDIA_FLASH (0xB0070002)

## ◆ BOOTLOADER_MEDIA_EMMC

#define BOOTLOADER_MEDIA_EMMC (0xB0070003)

## ◆ BOOTLOADER_MEDIA_SD

#define BOOTLOADER_MEDIA_SD (0xB0070004)

## ◆ BOOTLOADER_MEDIA_BUFIO

#define BOOTLOADER_MEDIA_BUFIO (0xB0070005)

## ◆ BOOTLOADER_MEDIA_PCIE

#define BOOTLOADER_MEDIA_PCIE (0xB0070006)

## ◆ BOOTLOADER_MEDIA_USB

#define BOOTLOADER_MEDIA_USB (0xB0070007)

## ◆ BOOTLOADER_MEDIA_UART

#define BOOTLOADER_MEDIA_UART (0xB0070008)

## ◆ BOOTLOADER_SCRATCH_MEM_ENABLE

#define BOOTLOADER_SCRATCH_MEM_ENABLE (1U)

Bootloader buffer enable.

## ◆ LINUX_LOAD_ONLY_IMAGE_ID

#define LINUX_LOAD_ONLY_IMAGE_ID (21U)

RPRC image ID for linux load only images.

## Typedef Documentation

## ◆ Bootloader_Handle

typedef void* Bootloader_Handle

Handle to the Bootloader driver returned by Bootloader_open()

## ◆ Bootloader_imgOpenFxn

typedef int32_t(* Bootloader_imgOpenFxn) (void *args, Bootloader_Params *params)

Driver implementation to open a specific bootloader driver - Memory, OSPI, UART, MMCSD etc.

Typically this callback is hidden from the end application and is implemented when a new boot media needs to be supported.

Parameters

  args | [in] Boot media specific arguments, obtained from the config
  params | [in] User controllable params

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_imgReadFxn

typedef int32_t(* Bootloader_imgReadFxn) (void *dstAddr, uint32_t length, void *args)

Driver implementation to read from boot media using a specific bootloader driver - Memory, OSPI, UART, MMCSD etc.

Typically this callback is hidden from the end application and is implemented when a new boot media needs to be supported.

Parameters

  dstAddr | [in] Destination address to which the data is to be read into
  length | [in] Length in bytes of the data to be read
  args | [in] Boot media specific arguments, obtained from the config

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_imgOffsetFxn

typedef uint32_t(* Bootloader_imgOffsetFxn) (void *args)

Driver implementation to get the current offset in the boot media.

Typically this callback is hidden from the end application and is implemented when a new boot media needs to be supported.

Parameters

  args | [in] Boot media specific arguments, obtained from the config

Returns
  Current Offset

## ◆ Bootloader_imgSeekFxn

typedef void(* Bootloader_imgSeekFxn) (uint32_t location, void *args)

Driver implementation to read from boot media using a specific bootloader driver - Memory, OSPI, UART, MMCSD etc.

Typically this callback is hidden from the end application and is implemented when a new boot media needs to be supported.

Parameters

  location | [in] location of bootloader image
  args | [in] Boot media specific arguments, obtained from the config

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_imgCloseFxn

typedef void(* Bootloader_imgCloseFxn) (void *handle, void *args)

Driver implementation to close a specific bootloader driver - Memory, OSPI, UART, MMCSD etc.

Typically this callback is hidden from the end application and is implemented when a new boot media needs to be supported.

Parameters

  handle | [in] Handle returned from Bootloader_imgOpen
  args | [in] Boot media specific arguments, obtained from the config

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_imgCustomFxn

typedef int32_t(* Bootloader_imgCustomFxn) (void *args)

Driver implementation to enable a custom function for a specific bootloader driver - Memory, OSPI, UART, MMCSD etc.

Typically this callback is hidden from the end application and is implemented when a new boot media needs to be supported.

Parameters

  args | [in] Boot media specific arguments, obtained from the config

Returns
  SystemP_SUCCESS on success, else failure

## Function Documentation

## ◆ Bootloader_Params_init()

void Bootloader_Params_init | ( | Bootloader_Params * | params | ) |

Initialize Bootloader params.

Parameters

  params | [out] Pointer to a Bootloader_Params structure

## ◆ Bootloader_BootImageInfo_init()

void Bootloader_BootImageInfo_init | ( | Bootloader_BootImageInfo * | bootImageInfo | ) |

Initialize BootImage info.

Parameters

  bootImageInfo | [out] Pointer to a Bootloader_BootImageInfo structure

## ◆ Bootloader_CpuInfo_init()

void Bootloader_CpuInfo_init | ( | Bootloader_CpuInfo * | cpuInfo | ) |

Initialize CPU info.

Parameters

  cpuInfo | [out] Pointer to a Bootloader_CpuInfo structure

## ◆ Bootloader_open()

Bootloader_Handle Bootloader_open | ( | uint32_t | instanceNum,
|  | Bootloader_Params * | openParams
| ) |  |

Open bootloader driver.

Make sure the SOC periheral driver is open'ed before calling this API. Drivers_open function generated by SysCfg opens the underlying SOC peripheral driver, e.g OSPI.

Global variables `Bootloader_Config gBootloaderConfig[]` and `uint32_t gBootloaderConfigNum` is instantiated by SysCfg to describe the boot media and other configuration based on user selection in SysCfg.

Parameters

  instanceNum | [in] Index within `Bootloader_Config gBootloaderConfig[]` denoting the bootloader driver to open
  openParams | [in] Open parameters

Returns
  Handle to bootloader driver which should be used in subsequent API call
  NULL in case of failure

## ◆ Bootloader_close()

void Bootloader_close | ( | Bootloader_Handle | handle | ) |

Close bootloader driver.

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open

## ◆ Bootloader_initCpu()

int32_t Bootloader_initCpu | ( | Bootloader_Handle | handle,
|  | Bootloader_CpuInfo * | cpuInfo
| ) |  |

API to initialize a non-self CPU.

This API will initialize a non-self CPU, i.e a CPU on which the bootloader application is not running. This API is not applicable for cores from self cluster. They will be loaded by the Bootloader_loadSelfCpu API.

NOTE: No checks are done to confirm non-self CPU ID is passed, user need to make sure non-self CPU ID is passed, else the load could fail.

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open
  cpuInfo | [in] Data structure containing information regarding the CPU. This should have been filled by the Bootloader_parseMultiCoreAppImage API

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_loadCpu()

int32_t Bootloader_loadCpu | ( | Bootloader_Handle | handle,
|  | Bootloader_CpuInfo * | cpuInfo
| ) |  |

API to load a non-self CPU.

This API will load RPRC images on a non-self CPU, i.e a CPU on which the bootloader application is not running. This API is not applicable for cores from self cluster. They will be loaded by the Bootloader_loadSelfCpu API.

NOTE: No checks are done to confirm non-self CPU ID is passed, user need to make sure non-self CPU ID is passed, else the load could fail.

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open
  cpuInfo | [in] Data structure containing information regarding the CPU. This should have been filled by the Bootloader_parseMultiCoreAppImage API

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_loadSelfCpu()

int32_t Bootloader_loadSelfCpu | ( | Bootloader_Handle | handle,
|  | Bootloader_CpuInfo * | cpuInfo,
|  | uint32_t | skipLoad
| ) |  |

API to load self CPU.

This API will load RPRC images on self CPU, i.e a CPU on which the bootloader application is running

NOTE: No checks are done to confirm self CPU ID is passed, user need to make sure self CPU ID is passed, else the load could fail.

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open
  cpuInfo | [in] Data structure containing information regarding the CPU. This should have been filled by the Bootloader_parseMultiCoreAppImage API
  skipLoad | [in] Skip the image load, only do the initialization

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_runCpu()

int32_t Bootloader_runCpu | ( | Bootloader_Handle | handle,
|  | Bootloader_CpuInfo * | cpuInfo
| ) |  |

API to run a non-self CPU.

This API will run a non-self CPU, i.e a CPU on which the bootloader application is not running. This API is not applicable for cores from self cluster. They will be run by the Bootloader_runSelfCpu API. It is expected that this API be called after Bootloader_loadCpu API

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open
  cpuInfo | [in] Data structure containing information regarding the CPU. This should have been filled by the Bootloader_parseMultiCoreAppImage API

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_runSelfCpu()

int32_t Bootloader_runSelfCpu | ( | Bootloader_Handle | handle,
|  | Bootloader_BootImageInfo * | bootImageInfo
| ) |  |

API to boot self CPU.

This API will boot self CPU, i.e a CPU on which the bootloader application is running. It is expected that this API be called after Bootloader_loadSelfCpu API

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open
  bootImageInfo | [in] Data structure of type Bootloader_BootImageInfo containing information regarding self CPU. This should have been filled by the Bootloader_parseMultiCoreAppImage API

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_bootCpu()

int32_t Bootloader_bootCpu | ( | Bootloader_Handle | handle,
|  | Bootloader_CpuInfo * | cpuInfo
| ) |  |

API to boot a non-self CPU.

This API will boot a non-self CPU, i.e a CPU on which the bootloader application is not running. Now if the self CPU is a dual core CPU, like a Cortex R5, this API is not applicable for the second core of the self CPU. That will be booted by the Bootloader_bootSelfCpu API.

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open
  cpuInfo | [in] Data structure containing information regarding the CPU. This should have been filled by the Bootloader_parseMultiCoreAppImage API

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_bootSelfCpu()

int32_t Bootloader_bootSelfCpu | ( | Bootloader_Handle | handle,
|  | Bootloader_BootImageInfo * | bootImageInfo
| ) |  |

API to boot self CPU.

This API will boot self CPU, i.e a CPU on which the bootloader application is running

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open
  bootImageInfo | [in] Data structure of type Bootloader_BootImageInfo containing information regarding self CPU. This should have been filled by the Bootloader_parseMultiCoreAppImage API

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_parseMultiCoreAppImage()

int32_t Bootloader_parseMultiCoreAppImage | ( | Bootloader_Handle | handle,
|  | Bootloader_BootImageInfo * | bootImageInfo
| ) |  |

Parse Multicore Appimage.

When the booting is done through some boot media, unlike loading via CCS, the application binaries for each core applicable are converted into a file format '.rprc' and combined together into a multicore appimage binary. The bootloader needs to read this appimage, and load the binaries correctly into memories. This API helps in parsing the multicore appimage and filling the metadata in the bootImageInfo structure passed.

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open
  bootImageInfo | [in] Data structure of type Bootloader_BootImageInfo which will be filled

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_cpuSetAppEntryPoint()

int32_t Bootloader_cpuSetAppEntryPoint | ( | Bootloader_BootImageInfo * | bootImageInfo,
|  | uint32_t | bDualSelfR5F
| ) |  |

Set Application entry point for self CPU in the AM65x SOC from reset.

Parameters

  bootImageInfo | [out] Pointer to a Bootloader_BootImageInfo structure
  bDualSelfR5F | TRUE (1U) if dual cores enabled, FALSE (0U) if not.

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_rprcImageParseEntryPoint()

int32_t Bootloader_rprcImageParseEntryPoint | ( | Bootloader_Handle | handle,
|  | Bootloader_CpuInfo * | cpuInfo
| ) |  |

Parse entrypoint from RPRC.

This API reads the RPRC image to parse the entry points of a particular CPU

## ◆ Bootloader_rprcImageLoad()

int32_t Bootloader_rprcImageLoad | ( | Bootloader_Handle | handle,
|  | Bootloader_CpuInfo * | cpuInfo
| ) |  |

Load application binaries into SOC memory.

This API loads the application binaries for each core applicable is loaded from the boot media to the SOC memory

## ◆ Bootloader_parseAndLoadLinuxAppImage()

int32_t Bootloader_parseAndLoadLinuxAppImage | ( | Bootloader_Handle | handle,
|  | Bootloader_BootImageInfo * | bootImageInfo
| ) |  |

Parse and load linux Appimage, containing linux binaries(ATF, OPTEE, SPL)

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open
  bootImageInfo | [in] Data structure of type Bootloader_BootImageInfo which will be filled

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_runSelfCpuWithLinux()

int32_t Bootloader_runSelfCpuWithLinux | ( | void |  | ) |

API to boot self CPU with Linux.

This API will boot self CPU, i.e a CPU on which the bootloader application is running. It is expected that this API be called after Bootloader_loadSelfCpu API. This API does not perform a security handoff

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_getMulticoreImageSize()

uint32_t Bootloader_getMulticoreImageSize | ( | Bootloader_Handle | handle | ) |

API to fetch the size of the multicore image.

This API simply returns the internal global variable which gets updated everytime a section is loaded. So this API should only be called after all the rprc loading is complete.

Parameters

  handle | Bootloader driver handle from Bootloader_open

Returns
  Size of the multicore image size

## ◆ Bootloader_isCorePresent()

uint32_t Bootloader_isCorePresent | ( | Bootloader_Handle | handle,
|  | uint32_t | cslCoreId
| ) |  |

API to check if a particular core's image is present in the multicore image.

This API checks the csl core id against an internally maintained bitmap which will be populated after parsing the image. So this API should be called only after the multicore image is parsed.

Parameters

  handle | Bootloader driver handle from Bootloader_open
  cslCoreId | CSL core ID of the interested core

Returns
  TRUE if the given core's rprc is present in the multicore image

## ◆ Bootloader_getBootMedia()

uint32_t Bootloader_getBootMedia | ( | Bootloader_Handle | handle | ) |

API to get the selected boot media in the bootloader instance.

This API returns the selected boot media. This data will be filled by sysconfig

Parameters

  handle | [in] Bootloader driver handle from Bootloader_open

Returns
  Boot media ID of the selected media

## ◆ Bootloader_parseAndLoadMultiCoreELF()

int32_t Bootloader_parseAndLoadMultiCoreELF | ( | Bootloader_Handle | handle,
|  | Bootloader_BootImageInfo * | bootImageInfo
| ) |  |

API to parse and load MCELF image.

This API parses the MCELF file and loads the loadable segments into xthe respective cores.

Parameters

  handle | Bootloader driver handle from Bootloader_open
  bootImageInfo | [in] Data structure of type Bootloader_BootImageInfo which will be filled

Returns
  SystemP_SUCCESS on success, else failure

## ◆ Bootloader_getX509CertLen()

uint32_t Bootloader_getX509CertLen | ( | uint8_t * | x509_cert_ptr | ) |

API to get the length of an x509 certificate.

This API calculates the length of an x509 certificate from the 4 byte x509 header present at the top.

Parameters

  x509_cert_ptr | Pointer to the 4 byte x509 header present at the start of the certificate.

Returns
  Length of the certificate

## ◆ Bootloader_getMsgLen()

uint32_t Bootloader_getMsgLen | ( | uint8_t * | x509_cert_ptr,
|  | uint32_t | x509_cert_size
| ) |  |

API to get image length from a x509 certificate.

This API calculates the length of an image from the x509 certificate.

Parameters

  x509_cert_ptr | Pointer to the x509 certificate.
  x509_cert_size | Length of the x509 certificate.

Returns
  Length of the image