diff --git a/.github/workflows/ccs_build.yml b/.github/workflows/ccs_build.yml index a7bc8792b..46f0a7692 100644 --- a/.github/workflows/ccs_build.yml +++ b/.github/workflows/ccs_build.yml @@ -66,8 +66,8 @@ jobs: ~/ti/ccs_20.3.1 ~/ti/ti-cgt-pru_2.3.3 ~/ti/ti-cgt-armllvm_4.0.3.LTS - ~/ti/sysconfig_1.26.2 - key: toolchain-ccs-${{ runner.os }}-v5-ccs20_3_1-sysconfig1_26_2-pru2_3_3-armclang4_0_3 + ~/ti/sysconfig_1.27.0 + key: toolchain-ccs-${{ runner.os }}-v5-ccs20_3_1-sysconfig1_27_0-pru2_3_3-armclang4_0_3 - name: Install CCS, SYSCONFIG, TIARMCLANG and PRU CGT if missing if: success() && steps.cache.outputs.cache-hit != 'true' @@ -87,14 +87,14 @@ jobs: cd CCS_20.3.1.00005_linux ./ccs_setup_20.3.1.00005.run --mode unattended --enable-components PF_ARM_MPU,PF_SITARA_MCU --prefix "$HOME/ti/ccs_20.3.1" fi - # Install SYSCONFIG 1.26.2 - if [ ! -d "$HOME/ti/ccs_20.3.1/ccs/utils/sysconfig_1.26.2" ] && [ ! -d "$HOME/ti/sysconfig_1.26.2" ]; then + # Install SYSCONFIG 1.27.0 + if [ ! -d "$HOME/ti/ccs_20.3.1/ccs/utils/sysconfig_1.27.0" ] && [ ! -d "$HOME/ti/sysconfig_1.27.0" ]; then cd "$HOME/ti/downloads" wget -q --retry-connrefused --waitretry=1 --tries=5 --timeout=30 \ - https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-nsUM6f7Vvb/1.26.2.4477/sysconfig-1.26.2_4477-setup.run - chmod +x sysconfig-1.26.2_4477-setup.run - ./sysconfig-1.26.2_4477-setup.run --mode unattended --prefix "$HOME/ti/sysconfig_1.26.2" - chmod -R +x "$HOME/ti/sysconfig_1.26.2" + https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-nsUM6f7Vvb/1.27.0.4565/sysconfig-1.27.0_4565-setup.run + chmod +x sysconfig-1.27.0_4565-setup.run + ./sysconfig-1.27.0_4565-setup.run --mode unattended --prefix "$HOME/ti/sysconfig_1.27.0" + chmod -R +x "$HOME/ti/sysconfig_1.27.0" fi # Install ARM CLANG CGT 4.0.3 if [ ! -d "$HOME/ti/ccs_20.3.1/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS" ] && [ ! -d "$HOME/ti/ti-cgt-armllvm_4.0.3.LTS" ]; then @@ -134,7 +134,7 @@ jobs: rm -rf "$HOME/ti/ccs_20.3.1/ccs/uninstallers" echo "=== Toolchain sizes after cleanup ===" du -sh "$HOME/ti/ccs_20.3.1" "$HOME/ti/ti-cgt-pru_2.3.3" \ - "$HOME/ti/ti-cgt-armllvm_4.0.3.LTS" "$HOME/ti/sysconfig_1.26.2" 2>/dev/null || true + "$HOME/ti/ti-cgt-armllvm_4.0.3.LTS" "$HOME/ti/sysconfig_1.27.0" 2>/dev/null || true - name: Save toolchain cache if: success() && steps.cache.outputs.cache-hit != 'true' @@ -144,8 +144,8 @@ jobs: ~/ti/ccs_20.3.1 ~/ti/ti-cgt-pru_2.3.3 ~/ti/ti-cgt-armllvm_4.0.3.LTS - ~/ti/sysconfig_1.26.2 - key: toolchain-ccs-${{ runner.os }}-v5-ccs20_3_1-sysconfig1_26_2-pru2_3_3-armclang4_0_3 + ~/ti/sysconfig_1.27.0 + key: toolchain-ccs-${{ runner.os }}-v5-ccs20_3_1-sysconfig1_27_0-pru2_3_3-armclang4_0_3 ccs-build: name: CCS Build (${{ matrix.device }}) @@ -157,25 +157,25 @@ jobs: matrix: include: - device: am243x - mcu_plus_sdk: mcu_plus_sdk_am243x_11_02_00_24 - sdk_installer: mcu_plus_sdk_am243x_11_02_00_24-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-ouHbHEm1PK/11.02.00.24/mcu_plus_sdk_am243x_11_02_00_24-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am243x_12_00_00_26 + sdk_installer: mcu_plus_sdk_am243x_12_00_00_26-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-ouHbHEm1PK/12.00.00.26/mcu_plus_sdk_am243x_12_00_00_26-linux-x64-installer.run - device: am261x - mcu_plus_sdk: mcu_plus_sdk_am261x_10_02_00_15 - sdk_installer: mcu_plus_sdk_am261x_10_02_00_15-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-h64OlWnQrg/10.02.00.15/mcu_plus_sdk_am261x_10_02_00_15-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am261x_26_00_00_06 + sdk_installer: mcu_plus_sdk_am261x_26_00_00_06-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-h64OlWnQrg/26.00.00.06.STS/mcu_plus_sdk_am261x_26_00_00_06-linux-x64-installer.run - device: am263px - mcu_plus_sdk: mcu_plus_sdk_am263px_10_02_00_15 - sdk_installer: mcu_plus_sdk_am263px_10_02_00_15-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-JVtW1V4WfA/10.02.00.15/mcu_plus_sdk_am263px_10_02_00_15-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am263px_26_00_00_06 + sdk_installer: mcu_plus_sdk_am263px_26_00_00_06-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-JVtW1V4WfA/26.00.00.06.STS/mcu_plus_sdk_am263px_26_00_00_06-linux-x64-installer.run - device: am263x - mcu_plus_sdk: mcu_plus_sdk_am263x_10_02_00_13 - sdk_installer: mcu_plus_sdk_am263x_10_02_00_13-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-r5FY9rRaGv/10.02.00.13/mcu_plus_sdk_am263x_10_02_00_13-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am263x_26_00_00_06 + sdk_installer: mcu_plus_sdk_am263x_26_00_00_06-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-r5FY9rRaGv/26.00.00.06.STS/mcu_plus_sdk_am263x_26_00_00_06-linux-x64-installer.run - device: am64x - mcu_plus_sdk: mcu_plus_sdk_am64x_11_02_00_24 - sdk_installer: mcu_plus_sdk_am64x_11_02_00_24-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-SfkcjYAjGS/11.02.00.24/mcu_plus_sdk_am64x_11_02_00_24-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am64x_12_00_00_27 + sdk_installer: mcu_plus_sdk_am64x_12_00_00_27-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-SfkcjYAjGS/12.00.00.27/mcu_plus_sdk_am64x_12_00_00_27-linux-x64-installer.run - device: am62x mcu_plus_sdk: "" sdk_installer: "" @@ -204,8 +204,8 @@ jobs: ~/ti/ccs_20.3.1 ~/ti/ti-cgt-pru_2.3.3 ~/ti/ti-cgt-armllvm_4.0.3.LTS - ~/ti/sysconfig_1.26.2 - key: toolchain-ccs-${{ runner.os }}-v5-ccs20_3_1-sysconfig1_26_2-pru2_3_3-armclang4_0_3 + ~/ti/sysconfig_1.27.0 + key: toolchain-ccs-${{ runner.os }}-v5-ccs20_3_1-sysconfig1_27_0-pru2_3_3-armclang4_0_3 fail-on-cache-miss: true - name: Install device MCU+ SDK @@ -255,7 +255,7 @@ jobs: # initializing the workspace. See test_ccs_import.sh for background. # No backup/restore needed — CI workspace is ephemeral. run: | - SYSCFG_VERSION="1.26.2" + SYSCFG_VERSION="1.27.0" OPENPRU_VERSION="1.${SYSCFG_VERSION}" sed -i "s/^ \"version\": \"[^\"]*\"/ \"version\": \"${OPENPRU_VERSION}\"/" \ .metadata/.tirex/package.tirex.json @@ -276,9 +276,9 @@ jobs: WORKSPACE="${HOME}/workspace_ccs_${DEVICE}" CCS_CLI="$HOME/ti/ccs_20.3.1/ccs/eclipse/ccs-server-cli.sh" - PRODUCT_PATHS="${GITHUB_WORKSPACE};$HOME/ti/sysconfig_1.26.2" - if [ -d "$HOME/ti/ccs_20.3.1/ccs/utils/sysconfig_1.26.2" ]; then - PRODUCT_PATHS="${GITHUB_WORKSPACE};$HOME/ti/ccs_20.3.1/ccs/utils/sysconfig_1.26.2" + PRODUCT_PATHS="${GITHUB_WORKSPACE};$HOME/ti/sysconfig_1.27.0" + if [ -d "$HOME/ti/ccs_20.3.1/ccs/utils/sysconfig_1.27.0" ]; then + PRODUCT_PATHS="${GITHUB_WORKSPACE};$HOME/ti/ccs_20.3.1/ccs/utils/sysconfig_1.27.0" fi if [ -n "${{ matrix.mcu_plus_sdk }}" ]; then PRODUCT_PATHS="${PRODUCT_PATHS};$HOME/ti/${{ matrix.mcu_plus_sdk }}" diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 0df4bb2c9..7a6180666 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -24,25 +24,25 @@ jobs: matrix: include: - device: am243x - mcu_plus_sdk: mcu_plus_sdk_am243x_11_02_00_24 - sdk_installer: mcu_plus_sdk_am243x_11_02_00_24-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-ouHbHEm1PK/11.02.00.24/mcu_plus_sdk_am243x_11_02_00_24-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am243x_12_00_00_26 + sdk_installer: mcu_plus_sdk_am243x_12_00_00_26-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-ouHbHEm1PK/12.00.00.26/mcu_plus_sdk_am243x_12_00_00_26-linux-x64-installer.run - device: am261x - mcu_plus_sdk: mcu_plus_sdk_am261x_10_02_00_15 - sdk_installer: mcu_plus_sdk_am261x_10_02_00_15-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-h64OlWnQrg/10.02.00.15/mcu_plus_sdk_am261x_10_02_00_15-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am261x_26_00_00_06 + sdk_installer: mcu_plus_sdk_am261x_26_00_00_06-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-h64OlWnQrg/26.00.00.06.STS/mcu_plus_sdk_am261x_26_00_00_06-linux-x64-installer.run - device: am263px - mcu_plus_sdk: mcu_plus_sdk_am263px_10_02_00_15 - sdk_installer: mcu_plus_sdk_am263px_10_02_00_15-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-JVtW1V4WfA/10.02.00.15/mcu_plus_sdk_am263px_10_02_00_15-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am263px_26_00_00_06 + sdk_installer: mcu_plus_sdk_am263px_26_00_00_06-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-JVtW1V4WfA/26.00.00.06.STS/mcu_plus_sdk_am263px_26_00_00_06-linux-x64-installer.run - device: am263x - mcu_plus_sdk: mcu_plus_sdk_am263x_10_02_00_13 - sdk_installer: mcu_plus_sdk_am263x_10_02_00_13-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-r5FY9rRaGv/10.02.00.13/mcu_plus_sdk_am263x_10_02_00_13-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am263x_26_00_00_06 + sdk_installer: mcu_plus_sdk_am263x_26_00_00_06-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-r5FY9rRaGv/26.00.00.06.STS/mcu_plus_sdk_am263x_26_00_00_06-linux-x64-installer.run - device: am64x - mcu_plus_sdk: mcu_plus_sdk_am64x_11_02_00_24 - sdk_installer: mcu_plus_sdk_am64x_11_02_00_24-linux-x64-installer.run - sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-SfkcjYAjGS/11.02.00.24/mcu_plus_sdk_am64x_11_02_00_24-linux-x64-installer.run + mcu_plus_sdk: mcu_plus_sdk_am64x_12_00_00_27 + sdk_installer: mcu_plus_sdk_am64x_12_00_00_27-linux-x64-installer.run + sdk_url: https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-SfkcjYAjGS/12.00.00.27/mcu_plus_sdk_am64x_12_00_00_27-linux-x64-installer.run - device: am62x mcu_plus_sdk: "" sdk_installer: "" @@ -82,8 +82,8 @@ jobs: path: | ~/ti/ti-cgt-pru_2.3.3 ~/ti/ti-cgt-armllvm_4.0.3.LTS - ~/ti/sysconfig_1.26.2 - key: toolchain-make-${{ runner.os }}-v3-sysconfig1_26_2-pru2_3_3-armclang4_0_3 + ~/ti/sysconfig_1.27.0 + key: toolchain-make-${{ runner.os }}-v3-sysconfig1_27_0-pru2_3_3-armclang4_0_3 - name: Install SYSCONFIG, TIARMCLANG and PRU CGT if missing if: steps.cache.outputs.cache-hit != 'true' @@ -91,14 +91,14 @@ jobs: set -e mkdir -p "$HOME/ti/downloads" - # Install SYSCONFIG 1.26.2 - if [ ! -d "$HOME/ti/sysconfig_1.26.2" ]; then + # Install SYSCONFIG 1.27.0 + if [ ! -d "$HOME/ti/sysconfig_1.27.0" ]; then cd "$HOME/ti/downloads" wget -q --retry-connrefused --waitretry=1 --tries=5 --timeout=30 \ - https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-nsUM6f7Vvb/1.26.2.4477/sysconfig-1.26.2_4477-setup.run - chmod +x sysconfig-1.26.2_4477-setup.run - ./sysconfig-1.26.2_4477-setup.run --mode unattended --prefix "$HOME/ti/sysconfig_1.26.2" - chmod -R +x "$HOME/ti/sysconfig_1.26.2" + https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-nsUM6f7Vvb/1.27.0.4565/sysconfig-1.27.0_4565-setup.run + chmod +x sysconfig-1.27.0_4565-setup.run + ./sysconfig-1.27.0_4565-setup.run --mode unattended --prefix "$HOME/ti/sysconfig_1.27.0" + chmod -R +x "$HOME/ti/sysconfig_1.27.0" fi # Install ARM CLANG CGT 4.0.3 if [ ! -d "$HOME/ti/ti-cgt-armllvm_4.0.3.LTS" ]; then @@ -142,7 +142,7 @@ jobs: # Toolchains (standalone; CCS not installed in make CI) CGT_TI_PRU_PATH := $(HOME)/ti/ti-cgt-pru_2.3.3 CGT_TI_ARM_CLANG_PATH := $(HOME)/ti/ti-cgt-armllvm_4.0.3.LTS - SYSCFG_PATH ?= $(HOME)/ti/sysconfig_1.26.2 + SYSCFG_PATH ?= $(HOME)/ti/sysconfig_1.27.0 # Other variables # you probably will not need to edit these values OPEN_PRU_PATH ?= $(abspath .) diff --git a/.metadata/.tirex/am243x.content.tirex.json b/.metadata/.tirex/am243x.content.tirex.json deleted file mode 100644 index fe51488c7..000000000 --- a/.metadata/.tirex/am243x.content.tirex.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/.metadata/.tirex/am261x.content.tirex.json b/.metadata/.tirex/am261x.content.tirex.json deleted file mode 100644 index fe51488c7..000000000 --- a/.metadata/.tirex/am261x.content.tirex.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/.metadata/.tirex/am263px.content.tirex.json b/.metadata/.tirex/am263px.content.tirex.json deleted file mode 100644 index fe51488c7..000000000 --- a/.metadata/.tirex/am263px.content.tirex.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/.metadata/.tirex/am263x.content.tirex.json b/.metadata/.tirex/am263x.content.tirex.json deleted file mode 100644 index fe51488c7..000000000 --- a/.metadata/.tirex/am263x.content.tirex.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/.metadata/.tirex/am64x.content.tirex.json b/.metadata/.tirex/am64x.content.tirex.json deleted file mode 100644 index fe51488c7..000000000 --- a/.metadata/.tirex/am64x.content.tirex.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/.metadata/.tirex/package.tirex.json b/.metadata/.tirex/package.tirex.json index 5be2935e0..ffba8574e 100644 --- a/.metadata/.tirex/package.tirex.json +++ b/.metadata/.tirex/package.tirex.json @@ -4,12 +4,12 @@ "id": "com.ti.OPEN_PRU", "name": "OpenPRU", "rootCategory": [ "OpenPRU"], - "version": "2026.01.00", + "version": "2026.02.00", "type": "software", "license": "../../LICENSE", "devices": ["AM243x", "AM64x", "AM261x", "AM263Px", "AM263x", "AM62x"], "tags": ["Baremetal", "FreeRTOS", "Linux"], - "description": "Welcome to OpenPRU. This repository contains examples, training, and tools to develop PRU applications.", + "description": "OpenPRU provides examples, academy training labs, and tools to develop real-time applications on the TI Programmable Real-Time Unit (PRU/ICSSM) across AM243x, AM64x, AM261x, AM263x, AM263Px, and AM62x devices.", "dependencies": [ { "packageId": "sysconfig", "version": "1.21.0", "require": "mandatory" }, { "packageId": "ti_cgt_tiarmclang", "version": "4.0.0", "require": "mandatory" }, diff --git a/.metadata/product.json b/.metadata/product.json index d52dd5706..ef889bc44 100644 --- a/.metadata/product.json +++ b/.metadata/product.json @@ -1,7 +1,7 @@ { "name": "OPEN_PRU", "displayName": "OPEN_PRU", - "version": "07.03.01", + "version": "2026.02.00", "documentationPath": "../docs", "includePaths": [ "../source", diff --git a/.pr_agent.toml b/.pr_agent.toml index fd864d363..1b179af21 100644 --- a/.pr_agent.toml +++ b/.pr_agent.toml @@ -8,3 +8,7 @@ push_commands = [ "/agentic_describe", "/agentic_review", ] + +[config] +invite_only_mode = true +allowed_users = ["pratheesh-ti", "nsaulnier-ti", "dhavaljk", "tleyrer", "manojKoppolu", "a1248924", "rajul-bhambay", "achala-ti", "JC-Jayachandran"] diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..2b1067ae7 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,5 @@ +# OpenPRU — AI Agent Instructions + +Before any OpenPRU task — porting, creating, feature work, code review, firmware +changes, etc — read `docs_ai/README.md`. It routes you to a task runbook if one +exists, and lists reference files with when-to-read triggers. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 000000000..43c994c2d --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/academy/crc/crc/readme.md b/academy/crc/crc/readme.md index c44abb158..6b3801660 100644 --- a/academy/crc/crc/readme.md +++ b/academy/crc/crc/readme.md @@ -19,11 +19,25 @@ The example code configures the CRC module, performs the calculations, and store This implementation is particularly useful in applications requiring data integrity validation, error detection in communication protocols, and verification of data transmission accuracy. The example runs on various AM26x family processors and demonstrates the essential features of the PRU CRC module in a straightforward manner. -# Supported Combinations - - Parameter | Value - ---------------|----------- - ICSSM | ICSSM0 - PRU0, PRU1; ICSSM1 (only in am261x) - PRU0, PRU1 - Toolchain | pru-cgt - Board | am261x-lp, am261x-som, am263px-cc, am263px-lp, am263x-cc, am263x-lp - Example folder | academy/crc/crc/ +## Supported Combinations + +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am261x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263px | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | + +## Steps to Run the Example + +1. Build and run the PRU firmware +2. After program halts, inspect the PRU register values: + - R10: CRC16 result + - R11: CRC32 result diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 598b63d85..dfe8fa5a2 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index a234f6139..0cc77ccec 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 7344824b8..15d7f2928 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec index f307485d1..87fc0985b 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile index 7000bb540..5e35844a9 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 7344824b8..15d7f2928 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 35a880d38..3f07a916f 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile index 52a3eb958..950b770a3 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 719521d0f..d6f49d8fb 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 379785603..699ec3a53 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 56e4ab4bb..135e9a548 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 719521d0f..d6f49d8fb 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg index 8561a4a83..34f91d60c 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 510bc8f74..7b85f6cd8 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile index bfd084d8c..8ea6e3002 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index a51d2d8e1..44b500335 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index a1497a717..3374ec1c5 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 3cad02d43..cfe8152b2 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index a51d2d8e1..44b500335 100644 --- a/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/assembly_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/assembly_code/solution/readme.md b/academy/getting_started_labs/assembly_code/solution/readme.md index 6de44b71b..e9aa17f52 100644 --- a/academy/getting_started_labs/assembly_code/solution/readme.md +++ b/academy/getting_started_labs/assembly_code/solution/readme.md @@ -2,40 +2,34 @@ ## Introduction -This example acts as a getting started point for PRU firmware development in assembly. +This is a training lab for getting started with PRU firmware development in +assembly. -# Supported Combinations +## Supported Combinations - Parameter | Value - ---------------|----------- - ICSSG | ICSSG0 - PRU0, PRU1, RTU0, RTU1, TX_PRU0,TX_PRU1 - ICSSM | ICSSM0 - PRU0, PRU1 - | ICSSM1 - PRU0, PRU1 (am261x only) - Toolchain | pru-cgt - Board | am64x-evm, am243x-evm, am243x-lp, am261x-lp, am261x-som, am263px-cc, am263px-lp, am263x-cc, am263x-lp - Example folder | academy/getting_started_labs/assembly_code/solution/ +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. -# Steps to Run the Example +## Validated HW & SW -> Prerequisite: [PRU-CGT-2-3](https://www.ti.com/tool/PRU-CGT) (ti-pru-cgt) should be installed at: `C:/ti/` +This project was tested on hardware with these software versions: -- **When using CCS projects to build**, import the CCS project from the above mentioned Example folder path for R5F and PRU, After this `main.asm`, `linker.cmd` files gets copied to ccs workspace of PRU project. The `main.asm` contains sample code to halt PRU program +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am243x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am261x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263px | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am62x | FIXME | OpenPRU FIXME | +| am64x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | - - Build the PRU project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Build Flow: Once you click on build in PRU project, firmware header file which is generated in release or debug folder of ccs workspace, is moved to `` +## Steps to Run the Example - - Build the R5F project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Firmware header file path is included in R5F project include options by default, Instructions in Firmware header file can be written into PRU IRAM memory using PRUICSS_loadFirmware API (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe)) - - Build Flow: Once you click on build in R5F project, SysConfig files are generated, Finally the R5F project will be generated using both the generated SysConfig and PRU project binaries. - - - Launch a CCS debug session and run the executable, (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_LAUNCH_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_LAUNCH_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_LAUNCH_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_LAUNCH_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_LAUNCH_PAGE.html)) - -- **When using makefiles to build**: - - For steps on how to use makefiles, run `make help` from the root folder - of the open-pru repository. - -# Writing PRU code - -* You can modify this example to write your own firmware. For more information, - refer to - [Creating a New Project in the OpenPRU Repo](../../docs/open_pru_create_new_project.md). +1. Build the project. Refer to the **PRU Getting Started Labs > Lab 3: How to + Build PRU Firmware** for details. +2. Load the firmware onto the PRU core using CCS, an MCU+ core, or a Linux + core. Refer to the **PRU Getting + Started Labs > Lab 4: How to Initialize the PRU** for details. +3. Run the PRU firmware and debug as discussed in the **PRU Getting + Started Labs > Lab 5: How to debug PRU firmware**. diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index e326998e9..ff23aba06 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 0e8ac26f2..f35a97b70 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 6aafac569..15d7f2928 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec index dbe2766d4..c1c2d1814 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile index e97bc7288..9e047c5a4 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 6aafac569..15d7f2928 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 4f6a4dc4a..92c356609 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile index eb325f046..1c1b827c5 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index bfc15b778..d6f49d8fb 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 47fa79159..7aebb3fd2 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 2ae837977..09c525292 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index bfc15b778..d6f49d8fb 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg index 8561a4a83..34f91d60c 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index bc84aea50..9b1eb55fd 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile index 2273b708c..fbb991f09 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index b0d059d30..44b500335 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index bbd96bf5b..7e781e371 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 501f15766..e07841428 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index b0d059d30..44b500335 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_assembly/solution/readme.md b/academy/getting_started_labs/c_and_assembly/solution/readme.md index cf831c61e..3a220b6c7 100644 --- a/academy/getting_started_labs/c_and_assembly/solution/readme.md +++ b/academy/getting_started_labs/c_and_assembly/solution/readme.md @@ -2,41 +2,34 @@ ## Introduction -This example acts as a getting started point for PRU firmware development -with mixed C and assembly. +This is a training lab for getting started with PRU firmware development +in mixed C and assembly. -# Supported Combinations +## Supported Combinations - Parameter | Value - ---------------|----------- - ICSSG | ICSSG0 - PRU0, PRU1, RTU0, RTU1, TX_PRU0,TX_PRU1 - ICSSM | ICSSM0 - PRU0, PRU1 - | ICSSM1 - PRU0, PRU1 (am261x only) - Toolchain | pru-cgt - Board | am64x-evm, am243x-evm, am243x-lp, am261x-lp, am261x-som, am263px-cc, am263px-lp, am263x-cc, am263x-lp - Example folder | academy/getting_started_labs/c_and_assembly/solution/ +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. -# Steps to Run the Example +## Validated HW & SW -> Prerequisite: [PRU-CGT-2-3](https://www.ti.com/tool/PRU-CGT) (ti-pru-cgt) should be installed at: `C:/ti/` +This project was tested on hardware with these software versions: -- **When using CCS projects to build**, import the CCS project from the above mentioned Example folder path for R5F and PRU, After this `main.asm`, `linker.cmd` files gets copied to ccs workspace of PRU project. The `main.asm` contains sample code to halt PRU program +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am243x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am261x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263px | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am62x | FIXME | OpenPRU FIXME | +| am64x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | - - Build the PRU project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Build Flow: Once you click on build in PRU project, firmware header file which is generated in release or debug folder of ccs workspace, is moved to `` +## Steps to Run the Example +1. Build the project. Refer to the **PRU Getting Started Labs > Lab 3: How to + Build PRU Firmware** for details. +2. Load the firmware onto the PRU core using CCS, an MCU+ core, or a Linux + core. Refer to the **PRU Getting + Started Labs > Lab 4: How to Initialize the PRU** for details. +3. Run the PRU firmware and debug as discussed in the **PRU Getting + Started Labs > Lab 5: How to debug PRU firmware**. - - Build the R5F project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Firmware header file path is included in R5F project include options by default, Instructions in Firmware header file can be written into PRU IRAM memory using PRUICSS_loadFirmware API (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe)) - - Build Flow: Once you click on build in R5F project, SysConfig files are generated, Finally the R5F project will be generated using both the generated SysConfig and PRU project binaries. - - - Launch a CCS debug session and run the executable, (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_LAUNCH_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_LAUNCH_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_LAUNCH_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_LAUNCH_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_LAUNCH_PAGE.html)) - -- **When using makefiles to build**: - - For steps on how to use makefiles, run `make help` from the root folder - of the open-pru repository. - -# Writing PRU code - -* You can modify this example to write your own firmware. For more information, - refer to - [Creating a New Project in the OpenPRU Repo](../../docs/open_pru_create_new_project.md). diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 7a2ce09e6..5c53ce553 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 2d89fcf22..3075f0973 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_inline_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_inline_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 903f49561..15d7f2928 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 3ebc44110..bd9e77c01 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile index 31a9f3366..da355b084 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_inline_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_inline_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 903f49561..15d7f2928 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 4bb753767..3d7e230e7 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile index 4f375c722..cdbf69327 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_inline_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_inline_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index c80067166..d6f49d8fb 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index a247311ad..c3ea2cac8 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile index c92b38e8e..14982164a 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_inline_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_inline_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index c80067166..d6f49d8fb 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg index 8561a4a83..34f91d60c 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 041b5ba96..d9c22e084 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile index e22e711a0..6b933f53f 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_inline_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_inline_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index f097a671a..44b500335 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 470247afe..af1eee540 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 07d300256..aa82eaf0a 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c_and_inline_assembly.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c_and_inline_assembly.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c_and_inline_assembly.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index f097a671a..44b500335 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c_and_inline_assembly.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_and_inline_assembly/solution/readme.md b/academy/getting_started_labs/c_and_inline_assembly/solution/readme.md index 73846f619..824b93fa6 100644 --- a/academy/getting_started_labs/c_and_inline_assembly/solution/readme.md +++ b/academy/getting_started_labs/c_and_inline_assembly/solution/readme.md @@ -2,41 +2,35 @@ ## Introduction -This example acts as a getting started point for PRU firmware development with +This is a training lab for getting started with PRU firmware development in mixed C and inline assembly. -# Supported Combinations +## Supported Combinations - Parameter | Value - ---------------|----------- - ICSSG | ICSSG0 - PRU0, PRU1, RTU0, RTU1, TX_PRU0,TX_PRU1 - ICSSM | ICSSM0 - PRU0, PRU1 - | ICSSM1 - PRU0, PRU1 (am261x only) - Toolchain | pru-cgt - Board | am64x-evm, am243x-evm, am243x-lp, am261x-lp, am261x-som, am263px-cc, am263px-lp, am263x-cc, am263x-lp - Example folder | academy/getting_started_labs/c_and_inline_assembly/solution/ +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. -# Steps to Run the Example +## Validated HW & SW -> Prerequisite: [PRU-CGT-2-3](https://www.ti.com/tool/PRU-CGT) (ti-pru-cgt) should be installed at: `C:/ti/` +This project was tested on hardware with these software versions: -- **When using CCS projects to build**, import the CCS project from the above mentioned Example folder path for R5F and PRU, After this `main.asm`, `linker.cmd` files gets copied to ccs workspace of PRU project. The `main.asm` contains sample code to halt PRU program +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am243x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am261x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263px | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am62x | FIXME | OpenPRU FIXME | +| am64x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | - - Build the PRU project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Build Flow: Once you click on build in PRU project, firmware header file which is generated in release or debug folder of ccs workspace, is moved to `` +## Steps to Run the Example - - Build the R5F project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Firmware header file path is included in R5F project include options by default, Instructions in Firmware header file can be written into PRU IRAM memory using PRUICSS_loadFirmware API (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe)) - - Build Flow: Once you click on build in R5F project, SysConfig files are generated, Finally the R5F project will be generated using both the generated SysConfig and PRU project binaries. +1. Build the project. Refer to the **PRU Getting Started Labs > Lab 3: How to + Build PRU Firmware** for details. +2. Load the firmware onto the PRU core using CCS, an MCU+ core, or a Linux + core. Refer to the **PRU Getting + Started Labs > Lab 4: How to Initialize the PRU** for details. +3. Run the PRU firmware and debug as discussed in the **PRU Getting + Started Labs > Lab 5: How to debug PRU firmware**. - - Launch a CCS debug session and run the executable, (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_LAUNCH_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_LAUNCH_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_LAUNCH_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_LAUNCH_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_LAUNCH_PAGE.html)) - -- **When using makefiles to build**: - - For steps on how to use makefiles, run `make help` from the root folder - of the open-pru repository. - -# Writing PRU code - -* You can modify this example to write your own firmware. For more information, - refer to - [Creating a New Project in the OpenPRU Repo](../../docs/open_pru_create_new_project.md). diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index ad5a04c6d..2f030d506 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index ff7cb7b0a..91de8c4be 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 3b97527cf..15d7f2928 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 4d66e3efd..80e4f8495 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile index d8dc86470..5b56feee0 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 3b97527cf..15d7f2928 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index bc751b209..bd228faf0 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile index 4f5ed1937..ced6aaca3 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index c8877cc8d..d6f49d8fb 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 776cb07a8..7cb61dad0 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile index f3533d461..38b729340 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index c8877cc8d..d6f49d8fb 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg index 8561a4a83..34f91d60c 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index dc2868738..49bdd4fd7 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile index 4e8c61b62..216ed7723 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 88b0a1b47..44b500335 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 00861dafd..5a226f66e 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 4fe320cd9..48fc69d83 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_add_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_add_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_add_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_add_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_add_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_add_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_add_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 88b0a1b47..44b500335 100644 --- a/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/getting_started_labs/c_code/solution/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_add_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/getting_started_labs/c_code/solution/readme.md b/academy/getting_started_labs/c_code/solution/readme.md index 40347a0f2..3883eb240 100644 --- a/academy/getting_started_labs/c_code/solution/readme.md +++ b/academy/getting_started_labs/c_code/solution/readme.md @@ -2,41 +2,34 @@ ## Introduction -This example acts as a getting started point for PRU firmware development in -C. +This is a training lab for getting started with PRU firmware development in C. -# Supported Combinations +## Supported Combinations - Parameter | Value - ---------------|----------- - ICSSG | ICSSG0 - PRU0, PRU1, RTU0, RTU1, TX_PRU0,TX_PRU1 - ICSSM | ICSSM0 - PRU0, PRU1 - | ICSSM1 - PRU0, PRU1 (am261x only) - Toolchain | pru-cgt - Board | am64x-evm, am243x-evm, am243x-lp, am261x-lp, am261x-som, am263px-cc, am263px-lp, am263x-cc, am263x-lp - Example folder | academy/getting_started_labs/c_code/solution/ +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. -# Steps to Run the Example +## Validated HW & SW -> Prerequisite: [PRU-CGT-2-3](https://www.ti.com/tool/PRU-CGT) (ti-pru-cgt) should be installed at: `C:/ti/` +This project was tested on hardware with these software versions: -- **When using CCS projects to build**, import the CCS project from the above mentioned Example folder path for R5F and PRU, After this `main.asm`, `linker.cmd` files gets copied to ccs workspace of PRU project. The `main.asm` contains sample code to halt PRU program +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am243x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am261x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263px | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am62x | FIXME | OpenPRU FIXME | +| am64x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | - - Build the PRU project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Build Flow: Once you click on build in PRU project, firmware header file which is generated in release or debug folder of ccs workspace, is moved to `` +## Steps to Run the Example - - Build the R5F project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Firmware header file path is included in R5F project include options by default, Instructions in Firmware header file can be written into PRU IRAM memory using PRUICSS_loadFirmware API (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe)) - - Build Flow: Once you click on build in R5F project, SysConfig files are generated, Finally the R5F project will be generated using both the generated SysConfig and PRU project binaries. +1. Build the project. Refer to the **PRU Getting Started Labs > Lab 3: How to + Build PRU Firmware** for details. +2. Load the firmware onto the PRU core using CCS, an MCU+ core, or a Linux + core. Refer to the **PRU Getting + Started Labs > Lab 4: How to Initialize the PRU** for details. +3. Run the PRU firmware and debug as discussed in the **PRU Getting + Started Labs > Lab 5: How to debug PRU firmware**. - - Launch a CCS debug session and run the executable, (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_LAUNCH_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_LAUNCH_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_LAUNCH_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_LAUNCH_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_LAUNCH_PAGE.html)) - -- **When using makefiles to build**: - - For steps on how to use makefiles, run `make help` from the root folder - of the open-pru repository. - -# Writing PRU code - -* You can modify this example to write your own firmware. For more information, - refer to - [Creating a New Project in the OpenPRU Repo](../../docs/open_pru_create_new_project.md). diff --git a/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/example.syscfg b/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/example.syscfg index d4af28f05..24616cba6 100644 --- a/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/example.syscfg +++ b/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM261x_ZFG" --part "AM2612" --package "ZFG" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2612" --package "NFBGA (ZFG)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM261x_ZFG" --part "AM2612" --package "ZFG" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2612" --package "NFBGA (ZFG)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 11a71c7a7..d096dc432 100644 --- a/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 274a38df5..3098499ca 100644 --- a/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=gpio_toggle.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=gpio_toggle.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=gpio_toggle.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=gpio_toggle.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=gpio_toggle.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=gpio_toggle.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=gpio_toggle.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=gpio_toggle.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 452b2dafd..15d7f2928 100644 --- a/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/gpio/gpio_toggle/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/gpio_toggle.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/gpio_toggle.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/example.syscfg b/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/example.syscfg index 3ec4ccd00..03fb2a748 100644 --- a/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/example.syscfg +++ b/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263Px" --part "AM263P4" --package "ZCZ_C" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM263P4-Q1" --package "NFBGA (ZCZ-C)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263Px" --part "AM263P4" --package "ZCZ_C" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM263P4-Q1" --package "NFBGA (ZCZ-C)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index c7c91e09d..687901129 100644 --- a/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile index d873e1eaa..c0c4eacc0 100644 --- a/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=gpio_toggle.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=gpio_toggle.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=gpio_toggle.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=gpio_toggle.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=gpio_toggle.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=gpio_toggle.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=gpio_toggle.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=gpio_toggle.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index bbc6e4799..d6f49d8fb 100644 --- a/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/gpio/gpio_toggle/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/gpio_toggle.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/gpio_toggle.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/example.syscfg b/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/example.syscfg index aeb873a8a..ad039eb08 100644 --- a/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/example.syscfg +++ b/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index a6e21fe99..bf2f99c43 100644 --- a/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index eadcdca52..70d45c47e 100644 --- a/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=gpio_toggle.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=gpio_toggle.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=gpio_toggle.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=gpio_toggle.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=gpio_toggle.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=gpio_toggle.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=gpio_toggle.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=gpio_toggle.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 9b22b4631..44b500335 100644 --- a/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/gpio/gpio_toggle/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/gpio_toggle.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/gpio_toggle.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/gpio/gpio_toggle/readme.md b/academy/gpio/gpio_toggle/readme.md index e9b2b1420..df83aa835 100644 --- a/academy/gpio/gpio_toggle/readme.md +++ b/academy/gpio/gpio_toggle/readme.md @@ -16,12 +16,25 @@ In both cases, the toggled signal is routed to a readily accessible location on The oscillating signal generated can be used to validate proper PRU operation and GPIO configuration, making this example particularly useful for initial hardware bring-up and verification of PRU GPIO functionality. -# Supported Combinations - - Parameter | Value - ---------------|----------- - ICSSM | ICSSM0 - PRU0, PRU1; ICSSM1 (only in am261x) - PRU0, PRU1 - Toolchain | pru-cgt - Board | am261x-lp, am263px-lp, am263x-lp - Example folder | academy/gpio/gpio_toggle +## Supported Combinations + +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am261x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263px | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | + +## Steps to Run the Example + +1. Build and run the PRU firmware +2. Connect a logic analyzer or oscilloscope to header pin BP.17 (J2) and + observe the toggling signal diff --git a/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/example.syscfg b/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/example.syscfg index 5dc4e2240..183c5faae 100644 --- a/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/example.syscfg +++ b/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM261x_ZFG" --part "AM2612" --package "ZFG" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2612" --package "NFBGA (ZFG)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM261x_ZFG" --part "AM2612" --package "ZFG" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2612" --package "NFBGA (ZFG)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ @@ -43,19 +43,17 @@ const section12 = section.addInstance(); /** * Write custom configuration values to the imported modules. */ -pruicss1.$name = "CONFIG_PRU_ICSS0"; -pruicss1.instance = "ICSSM1"; -pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; pruicss1.AdditionalICSSSettings[0].PruGPIO.create(1); -pruicss1.AdditionalICSSSettings[0].PruGPIO[0].$name = "CONFIG_PRU_ICSS_GPIO0"; -pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO0.$assign = "GPIO81"; -pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO0.$used = true; -pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO8.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].$name = "CONFIG_PRU_ICSS_GPIO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU0_GPIO0.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU0_GPIO8.$used = true; pruicss1.intcMapping.create(2); -pruicss1.intcMapping[0].$name = "CONFIG_ICSS1_INTC_MODE1_MAPPING0"; -pruicss1.intcMapping[1].$name = "CONFIG_ICSS1_INTC_MODE1_MAPPING1"; -pruicss1.intcMapping[1].event = "60"; -pruicss1.intcMapping[1].channel = "1"; +pruicss1.intcMapping[0].$name = "CONFIG_ICSS0_INTC_MODE1_MAPPING0"; +pruicss1.intcMapping[1].$name = "CONFIG_ICSS0_INTC_MODE1_MAPPING1"; +pruicss1.intcMapping[1].event = "60"; +pruicss1.intcMapping[1].channel = "1"; debug_log.enableUartLog = true; debug_log.enableSharedMemLog = true; @@ -292,5 +290,6 @@ section12.output_section[0].alignment = 0; * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to * re-solve from scratch. */ -pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].$suggestSolution = "PRU-ICSS1"; -pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO8.$suggestSolution = "GPIO44"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].$suggestSolution = "PRU-ICSS0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU0_GPIO0.$suggestSolution = "GPIO93"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU0_GPIO8.$suggestSolution = "GPIO90"; diff --git a/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index ccb8b505b..0ad7b953f 100644 --- a/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 9357b5057..539a4efea 100644 --- a/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=intc_mcu.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=intc_mcu.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=intc_mcu.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=intc_mcu.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=intc_mcu.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=intc_mcu.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=intc_mcu.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index ee3b800da..15d7f2928 100644 --- a/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/intc/intc_mcu/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/example.syscfg b/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/example.syscfg index 9527a1d52..eedb99c84 100644 --- a/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/example.syscfg +++ b/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263Px" --part "AM263P4" --package "ZCZ_S" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM263P4-Q1" --package "NFBGA (ZCZ-S)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263Px" --part "AM263P4" --package "ZCZ_S" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM263P4-Q1" --package "NFBGA (ZCZ-S)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 1ffc6d9d6..b9febe0c2 100644 --- a/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile index 4ef706164..88bd3ff6a 100644 --- a/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=intc_mcu.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=intc_mcu.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=intc_mcu.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=intc_mcu.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=intc_mcu.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=intc_mcu.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=intc_mcu.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 60598d522..d6f49d8fb 100644 --- a/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/intc/intc_mcu/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/example.syscfg b/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/example.syscfg index 20a5c8daa..044997271 100644 --- a/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/example.syscfg +++ b/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263Px" --part "AM263P4" --package "ZCZ_C" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM263P4-Q1" --package "NFBGA (ZCZ-C)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263Px" --part "AM263P4" --package "ZCZ_C" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM263P4-Q1" --package "NFBGA (ZCZ-C)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 366d2f87c..7dd7be533 100644 --- a/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile index ee5d53e06..19fdc4694 100644 --- a/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=intc_mcu.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=intc_mcu.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=intc_mcu.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=intc_mcu.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=intc_mcu.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=intc_mcu.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=intc_mcu.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 60598d522..d6f49d8fb 100644 --- a/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/intc/intc_mcu/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/example.syscfg b/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/example.syscfg index 280265c54..386f3a1d6 100644 --- a/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/example.syscfg +++ b/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 57aadbd19..be973dab6 100644 --- a/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile index fd1aa581a..36fa702f2 100644 --- a/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=intc_mcu.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=intc_mcu.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=intc_mcu.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=intc_mcu.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=intc_mcu.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=intc_mcu.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=intc_mcu.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 0bf502ba5..44b500335 100644 --- a/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/intc/intc_mcu/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/example.syscfg b/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/example.syscfg index 43e523973..b318a80cd 100644 --- a/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/example.syscfg +++ b/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2631-Q1" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2631-Q1" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 488f95fce..0392dfca4 100644 --- a/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 5a21545f4..6d7818518 100644 --- a/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=intc_mcu.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=intc_mcu.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=intc_mcu.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=intc_mcu.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=intc_mcu.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=intc_mcu.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=intc_mcu.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 0bf502ba5..44b500335 100644 --- a/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/academy/intc/intc_mcu/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/intc_mcu.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/academy/intc/intc_mcu/intc_mcu.c b/academy/intc/intc_mcu/intc_mcu.c index 7552ab976..b3f1153c5 100644 --- a/academy/intc/intc_mcu/intc_mcu.c +++ b/academy/intc/intc_mcu/intc_mcu.c @@ -98,7 +98,7 @@ int32_t PRUICSS_goToSection(PRUICSS_Handle handle, uint32_t pruCore, uint32_t se else return SystemP_FAILURE; - /* TODO: decide the final memory and offset */ + /* FIXME: decide the final memory and offset */ CSL_REG32_WR(baseaddr + PRUICSS_PRGM_FLOW_CNTRL_OFFSET, sectionId); retVal = PRUICSS_sendEvent(handle, eventNum); } @@ -126,11 +126,7 @@ void intc_mcu_main(void *args) DebugP_assert(gPruIcss0Handle != NULL); /* Initialize INTC */ - #if defined(SOC_AM261X) - status = PRUICSS_intcInit(gPruIcss0Handle, &icss1_intc_initdata); - #else status = PRUICSS_intcInit(gPruIcss0Handle, &icss0_intc_initdata); - #endif DebugP_assert(SystemP_SUCCESS == status); /* Register interrupt handler */ diff --git a/academy/intc/intc_mcu/readme.md b/academy/intc/intc_mcu/readme.md index f389bc0c2..f9c6da6c7 100644 --- a/academy/intc/intc_mcu/readme.md +++ b/academy/intc/intc_mcu/readme.md @@ -20,12 +20,26 @@ The successful completion of this interrupt sequence can be verified by checking - The R5F successfully generated a response interrupt - The PRU correctly received and handled the response interrupt -# Supported Combinations - - Parameter | Value - ---------------|----------- - ICSSM | ICSSM0 - PRU0, PRU1; ICSSM1 (only in am261x) - PRU0, PRU1 - Toolchain | pru-cgt - Board | am261x-lp, am263px-cc, am263px-lp, am263x-cc, am263x-lp - Example folder | academy/intc/intc_mcu +## Supported Combinations + +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am261x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263px | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | + +## Steps to Run the Example + +1. Build and run the PRU firmware. +2. After the firmware finishes running, Inspect PRU register R11. The expected + value is `0x12345678`, confirming + that the full PRU ↔ R5F interrupt handshake completed successfully. diff --git a/academy/mac/mac/readme.md b/academy/mac/mac/readme.md index 89c490a51..732545854 100644 --- a/academy/mac/mac/readme.md +++ b/academy/mac/mac/readme.md @@ -22,11 +22,25 @@ The final result is stored across two PRU registers: - R26: Contains the lower 32 bits of the result - R27: Contains the upper 32 bits of the result -# Supported Combinations - - Parameter | Value - ---------------|----------- - ICSSM | ICSSM0 - PRU0, PRU1; ICSSM1 (only in am261x) - PRU0, PRU1 - Toolchain | pru-cgt - Board | am261x-lp, am261x-som, am263px-cc, am263px-lp, am263x-cc, am263x-lp - Example folder | academy/mac/mac/ +## Supported Combinations + +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am261x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263px | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | + +## Steps to Run the Example + +1. Build and run the PRU firmware. +2. After the firmware finishes running, inspect the PRU register values: + - R26: lower 32 bits of the dot product result; expected `0x20` (32 decimal) + - R27: upper 32 bits; expected `0x00` diff --git a/academy/mac/mac_c/README.md b/academy/mac/mac_c/README.md new file mode 100644 index 000000000..4af740a13 --- /dev/null +++ b/academy/mac/mac_c/README.md @@ -0,0 +1,51 @@ +# MAC Multiply-Accumulate (C) + +## Introduction + +This example implements Multiply and Accumulate functionality in C. It does NOT +currently use the PRU MAC (Multiply and Accumulate) hardware accelerator. + +## Overview + +This example allocates 256 pairs of 32-bit operands +in PRU Data RAM, fills them with sequential values, performs 256 +multiply-accumulate operations accumulating a 64-bit result, stores the +result, and halts. + +The example is adapted from the PRU Software Support Package (PSSP) +`PRU_MAC_Multiply_Accum` example. + +The 256-entry operand buffer (`buf`) uses 2 KB (0x800 bytes) of PRU Data RAM. +After building, inspect the `.map` file to verify the total Data RAM usage +fits within the target device's Data RAM. + +## Supported Combinations + +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +| Processor | Hardware | Software | +|-----------|-----------|-----------------------------------------------------------------------------| +| AM62x | SK-AM62B | TI PRU CGT v2.3.3, CCS 12.7, OpenPRU v2026.01.00 | +| AM64x | TMDS64EVM | TI PRU CGT v2.3.3, CCS 12.7, OpenPRU v2026.01.00 | + +## Running and Validating + +1. Load the built ELF onto the target PRU core using CCS. Refer to the **PRU + Getting Started Labs > Lab 4: How to Initialize the PRU** for details. +2. Run the PRU core. +3. Halt execution at `__halt()`. +4. Inspect the value in `storeValue`. Refer to the **PRU Getting Started Labs > + Lab 5: How to debug PRU firmware** for details. + * The expected accumulated result in storeValue is 5,592,320 = 0x555500 [1] + +[1] Calculation for storeValue: +Each iteration contributes i * (i+1) = i² + i, so: +result = Σ(i=0 to 255) (i² + i) = Σi² + Σi +Using the standard closed-form formulas for sums up to n=255: + - Σi (0→255) = 255×256/2 = 32,640 + - Σi² (0→255) = 255×256×511/6 = 5,559,680 + - result = 32,640 + 5,559,680 = 5,592,320 = 0x555500 diff --git a/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/example.projectspec b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..9f8880cf8 --- /dev/null +++ b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/linker.cmd b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..8657dff58 --- /dev/null +++ b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,90 @@ +/* + * AM62x_PRU0.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM62x PRU0 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 16 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00004000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00002000 CREGISTER=24 + /* 8 KB PRU Data RAM 1 */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00002000 CREGISTER=25 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 32 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00008000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + PRU0_CTRL : org = 0x00022000 len = 0x00000030 CREGISTER=11 + PRU_RAT0 : org = 0x00008000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD9 : org = 0x00033000 len = 0x0000100 CREGISTER=9 + RSVD10 : org = 0x0002A000 len = 0x0000100 CREGISTER=10 + RSVD12 : org = 0x00027000 len = 0x0000100 CREGISTER=12 + RSVD13 : org = 0x0002C000 len = 0x0000100 CREGISTER=13 + RSVD14 : org = 0x00024800 len = 0x0000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x0000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x0000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x0000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x0000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x0000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x0000100 CREGISTER=20 + RSVD21 : org = 0x00032400 len = 0x0000100 CREGISTER=21 + RSVD23 : org = 0xC0000000 len = 0x0000100 CREGISTER=23 + RSVD27 : org = 0x00032000 len = 0x0000100 CREGISTER=27 + /* length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..55c7a0fae --- /dev/null +++ b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,50 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := mac_c_am62x-sk_pruss0_pru0_fw + +# NOT SUPPORTED on AM62x +# AM62x does not support initializing PRU cores from an MCU+ core +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/mac/mac_c/firmware/am62x-sk/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 3 +EXPECTED_DEVICE := am62x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile_projectspec b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..78f846fcb --- /dev/null +++ b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=mac_c_am62x-sk_pruss0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/example.projectspec b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..e82684cd9 --- /dev/null +++ b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/linker.cmd b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..6632a78ad --- /dev/null +++ b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,90 @@ +/* + * AM62x_PRU1.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM62x PRU1 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 16 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00004000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 + /* 8 KB PRU Data RAM 0 */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 32 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00008000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + PRU1_CTRL : org = 0x00024000 len = 0x00000030 CREGISTER=11 + PRU_RAT1 : org = 0x00009000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD9 : org = 0x00033000 len = 0x0000100 CREGISTER=9 + RSVD10 : org = 0x0002A000 len = 0x0000100 CREGISTER=10 + RSVD12 : org = 0x00027000 len = 0x0000100 CREGISTER=12 + RSVD13 : org = 0x0002C000 len = 0x0000100 CREGISTER=13 + RSVD14 : org = 0x00024800 len = 0x0000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x0000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x0000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x0000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x0000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x0000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x0000100 CREGISTER=20 + RSVD21 : org = 0x00032400 len = 0x0000100 CREGISTER=21 + RSVD23 : org = 0xC0000000 len = 0x0000100 CREGISTER=23 + RSVD27 : org = 0x00032000 len = 0x0000100 CREGISTER=27 + /* length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU1_DMEM_1, PAGE 1 + .bss > PRU1_DMEM_1, PAGE 1 + .cio > PRU1_DMEM_1, PAGE 1 + .data > PRU1_DMEM_1, PAGE 1 + .switch > PRU1_DMEM_1, PAGE 1 + .sysmem > PRU1_DMEM_1, PAGE 1 + .cinit > PRU1_DMEM_1, PAGE 1 + .rodata > PRU1_DMEM_1, PAGE 1 + .rofardata > PRU1_DMEM_1, PAGE 1 + .farbss > PRU1_DMEM_1, PAGE 1 + .fardata > PRU1_DMEM_1, PAGE 1 +} diff --git a/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/makefile b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..5c3ac9866 --- /dev/null +++ b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,50 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := mac_c_am62x-sk_pruss0_pru1_fw + +# NOT SUPPORTED on AM62x +# AM62x does not support initializing PRU cores from an MCU+ core +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +HEX_ARRAY_PREFIX := PRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/mac/mac_c/firmware/am62x-sk/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 3 +EXPECTED_DEVICE := am62x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/makefile_projectspec b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..2e12b47c9 --- /dev/null +++ b/academy/mac/mac_c/firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=mac_c_am62x-sk_pruss0_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..7bf520b03 --- /dev/null +++ b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..411673d10 --- /dev/null +++ b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,99 @@ +/* + * AM64x_PRU0.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM64x PRU0 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 CREGISTER=24 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 CREGISTER=25 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* XXX: PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + MII_G_RT : org = 0x00033000 len = 0x00000F44 CREGISTER=9 + TM_CFG_PRU0 : org = 0x0002A000 len = 0x0000004C CREGISTER=10 + PRU0_CTRL : org = 0x00022000 len = 0x00000030 CREGISTER=11 + PA_STATS_QRAM : org = 0x00027000 len = 0x00001000 CREGISTER=12 + PA_STATS_CRAM : org = 0x0002C000 len = 0x00001000 CREGISTER=13 + MII_MDIO : org = 0x00032400 len = 0x00000088 CREGISTER=21 + PRU_RTU_RAT0 : org = 0x00008000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + MII_RT : org = 0x00032000 len = 0x00000070 CREGISTER=27 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD14 : org = 0x00024800 len = 0x00000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x00000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x00000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x00000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x00000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x00000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x00000100 CREGISTER=20 + RSVD23 : org = 0xC0000000 len = 0x00000100 CREGISTER=23 + /* Random length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..dcb279785 --- /dev/null +++ b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := mac_c_am64x-evm_icss_g0_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/mac/mac_c/firmware/am64x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am64x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..5e49d93fe --- /dev/null +++ b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=mac_c_am64x-evm_icss_g0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..0cc984ce8 --- /dev/null +++ b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..009b97e36 --- /dev/null +++ b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,100 @@ +/* + * AM64x_PRU1.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM64x PRU1 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 CREGISTER=24 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 CREGISTER=25 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* XXX: PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + MII_G_RT : org = 0x00033000 len = 0x00000F44 CREGISTER=9 + TM_CFG_PRU1 : org = 0x0002A200 len = 0x0000004C CREGISTER=10 + PRU1_CTRL : org = 0x00024000 len = 0x00000030 CREGISTER=11 + + PA_STATS_QRAM : org = 0x00027000 len = 0x00001000 CREGISTER=12 + PA_STATS_CRAM : org = 0x0002C000 len = 0x00001000 CREGISTER=13 + MII_MDIO : org = 0x00032400 len = 0x00000088 CREGISTER=21 + PRU_RTU_RAT1 : org = 0x00009000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + MII_RT : org = 0x00032000 len = 0x00000070 CREGISTER=27 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD14 : org = 0x00024800 len = 0x00000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x00000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x00000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x00000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x00000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x00000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x00000100 CREGISTER=20 + RSVD23 : org = 0xC0000000 len = 0x00000100 CREGISTER=23 + /* Random length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU1_DMEM_1, PAGE 1 + .bss > PRU1_DMEM_1, PAGE 1 + .cio > PRU1_DMEM_1, PAGE 1 + .data > PRU1_DMEM_1, PAGE 1 + .switch > PRU1_DMEM_1, PAGE 1 + .sysmem > PRU1_DMEM_1, PAGE 1 + .cinit > PRU1_DMEM_1, PAGE 1 + .rodata > PRU1_DMEM_1, PAGE 1 + .rofardata > PRU1_DMEM_1, PAGE 1 + .farbss > PRU1_DMEM_1, PAGE 1 + .fardata > PRU1_DMEM_1, PAGE 1 +} diff --git a/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..118b26313 --- /dev/null +++ b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := mac_c_am64x-evm_icss_g0_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +HEX_ARRAY_PREFIX := PRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/mac/mac_c/firmware/am64x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am64x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..b742de057 --- /dev/null +++ b/academy/mac/mac_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=mac_c_am64x-evm_icss_g0_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/mac/mac_c/firmware/main.c b/academy/mac/mac_c/firmware/main.c new file mode 100644 index 000000000..dd5f12727 --- /dev/null +++ b/academy/mac/mac_c/firmware/main.c @@ -0,0 +1,91 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com/ + */ + +// *************************************** +// * Global Structure Definitions * +// *************************************** + +#include + + +/* R31 is used to generate the "I'm done" back to the ARM */ +volatile register uint8_t __R31; + +/* Accessing the operands structure within the multiplyParams structure + * forces the compiler to pair the registers together */ +typedef struct { + uint32_t op1; + uint32_t op2; +} operands; + +#define NUMMACS 256 + +/* + * Structure buf is pretty big: uint32 * 2 * 256 = 2kB, or 0x800 memory. + * Make sure that there is enough Data RAM for your program. This example + * allocates space for buf in .bss (uninitialized near data section). + * After you build the example, you can verify the amount of Data RAM the + * example uses by inspecting the .map file in the outputs folder. + * The .map file for the MAC example tells us: + * MEMORY CONFIGURATION --> PRUx_DMEMx: 0x900 memory is used + * SECTION ALLOCATION MAP: .bss uses 0x800 (this is buf), .stack uses 0x100 + * + * To modify the size of the stack, edit Makefile > STACK_SIZE. + * + * Reference "PRU Optimizing C/C++ Compiler User's Guide", section "Dynamic + * Memory Allocation" if you want to allocate large arrays from the heap instead + * of the .bss section. + */ +operands buf[NUMMACS]; + +/* Need to create a while loop inside main to wait for interrupt from host. + * The interrupt will signify that a buffer of data has been passed and is + * ready for MAC processing. This will be passed by rpmsg driver. + */ +int main(void) +{ + uint32_t i; + uint16_t numMacs = NUMMACS; // Arbitrary number + uint64_t result = 0; + volatile uint64_t storeValue = 0; + + /* Dummy data set */ + for (i = 0; i < numMacs; i++) { + buf[i].op1 = i; + buf[i].op2 = i+1; + } + + /* Perform numMacs MAC operations */ + for (i = 0; i < numMacs; i++) { + result += (uint64_t)buf[i].op1 * (uint64_t)buf[i].op2; + } + + /* + * NOTE! + * + * This C code does NOT use the PRU subsystem's MAC hardware + * accelerator. Instead, the multiplication is converted by the C + * compiler into a series of additions in the generated assembly file. + * Test by adding --keep_asm to the compiler flags as per the PRU + * Getting Started Labs, and searching the generated main.asm file for + * the line number with the multiply. + * + * For an example of using assembly code to use the MAC hardware + * accelerator, refer to academy/mac/mac. + * + * For an example of writing mixed C and assembly code, refer to the + * PRU Getting Started Labs under academy/getting_started_labs. + */ + + /* + * FIXME: research, is there a way to call MAC hardware accelerator + * directly from C code? + */ + + storeValue = result; + + /* Nothing to do so halt */ + __halt(); +} diff --git a/academy/mac/mac_c/makefile b/academy/mac/mac_c/makefile new file mode 100644 index 000000000..10d3aede1 --- /dev/null +++ b/academy/mac/mac_c/makefile @@ -0,0 +1,106 @@ +include ../../../imports.mak + +####################### +# project information # +####################### + +PROJECT_NAME := mac_c +SUPPORTED_PROCESSORS := am62x am64x +# Does the PRU code have dependencies outside of the open-pru repo? +PRU_DEPENDENCIES := +# Use NON_PRU_DEPENDENCIES to select which makefiles to call for non-PRU cores +NON_PRU_DEPENDENCIES := + +################### +# Prebuild checks # +################### +BUILD_PROJECT := y +DEVICE_NON_PRU := + +# Only build project if $(DEVICE) is in $(SUPPORTED_PROCESSORS) +ifeq (,$(findstring $(DEVICE),$(SUPPORTED_PROCESSORS))) +BUILD_PROJECT := n +MESSAGE := Project $(PROJECT_NAME) does not have a build option for $(DEVICE) +endif + +# Only build project if PRU dependencies exist +ifneq (,$(PRU_DEPENDENCIES)) +# MCU+ SDK dependency? +ifeq (mcuplus,$(findstring mcuplus,$(PRU_DEPENDENCIES))) +ifneq ($(BUILD_MCUPLUS),y) +BUILD_PROJECT := n +MESSAGE ?= Project $(PROJECT_NAME) depends on MCU+ SDK, but BUILD_MCUPLUS != y. +endif +endif +# Additional PRU dependency checks go here. For example: +#ifeq (dependency,$(findstring dependency,$(PRU_DEPENDENCIES))) +#if (dependency check fails) +#BUILD_PROJECT := n +#MESSAGE ?= Project $(PROJECT_NAME) depends on dependency, but dependency does not exist. +#endif +#endif +endif + +# Only build non-PRU code if the non-PRU code is enabled in imports.mak +ifeq ($(BUILD_MCUPLUS),y) +ifeq (mcuplus,$(findstring mcuplus,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_mcuplus +endif +endif +ifeq ($(BUILD_LINUX),y) +ifeq (linux,$(findstring linux,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_linux +endif +endif + +########################### +# Make and clean commands # +########################### + +ifeq ($(BUILD_PROJECT),y) +# "make" or "make all" builds projects that match $(DEVICE) set in imports.mak +# "make" builds PRU firmware first, then host (non-PRU) code +all: MESSAGE = "Building $(PROJECT_NAME) for $(DEVICE)" +all: pre_build_message + $(MAKE) pru + $(MAKE) host + +# "make pru" builds only PRU firmware for $(DEVICE) +pru: ARGUMENTS_PRU = all +pru: $(DEVICE) + +# "make host" builds only host (non-PRU) code for $(DEVICE) +host: ARGUMENTS_MCUPLUS = all +host: $(DEVICE_NON_PRU) + +# "make clean" cleans projects that match $(DEVICE) set in imports.mak +clean: ARGUMENTS_PRU = clean +clean: ARGUMENTS_MCUPLUS = scrub +clean: MESSAGE = "Cleaning $(PROJECT_NAME) for $(DEVICE)" +clean: pre_build_message $(DEVICE) $(DEVICE_NON_PRU) + +else +# if a prebuild check failed, print message and exit +all clean pru host: pre_build_message +endif + +pre_build_message: + @echo $(MESSAGE) + +###################### +# Target definitions # +###################### + +# provide target definitions for each supported processor +# PRU firmware should be built before any RTOS code that includes it +am62x: +# am62x-sk + $(MAKE) -C firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am62x-sk/pruss0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +am64x: +# am64x-evm + $(MAKE) -C firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +.PHONY: all clean pru host pre_build_message $(DEVICE) $(DEVICE_NON_PRU) $(SUPPORTED_PROCESSORS) diff --git a/academy/mac/mac_multiply/readme.md b/academy/mac/mac_multiply/readme.md index 39e1adb4b..9b914ad64 100644 --- a/academy/mac/mac_multiply/readme.md +++ b/academy/mac/mac_multiply/readme.md @@ -4,10 +4,6 @@ This example acts as a basic demonstration of the usage of MAC module in Multiply-Only mode in ICSSM PRU. -## Overview - -Here's the Overview section for the MAC (Multiply Only Mode) example README: - ## Overview This example demonstrates the usage of PRU's MAC (Multiply and Accumulate) broadside accelerator in its Multiply Only mode. While the MAC module is capable of both multiplication and accumulation operations, this mode specifically showcases its ability to perform high-speed unsigned multiplications without accumulation, making it ideal for applications requiring quick multiplication operations. @@ -22,12 +18,27 @@ The MAC module performs the multiplication without any accumulation, demonstrati This simple demonstration shows how the PRU's hardware acceleration can be utilized for basic arithmetic operations with improved performance compared to software-based multiplication. -# Supported Combinations +## Supported Combinations + +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am261x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263px | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am263x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | + +## Steps to Run the Example - Parameter | Value - ---------------|----------- - ICSSM | ICSSM0 - PRU0, PRU1; ICSSM1 (only in am261x) - PRU0, PRU1 - Toolchain | pru-cgt - Board | am261x-lp, am261x-som, am263px-cc, am263px-lp, am263x-cc, am263x-lp - Example folder | academy/mac/mac_multiply +1. Build and run the PRU firmware. +2. After the firmware finishes running, inspect the PRU register values: + - R26: lower 32 bits of the multiplication result; expected `0x4E2` + (1250 decimal = 50 × 25) + - R27: upper 32 bits; expected `0x00` diff --git a/academy/makefile b/academy/makefile index 78755988e..4dc72ef00 100644 --- a/academy/makefile +++ b/academy/makefile @@ -5,7 +5,8 @@ SUBDIRS := \ getting_started_labs \ gpio/gpio_toggle \ intc/intc_mcu \ - mac/mac mac/mac_multiply + mac/mac mac/mac_multiply mac/mac_c \ + uart/uart_loopback # "make" or "make all" builds projects that match $(DEVICE) set in imports.mak all: ARGUMENTS = all diff --git a/academy/readme.md b/academy/readme.md index 25c9e171d..1cf4d6ce0 100644 --- a/academy/readme.md +++ b/academy/readme.md @@ -44,10 +44,16 @@ intc/intc_mcu between the PRU core and an MCU+ core mac/mac -* How to use the MAC module in Multiply and Accumulate mode +* How to use the MAC module in Multiply and Accumulate mode (assembly) + +mac/mac_c +* How to do MAC without using the hardware MAC accelerator (C) mac/mac_multiply -* How to use the MAC module in Multiply-Only mode +* How to use the MAC module in Multiply-Only mode (assembly) + +uart/uart_loopback +* Loopback example with the PRU hardware UART peripheral ## Supported processors per-project @@ -82,4 +88,6 @@ For more information about the PRU features on each processor, refer to app note | gpio/gpio_toggle | Yport | Y | Y | Y | N-sw | Yport | | intc/intc_mcu | Yport | Y | Y | Y | N-sw | Yport | | mac/mac | Yport | Y | Y | Y | Yport | Yport | +| mac/mac_c | Yport | Yport | Yport | Yport | Y | Y | | mac/mac_multiply | Yport | Y | Y | Y | Yport | Yport | +| uart/uart_loopback | Yport | Yport | Yport | Yport | Y | Yport | diff --git a/academy/uart/uart_loopback/README.md b/academy/uart/uart_loopback/README.md new file mode 100644 index 000000000..5c29a15f7 --- /dev/null +++ b/academy/uart/uart_loopback/README.md @@ -0,0 +1,46 @@ +# UART Loopback + +## Introduction + +This example demonstrates the PRU UART peripheral by configuring it in +loopback mode and exercising a transmit/receive cycle. + +## Overview + +This example demonstrates the PRU UART peripheral by configuring it at 115200 +baud in loopback mode, transmitting 6 characters ("Hello!"), receiving them +back through the internal loopback path, and halting. No external wiring is +required because loopback mode connects the transmit output to the receive +input inside the UART block. + +The example is adapted from the PRU Software Support Package (PSSP) +`PRU_Hardware_UART` example. + +## Supported Combinations + +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Hardware + +No external connections are required. The UART operates in internal loopback +mode. To route UART signals to physical pins, disable loopback (clear +`CT_UART.MCTR`) and configure the appropriate pinmux before running the +firmware. + +## Validated HW & SW + +| Processor | Hardware | Software | +|-----------|----------|---------------------------------------------------------------------------| +| AM62x | SK-AM62B | TI PRU CGT v2.3.3, CCS 12.7, OpenPRU v2026.01.00 | + +## Running and Validating + +1. Load the built ELF onto the AM62x-SK PRU0 core using CCS. Refer to the **PRU + Getting Started Labs > Lab 4: How to Initialize the PRU** for details. +2. Run the PRU core. +3. Halt execution at `__halt()`. +4. Inspect the `buffer` array. Refer to the **PRU Getting Started Labs > + Lab 5: How to debug PRU firmware** for details. + * The first 6 bytes should contain `0x48 0x65 0x6C 0x6C 0x6F 0x21` ("Hello!"). diff --git a/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/example.projectspec b/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..d2a9d7144 --- /dev/null +++ b/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/linker.cmd b/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..8657dff58 --- /dev/null +++ b/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,90 @@ +/* + * AM62x_PRU0.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM62x PRU0 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 16 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00004000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00002000 CREGISTER=24 + /* 8 KB PRU Data RAM 1 */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00002000 CREGISTER=25 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 32 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00008000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + PRU0_CTRL : org = 0x00022000 len = 0x00000030 CREGISTER=11 + PRU_RAT0 : org = 0x00008000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD9 : org = 0x00033000 len = 0x0000100 CREGISTER=9 + RSVD10 : org = 0x0002A000 len = 0x0000100 CREGISTER=10 + RSVD12 : org = 0x00027000 len = 0x0000100 CREGISTER=12 + RSVD13 : org = 0x0002C000 len = 0x0000100 CREGISTER=13 + RSVD14 : org = 0x00024800 len = 0x0000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x0000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x0000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x0000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x0000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x0000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x0000100 CREGISTER=20 + RSVD21 : org = 0x00032400 len = 0x0000100 CREGISTER=21 + RSVD23 : org = 0xC0000000 len = 0x0000100 CREGISTER=23 + RSVD27 : org = 0x00032000 len = 0x0000100 CREGISTER=27 + /* length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile b/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..922349318 --- /dev/null +++ b/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,50 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := uart_loopback_am62x-sk_pruss0_pru0_fw + +# NOT SUPPORTED on AM62x +# AM62x does not support initializing PRU cores from an MCU+ core +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/uart/uart_loopback/firmware/am62x-sk/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 3 +EXPECTED_DEVICE := am62x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile_projectspec b/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..9f1935f69 --- /dev/null +++ b/academy/uart/uart_loopback/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=uart_loopback_am62x-sk_pruss0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/uart/uart_loopback/firmware/main.c b/academy/uart/uart_loopback/firmware/main.c new file mode 100644 index 000000000..203867c09 --- /dev/null +++ b/academy/uart/uart_loopback/firmware/main.c @@ -0,0 +1,133 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2024-2024 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include + +/* The FIFO size on the PRU UART is 16 bytes; however, we are (arbitrarily) + * only going to send 8 at a time */ +#define FIFO_SIZE 16 +#define MAX_CHARS 8 + +/* This hostBuffer structure is temporary but stores a data buffer */ +struct { + uint8_t msg; // Not used today + uint8_t data[FIFO_SIZE]; +} hostBuffer; + +/* Making this buffer global will force the received data into memory */ +uint8_t buffer[MAX_CHARS]; + +int main(void) +{ + uint8_t tx; + uint8_t cnt; + + /* FIXME: If modifying this to send data through the pins then PinMuxing + * needs to be taken care of prior to running this code. + * This is usually done via a GEL file in CCS or by the Linux driver */ + + /* + * NOTE!!! As of AM62x TRM Rev B: + * + * - Definitions of PRU UART register field descriptions are missing + * + * - The PRU UART hardware in AM335x & AM62x is EXACTLY identical. + * Thus, we can reference the AM335x TRM instead + * + * - Detailed register field descriptions can be found in the AM335x + * TRM, Section PRU > Registers > PRU_ICSS_UART Registers + * + * - PRU UART register bitfields are wrong, for the registers where + * multiple registers share the same base address (RBR, THR, IIR, FCR) + * + * - Refer to AM335x TRM for correct bitfields + */ + + /*** INITIALIZATION ***/ + + /* Set up UART to function at 115200 baud - DLL divisor is 104 at 16x oversample + * 192MHz / 104 / 16 = ~115200 */ + CT_UART.DIVLSB = 104; + CT_UART.DIVMSB = 0; + CT_UART.MODE = 0x0; + + /* Enable Interrupts in UART module. This allows the main thread to poll for + * Receive Data Available and Transmit Holding Register Empty */ + CT_UART.INT_EN = 0x7; + + /* If FIFOs are to be used, select desired trigger level and enable + * FIFOs by writing to FCR. FIFOEN bit in FCR must be set first before + * other bits are configured */ + CT_UART.FCR_bit.FIFOEN = 1; + + /* Enable FIFOs */ + CT_UART.FCR_bit.DMAMODE1 = 1; + /* RXFIFTL = 0x0 = 1-byte RX FIFO trigger */ + /* Alternative: 8-byte RX FIFO trigger */ + // CT_UART.FCR_bit.RXFIFTL = 0x2; + + /* flush the FIFOs */ + CT_UART.FCR_bit.TXCLR = 1; + CT_UART.FCR_bit.RXCLR = 1; + + /* Choose desired protocol settings by writing to LCR */ + /* 8-bit word, 1 stop bit, no parity, no break control and no divisor latch */ + CT_UART.LCTR = 3; + + /* Enable loopback for test */ + /* + * NOTE! + * loopback will prevent the UART from sending data to the output + * pins. Remember to disable loopback in the MCR register before + * looking for signals on your UART pins. + */ + CT_UART.MCTR = 0x10; + + /* Choose desired response to emulation suspend events by configuring + * FREE bit and enable UART by setting UTRST and URRST in PWR */ + /* Allow UART to run free, enable UART TX/RX */ + CT_UART.PWR = 0x6001; + + /*** END INITIALIZATION ***/ + + /* Priming the 'hostbuffer' with a message */ + hostBuffer.data[0] = 'H'; + hostBuffer.data[1] = 'e'; + hostBuffer.data[2] = 'l'; + hostBuffer.data[3] = 'l'; + hostBuffer.data[4] = 'o'; + hostBuffer.data[5] = '!'; + hostBuffer.data[6] = '\0'; + + /*** SEND SOME DATA ***/ + + /* Let's send/receive some dummy data */ + for (cnt = 0; cnt < MAX_CHARS; cnt++) { + /* Load character, ensure it is not string termination */ + if ((tx = hostBuffer.data[cnt]) == '\0') + break; + /* Write to the THR data bitfield, as defined in the AM335x TRM */ + CT_UART.THR_bit.DATA = tx; + + /* Because we are doing loopback, wait until LSR.DR == 1 + * indicating there is data in the RX FIFO */ + while ((CT_UART.LSR1_bit.DR == 0x0)); + + /* Read the value from RBR */ + buffer[cnt] = CT_UART.RBR_bit.DATA; + + /* Wait for TX FIFO to be empty */ + while (!((CT_UART.IIR_bit.INTID) == 0x1)); + } + + /*** DONE SENDING DATA ***/ + + /* Disable UART before halting */ + CT_UART.PWR = 0x0; + + /* Halt PRU core */ + __halt(); +} diff --git a/academy/uart/uart_loopback/makefile b/academy/uart/uart_loopback/makefile new file mode 100644 index 000000000..5d3653657 --- /dev/null +++ b/academy/uart/uart_loopback/makefile @@ -0,0 +1,100 @@ +include ../../../imports.mak + +####################### +# project information # +####################### + +PROJECT_NAME := uart_loopback +SUPPORTED_PROCESSORS := am62x +# Does the PRU code have dependencies outside of the open-pru repo? +PRU_DEPENDENCIES := +# Use NON_PRU_DEPENDENCIES to select which makefiles to call for non-PRU cores +NON_PRU_DEPENDENCIES := + +################### +# Prebuild checks # +################### +BUILD_PROJECT := y +DEVICE_NON_PRU := + +# Only build project if $(DEVICE) is in $(SUPPORTED_PROCESSORS) +ifeq (,$(findstring $(DEVICE),$(SUPPORTED_PROCESSORS))) +BUILD_PROJECT := n +MESSAGE := Project $(PROJECT_NAME) does not have a build option for $(DEVICE) +endif + +# Only build project if PRU dependencies exist +ifneq (,$(PRU_DEPENDENCIES)) +# MCU+ SDK dependency? +ifeq (mcuplus,$(findstring mcuplus,$(PRU_DEPENDENCIES))) +ifneq ($(BUILD_MCUPLUS),y) +BUILD_PROJECT := n +MESSAGE ?= Project $(PROJECT_NAME) depends on MCU+ SDK, but BUILD_MCUPLUS != y. +endif +endif +# Additional PRU dependency checks go here. For example: +#ifeq (dependency,$(findstring dependency,$(PRU_DEPENDENCIES))) +#if (dependency check fails) +#BUILD_PROJECT := n +#MESSAGE ?= Project $(PROJECT_NAME) depends on dependency, but dependency does not exist. +#endif +#endif +endif + +# Only build non-PRU code if the non-PRU code is enabled in imports.mak +ifeq ($(BUILD_MCUPLUS),y) +ifeq (mcuplus,$(findstring mcuplus,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_mcuplus +endif +endif +ifeq ($(BUILD_LINUX),y) +ifeq (linux,$(findstring linux,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_linux +endif +endif + +########################### +# Make and clean commands # +########################### + +ifeq ($(BUILD_PROJECT),y) +# "make" or "make all" builds projects that match $(DEVICE) set in imports.mak +# "make" builds PRU firmware first, then host (non-PRU) code +all: MESSAGE = "Building $(PROJECT_NAME) for $(DEVICE)" +all: pre_build_message + $(MAKE) pru + $(MAKE) host + +# "make pru" builds only PRU firmware for $(DEVICE) +pru: ARGUMENTS_PRU = all +pru: $(DEVICE) + +# "make host" builds only host (non-PRU) code for $(DEVICE) +host: ARGUMENTS_MCUPLUS = all +host: $(DEVICE_NON_PRU) + +# "make clean" cleans projects that match $(DEVICE) set in imports.mak +clean: ARGUMENTS_PRU = clean +clean: ARGUMENTS_MCUPLUS = scrub +clean: MESSAGE = "Cleaning $(PROJECT_NAME) for $(DEVICE)" +clean: pre_build_message $(DEVICE) $(DEVICE_NON_PRU) + +else +# if a prebuild check failed, print message and exit +all clean pru host: pre_build_message +endif + +pre_build_message: + @echo $(MESSAGE) + +###################### +# Target definitions # +###################### + +# provide target definitions for each supported processor +# PRU firmware should be built before any RTOS code that includes it +am62x: +# am62x-sk + $(MAKE) -C firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +.PHONY: all clean pru host pre_build_message $(DEVICE) $(DEVICE_NON_PRU) $(SUPPORTED_PROCESSORS) diff --git a/best_practices.md b/best_practices.md index 209053d4f..5b3810510 100644 --- a/best_practices.md +++ b/best_practices.md @@ -402,6 +402,8 @@ Key conventions: - Copyright header is required on all source files (see General Remarks). - Use FIXME (not TODO) for pending work markers. - Column limits: no text beyond column 79 (soft), column 129 (hard). + Tool-generated files (for example SysConfig `*.syscfg` files) are exempt; see + General Remarks rule 11. ## C Code Best Practices (MCU+ Host Cores) @@ -612,12 +614,18 @@ m_test_assert .macro condition, error_code 8. Use "for example" instead of "e.g.". 9. Use "that is" instead of "i.e.". 10. Use "and so on" instead of "etc,". -11. No text beyond column 79 in source files (does not apply to markdown docs or .txt docs). +11. No text beyond column 79 in hand-written source files (does not apply to + markdown docs, .txt docs, or tool-generated files). - Column 79 is the "soft" limit. - Long lines of code are more difficult to follow and interrupt code flow. - There shall be no text beyond column 129. - This is the "hard" limit. - Lines longer than column 79 should be the exceptional case in any source file. + - Tool-generated files are exempt from both the soft and hard limits, since + their formatting is owned by the generating tool and cannot be wrapped by + hand. This notably includes SysConfig `*.syscfg` files, whose + `@cliArgs`/`@v2CliArgs` header lines are emitted as single-line command + strings that exceed column 129 by construction. ## Files 1. The extension for clpru (CGT PRU) source files shall be ".asm". @@ -727,6 +735,13 @@ Compiler does not support forward declarations of symbols via the .set directive ## Header File include rules - It is recommended to include only header files required in .asm sources +- Use the backslash character (`\`) in PRU assembly `.include` paths for + cross-platform compatibility with the PRU assembler. Do not use forward + slash (`/`) separators in `.include` operands. + ``` + ; portable across Windows and Linux builds for PRU assembly includes + .include "source\firmware\common\icss_constant_defines.inc" + ``` - Four underscores recommended in header guard, example below: ``` .if !$isdefed("____icss_header_h") @@ -954,6 +969,3 @@ For the complete and up-to-date PRU Assembly Instruction Cheat Sheet, see: - **Solution**: Document all timing-critical sections and hardware dependencies --- - - - diff --git a/docs/contributing.md b/docs/contributing.md index f85ab2067..38eef6090 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -55,6 +55,9 @@ If the existing runbooks in `docs_ai/` still accurately describe the patterns after your change, no update is needed. If they no longer match, update the relevant runbook(s) as part of the same PR. +When adding a new runbook or reference to `docs_ai/`, or otherwise changing its +structure, follow [`docs_ai/authoring_guide.md`](../docs_ai/authoring_guide.md). + ### Update pr_compliance_checklist.yaml If your PR adds or changes a contribution requirement in this file, also diff --git a/docs/release_notes.md b/docs/release_notes.md index fd865dfff..a4b18ff4b 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -9,8 +9,9 @@ [Checking out a specific release](#checking-out-a-specific-release) [Compatible versions of CCS & other tools](#compatible-versions-of-ccs--other-tools) [All Release Notes](#all-release-notes) -[v2026.01.00](#v20260100) -[v2026.00.00](#v20260000) +[v2026.02.00](#v20260200), +[v2026.01.00](#v20260100), +[v2026.00.00](#v20260000), [v2025.00.00](#v20250000) The open-pru repo does not have official software releases like the TI SDKs. @@ -18,6 +19,9 @@ The open-pru repo does not have official software releases like the TI SDKs. Instead, we will regularly update the open-pru repo. When the repo has been significantly changed, we will add a new tag to the main branch. +Starting with v2026.02.00, academy links are in the top-level README.md instead +of specific release notes. + ## Checking out a specific release To base your development on a specific tag (instead of the tip of the main @@ -40,6 +44,52 @@ repo is checked out to the specific release tag that you are using. ## All Release Notes +### v2026.02.00 + +#### Major Updates + +* AM26x: add support for MCU+ SDK 11.0 - 26.0 [1] + * am261x, am263px, and am263x FreeRTOS projects build with MCU+ SDK + 11.0, 11.1, and 26.0 + * Update AM26x CCS project files for MCU+ SDK 11.0+ + +* GitHub CI: test latest MCU+ SDK releases + * am261x, am263px, am263x: MCU+ SDK 26.0 + * am243x, am64x: MCU+ SDK 12.0 + +* rpmsg: add GCC (Linux/A53) build support + * New rpmsg example built with the GCC toolchain + +#### Supported Processors + +AM243x, AM261x, AM263Px, AM263x, AM62x, AM64x + +#### Compatible SDKs + +These SDK release versions can be used to build OpenPRU projects with a specific +tag. The OpenPRU projects may require modifications before they can be built +with older SDK versions. For more information, refer to +[Using Older SDKs with OpenPRU](./using_older_sdks_with_open_pru.md). + +| SDK | am243x | am261x | am263px | am263x | am62x | am64x | +| --------- | ----------- | ----------- | ----------- | ----------- | ---------- | ----------- | +| MCU+ SDK | 11.1 - 12.0 | 11.0 - 26.0 | 11.0 - 26.0 | 11.0 - 26.0 | N/A | 11.1 - 12.0 | +| Linux SDK | N/A | N/A | N/A | N/A | 11.x, 12.x | 11.x, 12.x | + +#### Additional Updates & bugfixes + +* docs: document PRU assembly `.include` separator conventions; add PR + compliance check for include separators + +* rpmsg (GCC): fix integer cast of pointer; fix compiler warning; add missing + header + +[1] +* Adding support for AM26x MCU+ SDK 11.0 breaks backwards compatibility with + AM26x MCU+ SDK 10.2. For more information on building an OpenPRU project with + an older version of MCU+ SDK, refer to + [Using Older SDKs with OpenPRU](./using_older_sdks_with_open_pru.md) + ### v2026.01.00 #### Major Updates diff --git a/docs/tagging_checklist.md b/docs/tagging_checklist.md index a8d6c81ce..37317a65b 100644 --- a/docs/tagging_checklist.md +++ b/docs/tagging_checklist.md @@ -85,9 +85,10 @@ SDK versions that were validated during [Test SDK releases](#test-sdk-releases): ## Update the .metadata version Update the OpenPRU version field to the new release tag (e.g. `2026.01.00`) in -this file: +these files: -`.metadata/.tirex/package.tirex.json` +* `.metadata/.tirex/package.tirex.json` +* `.metadata/product.json` ## Update the year diff --git a/docs/using_older_sdks_with_open_pru.md b/docs/using_older_sdks_with_open_pru.md index f3b6dfbb8..5643cec7e 100644 --- a/docs/using_older_sdks_with_open_pru.md +++ b/docs/using_older_sdks_with_open_pru.md @@ -25,7 +25,7 @@ number to represent each kind of modification. | AM243X SDK | Mandatory modifications | Optional modifications | | --------------- | ----------------------- | ---------------------- | | MCU+ 8.6 - 9.2 | [1] [2] | [4] | - | MCU+ 10.0 | [1], either [2] or [7] | [4] | + | MCU+ 10.0 | [1]; either [2] or [7] | [4] | | MCU+ 10.1-11.0 | Either [2] or [7] | | @@ -35,27 +35,30 @@ number to represent each kind of modification. | AM261x SDK | Mandatory modifications | Optional modifications | | --------------- | ----------------------- | ---------------------- | - | MCU+ SDK 10.0.1 | Either [2] or [3] | | + | MCU+ SDK 10.0.1 | Either [2] or [3]; [8] | | + | MCU+ SDK 10.2 | [8] | |
AM263Px - | AM263Px SDK | Mandatory modifications | Optional modifications | - | ------------- | ----------------------- | ---------------------- | - | MCU+ SDK 10.0 | [1]. Either [2] or [3] | [4] | - | MCU+ SDK 10.1 | Either [2] or [3] | | + | AM263Px SDK | Mandatory modifications | Optional modifications | + | ------------- | ---------------------------- | ---------------------- | + | MCU+ SDK 10.0 | [1]; Either [2] or [3]; [8] | [4] | + | MCU+ SDK 10.1 | Either [2] or [3]; [8] | | + | MCU+ SDK 10.2 | [8] | |
AM263x - | AM263x SDK | Mandatory modifications | Optional modifications | - | --------------- | ------------------------ | ---------------------- | - | MCU+ 9.2 | [1]. Either [2] or [3] | [4] | - | MCU+ 10.0, 10.1 | Either [2] or [3] | | + | AM263x SDK | Mandatory modifications | Optional modifications | + | --------------- | ----------------------------- | ---------------------- | + | MCU+ 9.2 | [1]; Either [2] or [3]; [8] | [4] | + | MCU+ 10.0, 10.1 | Either [2] or [3]; [8] | | + | MCU+ 10.2 | [8] | |
@@ -96,6 +99,8 @@ number to represent each kind of modification. [7. Revert MCU+ SDK 11.1 makefile updates](#7-revert-mcu-sdk-11-1-makefile-updates). Affects: AM243x & AM64x MCU+ cores +[8. Revert AM26x MCU+ SDK 11.0 makefile updates](#8-revert-am26x-mcu-sdk-110-makefile-updates). Affects: AM26x MCU+ cores + ## 1. Update SysConfig version Affects: PRU code @@ -202,3 +207,19 @@ adding XML build infrastructure, and several other miscellaneous changes. In order to undo these changes, revert the file changes that were done in OpenPRU commit [AM243x & AM64x: Add support for MCU+ SDK 11.1&11.2](https://github.com/TexasInstruments/open-pru/commit/a29c10dbb4348065d13ba91af515e64e517e11a5) + +## 8. Revert AM26x MCU+ SDK 11.0 makefile updates + +Affects: AM26x MCU+ cores (AM261x, AM263Px, AM263x) + +Starting in AM26x MCU+ SDK 11.0, the makefile infrastructure for MCU+ cores +is updated. Changes include adding the `-DOS_FREERTOS` define, renaming +libraries to include a `.freertos.` infix, adding XML build infrastructure, +updating the boot image format from appimage to MulticoreELF (MCELF), and +several other miscellaneous changes. + +In order to undo these changes, revert the file changes that were done in +OpenPRU commit +[AM26x: Add support for MCU+ SDK 11.0](https://github.com/TexasInstruments/open-pru/commit/402bcbbfc0b699a5ebdee3a8dedefb565fa13056) +and +[AM26x: Update CCS project files for MCU+ SDK 11.0+](https://github.com/TexasInstruments/open-pru/commit/b12ce335e1bfc4f82cc21b6892d3feecdd29d990). diff --git a/docs_ai/README.md b/docs_ai/README.md new file mode 100644 index 000000000..3c83c5cde --- /dev/null +++ b/docs_ai/README.md @@ -0,0 +1,40 @@ +# docs_ai/ — AI-Agent Documentation for OpenPRU + +This README file +- directs you to the correct task runbook, if one exists +- lists useful reference files with when-to-read triggers + +## Task runbook index + +| Task | File | +|------|------| +| Create a new OpenPRU project | `docs_ai/task_create_project.md` | +| Port an existing project to a new device or board | `docs_ai/task_port_project.md` | + +## Reference files (read on demand) + +Read these files when directed to by a task runbook, or when the when-to-read +trigger applies. Do not read them upfront. + +| File | Contents | When to read | +|------|----------|--------------| +| `docs/open_pru_organization.md` | Repo layout and project structure | Before placing a new project, directory, or source file | +| `docs/open_pru_create_new_project.md` | Project creation patterns | When creating a new project | +| `docs/open_pru_create_new_mcuplus_project.md` | Project creation patterns with MCU+ code | When creating a new project with MCU+ (R5F) host code | +| `best_practices.md` | Coding standards for PRU assembly and C | Before writing or reviewing PRU C/assembly; skip for makefile, projectspec, linker, or other build-infrastructure files | +| `docs/PRU Assembly Instruction Cheat Sheet.md` | PRU instruction reference | When writing or debugging PRU assembly | +| `docs_ai/reference/pru_subsystem_features_comparison_g/pru_subsystem_features_comparison_g.md` | Feature-by-feature comparison of PRU-ICSS, PRU_ICSSG, and PRUSS subsystems across devices | When selecting a device or confirming whether a PRU feature/peripheral exists on the target subsystem | +| `docs_ai/reference/pru_subsystem_migration_guide/pru_subsystem_migration_guide.md` | PRU-ICSS vs PRU_ICSSG hardware differences: memory maps, constant tables, I/O, interrupts, peripherals (UART/eCAP/PWM/IEP/MDIO/MII_RT) | When porting firmware between PRU-ICSS and PRU_ICSSG subsystems, or resolving register/memory-map/peripheral differences | + +**Deep references** (read only when a compiler or assembler question arises; +grep for the relevant section first rather than reading the file in full): + +| File | Contents | When to read | +|------|----------|--------------| +| `docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/pru_assembly_language_tools_users_guide_v2_3.md` | PRU assembler, linker, and object-tools reference (directives, sections, pseudo-ops) | For PRU assembler syntax, directives, or linker/section questions | +| `docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/pru_optimizing_c_compiler_users_guide_v2_3.md` | PRU C/C++ compiler reference (pragmas, intrinsics, optimization, run-time environment) | For PRU C compiler pragmas, intrinsics, or optimization questions | + +--- + +Modifying docs_ai itself (adding a tasklist, reference, or feature runbook)? +See `docs_ai/authoring_guide.md`. Day-to-day task agents do not need it. diff --git a/docs_ai/authoring_guide.md b/docs_ai/authoring_guide.md new file mode 100644 index 000000000..ab23ff641 --- /dev/null +++ b/docs_ai/authoring_guide.md @@ -0,0 +1,202 @@ +# docs_ai/ — Authoring Guide + +Read this before adding to or changing `docs_ai/` (a new tasklist, a new +reference doc, a feature or simulator-testing runbook, or an edit to +`README.md`). It is not read during day-to-day tasks — `README.md` does not +route task agents here. + +## Why docs_ai is structured the way it is + +`AGENTS.md` makes every OpenPRU task begin by reading `docs_ai/README.md`. That +file is therefore always-loaded context for every task, competing with the +actual work for the agent's attention and token budget. Everything below follows +from that: keep the always-loaded surface tiny, and push detail into files that +are loaded only on demand. + +## Two kinds of file, kept separate + +- **Execution docs** — task runbooks (`task_*.md`) an agent *follows* to do work, + and reference docs under `reference/` an agent *consults*. These are what + `README.md` routes to. +- **Meta docs** — this authoring guide. Read only when editing docs_ai, by a + different actor at a different time. Never routed from the task or reference + tables. + +Do not mix the two. Guidance about *how to write* a runbook does not belong in a +runbook, and never belongs in `README.md`. + +## Authoring practices + +1. **Progressive disclosure.** `README.md` is a router, not a manual. Detail + lives in leaf files loaded on demand. Never inline into `README.md` what a + table row can point to. + +2. **A when-to-read trigger on every reference.** Each row in the reference + tables must say when to read the file and, where useful, when to skip it. + Without an explicit trigger an agent over-reads. For large files, add a "grep + for the relevant section first" instruction. + +3. **Self-contained.** Runbooks and references must point only to files inside + the repo and standard tool install paths. They must not depend on any + individual developer's local configuration (for example, `~/.claude/CLAUDE.md` + or a machine-specific path). Anything shared with other engineers must assume + no ambient local state. + +4. **Keep README.md a pure router.** Concretely, `README.md` contains only: + its short intro, the task runbook index table, the reference-files table, the + deep-references table, and the one-line pointer to this guide. It must NOT + contain: prose explaining a task (that goes in the runbook), authoring or + maintenance rules (they go here), background or rationale, or any content an + agent would read but not act on. Before committing a `README.md` change, ask: + "does a task-executing agent act on this line?" If no, it does not belong in + `README.md`. New rows are fine; new sections are a signal you are adding + content that belongs in a leaf file or in this guide. + +5. **Maintenance is part of the same PR.** When a PR changes an OpenPRU repo + pattern that docs_ai documents, the PR author updates the affected docs_ai + files in that same PR. The authoritative list of triggering changes lives in + `docs/contributing.md` §"Update AI-agent documentation" — do not restate it + here; keep that list the single source of truth. + +## Writing a task runbook for an AI agent + +A task runbook is a procedure an agent *executes* end to end, often unattended +and often on a non-Claude harness. Write for an executor that is capable but +has no memory of this repo beyond the runbook and its pre-reads, follows +instructions literally, and will fill any gap with a plausible guess unless +told not to. The failure mode is not missing instructions — it is steps buried +in prose getting skipped, and steps marked done that were never performed. + +### Required skeleton + +Use this top-level structure, in order: + +1. **Title** — `# Task: `. +2. **How to run this task** — the execution protocol the agent follows before + touching a step. Use the template in "Make the checklist the spine" below. + This is what turns a document into a tracked procedure. +3. **Pre-read list** — the exact files to read first, each with a one-line + reason. Repo knowledge enters here; every step below assumes it. +4. **Decision tree** — the branching questions that set scope (target + device/board, host type, PR vs private), answered *before* any step runs. + End it with an instruction to record the answers to a visible note; later + sections branch on them. +5. **Sections of checkboxed steps** — the work (see step rules below). +6. **Verification steps** — numbered `V1, V2, …`, each with the command to run, + the expected result, and an instruction to paste the actual output. Have them + reproduce locally whatever gate the change must ultimately pass (for this + repo, the top-level and CCS builds that CI runs), so failures surface before + handoff — the agent runs these steps, not CI. End with a step that checks each + recorded Do-not-do constraint held. +7. **Do-not-do list** — the mistakes an agent would otherwise make, each with a + one-line reason so the constraint survives paraphrase. + +### Make the checklist the spine + +The "How to run this task" section converts a static document into a tracked +procedure. Use this template verbatim, adapting only the reference to the +runbook's decision steps: + +````markdown +## How to run this task + +Before starting: + +1. Read the Pre-read list below. +2. Answer the Decision tree questions and record the answers — plus the + Do-not-do constraints — in a "Run parameters" note you keep visible. Every + section below branches on the answers; the final verification checks the + constraints held. +3. Turn each `- [ ]` item in the sections your answers select into tracked + work: + - If your environment provides a task or to-do tracking tool, create one + tracked item per checkbox and mark each done as you complete it. + - Otherwise, copy the relevant checklist into your first response and + re-post it with items marked `[x]` as you finish them. + Either way, your first response must show the materialized list — the tool's + items or the pasted checklist — so the tracking is visible before any step + runs. +4. A checkbox with sub-bullets is done only when every sub-bullet is done. +5. Do the steps in order; later sections depend on earlier outputs. Do not skip + an item because it "looks unnecessary." If an item is N/A given your + answers, mark it N/A with a one-line reason. +```` + +The rules this template encodes: + +- **Atomic imperative items.** Every step is a `- [ ]` box with one action. + Prose paragraphs bury actions — do not hide a required step inside one. +- **Portable task-tracking — never name a tool.** The template describes the + capability ("if your environment provides a task/to-do tool …"). Naming a + specific harness's task tool breaks the runbook on other harnesses. +- **Verification proves success, not asserts it.** Every verification step + states the command, the expected result, and an instruction to paste the + actual output. A step the agent can satisfy by saying "done" — "confirm it + works," "ensure the build passes" — verifies nothing. + +### How to write the steps + +- **Point to the authoritative doc; do not restate it.** Write + `See \`docs/…\` §"Section name"` and summarize only the keys that matter. + Duplicated procedure drifts out of sync — the single-source rule the rest of + this guide follows. +- **Make every branch explicit.** State the condition and both outcomes + ("For Linux-only or standalone hosts, skip this step; otherwise …"). Never + leave the executor to infer whether a step applies; tell it to mark an + inapplicable step N/A with a one-line reason rather than silently skip it. +- **Inline the exact command** where one exists (`cp -r `), with + placeholders in angle brackets. +- **Gate irreversible, hardware, or ambiguous actions on the user.** For pin + routing, SysConfig, device settings, and anything unverifiable from repo + files: copy a known-good starting point, tell the user it is unmodified and + needs manual review, and do not let the agent edit it — even with + user-provided values. +- **Forbid guessing explicitly.** Where a value cannot be derived from an + observed source, instruct the agent to mark a FIXME and ask the user rather + than invent one. Agents guess by default; the runbook is where you stop it. +- **Insert a first-artifact checkpoint.** Where the work has a natural first + coherent artifact — a renamed skeleton before customization, the first core + that builds — add a step that presents it and re-checks it against the + recorded scope before the pattern is replicated or customized further. An + interpretation error caught here is caught once, not repeated across every + later step. +- **Bound blind retries.** Tell the agent that if a verification (build or test) + fails, it may make a small number of fix attempts, then must stop and report — + never invent a workaround or edit outside the project to force a pass. + Unbounded edit→build loops are a silent failure mode. +- **Use stable named anchors** for cross-references (section names, step IDs), + never numeric footnotes. Step IDs must be unique within a runbook; the same + IDs (`A1`, `D1`, `V1`) recurring across runbooks is fine — each is executed in + isolation. + +### Adherence is not a guarantee + +In-document wording maximizes adherence but does not enforce it. If a task must +not deviate, enforcement comes from a wrapper outside the document (a harness +hook or an external runner that checks the ticked checklist), not from stronger +prose. Write the runbook for maximum adherence; do not assume it is airtight. + +### Self-check before committing a runbook + +- Could an agent with no prior knowledge of this repo follow it top to bottom, + stopping at every point a human decision is required? +- Does every step either contain its command or name the doc and section that + does? +- Does every verification step state a command, an expected result, and an + instruction to paste the actual output? +- Do the verification steps reproduce the gate the change must ultimately pass, + and end by checking each Do-not-do constraint held? + +## Adding a new task runbook + +1. Write `docs_ai/task_.md` following the skeleton and rules in + "Writing a task runbook for an AI agent" above. +2. Add one row to the task runbook index table in `README.md`. +3. Do not add prose about the task to `README.md` — it goes in the runbook. + +## Adding a new reference doc + +1. Place it under `docs_ai/reference//`, one folder per document, so + any figures or assets stay beside the file that links them. +2. Add one row to the reference-files table (or the deep-references table for + large tool manuals) in `README.md`, with a when-to-read trigger. diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_100_Figure_2.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_100_Figure_2.jpeg new file mode 100644 index 000000000..7ef00adb9 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_100_Figure_2.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_100_Figure_5.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_100_Figure_5.jpeg new file mode 100644 index 000000000..cf6999a47 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_100_Figure_5.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_101_Figure_10.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_101_Figure_10.jpeg new file mode 100644 index 000000000..7c3b887bd Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_101_Figure_10.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_133_Figure_5.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_133_Figure_5.jpeg new file mode 100644 index 000000000..a430d4405 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_133_Figure_5.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_160_Figure_5.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_160_Figure_5.jpeg new file mode 100644 index 000000000..b6e4f886b Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_160_Figure_5.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_17_Figure_4.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_17_Figure_4.jpeg new file mode 100644 index 000000000..de5461f76 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_17_Figure_4.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_18_Figure_15.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_18_Figure_15.jpeg new file mode 100644 index 000000000..14232d465 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_18_Figure_15.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_202_Figure_6.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_202_Figure_6.jpeg new file mode 100644 index 000000000..4ee1a6e8a Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_202_Figure_6.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_226_Figure_21.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_226_Figure_21.jpeg new file mode 100644 index 000000000..0ce8c0feb Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_226_Figure_21.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_227_Picture_15.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_227_Picture_15.jpeg new file mode 100644 index 000000000..d35c11e90 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_227_Picture_15.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_237_Figure_6.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_237_Figure_6.jpeg new file mode 100644 index 000000000..d75ceb089 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_237_Figure_6.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_243_Figure_6.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_243_Figure_6.jpeg new file mode 100644 index 000000000..8f4097df1 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_243_Figure_6.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_254_Figure_6.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_254_Figure_6.jpeg new file mode 100644 index 000000000..8aab63517 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_254_Figure_6.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_258_Figure_18.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_258_Figure_18.jpeg new file mode 100644 index 000000000..dc2b1a183 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_258_Figure_18.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_259_Figure_14.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_259_Figure_14.jpeg new file mode 100644 index 000000000..d7523ea45 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_259_Figure_14.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_261_Figure_4.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_261_Figure_4.jpeg new file mode 100644 index 000000000..01671637b Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_261_Figure_4.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_264_Figure_3.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_264_Figure_3.jpeg new file mode 100644 index 000000000..aa0763d0a Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_264_Figure_3.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_272_Figure_14.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_272_Figure_14.jpeg new file mode 100644 index 000000000..1293da5ad Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_272_Figure_14.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_273_Figure_12.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_273_Figure_12.jpeg new file mode 100644 index 000000000..29065a06d Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_273_Figure_12.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_274_Figure_10.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_274_Figure_10.jpeg new file mode 100644 index 000000000..087a929ef Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_274_Figure_10.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_275_Figure_11.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_275_Figure_11.jpeg new file mode 100644 index 000000000..bb8f9e03b Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_275_Figure_11.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_275_Figure_12.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_275_Figure_12.jpeg new file mode 100644 index 000000000..d4efdd850 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_275_Figure_12.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_276_Figure_7.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_276_Figure_7.jpeg new file mode 100644 index 000000000..b63eb81ca Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_276_Figure_7.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_276_Figure_8.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_276_Figure_8.jpeg new file mode 100644 index 000000000..4e98f5db0 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_276_Figure_8.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_297_Figure_6.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_297_Figure_6.jpeg new file mode 100644 index 000000000..ce5e4448b Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_297_Figure_6.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_29_Figure_7.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_29_Figure_7.jpeg new file mode 100644 index 000000000..48e819757 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_29_Figure_7.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_301_Figure_6.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_301_Figure_6.jpeg new file mode 100644 index 000000000..bb892342c Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_301_Figure_6.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_304_Figure_4.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_304_Figure_4.jpeg new file mode 100644 index 000000000..0bd8c0e6b Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_304_Figure_4.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_304_Figure_8.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_304_Figure_8.jpeg new file mode 100644 index 000000000..fc88529df Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_304_Figure_8.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_307_Figure_5.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_307_Figure_5.jpeg new file mode 100644 index 000000000..2d255be4c Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_307_Figure_5.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_34_Figure_7.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_34_Figure_7.jpeg new file mode 100644 index 000000000..87cb85995 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_34_Figure_7.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_35_Picture_3.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_35_Picture_3.jpeg new file mode 100644 index 000000000..b190e004f Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_35_Picture_3.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_59_Figure_4.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_59_Figure_4.jpeg new file mode 100644 index 000000000..3b37be569 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_59_Figure_4.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_69_Figure_6.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_69_Figure_6.jpeg new file mode 100644 index 000000000..a82bbb9a0 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_69_Figure_6.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_70_Figure_6.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_70_Figure_6.jpeg new file mode 100644 index 000000000..9eae11081 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_70_Figure_6.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_71_Figure_11.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_71_Figure_11.jpeg new file mode 100644 index 000000000..0eaf07ccb Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_71_Figure_11.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_71_Figure_9.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_71_Figure_9.jpeg new file mode 100644 index 000000000..fce43f9e2 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_71_Figure_9.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_72_Figure_7.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_72_Figure_7.jpeg new file mode 100644 index 000000000..d9df903ff Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_72_Figure_7.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_93_Figure_10.jpeg b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_93_Figure_10.jpeg new file mode 100644 index 000000000..780dafc26 Binary files /dev/null and b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/_page_93_Figure_10.jpeg differ diff --git a/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/pru_assembly_language_tools_users_guide_v2_3.md b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/pru_assembly_language_tools_users_guide_v2_3.md new file mode 100644 index 000000000..78feeb68d --- /dev/null +++ b/docs_ai/reference/pru_assembly_language_tools_users_guide_v2_3/pru_assembly_language_tools_users_guide_v2_3.md @@ -0,0 +1,12517 @@ +# Contents + +- Preface ........ 10 +- **1 Introduction to the Software Development Tools** ........ 13 + - 1.1 Software Development Tools Overview ........ 14 + - 1.2 Tools Descriptions ........ 15 +- **2 Introduction to Object Modules** ........ 16 + - 2.1 Object File Format Specification ........ 17 + - 2.2 Executable Object Files ........ 17 + - 2.3 Introduction to Sections ........ 17 + - 2.3.1 Special Section Names ........ 18 + - 2.4 How the Assembler Handles Sections ........ 18 + - 2.4.1 Uninitialized Sections ........ 19 + - 2.4.2 Initialized Sections ........ 19 + - 2.4.3 User-Named Sections ........ 20 + - 2.4.4 Current Section ........ 20 + - 2.4.5 Section Program Counters ........ 20 + - 2.4.6 Subsections ........ 21 + - 2.4.7 Using Sections Directives ........ 21 + - 2.5 How the Linker Handles Sections ........ 23 + - 2.5.1 Combining Input Sections ........ 24 + - 2.5.2 Placing Sections ........ 25 + - 2.6 Symbols ........ 25 + - 2.6.1 External Symbols ........ 25 + - 2.6.2 Weak Symbols ........ 26 + - 2.6.3 The Symbol Table ........ 27 + - 2.7 Symbolic Relocations ........ 27 + - 2.8 Loading a Program ........ 27 +- **3 Program Loading and Running** ........ 28 + - 3.1 Loading ........ 29 + - 3.1.1 Load and Run Addresses ........ 29 + - 3.1.2 Bootstrap Loading ........ 30 + - 3.2 Entry Point ........ 34 + - 3.3 Run-Time Initialization ........ 34 + - 3.3.1 The _c_int00 Function ........ 34 + - 3.3.2 Variable Initialization ........ 35 + - 3.3.3 Copy Tables ........ 37 + - 3.4 Arguments to main ........ 37 + - 3.5 Run-Time Relocation ........ 37 + - 3.6 Additional Information ........ 38 +- **4 Assembler Description** ........ 39 + - 4.1 Assembler Overview ........ 40 + - 4.2 The Assembler's Role in the Software Development Flow ........ 41 + - 4.3 Invoking the Assembler ........ 42 + - 4.4 Naming Alternate Directories for Assembler Input ........ 43 + - 4.4.1 Using the --include_path Assembler Option ........ 43 + - 4.4.2 Using the PRU_A_DIR Environment Variable ........ 44 + - 4.5 Source Statement Format ........ 45 + - 4.5.1 Label Field ........ 46 + - 4.5.2 Mnemonic Field ........ 46 + - 4.5.3 Operand Field ........ 46 + - 4.5.4 Comment Field ........ 47 + - 4.6 Literal Constants ........ 47 + - 4.6.1 Integer Literals ........ 47 + - 4.6.2 Character String Literals ........ 49 + - 4.6.3 Floating-Point Literals ........ 49 + - 4.7 Assembler Symbols ........ 49 + - 4.7.1 Identifiers ........ 50 + - 4.7.2 Labels ........ 50 + - 4.7.3 Local Labels ........ 50 + - 4.7.4 Symbolic Constants ........ 51 + - 4.7.5 Defining Symbolic Constants (--asm_define Option) ........ 52 + - 4.7.6 Predefined Symbolic Constants ........ 53 + - 4.7.7 Registers ........ 53 + - 4.7.8 Substitution Symbols ........ 53 + - 4.8 Expressions ........ 54 + - 4.8.1 Mathematical and Logical Operators ........ 55 + - 4.8.2 Relational Operators and Conditional Expressions ........ 56 + - 4.8.3 Well-Defined Expressions ........ 56 + - 4.8.4 Relocatable Symbols and Legal Expressions ........ 56 + - 4.8.5 Expression Examples ........ 57 + - 4.9 Built-in Functions and Operators ........ 58 + - 4.9.1 Built-In Math and Trigonometric Functions ........ 58 + - 4.10 Source Listings ........ 59 + - 4.11 Debugging Assembly Source ........ 61 + - 4.12 Cross-Reference Listings ........ 62 +- **5 Assembler Directives** ........ 63 + - 5.1 Directives Summary ........ 64 + - 5.2 Directives that Define Sections ........ 68 + - 5.3 Directives that Initialize Values ........ 69 + - 5.4 Directives that Perform Alignment and Reserve Space ........ 72 + - 5.5 Directives that Format the Output Listings ........ 73 + - 5.6 Directives that Reference Other Files ........ 74 + - 5.7 Directives that Enable Conditional Assembly ........ 75 + - 5.8 Directives that Define Union or Structure Types ........ 75 + - 5.9 Directives that Define Enumerated Types ........ 76 + - 5.10 Directives that Define Symbols at Assembly Time ........ 76 + - 5.11 Miscellaneous Directives ........ 77 + - 5.12 Directives Reference ........ 78 +- **6 Macro Language Description** ........ 136 + - 6.1 Using Macros ........ 137 + - 6.2 Defining Macros ........ 137 + - 6.3 Macro Parameters/Substitution Symbols ........ 139 + - 6.3.1 Directives That Define Substitution Symbols ........ 140 + - 6.3.2 Built-In Substitution Symbol Functions ........ 141 + - 6.3.3 Recursive Substitution Symbols ........ 142 + - 6.3.4 Forced Substitution ........ 142 + - 6.3.5 Accessing Individual Characters of Subscripted Substitution Symbols ........ 143 + - 6.3.6 Substitution Symbols as Local Variables in Macros ........ 144 + - 6.4 Macro Libraries ........ 145 + - 6.5 Using Conditional Assembly in Macros ........ 145 + - 6.6 Using Labels in Macros ........ 147 + - 6.7 Producing Messages in Macros ........ 148 + - 6.8 Using Directives to Format the Output Listing ........ 149 + - 6.9 Using Recursive and Nested Macros ........ 150 + - 6.10 Macro Directives Summary ........ 151 +- **7 Archiver Description** ........ 152 + - 7.1 Archiver Overview ........ 153 + - 7.2 The Archiver's Role in the Software Development Flow ........ 154 + - 7.3 Invoking the Archiver ........ 155 + - 7.4 Archiver Examples ........ 156 + - 7.5 Library Information Archiver Description ........ 157 + - 7.5.1 Invoking the Library Information Archiver ........ 157 + - 7.5.2 Library Information Archiver Example ........ 158 + - 7.5.3 Listing the Contents of an Index Library ........ 158 + - 7.5.4 Requirements ........ 158 +- **8 Linker Description** ........ 159 + - 8.1 Linker Overview ........ 160 + - 8.2 The Linker's Role in the Software Development Flow ........ 161 + - 8.3 Invoking the Linker ........ 162 + - 8.4 Linker Options ........ 163 + - 8.4.1 Wildcards in File, Section, and Symbol Patterns ........ 165 + - 8.4.2 Specifying C/C++ Symbols with Linker Options ........ 165 + - 8.4.3 Relocation Capabilities (--absolute_exe and --relocatable Options) ........ 165 + - 8.4.4 Allocate Memory for Use by the Loader to Pass Arguments (--arg_size Option) ........ 166 + - 8.4.5 Compression (--cinit_compression and --copy_compression Option) ........ 166 + - 8.4.6 Compress DWARF Information (--compress_dwarf Option) ........ 167 + - 8.4.7 Control Linker Diagnostics ........ 167 + - 8.4.8 Automatic Library Selection (--disable_auto_rts Option) ........ 168 + - 8.4.9 Do Not Remove Unused Sections (--unused_section_elimination Option) ........ 168 + - 8.4.10 Linker Command File Preprocessing (--disable_pp, --define and --undefine Options) ........ 168 + - 8.4.11 Error Correcting Code Testing (--ecc Options) ........ 169 + - 8.4.12 Define an Entry Point (--entry_point Option) ........ 170 + - 8.4.13 Set Default Fill Value (--fill_value Option) ........ 170 + - 8.4.14 Define Heap Size (--heap_size Option) ........ 171 + - 8.4.15 Hiding Symbols ........ 171 + - 8.4.16 Alter the Library Search Algorithm (--library Option, --search_path Option, and PRU_C_DIR Environment Variable) ........ 172 + - 8.4.17 Change Symbol Localization ........ 175 + - 8.4.18 Create a Map File (--map_file Option) ........ 176 + - 8.4.19 Managing Map File Contents (--mapfile_contents Option) ........ 177 + - 8.4.20 Disable Name Demangling (--no_demangle) ........ 178 + - 8.4.21 Merging of Symbolic Debugging Information ........ 178 + - 8.4.22 Strip Symbolic Information (--no_symtable Option) ........ 178 + - 8.4.23 Name an Output Module (--output_file Option) ........ 179 + - 8.4.24 Prioritizing Function Placement (--preferred_order Option) ........ 179 + - 8.4.25 C Language Options (--ram_model and --rom_model Options) ........ 179 + - 8.4.26 Retain Discarded Sections (--retain Option) ........ 179 + - 8.4.27 Create an Absolute Listing File (--run_abs Option) ........ 180 + - 8.4.28 Scan All Libraries for Duplicate Symbol Definitions (--scan_libraries) ........ 180 + - 8.4.29 Define Stack Size (--stack_size Option) ........ 180 + - 8.4.30 Enforce Strict Compatibility (--strict_compatibility Option) ........ 180 + - 8.4.31 Mapping of Symbols (--symbol_map Option) ........ 180 + - 8.4.32 Introduce an Unresolved Symbol (--undef_sym Option) ........ 181 + - 8.4.33 Display a Message When an Undefined Output Section Is Created (--warn_sections) ........ 181 + - 8.4.34 Generate XML Link Information File (--xml_link_info Option) ........ 181 + - 8.4.35 Zero Initialization (--zero_init Option) ........ 181 + - 8.5 Linker Command Files ........ 182 + - 8.5.1 Reserved Names in Linker Command Files ........ 183 + - 8.5.2 Constants in Linker Command Files ........ 183 + - 8.5.3 Accessing Files and Libraries from a Linker Command File ........ 183 + - 8.5.4 The MEMORY Directive ........ 185 + - 8.5.5 The SECTIONS Directive ........ 188 + - 8.5.6 Placing a Section at Different Load and Run Addresses ........ 200 + - 8.5.7 Using GROUP and UNION Statements ........ 202 + - 8.5.8 Special Section Types (DSECT, COPY, NOLOAD, and NOINIT) ........ 206 + - 8.5.9 Configuring Error Correcting Code (ECC) with the Linker ........ 206 + - 8.5.10 Assigning Symbols at Link Time ........ 209 + - 8.5.11 Creating and Filling Holes ........ 213 + - 8.6 Linker Symbols ........ 216 + - 8.6.1 Using Linker Symbols in C/C++ Applications ........ 216 + - 8.6.2 Declaring Weak Symbols ........ 217 + - 8.6.3 Resolving Symbols with Object Libraries ........ 217 + - 8.7 Default Placement Algorithm ........ 219 + - 8.7.1 How the Allocation Algorithm Creates Output Sections ........ 219 + - 8.7.2 Reducing Memory Fragmentation ........ 220 + - 8.8 Linker-Generated Copy Tables ........ 220 + - 8.8.1 Using Copy Tables for Boot Loading ........ 220 + - 8.8.2 Using Built-in Link Operators in Copy Tables ........ 221 + - 8.8.3 Overlay Management Example ........ 221 + - 8.8.4 Generating Copy Tables With the table() Operator ........ 222 + - 8.8.5 Compression ........ 227 + - 8.8.6 Copy Table Contents ........ 230 + - 8.8.7 General Purpose Copy Routine ........ 230 + - 8.9 Partial (Incremental) Linking ........ 231 + - 8.10 Linking C/C++ Code ........ 232 + - 8.10.1 Run-Time Initialization ........ 233 + - 8.10.2 Object Libraries and Run-Time Support ........ 233 + - 8.10.3 Setting the Size of the Stack and Heap Sections ........ 233 + - 8.10.4 Initializing and AutoInitialzing Variables at Run Time ........ 233 + - 8.11 Linker Example ........ 234 +- **9 Absolute Lister Description** ........ 237 + - 9.1 Producing an Absolute Listing ........ 238 + - 9.2 Invoking the Absolute Lister ........ 239 + - 9.3 Absolute Lister Example ........ 240 +- **10 Cross-Reference Lister Description** ........ 243 + - 10.1 Producing a Cross-Reference Listing ........ 244 + - 10.2 Invoking the Cross-Reference Lister ........ 245 + - 10.3 Cross-Reference Listing Example ........ 246 +- **11 Object File Utilities** ........ 248 + - 11.1 Invoking the Object File Display Utility ........ 249 + - 11.2 Invoking the Disassembler ........ 250 + - 11.3 Invoking the Name Utility ........ 252 + - 11.4 Invoking the Strip Utility ........ 253 +- **12 Hex Conversion Utility Description** ........ 254 + - 12.1 The Hex Conversion Utility's Role in the Software Development Flow ........ 255 + - 12.2 Invoking the Hex Conversion Utility ........ 256 + - 12.2.1 Invoking the Hex Conversion Utility From the Command Line ........ 256 + - 12.2.2 Invoking the Hex Conversion Utility With a Command File ........ 258 + - 12.3 Linking with an ARM Executable ........ 259 + - 12.4 Understanding Memory Widths ........ 259 + - 12.4.1 Target Width ........ 259 + - 12.4.2 Specifying the Memory Width ........ 260 + - 12.4.3 Partitioning Data Into Output Files ........ 260 + - 12.5 The ROMS Directive ........ 263 + - 12.5.1 When to Use the ROMS Directive ........ 264 + - 12.5.2 An Example of the ROMS Directive ........ 264 + - 12.6 The SECTIONS Directive ........ 266 + - 12.7 The Load Image Format (--load_image Option) ........ 267 + - 12.7.1 Load Image Section Formation ........ 267 + - 12.7.2 Load Image Characteristics ........ 267 + - 12.8 Excluding a Specified Section ........ 268 + - 12.9 Assigning Output Filenames ........ 268 + - 12.10 Image Mode and the --fill Option ........ 269 + - 12.10.1 Generating a Memory Image ........ 269 + - 12.10.2 Specifying a Fill Value ........ 270 + - 12.10.3 Steps to Follow in Using Image Mode ........ 270 + - 12.11 Array Output Format ........ 270 + - 12.12 Controlling the ROM Device Address ........ 271 + - 12.13 Control Hex Conversion Utility Diagnostics ........ 272 + - 12.14 Description of the Object Formats ........ 273 + - 12.14.1 ASCII-Hex Object Format (--ascii Option) ........ 273 + - 12.14.2 Intel MCS-86 Object Format (--intel Option) ........ 274 + - 12.14.3 Motorola Exorciser Object Format (--motorola Option) ........ 275 + - 12.14.4 Extended Tektronix Object Format (--tektronix Option) ........ 276 + - 12.14.5 Texas Instruments SDSMAC (TI-Tagged) Object Format (--ti_tagged Option) ........ 277 + - 12.14.6 TI-TXT Hex Format (--ti_txt Option) ........ 278 +- **13 Sharing C/C++ Header Files With Assembly Source** ........ 279 + - 13.1 Overview of the .cdecls Directive ........ 280 + - 13.2 Notes on C/C++ Conversions ........ 280 + - 13.2.1 Comments ........ 280 + - 13.2.2 Conditional Compilation (#if/#else/#ifdef/etc.) ........ 281 + - 13.2.3 Pragmas ........ 281 + - 13.2.4 The #error and #warning Directives ........ 281 + - 13.2.5 Predefined symbol __ASM_HEADER__ ........ 281 + - 13.2.6 Usage Within C/C++ asm( ) Statements ........ 281 + - 13.2.7 The #include Directive ........ 281 + - 13.2.8 Conversion of #define Macros ........ 281 + - 13.2.9 The #undef Directive ........ 282 + - 13.2.10 Enumerations ........ 282 + - 13.2.11 C Strings ........ 282 + - 13.2.12 C/C++ Built-In Functions ........ 283 + - 13.2.13 Structures and Unions ........ 283 + - 13.2.14 Function/Variable Prototypes ........ 283 + - 13.2.15 C Constant Suffixes ........ 284 + - 13.2.16 Basic C/C++ Types ........ 284 + - 13.3 Notes on C++ Specific Conversions ........ 284 + - 13.3.1 Name Mangling ........ 284 + - 13.3.2 Derived Classes ........ 284 + - 13.3.3 Templates ........ 285 + - 13.3.4 Virtual Functions ........ 285 + - 13.4 Special Assembler Support ........ 285 + - 13.4.1 Enumerations (.enum/.emember/.endenum) ........ 285 + - 13.4.2 The .define Directive ........ 285 + - 13.4.3 The .undefine/.unasg Directives ........ 285 + - 13.4.4 The $defined( ) Built-In Function ........ 286 + - 13.4.5 The $sizeof Built-In Function ........ 286 + - 13.4.6 Structure/Union Alignment and $alignof() ........ 286 + - 13.4.7 The .cstring Directive ........ 286 +- **A Symbolic Debugging Directives** ........ 287 + - A.1 DWARF Debugging Format ........ 288 + - A.2 Debug Directive Syntax ........ 288 +- **B XML Link Information File Description** ........ 289 + - B.1 XML Information File Element Types ........ 290 + - B.2 Document Elements ........ 290 + - B.2.1 Header Elements ........ 290 + - B.2.2 Input File List ........ 291 + - B.2.3 Object Component List ........ 292 + - B.2.4 Logical Group List ........ 293 + - B.2.5 Placement Map ........ 295 + - B.2.6 Symbol Table ........ 296 +- **C Hex Conversion Utility Examples** ........ 297 + - C.1 Scenario 1: Building a Hex Conversion Command File for a Single 8-Bit EPROM ........ 298 + - C.2 Scenario 2: Building a Hex Conversion Command File for 16-BIS Code ........ 302 + - C.3 Scenario 3: Building a Hex Conversion Command File for Two 8-Bit EPROMs ........ 305 +- **D Glossary** ........ 309 + - D.1 Terminology ........ 309 +- **E Revision History** ........ 314 + - E.1 Recent Revisions ........ 314 + +# List of Figures + +| 1-1. | PRU Software Development Flow | 14 | +|--------|-----------------------------------------------------------------|------------| +| 2-1. | Partitioning Memory Into Logical Blocks | 18 | +| 2-2. | Using Sections Directives Example | 22 | +| 2-3. | Object Code Generated by the File in | 23 | +| 2-4. | Combining Input Sections to Form an Executable Object Module | 24 | +| 3-1. | Bootloading Sequence (Simplified) | 30 | +| 3-2. | Bootloading Sequence with Secondary Bootloader | 31 | +| 3-3. | ROM-Based Variable Initialization Via cinit | 35 | +| 3-4. | The .cinit Section | 36 | +| 4-1. | The Assembler in the PRU Software Development Flow | 41 | +| 4-2. | Example Assembler Listing | 60 | +| 5-1. | The .field Directive | 70 | +| 5-2. | Initialization Directives | 71 | +| 5-3. | The .align Directive | 72 | +| 5-4. | The .space and .bes Directives | 73 | +| 5-5. | Double-Precision Floating-Point Format | 94 | +| 5-6. | The .field Directive | 101 | +| 5-7. | Single-Precision Floating-Point Format | 102 | +| 5-8. | The .usect Directive | 134 | +| 7-1. | The Archiver in the PRU Software Development Flow | 154 | +| 8-1. | The Linker in the PRU Software Development Flow | 161 | +| 8-2. | Section Placement Defined by | 190 | +| 8-3. | Memory Allocation Shown in and | 203 | +| 8-4. | Compressed Copy Table | 227 | +| 8-5. | Handler Table | 228 | +| 9-1. | Absolute Lister Development Flow | 238 | +| 10-1. | The Cross-Reference Lister Development Flow | 244 | +| 12-1. | The Hex Conversion Utility in the PRU Software Development Flow | 255 | +| 12-2. | Hex Conversion Utility Process Flow | 259 | +| 12-3. | Object File Data and Memory Widths | 260 | +| 12-4. | Data, Memory, and ROM Widths | 262 | +| 12-5. | The infile.out File Partitioned Into Four Output Files | 265 | +| 12-6. | ASCII-Hex Object Format | 273 | +| 12-7. | Intel Hexadecimal Object Format | 274 | +| 12-8. | Motorola-S Format | 275 | +| 12-9. | Extended Tektronix Object Format | 276 | +| 12-10. | TI-Tagged Object Format | 277 | +| 12-11. | TI-TXT Object Format | 278 | +| C-1. | EPROM Memory System for Scenario 1 | 298 | +| C-2. | Contents of Hex Output File example1.hex | 301 | +| C-3. | EPROM Memory System for Scenario 2 | 302 | +| C-4. | Contents of Hex Output File example2.hex | 305 | +| C-5. | EPROM Memory System for Scenario 3 | 305 | +| C-6. | Contents of Hex Output File | 308 | + +# List of Tables + +| 4-1. | PRU Assembler Options | 42 | +|-------|------------------------------------------------------|-----| +| 4-2. | PRU Processor Symbolic Constants | 53 | +| 4-3. | Operators Used in Expressions (Precedence) | 55 | +| 4-4. | Expressions With Absolute and Relocatable Symbols | 56 | +| 4-5. | Built-In Mathematical Functions | 58 | +| 4-6. | Symbol Attributes | 62 | +| 5-1. | Directives that Control Section Use | 64 | +| 5-2. | Directives that Affect Unused Section Elimination | 64 | +| 5-3. | Directives that Initialize Values (Data and Memory) | 64 | +| 5-4. | Directives that Perform Alignment and Reserve Space | 65 | +| 5-5. | Directives that Format the Output Listing | 65 | +| 5-6. | Directives that Reference Other Files | 65 | +| 5-7. | Directives that Affect Symbol Linkage and Visibility | 66 | +| 5-8. | Directives that Enable Conditional Assembly | 66 | +| 5-9. | Directives that Define Structure Types | 66 | +| 5-10. | Directives that Define Symbols | 66 | +| 5-11. | Directives that Create or Affect Macros | 67 | +| 5-12. | Directives that Control Diagnostics | 67 | +| 5-13. | Directives that Perform Assembly Source Debug | 67 | +| 5-14. | Directives that Are Used by the Absolute Lister | 67 | +| 5-15. | Directives that Perform Miscellaneous Functions | 67 | +| 6-1. | Substitution Symbol Functions and Return Values | 141 | +| 6-2. | Creating Macros | 151 | +| 6-3. | Manipulating Substitution Symbols | 151 | +| 6-4. | Conditional Assembly | 151 | +| 6-5. | Producing Assembly-Time Messages | 151 | +| 6-6. | Formatting the Listing | 151 | +| 8-1. | Basic Options Summary | 163 | +| 8-2. | File Search Path Options Summary | 163 | +| 8-3. | Command File Preprocessing Options Summary | 163 | +| 8-4. | Diagnostic Options Summary | 163 | +| 8-5. | Linker Output Options Summary | 164 | +| 8-6. | Symbol Management Options Summary | 164 | +| 8-7. | Run-Time Environment Options Summary | 164 | +| 8-8. | Link-Time Optimization Options Summary | 164 | +| 8-9. | Miscellaneous Options Summary | 165 | +| 8-10. | Predefined PRU Macro Names | 169 | +| 8-11. | Groups of Operators Used in Expressions (Precedence) | 210 | +| 10-1. | Symbol Attributes in Cross-Reference Listing | 246 | +| 12-1. | Basic Hex Conversion Utility Options | 256 | +| 12-2. | Options for Specifying Hex Conversion Formats | 273 | +| A-1. | Symbolic Debugging Directives | 288 | + +# Read This First + +## About This Manual + +The *PRU Assembly Language Tools User's Guide* explains how to use the following Texas Instruments Code Generation object file tools: + +- Assembler +- Archiver +- Linker +- Library information archiver +- Absolute lister +- Cross-reference lister +- Disassembler +- Object file display utility +- Name utility +- Strip utility +- Hex conversion utility + +## How to Use This Manual + +This book helps you learn how to use the Texas Instruments object file and assembly language tools designed specifically for the PRU 32-bit devices. This book consists of four parts: + +- **Introductory information**, consisting of Chapter 1 through Chapter 3, gives you an overview of the object file and assembly language development tools. Chapter 2, in particular, explains object modules and how they can be managed to help your PRU application load and run. It is highly recommended that developers become familiar with what object modules are and how they are used before using the assembler and linker. +- **Assembler description**, consisting of Chapter 4 through Chapter 6, contains detailed information about using the assembler. Chapter 4 and Chapter 5 explain how to invoke the assembler and discuss source statement format, valid constants and expressions, assembler output, and assembler directives. Chapter 6 focuses on the macro language. +- **Linker and other object file tools description**, consisting of Chapter 7 through Chapter 12, describes in detail each of the tools provided with the assembler to help you create executable object files. Chapter 7 provides details about using the archiver to create object libraries. Chapter 8 explains how to invoke the linker, how the linker operates, and how to use linker directives. Chapter 11 provides a brief overview of some of the object file utilities that can be useful in examining the content of object files as well as removing symbol and debug information to reduce the size of a given object file. Chapter 12 explains how to use the hex conversion utility. +- **Additional Reference material**, consisting of Appendix A through Appendix D, provides supplementary information including symbolic debugging directives used by the PRU C/C++ compiler. It also provides hex utility examples. A description of the XML link information file and a glossary are also provided. + +## Notational Conventions + +This document uses the following conventions: + +• Program listings, program examples, and interactive displays are shown in a special typeface. Interactive displays use a bold version of the special typeface to distinguish commands that you enter from items that the system displays (such as prompts, command output, error messages, etc.). + +Here is a sample of C code: + +``` +#include +main() +{ printf("hello world\n"); +} +``` + +- In syntax descriptions, the instruction, command, or directive is in a **bold typeface** and parameters are in an *italic typeface*. Portions of a syntax that are in bold should be entered as shown; portions of a syntax that are in italics describe the type of information that should be entered. +- Square brackets ( [ and ] ) identify an optional parameter. If you use an optional parameter, you specify the information within the brackets. Unless the square brackets are in the **bold typeface**, do not enter the brackets themselves. The following is an example of a command that has an optional parameter: + +``` +clpru [options] [filenames] [--run_linker [link_options] [object files]] +``` + +• Braces ( { and } ) indicate that you must choose one of the parameters within the braces; you do not enter the braces themselves. This is an example of a command with braces that are not included in the actual syntax but indicate that you must specify either the --rom\_model or --ram\_model option: + +``` +clpru --run_linker {--rom_model | --ram_model} filenames [--output_file= name.out] + --library= libraryname +``` + +• In assembler syntax statements, The leftmost character position, column 1, is reserved for the first character of a label or symbol. If the label or symbol is optional, it is usually not shown. If it is a required parameter, it is shown starting against the left margin of the box, as in the example below. No instruction, command, directive, or parameter, other than a symbol or label, can begin in column 1. + +``` +symbol .usect "section name", size in bytes[, alignment] +``` + +• Some directives can have a varying number of parameters. For example, the .byte directive can have multiple parameters. This syntax is shown as [, ..., *parameter*]. + +``` +.byte parameter1[, ... , parametern] +``` + +• Other symbols and abbreviations used throughout this document include the following: + +| Symbol | Definition | +|--------|------------------------------| +| B,b | Suffix — binary integer | +| H, h | Suffix — hexadecimal integer | +| LSB | Least significant bit | +| MSB | Most significant bit | +| 0x | Prefix — hexadecimal integer | +| Q, q | Suffix — octal integer | + +### Related Documentation From Texas Instruments + +See the following resources for further information about the TI Code Generation Tools: + +- Texas Instruments Wiki: [Compiler](http://processors.wiki.ti.com/index.php/Category:Compiler) topics +- Texas Instruments E2E Community: [Compiler](http://e2e.ti.com/support/development_tools/compiler/f/343) forum + +You can use the following books to supplement this user's guide: + +**[SPRUHV7](http://www.ti.com/lit/pdf/spruhv7) —PRU Optimizing C/C++ Compiler User's Guide.** Describes the PRU C/C++ compiler. This C/C++ compiler accepts ANSI standard C/C++ source code and produces assembly language source code for the PRU device. + +**Texas [Instruments](http://processors.wiki.ti.com/index.php/Programmable_Realtime_Unit_Software_Development) Wiki —Programmable Realtime Unit Software Development.** Provides information about software development for the PRU device and Programmable Realtime Unit SubSystem (PRUSS). + +#### Trademarks + +All trademarks are the property of their respective owners. + +# 1 Introduction to the Software Development Tools + +The PRU is supported by a set of software development tools, which includes an optimizing C/C++ compiler, an assembler, a linker, and assorted utilities. This chapter provides an overview of these tools. + +The PRU is supported by the following assembly language development tools: + +- Assembler +- Archiver +- Linker +- Library information archiver +- Absolute lister +- Cross-reference lister +- Object file display utility +- Disassembler +- Name utility +- Strip utility +- Hex conversion utility + +This chapter shows how these tools fit into the general software tools development flow and gives a brief description of each tool. For convenience, it also summarizes the C/C++ compiler and debugging tools. For detailed information on the compiler and debugger, and for complete descriptions of the PRU, refer to the books listed in *Related Documentation From Texas Instruments*. + +**Topic** ........................................................................................................................... **Page** + +| 1.1 | Software Development Tools Overview | 14 | +|-----|-------------------------------------|----| +| 1.2 | Tools Descriptions | 15 | + +## 1.1 Software Development Tools Overview + +Figure 1-1 shows the PRU software development flow. The shaded portion highlights the most common development path; the other portions are optional. The other portions are peripheral functions that enhance the development process. + +**Figure 1-1. PRU Software Development Flow** + +## 1.2 Tools Descriptions + +The following list describes the tools that are shown in Figure 1-1: + +- The **C/C++ compiler** accepts C/C++ source code and produces PRU machine code object modules. See the *PRU Optimizing C/C++ Compiler User's Guide* for more information. A **shell program**, an **optimizer**, and an **interlist utility** are included in the installation: + - The shell program enables you to compile, assemble, and link source modules in one step. + - The optimizer modifies code to improve the efficiency of C/C++ programs. + - The interlist utility interlists C/C++ source statements with assembly language output to correlate code produced by the compiler with your source code. +- The **assembler** translates assembly language source files into machine language object modules. Source files can contain instructions, assembler directives, and macro directives. You can use assembler directives to control the assembly process, including the source listing format, data alignment, and section content. See Chapter 4 through Chapter 6. +- The **linker** combines object files into a single object module. It performs symbolic relocation and resolves external references. The linker accepts relocatable object modules (created by the assembler) as input. It also accepts archiver library members and output modules created by a previous linker run. Link directives allow you to combine object file sections, bind sections or symbols to addresses or within memory ranges, and define global symbols. See Chapter 8. +- The **archiver** allows you to collect a group of files into a single archive file, called a library. The most common use of the archiver is to collect a group of object files into an object library. The linker extracts object library members to resolve external references during the link. You can also use the archiver to collect several macros into a macro library. The assembler searches the library and uses the members that are called as macros by the source file. The archiver allows you to modify a library by deleting, replacing, extracting, or adding members. See Section 7.1. +- The **library information archiver** allows you to create an index library of several object file library variants, which is useful when several variants of a library with different options are available. Rather than refer to a specific library, you can link against the index library, and the linker will choose the best match from the indexed libraries. See Section 7.5 for more information about using the archiver to manage the content of a library. +- You can use the **library-build utility** to build your own customized run-time-support library. See the *PRU Optimizing C/C++ Compiler User's Guide* for more information. +- The **hex conversion utility** converts object files to TI-Tagged, ASCII-Hex, Intel, Motorola-S, or Tektronix object format. Converted files can be downloaded to an EPROM programmer. See Chapter 12. +- The **absolute lister** uses linked object files to create .abs files. These files can be assembled to produce a listing of the absolute addresses of object code. See Chapter 9. +- The **cross-reference lister** uses object files to produce a cross-reference listing showing symbols, their definition, and their references in the linked source files. See Chapter 10. +- The main product of this development process is a executable object file that can be executed on a **PRU** device. You can use one of several debugging tools to refine and correct your code. Available products include: + - An XDS emulator + +In addition, the following utilities are provided to help examine or manage the content of a given object file: + +- The **object file display utility** prints the contents of object files and object libraries in either human readable or XML formats. See Section 11.1. +- The **disassembler** decodes the machine code from object modules to show the assembly instructions that it represents. See Section 11.2. +- The **name utility** prints a list of symbol names for objects and functions defined or referenced in an object file or object archive. See Section 11.3. +- The **strip utility** removes symbol table and debugging information from object files and object libraries. See Section 11.4. + +# 2 Introduction to Object Modules + +The assembler creates object modules from assembly code, and the linker creates executable object files from object modules. These executable object files can be executed by a PRU device. + +Object modules make modular programming easier because they encourage you to think in terms of *blocks* of code and data when you write an assembly language program. These blocks are known as sections. Both the assembler and the linker provide directives that allow you to create and manipulate sections. + +This chapter focuses on the concept and use of sections in assembly language programs. + +**Topic** ........................................................................................................................... **Page** + +| 2.1 | Object File Format Specification | 17 | +|-----|------------------------------------|----| +| 2.2 | Executable Object Files | 17 | +| 2.3 | Introduction to Sections | 17 | +| 2.4 | How the Assembler Handles Sections | 18 | +| 2.5 | How the Linker Handles Sections | 23 | +| 2.6 | Symbols | 25 | +| 2.7 | Symbolic Relocations | 27 | +| 2.8 | Loading a Program | 27 | +| | | | + +## 2.1 Object File Format Specification + +The object files created by the assembler and linker conform to the ELF (Executable and Linking Format) binary format. The ELF object files generated by the assembler and linker conform to the December 17, 2003 snapshot of the [System](http://sco.com/developers/gabi/) V generic ABI (or gABI). This specification is currently maintained by SCO. + +## 2.2 Executable Object Files + +The linker produces executable object modules. An executable object module has the same format as object files that are used as linker input. The sections in an executable object module, however, have been combined and placed in target memory, and the relocations are all resolved. + +To run a program, the data in the executable object module must be transferred, or loaded, into target system memory. See Chapter 3 for details about loading and running programs. + +## 2.3 Introduction to Sections + +The smallest unit of an object file is a *section*. A section is a block of code or data that occupies contiguous space in the memory map. Each section of an object file is separate and distinct. + +ELF format executable object files contain *segments*. An ELF segment is a meta-section. It represents a contiguous region of target memory. It is a collection of *sections* that have the same property, such as writeable or readable. An ELF loader needs the segment information, but does not need the section information. The ELF standard allows the linker to omit ELF section information entirely from the executable object file. + +Object files usually contain three default sections: + +| | | +|---|---| +| **.text section** | Contains executable code (1) | +| **.data section** | Usually contains initialized data | +| **.bss section** | Usually reserves space for uninitialized variables | + +The assembler and linker allow you to create, name, and link other kinds of sections. The .text, .data, and .bss sections are archetypes for how sections are handled. + +There are two basic types of sections: + +| | | +|---|---| +| **Initialized sections** | Contain data or code. The .text and .data sections are initialized; user-named sections created with the .sect assembler directive are also initialized. | +| **Uninitialized sections** | Reserve space in the memory map for uninitialized data. The .bss section is uninitialized; user-named sections created with the .usect assembler directive are also uninitialized. | + +Several assembler directives allow you to associate various portions of code and data with the appropriate sections. The assembler builds these sections during the assembly process, creating an object file organized as shown in Figure 2-1. + +One of the linker's functions is to relocate sections into the target system's memory map; this function is called *placement*. Because most systems contain several types of memory, using sections can help you use target memory more efficiently. All sections are independently relocatable; you can place any section into any allocated block of target memory. For example, you can define a section that contains an initialization routine and then allocate the routine in a portion of the memory map that contains ROM. For information on section placement, see the "Specifying Where to Allocate Sections in Memory" section of the *PRU Optimizing C/C++ Compiler User's Guide*. + +(1) Some targets allow content other than text, such as constants, in .text sections. + +Figure 2-1 shows the relationship between sections in an object file and a hypothetical target memory. + +**Figure 2-1. Partitioning Memory Into Logical Blocks** + +![Figure 2-1: Partitioning Memory Into Logical Blocks — diagram showing object file sections mapping to target memory regions](_page_17_Figure_4.jpeg) + +**Figure 2-1: Partitioning Memory Into Logical Blocks.** Diagram showing three sections of an object file (.bss, .data, .text, stacked top to bottom) mapped by arrows to three regions of target memory (RAM, EEPROM, ROM respectively). The .bss section maps to RAM, .data maps to EEPROM, and .text maps to ROM. + +### 2.3.1 Special Section Names + +You can use the .sect and .usect directives to create any section name you like, but certain sections are treated in a special manner by the linker and the compiler's run-time support library. If you create a section with the same name as a special section, you should take care to follow the rules for that special section. + +A few common special sections are: + +- .text -- Used for program code. +- .bss -- Used for uninitialized objects (global variables). +- .data -- Used for initialized non-const objects (global variables). +- .const -- Used for initialized const objects (string constants, variables declared const). +- .cinit -- Used to initialize C global variables at startup. +- .stack -- Used for the function call stack. +- .sysmem - Used for the dynamic memory allocation pool. + +For more information on sections, see the "Specifying Where to Allocate Sections in Memory" section of the *PRU Optimizing C/C++ Compiler User's Guide*. + +## 2.4 How the Assembler Handles Sections + +The assembler identifies the portions of an assembly language program that belong in a given section. The assembler has the following directives that support this function: + +- .bss +- .data +- .sect +- .text +- .usect + +The .bss and .usect directives create *uninitialized sections*; the .text, .data, and .sect directives create *initialized sections*. + +You can create subsections of any section to give you tighter control of the memory map. Subsections are created using the .sect and .usect directives. Subsections are identified with the base section name and a subsection name separated by a colon; see Section 2.4.6. + +#### Default Sections Directive + +**NOTE:** If you do not use any of the sections directives, the assembler assembles everything into the .text section. + +### 2.4.1 Uninitialized Sections + +Uninitialized sections reserve space in PRU memory; they are usually placed in RAM. These sections have no actual contents in the object file; they simply reserve memory. A program can use this space at run time for creating and storing variables. + +Uninitialized data areas are built by using the following assembler directives. + +- The .bss directive reserves space in the .bss section. +- The .usect directive reserves space in a specific uninitialized user-named section. + +Each time you invoke the .bss or .usect directive, the assembler reserves additional space in the .bss or the user-named section. The syntax is: + +| | .bss symbol, size in bytes[, alignment [, bank offset] ] | +|--------|-------------------------------------------------------------------| +| symbol | .usect "section name", size in bytes[, alignment[, bank offset] ] | +| | | + +| symbol | points to the first byte reserved by this invocation of the .bss or .usect directive. The
symbol corresponds to the name of the variable that you are reserving space for. It can
be referenced by any other section and can also be declared as a global symbol (with
the .global directive). | +|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| size in bytes | is an absolute expression (see Section 4.8). The .bss directive reserves size in bytes
bytes in the .bss section. The .usect directive reserves size in bytes bytes in section
name. For both directives, you must specify a size; there is no default value. | +| alignment | is an optional parameter. It specifies the minimum alignment in bytes required by the
space allocated. The default value is byte aligned; this option is represented by the
value 1. The value must be a power of 2. | +| bank offset | is an optional parameter. It ensures that the space allocated to the symbol occurs on a
specific memory bank boundary. The bank offset measures the number of bytes to
offset from the alignment specified before assigning the symbol to that location. | +| section name | specifies the user-named section in which to reserve space. See Section 2.4.3. | + +Initialized section directives (.text, .data, and .sect) change which section is considered the *current* section (see Section 2.4.2). However, the .bss and .usect directives *do not* change the current section; they simply escape from the current section temporarily. Immediately after a .bss or .usect directive, the assembler resumes assembling into whatever the current section was before the directive. The .bss and .usect directives can appear anywhere in an initialized section without affecting its contents. + +The .usect directive can also be used to create uninitialized subsections. See Section 2.4.6 for more information on creating subsections. + +### 2.4.2 Initialized Sections + +Initialized sections contain executable code or initialized data. The contents of these sections are stored in the object file and placed in PRU memory when the program is loaded. Each initialized section is independently relocatable and may reference symbols that are defined in other sections. The linker automatically resolves these references. The following directives tell the assembler to place code or data into a section. The syntaxes for these directives are: + +![Syntax box showing the three initialized-section directives: .text, .data, and .sect "section name"](_page_18_Figure_15.jpeg) + +**Initialized sections syntax.** Code syntax box showing the three directives that create initialized sections: `.text`, `.data`, and `.sect "section name"`. + +The .sect directive can also be used to create initialized subsections. See Section 2.4.6, for more information on creating subsections. + +### 2.4.3 User-Named Sections + +User-named sections are sections that *you* create. You can use them like the default .text, .data, and .bss sections, but each section with a distinct name is kept distinct during assembly. + +For example, repeated use of the .text directive builds up a single .text section in the object file. This .text section is allocated in memory as a single unit. Suppose there is a portion of executable code (perhaps an initialization routine) that you want the linker to place in a different location than the rest of .text. If you assemble this segment of code into a user-named section, it is assembled separately from .text, and you can use the linker to allocate it into memory separately. You can also assemble initialized data that is separate from the .data section, and you can reserve space for uninitialized variables that is separate from the .bss section. + +These directives let you create user-named sections: + +- The **.usect** directive creates uninitialized sections that are used like the .bss section. These sections reserve space in RAM for variables. +- The **.sect** directive creates initialized sections, like the default .text and .data sections, that can contain code or data. The .sect directive creates user-named sections with relocatable addresses. + +The syntaxes for these directives are: + +``` +symbol .usect "section name", size in bytes[, alignment[, bank offset]] + .sect "section name" +``` + +The maximum number of sections is 232-1 (4294967295). + +The *section name* parameter is the name of the section. For the .usect and .sect directives, a section name can refer to a subsection; see Section 2.4.6 for details. + +Each time you invoke one of these directives with a new name, you create a new user-named section. Each time you invoke one of these directives with a name that was already used, the assembler resumes assembling code or data (or reserves space) into the section with that name. *You cannot use the same names with different directives*. That is, you cannot create a section with the .usect directive and then try to use the same section with .sect. + +### 2.4.4 Current Section + +The assembler adds code or data to one section at a time. The section the assembler is currently filling is the *current section*. The .text, .data, and .sect directives change which section is considered the current section. When the assembler encounters one of these directives, it stops assembling into the current section (acting as an implied end of current section command). The assembler sets the designated section as the current section and assembles subsequent code into the designated section until it encounters another .text, .data, or .sect directive. + +If one of these directives sets the current section to a section that already has code or data in it from earlier in the file, the assembler resumes adding to the end of that section. The assembler generates only one contiguous section for each given section name. This section is formed by concatenating all of the code or data which was placed in that section. + +### 2.4.5 Section Program Counters + +The assembler maintains a separate program counter for each section. These program counters are known as *section program counters*, or *SPCs*. + +An SPC represents the current address within a section of code or data. Initially, the assembler sets each SPC to 0. As the assembler fills a section with code or data, it increments the appropriate SPC. If you resume assembling into a section, the assembler remembers the appropriate SPC's previous value and continues incrementing the SPC from that value. + +The assembler treats each section as if it began at address 0; the linker relocates the symbols in each section according to the final address of the section in which that symbol is defined. See Section 2.7 for information on relocation. + +### 2.4.6 Subsections + +A subsection is created by creating a section with a colon in its name. Subsections are logical subdivisions of larger sections. Subsections are themselves sections and can be manipulated by the assembler and linker. + +The assembler has no concept of subsections; to the assembler, the colon in the name is not special. The subsection .text:rts would be considered completely unrelated to its parent section .text, and the assembler will not combine subsections with their parent sections. + +Subsections are used to keep parts of a section as distinct sections so that they can be separately manipulated. For instance, by placing each function and object in a uniquely-named subsection, the linker gets a finer-grained view of the section for memory placement and unused-function elimination. + +By default, when the linker sees a SECTION directive in the linker command file like ".text", it will gather .text and all subsections of .text into one large output section named ".text". You can instead use the SECTION directive to control the subsection independently. See Section 8.5.5.1 for an example. + +You can create subsections in the same way you create other user-named sections: by using the .sect or .usect directive. + +The syntaxes for a subsection name are: + +``` +symbol .usect "section_name:subsection_name",size in bytes[, alignment[, bank offset] ] + .sect "section_name:subsection_name" +``` + +A subsection is identified by the base section name followed by a colon and the name of the subsection. The subsection name may not contain any spaces. + +A subsection can be allocated separately or grouped with other sections using the same base name. For example, you create a subsection called \_func within the .text section: + +``` +.sect ".text:_func" +``` + +Using the linker's SECTIONS directive, you can allocate .text:\_func separately, or with all the .text sections. + +You can create two types of subsections: + +- Initialized subsections are created using the .sect directive. See Section 2.4.2. +- Uninitialized subsections are created using the .usect directive. See Section 2.4.1. + +Subsections are placed in the same manner as sections. See Section 8.5.5 for information on the SECTIONS directive. + +### 2.4.7 Using Sections Directives + +Figure 2-2 shows how you can build sections incrementally, using the sections directives to swap back and forth between the different sections. You can use sections directives to begin assembling into a section for the first time, or to continue assembling into a section that already contains code. In the latter case, the assembler simply appends the new code to the code that is already in the section. + +The format in Figure 2-2 is a listing file. Figure 2-2 shows how the SPCs are modified during assembly. A line in a listing file has four fields: + +- **Field 1** contains the source code line counter. +- **Field 2** contains the section program counter. +- **Field 3** contains the object code. +- **Field 4** contains the original source statement. + +See Section 4.10 for more information on interpreting the fields in a source listing. + +**Figure 2-2. Using Sections Directives Example** + +As Figure 2-3 shows, the file in Figure 2-2 creates the following sections: + +| | | +|---|---| +| **.text** | contains six 32-bit words of object code. | +| **.data** | contains seven words of initialized data. | +| **.bss** | reserves ten bytes in memory. | +| **newvars** | is a user-named section created with the .usect directive; it reserves eight bytes in memory. | + +The second column shows the object code that is assembled into these sections; the first column shows the source statements that generated the object code. + +**Figure 2-3. Object Code Generated by the File in Figure 2-2** + +| Line numbers | Object code | Section | +|-------------------------------------|----------------------------------------------------------------------------------|---------| +| 19
20
21
36
37
38 | 2404D2E1
0501E1E1
6F00E1FF
240D80E3
0501E3E3
6F00E3FF | .text | +| 5
5
5
14
26
26
26 | 00000011
00000022
00000033
00000123
000000AA
000000BB
000000CC | .data | +| 10 | No data -
ten bytes
reserved | .bss | +| 30
31 | No data -
eight bytes
reserved | newvars | + +## 2.5 How the Linker Handles Sections + +The linker has two main functions related to sections. First, the linker uses the sections in object files as building blocks; it combines input sections to create output sections in an executable output module. Second, the linker chooses memory addresses for the output sections; this is called *placement*. Two linker directives support these functions: + +- The *MEMORY* directive allows you to define the memory map of a target system. You can name portions of memory and specify their starting addresses and their lengths. +- The *SECTIONS* directive tells the linker how to combine input sections into output sections and where to place these output sections in memory. + +Subsections let you manipulate the placement of sections with greater precision. You can specify the location of each subsection with the linker's SECTIONS directive. If you do not specify a subsection, the subsection is combined with the other sections with the same base section name. See Section 8.5.5.1. + +It is not always necessary to use linker directives. If you do not use them, the linker uses the target processor's default placement algorithm described in Section 8.7. When you *do* use linker directives, you must specify them in a linker command file. + +Refer to the following sections for more information about linker command files and linker directives: + +- Section 8.5, *Linker Command Files* +- Section 8.5.4, *The MEMORY Directive* +- Section 8.5.5, *The SECTIONS Directive* +- Section 8.7, *Default Placement Algorithm* + +### 2.5.1 Combining Input Sections + +Figure 2-4 provides a simplified example of the process of linking two files together. + +Note that this is a simplified example, so it does not show all the sections that will be created or the actual sequence of the sections. See Section 8.7 for the actual default memory placement map for PRU. + +**Figure 2-4. Combining Input Sections to Form an Executable Object Module** + +In Figure 2-4, file1.obj and file2.obj have been assembled to be used as linker input. Each contains the .text, .data, and .bss default sections; in addition, each contains a user-named section. The executable object module shows the combined sections. The linker combines the .text section from file1.obj and the .text section from file2.obj to form one .text section, then combines the two .data sections and the two .bss sections, and finally places the user-named sections at the end. The memory map shows the combined sections to be placed into memory. + +### 2.5.2 Placing Sections + +Figure 2-4 illustrates the linker's default method for combining sections. Sometimes you may not want to use the default setup. For example, you may not want all of the .text sections to be combined into a single .text section. Or you may want a user-named section placed where the .data section would normally be allocated. Most memory maps contain various types of memory (RAM, ROM, EPROM, FLASH, etc.) in varying amounts; you may want to place a section in a specific type of memory. + +For further explanation of section placement within the memory map, see the discussions in Section 8.5.4 and Section 8.5.5. See Section 8.7 for the actual default memory allocation map for PRU. + +## 2.6 Symbols + +An object file contains a symbol table that stores information about *external symbols* in the object file. The linker uses this table when it performs relocation. See Section 2.7. + +An object file symbol is a named 32-bit integer value, usually representing an address. A symbol can represent such things as the starting address of a function, variable, or section. + +An object file symbol can also represent an absolute integer, such as the size of the stack. To the linker, this integer is an unsigned value, but the integer may be treated as signed or unsigned depending on how it is used. The range of legal values for an absolute integer is 0 to 2^32-1 for unsigned treatment and -2^31 to 2^31-1 for signed treatment. + +Symbols can be bound as *global symbols*, *local symbols*, or *weak symbols*. The linker handles symbols differently based on their binding. For example, the linker does not allow multiple global definitions of a symbol, but local symbols can be defined in multiple object files (but only once per object file). The linker does not resolve references to local symbols in different object files, but it does resolve references to global symbols in any other object file. + +A *global symbol* is defined in the same manner as any other symbol; that is, it appears as a label or is defined by a directive, such as .set, .equ, .bss, or .usect. If a global symbol is defined more than once, the linker issues a multiple-definition error. (The assembler can provide a similar multiple-definition error for local symbols.) + +A *weak symbol* is a symbol that is used in the current module but is defined in another module. The linker resolves this symbol's definition at link time. Weak symbols are similar to global symbols, except that if one object file contains a weak symbol, and another object file contains a global symbol with the same name, the global symbol is used to resolve references. A weak reference may be unresolved at link time, in which case the address is treated as 0. Therefore, for weak references, application code must test to make sure &var is not zero before attempting to read the contents. See Section 2.6.2 for more about weak symbols. + +In general, common symbols (see .common directive) are preferred over weak symbols. + +See Section 4.7 for information about assembler symbols. + +### 2.6.1 External Symbols + +External symbols are symbols that are visible to other object modules. Because they are visible across object modules, they may be defined in one file and referenced in another file. You can use the .def, .ref, or .global directive to identify a symbol as external: + +| | | +|---|---| +| **.def** | The symbol is defined in the current file and may be used in another file. | +| **.ref** | The symbol is referenced in the current file, but defined in another file. | +| **.global** | The symbol can be either of the above. The assembler chooses either .def or .ref as appropriate for each symbol. | + +The following code fragments illustrate the use of the .global directive. + +``` +x: .word y + .global x ; acts as .def of x + .global y ; acts as .ref of y +``` + +Because x is defined in this module, the assembler treats ".global x" as ".def x", and other modules can refer to x. Because y is not defined in this module, the assembler treats ".global y" as ".ref y". The symbol y must be defined in another module. + +Both the symbols x and y are external symbols and are placed in the object file's symbol table; x as a defined symbol, and y as an undefined symbol. When the object file is linked with other object files, the entry for x will be used to resolve references to x in other files. The entry for y causes the linker to look through the symbol tables of other files for y's definition. + +The linker attempts to match all references with corresponding definitions. If the linker cannot find a symbol's definition, it prints an error message about the unresolved reference. This type of error prevents the linker from creating an executable object module. + +An error also occurs if the same symbol is defined more than once. + +### 2.6.2 Weak Symbols + +The linker processes absolute symbols that are defined with "weak" binding differently from absolute symbols that are defined with global binding (the default). Instead of including a weak absolute symbol in the output file's symbol table by default (as it would for a global absolute symbol), the linker only includes a weak absolute symbol in the output of a "final" link if the symbol is required to resolve an otherwise unresolved reference. + +This weak symbol handling allows you to associate addresses with symbols known to have been preloaded (such as function addresses in system memory) and then link the current application against a preloaded memory image. If such symbols are defined as weak absolute symbols, the linker can minimize the number of symbols it includes in the output file's symbol table by omitting those that are not needed to resolve references. Reducing the size of the output file's symbol table reduces the time required to link, especially if there are a large number of pre-loaded symbols to link against. This feature is particularly helpful for OpenCL applications. + +You can define a weak absolute symbol using either assembly or the linker command file. + +**Using Assembly:** To define a weak absolute symbol in an input object file, the source file can be written in assembly. Use the .weak and .set directives in combination as shown in the following example, which defines a weak absolute symbol "ext\_addr\_sym": + +``` +.weak ext_addr_sym +ext_addr_sym .set 0x12345678 +``` + +Assemble the source file that defines weak symbols, and include the resulting object file in the link. The "ext\_addr\_sym" in this example is available as a weak absolute symbol in a final link. It is a candidate for removal if the symbol is not referenced elsewhere in the application. See .weak directive. + +**Using the Linker Command File:** To define a weak symbol in a linker command file, use the "weak" operator in an assignment expression to designate that the symbol as eligible for removal from the output file's symbol table if it is not referenced. In a linker command file, an assignment expression outside a MEMORY or SECTIONS directive can be used to define a weak linker-defined absolute symbol. For example, you can define "ext\_addr\_sym" as follows: + +``` +weak(ext_addr_sym) = 0x12345678; +``` + +If the linker command file is used to perform the final link, then "ext\_addr\_sym" is presented to the linker as a weak absolute symbol; it will not be included in the resulting output file if the symbol is not referenced. See Section 8.6.2. + +If there are multiple definitions of the same absolute symbol, the linker uses certain rules to determine which definition takes precedence. Some definitions may have weak binding and others may have strong binding. "Strong" in this context means that the symbol has *not* been given a weak binding by either of the two methods described above. Some definitions may come from an input object file (that is, using assembly directives) and others may come from an assignment statement in a linker command file. + +The linker uses the following guidelines to determine which definition is used when resolving references to a symbol: + +- A strongly bound symbol always takes precedence over a weakly bound symbol. +- If two symbols are both strongly bound or both weakly bound, a symbol defined in a linker command file takes precedence over a symbol defined in an input object file. +- If two symbols are both strongly bound and both are defined in an input object file, the linker provides a symbol redefinition error and halts the link process. + +### 2.6.3 The Symbol Table + +The assembler generates an entry in the symbol table for each .ref, .def, or .global directive in Section 2.6.1. These are external symbols, which are visible to other object modules. + +The assembler also creates special symbols that point to the beginning of each section. + +The assembler does not usually create symbol table entries for any symbols other than those described above, because the linker does not use them. For example, labels \(Section 4.7.2) are not included in the symbol table unless they are declared with the .global directive. For informational purposes, there are entries in the symbol table for each symbol in a program. + +## 2.7 Symbolic Relocations + +The assembler treats each section as if it began at address 0. Of course, all sections cannot actually begin at address 0 in memory, so the linker must relocate sections. Relocations are symbol-relative rather than section-relative. + +The linker can *relocate* sections by: + +- Allocating them into the memory map so that they begin at the appropriate address as defined with the linker's MEMORY directive +- Adjusting symbol values to correspond to the new section addresses +- Adjusting references to relocated symbols to reflect the adjusted symbol values + +The linker uses *relocation entries* to adjust references to symbol values. The assembler creates a relocation entry each time a relocatable symbol is referenced. The linker then uses these entries to patch the references after the symbols are relocated. Example 2-1 contains a code fragment for a PRU device for which the assembler generates relocation entries. + +### Example 2-1. Code That Generates Relocation Entries + +``` +1 ********************************************* +2 ** Generating Relocation Entries ** +3 ********************************************* +4 .ref X +5 .def Y +6 00000000 .text +7 00000000 E0921003 ADDS R1, R2, R3 +8 00000004 0A000001 BEQ Y +9 00000008 E1C410BE STRH R1, [R4, #14] +10 0000000c EAFFFFFB! B X ; generates a relocation entry +11 00000010 E0821003 Y: ADD R1, R2, R3 +``` + +The relocation generated for 'Y' would actually refer to the symbol 'Y' and resolve the value for 'Y' in the opcode based on where the definition of 'Y' ends up. + +## 2.8 Loading a Program + +The linker creates an executable object file which can be loaded in several ways, depending on your execution environment. These methods include using Code Composer Studio or the hex conversion utility. For details, see Section 3.1. + +# 3 Program Loading and Running + +Even after a program is written, compiled, and linked into an executable object file, there are still many tasks that need to be performed before the program does its job. The program must be loaded onto the target, memory and registers must be initialized, and the program must be set to running. + +Some of these tasks need to be built into the program itself. *Bootstrapping* is the process of a program performing some of its own initialization. Many of the necessary tasks are handled for you by the compiler and linker, but if you need more control over these tasks, it helps to understand how the pieces are expected to fit together. + +This chapter will introduce you to the concepts involved in program loading, initialization, and startup. + +This chapter does not cover *dynamic loading*. + +This chapter currently provides examples for the C6000 device family. Refer to your device documentation for various device-specific aspects of bootstrapping. + +**Topic** ........................................................................................................................... **Page** + +| 3.1 | Loading | 29 | +|-----|-------------------------|----| +| 3.2 | Entry Point | 34 | +| 3.3 | Run-Time Initialization | 34 | +| 3.4 | Arguments to main | 37 | +| 3.5 | Run-Time Relocation | 37 | +| 3.6 | Additional Information | 38 | +| | | | + +## 3.1 Loading + +A program needs to be placed into the target device's memory before it may be executed. *Loading* is the process of preparing a program for execution by initializing device memory with the program's code and data. A *loader* might be another program on the device, an external agent (for example, a debugger), or the device might initialize itself after power-on, which is known as *bootstrap loading*, or *bootloading*. + +The loader is responsible for constructing the *load image* in memory before the program starts. The load image is the program's code and data in memory before execution. What exactly constitutes loading depends on the environment, such as whether an operating system is present. This section describes several loading schemes for bare-metal devices. This section is not exhaustive. + +A program may be loaded in the following ways: + +- **A debugger running on a connected host workstation.** In a typical embedded development setup, the device is subordinate to a host running a debugger such as Code Composer Studio (CCS). The device is connected with a communication channel such as a JTAG interface. CCS reads the program and writes the load image directly to target memory through the communications interface. +- **Another program running on the device.** The running program can create the load image and transfer control to the loaded program. If an operating system is present, it may have the ability to load and run programs. +- **"Burning" the load image onto an EPROM module.** The hex converter (hexpru) can assist with this by converting the executable object file into a format suitable for input to an EPROM programmer. The EPROM is placed onto the device itself and becomes a part of the device's memory. See Chapter 12 for details. +- **Bootstrap loading from a dedicated peripheral, such as an I 2C peripheral.** The device may require a small program called a bootloader to perform the loading from the peripheral. The hex converter can assist in creating a bootloader. + +### 3.1.1 Load and Run Addresses + +Consider an embedded device for which the program's load image is burned onto EPROM/ROM. Variable data in the program must be writable, and so must be located in writable memory, typically RAM. However, RAM is *volatile*, meaning it will lose its contents when the power goes out. If this data must have an initial value, that initial value must be stored somewhere else in the load image, or it would be lost when power is cycled. The initial value must be copied from the non-volatile ROM to its run-time location in RAM before it is used. See Section 8.8 for ways this is done. + +The *load address* is the location of an object in the load image. + +The *run address* is the location of the object as it exists during program execution. + +An *object* is a chunk of memory. It represents a section, segment, function, or data. + +*The load and run addresses for an object may be the same.* This is commonly the case for program code and read-only data, such as the .const section. In this case, the program can read the data directly from the load address. Sections that have no initial value, such as the .bss section, do not have load data and are considered to have load and run addresses that are the same. If you specify different load and run addresses for an uninitialized section, the linker provides a warning and ignores the load address. + +*The load and run addresses for an object may be different.* This is commonly the case for writable data, such as the .data section. The .data section's starting contents are placed in ROM and copied to RAM. This often occurs during program startup, but depending on the needs of the object, it may be deferred to sometime later in the program as described in Section 3.5. + +Symbols in assembly code and object files almost always refer to the run address. When you look at an address in the program, you are almost always looking at the run address. The load address is rarely used for anything but initialization. + +The load and run addresses for a section are controlled by the linker command file and are recorded in the object file metadata. + +The load address determines where a loader places the raw data for the section. Any references to the section (such as references to labels in it) refer to its run address. The application must copy the section from its load address to its run address before the first reference of the symbol is encountered at run time; this does *not* happen automatically simply because you specify a separate run address. For examples that specify load and run addresses, see Section 8.5.6.1. + +ELF format executable object files contain *segments*. See Section 2.3 for information about sections and segments. + +### 3.1.2 Bootstrap Loading + +The details of bootstrap loading (bootloading) vary a great deal between devices. Not every device supports every bootloading mode, and using the bootloader is optional. This section discusses various bootloading schemes to help you understand how they work. Refer to your device's data sheet to see which bootloading schemes are available and how to use them. + +A typical embedded system uses bootloading to initialize the device. The program code and data may be stored in ROM or FLASH memory. At power-on, an on-chip bootloader (the *primary bootloader*) built into the device hardware starts automatically. + +![Figure 3-1: Bootloading Sequence (Simplified) — flowchart showing the four-step boot sequence: Power On → Device Reset (on-chip bootloader) → Entry point (_c_int00 by default) → main](_page_29_Figure_7.jpeg) + +**Figure 3-1. Bootloading Sequence (Simplified).** Flowchart showing the four-step simplified bootloading sequence: Power On → Device Reset (on-chip bootloader) → Entry point (_c_int00 by default) → main, connected by downward arrows. + +The primary bootloader is typically very small and copies a limited amount of memory from a dedicated location in ROM to a dedicated location in RAM. (Some bootloaders support copying the program from an I/O peripheral.) After the copy is completed, it transfers control to the program. + +For many programs, the primary bootloader is not capable of loading the entire program, so these programs supply a more capable secondary bootloader. The primary bootloader loads the secondary bootloader and transfers control to it. Then, the secondary bootloader loads the rest of the program and transfers control to it. There can be any number of layers of bootloaders, each loading a more capable bootloader to which it transfers control. + +**Figure 3-2. Bootloading Sequence with Secondary Bootloader** + +#### 3.1.2.1 Boot, Load, and Run Addresses + +The *boot address* of a bootloaded object is where its raw data exists in ROM before power-on. + +The boot, load, and run addresses for an object may all be the same; this is commonly the case for .const data. If they are different, the object's contents must be copied to the correct location before the object may be used. + +The boot address may be different than the load address. The bootloader is responsible for copying the raw data to the load address. + +The boot address is not controlled by the linker command file or recorded in the object file; it is strictly a convention shared by the bootloader and the program. + +#### 3.1.2.2 Primary Bootloader + +The detailed operation of the primary bootloader is device-specific. Some devices have complex capabilities such as booting from an I/O peripheral or configuring memory controller parameters. + +#### 3.1.2.3 Secondary Bootloader + +The hex converter assumes the secondary bootloader is of a particular format. The hex converter's model bootloader uses a *boot table*. You can use whatever format you want, but if you follow this model, the hex converter can create the boot table automatically. + +#### 3.1.2.4 Boot Table + +The input for the model secondary bootloader is the *boot table*. The boot table contains records that instruct the secondary bootloader to copy blocks of data contained in the table to specified destination addresses. The hex conversion utility automatically builds the boot table for the secondary bootloader. Using the utility, you specify the sections you want to initialize, the boot table location, and the name of the section containing the secondary bootloader routine and where it should be located. The hex conversion utility builds a complete image of the table and adds it to the program. + +The boot table is target-specific. For C6000, the format of the boot table is simple. A header record contains a 4-byte field that indicates where the boot loader should branch after it has completed copying data. After the header, each section that is to be included in the boot table has the following contents: + +- 4-byte field containing the size of the section +- 4-byte field containing the destination address for the copy +- the raw data +- 0 to 3 bytes of trailing padding to make the next field aligned to 4 bytes + +More than one section can be entered; a termination block containing an all-zero 4-byte field follows the last section. + +#### 3.1.2.5 Bootloader Routine + +The bootloader routine is a normal function, except that it executes before the C environment is set up. For this reason, it can't use the C stack, and it can't call any functions that have yet to be loaded! + +The following sample code is for C6000 and is from *Creating a Second-Level Bootloader for FLASH Bootloading on TMS320C6000 Platform With Code Composer Studio* [\(SPRA999\)](http://www.ti.com/lit/pdf/SPRA999). + +#### Example 3-1. Sample Secondary Bootloader Routine + +``` +; ======== boot_c671x.s62 ======== +; global EMIF symbols defined for the c671x family + .include boot_c671x.h62 + .sect ".boot_load" + .global _boot +_boot: +;************************************************************************ +;* DEBUG LOOP − COMMENT OUT B FOR NORMAL OPERATION +;************************************************************************ +zero B1 +_myloop: ; [!B1] B _myloop + nop 5 +_myloopend: nop +;************************************************************************ +;* CONFIGURE EMIF +;************************************************************************ + ;**************************************************************** + ; *EMIF_GCTL = EMIF_GCTL_V; + ;**************************************************************** + mvkl EMIF_GCTL,A4 + || mvkl EMIF_GCTL_V,B4 + mvkh EMIF_GCTL,A4 + || mvkh EMIF_GCTL_V,B4 + stw B4,*A4 + ;**************************************************************** + ; *EMIF_CE0 = EMIF_CE0_V + ;**************************************************************** + mvkl EMIF_CE0,A4 + || mvkl EMIF_CE0_V,B4 + mvkh EMIF_CE0,A4 + || mvkh EMIF_CE0_V,B4 + stw B4,*A4 +``` + +#### Example 3-1. Sample Secondary Bootloader Routine (continued) + +``` + ;**************************************************************** + ; *EMIF_CE1 = EMIF_CE1_V (setup for 8-bit async) + ;**************************************************************** + mvkl EMIF_CE1,A4 + || mvkl EMIF_CE1_V,B4 + mvkh EMIF_CE1,A4 + || mvkh EMIF_CE1_V,B4 + stw B4,*A4 + ;**************************************************************** + ; *EMIF_CE2 = EMIF_CE2_V (setup for 32-bit async) + ;**************************************************************** + mvkl EMIF_CE2,A4 + || mvkl EMIF_CE2_V,B4 + mvkh EMIF_CE2,A4 + || mvkh EMIF_CE2_V,B4 + stw B4,*A4 + ;**************************************************************** + ; *EMIF_CE3 = EMIF_CE3_V (setup for 32-bit async) + ;**************************************************************** + mvkl EMIF_CE3,A4 + || mvkl EMIF_CE3_V,B4 + mvkh EMIF_CE3,A4 + || mvkh EMIF_CE3_V,B4 + stw B4,*A4 + ;**************************************************************** + ; *EMIF_SDRAMCTL = EMIF_SDRAMCTL_V + ;**************************************************************** + || mvkl EMIF_SDRAMCTL,A4 + || mvkl EMIF_SDRAMCTL_V,B4 + mvkh EMIF_SDRAMCTL,A4 + || mvkh EMIF_SDRAMCTL_V,B4 + stw B4,*A4 + ;**************************************************************** + ; *EMIF_SDRAMTIM = EMIF_SDRAMTIM_V + ;**************************************************************** + mvkl EMIF_SDRAMTIM,A4 + || mvkl EMIF_SDRAMTIM_V,B4 + mvkh EMIF_SDRAMTIM,A4 + || mvkh EMIF_SDRAMTIM_V,B4 + stw B4,*A4 + ;**************************************************************** + ; *EMIF_SDRAMEXT = EMIF_SDRAMEXT_V + ;**************************************************************** + mvkl EMIF_SDRAMEXT,A4 + || mvkl EMIF_SDRAMEXT_V,B4 + mvkh EMIF_SDRAMEXT,A4 + || mvkh EMIF_SDRAMEXT_V,B4 + stw B4,*A4 +;********************************************************************** +; copy sections +;********************************************************************** + mvkl COPY_TABLE, a3 ; load table pointer + mvkh COPY_TABLE, a3 + ldw *a3++, b1 ; Load entry point +copy_section_top: + ldw *a3++, b0 ; byte count + ldw *a3++, a4 ; ram start address + nop 3 +[!b0] b copy_done ; have we copied all sections? + nop 5 +copy_loop: + ldb *a3++,b5 + sub b0,1,b0 ; decrement counter +[ b0] b copy_loop ; setup branch if not done +``` + +#### Example 3-1. Sample Secondary Bootloader Routine (continued) + +``` +[!b0] b copy_section_top + zero a1 +[!b0] and 3,a3,a1 + stb b5,*a4++ +[!b0] and -4,a3,a5 ; round address up to next multiple of 4 +[ a1] add 4,a5,a3 ; round address up to next multiple of 4 +;********************************************************************** +; jump to entry point +;********************************************************************** +copy_done: + b .S2 b1 + nop 5 +``` + +## 3.2 Entry Point + +The entry point is the address at which the execution of the program begins. This is the address of the startup routine. The startup routine is responsible for initializing and calling the rest of the program. For a C/C++ program, the startup routine is usually named \_c\_int00 (see Section 3.3.1). After the program is loaded, the value of the entry point is placed in the PC register and the CPU is allowed to run. + +The object file has an entry point field. For a C/C++ program, the linker will fill in \_c\_int00 by default. You can select a custom entry point; see Section 8.4.12. The device itself cannot read the entry point field from the object file, so it has to be encoded in the program somewhere. + +- If you are using a bootloader, the boot table includes an entry point field. When it finishes running, the bootloader branches to the entry point. +- If you are using a hosted debugger, such as CCS, the debugger may explicitly set the program counter (PC) to the value of the entry point. + +## 3.3 Run-Time Initialization + +After the load image is in place, the program can run. The subsections that follow describe bootstrap initialization of a C/C++ program. An assembly-only program may not need to perform all of these steps. + +#### 3.3.1 The \_c\_int00 Function + +The function \_c\_int00 is the *startup routine* (also called the *boot routine*) for C/C++ programs. It performs all the steps necessary for a C/C++ program to initialize itself. + +The name \_c\_int00 means that it is the interrupt handler for interrupt number 0, RESET, and that it sets up the C environment. Its name need not be exactly \_c\_int00, but the linker sets \_c\_int00 as the entry point for C programs by default. The compiler's run-time-support library provides a default implementation of \_c\_int00. + +The startup routine is responsible for performing the following actions: + +1. Switch to user mode and sets up the user mode stack +2. Set up status and configuration registers +3. Set up the stack and secondary system stack +4. Process special binit copy table, if present. +5. Process the run-time initialization table to autoinitialize global variables (when using the --rom\_model option) +6. Call all global constructors +7. Call the function main +8. Call exit when main returns + +### 3.3.2 Variable Initialization + +Initialized read-write variables are collected into dedicated section(s) of the object file, for example .data. The section contains an image of its initial state upon program startup. + +There are two models for loading such sections. In the *RAM model* (--ram\_model), an external agent such as a loader is responsible for getting the data from the executable file to its location in read-write memory. This is the typical direct-initialization model used in OS-based systems or, in some instances, boot-loaded systems. + +The other model, called the *ROM model* (--rom\_model), is intended for bare-metal embedded systems that must be capable of cold starts without the support of an OS or other loader. Any data needed to initialize the program must reside in persistent offline storage (ROM), and get copied into its RAM location upon startup. The TI tools implement this by leveraging the copy table capability. The initialization mechanism is conceptually similar to copy tables, but differs slightly in the details. + +Figure 3-3 shows the conceptual operation of variable initialization under the ROM model. In this model, the linker *removes* the data from sections that contain initialized variables. The sections become uninitialized sections, allocated into RAM at their run-time address (much like .bss). The linker encodes the initialization data into a special section called .cinit (for C Initialization), where the startup code from the run-time library decodes and copies it to its run address. + +![Figure 3-3: ROM-Based Variable Initialization Via cinit — pipeline diagram showing source code compiled and linked into an executable with a .cinit section, loaded to ROM, and copied to RAM at startup](_page_34_Figure_7.jpeg) + +**Figure 3-3. ROM-Based Variable Initialization Via cinit.** Pipeline diagram illustrating the Compile → Link → Load → Startup flow for ROM-based variable initialization. Source code (int a=123; int b=456;) and an object file (.data section with a: .word 123, b: .word 456) are linked: the linker compresses the source data and creates a .cinit section (containing cinit records, handler table, and compressed data) while making .data uninitialized. After loading, .cinit resides in ROM. At startup, startup code reads the cinit table, decompresses the source data, and copies it to the RAM run-time locations (a: 123, b: 456). + +Like copy tables, the source data in the .cinit tables may or may not be compressed. If it is compressed, the encoding and decoding scheme is identical to that of copy tables so that the handler tables and decompression handlers can be shared. + +The .cinit section contains some or all of the following items: + +- The **cinit table**, consisting of cinit records, which are similar to copy records. +- The **handler table**, consisting of pointers to decompression routines. The handler table and handlers are shared by initialization and copy tables. +- The **source data**, consisting of compressed or uncompressed data used to initialize variables. + +These items may be in any order. + +Figure 3-4 is a schematic depiction of the .cinit section. + +![Figure 3-4: The .cinit Section — memory layout schematic showing the cinit table, handler table, and cinit source data regions bounded by four special symbols](_page_35_Picture_3.jpeg) + +**Figure 3-4. The .cinit Section.** Schematic memory layout of the .cinit section. Four special symbols bound the three regions: __TI_CINIT_Base points to the start of the cinit table (containing cinit records); __TI_CINIT_Limit and __TI_Handler_Table_Base delimit the handler table (containing handler 0 through handler N); __TI_Handler_Table_Limit points to the start of the cinit source data region (containing one or more cinit source data blocks). + +The .cinit section has the section type SHT\_TI\_INITINFO which identifies it as being in this format. Tools should rely on the section type and not on the name .cinit. + +Two special symbols are defined to delimit the cinit table: \_ \_TI\_CINIT\_Base points to the cinit table, and \_ \_TI\_CINIT\_Limit points one byte past the end of the table. The startup code references the table using these symbols. + +Records in the cinit table have the following format: + +``` +typedef struct +{ + uint32 source_data; + uint32 dest; +} CINIT_RECORD; +``` + +- The **source\_data** field points to the source data in the cinit section. +- The **dest** field points to the destination address. Unlike copy table records, cinit records do not contain a size field; the size is always encoded in the source data. + +The source data has the same format as compressed copy table source data, and the handlers have the same interface. In addition to the RLE and LZSS formats, there are two additional formats defined for cinit records: uncompressed, and zero-initialized. + +• The explicit **uncompressed** format is required because unlike a copy table record, there is no overloaded size field in a cinit record. The size field is always encoded into the source data, even when no compression is used. The encoding is as follows: + +| handler index | padding | size | data | +|---------------|---------|---------|------------| +| 1 byte | 3 bytes | 4 bytes | size bytes | + +The encoded data includes a size field, which is aligned on the next 4-byte boundary following the handler index. The size field specifies how many bytes are in the data payload, which begins immediately following the size field. The initialization operation copies *size* bytes from the data field to + +the destination address. The TI run-time library contains a handler called \_ \_TI\_decompress\_none for the uncompressed format. + +• The **zero-initialization** format is a compact format used for the common case of variables whose initial value is zero. The encoding is as follows: + +| handler index | padding | size | +|---------------|---------|---------| +| 1 byte | 3 bytes | 4 bytes | + +The size field is aligned on the next 4-byte boundary following the handler index. The initialization operation fills *size* consecutive bytes at the destination address with zero. The TI run-time library contains a handler called \_ \_TI\_zero\_init for this format. + +As an optimization, the linker is free to coalesce initializations of adjacent objects into single cinit records if they can be profitably encoded using the same format. This is typically significant for zeroinitialized objects. + +### 3.3.3 Copy Tables + +The RTS function copy\_in can be used at run-time to move code and data around, usually from its load address to its run address. This function reads size and location information from copy tables. The linker automatically generates several kinds of copy tables. Refer to Section 8.8. + +You can create and control code overlays with copy tables. See Section 8.8.4 for details and examples. + +Using copy tables is similar to performing run-time relocations as described in Section 3.5, however copy tables require a specific table format. + +#### 3.3.3.1 BINIT + +The BINIT (boot-time initialization) copy table is special in that the target will automatically perform the copying at auto-initialization time. Refer to Section 8.8.4.2 for more about the BINIT copy table name. The BINIT copy table is copied before .cinit processing. + +#### 3.3.3.2 CINIT + +EABI .cinit tables are special kinds of copy tables. Refer to Section 3.3.2 for information about using the .cinit section with the ROM model for variable initialization. + +## 3.4 Arguments to main + +Some programs expect arguments to main (argc, argv) to be valid. Normally this isn't possible for an embedded program, but the TI runtime does provide a way to do it. The user must allocate an .args section of an appropriate size using the --args linker option. It is the responsibility of the loader to populate the .args section. It is not specified how the loader determines which arguments to pass to the target. The format of the arguments is the same as an array of pointers to char on the target. + +See Section 8.4.4 for information about allocating memory for argument passing. + +## 3.5 Run-Time Relocation + +At times you may want to load code into one area of memory and move it to another area before running it. For example, you may have performance-critical code in an external-memory-based system. The code must be loaded into external memory, but it would run faster in internal memory. Because internal memory is limited, you might swap in different speed-critical functions at different times. + +The linker provides a way to handle this. Using the SECTIONS directive, you can optionally direct the linker to allocate a section twice: first to set its load address and again to set its run address. Use the *load* keyword for the load address and the *run* keyword for the run address. See Section 3.1.1 for more about load and run addresses. If a section is assigned two addresses at link time, all labels defined in the section are relocated to refer to the run-time address so that references to the section (such as branches) are correct when the code runs. + +If you provide only one allocation (either load or run) for a section, the section is allocated only once and loads and runs at the same address. If you provide both allocations, the section is actually allocated as if it were two separate sections of the same size. + +Uninitialized sections (such as .bss) are not loaded, so the only significant address is the run address. The linker allocates uninitialized sections only once; if you specify both run and load addresses, the linker warns you and ignores the load address. + +For a complete description of run-time relocation, see Section 8.5.6. + +## 3.6 Additional Information + +See the following sections and documents for additional information: + +Section 8.4.4, "Allocate Memory for Use by the Loader to Pass Arguments (--arg\_size Option)" + +Section 8.4.12, "Define an Entry Point (--entry\_point Option)" + +Section 8.5.6.1 ,"Specifying Load and Run Addresses" + +Section 8.8, "Linker-Generated Copy Tables" + +Section 8.10.1, "Run-Time Initialization" + +Chapter 12, "Hex Conversion Utility Description" + +"Run-Time Initialization" and "System Initialization" sections in the *PRU Optimizing C/C++ Compiler User's Guide* + +*Creating a Second-Level Bootloader for FLASH Bootloading on TMS320C6000 Platform With Code Composer Studio* ([SPRA999\)](http://www.ti.com/lit/pdf/SPRA999). + +# 4 Assembler Description + +The PRU assembler translates assembly language source files into machine language object files. These files are object modules, which are discussed in Chapter 2. Source files can contain the following assembly language elements: + +Assembler directives + described in Chapter 5 + +Macro directives + described in Chapter 6 + +Assembly language instructions + described in the *PRU Family User's Guide*. + +**Topic** ........................................................................................................................... **Page** + +| 4.1 | Assembler Overview | 40 | +|------|-------------------------------------------------------|----| +| 4.2 | The Assembler's Role in the Software Development Flow | 41 | +| 4.3 | Invoking the Assembler | 42 | +| 4.4 | Naming Alternate Directories for Assembler Input | 43 | +| 4.5 | Source Statement Format | 45 | +| 4.6 | Literal Constants | 47 | +| 4.7 | Assembler Symbols | 49 | +| 4.8 | Expressions | 54 | +| 4.9 | Built-in Functions and Operators | 58 | +| 4.10 | Source Listings | 59 | +| 4.11 | Debugging Assembly Source | 61 | +| 4.12 | Cross-Reference Listings | 62 | + +## 4.1 Assembler Overview + +The 2-pass assembler does the following: + +- Processes the source statements in a text file to produce a relocatable object file +- Produces a source listing (if requested) and provides you with control over this listing +- Allows you to divide your code into sections and maintain a section program counter (SPC) for each section of object code +- Defines and references global symbols and appends a cross-reference listing to the source listing (if requested) +- Allows conditional assembly +- Supports macros, allowing you to define macros inline or in a library + +## 4.2 The Assembler's Role in the Software Development Flow + +Figure 4-1 illustrates the assembler's role in the software development flow. The shaded portion highlights the most common assembler development path. The assembler accepts assembly language source files as input, both those you create and those created by the PRU C/C++ compiler. + +**Figure 4-1. The Assembler in the PRU Software Development Flow.** Flow diagram showing the PRU software development tools. The shaded central path shows: C/C++ source files → C/C++ compiler → Assembler source → Assembler → Object files → Linker → Executable object file. Macro source files and macro library (via Archiver) feed into the Assembler. Object files also feed into another Archiver to produce a library of object files for the Linker. A Run-time-support library (via Library-build utility) also feeds the Linker. C/C++ name demangling utility connects to Assembler source. Debugging tools connect to the Executable object file. The Executable object file feeds downstream tools: Hex-conversion utility → EPROM programmer; Absolute lister; Cross-reference lister; Object file utilities; and the PRU target device. + +## 4.3 Invoking the Assembler + +To invoke the assembler, enter the following: + +``` +clpru input file [options] +``` + +**clpru** is the command that invokes the assembler through the compiler. The compiler considers any file with an .asm extension to be an assembly file and invokes the assembler. + +*input file* names the assembly language source file. + +*options* identify the assembler options that you want to use. Options are case sensitive and can appear anywhere on the command line following the command. Precede each option with one or two hyphens as shown. + +The valid assembler options are listed in Table 4-1. + +**Table 4-1. PRU Assembler Options** + +| Option | Alias | Description | +|----------------------------------------------|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| absolute_listing | -aa | Creates an absolute listing. When you useabsolute_listing, the assembler does not produce
an object file. Theabsolute_listing option is used in conjunction with the absolute lister. | +| asm_define=name[=def] | -ad | Sets the name symbol. This is equivalent to defining name with a .set directive in the case of a
numeric value or with an .asg directive otherwise. If value is omitted, the symbol is set to 1.
See Section 4.7.5. | +| asm_dependency | -apd | Performs preprocessing for assembly files, but instead of writing preprocessed output, writes a
list of dependency lines suitable for input to a standard make utility. The list is written to a file
with the same name as the source file but with a .ppa extension. | +| asm_includes | -api | Performs preprocessing for assembly files, but instead of writing preprocessed output, writes a
list of files included with the .include directive. The list is written to a file with the same name
as the source file but with a .ppa extension. | +| asm_listing | -al | Produces a listing file with the same name as the input file with a .lst extension. | +| asm_listing_cross_reference | -ax | Produces a cross-reference table and appends it to the end of the listing file; it also adds
cross-reference information to the object file for use by the cross-reference utility. If you do not
request a listing file but use theasm_listing_cross_reference option, the assembler creates a
listing file automatically, naming it with the same name as the input file with a .lst extension. | +| asm_undefine=name | -au | Undefines the predefined constant name, which overrides anyasm_define options for the
specified constant. | +| cmd_file=filename | -@ | Appends the contents of a file to the command line. You can use this option to avoid limitations
on command line length imposed by the host operating system. Use an asterisk or a
semicolon (* or ;) at the beginning of a line in the command file to include comments.
Comments that begin in any other column must begin with a semicolon. Within the command
file, filenames or option parameters containing embedded spaces or hyphens must be
surrounded with quotation marks. For example: "this-file.asm" | +| code_address_listing_unit={
byte word } | | Selects the unit to use for the code section program counter field in the assembler listing file.
The default unit is bytes. Note that this option applies to code sections, but not to data
sections. See Section 4.10. | +| endian={ big little } | | Specify the endianness of both code and data. If not specified, defaults toendian=little. For
more information, see the PRU Optimizing C/C++ Compiler User's Guide. | +| include_file=filename | -ahi | Includes the specified file for the assembly module. The file is included before source file
statements. The included file does not appear in the assembly listing files. | +| include_path=pathname | -I | Specifies a directory where the assembler can find files named by the .copy, .include, or .mlib
directives. There is no limit to the number of directories you can specify in this manner; each
pathname must be preceded by theinclude_path option. See Section 4.4.1. | +| quiet | -q | Suppresses the banner and progress information (assembler runs in quiet mode). | +| symdebug:dwarf or
symdebug:none | -g | (DWARF is on by default) Enables assembler source debugging in the C source debugger.
Line information is output to the object module for every line of source in the assembly
language source file. You cannot use this option on assembly code that contains .line
directives. See Section 4.11. | + +## 4.4 Naming Alternate Directories for Assembler Input + +The .copy, .include, and .mlib directives tell the assembler to use code from external files. The .copy and .include directives tell the assembler to read source statements from another file, and the .mlib directive names a library that contains macro functions. Chapter 5 contains examples of the .copy, .include, and .mlib directives. The syntax for these directives is: + +``` +.copy ["]filename["] +.include ["]filename["] +.mlib ["]filename["] +``` + +The *filename* names a copy/include file that the assembler reads statements from or a macro library that contains macro definitions. If *filename* begins with a number the double quotes are required. Quotes are recommended so that there is no issue in dealing with path information that is included in the filename specification or path names that include white space. The filename may be a complete pathname, a partial pathname, or a filename with no path information. + +The assembler searches for the file in the following locations in the order given: + +1. The directory that contains the current source file. The current source file is the file being assembled when the .copy, .include, or .mlib directive is encountered. +2. Any directories named with the --include\_path option +3. Any directories named with the PRU\_A\_DIR environment variable +4. Any directories named with the PRU\_A\_DIR environment variable + +Because of this search hierarchy, you can augment the assembler's directory search algorithm by using the --include\_path option (described in Section 4.4.1) or the PRU\_A\_DIR environment variable (described in Section 4.4.2). The PRU\_A\_DIR environment variable is discussed in the *PRU Optimizing C/C++ Compiler User's Guide*. + +### 4.4.1 Using the --include\_path Assembler Option + +The --include\_path assembler option names an alternate directory that contains copy/include files or macro libraries. The format of the --include\_path option is as follows: + +``` +clpru --include_path= pathname source filename [other options] +``` + +There is no limit to the number of --include\_path options per invocation; each --include\_path option names one pathname. In assembly source, you can use the .copy, .include, or .mlib directive without specifying path information. If the assembler does not find the file in the directory that contains the current source file, it searches the paths designated by the --include\_path options. + +For example, assume that a file called source.asm is in the current directory; source.asm contains the following directive statement: + +``` +.copy "copy.asm" +``` + +Assume the following paths for the copy.asm file: + +UNIX: /tools/files/copy.asm +Windows: c:\tools\files\copy.asm + +You could set up the search path with the commands shown below: + +| Operating System | Enter | +|---------------------|---------------------------------------------| +| UNIX (Bourne shell) | clpru --include_path=/tools/files source.asm | +| Windows | clpru --include_path=c:\tools\files source.asm | + +The assembler first searches for copy.asm in the current directory because source.asm is in the current directory. Then the assembler searches in the directory named with the --include\_path option. + +### 4.4.2 Using the PRU\_A\_DIR Environment Variable + +An environment variable is a system symbol that you define and assign a string to. The assembler uses the PRU\_A\_DIR environment variable to name alternate directories that contain copy/include files or macro libraries. + +The assembler looks for the PRU\_A\_DIR environment variable and then reads and processes it. If the assembler does not find the PRU\_A\_DIR variable, it then searches for PRU\_C\_DIR. The processorspecific variables are useful when you are using Texas Instruments tools for different processors at the same time. + +See the *PRU Optimizing C/C++ Compiler User's Guide* for details on PRU\_C\_DIR. + +The command syntax for assigning the environment variable is as follows: + +| Operating System | Enter | +|---------------------|---------------------------------------------------------------| +| UNIX (Bourne Shell) | PRU_A_DIR=" pathname1
; pathname2
; "; export PRU_A_DIR | +| Windows | set PRU_A_DIR= pathname1
; pathname2
; | + +The *pathnames* are directories that contain copy/include files or macro libraries. The pathnames must follow these constraints: + +- Pathnames must be separated with a semicolon. +- Spaces or tabs at the beginning or end of a path are ignored. For example the space before and after the semicolon in the following is ignored: + +``` +set PRU_A_DIR= c:\path\one\to\tools ; c:\path\two\to\tools +``` + +• Spaces and tabs are allowed within paths to accommodate Windows directories that contain spaces. For example, the pathnames in the following are valid: + +``` +set PRU_A_DIR=c:\first path\to\tools;d:\second path\to\tools +``` + +In assembly source, you can use the .copy, .include, or .mlib directive without specifying path information. If the assembler does not find the file in the directory that contains the current source file or in directories named by the --include\_path option, it searches the paths named by the environment variable. + +For example, assume that a file called source.asm contains these statements: + +``` +.copy "copy1.asm" +.copy "copy2.asm" +``` + +Assume the following paths for the files: + +UNIX: /tools/files/copy1.asm and /dsys/copy2.asm +Windows: c:\tools\files\copy1.asm and c:\dsys\copy2.asm + +You could set up the search path with the commands shown below: + +| Operating System | Enter | +|---------------------|----------------------------------------------------------------------------------| +| UNIX (Bourne shell) | PRU_A_DIR="/dsys"; export PRU_A_DIR
clpru --include_path=/tools/files source.asm | +| Windows | PRU_A_DIR=c:\dsys
clpru --include_path=c:\tools\files source.asm | + +The assembler first searches for copy1.asm and copy2.asm in the current directory because source.asm is in the current directory. Then the assembler searches in the directory named with the --include\_path option and finds copy1.asm. Finally, the assembler searches the directory named with PRU\_A\_DIR and finds copy2.asm. + +The environment variable remains set until you reboot the system or reset the variable by entering one of these commands: + +| Operating System | Enter | +|---------------------|-----------------| +| UNIX (Bourne shell) | unset PRU_A_DIR | +| Windows | set PRU_A_DIR= | + +## 4.5 Source Statement Format + +Each line in a PRU assembly input file can be empty, a comment, an assembler directive, a macro invocation, or an assembly instruction. + +Assembly language source statements can contain four ordered fields (label, mnemonic, operand list, and comment). The general syntax for source statements is as follows: + +``` +[label[:]]mnemonic [operand list][;comment] +``` + +Following are examples of source statements: + +``` +SYM1 .set 2 ; Symbol SYM1 = 2 +Begin: LDI R0, SYM1 ; Load R0 with 2 + .word 016h ; Initialize word (016h) +``` + +The PRU assembler reads an unlimited number of characters per line. Source statements that extend beyond 400 characters in length (including comments) are truncated in the listing file. + +Follow these guidelines: + +- All statements must begin with a label, a blank, an asterisk, or a semicolon. +- Labels are optional for most statements; if used, they must begin in column 1. +- One or more space or tab characters must separate each field. +- Comments are optional. Comments that begin in column 1 can begin with an asterisk or a semicolon (\* or ;), but comments that begin in any other column *must* begin with a semicolon. + +**NOTE:** A mnemonic cannot begin in column 1 or it will be interpreted as a label. Mnemonic opcodes and assembler directive names without the . prefix are valid label names. Remember to always use whitespace before the mnemonic, or the assembler will think the identifier is a new label definition. + +The following sections describe each of the fields. + +### 4.5.1 Label Field + +A label must be a legal identifier (see Section 4.7.1) placed in column 1. Every instruction may optionally have a label. Many directives allow a label, and some require a label. + +A label can be followed by a colon (:). The colon is not treated as part of the label name. If you do not use a label, the first character position must contain a blank, a semicolon, or an asterisk. + +When you use a label on an assembly instruction or data directive, an *assembler symbol* (Section 4.7) with the same name is created. Its value is the current value of the *section program counter* (SPC, see Section 2.4.5). This symbol represents the address of that instruction. In the following example, the .word directive is used to create an array of 3 words. Because a label was used, the assembly symbol Start refers to the first word, and the symbol will have the value 40h. + +``` +. . . . + 9 * Assume some code was assembled + 10 00000040 0000000A Start: .word 0Ah,3,7 + 00000044 00000003 + 00000048 00000007 +``` + +A label on a line by itself is a valid statement. When a label appears on a line by itself, it points to the instruction on the next line (the SPC is not incremented): + +``` +1 00000000 Here: +2 00000000 00000003 .word 3 +``` + +A label on a line by itself is equivalent to writing: + +``` +Here: .equ $ ; $ provides the current value of the SPC +``` + +If you do not use a label, the character in column 1 must be a blank, an asterisk, or a semicolon. + +### 4.5.2 Mnemonic Field + +The mnemonic field follows the label field. The mnemonic field cannot start in column 1; if it does, it is interpreted as a label. There is one exception: the parallel bars (||) of the mnemonic field can start in column 1. The mnemonic field contains one of the following items: + +- Machine-instruction mnemonic (such as ADD, SBBO, STR) +- Assembler directive (such as .data, .list, .equ) +- Macro directive (such as .macro, .var, .mexit) +- Macro invocation + +### 4.5.3 Operand Field + +The operand field follows the mnemonic field and contains zero or more comma-separated operands. An operand can be one of the following: + +- an immediate operand (usually a constant or symbol) (see Section 4.6 and Section 4.7) +- a register operand +- a memory reference operand +- an expression that evaluates to one of the above (see Section 4.8) + +An *immediate operand* is encoded directly in the instruction. The value of an immediate operand must be a *constant expression*. Most instructions with an immediate operand require an *absolute constant expression*, such as 1234. Some instructions (such as a call instruction) allow a *relocatable constant expression*, such as a symbol defined in another file. (See Section 4.8 for details about types of expressions.) + +A *register operand* is a special pre-defined symbol that represents a CPU register. + +A *memory reference operand* uses one of several memory addressing modes to refer to a location in memory. Memory reference operands use a special target-specific syntax defined in the appropriate *CPU and Instruction Set Reference Guide*. + +You must separate operands with commas. Not all operand types are supported for all operands. See the description of the specific instruction in the *CPU and Instruction Set Reference Guide* for your device. + +#### 4.5.3.1 Immediate Values as Operands + +You use immediate values as operands primarily with instructions. In some cases, you can use immediate values with the operands of directives. For instance, you can use immediate values with the .byte directive to load values into the current section. + +The # sign may not be used in instructions or directives to identify immediate values. Doing so causes a syntax error. + +See Chapter 5 for more information on the syntax and usage of directives. + +### 4.5.4 Comment Field + +A comment can begin in any column and extends to the end of the source line. A comment can contain any ASCII character, including blanks. Comments are printed in the assembly source listing, but they do not affect the assembly. + +A source statement that contains only a comment is valid. If it begins in column 1, it can start with a semicolon ( **;** ) or an asterisk ( **\***). Comments that begin anywhere else on the line must begin with a semicolon. The asterisk identifies a comment only if it appears in column 1. + +## 4.6 Literal Constants + +A *literal constant* (also known as a *literal* or in some other documents as an *immediate value*) is a value that represents itself, such as 12, 3.14, or "hello". + +The assembler supports several types of literals: + +- Binary integer literals +- Octal integer literals +- Decimal integer literals +- Hexadecimal integer literals +- Character literals +- Character string literals +- Floating-point literals + +Error checking for invalid or incomplete literals is performed. + +### 4.6.1 Integer Literals + +The assembler maintains each integer literal internally as a 32-bit signless quantity. Literals are considered unsigned values, and are not sign extended. For example, the literal 00FFh is equal to 00FF (base 16) or 255 (base 10); it *does not* equal -1. which is 0FFFFFFFFh (base 16). Note that if you store 0FFh in a .byte location, the bits will be exactly the same as if you had stored -1. It is up to the reader of that location to interpret the signedness of the bits. + +#### 4.6.1.1 Binary Integer Literals + +A binary integer literal is a string of up to 32 binary digits (0s and 1s) followed by the suffix B (or b). Binary literals of the form "0[bB][10]+" are also supported. If fewer than 32 digits are specified, the assembler right justifies the value and fills the unspecified bits with zeros. These are examples of valid binary literals: + +00000000B Literal equal to 010 or 016 +0100000b Literal equal to 3210 or 2016 +01b Literal equal to 110 or 116 +11111000B Literal equal to 24810 or 0F816 +0b00101010 Literal equal to 4210 or 2A16 +0B101010 Literal equal to 4210 or 2A16 + +#### 4.6.1.2 Octal Integer Literals + +An octal integer literal is a string of up to 11 octal digits (0 through 7) followed by the suffix Q (or q). Octal literals may also begin with a 0, contain no 8 or 9 digits, and end with no suffix. These are examples of valid octal literals: + +10Q Literal equal to 810 or 816 + +054321 Literal equal to 2273710 or 58D116 +100000Q Literal equal to 3276810 or 800016 +226q Literal equal to 15010 or 9616 + +#### 4.6.1.3 Decimal Integer Literals + +A decimal integer literal is a string of decimal digits ranging from -2147 483 648 to 4 294 967 295. These are examples of valid decimal integer literals: + +1000 Literal equal to 100010 or 3E816 +-32768 Literal equal to -32 76810 or -800016 + +25 Literal equal to 2510 or 1916 + +4815162342 Literal equal to 481516234210 or 11F018BE616 + +#### 4.6.1.4 Hexadecimal Integer Literals + +A hexadecimal integer literal is a string of up to eight hexadecimal digits followed by the suffix H (or h) or preceded by 0x. *A hexadecimal literal must begin with a decimal value (0-9) if it is indicated by the H or h suffix.* + +Hexadecimal digits include the decimal values 0-9 and the letters A-F or a-f. If fewer than eight hexadecimal digits are specified, the assembler right-justifies the bits. + +These are examples of valid hexadecimal literals: + +78h Literal equal to 12010 or 007816 0x78 Literal equal to 12010 or 007816 0Fh Literal equal to 1510 or 000F16 37ACh Literal equal to 1425210 or 37AC16 + +#### 4.6.1.5 Character Literals + +A character literal is a single character enclosed in *single* quotes. The characters are represented internally as 8-bit ASCII characters. Two consecutive single quotes are required to represent each single quote that is part of a character literal. A character literal consisting only of two single quotes is valid and is assigned the value 0. These are examples of valid character literals: + +- 'a' Defines the character literal *a* and is represented internally as 6116 +- 'C' Defines the character literal *C* and is represented internally as 4316 +- '''' Defines the character literal *'* and is represented internally as 2716 +- '' Defines a null character and is represented internally as 0016 + +Notice the difference between character *literals* and character *string literals* \(Section 4.6.2 discusses character strings). A character literal represents a single integer value; a string is a sequence of characters. + +### 4.6.2 Character String Literals + +A character string is a sequence of characters enclosed in *double* quotes. Double quotes that are part of character strings are represented by two consecutive double quotes. The maximum length of a string varies and is defined for each directive that requires a character string. Characters are represented internally as 8-bit ASCII characters. + +These are examples of valid character strings: + +``` +"sample program" defines the 14-character string sample program. +"PLAN ""C""" defines the 8-character string PLAN "C". +``` + +Character strings are used for the following: + +- Filenames, as in .copy "filename" +- Section names, as in .sect "section name" +- Data initialization directives, as in .byte "charstring" +- Operands of .string directives + +### 4.6.3 Floating-Point Literals + +A floating-point literal is a string of decimal digits followed by a required decimal point, an optional fractional portion, and an optional exponent portion. The syntax for a floating-point number is: + +``` +[ +|- ] nnn . [ nnn] [ E|e [ +|- ] nnn ] +``` + +Replace *nnn* with a string of decimal digits. You can precede *nnn* with a + or a -. You must specify a decimal point. For example, 3.e5 is valid, but 3e5 is not valid. The exponent indicates a power of 10. These are examples of valid floating-point literals: + +``` +3.0 +3.14 +3. +-0.314e13 ++314.59e-2 +``` + +The assembler syntax does not support all C89-style float literals nor C99-style hexadecimal constants, but the \$strtod built-in mathematical function supports both. If you want to specify a floating-point literal using one of those formats, use \$strtod. For example: + +``` +$strtod(".3") +$strtod("0x1.234p-5") +``` + +You cannot directly use NaN, Inf, or -Inf as floating-point literals. Instead, use \$strtod to express these values. The "NaN" and "Inf" strings are handled case-insensitively. See Section 4.9.1 for built-in functions. + +## 4.7 Assembler Symbols + +An assembler symbol is a named 32-bit signless integer value, usually representing an address or absolute integer. A symbol can represent such things as the starting address of a function, variable, or section. The name of a symbol must be a legal identifier. The identifier becomes a symbolic representation of the symbol's value, and may be used in subsequent instructions to refer to the symbol's location or value. + +Some assembler symbols become external symbols, and are placed in the object file's symbol table. A symbol is valid only within the module in which it is defined, unless you use the .global directive or the .def directive to declare it as an *external symbol* (see .global directive). + +See Section 2.6 for more about symbols and the symbol tables in object files. + +### 4.7.1 Identifiers + +Identifiers are names used as labels, registers, symbols, and substitution symbols. An identifier is a string of alphanumeric characters, the dollar sign, and underscores (A-Z, a-z, 0-9, \$, and \_). The first character in an identifier cannot be a number, and identifiers cannot contain embedded blanks. The identifiers you define are case sensitive; for example, the assembler recognizes ABC, Abc, and abc as three distinct identifiers. + +### 4.7.2 Labels + +An identifier used as a label becomes an assembler symbol, which represent an address in the program. Labels within a file must be unique. + +**NOTE:** A mnemonic cannot begin in column 1 or it will be interpreted as a label. Mnemonic opcodes and assembler directive names without the . prefix are valid label names. Remember to always use whitespace before the mnemonic, or the assembler will think the identifier is a new label definition. + +### 4.7.3 Local Labels + +Local labels are special labels whose scope and effect are temporary. A local label can be defined in two ways: + +- \$n, where n is a decimal digit in the range 0-9. For example, \$4 and \$1 are valid local labels. See Example 4-1. +- *name*?, where *name* is any legal identifier as described above. The assembler replaces the question mark with a period followed by a unique number. When the source code is expanded, *you will not see the unique number in the listing file*. Your label appears with the question mark as it did in the source definition. + +You cannot declare these types of labels as global. + +Normal labels must be unique (they can be declared only once), and they can be used as constants in the operand field. Local labels, however, can be undefined and defined again. Local labels cannot be defined by directives. + +A local label can be undefined or reset in one of these ways: + +- By using the .newblock directive +- By changing sections (using a .sect, .text, or .data directive) +- By entering an include file (specified by the .include or .copy directive) +- By leaving an include file (specified by the .include or .copy directive) + +#### Example 4-1. Local Labels of the Form \$n + +``` +This is an example of code that declares and uses a local label legally: + QBEQ $1, r14, 0 + ADD r14, r14, 1 +$1: + .newblock + QBEQ $1, r15, 0 + ADD r15, r15, 1 +$1: + JMP r3.w2 +The following code uses a local label illegally: + QBEQ $1, r14, 0 + ADD r14, r14, 1 +$1: + QBEQ $1, r15, 0 +``` + +### Example 4-1. Local Labels of the Form \$n (continued) + +``` +ADD r15, r15, 1 +$1: + JMP r3.w2 +``` + +The \$1 label is not undefined before being reused by the second branch instruction. Therefore, \$1 is redefined, which is illegal. + +Local labels are especially useful in macros. If a macro contains a normal label and is called more than once, the assembler issues a multiple-definition error. If you use a local label and .newblock within a macro, however, the local label is used and reset each time the macro is expanded. + +Up to ten local labels of the \$n form can be in effect at one time. Local labels of the form name? are not limited. After you undefine a local label, you can define it and use it again. Local labels do not appear in the object code symbol table. + +For more information about using labels in macros see Section 6.6. + +### 4.7.4 Symbolic Constants + +A symbolic constant is a symbol with a value that is an absolute constant expression (see Section 4.8). By using symbolic constants, you can assign meaningful names to constant expressions. The .set and .struct/.tag/.endstruct directives enable you to set symbolic constants (see Define Assembly-Time Constant). Once defined, symbolic constants *cannot* be redefined. + +If you use the .set directive to assign a value to a symbol , the symbol becomes a symbolic constant and may be used where a constant expression is expected. For example: + +``` +shift3 .set 3 + LDI R0, shift3 +``` + +You can also use the .set directive to assign symbolic constants for other symbols, such as register names. In this case, the symbolic constant becomes a synonym for the register: + +``` +AuxR1 .set R1 + LBBO &AuxR1, R2, 0, 4 +``` + +The following example shows how the .set directive can be used with the .struct, .tag. and .endstruct directives. It creates the symbolic constants K, maxbuf, item, value, delta, and i\_len. + +``` +K .set 1024 ;constant definitions +maxbuf .set 2*K +item .struct ;item structure definition + .int value ;constant offsets value = 0 + .int delta ;constant offsets delta = 1 +i_len .endstruct +array .tag item ;array declaration + .bss array, i_len*K +``` + +The assembler also has many predefined symbolic constants; these are discussed in Section 4.7.6. + +### 4.7.5 Defining Symbolic Constants (--asm\_define Option) + +The --asm\_define option equates a constant value or a string with a symbol. The symbol can then be used in place of a value in assembly source. The format of the --asm\_define option is as follows: + +``` +clpru --asm_define=name[=value] +``` + +The *name* is the name of the symbol you want to define. The *value* is the constant or string value you want to assign to the symbol. If the *value* is omitted, the symbol is set to 1. If you want to define a quoted string and keep the quotation marks, do one of the following: + +- For Windows, use **--asm\_define=** *name* **="\"** *value* **\""**. For example, --asm\_define=car="\"sedan\"" +- For UNIX, use **--asm\_define=** *name* **='"** *value* **"'**. For example, --asm\_define=car='"sedan"' +- For Code Composer, enter the definition in a file and include that file with the --cmd\_file (or -@) option. + +Once you have defined the name with the --asm\_define option, the symbol can be used with assembly directives and instructions as if it had been defined with the .set directive. For example, on the command line you enter: + +``` +clpru --asm_define=SYM1=1 --asm_define=SYM2=2 --asm_define=SYM3=3 --asm_define=SYM4=4 value.asm +``` + +Since you have assigned values to SYM1, SYM2, SYM3, and SYM4, you can use them in source code. Example 4-2 shows how the value.asm file uses these symbols without defining them explicitly. + +Within assembler source, you can test the symbol defined with the --asm\_define option with these directives: + +| Type of Test | Directive Usage | +|--------------------|-----------------------------| +| Existence | .if \$isdefed(" name ") | +| Nonexistence | .if \$isdefed(" name ") = 0 | +| Equal to value | .if name = value | +| Not equal to value | .if name != value | + +The argument to the \$isdefed built-in function must be enclosed in quotes. The quotes cause the argument to be interpreted literally rather than as a substitution symbol. + +### Example 4-2. Using Symbolic Constants Defined on Command Line + +``` +IF_4: .if SYM4 = SYM2 * SYM2 + .byte SYM4 ; Equal values + .else + .byte SYM2 * SYM2 ; Unequal values + .endif +IF_5: .if SYM1 <= 10 + .byte 10 ; Less than / equal + .else + .byte SYM1 ; Greater than + .endif +IF_6: .if SYM3 * SYM2 != SYM4 + SYM2 + .byte SYM3 * SYM2 ; Unequal value + .else + .byte SYM4 + SYM4 ; Equal values + .endif +IF_7: .if SYM1 = SYM2 + .byte SYM1 + .elseif SYM2 + SYM3 = 5 + .byte SYM2 + SYM3 + .endif +``` + +### 4.7.6 Predefined Symbolic Constants + +The assembler has several types of predefined symbols. + +**\$**, the dollar-sign character, represents the current value of the section program counter (SPC). + +In addition, the following predefined processor symbolic constants are available: + +**Table 4-2. PRU Processor Symbolic Constants** + +| Macro Name | Description | | | | | | +|---------------|----------------------------------------------------------------------------------------------------------------------|--|--|--|--|--| +| PRU | Always set to 1. | | | | | | +| PRU_V0 | Set to 1 if the silicon version is 0; otherwise, set to 0. | | | | | | +| PRU_V1 | Set to 1 if the silicon version is 1; otherwise, set to 0. | | | | | | +| PRU_V2 | Set to 1 if the silicon version is 2; otherwise, set to 0. | | | | | | +| PRU_V3 | Set to 1 if the silicon version is 3; otherwise, set to 0. | | | | | | +| TI_EABI | Always set to 1. | | | | | | +| BIG_ENDIAN | Set to 1 if big-endian mode is selected (theendian=big option is used); otherwise, set to 0. | | | | | | +| LITTLE_ENDIAN | Set to 1 if little-endian mode is selected (the default or theendian=little option is used); otherwise, set
to 0. | | | | | | + +### 4.7.7 Registers + +The names of PRU registers are register symbols, including R0-R15. There are no register aliases for the PRU registers. + +Register symbols can be entered as all uppercase or all lowercase characters.For example, R13 could also be entered as r13. + +Control register symbols can be entered in all upper-case or all lower-case characters. + +See the "Register Conventions" section of the *PRU Optimizing C/C++ Compiler User's Guide* for details about the registers and their uses. + +### 4.7.8 Substitution Symbols + +Symbols can be assigned a string value. This enables you to create aliases for character strings by equating them to symbolic names. Symbols that represent character strings are called substitution symbols. When the assembler encounters a substitution symbol, its string value is substituted for the symbol name. Unlike symbolic constants, substitution symbols can be redefined. + +A string can be assigned to a substitution symbol anywhere within a program; for example: + +``` +.asg "R2", stack-pointer + ; Assigns the string R2 to the substitution symbol stack-pointer. +.asg "0x20", block2 + ; Assigns the string 0x20 to the substitution symbol block2. +ADD stack-pointer, stack-pointer, block2 + ; Adds the value in SP to 0x20 and stores the result in SP. +``` + +When you are using macros, substitution symbols are important because macro parameters are actually substitution symbols that are assigned a macro argument. The following code shows how substitution symbols are used in macros: + +``` +sign_extend_32_8 .macro dest, src + .newblock + MOV dest, src + ; zero extends src into dest + QBBC $1, dest, 7 + FILL &dest.b1, 3 +$1: + .endm +``` + +See Chapter 6 for more information about macros. + +## 4.8 Expressions + +Nearly all values and operands in assembly language are *expressions*, which may be any of the following: + +- a literal constant +- a register +- a register pair +- a memory reference +- a symbol +- a built-in function invocation +- a mathematical or logical operation on one or more expressions + +This section defines several types of expressions that are referred to throughout this document. Some instruction operands accept limited types of expressions. For example, the .if directive requires its operand be an absolute constant expression with an integer value. Absolute in the context of assembly code means that the value of the expression must be known at assembly time. + +A *constant expression* is any expression that does not in any way refer to a register or memory reference. An *immediate operand* will usually not accept a register or memory reference. It must be given a constant expression. Constant expressions may be any of the following: + +- a literal constant +- an address constant expression +- a symbol whose value is a constant expression +- a built-in function invocation on a constant expression +- a mathematical or logical operation on one or more constant expressions + +An *address constant expression* is a special case of a constant expression. Some immediate operands that require an address value can accept a symbol plus an addend; for example, some branch instructions. The symbol must have a value that is an address, and it may be an external symbol. The addend must be an absolute constant expression with an integer value. For example, a valid address constant expression is "array+4". + +A constant expression may be absolute or relocatable. *Absolute* means known at assembly time. *Relocatable* means constant, but not known until link time. External symbols are relocatable, even if they refer to a symbol defined in the same module. + +An *absolute constant expression* may not refer to any external symbols anywhere in the expression. In other words, an absolute constant expression may be any of the following: + +- a literal constant +- an absolute address constant expression +- a symbol whose value is an absolute constant expression +- a built-in function invocation whose arguments are all absolute constant expressions +- a mathematical or logical operation on one or more absolute constant expressions + +A *relocatable constant expression* refers to at least one external symbol. Such expressions may contain at most one external symbol. A relocatable constant expression may be any of the following: + +- an external symbol +- a relocatable address constant expression +- a symbol whose value is a relocatable constant expression +- a built-in function invocation with any arguments that are relocatable constant expressions +- a mathematical or logical operation on one or more expressions, at least one of which is a relocatable constant expression + +In some cases, the value of a relocatable address expression may be known at assembly time. For example, a relative displacement branch may branch to a label defined in the same section. + +### 4.8.1 Mathematical and Logical Operators + +The operands of a mathematical or logical operator must be well-defined expressions. That is, you must use the correct number of operands and the operation must make sense. For example, you cannot take the XOR of a floating-point value. In addition, well-defined expressions contain only symbols or assemblytime constants that have been defined before they occur in the directive's expression. + +Three main factors influence the order of expression evaluation: + +**Parentheses** Expressions enclosed in parentheses are always evaluated first. + +8 / (4 / 2) = 4, but 8 / 4 / 2 = 1 + +You *cannot* substitute braces ( { } ) or brackets ( [ ] ) for parentheses. + +**Precedence groups** Operators, listed in Table 4-3, are divided into nine precedence groups. When parentheses do not determine the order of expression evaluation, the highest precedence operation is evaluated first. + +8 + 4 / 2 = 10 (4 / 2 is evaluated first) + +**Left-to-right evaluation** When parentheses and precedence groups do not determine the order of expression evaluation, the expressions are evaluated from left to right, except for Group 1, which is evaluated from right to left. + +8 / 4\*2 = 4, but 8 / (4\*2) = 1 + +Table 4-3 lists the operators that can be used in expressions, according to precedence group. + +**Table 4-3. Operators Used in Expressions (Precedence)** + +| Group(1) | Operator | Description(2) | +|----------|----------|----------------------------| +| 1 | + | Unary plus | +| | - | Unary minus | +| | ~ | 1s complement | +| | ! | Logical NOT | +| 2 | * | Multiplication | +| | / | Division | +| | % | Modulo | +| 3 | + | Addition | +| | - | Subtraction | +| 4 | << | Shift left | +| | >> | Shift right | +| 5 | < | Less than | +| | <= | Less than or equal to | +| | > | Greater than | +| | >= | Greater than or equal to | +| 6 | =[=] | Equal to | +| | != | Not equal to | +| 7 | & | Bitwise AND | +| 8 | ^^ | Bitwise exclusive OR (XOR) | +| 9 | \| | Bitwise OR | + +(1) Group 1 operators are evaluated right to left. All other operators are evaluated left to right. + +The assembler checks for overflow and underflow conditions when arithmetic operations are performed during assembly. It issues a warning (the "value truncated" message) whenever an overflow or underflow occurs. The assembler *does not* check for overflow or underflow in multiplication. + +(2) Unary + and - have higher precedence than the binary forms. + +### 4.8.2 Relational Operators and Conditional Expressions + +The assembler supports relational operators that can be used in any expression; they are especially useful for conditional assembly. Relational operators include the following: + +- **=** Equal to +- **!=** Not equal to +- **<** Less than +- **<=** Less than or equal to +- **>** Greater than +- **>=** Greater than or equal to + +Conditional expressions evaluate to 1 if true and 0 if false and can be used only on operands of equivalent types; for example, absolute value compared to absolute value, but not absolute value compared to relocatable value. + +### 4.8.3 Well-Defined Expressions + +Some assembler directives, such as .if, require well-defined absolute constant expressions as operands. Well-defined expressions contain only symbols or assembly-time constants that have been defined before they occur in the directive's expression. In addition, they must use the correct number of operands and the operation must make sense. The evaluation of a well-defined expression must be unambiguous. + +This is an example of a well-defined expression: + +1000h+X + +where X was previously defined as an absolute symbol. + +### 4.8.4 Relocatable Symbols and Legal Expressions + +All legal expressions can be reduced to one of two forms: + +*relocatable symbol* ± *absolute symbol* + +or + +*absolute value* + +Unary operators can be applied only to absolute values; they cannot be applied to relocatable symbols. Expressions that cannot be reduced to contain only one relocatable symbol are illegal. + +Table 4-4 summarizes valid operations on absolute, relocatable, and external symbols. An expression cannot contain multiplication or division by a relocatable or external symbol. An expression cannot contain unresolved symbols that are relocatable to other sections. + +Symbols that have been defined as global with the .global directive can also be used in expressions; in Table 4-4, these symbols are referred to as *external*. + +**Table 4-4. Expressions With Absolute and Relocatable Symbols** + +| If A is and | If B is , then | A + B is and | A - B is | +|-------------|----------------|--------------|-------------| +| absolute | absolute | absolute | absolute | +| absolute | relocatable | relocatable | illegal | +| absolute | external | external | illegal | +| relocatable | absolute | relocatable | relocatable | +| relocatable | relocatable | illegal | absolute(1) | +| relocatable | external | illegal | illegal | +| external | absolute | external | external | +| external | relocatable | illegal | illegal | +| external | external | illegal | illegal | + +(1) A and B must be in the same section; otherwise, adding relocatable symbols to relocatable symbols is illegal. + +### 4.8.5 Expression Examples + +Following are examples of expressions that use relocatable and absolute symbols. These examples use four symbols that are defined in the same section: + +``` +.global extern_1 ; Defined in an external module +intern_1: .word '"D' ; Relocatable, defined in current + ; module +LAB1: .set 2 ; LAB1 = 2 +intern_2 ; Relocatable, defined in current + ; module +intern_3 ; Relocatable, defined in current + ; module +``` + +### • **Example 1** + +The statements in this example use an absolute symbol, LAB1, which is defined to have a value of 2. The first statement loads the value 51 into R0. The second statement loads the value 27 into R0. + +``` +LDI R0, LAB1 + ((4+3) * 7) ; R0 = 51 + ; 2 + ((7) * 7) + ; 2 + (49) = 51 +LDI R0, LAB1 + 4 + (3*7) ; R0 = 27 + ; 2 + 4 + (21) = 27 +``` + +### • **Example 2** + +The first statement in the following example is valid; the statements that follow it are invalid. + +``` +LDI R1, intern_1 - 10 ; Legal +LDI R1, 10-intern_1 ; Can't negate reloc. symbol +LDI R1, -(intern_1) ; Can't negate reloc. symbol +LDI R1, intern_1/10 ; / isn't additive operator +LDI R1, intern_1 + intern_2 ; Multiple relocatables +``` + +### • **Example 3** + +The first statement below is legal; although intern\_1 and intern\_2 are relocatable, their difference is absolute because they are in the same section. Subtracting one relocatable symbol from another reduces the expression to *relocatable symbol + absolute value*. The second statement is illegal because the sum of two relocatable symbols is not an absolute value. + +``` +LDR R1, intern_1 - intern_2 + intern_3 ; Legal +LDR R1, intern_1 + intern_2 + intern_3 ; Illegal +``` + +### • **Example 4** + +A relocatable symbol's placement in the expression is important to expression evaluation. Although the statement below is similar to the first statement in the previous example, it is illegal because of left-toright operator precedence; the assembler attempts to add intern\_1 to extern\_3. + +``` +LDR R1, intern_1 + intern_3 - intern_2 ; Illegal +``` + +## 4.9 Built-in Functions and Operators + +The assembler supports built-in mathematical functions and built-in addressing operators. + +The built-in substitution symbol functions are discussed in Section 6.3.2. + +### 4.9.1 Built-In Math and Trigonometric Functions + +The assembler supports built-in functions for conversions and various math computations. Table 4-5 describes the built-in functions. The *expr* must be a constant value. + +**Table 4-5. Built-In Mathematical Functions** + +| Function | Description | +|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| +| \$acos(expr) | Returns the arccosine of expr as a floating-point value| +| \$asin(expr) | Returns the arcsine of expr as a floating-point value| +| \$atan(expr) | Returns the arctangent of expr as a floating-point value| +| \$atan2(expr, y) | Returns the arctangent of expr as a floating-point value in range [-π, π]| +| \$ceil(expr) | Returns the smallest integer not less than expr| +| \$cos(expr) | Returns the cosine of expr as a floating-point value| +| \$cosh(expr) | Returns the hyperbolic cosine of expr as a floating-point value| +| \$cvf(expr) | Converts expr to a floating-point value| +| \$cvi(expr) | converts expr to integer value| +| \$exp(expr) | Returns the exponential function eexpr | +| \$fabs(expr) | Returns the absolute value of expr as a floating-point value| +| \$floor(expr) | Returns the largest integer not greater than expr| +| \$fmod(expr, y) | Returns the remainder of expr1 ÷ expr2| +| \$int(expr) | Returns 1 if expr has an integer value; else returns 0. Returns an integer.| +| \$ldexp(expr, expr2) | Multiplies expr by an integer power of 2. That is, expr1 × 2expr2 | +| \$log(expr) | Returns the natural logarithm of expr, where expr>0| +| \$log10(expr) | Returns the base 10 logarithm of expr, where expr>0| +| \$max(expr1, expr2) | Returns the maximum of two values| +| \$min(expr1, expr2) | Returns the minimum of two values| +| \$pow(expr1, expr2) | Returns expr1 raised to the power of expr2| +| \$round(expr) | Returns expr rounded to the nearest integer| +| \$sgn(expr) | Returns the sign of expr.| +| \$sin(expr) | Returns the sine of expr| +| \$sinh(expr) | Returns the hyperbolic sine of expr as a floating-point value| +| \$sqrt(expr) | Returns the square root of expr, expr≥0, as a floating-point value| +| \$strtod(str) | Converts a character string to a double precision floating-point value. The string contains a properly
formatted C99-style floating-point literal.| +| \$tan(expr) | Returns the tangent of expr as a floating-point value| +| \$tanh(expr) | Returns the hyperbolic tangent of expr as a floating-point value| +| \$trunc(expr) | Returns expr rounded toward 0| + +## 4.10 Source Listings + +A source listing shows source statements and the object code they produce. To obtain a listing file, invoke the assembler with the --asm\_listing option (see Section 4.3). + +Two banner lines, a blank line, and a title line are at the top of each source listing page. Any title supplied by the .title directive is printed on the title line. A page number is printed to the right of the title. If you do not use the .title directive, the name of the source file is printed. The assembler inserts a blank line below the title line. + +Each line in the source file produces at least one line in the listing file. This line shows a source statement number, an SPC value, the object code assembled, and the source statement. Figure 4-2 shows these in an actual listing file. + +### Field 1: Source Statement Number + +#### Line number + +The source statement number is a decimal number. The assembler numbers source lines as it encounters them in the source file; some statements increment the line counter but are not listed. (For example, .title statements and statements following a .nolist are not listed.) The difference between two consecutive source line numbers indicates the number of intervening statements in the source file that are not listed. + +#### Include file letter + +A letter preceding the line number indicates the line is assembled from the include file designated by the letter. + +#### Nesting level number + +A number preceding the line number indicates the nesting level of macro expansions or loop blocks. + +### Field 2: Section Program Counter + +This field contains the SPC value, which is hexadecimal. All sections (.text, .data, .bss, and named sections) maintain separate SPCs. Some directives do not affect the SPC and leave this field blank. The --code\_address\_listing\_unit={ byte | word } assembler option changes the unit used for the code section program counter field in the assembler listing file. By default bytes are used. Note that this option applies to code sections, but not to data sections. + +### Field 3: Object Code + +This field contains the hexadecimal representation of the object code. All machine instructions and directives use this field to list object code. This field also indicates the relocation type associated with an operand for this line of source code. If more than one operand is relocatable, this column indicates the relocation type for the first operand. The characters that can appear in this column and their associated relocation types are listed below: + +- ! undefined external reference +- **'**.text relocatable +- + .sect relocatable +- " .data relocatable +- .bss, .usect relocatable +- % relocation expression + +### Field 4: Source Statement Field + +This field contains the characters of the source statement as they were scanned by the assembler. The assembler accepts a maximum line length of 200 characters. Spacing in this field is determined by the spacing in the source statement. + +Figure 4-2 shows an assembler listing with each of the four fields identified. + +![Figure 4-2: Example Assembler Listing — annotated assembly listing showing the four fields: line/nesting number (Field 1), SPC in hex (Field 2), object code in hex (Field 3), source statement text (Field 4)](_page_59_Figure_4.jpeg) + +**Figure 4-2: Example Assembler Listing.** Annotated assembler listing output showing the four fields: Field 1 (source statement number, optionally preceded by an include-file letter or a macro nesting-level digit), Field 2 (section program counter in hexadecimal), Field 3 (assembled object code in hexadecimal), and Field 4 (source statement text as scanned). The example listing defines a `sign_extend_32_8` macro (lines 1–10), then at line 15 expands it as `sign_extend_32_8 R14, R14.b0`; the macro-expanded instructions (lines shown with nesting-level digit "1" in Field 1) appear with their SPC values and assembled object-code words. + +## 4.11 Debugging Assembly Source + +By default, when you compile an assembly file, the assembler provides symbolic debugging information that allows you to step through your assembly code in a debugger rather than using the Disassembly window in Code Composer Studio. This enables you to view source comments and other source-code annotations while debugging. The default has the same behavior as using the --symdebug:dwarf option. You can disable the generation of debugging information by using the --symdebug:none option. + +The .asmfunc and .endasmfunc (see .asmfunc directive) directives enable you to use C characteristics in assembly code that makes the process of debugging an assembly file more closely resemble debugging a C/C++ source file. + +The .asmfunc and .endasmfunc directives allow you to name certain areas of your code, and make these areas appear in the debugger as C functions. Contiguous sections of assembly code that are not enclosed by the .asmfunc and .endasmfunc directives are automatically placed in assembler-defined functions named with this syntax: + +``` +$ filename : starting source line : ending source line $ +``` + +If you want to view your variables as a user-defined type in C code, the types must be declared and the variables must be defined in a C file. This C file can then be referenced in assembly code using the .ref directive (see .ref directive). Example 4-3 shows the cvar.c C program that defines a variable, svar, as the structure type X. The svar variable is then referenced in the addfive.asm assembly program in Example 4-4 and 5 is added to svar's second data member. + +Compile both source files with the --symdebug:dwarf option (-g) and link them as follows: + +``` +clpru --symdebug:dwarf cvars.c addfive.asm --run_linker --library=lnk.cmd -- +library=rtspruv3_le.lib + --output_file=addfive.out +``` + +When you load this program into a symbolic debugger, addfive appears as a C function. You can monitor the values in svar while stepping through main just as you would any regular C variable. + +### Example 4-3. Viewing Assembly Variables as C Types C Program + +``` +typedef struct { + int m1; + int m2; +} X; +X svar = { 1, 2 }; +``` + +### Example 4-4. Assembly Program for Example 4-3 + +``` +;------------------------------------------------------------------------------------- +; Tell assembler we're referencing "svar", which is defined in another file (cvars.c). +;------------------------------------------------------------------------------------- + .ref svar +;------------------------------------------------------------------------------ +; addfive() - Add five to the second data member of svar +;------------------------------------------------------------------------------ + .sect ".text:addfive" + .global addfive +addfive: .asmfunc + LDI r0, svar+4 + LBBO &r1, r0, 0, 4 + ADD r1, r1, 0x05 + SBBO &r1, r0, 0, 4 + JMP r3.w2 + .endasmfunc +``` + +## 4.12 Cross-Reference Listings + +A cross-reference listing shows symbols and their definitions. To obtain a cross-reference listing, invoke the assembler with the --asm\_listing\_cross\_reference option (see Section 4.3) or use the .option directive with the X operand (see Select Listing Options\). The assembler appends the cross-reference to the end of the source listing. Example 4-5 shows the four fields contained in the cross-reference listing. + +*Example 4*‑*5. An Assembler Cross-Reference Listing* + +| LABEL | VALUE | DEFN | REF | +|------------------------------|------------|------|----------| +| BIG_ENDIAN | 00000000 | 0 | | +| LITTLE_ENDIAN | 00000001 | 0 | | +| PRU_V0 | 00000000 | 0 | | +| PRU_V1 | 00000000 | 0 | | +| PRU_V2 | 00000000 | 0 | | +| PRU_V3 | 00000000 | 0 | | +| PRU | 00000001 | 0 | | +| TI_ASSEMBLER_VERSION_QUAL_ID | 00003760 | 0 | | +| TI_ASSEMBLER_VERSION_QUAL | 00000049 | 0 | | +| TI_ASSEMBLER_VERSION | 001e8868 | 0 | | +| TI_EABI | 00000001 | 0 | | +| aloop | 00000010' | 38 | 38 38 | +| buffer | 00000000- | 10 | | +| coeff | 00000000" | 5 | | +| gptr | REF | | 14 14 40 | +| inbuf | 00000001- | 31 | | +| ivals | 00000010" | 26 | | +| l1 | 00000004' | 21 | 21 21 | +| ptr | 0000000c" | 14 | | +| var2 | 00000000- | 30 | | + +**Label** column contains each symbol that was defined or referenced during the assembly. **Value** column contains an 8-digit hexadecimal number (which is the value assigned to the symbol) *or* a name that describes the symbol's attributes. A value may also be preceded by a character that describes the symbol's attributes. Table 4-6 lists these characters and names. + +**Definition** (DEFN) column contains the statement number that defines the symbol. This column is blank for undefined symbols. + +**Reference** (REF) column lists the line numbers of statements that reference the symbol. A blank in this column indicates that the symbol was never used. + +**Table 4-6. Symbol Attributes** + +| Character or Name | Meaning | +|-------------------|--------------------------------------------| +| REF | External reference (global symbol) | +| UNDF | Undefined | +| ' | Symbol defined in a .text section | +| " | Symbol defined in a .data section | +| + | Symbol defined in a .sect section | +| - | Symbol defined in a .bss or .usect section | + +# 5 Assembler Directives + +Assembler directives supply data to the program and control the assembly process. Assembler directives enable you to do the following: + +- Assemble code and data into specified sections +- Reserve space in memory for uninitialized variables +- Control the appearance of listings +- Initialize memory +- Assemble conditional blocks +- Define global variables +- Specify libraries from which the assembler can obtain macros +- Examine symbolic debugging information + +This chapter is divided into two parts: the first part \(Section 5.1 through Section 5.11) describes the directives according to function, and the second part \(Section 5.12) is an alphabetical reference. + +**Topic** ........................................................................................................................... **Page** + +| 5.1 | Directives Summary | 64 | +|------|-----------------------------------------------------|----| +| 5.2 | Directives that Define Sections | 68 | +| 5.3 | Directives that Initialize Values | 69 | +| 5.4 | Directives that Perform Alignment and Reserve Space | 72 | +| 5.5 | Directives that Format the Output Listings | 73 | +| 5.6 | Directives that Reference Other Files | 74 | +| 5.7 | Directives that Enable Conditional Assembly | 75 | +| 5.8 | Directives that Define Union or Structure Types | 75 | +| 5.9 | Directives that Define Enumerated Types | 76 | +| 5.10 | Directives that Define Symbols at Assembly Time | 76 | +| 5.11 | Miscellaneous Directives | 77 | +| 5.12 | Directives Reference | 78 | +| | | | + +## 5.1 Directives Summary + +Table 5-1 through Table 5-15 summarize the assembler directives. + +Besides the assembler directives documented here, the PRU software tools support the following directives: + +- Macro directives are discussed in Chapter 6; they are not discussed in this chapter. +- The C compiler uses directives for symbolic debugging. Unlike other directives, symbolic debugging directives are not used in most assembly language programs. Appendix A discusses these directives; they are not discussed in this chapter. + +### Labels and Comments Are Not Shown in Syntaxes + +**NOTE:** Most source statements that contain a directive can also contain a label and a comment. Labels begin in the first column (only labels and comments can appear in the first column), and comments must be preceded by a semicolon, or an asterisk if the comment is the only element in the line. To improve readability, labels and comments are not shown as part of the directive syntax here. See the detailed description of each directive for using labels with directives. + +**Table 5-1. Directives that Control Section Use** + +| Mnemonic and Syntax | Description | See | +|-----------------------------------------------------------------------------|--------------------------------------------------------------|--------------| +| .bss symbol, size in bytes[, alignment
[, bank offset]] | Reserves size bytes in the .bss (uninitialized data) section | .bss topic | +| .data | Assembles into the .data (initialized data) section | .data topic | +| .sect "section name" | Assembles into a named (initialized) section | .sect topic | +| .text | Assembles into the .text (executable code) section | .text topic | +| symbol .usect "section name", size in bytes
[, alignment[, bank offset]] | Reserves size bytes in a named (uninitialized) section | .usect topic | + +**Table 5-2. Directives that Affect Unused Section Elimination** + +| Mnemonic and Syntax | Description | See | +|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|---------------| +| .retain "section name" | Instructs the linker to include the current or specified section in the
linked output file, regardless of whether the section is referenced or
not | .retain topic | +| .retainrefs "section name" | Instructs the linker to include any data object that references the
current or specified section. | .retain topic | + +**Table 5-3. Directives that Initialize Values (Data and Memory)** + +| Mnemonic and Syntax | Description | See | +|-----------------------------------------------------------|------------------------------------------------------------------------------------|---------------| +| .bits value1
[, , valuen
] | Initializes one or more successive bits in the current section | .bits topic | +| .byte value1
[, , valuen
] | Initializes one or more successive bytes in the current section | .byte topic | +| .char value1
[, , valuen
] | Initializes one or more successive bytes in the current section | .char topic | +| .cstring {expr1
"string1"}[, , {exprn
"stringn"}] | Initializes one or more text strings | .string topic | +| .double value1
[, , valuen
] | Initializes one or more 64-bit, IEEE double-precision, floating-point
constants | .double topic | +| .field value[, size] | Initializes a field of size bits (1-32) with value | .field topic | +| .float value1
[, , valuen
] | Initializes one or more 32-bit, IEEE single-precision, floating-point
constants | .float topic | +| .half value1
[, , valuen
] | Initializes one or more 16-bit integers (halfword) | .half topic | +| .int value1
[, , valuen
] | Initializes one or more 32-bit integers | .int topic | +| .long value1
[, , valuen
] | Initializes one or more 32-bit integers | .long topic | +| .short value1
[, , valuen
] | Initializes one or more 16-bit integers (halfword) | .short topic | + +### Table 5-3. Directives that Initialize Values (Data and Memory) (continued) + +| Mnemonic and Syntax | Description | See | +|----------------------------------------------------------|-----------------------------------------------------------------------------|---------------| +| .string {expr1
"string1"}[, , {exprn
"stringn"}] | Initializes one or more text strings | .string topic | +| .ubyte value1
[, , valuen
] | Initializes one or more successive unsigned bytes in the current
section | .ubyte topic | +| .uchar value1
[, , valuen
] | Initializes one or more successive unsigned bytes in the current
section | .uchar topic | +| .uhalf value1
[, , valuen
] | Initializes one or more unsigned 16-bit integers (halfword) | .uhalf topic | +| .uint value1
[, , valuen
] | Initializes one or more unsigned 32-bit integers | .uint topic | +| .ulong value1
[, , valuen
] | Initializes one or more unsigned 32-bit integers | .long topic | +| .ushort value1
[, , valuen
] | Initializes one or more unsigned 16-bit integers (halfword) | .short topic | +| .uword value1
[, , valuen
] | Initializes one or more unsigned 32-bit integers | .uword topic | +| .word value1
[, , valuen
] | Initializes one or more 32-bit integers | .word topic | + +## Table 5-4. Directives that Perform Alignment and Reserve Space + +| Mnemonic and Syntax | Description | See | +|------------------------|-------------------------------------------------------------------------------------------------------------------|--------------| +| .align [size in bytes] | Aligns the SPC on a boundary specified by size in bytes, which
must be a power of 2; defaults to byte boundary | .align topic | +| .bes size | Reserves size bytes in the current section; a label points to the end
of the reserved space | .bes topic | +| .space size | Reserves size bytes in the current section; a label points to the
beginning of the reserved space | .space topic | + +## Table 5-5. Directives that Format the Output Listing + +| Mnemonic and Syntax | Description | See | +|-------------------------------------|-------------------------------------------------------------------------------------------|-----------------| +| .drlist | Enables listing of all directive lines (default) | .drlist topic | +| .drnolist | Suppresses listing of certain directive lines | .drnolist topic | +| .fclist | Allows false conditional code block listing (default) | .fclist topic | +| .fcnolist | Suppresses false conditional code block listing | .fcnolist topic | +| .length [page length] | Sets the page length of the source listing | .length topic | +| .list | Restarts the source listing | .list topic | +| .mlist | Allows macro listings and loop blocks (default) | .mlist topic | +| .mnolist | Suppresses macro listings and loop blocks | .mnolist topic | +| .nolist | Stops the source listing | .nolist topic | +| .option option1
[, option2
,] | Selects output listing options; available options are A, B, H, M, N,
O, R, T, W, and X | .option topic | +| .page | Ejects a page in the source listing | .page topic | +| .sslist | Allows expanded substitution symbol listing | .sslist topic | +| .ssnolist | Suppresses expanded substitution symbol listing (default) | .ssnolist topic | +| .tab size | Sets tab to size characters | .tab topic | +| .title "string" | Prints a title in the listing page heading | .title topic | +| .width [page width] | Sets the page width of the source listing | .width topic | + +### Table 5-6. Directives that Reference Other Files + +| Mnemonic and Syntax | Description | See | +|-------------------------|--------------------------------------------------------------------|----------------| +| .copy ["]filename["] | Includes source statements from another file | .copy topic | +| .include ["]filename["] | Includes source statements from another file | .include topic | +| .mlib ["]filename["] | Specifies a macro library from which to retrieve macro definitions | .mlib topic | + +### Table 5-7. Directives that Affect Symbol Linkage and Visibility + +| Mnemonic and Syntax | Description | See | +|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|------------------| +| .common symbol, size in bytes [, alignment]r
.common symbol, structure tag [, alignment] | Defines a common symbol for a variable. | .common topic | +| .def symbol1
[, , symboln
] | Identifies one or more symbols that are defined in the current
module and that can be used in other modules | .def topic | +| .global symbol1
[, , symboln
] | Identifies one or more global (external) symbols | .global topic | +| .ref symbol1
[, , symboln
] | Identifies one or more symbols used in the current module that are
defined in another module | .ref topic | +| .symdepend dst symbol name[, src symbol name] | Creates an artificial reference from a section to a symbol | .symdepend topic | +| .weak symbol name | Identifies a symbol used in the current module that is defined in
another module | .weak topic | + +## Table 5-8. Directives that Enable Conditional Assembly + +| Mnemonic and Syntax | Description | See | +|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------| +| .if condition | Assembles code block if the condition is true | .if topic | +| .else | Assembles code block if the .if condition is false. When using the .if
construct, the .else construct is optional. | .else topic | +| .elseif condition | Assembles code block if the .if condition is false and the .elseif
condition is true. When using the .if construct, the .elseif construct
is optional. | .elseif topic | +| .endif | Ends .if code block | .endif topic | +| .loop [count] | Begins repeatable assembly of a code block; the loop count is
determined by the count. | .loop topic | +| .break [end condition] | Ends .loop assembly if end condition is true. When using the .loop
construct, the .break construct is optional. | .break topic | +| .endloop | Ends .loop code block | .endloop topic | + +### Table 5-9. Directives that Define Structure Types + +| Mnemonic and Syntax | Description | See | +|---------------------|----------------------------------------------------------------------------------------------|--------------------------------| +| .cstruct | Acts like .struct, but adds padding and alignment like that which is
done to C structures | .cstruct topic | +| .cunion | Acts like .union, but adds padding and alignment like that which is
done to C unions | .cunion topic | +| .emember | Sets up C-like enumerated types in assembly code | Section 5.9 | +| .endenum | Sets up C-like enumerated types in assembly code | Section 5.9 | +| .endstruct | Ends a structure definition | .struct topic | +| .endunion | Ends a union definition | .cunion topic,
.union topic | +| .enum | Sets up C-like enumerated types in assembly code | Section 5.9 | +| .union | Begins a union definition | .union topic | +| .sassign | Map a defined structure onto the PRU registers | .sassign topic | +| .struct | Begins structure definition | .struct topic | +| .tag | Assigns structure attributes to a label | .struct topic | + +### Table 5-10. Directives that Define Symbols + +| Mnemonic and Syntax | Description | See | +|-----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|------------| +| .asg ["]character string["], substitution symbol | Assigns a character string to substitution symbol. Substitution
symbols created with .asg can be redefined. | .asg topic | +| .define ["]character string["], substitution symbol | Assigns a character string to substitution symbol. Substitution
symbols created with .define cannot be redefined. | .asg topic | +| symbol .equ value | Equates value with symbol | .equ topic | + +## Table 5-10. Directives that Define Symbols (continued) + +| Mnemonic and Syntax | Description | See | +|-------------------------------------------|---------------------------------------------------------|-----------------| +| .elfsym name, SYM_SIZE(size | Provides ELF symbol information | .elfsym topic | +| .eval expression ,
substitution symbol | Performs arithmetic on a numeric substitution symbol | .eval topic | +| .newblock | Undefines local labels | .newblock topic | +| symbol .set value | Equates value with symbol | .set topic | +| .unasg symbol | Turns off assignment of symbol as a substitution symbol | .unasg topic | +| .undefine symbol | Turns off assignment of symbol as a substitution symbol | .unasg topic | + +## Table 5-11. Directives that Create or Affect Macros + +| Mnemonic and Syntax | | Description | See | +|---------------------|--------------------------------------|--------------------------------------------------------------|--------------| +| macname .macro | [parameter1
][, , parametern
] | Begin definition of macro named macname | .macro topic | +| .endm | | End macro definition | .endm topic | +| .mexit | | Go to .endm | Section 6.2 | +| .mlib filename | | Identify library containing macro definitions | .mlib topic | +| .var | | Adds a local substitution symbol to a macro's parameter list | .var topic | + +## Table 5-12. Directives that Control Diagnostics + +| Mnemonic and Syntax | Description | See | +|---------------------|----------------------------------------------------------------------------------|-------------| +| .emsg string | Sends user-defined error messages to the output device;
produces no .obj file | .emsg topic | +| .mmsg string | Sends user-defined messages to the output device | .mmsg topic | +| .wmsg string | Sends user-defined warning messages to the output device | .wmsg topic | + +## Table 5-13. Directives that Perform Assembly Source Debug + +| Mnemonic and Syntax | Description | See | +|---------------------|----------------------------------------------------------------------|----------------------| +| .asmfunc | Identifies the beginning of a block of code that contains a function | .asmfunc topic | +| .endasmfunc | Identifies the end of a block of code that contains a function | .endasmfunc
topic | + +### Table 5-14. Directives that Are Used by the Absolute Lister + +| Mnemonic and Syntax | Description | See | +|---------------------|------------------------------------------------|-----------| +| .setsect | Produced by absolute lister; sets a section | Chapter 9 | +| .setsym | Produced by the absolute lister; sets a symbol | Chapter 9 | + +## Table 5-15. Directives that Perform Miscellaneous Functions + +| Mnemonic and Syntax | Description | See | +|------------------------------------------------|---------------------------------------------|---------------| +| .cdecls [options ,]"filename"[, "filename2"[,] | Share C headers between C and assembly code | .cdecls topic | +| .end | Ends program | .end topic | + +In addition to the assembly directives that you can use in your code, the C/C++ compiler produces several directives when it creates assembly code. These directives are to be used only by the compiler; do not attempt to use these directives. + +- DWARF directives listed in Section A.1 +- The **.battr** directive is used to encode build attributes for the object file. +- The **.bound** directive is used internally. +- The **.comdat** directive is used internally. +- The **.compiler\_opts** directive indicates that the assembly code was produced by the compiler, and which build model options were used for this file. + +## 5.2 Directives that Define Sections + +These directives associate portions of an assembly language program with the appropriate sections: + +- The **.bss** directive reserves space in the .bss section for uninitialized variables. +- The **.data** directive identifies portions of code in the .data section. The .data section usually contains initialized data. +- The **.retain** directive can be used to indicate that the current or specified section must be included in the linked output. Thus even if no other sections included in the link reference the current or specified section, it is still included in the link. +- The **.retainrefs** directive can be used to force sections to refer to the specified section. +- The **.sect** directive defines an initialized named section and associates subsequent code or data with that section. A section defined with .sect can contain code or data. +- The **.text** directive identifies portions of code in the .text section. The .text section usually contains executable code. +- The **.usect** directive reserves space in an uninitialized named section. The .usect directive is similar to the .bss directive, but it allows you to reserve space separately from the .bss section. + +Chapter 2 discusses these sections in detail. + +Example 5-1 shows how you can use sections directives to associate code and data with the proper sections. This is an output listing; column 1 shows line numbers, and column 2 shows the SPC values. (Each section has its own program counter, or SPC.) When code is first placed in a section, its SPC equals 0. When you resume assembling into a section after other code is assembled, the section's SPC resumes counting as if there had been no intervening code. + +The directives in Example 5-1 perform the following tasks: + +**.text** initializes words with the values 1, 2, 3, 4, 5, 6, 7, and 8. + +**.data** initializes words with the values 9, 10, 11, 12, 13, 14, 15, and 16. + +**var\_defs** initializes words with the values 17 and 18. + +**.bss** reserves 19 bytes. **xy** reserves 20 bytes. + +The .bss and .usect directives do not end the current section or begin new sections; they reserve the specified amount of space, and then the assembler resumes assembling code or data into the current section. + +### Example 5-1. Sections Directives + +``` + 1 + 2 + 3 **************************************************** + * Start assembling into the .text section * + **************************************************** + 4 00000000 .text + 5 00000000 00000001 .word 1,2 + 00000004 00000002 + 6 00000008 00000003 .word 3,4 + 0000000c 00000004 + 7 + 8 **************************************************** + * Start assembling into the .data section * + **************************************************** + 9 +10 +11 00000000 .data +12 00000000 00000009 .word 9, 10 + 00000004 0000000A +13 00000008 0000000B .word 11, 12 + 0000000c 0000000C +14 +15 **************************************************** +16 * Start assembling into a named, * +17 * initialized section, var_defs * + **************************************************** +19 00000000 .sect "var_defs" +20 00000000 00000011 .word 17, 18 + 00000004 00000012 +21 +22 **************************************************** +23 * Resume assembling into the .data section * + **************************************************** +24 +25 00000010 .data +26 00000010 0000000D .word 13, 14 + 00000014 0000000E +27 00000000 .bss sym, 19 ; Reserve space in .bss +28 00000018 0000000F .word 15, 16 ; Still in .data + 0000001c 00000010 +29 +30 **************************************************** +31 * Resume assembling into the .text section * + **************************************************** +32 +33 00000010 .text +34 00000010 00000005 .word 5, 6 + 00000014 00000006 +35 00000000 usym .usect "xy", 20 ; Reserve space in xy +36 00000018 00000007 .word 7, 8 ; Still in .text + 0000001c 00000008 +``` + +### 5.3 Directives that Initialize Values + +Several directives assemble values for the current section. For example: + +- The .byte and .char directives place one or more 8-bit values into consecutive bytes of the current section. These directives are similar to .word, .int, and .long, except that the width of each value is restricted to 8 bits. +- The .double directive calculates the double-precision (64-bit) IEEE floating-point representation of one or more floating-point values and stores them in two consecutive words in the current section. The .double directive automatically aligns to the double-word boundary. +- The .field directive places a single value into a specified number of bits in the current word. With .field, you can pack multiple fields into a single word; the assembler does not increment the SPC until a word is filled. If a field will not fit in the space remaining in the current word, .field will insert zeros to fill the current word and then place the field in the next word. See the .field topic. + +Figure 5-1 shows how fields are packed into a word. Using the following assembled code, notice that the SPC does not change for the first three fields (the fields are packed into the same word): + +``` +1 00000000 60000000 .field 3, 3 +2 00000000 64000000 .field 8, 6 +3 00000000 64400000 .field 16, 5 +4 00000004 01234000 .field 01234h, 20 +5 00000008 00001234 .field 01234h, 32 +``` + +![Figure 5-1: The .field Directive — five bit-field diagrams showing progressive packing of values into a 32-bit word](_page_69_Figure_6.jpeg) + +**Figure 5-1: The .field Directive.** Five bit-field diagrams showing how `.field` packs consecutive fields into a single 32-bit word. (1) `.field 3,3` places the 3-bit value 3 (binary `011`) into bits 31–29. (2) `.field 8,6` appends a 6-bit value in bits 28–23. (3) `.field 16,5` appends a 5-bit value in bits 22–18 — all three fit in the same word (SPC unchanged). (4) `.field 01234h,20` places a 20-bit value spanning bits 31–12 of a new word (SPC advances to 00000004h). (5) `.field 01234h,32` places the full 32-bit value 01234h in its own word (SPC advances to 00000008h). + +- The **.float** directive calculates the single-precision (32-bit) IEEE floating-point representation of a single floating-point value and stores it in a word in the current section that is aligned to a word boundary. +- The **.half** and **.short** directives place one or more 16-bit values into consecutive 16-bit fields (halfwords) in the current section. The .half and .short directives automatically align to a short (2-byte) boundary. +- The **.int**, **.long**, and **.word** directives place one or more 32-bit values into consecutive 32-bit fields (words) in the current section. The .int, .long, and .word directives automatically align to a word boundary. +- The **.string** and **.cstring** directives place 8-bit characters from one or more character strings into the current section. The .string and .cstring directives are similar to .byte, placing an 8-bit character in each consecutive byte of the current section. The .cstring directive adds a NUL character needed by C; the .string directive does not add a NUL character. +- The **.ubyte**, **.uchar**, **.uhalf**, **.uint**, **.ulong**, **.ushort**, and **.uword** directives are provided as unsigned versions of their respective signed directives. These directives are used primarily by the C/C++ compiler to support unsigned types in C/C++. + +### Directives that Initialize Constants When Used in a .struct/.endstruct Sequence + +**NOTE:** The .bits, .byte, .char, .int, .long, .word, .double, .half, .short, .ubyte, .uchar, .uhalf, .uint, .ulong, .ushort, .uword, .string, .float, and .field directives do not initialize memory when they are part of a .struct/ .endstruct sequence; rather, they define a member's size. For more information, see the .struct/.endstruct directives. + +Figure 5-2 compares the .byte, .char, .short, .int, .long, .float, .double, .word, and .string directives using the following assembled code: + +``` +1 00000000 AA .byte 0AAh, 0BBh + 00000001 BB +2 00000002 CC .char 0CCh +3 00000004 ABCD .short 0ABCDh +4 00000006 0000DDDD .word 0DDDDh +5 0000000a EEEEFFFF .long 0EEEEFFFFh +6 0000000e 0000DDDD .int 0DDDDh +7 00000012 3FFFFCB9 .float 1.9999 +8 00000016 3FFFFFF5 .double 1.99999 + 0000001a 83A53B8E +9 0000001e 48 .string "Help" + 0000001f 65 + 00000020 6C + 00000021 70 +``` + +![Figure 5-2: Initialization Directives — memory layout diagram showing byte addresses and hex content for .byte, .char, .short, .word, .long, .int, .float, .double, and .string directives](_page_70_Figure_6.jpeg) + +**Figure 5-2: Initialization Directives.** Memory layout diagram showing the byte address (Byte column) and hex content (Code column) for each initialization directive. `.byte 0AAh` and `.byte 0BBh` place bytes AA and BB at addresses 0 and 1; `.char 0CCh` places CC at 2; `.short 0ABCDh` places a 16-bit halfword at 4; `.word 0DDDDh` places a zero-extended 32-bit word at 6; `.long 0EEEEFFFFh` places a 32-bit word at a; `.int 0DDDDh` places another word at e; `.float 1.9999` places 32-bit IEEE single `3FFFCB9h` at 12; `.double 1.99999` places 64-bit IEEE double across words at 16 and 1a; `.string "Help"` places ASCII bytes 48, 65, 6C, 70 at addresses 1e–21. + +### 5.4 Directives that Perform Alignment and Reserve Space + +These directives align the section program counter (SPC) or reserve space in a section: + +• The **.align** directive aligns the SPC at a 1-byte to 32K-byte boundary. This ensures that the code following the directive begins on the byte value that you specify. If the SPC is already aligned at the selected boundary, it is not incremented. Operands for the .align directive must equal a power of 2 between 20 and 215, inclusive. + +Figure 5-3 demonstrates the .align directive. Using the following assembled code: + +``` +1 00000000 40000000 .field 2,3 +2 00000000 4000000B .field 11, 21 +3 .align 2 +4 00000004 45 .string "Errcnt" +00000005 72 +00000006 72 +00000007 63 +00000008 6E +00000009 74 +5 .align +6 0000000c 04 .byte 4 +``` + +![Figure 5-3(a): The .align Directive — memory diagram showing SPC=03h advancing to SPC=04h with 2 bytes of null padding after .align 2](_page_71_Figure_9.jpeg) + +**(a) Result of .align 2.** Memory diagram showing that with current SPC = 03h, assembling `.align 2` inserts 2 bytes of null padding, advancing the SPC to 04h (the next halfword boundary). + +![Figure 5-3(b): The .align Directive — memory diagram showing SPC=0Ah advancing to SPC=0Ch with 1 word (4-byte boundary) after .align with no argument](_page_71_Figure_11.jpeg) + +**(b) Result of .align without an argument.** Memory diagram showing that with current SPC = 0Ah (2 bytes into the word spanning 08h–0Bh), assembling `.align` with no argument inserts 2 bytes of null padding to advance the SPC to 0Ch (the next 4-byte word boundary). The diagram labels the aligned word slot 08h–0Ch as "1 word" to indicate the alignment unit. + +- The .bes and .space directives reserve a specified number of bytes in the current section. The assembler fills these reserved bytes with 0s. You can reserve a specified number of words by multiplying the number of bytes by 4. + - When you use a label with .space, it points to the *first* byte that contains reserved bits. + - When you use a label with .bes, it points to the *last* byte that contains reserved bits. + +Figure 5-4 shows how the .space and .bes directives work for the following assembled code: + +``` +1 +2 00000000 00000100 .word 100h, 200h + 00000004 00000200 +3 00000008 Res_1: .space 17 +4 0000001c 0000000F .word 15 +5 00000033 Res_2: .bes 20 +6 00000034 BA .byte 0BAh +``` + +Res\_1 points to the first byte in the space reserved by .space. Res\_2 points to the last byte in the space reserved by .bes. + +![Figure 5-4: The .space and .bes Directives — memory diagram showing 17 reserved bytes (Res_1=08h) and 20 reserved bytes (Res_2=33h)](_page_72_Figure_7.jpeg) + +**Figure 5-4: The .space and .bes Directives.** Memory diagram showing two reserved blocks. The first block (17 bytes, reserved by `.space 17`) has its label `Res_1` pointing to the first byte at address 08h. The second block (20 bytes, reserved by `.bes 20`) has its label `Res_2` pointing to the last byte at address 33h. This illustrates the key difference: `.space` labels point to the first reserved byte, while `.bes` labels point to the last reserved byte. + +## 5.5 Directives that Format the Output Listings + +These directives format the listing file: + +• The **.drlist** directive causes printing of the directive lines to the listing; the **.drnolist** directive turns it off for certain directives. You can use the .drnolist directive to suppress the printing of the following directives. You can use the .drlist directive to turn the listing on again. + +| .asg | .eval | .length | .mnolist | .var | +|--------|-----------|---------|-----------|--------| +| .break | .fclist | .mlist | .sslist | .width | +| .emsg | .fcnolist | .mmsg | .ssnolist | .wmsg | + +- The source code listing includes false conditional blocks that do not generate code. The **.fclist** and **.fcnolist** directives turn this listing on and off. You can use the .fclist directive to list false conditional blocks exactly as they appear in the source code. You can use the .fcnolist directive to list only the conditional blocks that are actually assembled. +- The **.length** directive controls the page length of the listing file. You can use this directive to adjust listings for various output devices. +- The **.list** and **.nolist** directives turn the output listing on and off. You can use the .nolist directive to prevent the assembler from printing selected source statements in the listing file. Use the .list directive to turn the listing on again. +- The source code listing includes macro expansions and loop blocks. The **.mlist** and **.mnolist** directives turn this listing on and off. You can use the .mlist directive to print all macro expansions and loop blocks to the listing, and the .mnolist directive to suppress this listing. + +- The **.option** directive controls certain features in the listing file. This directive has the following operands: + - **A** turns on listing of all directives and data, and subsequent expansions, macros, and blocks. + - **B** limits the listing of .byte and .char directives to one line. + - **H** limits the listing of .half and .short directives to one line. + - **M** turns off macro expansions in the listing. + - **N** turns off listing (performs .nolist). + - **O** turns on listing (performs .list). + - **R** resets the B, H, M, T, and W directives (turns off the limits of B, H, M, T, and W). + - **T** limits the listing of .string directives to one line. + - **W** limits the listing of .word and .int directives to one line. + - **X** produces a cross-reference listing of symbols. You can also obtain a cross-reference listing by invoking the assembler with the --asm\_listing\_cross\_reference option (see Section 4.3). +- The **.page** directive causes a page eject in the output listing. +- The source code listing includes substitution symbol expansions. The **.sslist** and **.ssnolist** directives turn this listing on and off. You can use the .sslist directive to print all substitution symbol expansions to the listing, and the .ssnolist directive to suppress this listing. These directives are useful for debugging the expansion of substitution symbols. +- The **.tab** directive defines tab size. +- The **.title** directive supplies a title that the assembler prints at the top of each page. +- The **.width** directive controls the page width of the listing file. You can use this directive to adjust listings for various output devices. + +## 5.6 Directives that Reference Other Files + +These directives supply information for or about other files that can be used in the assembly of the current file: + +- The **.copy** and **.include** directives tell the assembler to begin reading source statements from another file. When the assembler finishes reading the source statements in the copy/include file, it resumes reading source statements from the current file. The statements read from a copied file are printed in the listing file; the statements read from an included file are *not* printed in the listing file. +- The **.def** directive identifies a symbol that is defined in the current module and that can be used in another module. The assembler includes the symbol in the symbol table. +- The **.global** directive declares a symbol external so that it is available to other modules at link time. (For more information about global symbols, see Section 2.6.1). The .global directive does double duty, acting as a .def for defined symbols and as a .ref for undefined symbols. The linker resolves an undefined global symbol reference only if the symbol is used in the program. The .global directive declares a 16-bit symbol. +- The **.mlib** directive supplies the assembler with the name of an archive library that contains macro definitions. When the assembler encounters a macro that is not defined in the current module, it searches for it in the macro library specified with .mlib. +- The **.ref** directive identifies a symbol that is used in the current module but is defined in another module. The assembler marks the symbol as an undefined external symbol and enters it in the object symbol table so the linker can resolve its definition. The .ref directive forces the linker to resolve a symbol reference. +- The **.symdepend** directive creates an artificial reference from the section defining the source symbol name to the destination symbol. The .symdepend directive prevents the linker from removing the section containing the destination symbol if the source symbol section is included in the output module. +- The **.weak** directive identifies a symbol that is used in the current module but is defined in another module. It is equivalent to the .ref directive, except that the reference has weak linkage. + +## 5.7 Directives that Enable Conditional Assembly + +Conditional assembly directives enable you to instruct the assembler to assemble certain sections of code according to a true or false evaluation of an expression. Two sets of directives allow you to assemble conditional blocks of code: + +• The **.if/.elseif/.else/.endif** directives tell the assembler to conditionally assemble a block of code according to the evaluation of an expression. + +**.if** *condition* marks the beginning of a conditional block and assembles code if the .if *condition* is true. + +[**.elseif** *condition*] marks a block of code to be assembled if the .if *condition* is false and the .elseif condition is true. + +**.else** marks a block of code to be assembled if the .if *condition* is false and any .elseif conditions are false. + +**.endif** marks the end of a conditional block and terminates the block. + +• The **.loop/.break/.endloop** directives tell the assembler to repeatedly assemble a block of code according to the evaluation of an expression. + +**.loop** [*count*] marks the beginning of a repeatable block of code. The optional expression evaluates to the loop count. + +**.break** [*end condition*] tells the assembler to assemble repeatedly when the .break *end condition* is false and to go to the code immediately after .endloop when the expression is true or omitted. + +**.endloop** marks the end of a repeatable block. + +The assembler supports several relational operators that are useful for conditional expressions. For more information about relational operators, see Section 4.8.2. + +## 5.8 Directives that Define Union or Structure Types + +These directives set up specialized types for later use with the .tag directive, allowing you to use symbolic names to refer to portions of a complex object. The types created are analogous to the struct and union types of the C language. + +The .struct, .union, .cstruct, and .cunion directives group related data into an aggregate structure which is more easily accessed. These directives do not allocate space for any object. Objects must be separately allocated, and the .tag directive must be used to assign the type to the object. + +``` +type .struct ; structure tag definition +X .int +Y .int +T_LEN .endstruct +COORD .tag type ; declare COORD (coordinate) +COORD .space T_LEN ; actual memory allocation + LDR R0, COORD.Y ; load member Y of structure + ; COORD into register R0. +``` + +The .cstruct and .cunion directives guarantee that the data structure will have the same alignment and padding as if the structure were defined in analogous C code. This allows structures to be shared between C and assembly code. See Chapter 13. For .struct and .union, element offset calculation is left up to the assembler, so the layout may be different than .cstruct and .cunion. + +The .sassign directive allows you to map a defined structure onto the PRU registers. + +## 5.9 Directives that Define Enumerated Types + +These directives set up specialized types for later use in expressions allowing you to use symbolic names to refer to compile-time constants. The types created are analogous to the enum type of the C language. This allows enumerated types to be shared between C and assembly code. See Chapter 13. + +See Section 13.2.10 for an example of using .enum. + +## 5.10 Directives that Define Symbols at Assembly Time + +Assembly-time symbol directives equate meaningful symbol names to constant values or strings. + +• The **.asg** directive assigns a character string to a substitution symbol. The value is stored in the substitution symbol table. When the assembler encounters a substitution symbol, it replaces the symbol with its character string value. Substitution symbols created with .asg can be redefined. + +``` +.asg "10, 20, 30, 40", coefficients + ; Assign string to substitution symbol. +.byte coefficients + ; Place the symbol values 10, 20, 30, and 40 + ; into consecutive bytes in current section. +``` + +- The **.define** directive assigns a character string to a substitution symbol. The value is stored in the substitution symbol table. When the assembler encounters a substitution symbol, it replaces the symbol with its character string value. Substitution symbols created with .define cannot be redefined. +- The **.eval** directive evaluates a well-defined expression, translates the results into a character string, and assigns the character string to a substitution symbol. This directive is most useful for manipulating counters: + +``` +.asg 1 , x ; x = 1 +.loop ; Begin conditional loop. +.byte x*10h ; Store value into current section. +.break x = 4 ; Break loop if x = 4. +.eval x+1, x ; Increment x by 1. +.endloop ; End conditional loop. +``` + +• The **.set** and **.equ** directives set a constant value to a symbol. The symbol is stored in the symbol table and cannot be redefined; for example: + +``` +bval .set 0100h ; Set bval = 0100h + .long bval, bval*2, bval+12 + ; Store the values 0100h, 0200h, and 010Ch + ; into consecutive words in current section. +``` + +The .set and .equ directives produce no object code. The two directives are identical and can be used interchangeably. + +- The **.unasg** directive turns off substitution symbol assignment made with .asg. +- The **.undefine** directive turns off substitution symbol assignment made with .define. +- The **.var** directive allows you to use substitution symbols as local variables within a macro. + +## 5.11 Miscellaneous Directives + +These directives enable miscellaneous functions or features: + +- The **.asmfunc** and **.endasmfunc** directives mark function boundaries. These directives are used with the compiler --symdebug:dwarf (-g) option to generate debug information for assembly functions. +- The **.cdecls** directive enables programmers in mixed assembly and C/C++ environments to share C headers containing declarations and prototypes between C and assembly code. +- The **.end** directive terminates assembly. If you use the .end directive, it should be the last source statement of a program. This directive has the same effect as an end-of-file character. +- The **.group**, **.gmember**, and **.endgroup** directives define an ELF group section to be shared by several sections. +- The **.newblock** directive resets local labels. Local labels are symbols of the form \$n, where n is a decimal digit. They are defined when they appear in the label field. Local labels are temporary labels that can be used as operands for jump instructions. The .newblock directive limits the scope of local labels by resetting them after they are used. See Section 4.7.3 for information on local labels. + +These three directives enable you to define your own error and warning messages: + +- The **.emsg** directive sends error messages to the standard output device. The .emsg directive generates errors in the same manner as the assembler, incrementing the error count and preventing the assembler from producing an object file. +- The **.mmsg** directive sends assembly-time messages to the standard output device. The .mmsg directive functions in the same manner as the .emsg and .wmsg directives but does not set the error count or the warning count. It does not affect the creation of the object file. +- The **.wmsg** directive sends warning messages to the standard output device. The .wmsg directive functions in the same manner as the .emsg directive but increments the warning count rather than the error count. It does not affect the creation of the object file. + +For more information about using the error and warning directives in macros, see Section 6.7. + +## 5.12 Directives Reference + +The remainder of this chapter is a reference. Generally, the directives are organized alphabetically, one directive per topic. Related directives (such as .if/.else/.endif), however, are presented together in one topic. + +### **.align** *Align SPC on the Next Boundary* + +**Syntax .align** [*size in bytes*] + +**Description** The **.align** directive aligns the section program counter (SPC) on the next boundary, depending on the *size in bytes* parameter. The *size* can be any power of 2, although only certain values are useful for alignment. An operand of 1 aligns the SPC on the next byte boundary, and this is the default if no *size in bytes* is given. The *size in bytes* must equal a power of 2; the value must be between 1 and 32,768, inclusive. The assembler assembles words containing null values (0) up to the next size in bytes boundary: + + +- 1 — aligns SPC to byte boundary +- 2 — aligns SPC to halfword boundary +- 4 — aligns SPC to word boundary +- 8 — aligns SPC to doubleword boundary +- 128 — aligns SPC to page boundary + +Using the .align directive has two effects: + +- The assembler aligns the SPC on an x-byte boundary *within* the current section. +- The assembler sets a flag that forces the linker to align the section so that individual alignments remain intact when a section is loaded into memory. + +**Example** This example shows several types of alignment, including .align 2, .align 8, and a default .align. + +``` +1 00000000 04 .byte 4 +2 .align 2 +3 00000002 45 .string "Errorcnt" + 00000003 72 + 00000004 72 + 00000005 6F + 00000006 72 + 00000007 63 + 00000008 6E + 00000009 74 +4 .align +5 0000000c 60000000 .field 3,3 +6 0000000c 6A000000 .field 5,4 +7 .align 2 +8 0000000c 6A006000 .field 3,3 +9 .align 8 +10 00000010 50000000 .field 5,4 +11 .align +12 00000014 04 .byte 4 +``` + +### **.asg/.define/.eval** *Assign a Substitution Symbol* + +**Syntax .asg "***character string***",***substitution symbol* + +**.define "***character string***",***substitution symbol* + +**.eval** *expression***,***substitution symbol* + +**Description** The **.asg** and **.define** directives assign character strings to substitution symbols. Substitution symbols are stored in the substitution symbol table. The .asg directive can be used in many of the same ways as the .set directive, but while .set assigns a constant value (which cannot be redefined) to a symbol, .asg assigns a character string (which can be redefined) to a substitution symbol. + +- The assembler assigns the *character string* to the substitution symbol. +- The *substitution symbol* must be a valid symbol name. The substitution symbol is up to 128 characters long and must begin with a letter. Remaining characters of the symbol can be a combination of alphanumeric characters, the underscore (\_), and the dollar sign (\$). + +The **.define** directive functions in the same manner as the .asg directive, except that .define disallows creation of a substitution symbol that has the same name as a register symbol or mnemonic. It does not create a new symbol name space in the assembler, rather it uses the existing substitution symbol name space. The .define directive is used to prevent corruption of the assembly environment when converting C/C++ headers. See Chapter 13 for more information about using C/C++ headers in assembly source. + +The **.eval** directive performs arithmetic on substitution symbols, which are stored in the substitution symbol table. This directive evaluates the *expression* and assigns the string value of the result to the substitution symbol. The .eval directive is especially useful as a counter in .loop/.endloop blocks. + +- The *expression* is a well-defined alphanumeric expression in which all symbols have been previously defined in the current source module, so that the result is an absolute expression. +- The *substitution symbol* must be a valid symbol name. The substitution symbol is up to 128 characters long and must begin with a letter. Remaining characters of the symbol can be a combination of alphanumeric characters, the underscore (\_), and the dollar sign (\$). + +See the .unasg/.undefine topic for information on turning off a substitution symbol. + +### **Example** This example shows how .asg and .eval can be used. + +``` +1 .sslist ; show expanded sub. symbols + 2 ; using .asg and .eval + 3 + 4 .asg R2, STACKPTR + 5 .asg &, AND + 6 + 7 00000000 E28DD018 ADD STACKPTR, STACKPTR, 280 AND 255 +# ADD R2, R2, 280 & 255 + 8 00000004 E28DD018 ADD STACKPTR, STACKPTR, 280 & 255 +# ADD R2, R2, 280 & 255 + 9 + 10 .asg 0, x + 11 .loop 5 + 12 .eval x+1, x + 13 .word x + 14 .endloop +1 .eval x+1, x +# .eval 0+1, x +1 00000008 00000001 .word x +# .word 1 +1 .eval x+1, x +# .eval 1+1, x +1 0000000c 00000002 .word x +# .word 2 +1 .eval x+1, x +# .eval 2+1, x +1 00000010 00000003 .word x +# .word 3 +1 .eval x+1, x +# .eval 3+1, x +1 00000014 00000004 .word x +# .word 4 +1 .eval x+1, x +# .eval 4+1, x +1 00000018 00000005 .word x +# .word 5 +``` + +## **.asmfunc/.endasmfunc** *Mark Function Boundaries* + +**Syntax** *symbol* **.asmfunc** [**stack\_usage(***num***)**] + +**.endasmfunc** + +**Description** The **.asmfunc** and **.endasmfunc** directives mark function boundaries. These directives are used with the compiler -g option (--symdebug:dwarf) to allow assembly code sections to be debugged in the same manner as C/C++ functions. + +> You should not use the same directives generated by the compiler (see Appendix A) to accomplish assembly debugging; those directives should be used only by the compiler to generate symbolic debugging information for C/C++ source files. + +The *symbol* is a label that must appear in the label field. + +The .asmfunc directive has an optional parameter, stack\_usage, which indicates that the function may use up to *num* bytes. + +Consecutive ranges of assembly code that are not enclosed within a pair of .asmfunc and .endasmfunc directives are given a default name in the following format: + +**\$** *filename* **:** *beginning source line* **:** *ending source line* **\$** + +**Example** In this example the .asmfunc and .endasmfunc directives are used to mark function boundaries for the user\_func function. + +``` +1 00000000 .sect ".text" +2 .global user_func +3 .align 4 +4 +5 userfunc: .asmfunc +6 LDI R28, 1 +7 MOV R29, R26 +8 XIN 0, &R26, 4 +9 .endasmfunc +``` + +## **.bits** *Initialize Bits* + +**Syntax** **.bits** *value1*[**, ... ,** *valuen* ] + +**Description** The **.bits** directive places one or more values into consecutive bits of the current section. + +The .bits directive is similar to the .field directive (see .field topic). However, the .bits directive does not allow you to specify the number of bits to fill or increment the SPC. + +## **.bss** *Reserve Space in the .bss Section* + +**Syntax** + +.bss symbol, size in bytes[, alignment] + +**Description** + +The **.bss** directive reserves space for variables in the .bss section. This directive is usually used to allocate space in RAM. + +- The *symbol* is a required parameter. It defines a symbol that points to the first location reserved by the directive. The symbol name must correspond to the variable that you are reserving space for. +- The size in bytes is a required parameter; it must be an absolute constant expression. The assembler allocates size bytes in the .bss section. There is no default size. +- The alignment is an optional parameter that ensures that the space allocated to the symbol occurs on the specified boundary. The boundary indicates must be set to a power of 2 between 20 and 215, inclusive. If the SPC is already aligned at the specified boundary, it is not incremented. + +For more information about sections, see Chapter 2. + +**Example** + +In this example, the .bss directive allocates space for two variables, TEMP and ARRAY. The symbol TEMP points to four bytes of uninitialized space (at .bss SPC = 0). The symbol ARRAY points to 100 bytes of uninitialized space (at .bss SPC = 04h). Symbols declared with the .bss directive can be referenced in the same manner as other symbols and can also be declared external. + +``` + 1 ******************************************** + 2 ** Start assembling into the .text section. ** + 3 ******************************************** + 4 00000000 .text + 5 00000000 E3A00000 LDI R0, 0 + 6 + 7 ******************************************** + 8 ** Allocate 4 bytes in .bss for TEMP. ** + 9 ******************************************** +10 00000000 Var_1: .bss TEMP, 4 +11 +12 ******************************************** +13 ** Still in .text. ** +14 ******************************************** +15 00000004 E2801056 ADD R1, R0, 56h +16 +17 +18 ******************************************** +19 ** Allocate 100 bytes in .bss for the symbol ** +20 ** named ARRAY. ** +21 ******************************************** +22 00000004 .bss ARRAY, 100, 4 +23 +24 ******************************************** +25 ** Assemble more code into .text. ** +26 ******************************************** +27 0000000c E1A0F00E JMP R3.w2 +28 +29 ******************************************** +30 ** Declare external .bss symbols. ** +31 ******************************************** +32 .global ARRAY, TEMP +33 .end +``` + +## **.byte/.ubyte/.char/.uchar** *Initialize Byte* + +**Syntax** + +**.byte** *value1*[**, ... ,** *valuen* ] +**.ubyte** *value1*[**, ... ,** *valuen* ] +**.char** *value1*[**, ... ,** *valuen* ] +**.uchar** *value1*[**, ... ,** *valuen* ] + +**Description** The **.byte**, **.ubyte**, **.char**, and **.uchar** directives place one or more values into consecutive bytes of the current section. A *value* can be one of the following: + +- An expression that the assembler evaluates and treats as an 8-bit signed number +- A character string enclosed in double quotes. Each character in a string represents a separate value, and values are stored in consecutive bytes. The entire string *must* be enclosed in quotes. + +The first byte occupies the eight least significant bits of a full 32-bit word. The second byte occupies bits eight through 15 while the third byte occupies bits 16 through 23. The assembler truncates values greater than eight bits. + +If you use a label, it points to the location of the first byte that is initialized. + +When you use these directives in a .struct/.endstruct sequence, they define a member's size; they do not initialize memory. For more information, see the .struct/.endstruct/.tag topic. + +**Example** In this example, 8-bit values (10, -1, abc, and a) are placed into consecutive bytes in memory with .byte. Also, 8-bit values (8, -3, def, and b) are placed into consecutive bytes in memory with .char. The label STRX has the value 0h, which is the location of the first initialized byte. The label STRY has the value 6h, which is the first byte initialized by the .char directive. + +``` +1 00000000 .space 100h +2 00000100 0A STRX .byte 10, -1, "abc", 'a' + 00000101 FF + 00000102 61 + 00000103 62 + 00000104 63 + 00000105 61 +3 00000106 08 STRY .char 8, -3, "def", 'b' + 00000107 FD + 00000108 64 + 00000109 65 + 0000010a 66 + 0000010b 62 +``` + +### **.cdecls** *Share C Headers Between C and Assembly Code* + +**Syntax Single Line:** + +**.cdecls** [*options* **,**] **"** *filename* **"**[**, "** *filename2* **"**[**,**...]] + +**Syntax Multiple Lines:** + +``` +.cdecls [options] +%{ + /*---------------------------------------------------------------------------------*/ + /* C/C++ code - Typically a list of #includes and a few defines */ + /*---------------------------------------------------------------------------------*/ +%} +``` + +**Description** The **.cdecls** directive allows programmers in mixed assembly and C/C++ environments to share C headers containing declarations and prototypes between the C and assembly code. Any legal C/C++ can be used in a .cdecls block and the C/C++ declarations cause suitable assembly to be generated automatically, allowing you to reference the C/C++ constructs in assembly code; such as calling functions, allocating space, and accessing structure members; using the equivalent assembly mechanisms. While function and variable definitions are ignored, most common C/C++ elements are converted to assembly, for instance: enumerations, (non-function-like) macros, function and variable prototypes, structures, and unions. + +The .cdecls options control whether the code is treated as C or C++ code; and how the .cdecls block and converted code are presented. Options must be separated by commas; they can appear in any order: + +| Option | Description | +|--------|-------------| +| C | Treat the code in the .cdecls block as C source code (default). | +| CPP | Treat the code in the .cdecls block as C++ source code. This is the opposite of the C option. | +| NOLIST | Do not include the converted assembly code in any listing file generated for the containing assembly file (default). | +| LIST | Include the converted assembly code in any listing file generated for the containing assembly file. This is the opposite of the NOLIST option. | +| NOWARN | Do not emit warnings on STDERR about C/C++ constructs that cannot be converted while parsing the .cdecls source block (default). | +| WARN | Generate warnings on STDERR about C/C++ constructs that cannot be converted while parsing the .cdecls source block. This is the opposite of the NOWARN option. | + +In the single-line format, the options are followed by one or more filenames to include. The filenames and options are separated by commas. Each file listed acts as if #include "filename" was specified in the multiple-line format. + +In the multiple-line format, the line following .cdecls must contain the opening .cdecls block indicator %{. Everything after the %{, up to the closing block indicator %}, is treated as C/C++ source and processed. Ordinary assembler processing then resumes on the line following the closing %}. + +The text within %{ and %} is passed to the C/C++ compiler to be converted into assembly language. Much of C language syntax, including function and variable definitions as well as function-like macros, is not supported and is ignored during the conversion. However, all of what traditionally appears in C header files is supported, including function and variable prototypes; structure and union declarations; nonfunction-like macros; enumerations; and #defines. + +The resulting assembly language is included in the assembly file at the point of the .cdecls directive. If the LIST option is used, the converted assembly statements are printed in the listing file. + +The assembly resulting from the .cdecls directive is treated similarly to a .include file. Therefore the .cdecls directive can be nested within a file being copied or included. The assembler limits nesting to ten levels; the host operating system may set additional restrictions. The assembler precedes the line numbers of copied files with a letter code to identify the level of copying. An A indicates the first copied file, B indicates a second copied file, etc. + +The .cdecls directive can appear anywhere in an assembly source file, and can occur multiple times within a file. However, the C/C++ environment created by one .cdecls is **not** inherited by a later .cdecls; the C/C++ environment starts new for each .cdecls. + +See Chapter 13 for more information on setting up and using the .cdecls directive with C header files. + +**Example** In this example, the .cdecls directive is used call the C header.h file. + +**C header file:** + +``` +#define WANT_ID 10 +#define NAME "John\n" +extern int a_variable; +extern float cvt_integer(int src); +struct myCstruct { int member_a; float member_b; }; +enum status_enum { OK = 1, FAILED = 256, RUNNING = 0 }; +``` + +**Source file:** + +``` + .cdecls C,LIST,"myheader.h" +size: .int $sizeof(myCstruct) +aoffset: .int myCstruct.member_a +boffset: .int myCstruct.member_b +okvalue: .int status_enum.OK +failval: .int status_enum.FAILED + .if $defined(WANT_ID) +id .cstring NAME + .endif +``` + +**Listing File:** + +``` +1 .cdecls C,LIST,"myheader.h" +A 1 ; ------------------------------------------ +A 2 ; Assembly Generated from C/C++ Source Code +A 3 ; ------------------------------------------ +A 4 +A 5 ; =========== MACRO DEFINITIONS =========== +A 6 .define "10",WANT_ID +A 7 .define """John\n""",NAME +A 8 +A 9 ; =========== TYPE DEFINITIONS =========== +A 10 status_enum .enum +A 11 00000001 OK .emember 1 +A 12 00000100 FAILED .emember 256 +A 13 00000000 RUNNING .emember 0 +A 14 .endenum +A 15 +A 16 myCstruct .struct 0,4 + 17 ; struct size=(8 bytes|64 bits), alignment=4 +A 18 00000000 member_a .field 32 + 19 ; int member_a - offset 0 bytes, size (4 bytes|32 bits) +A 20 00000004 member_b .field 32 + 21 ; float member_b - offset 4 bytes, size (4 bytes|32 bits) +A 22 00000008 .endstruct + 23 ; final size=(8 bytes|64 bits) +A 24 +A 25 ; =========== EXTERNAL FUNCTIONS =========== +A 26 .global _cvt_integer +A 27 +A 28 ; =========== EXTERNAL VARIABLES =========== +A 29 .global _a_variable + 2 00000000 00000008 size: .int $sizeof(myCstruct) + 3 00000004 00000000 aoffset: .int myCstruct.member_a + 4 00000008 00000004 boffset: .int myCstruct.member_b + 5 0000000c 00000001 okvalue: .int status_enum.OK + 6 00000010 00000100 failval: .int status_enum.FAILED + 7 .if $defined(WANT_ID) + 8 00000014 0000004A id .cstring NAME + 00000015 0000006F + 00000016 00000068 + 00000017 0000006E + 00000018 0000000A + 00000019 00000000 + 9 .endif +``` + +## **.common** *Create a Common Symbol* + +**Syntax** + +.common symbol, size in bytes[, alignment] + +.common symbol, structure tag[, alignment] + +**Description** + +The .common directive creates a common symbol in a common block, rather than placing the variable in a memory section. + +This directive is used by the compiler when the --common option is enabled (the default), which causes uninitialized file scope variables to be emitted as common symbols. The benefit of common symbols is that generated code can remove unused variables that would otherwise increase the size of the .bss section. (Uninitialized variables of a size larger than 32 bytes are separately optimized through placement in separate subsections that can be omitted from a link.) This optimization happens for C/C++ code by default unless you use the --common=off compiler option. + +- The symbol is a required parameter. It defines a name for the symbol created by this + directive. The symbol name must correspond to the variable that you are reserving + space for. +- The size in bytes is a required parameter; it must be an absolute expression. The + assembler allocates size bytes in the section used for common symbols. There is no + default size. +- A *structure tag* can be used in place of a size to specify a structure created with the .struct directive. Either a size or a structure tag is required for this argument. +- The *alignment* is an optional parameter that ensures that the space allocated to the symbol occurs on the specified boundary. The boundary must be set to a power of 2 between 20 and 215, inclusive. If the SPC is already aligned at the specified boundary, it is not incremented. + +Common symbols are symbols that are placed in the symbol table of an ELF object file. They represent an uninitialized variable. Common symbols do not reference a section. (In contrast, initialized variables need to reference a section that contains the initialized data.) The value of a common symbol is its required alignment; it has no address and stores no address. While symbols for an uninitialized common block can appear in executable object files, common symbols may only appear in relocatable object files. Common symbols are preferred over weak symbols. See the section on the "Symbol Table" in the System V ABI specification for more about common symbols. + +When object files containing common symbols are linked, space is reserved in an uninitialized section for each common symbol. A symbol is created in place of the common symbol to refer to its reserved location. + +### **.copy/.include** *Copy Source File* + +**Syntax .copy "***filename***"** + +**.include "***filename***"** + +**Description** The **.copy** and **.include** directives tell the assembler to read source statements from a different file. The statements that are assembled from a copy file are printed in the assembly listing. The statements that are assembled from an included file are *not* printed in the assembly listing, regardless of the number of .list/.nolist directives assembled. + +When a .copy or .include directive is assembled, the assembler: + +- 1. Stops assembling statements in the current source file +- 2. Assembles the statements in the copied/included file +- 3. Resumes assembling statements in the main source file, starting with the statement that follows the .copy or .include directive + +The *filename* is a required parameter that names a source file. It is enclosed in double quotes and must follow operating system conventions. + +You can specify a full pathname (for example, /320tools/file1.asm). If you do not specify a full pathname, the assembler searches for the file in: + +1. The directory that contains the current source file +2. Any directories named with the --include\_path assembler option +3. Any directories specified by the PRU\_A\_DIR environment variable +4. Any directories specified by the PRU\_A\_DIR environment variable + +For more information about the --include\_path option and PRU\_A\_DIR, see Section 4.4. For more information about PRU\_A\_DIR, see the *PRU Optimizing C/C++ Compiler User's Guide*. + +The .copy and .include directives can be nested within a file being copied or included. The assembler limits nesting to 32 levels; the host operating system may set additional restrictions. The assembler precedes the line numbers of copied files with a letter code to identify the level of copying. A indicates the first copied file, B indicates a second copied file, etc. + +**Example 1** In this example, the .copy directive is used to read and assemble source statements from other files; then, the assembler resumes assembling into the current file. + +> The original file, copy.asm, contains a .copy statement copying the file byte.asm. When copy.asm assembles, the assembler copies byte.asm into its place in the listing (note listing below). The copy file byte.asm contains a .copy statement for a second file, word.asm. + +When it encounters the .copy statement for word.asm, the assembler switches to word.asm to continue copying and assembling. Then the assembler returns to its place in byte.asm to continue copying and assembling. After completing assembly of byte.asm, the assembler returns to copy.asm to assemble its remaining statement. + +| copy.asm
(source file) | byte.asm
(first copy file) | word.asm
(second copy file) | +|-----------------------------------------------------------|-------------------------------------------------------|-------------------------------------| +| .space 29
.copy "byte.asm"
** Back in original file | ** In byte.asm
.byte 32,1+ 'A'
.copy "word.asm" | ** In word.asm
.word 0ABCDh, 56q | +| .string "done" | ** Back in byte.asm
.byte 67h + 3q | | + +**Listing file:** + +``` +1 00000000 .space 29 + 2 .copy "byte.asm" +A 1 ** In byte.asm +A 2 0000001d 20 .byte 32,1+ 'A' + 0000001e 42 +A 3 .copy "word.asm" +B 1 ** In word.asm +B 2 00000020 0000ABCD .word 0ABCDh, 56q + 00000024 0000002E +A 4 ** Back in byte.asm +A 5 00000028 6A .byte 67h + 3q + 3 + 4 ** Back in original file + 5 00000029 64 .string "done" + 0000002a 6F + 0000002b 6E + 0000002c 65 +``` + +**Example 2** In this example, the .include directive is used to read and assemble source statements from other files; then, the assembler resumes assembling into the current file. The mechanism is similar to the .copy directive, except that statements are not printed in the listing file. + +| include.asm
(source file) | byte2.asm
(first copy file) | word2.asm
(second copy file) | +|------------------------------|--------------------------------|---------------------------------| +| .space 29 | ** In byte2.asm | ** In word2.asm | +| .include "byte2.asm" | .byte 32,1+ 'A'
.include | .word 0ABCDh, 56q | +| ** Back in original file | "word2.asm" | | +| | ** Back in byte2.asm | | +| .string "done" | | | +| | .byte 67h + 3q | | + +**Listing file:** + +``` +1 00000000 .space 29 +2 .include "byte2.asm" +3 +4 ** Back in original file +5 00000029 64 .string "done" + 0000002a 6F + 0000002b 6E + 0000002c 65 +``` + +## **.cstruct/.cunion/.endstruct/.endunion/.tag** *Declare C Structure Type* + +**Syntax** + +| [stag] | .cstruct|.cunion | [expr]| +|--------------------------------------------|----------------------|----------------------------------------------|--|--| +| [mem 0 ]
[mem 1 ] | element
element | [expr 0 ]
[expr 1 ]| +| • | • | •| +| • | · | •| +| [mem_n] | .tag stag | [expr_n]| +| [mem_N] | element | [expr_N]| +| [size] | .endstruct|.endunion || +| label | .tag | stag| + +**Description** + +The .cstruct and .cunion directives have been added to support ease of sharing of common data structures between assembly and C code. The .cstruct and .cunion directives can be used exactly like the existing .struct and .union directives except that they are guaranteed to perform data layout matching the layout used by the C compiler for C struct and union data types. + +In particular, the .cstruct and .cunion directives force the same alignment and padding as used by the C compiler when such types are nested within compound data structures. + +The **.endstruct** directive terminates the structure definition. The **.endunion** directive terminates the union definition. + +The .tag directive gives structure characteristics to a *label*, simplifying the symbolic representation and providing the ability to define structures that contain other structures. The .tag directive does not allocate memory. The structure tag (*stag*) of a .tag directive must have been previously defined. + +Following are descriptions of the parameters used with the .struct, .endstruct, and .tag directives: + +- The *stag* is the structure's tag. Its value is associated with the beginning of the structure. If no stag is present, the assembler puts the structure members in the global symbol table with the value of their absolute offset from the top of the structure. The stag is optional for .struct, but is required for .tag. +- The *element* is one of the following descriptors: .byte, .char, .int, .long, .word, .double, .half, .short, .string, .float, and .field. All of these except .tag are typical directives that initialize memory. Following a .struct directive, these directives describe the structure element's size. They do not allocate memory. A .tag directive is a special case because stag must be used (as in the definition of stag). +- The *expr* is an optional expression indicating the beginning offset of the structure. The default starting point for a structure is 0. +- The *exprn/N* is an optional expression for the number of elements described. This value defaults to 1. A .string element is considered to be one byte in size, and a .field element is one bit. +- The $mem_{n/N}$ is an optional label for a member of the structure. This label is absolute and equates to the present offset from the beginning of the structure. A label for a structure member cannot be declared global. +- The size is an optional label for the total size of the structure. + +**Example** + +This example illustrates a structure in C that will be accessed in assembly code. + +``` +typedef struct STRUCT1 +; { int i0; /* offset 0 */ +; short s0; /* offset 4 */ +; } struct1; /* size 8, alignment 4 */ +; +; typedef struct STRUCT2 +; { struct1 st1; /* offset 0 */ +; short s1; /* offset 8 */ +; } struct2; /* size 12, alignment 4 */ +; +; The structure will get the following offsets once the C compiler lays out the structure +; elements according to the C standard rules: +; +; offsetof(struct1, i0) = 0 +; offsetof(struct1, s0) = 4 +; sizeof(struct1) = 8 +; offsetof(struct2, s1) = 0 +; offsetof(struct2, i1) = 8 +; sizeof(struct2) = 12 +; +; Attempts to replicate this structure in assembly using the .struct/.union directives will not +; create the correct offsets because the assembler tries to use the most compact arrangement: +struct1 .struct +i0 .int ; bytes 0-3 +s0 .short ; bytes 4-5 +struct1len .endstruct ; size 6, alignment 4 +struct2 .struct +st1 .tag struct1 ; bytes 0-5 +s1 .short ; bytes 6-7 +endstruct2 .endstruct ; size 8, alignment 4 + .sect "data1" + .word struct1.i0 ; 0 + .word struct1.s0 ; 4 + .word struct1len ; 6 + .sect "data2" + .word struct2.st1 ; 0 + .word struct2.s1 ; 6 + .word endstruct2 ; 8 +; +; The .cstruct/.cunion directives calculate offsets in the same manner as the C compiler. The resulting +; assembly structure can be used to access the elements of the C structure. Compare the difference +; in the offsets of those structures defined via .struct above and the offsets for the C code. +cstruct1 .cstruct +i0 .int ; bytes 0-3 +s0 .short ; bytes 4-5 +cstruct1len .endstruct ; size 8, alignment 4 +cstruct2 .cstruct +st1 .tag cstruct1 ; bytes 0-7 +s1 .short ; bytes 8-9 +cendstruct2 .endstruct ; size 12, alignment 4 + .sect "data3" + .word cstruct1.i0, struct1.i0 ; 0 + .word cstruct1.s0, struct1.s0 ; 4 + .word cstruct1len, struct1len ; 8 + .sect "data4" + .word cstruct2.st1, struct2.st1 ; 0 + .word cstruct2.s1, struct2.s1 ; 8 + .word cendstruct2, endstruct2 ; 12 +``` + +## **.data** *Assemble Into the .data Section* + +**Syntax** + +.data + +**Description** + +The .data directive sets .data as the current section; the lines that follow will be assembled into the .data section. The .data section is normally used to contain tables of data or preinitialized variables. + +For more information about sections, see Chapter 2. + +**Example** + +In this example, code is assembled into the .data section. + +``` + 1 ********************************************* + 2 ** Reserve space in .data. ** + 3 ********************************************* + 4 00000000 .data + 5 00000000 .space 0CCh + 6 + 7 ********************************************* + 8 ** Assemble into .data. ** + 9 ********************************************* +10 000000cc Table: .data +11 000000cc FFFFFFFF .word -1 ; Assemble 32-bit +12 ; constant into .data. +13 +14 000000d0 FF .byte 0FFh ; Assemble 8-bit +15 ; constant into .data. +16 +``` + +### **.double** *Initialize Double-Precision Floating-Point Value* + +**Syntax** **.double** *value1*[**, ... ,** *valuen* ] + +**Description** The **.double** directive places the IEEE double-precision floating-point representation of one or more floating-point values into the current section. Each *value* must be an absolute constant expression with an arithmetic type or a symbol equated to an absolute constant expression with an arithmetic type. Each constant is converted to a floatingpoint value in IEEE double-precision 64-bit format. Double-precision floating point constants are aligned to a double word boundary. + +The 64-bit value is stored in the format shown in Figure 5-5. + +**Figure 5-5. Double-Precision Floating-Point Format** + +![Figure 5-5: Double-Precision Floating-Point Format — two 32-bit rows showing S (sign, bit 31), E×10 (exponent, bits 30–20), M×20 + M×32 (mantissa, 52 bits total)](_page_93_Figure_10.jpeg) + +**Figure 5-5: Double-Precision Floating-Point Format.** Bit-field diagram showing the layout of a 64-bit IEEE 754 double-precision value stored as two consecutive 32-bit words. The high word (bits 31–0) contains: S = sign (bit 31), E = 10-bit exponent (bits 30–20), and the upper 20 bits of the mantissa M (bits 19–0). The low word (bits 31–0) contains the remaining 32 bits of the mantissa M. Bit position labels 31, 20, and 0 are shown for the high word; 31 and 0 for the low word. + +**Legend:** S = sign +E = exponent (11-bit biased) +M = mantissa (52-bit fraction) + +When you use .double in a .struct/.endstruct sequence, .double defines a member's size; it does not initialize memory. For more information, see the .struct/.endstruct/.tag topic. + +**Example** This example shows the .double directive. + +``` +1 00000000 C5308B2A .double -2.0e25 + 00000004 2C280291 +2 00000008 40180000 .double 6 + 0000000c 00000000 +3 00000010 407C8000 .double 456 + 00000014 00000000 +``` + +### **.drlist/.drnolist** *Control Listing of Directives* + +**Syntax** + +**.drlist** + +**.drnolist** + +**Description** Two directives enable you to control the printing of assembler directives to the listing file: + +The **.drlist** directive enables the printing of all directives to the listing file. + +The **.drnolist** directive suppresses the printing of the following directives to the listing file. The .drnolist directive has no affect within macros. + +- .asg +- .break +- .emsg +- .eval +- .fclist +- .fcnolist +- .mlist +- .mmsg +- .mnolist +- .sslist +- .ssnolist +- .var +- .wmsg + +By default, the assembler acts as if the .drlist directive had been specified. + +**Example** This example shows how .drnolist inhibits the listing of the specified directives. + +**Source file:** + +``` +.asg 0, x +.loop 2 +.eval x+1, x +.endloop +.drnolist +.asg 1, x +.loop 3 +.eval x+1, x +.endloop +``` + +**Listing file:** + +``` + 3 .asg 0, x + 4 .loop 2 + 5 .eval x+1, x + 6 .endloop + 1 .eval 0+1, x + 1 .eval 1+1, x + 7 + 8 .drnolist + 12 .loop 3 + 13 .eval x+1, x + 14 .endloop +``` + +### **.elfsym** *ELF Symbol Information* + +**Syntax .elfsym** *name***, SYM\_SIZE(***size***)** + +**Description** The .elfsym directive provides additional information for symbols in the ELF format. This directive is designed to convey different types of information, so the *type*, *data* pair is used to represent each type. Currently, this directive only supports the SYM\_SIZE type. + +SYM\_SIZE indicates the allocation size (in bytes) of the symbol indicated by *name*. + +**Example** This example shows the use of the ELF symbol information directive. + +``` +.sect ".examp" + .alignment 4 + .elfsym ex_sym, SYM_SIZE(4) +ex_sym: + .word 0 +``` + +## **.emsg/.mmsg/.wmsg** *Define Messages* + +**Syntax .emsg** *string* + +**.mmsg** *string* + +**.wmsg** *string* + +**Description** These directives allow you to define your own error and warning messages. When you use these directives, the assembler tracks the number of errors and warnings it encounters and prints these numbers on the last line of the listing file. + +The **.emsg** directive sends an error message to the standard output device in the same manner as the assembler. It increments the error count and prevents the assembler from producing an object file. + +The **.mmsg** directive sends an assembly-time message to the standard output device in the same manner as the .emsg and .wmsg directives. It does not, however, set the error or warning counts, and it does not prevent the assembler from producing an object file. + +The **.wmsg** directive sends a warning message to the standard output device in the same manner as the .emsg directive. It increments the warning count rather than the error count, however. It does not prevent the assembler from producing an object file. + +**Example** This example sends the message ERROR -- MISSING PARAMETER to the standard output device. + +**Source file:** + +``` +MSG_EX .macro parm1 + .if $symlen(parm1) = 0 + .emsg "ERROR -- MISSING PARAMETER" + .else + ADD parm1, r7, r8 + .endif + .endm + MSG_EX R0 + MSG_EX +``` + +**Listing file:** + +``` +1 MSG_EX .macro parm1 + 2 .if $symlen(parm1) = 0 + 3 .emsg "ERROR -- MISSING PARAMETER" + 4 .else + 5 ADD parm1, r7, r8 + 6 .endif + 7 .endm + 8 + 9 00000000 MSG_EX R0 +1 .if $symlen(parm1) = 0 +1 .emsg "ERROR -- MISSING PARAMETER" +1 .else +1 00000000 E0870008 ADD R0, r7, r8 +1 .endif + 10 + 11 00000004 MSG_EX +1 .if $symlen(parm1) = 0 +1 .emsg "ERROR -- MISSING PARAMETER" +***** USER ERROR ***** - : ERROR -- MISSING PARAMETER +1 .else +1 ADD parm1, r7, r8 +1 .endif +``` + +1 Error, No Warnings + +In addition, the following messages are sent to standard output by the assembler: + +``` +*** ERROR! line 11: ***** USER ERROR ***** - : ERROR -- MISSING PARAMETER + .emsg "ERROR -- MISSING PARAMETER" ]] +1 Error, No Warnings +Errors in source - Assembler Aborted +``` + +## **.end** *End Assembly* + +**Syntax** **.end** + +**Description** The **.end** directive is optional and terminates assembly. The assembler ignores any source statements that follow a .end directive. If you use the .end directive, it must be the last source statement of a program. + +This directive has the same effect as an end-of-file character. You can use .end when you are debugging and you want to stop assembling at a specific point in your code. + +### Ending a Macro + +**NOTE:** Do not use the .end directive to terminate a macro; use the .endm macro directive instead. + +**Example** This example shows how the .end directive terminates assembly. Any source statements that follow the .end directive are ignored by the assembler. + +**Source file:** + +``` +.text +.bss dflag, 1 +.bss array, 100 +.copy globals.def +LDI r4, array +LDI r5, offst +LDI r3, dflag +LBBO &r0, r4, r5, 4 +SBBO &r0, r3, 0, 4 +.end +LDI r4, offst +SBBO &r0, r4, 0, 4 +``` + +### **.fclist/.fcnolist** *Control Listing of False Conditional Blocks* + +**Syntax .fclist** + +**.fcnolist** + +**Description** Two directives enable you to control the listing of false conditional blocks: + +The **.fclist** directive allows the listing of false conditional blocks (conditional blocks that do not produce code). + +The **.fcnolist** directive suppresses the listing of false conditional blocks until a .fclist directive is encountered. With .fcnolist, only code in conditional blocks that are actually assembled appears in the listing. The .if, .elseif, .else, and .endif directives do not appear. + +By default, all conditional blocks are listed; the assembler acts as if the .fclist directive had been used. + +**Example** This example shows the assembly language and listing files for code with and without the conditional blocks listed. + +**Source file:** + +``` +AAA .set 1 +BBB .set 0 + .fclist + .if AAA + ADD R0, R0, 1024 + .else + ADD R0, R0, 1024*10 + .endif + .fcnolist + .if AAA + ADD R0, R0, 1024 + .else + ADD R0, R0, 1024*10 + .endif +``` + +**Listing file:** + +``` +1 00000001 AAA .set 1 +2 00000000 BBB .set 0 +3 .fclist +4 +5 .if AAA +6 00000000 E2800B01 ADD R0, R0, 1024 +7 .else +8 ADD R0, R0, 1024*10 +9 .endif +10 +11 .fcnolist +12 +14 00000004 E2800B01 ADD R0, R0, 1024 +``` + +### **.field** *Initialize Field* + +**Syntax .field** *value*[**,** *size in bits*] + +**Description** The **.field** directive initializes a multiple-bit field within a single word (32 bits) of memory. This directive has two operands: + +- The *value* is a required parameter; it is an expression that is evaluated and placed in the field. The value must be absolute. +- The *size in bits* is an optional parameter; it specifies a number from 1 to 32, which is the number of bits in the field. The default size is . If you specify a value that cannot fit in *size in bits*, the assembler truncates the value and issues a warning message. For example, .field 3,1 causes the assembler to truncate the value 3 to 1; the assembler also prints the message: + +``` +*** WARNING! line 21: W0001: Field value truncated to 1 + .field 3, 1 +``` + +Successive .field directives pack values into the specified number of bits starting at the current word. Fields are packed starting at the most significant part of the word, moving toward the least significant part as more fields are added. If the assembler encounters a field size that does not fit into the current word, it writes out the word, and begins packing fields into the next word. + +The .field directive is similar to the .bits directive (see the .bits topic). However, the .bits directive does not allow you to specify the number of bits in the field and does not automatically increment the SPC when a word boundary is reached. + +Use the .align directive to force the next .field directive to begin packing a new word. + +If you use a label, it points to the byte that contains the specified field. + +When you use .field in a .struct/.endstruct sequence, .field defines a member's size; it does not initialize memory. For more information, see the .struct/.endstruct/.tag topic. + +**Example** This example shows how fields are packed into a word. The SPC does not change until a word is filled and the next word is begun. + +``` +1 ************************************ +2 ** Initialize a 14-bit field. ** +3 ************************************ +4 00000000 2AF00000 .field 0ABCh, 14 +5 +6 ************************************ +7 ** Initialize a 5-bit field ** +8 ** in the same word. ** +9 ************************************ +10 00000000 2AF14000 L_F: .field 0Ah, 5 +11 +12 ************************************ +13 ** Write out the word. ** +14 ************************************ +15 .align 4 +16 +17 ************************************ +18 ** Initialize a 4-bit field. ** +19 ** This fields starts a new word. ** +20 ************************************ +21 00000004 C0000000 x: .field 0Ch, 4 +22 +23 ************************************ +24 ** 32-bit relocatable field ** +25 ** in the next word. ** +26 ************************************ +27 00000008 00000004' .field x +28 +``` + +![Assembly listing fragment showing lines 29–32 of the .field example: comment box "Initialize a 32-bit field." and line 32 with .field 04321h, 32 at SPC 0000000c](_page_100_Figure_2.jpeg) + +**Listing fragment (lines 29–32 of the .field example).** The continuation of the `.field` example listing showing lines 29–31 (comment box: "Initialize a 32-bit field.") and line 32: `32 0000000c 00004321 .field 04321h, 32`, which places the full 32-bit value 04321h into a new word at SPC = 0000000ch. + +Figure 5-6 shows how the directives in this example affect memory. + +![Figure 5-6: The .field Directive — memory diagram showing four words (0–3) with bit-field layouts for .field 0ABCh,14; .field 00Ah,5; .align 4; .field 0Ch,4; .field x; and .field 04321h,32](_page_100_Figure_5.jpeg) + +**Figure 5-6: The .field Directive.** Memory diagram showing how `.field` packs consecutive bit fields into 32-bit words. Word 0 (first pass): `.field 0ABCh, 14` places a 14-bit value in bits 31–18. Word 0 (second pass): `.field 00Ah, 5` appends a 5-bit value in bits 17–13 of the same word, labeled "5-bit field". After `.align 4`, a new word boundary begins. Word 1: `.field 0Ch, 4` places a 4-bit value in bits 31–28, labeled "4-bit field". Word 2: `.field x` places the 32-bit relocatable value of label x. Word 3: `.field 04321h, 32` places the full 32-bit value into its own word. + +## **.float** *Initialize Single-Precision Floating-Point Value* + +**Syntax .float** *value*[**, ... ,** *valuen* ] + +**Description** The **.float** directive places the IEEE single-precision floating-point representation of a single floating-point constant into a word in the current section. The *value* must be an absolute constant expression with an arithmetic type or a symbol equated to an absolute constant expression with an arithmetic type. Each constant is converted to a floatingpoint value in IEEE single-precision 32-bit format. + +The 32-bit value is stored exponent byte first, most significant byte of fraction second, and least significant byte of fraction third, in the format shown in Figure 5-7. + +**Figure 5-7. Single-Precision Floating-Point Format** + +![Figure 5-7: Single-Precision Floating-Point Format — one 32-bit row showing S (sign, bit 31), E×8 (exponent, bits 30–23), M×23 (mantissa, bits 22–0)](_page_101_Figure_10.jpeg) + +**Figure 5-7: Single-Precision Floating-Point Format.** Bit-field diagram showing the layout of a 32-bit IEEE 754 single-precision value. The single 32-bit word contains: S = sign (bit 31), E = 8-bit exponent (bits 30–23), and M = 23-bit mantissa fraction (bits 22–0). Bit position labels 31, 23, and 0 are shown. + +value = (-1)S x (1.0 + mantissa) x (2)exponent-127 + +**Legend:** S = sign (1 bit) +E = exponent (8-bit biased) +M = mantissa (23-bit fraction) + +When you use .float in a .struct/.endstruct sequence, .float defines a member's size; it does not initialize memory. For more information, see the .struct/.endstruct/.tag topic. + +**Example** Following are examples of the .float directive: + +``` +1 00000000 E9045951 .float -1.0e25 +2 00000004 40400000 .float 3 +3 00000008 42F60000 .float 123 +``` + +## **.global/.def/.ref** *Identify Global Symbols* + +**Syntax** + +**.global** *symbol1*[**, ... ,** *symboln* ] +**.def** *symbol1*[**, ... ,** *symboln* ] +**.ref** *symbol1*[**, ... ,** *symboln* ] + +**Description** Three directives identify global symbols that are defined externally or can be referenced externally: + +The **.def** directive identifies a symbol that is defined in the current module and can be accessed by other files. The assembler places this symbol in the symbol table. + +The **.ref** directive identifies a symbol that is used in the current module but is defined in another module. The linker resolves this symbol's definition at link time. + +The **.global** directive acts as a .ref or a .def, as needed. + +A *global symbol* is defined in the same manner as any other symbol; that is, it appears as a label or is defined by the .set, .equ, .bss, or .usect directive. If a global symbol is defined more than once, the linker issues a multiple-definition error. (The assembler can provide a similar multiple-definition error for local symbols.) The .ref directive always creates a symbol table entry for a symbol, whether the module uses the symbol or not; .global, however, creates an entry only if the module actually uses the symbol. + +A symbol can be declared global for either of two reasons: + +- If the symbol is *not defined in the current module* (which includes macro, copy, and include files), the .global or .ref directive tells the assembler that the symbol is defined in an external module. This prevents the assembler from issuing an unresolved reference error. At link time, the linker looks for the symbol's definition in other modules. +- If the symbol is *defined in the current module*, the .global or .def directive declares that the symbol and its definition can be used externally by other modules. These types of references are resolved at link time. + +**Example** This example shows four files. The file1.lst and file2.lst refer to each other for all symbols used; file3.lst and file4.lst are similarly related. + +The **file1.lst** and **file3.lst** files are equivalent. Both files define the symbol INIT and make it available to other modules; both files use the external symbols X, Y, and Z. Also, file1.lst uses the .global directive to identify these global symbols; file3.lst uses .ref and .def to identify the symbols. + +The **file2.lst** and **file4.lst** files are equivalent. Both files define the symbols X, Y, and Z and make them available to other modules; both files use the external symbol INIT. Also, file2.lst uses the .global directive to identify these global symbols; file4.lst uses .ref and .def to identify the symbols. + +**file1.lst** + +``` +1 ; Global symbol defined in this file +2 .global INIT +3 ; Global symbols defined in file2.lst +4 .global X, Y, Z +5 00000000 INIT: +6 00000000 E2800056 ADD R0, R0, 56h +7 00000004 00000000! .word X +8 ; . +9 ; . +10 ; . +11 .end +``` + +**file2.lst** + +``` + 1 ; Global symbols defined in this file + 2 .global X, Y, Z + 3 ; Global symbol defined in file1.lst + 4 .global INIT + 5 00000001 X: .set 1 + 6 00000002 Y: .set 2 + 7 00000003 Z: .set 3 + 8 00000000 00000000! .word INIT + 9 ; . + 10 ; . + 11 ; . + 12 .end +``` + +**file3.lst** + +``` + 1 ; Global symbols defined in this file + 2 .def INIT + 3 ; Global symbol defined in file4.lst + 4 .ref X, Y, Z + 5 00000000 INIT: + 6 00000000 E2800056 ADD R0, R0, 56 + 7 00000004 00000000! .word X + 8 ; . + 9 ; . + 10 ; . + 11 .end +``` + +**file4.lst** + +``` + 1 ; Global symbols defined in this file + 2 .def X, Y, Z + 3 ; Global symbol defined in file3.lst + 4 .ref INIT + 5 00000001 X: .set 1 + 6 00000002 Y: .set 2 + 7 00000003 Z: .set 3 + 8 00000000 00000000! .word INIT + 9 ; . + 10 ; . + 11 ; . + 12 .end +``` + +## **.group/.gmember/.endgroup** *Define Common Data Section* + +**Syntax .group** *group section name group type* + +**.gmember** *section name* + +**.endgroup** + +**Description** Three directives instruct the assembler to make certain sections members of an ELF group section (see the ELF specification for more information on group sections). + +The **.group** directive begins the group declaration. The *group section name* designates the name of the group section. The *group type* designates the type of the group. The following types are supported: + +- 0x0 Regular ELF group +- 0x1 COMDAT ELF group + +Duplicate COMDAT (common data) groups are allowed in multiple modules; the linker keeps only one. Creating such duplicate groups is useful for late instantiation of C++ templates and for providing debugging information. + +The **.gmember** directive designates *section name* as a member of the group. + +The **.endgroup** directive ends the group declaration. + +## **.half/.short/.uhalf/.ushort** *Initialize 16-Bit Integers* + +**Syntax** + +**.half** *value1*[**, ... ,** *valuen* ] +**.short** *value1*[**, ... ,** *valuen* ] +**.uhalf** *value1*[**, ... ,** *valuen* ] +**.ushort** *value1*[**, ... ,** *valuen* ] + +**Description** The **.half** and **.short** directives place one or more values into consecutive halfwords in the current section. A *value* can be either: + +- An expression that the assembler evaluates and treats as a 16-bit signed or unsigned number +- A character string enclosed in double quotes. Each character in a string represents a separate value and is stored alone in the least significant eight bits of a 16-bit field, which is padded with 0s. + +The assembler truncates values greater than 16 bits. + +If you use a label with .half or .short, it points to the location where the assembler places the first byte. + +These directives perform a halfword (16-bit) alignment before data is written to the section. This guarantees that data resides on a 16-bit boundary. + +When you use .half or .short in a .struct/.endstruct sequence, they define a member's size; they do not initialize memory. For more information, see the .struct/.endstruct/.tag topic. + +**Example** In this example, .half is used to place 16-bit values (10, -1, abc, and a) into consecutive halfwords in memory; .short is used to place 16-bit values (8, -3, def, and b) into consecutive halfwords in memory. The label STRN has the value 100ch, which is the location of the first initialized halfword for .short. + +``` +1 00000000 .space 100h * 16 +2 00001000 000A .half 10, -1, "abc", 'a' + 00001002 FFFF + 00001004 0061 + 00001006 0062 + 00001008 0063 + 0000100a 0061 +3 0000100c 0008 STRN .short 8, -3, "def", 'b' + 0000100e FFFD + 00001010 0064 + 00001012 0065 + 00001014 0066 + 00001016 0062 +``` + +## **.if/.elseif/.else/.endif** *Assemble Conditional Blocks* + +**Syntax .if** *condition* + +[**.elseif** *condition*] + +[**.else**] + +**.endif** + +**Description** These directives provide conditional assembly: + +The **.if** directive marks the beginning of a conditional block. The *condition* is a required parameter. + +- If the expression evaluates to true (nonzero), the assembler assembles the code that follows the expression (up to a .elseif, .else, or .endif). +- If the expression evaluates to false (0), the assembler assembles code that follows a .elseif (if present), .else (if present), or .endif (if no .elseif or .else is present). + +The **.elseif** directive identifies a block of code to be assembled when the .if expression is false (0) and the .elseif expression is true (nonzero). When the .elseif expression is false, the assembler continues to the next .elseif (if present), .else (if present), or .endif (if no .elseif or .else is present). The .elseif is optional in a conditional block, and more than one .elseif can be used. If an expression is false and there is no .elseif, the assembler continues with the code that follows a .else (if present) or a .endif. + +The **.else** directive identifies a block of code that the assembler assembles when the .if expression and all .elseif expressions are false (0). The .else directive is optional in the conditional block; if an expression is false and there is no .else statement, the assembler continues with the code that follows the .endif. The .elseif and .else directives can be used in the same conditional assembly block. + +The **.endif** directive terminates a conditional block. + +See Section 4.8.2 for information about relational operators. + +**Example** This example shows conditional assembly: + +``` +1 00000001 SYM1 .set 1 +2 00000002 SYM2 .set 2 +3 00000003 SYM3 .set 3 +4 00000004 SYM4 .set 4 +5 +6 If_4: .if SYM4 = SYM2 * SYM2 +7 00000000 04 .byte SYM4 ; Equal values +8 .else +9 .byte SYM2 * SYM2 ; Unequal values +10 .endif +11 +12 If_5: .if SYM1 <= 10 +13 00000001 0A .byte 10 ; Less than / equal +14 .else +15 .byte SYM1 ; Greater than +16 .endif +17 +18 If_6: .if SYM3 * SYM2 != SYM4 + SYM2 +19 .byte SYM3 * SYM2 ; Unequal value +20 .else +21 00000002 08 .byte SYM4 + SYM4 ; Equal values +22 .endif +23 +24 If_7: .if SYM1 = SYM2 +25 .byte SYM1 +26 .elseif SYM2 + SYM3 = 5 +27 00000003 05 .byte SYM2 + SYM3 +28 .endif +``` + +## **.int/.unint/.long/.ulong/.word/.uword** *Initialize 32-Bit Integers* + +**Syntax** + +**.int** *value1*[**, ... ,** *valuen* ] +**.uint** *value1*[**, ... ,** *valuen* ] +**.long** *value1*[**, ... ,** *valuen* ] +**.ulong** *value1*[**, ... ,** *valuen* ] +**.word** *value1*[**, ... ,** *valuen* ] +**.uword** *value1*[**, ... ,** *valuen* ] + +**Description** The **.int**, **.unint**, **.word**, and **.uword** directives place one or more values into consecutive words in the current section. Each value is placed in a 32-bit word by itself and is aligned on a word boundary. A *value* can be either: + +- An expression that the assembler evaluates and treats as a 32-bit signed or unsigned number +- A character string enclosed in double quotes. Each character in a string represents a separate value and is stored alone in the least significant eight bits of a 32-bit field, which is padded with 0s. + +A value can be either an absolute or a relocatable expression. If an expression is relocatable, the assembler generates a relocation entry that refers to the appropriate symbol; the linker can then correctly patch (relocate) the reference. This allows you to initialize memory with pointers to variables or labels. + +If you use a label with these directives, it points to the first word that is initialized. + +When you use these directives in a .struct/.endstruct sequence, they define a member's size; they do not initialize memory. See the .struct/.endstruct/.tag topic. + +**Example 1** This example uses the .int directive to initialize words. + +``` +1 00000000 .space 73h +2 00000000 .bss PAGE, 128 +3 00000080 .bss SYMPTR, 4 +4 00000074 E3A00056 INST: LDI R0, 056h +5 00000078 0000000A .int 10, SYMPTR, -1, 35 + 'a', INST, "abc" + 0000007c 00000080- + 00000080 FFFFFFFF + 00000084 00000084 + 00000088 00000074' + 0000008c 00000061 + 00000090 00000062 + 00000094 00000063 +``` + +**Example 2** This example shows how the .long directive initializes words. The symbol DAT1 points to the first word that is reserved. + +``` +1 00000000 0000ABCD DAT1: .long 0ABCDh, 'A' + 100h, 'g', 'o' + 00000004 00000141 + 00000008 00000067 + 0000000c 0000006F +2 00000010 00000000' .long DAT1, 0AABBCCDDh + 00000014 AABBCCDD +3 00000018 DAT2: +``` + +**Example 3** In this example, the .word directive is used to initialize words. The symbol WORDX points to the first word that is reserved. + +``` +1 00000000 00000C80 WORDX: .word 3200, 1 + 'AB', -0AFh, 'X' + 00000004 00004242 + 00000008 FFFFFF51 + 0000000c 00000058 +``` + +## **.length/.width** *Set Listing Page Size* + +**Syntax** **.length** [*page length*] + +**.width** [*page width*] + +**Description** + +Two directives allow you to control the size of the output listing file. + +The **.length** directive sets the page length of the output listing file. It affects the current and following pages. You can reset the page length with another .length directive. + +- Default length: 60 lines. If you do not use the .length directive or if you use the .length directive without specifying the *page length*, the output listing length defaults to 60 lines. +- Minimum length: 1 line +- Maximum length: 32 767 lines + +The **.width** directive sets the page width of the output listing file. It affects the next line assembled and the lines following. You can reset the page width with another .width directive. + +- Default width: 132 characters. If you do not use the .width directive or if you use the .width directive without specifying a page width, the output listing width defaults to 132 characters. +- Minimum width: 80 characters +- Maximum width: 200 characters + +The width refers to a full line in a listing file; the line counter value, SPC value, and object code are counted as part of the width of a line. Comments and other portions of a source statement that extend beyond the page width are truncated in the listing. + +The assembler does not list the .width and .length directives. + +**Example** The following example shows how to change the page length and width. + +``` +********************************************* +** Page length = 65 lines ** +** Page width = 85 characters ** +********************************************* + .length 65 + .width 85 + +********************************************* +** Page length = 55 lines ** +** Page width = 100 characters ** +********************************************* + .length 55 + .width 100 +``` + +## **.list/.nolist** *Start/Stop Source Listing* + +**Syntax** **.list** + +**.nolist** + +**Description** Two directives enable you to control the printing of the source listing: + +The **.list** directive allows the printing of the source listing. + +The **.nolist** directive suppresses the source listing output until a .list directive is encountered. The .nolist directive can be used to reduce assembly time and the source listing size. It can be used in macro definitions to suppress the listing of the macro expansion. + +The assembler does not print the .list or .nolist directives or the source statements that appear after a .nolist directive. However, it continues to increment the line counter. You can nest the .list/.nolist directives; each .nolist needs a matching .list to restore the listing. + +By default, the source listing is printed to the listing file; the assembler acts as if the .list directive had been used. However, if you do not request a listing file when you invoke the assembler by including the --asm\_listing option on the command line (see Section 4.3), the assembler ignores the .list directive. + +**Example** This example shows how the .copy directive inserts source statements from another file. The first time this directive is encountered, the assembler lists the copied source lines in the listing file. The second time this directive is encountered, the assembler does not list the copied source lines, because a .nolist directive was assembled. The .nolist, the second .copy, and the .list directives do not appear in the listing file. Also, the line counter is incremented, even when source statements are not listed. + +**Source file:** + +``` +.copy "copy2.asm" +* Back in original file + NOP + .nolist + .copy "copy2.asm" + .list +* Back in original file + .string "Done" +``` + +**Listing file:** + +``` +1 .copy "copy2.asm" +A 1 * In copy2.asm (copy file) +A 2 00000000 00000020 .word 32, 1 + 'A' + 00000004 00000042 + 2 * Back in original file + 3 00000008 E1A00000 NOP + 7 * Back in original file + 8 00000014 44 .string "Done" + 00000015 6F + 00000016 6E + 00000017 65 +``` + +## **.loop/.endloop/.break** *Assemble Code Block Repeatedly* + +**Syntax** **.loop** [*count*] + +**.break** [*end-condition*] + +**.endloop** + +**Description** Three directives allow you to repeatedly assemble a block of code: + +The **.loop** directive begins a repeatable block of code. The optional *count* operand, if used, must be a well-defined integer expression. The *count* indicates the number of loops to be performed (the loop count). If *count* is omitted, it defaults to 1024. The loop will be repeated count number of times, unless terminated early by a .break directive. + +The optional **.break** directive terminates a .loop early. You may use .loop without using .break. The .break directive terminates a .loop only if the *end-condition* expression is true (evaluates to nonzero). If the optional *end-condition* operand is omitted, it defaults to true. If *end-condition* is true, the assembler stops repeating the .loop body immediately; any remaining statements after .break and before .endloop are not assembled. The assembler resumes assembling with the statement after the .endloop directive. If *endcondition* is false (evaluates to 0), the loop continues. + +The **.endloop** directive marks the end of a repeatable block of code. When the loop terminates, whether by a .break directive with a true *end-condition* or by performing the loop count number of iterations, the assembler stops repeating the loop body and resumes assembling with the statement after the .endloop directive. + +**Example** This example illustrates how these directives can be used with the .eval directive. The code in the first six lines expands to the code immediately following those six lines. + +``` +1 .eval 0,x +2 COEF .loop +3 .word x*100 +4 .eval x+1, x +5 .break x = 6 +6 .endloop +1 00000000 00000000 .word 0*100 +1 .eval 0+1, x +1 .break 1 = 6 +1 00000004 00000064 .word 1*100 +1 .eval 1+1, x +1 .break 2 = 6 +1 00000008 000000C8 .word 2*100 +1 .eval 2+1, x +1 .break 3 = 6 +1 0000000c 0000012C .word 3*100 +1 .eval 3+1, x +1 .break 4 = 6 +1 00000010 00000190 .word 4*100 +1 .eval 4+1, x +1 .break 5 = 6 +1 00000014 000001F4 .word 5*100 +1 .eval 5+1, x +1 .break 6 = 6 +``` + +## **.macro/.endm** *Define Macro* + +**Syntax** *macname* **.macro** [*parameter1* [**, ... ,** *parametern*]] + +*model statements or macro directives* + +**.endm** + +**Description** The **.macro** and **.endm** directives are used to define macros. + +You can define a macro anywhere in your program, but you must define the macro before you can use it. Macros can be defined at the beginning of a source file, in an .include/.copy file, or in a macro library. + +*macname* — names the macro. You must place the name in the source statement's label field. + +**.macro** — identifies the source statement as the first line of a macro definition. You must place .macro in the opcode field. + +[*parameters*] — are optional substitution symbols that appear as operands for the .macro directive. + +*model statements* — are instructions or assembler directives that are executed each time the macro is called. + +*macro directives* — are used to control macro expansion. **.endm** marks the end of the macro definition. + +Macros are explained in further detail in Chapter 6. + +## **.mlib** *Define Macro Library* + +**Syntax** **.mlib "***filename***"** + +**Description** The **.mlib** directive provides the assembler with the *filename* of a macro library. A macro library is a collection of files that contain macro definitions. The macro definition files are bound into a single file (called a library or archive) by the archiver. + +Each file in a macro library contains one macro definition that corresponds to the name of the file. The *filename* of a macro library member must be the same as the macro name, and its extension must be .asm. The filename must follow host operating system conventions; it can be enclosed in double quotes. You can specify a full pathname (for example, c:\320tools\macs.lib). If you do not specify a full pathname, the assembler searches for the file in the following locations in the order given: + +1. The directory that contains the current source file +2. Any directories named with the --include\_path assembler option +3. Any directories specified by the PRU\_A\_DIR environment variable +4. Any directories specified by the PRU\_A\_DIR environment variable + +See Section 4.4 for more information about the --include\_path option. + +A .mlib directive causes the assembler to open the library specified by *filename* and create a table of the library's contents. The assembler stores names of individual library members in the opcode table as library entries. This redefines any existing opcodes or macros with the same name. If one of these macros is called, the assembler extracts the library entry and loads it into the macro table. The assembler expands the library entry as it does other macros, but it does not place the source code in the listing. Only macros called from the library are extracted, and they are extracted only once. + +**Example** The code creates a macro library that defines two macros, inc4.asm and dec4.asm. The file inc4.asm contains the definition of inc4 and dec4.asm contains the definition of dec4. + +| inc4.asm | dec4.asm | +|----------------------------------------------------------------|----------------------------------------------------------------| +| * Macro for incrementing
inc4 .macro reg1, reg2, reg3, reg4 | * Macro for decrementing
dec4 .macro reg1, reg2, reg3, reg4 | +| Add reg1, reg1, 1 | SUB reg1, reg1, 1 | +| ADD reg2, reg2, 1 | SUB reg2, reg2, 1 | +| ADD reg3, reg3, 1
ADD reg4, reg4, 1 | SUB reg3, reg3, 1
SUB reg4, reg4, 1 | +| .endm | .endm | + +Use the archiver to create a macro library: + +``` +armar -a mac inc4.asm dec4.asm +ar32 -a mac inc4.asm dec4.asm +``` + +Now you can use the .mlib directive to reference the macro library and define the inc4.asm and dec4.asm macros: + +``` +1 .mlib "mac.lib" + 2 ; Macro call + 3 00000000 inc4 R7, R6, R5, R4 +1 00000000 E2877001 ADD R7, R7, 1 +1 00000004 E2866001 ADD R6, R6, 1 +1 00000008 E2855001 ADD R5, R5, 1 +1 0000000c E2844001 ADD R4, R4, 1 + 4 + 5 ; Macro call + 6 00000010 dec4 R0, R1, R2, R3 +1 00000010 E2400001 SUB R0, R0, 1 +1 00000014 E2411001 SUB R1, R1, 1 +1 00000018 E2422001 SUB R2, R2, 1 +1 0000001c E2433001 SUB R3, R3, 1 +``` + +## **.mlist/.mnolist** *Start/Stop Macro Expansion Listing* + +**Syntax .mlist** + +**.mnolist** + +**Description** Two directives enable you to control the listing of macro and repeatable block expansions in the listing file: + +The **.mlist** directive allows macro and .loop/.endloop block expansions in the listing file. + +The **.mnolist** directive suppresses macro and .loop/.endloop block expansions in the listing file. + +By default, the assembler behaves as if the .mlist directive had been specified. + +See Chapter 6 for more information on macros and macro libraries. See the .loop/.break/.endloop topic for information on conditional blocks. + +**Example** This example defines a macro named STR\_3. The first time the macro is called, the macro expansion is listed (by default). The second time the macro is called, the macro expansion is not listed, because a .mnolist directive was assembled. The third time the macro is called, the macro expansion is again listed because a .mlist directive was assembled. + +``` +1 STR_3 .macro P1, P2, P3 + 2 .string ":p1:", ":p2:", ":p3:" + 3 .endm + 4 + 5 00000000 STR_3 "as", "I", "am" ; Invoke STR_3 macro. +1 00000000 3A .string ":p1:", ":p2:", ":p3:" + 00000001 70 + 00000002 31 + 00000003 3A + 00000004 3A + 00000005 70 + 00000006 32 + 00000007 3A + 00000008 3A + 00000009 70 + 0000000a 33 + 0000000b 3A + 6 .mnolist ; Suppress expansion. + 7 0000000c STR_3 "as", "I", "am" ; Invoke STR_3 macro. + 8 .mlist ; Show macro expansion. + 9 00000018 STR_3 "as", "I", "am" ; Invoke STR_3 macro. +1 00000018 3A .string ":p1:", ":p2:", ":p3:" + 00000019 70 + 0000001a 31 + 0000001b 3A + 0000001c 3A + 0000001d 70 + 0000001e 32 + 0000001f 3A + 00000020 3A + 00000021 70 + 00000022 33 + 00000023 3A +``` + +## **.newblock** *Terminate Local Symbol Block* + +**Syntax** **.newblock** + +**Description** The **.newblock** directive undefines any local labels currently defined. Local labels, by nature, are temporary; the .newblock directive resets them and terminates their scope. + +A local label is a label in the form \$*n*, where *n* is a single decimal digit, or *name*?, where *name* is a legal symbol name. Unlike other labels, local labels are intended to be used locally, and cannot be used in expressions. They can be used only as operands in 8-bit jump instructions. Local labels are not included in the symbol table. + +After a local label has been defined and (perhaps) used, you should use the .newblock directive to reset it. The .text, .data, and .sect directives also reset local labels. Local labels that are defined within an include file are not valid outside of the include file. + +See Section 4.7.3 for more information on the use of local labels. + +**Example** + +``` + 1 + 2 + 3 + 4 sign_extend_32_8 .macro dest, src + 5 .newblock + 6 MOV dest, src + 7 QBBC $1, dest, 7 + 8 FILL &dest.b1, 3 + 9$1: + 10 .endm + 11 + 12 + 13 .global sign_extend + 14 00000000 sign_extend + 15 00000000 sign_extend_32_8 R14, R14.b0 +1 .newblock +1 00000000 000000100E0EEE MOV R14, R14.b0 +1 00000004 000000C907EE02 QBBC $1, R14, 7 +1 00000008 0000002EFF012E FILL &R14.b1, 3 +1 $1: + 16 0000000c 00000020C30000 JMP R3.w2 +``` + +## **.option** *Select Listing Options* + +**Syntax** **.option** *option₁*[, *option₂*, . . .] + +**Description** + +The **.option** directive selects options for the assembler output listing. The *options* must be separated by commas; each option selects a listing feature. These are valid options: + +- **A** turns on listing of all directives and data, and subsequent expansions, macros, and blocks. +- **B** limits the listing of .byte and .char directives to one line. +- **H** limits the listing of .half and .short directives to one line. +- **L** limits the listing of .long directives to one line. +- **M** turns off macro expansions in the listing. +- **N** turns off listing (performs .nolist). +- **O** turns on listing (performs .list). +- **R** resets any B, H, M, T, and W (turns off the limits of B, H, M, T, and W). +- **T** limits the listing of .string directives to one line. +- **W** limits the listing of .word and .int directives to one line. +- X produces a cross-reference listing of symbols. You can also obtain a cross-reference listing by invoking the assembler with the --asm\_listing\_cross\_reference option (see Section 4.3). + +Options are not case sensitive. + +**Example** This example shows how to limit the listings of the .byte, .char, .int, long, .word, and .string directives to one line each. + +``` + 1 + 2 ************************************************************* + 3 ** Limit the listing of .byte, .char, .int, .long, ** + 4 ** .word, and .string directives to 1 line each. ** + 5 ************************************************************* + .option B, W, T + 6 00000000 BD .byte -'C', 0B0h, 5 + 7 00000003 BC .char -'D', 0C0h, 6 + 8 00000008 0000000A .int 10, 35 + 'a', "abc" + 9 0000001c AABBCCDD .long OAABBCCDDh, 536 + 'A' +10 00000024 000015AA .word 5546, 78h +11 0000002c 45 .string "Extended Registers" +12 +13 +14 ************************************************************* +15 ** Reset the listing options. ** +16 ************************************************************* + .option R +17 0000003e BD .byte -'C', 0B0h, 5 + 0000003f B0 + 00000040 05 +18 00000041 BC .char -'D', 0C0h, 6 + 00000042 C0 + 00000043 06 +19 00000044 0000000A .int 10, 35 + 'a', "abc" + 00000048 00000084 + 0000004c 00000061 + 00000050 00000062 + 00000054 00000063 +20 00000058 AABBCCDD .long OAABBCCDDh, 536 + 'A' + 0000005c 00000259 +21 00000060 000015AA .word 5546, 78h + 00000064 00000078 +22 00000068 45 .string "Extended Registers" + 00000069 78 + 0000006a 74 + 0000006b 65 + 0000006c 6E + 0000006d 64 + 0000006e 65 + 0000006f 64 + 00000070 20 + 00000071 52 + 00000072 65 + 00000073 67 + 00000074 69 + 00000075 73 + 00000076 74 + 00000077 65 + 00000078 72 + 00000079 73 +``` + +## **.page** *Eject Page in Listing* + +**Syntax** **.page** + +**Description** The **.page** directive produces a page eject in the listing file. The .page directive is not printed in the source listing, but the assembler increments the line counter when it encounters the .page directive. Using the .page directive to divide the source listing into logical divisions improves program readability. + +**Example** This example shows how the .page directive causes the assembler to begin a new page of the source listing. + +**Source file:** + +``` +Source file (generic) + .title "**** Page Directive Example ****" +; . +; . +; . + .page +``` + +**Listing file:** + +``` +PRU Assembler Version x.xx Day Time Year +Copyright (c) 2012-2014 Texas Instruments Incorporated +**** Page Directive Example **** PAGE 1 + 2 ; . + 3 ; . + 4 ; . +PRU Assembler Version x.xx Day Time Year +Copyright (c) 2012-2014 Texas Instruments Incorporated +**** Page Directive Example **** PAGE 2 +``` + +No Errors, No Warnings + +## **.retain/.retainrefs** *Conditionally Retain Sections In Object Module Output* + +**Syntax** **.retain**[**"***section name***"**] + +**.retainrefs**[**"***section name***"**] + +**Description** The **.retain** directive indicates that the current or specified section is not eligible for removal via conditional linking. You can also override conditional linking for a given section with the --retain linker option. You can disable conditional linking entirely with the --unused\_section\_elimination=off linker option. + +The **.retainrefs** directive indicates that any sections that refer to the current or specified section are not eligible for removal via conditional linking. + +The *section name* identifies the section. If the directive is used without a section name, it applies to the current initialized section. If the directive is applied to an uninitialized section, the section name is required. The section name must be enclosed in double quotes. A section name can contain a subsection name in the form *section name***:***subsection name*. + +The linker assumes that all sections by default are eligible for removal via conditional linking. (However, the linker does automatically retain the .reset section.) The .retain directive is useful for overriding this default conditional linking behavior for sections that you want to keep included in the link, even if the section is not referenced by any other section in the link. For example, you could apply a .retain directive to an interrupt function that you have written in assembly language, but which is not referenced from any normal entry point in the application. + +## **.sassign** *Map defined structure onto PRU registers* + +**Syntax** *label* **.sassign** *structure*, *start\_reg*, *structure* + +**Description** The **.sassign** directive is used to map a defined structure onto the PRU registers. + +The *label* is a symbol that can be used to reference the mapped structure. + +The *start\_reg* is the first register into which the structure is placed. An .sassign directive can begin at any register boundary. If the structure requires more than 32 bits of storage, multiple registers will be used as needed. Some structures require specific alignments due to how their fields are arranged within the structure. The assembler generates an error if the structure alignment requirements can not be met with the specified starting register. This argument is required. + +The *structure* is a type of structure that has been previously defined using the .struct directive. This argument is required. + +**Example** This example causes a structure of type MyStruct to be mapped to registers beginning at + +R4. The structure can be referenced with the MyName1 label. + +MyName1 .sassign R4, MyStruct + +## **.sect** *Assemble Into Named Section* + +**Syntax** + +``` +.sect " section name " +.sect " section name " [,{RO|RW}] [,{ALLOC|NOALLOC}] +``` + +**Description** + +The .sect directive defines a named section that can be used like the default .text and .data sections. The .sect directive sets *section name* to be the current section; the lines that follow are assembled into the *section name* section. + +The section name identifies the section. The section name must be enclosed in double quotes. A section name can contain a subsection name in the form section name: subsection name. See Chapter 2 for more information about sections. + +The sections can be marked read-only (RO) or read-write (RW). Also, the sections can be marked for allocation (ALLOC) or no allocation (NOALLOC). These attributes can be specified in any order, but only one attribute from each set can be selected. RO conflicts with RW, and ALLOC conflicts with NOALLOC. If conflicting attributes are specified the assembler generates an error, for example: + +``` +"t.asm", ERROR! at line 1:[E0000] Attribute RO cannot be combined with attr RW .sect "illegal_sect",RO,RW +``` + +**Example** This example defines two special-purpose sections, Sym\_Defs and Vars, and assembles code into them. + +``` + 1 ************************************************************* + 2 ** Begin assembling into .text section. ** + 3 ************************************************************* + 4 00000000 .text + 5 00000000 E3A00078 LDI R0, 78h + 6 00000004 E2801078 ADD R1, R0, 78h + 7 ************************************************************* + 8 ** Begin assembling into Sym_Defs section. ** + 9 ************************************************************* +10 00000000 .sect "Sym_Defs" +11 00000000 3D4CCCCD .float 0.05 ; Assembled into Sym_Defs +12 00000004 000000AA X: .word 0AAh ; Assembled into Sym_Defs +13 00000008 E2833028 ADD R3, R3, 28h ; Assembled into Sym_Defs +14 ************************************************************* +15 ** Begin assembling into Vars section. ** +16 ************************************************************* +17 00000000 .sect "Vars" +18 00000010 WORD_LEN .set 16 +19 00000020 DWORD_LEN .set WORD_LEN * 2 +20 00000008 BYTE_LEN .set WORD_LEN / 2 +21 ************************************************************* +22 ** Resume assembling into .text section. ** +23 ************************************************************* +24 00000008 .text +25 00000008 E2802042 ADD R2, R0, 42h ; Assembled into .text +26 0000000c 03 .byte 3, 4 ; Assembled into .text + 0000000d 04 +27 ************************************************************* +28 ** Resume assembling into Vars section. ** +29 ************************************************************* +30 00000000 .sect "Vars" +31 00000000 000D0000 .field 13, WORD_LEN +32 00000000 000D0A00 .field 0Ah, BYTE_LEN +33 00000004 00000008 .field 10q, DWORD_LEN +``` + +## **.set/.equ** *Define Assembly-Time Constant* + +**Syntax** + +symbol .set value symbol .equ value + +**Description** + +The .set and .equ directives equate a constant value to a .set symbol. The symbol can then be used in place of a value in assembly source. This allows you to equate meaningful names with constants and other values. The .set and .equ directives are identical and can be used interchangeably. + +- The symbol is a label that must appear in the label field. +- The *value* must be a well-defined expression, that is, all symbols in the expression must be previously defined in the current source module. + +Undefined external symbols and symbols that are defined later in the module cannot be used in the expression. If the expression is relocatable, the symbol to which it is assigned is also relocatable. + +The value of the expression appears in the object field of the listing. This value is not part of the actual object code and is not written to the output file. + +Symbols defined with .set or .equ can be made externally visible with the .def or .global directive (see the .global/.def/.ref topic). In this way, you can define global absolute constants. + +**Example** This example shows how symbols can be assigned with .set and .equ. + +``` + 1 ************************************************************* + 2 ** Equate symbol AUX_R1 to register AR1 and use ** + 3 ** it instead of the register. ** + 4 ************************************************************* + 5 00000001 AUX_R1 .set R1 + 6 00000000 E3A01056 LDI AUX_R1, 56h + 7 + 8 ************************************************************* + 9 ** Set symbol index to an integer expression. ** +10 ** and use it as an immediate operand. ** +11 ************************************************************* +12 00000035 INDEX .equ 100/2 + 3 +13 00000004 E2810035 ADD R0, AUX_R1, INDEX +14 +15 ************************************************************* +16 ** Set symbol SYMTAB to a relocatable expression. ** +17 ** and use it as a relocatable operand. ** +18 ************************************************************* +19 00000008 0000000A LABEL .word 10 +20 00000009' SYMTAB .set LABEL + 1 +21 +22 ************************************************************* +23 ** Set symbol NSYMS equal to the symbol INDEX ** +24 ** INDEX and use it as you would INDEX. ** +25 ************************************************************* +26 00000035 NSYMS .set INDEX +27 0000000c 00000035 .word NSYMS +``` + +## **.space/.bes** *Reserve Space* + +**Syntax** + +[*label*] **.space** *size in bytes* + +[*label*] **.bes** *size in bytes* + +**Description** + +The **.space** and **.bes** directives reserve the number of bytes given by *size in* bytes in the current section and fill them with 0s. The section program counter is incremented to point to the word following the reserved space. + +When you use a label with the .space directive, it points to the *first*byte reserved. When you use a label with the .bes directive, it points to the *last* byte reserved. + +**Example** This example shows how memory is reserved with the .space and .bes directives. + +``` + 1 ************************************************************* + 2 ** Begin assembling into the .text section. ** + 3 ************************************************************* + 4 00000000 .text + 5 + 6 ************************************************************* + 7 ** Reserve 0F0 bytes in the .text section. ** + 8 ************************************************************* + 9 00000000 .space 0F0h +10 000000f0 00000100 .word 100h, 200h + 000000f4 00000200 +11 ************************************************************* +12 ** Begin assembling into the .data section. ** +13 ************************************************************* +14 00000000 .data +15 00000000 49 .string "In .data" + 00000001 6E + 00000002 20 + 00000003 2E + 00000004 64 + 00000005 61 + 00000006 74 + 00000007 61 +16 ************************************************************* +17 ** Reserve 100 bytes in the .data section; RES_1 ** +18 ** points to the first byte that contains ** +19 ** reserved bytes. ** +20 ************************************************************* +21 00000008 RES_1: .space 100 +22 0000006c 0000000F .word 15 +23 00000070 00000008' .word RES_1 +24 ************************************************************* +25 ** Reserve 20 bytes in the .data section; RES_2 ** +26 ** points to the last byte that contains ** +27 ** reserved bytes. ** +28 ************************************************************* +29 +30 00000087 RES_2: .bes 20 +31 00000088 00000036 .word 36h +32 0000008c 00000087' .word RES_2 +``` + +## **.sslist/.ssnolist** *Control Listing of Substitution Symbols* + +**Syntax** **.sslist** + +**.ssnolist** + +**Description** Two directives allow you to control substitution symbol expansion in the listing file: + +The **.sslist** directive allows substitution symbol expansion in the listing file. The expanded line appears below the actual source line. + +The **.ssnolist** directive suppresses substitution symbol expansion in the listing file. + +By default, all substitution symbol expansion in the listing file is suppressed; the assembler acts as if the .ssnolist directive had been used. + +Lines with the pound (#) character denote expanded substitution symbols. + +**Example** This example shows code that, by default, suppresses the listing of substitution symbol expansion, and it shows the .sslist directive assembled, instructing the assembler to list substitution symbol code expansion. + +**Default listing file without .sslist:** + +``` +1 .asg r14, ARG1 +2 .asg r15, ARG2 +3 +4 00000000 0000005100EE02 QBEQ $1, ARG1, 0 +5 00000004 0000000101EEEE ADD r14, ARG1, 1 +6$1: +7 .newblock +8 +9 00000008 0000005100EF02 QBEQ $1, ARG2, 0 +10 0000000c 0000000101EFEF ADD r15, ARG2, 1 +11 00000010 $1: +12 00000010 00000020C30000 JMP r3.w2 +``` + +**Listing with .sslist added:** + +``` +1 .sslist + 2 + 3 .asg r14, ARG1 + 4 .asg r15, ARG2 + 5 + 6 00000000 0000005100EE02 QBEQ $1, ARG1, 0 +# QBEQ $1, r14, 0 + 7 00000004 0000000101EEEE ADD r14, ARG1, 1 +# ADD r14, r14, 1 + 8$1: + 9 .newblock + 10 + 11 00000008 0000005100EF02 QBEQ $1, ARG2, 0 +# QBEQ $1, r15, 0 + 12 0000000c 0000000101EFEF ADD r15, ARG2, 1 +# ADD r15, r15, 1 + 13 00000010 $1: + 14 00000010 00000020C30000 JMP r3.w2 +``` + +## **.string/.cstring** *Initialize Text* + +**Syntax** **.string** {*expr1* | "*string1*"} [**, ... ,** {*exprn* | "*stringn*"} ] + +**.cstring** {*expr1* | "*string1*"} [**, ... ,** {*exprn* | "*stringn*"} ] + +**Description** The **.string** and **.cstring** directives place 8-bit characters from a character string into the current section. The *expr* or *string* can be one of the following: + +- An expression that the assembler evaluates and treats as an 8-bit signed number. +- A character string enclosed in double quotes. Each character in a string represents a separate value, and values are stored in consecutive bytes. The entire string *must* be enclosed in quotes. + +The .cstring directive adds a NUL character needed by C; the .string directive does not add a NUL character. In addition, .cstring interprets C escapes (\\ \a \b \f \n \r \t \v \). + +The assembler truncates any values that are greater than eight bits. Operands must fit on a single source statement line. + +If you use a label, it points to the location of the first byte that is initialized. + +When you use .string and .cstring in a .struct/.endstruct sequence, the directive only defines a member's size; it does not initialize memory. For more information, see the .struct/.endstruct/.tag topic. + +**Example** In this example, 8-bit values are placed into consecutive bytes in the current section. + +``` +1 00000000 41 Str_Ptr: .string "ABCD" + 00000001 42 + 00000002 43 + 00000003 44 +2 00000004 41 .string 41h, 42h, 43h, 44h + 00000005 42 + 00000006 43 + 00000007 44 +3 00000008 41 .string "Austin", "Houston", "Dallas" + 00000009 75 + 0000000a 73 + 0000000b 74 + 0000000c 69 + 0000000d 6E + 0000000e 48 + 0000000f 6F + 00000010 75 + 00000011 73 + 00000012 74 + 00000013 6F + 00000014 6E + 00000015 44 + 00000016 61 + 00000017 6C + 00000018 6C + 00000019 61 + 0000001a 73 +4 0000001b 30 .string 36 + 12 +``` + +## **.struct/.endstruct/.tag** *Declare Structure Type* + +**Syntax** + +| [stag] | .struct | [expr] | +|------------------|--------------------|--------------------| +| [mem₀]
[mem₁] | element
element | [expr₀]
[expr₁] | +| | • | | +| • | | Ē | +| • | • | • | +| [memn] | .tag stag | [exprn] | +| · | | • | +| • | • | • | +| • | • | • | +| [memN] | element | [exprN] | +| [size] | .endstruct | | +| label | .tag | stag | + +**Description** + +The .struct directive assigns symbolic offsets to the elements of a data structure definition. This allows you to group similar data elements together and let the assembler calculate the element offset. This is similar to a C structure or a Pascal record. The struct directive does not allocate memory; it merely creates a symbolic template that can be used repeatedly. + +The **.endstruct** directive terminates the structure definition. + +The .tag directive gives structure characteristics to a *label*, simplifying the symbolic representation and providing the ability to define structures that contain other structures. The .tag directive does not allocate memory. The structure tag (stag) of a .tag directive must have been previously defined. + +Following are descriptions of the parameters used with the .struct, .endstruct, and .tag directives: + +- The stag is the structure's tag. Its value is associated with the beginning of the structure. If no stag is present, the assembler puts the structure members in the global symbol table with the value of their absolute offset from the top of the structure. The stag is optional for .struct, but is required for .tag. +- The *expr* is an optional expression indicating the beginning offset of the structure. The default starting point for a structure is 0. +- The *memn/N* is an optional label for a member of the structure. This label is absolute and equates to the present offset from the beginning of the structure. A label for a structure member cannot be declared global. +- The *element* is one of the following descriptors: .byte, .char, .int, .long, .word, .double, .half, .short, .string, .float, .field, and .tag. All of these except .tag are typical directives that initialize memory. Following a .struct directive, these directives describe the structure element's size. They do not allocate memory. The .tag directive is a special case because stag must be used (as in the definition of stag). +- The *exprn/N* is an optional expression for the number of elements described. This value defaults to 1. A .string element is considered to be one byte in size, and a .field element is one bit. +- The *size* is an optional label for the total size of the structure. + +### Directives that Can Appear in a .struct/.endstruct Sequence + +**NOTE:** The only directives that can appear in a .struct/.endstruct sequence are element descriptors, conditional assembly directives, and the .align directive, which aligns the member offsets on word boundaries. Empty structures are illegal. + +The following examples show various uses of the .struct, .tag, and .endstruct directives. + +**Example 1** + +``` + 1 REAL_REC .struct + 2 00000000000000 NOM .int + 3 00000000000004 DEN .int + 4 00000000000008 REAL_LEN .endstruct + 5 + 6 00000000 .bss REAL, REAL_LEN + 7 + 8 00000000 000000240000E0! LDI r0, REAL + 9 00000004 000000F1042084 LBBO &r4, r0, REAL_REC.DEN, $sizeof(REAL_REC.DEN) +10 00000008 00000000E4E1E1 ADD r1, r1, r4 +11 +``` + +**Example 2** + +``` +12 CPLX_REC .struct +13 00000000000000 REALI .tag REAL_REC +14 00000000000008 IMAGI .tag REAL_REC +15 00000000000010 CPLX_LEN .endstruct +16 +17 00000000 .data +18 COMPLEX .tag CPLX_REC +19 00000000 COMPLEX .space CPLX_LEN +20 +21 0000000c .text +22 +23 0000000c 000000240000E0! LDI r0, COMPLEX.REALI.NOM +24 00000010 000000F1002084 LBBO &r4, r0, 0, $sizeof(REAL_REC.NOM) +25 00000014 00000000E4E1E1 ADD r1, r1, r4 +26 +``` + +**Example 3** + +``` +27 .struct +28 +29 00000000000000 X .int +30 00000000000004 Y .int +31 00000000000008 Z .int +32 +33 0000000000000C .endstruct +34 +``` + +**Example 4** + +``` +35 BIT_REC .struct +36 00000000000000 STREAM .string 64 +37 00000000000040 BIT7 .field 7 +38 00000000000040 BIT8 .field 9 +39 00000000000042 BIT10 .field 10 +40 00000000000044 X_INT .int +41 00000000000048 BIT_LEN .endstruct +42 +``` + +## **.symdepend/.weak** *Affect Symbol Linkage and Visibility* + +**Syntax** **.symdepend** *dst symbol name*[**,** *src symbol name*] + +**.weak** *symbol name* + +**Description** These directives are used to affect symbol linkage and visibility. + +The **.symdepend** directive creates an artificial reference from the section defining *src symbol name* to the symbol *dst symbol name*. This prevents the linker from removing the section containing *dst symbol name* if the section defining *src symbol name* is included in the output module. If *src symbol name* is not specified, a reference from the current section is created. + +The **.weak** directive identifies a symbol that is used in the current module but is defined in another module. The linker resolves this symbol's definition at link time. Instead of including a weak symbol in the output file's symbol table by default (as it would for a global symbol), the linker only includes a weak symbol in the output of a "final" link if the symbol is required to resolve an otherwise unresolved reference. See Section 2.6.2 for details about how weak symbols are handled by the linker. + +The .weak directive is equivalent to the .ref directive, except that the reference has weak linkage. + +A global *symbol* is defined in the same manner as any other symbol; that is, it appears as a label or is defined by the .set, .equ, .bss, or .usect directive. If a global symbol is defined more than once, the linker issues a multiple-definition error. (The assembler can provide a similar multiple-definition error for local symbols.) The .weak directive always creates a symbol table entry for a symbol, whether the module uses the symbol or not; .symdepend, however, creates an entry only if the module actually uses the symbol. + +A symbol can be declared global in either of the following ways: + +- If the symbol is *not defined in the current module* (which includes macro, copy, and include files), use the .weak directive to tell the assembler that the symbol is defined in an external module. This prevents the assembler from issuing an unresolved reference error. At link time, the linker looks for the symbol's definition in other modules. +- If the symbol is *defined in the current module*, use the .symdepend directive to declare that the symbol and its definition can be used externally by other modules. These types of references are resolved at link time. + +For example, use the .weak and .set directives in combination as shown in the following example, which defines a weak absolute symbol "ext\_addr\_sym": + +``` +.weak ext_addr_sym +ext_addr_sym .set 0x12345678 +``` + +If you assemble such assembly source and include the resulting object file in the link, the "ext\_addr\_sym" in this example is available as a weak absolute symbol in a final link. It is a candidate for removal if the symbol is not referenced elsewhere in the application. + +## **.tab** *Define Tab Size* + +**Syntax .tab** *size* + +**Description** The **.tab** directive defines the tab size. Tabs encountered in the source input are translated to *size* character spaces in the listing. The default tab size is eight spaces. + +**Example** In this example, each of the lines of code following a .tab statement consists of a single tab character followed by an NOP instruction. + +**Source file:** + +``` +; default tab size + NOP + NOP + NOP + .tab 4 + NOP + NOP + NOP + .tab 16 + NOP + NOP + NOP +``` + +**Listing file:** + +``` +1 ; default tab size +2 00000000 E1A00000 NOP +3 00000004 E1A00000 NOP +4 00000008 E1A00000 NOP +5 +7 0000000c E1A00000 NOP +8 00000010 E1A00000 NOP +9 00000014 E1A00000 NOP +10 +12 00000018 E1A00000 NOP +13 0000001c E1A00000 NOP +14 00000020 E1A00000 NOP +``` + +## **.text** *Assemble Into the .text Section* + +**Syntax** + +.text + +**Description** + +The .text sets .text as the current section. Lines that follow this directive will be assembled into the .text section, which usually contains executable code. The section program counter is set to 0 if nothing has yet been assembled into the .text section. If code has already been assembled into the .text section, the section program counter is restored to its previous value in the section. + +The .text section is the default section. Therefore, at the beginning of an assembly, the assembler assembles code into the .text section unless you use a .data or .sect directive to specify a different section. + +For more information about sections, see Chapter 2. + +**Example** This example assembles code into the .text and .data sections. + +``` +;***************************************************** +;* Begin assembling into the .text section (default) * +;***************************************************** + .text + LDI R0, 0 ; Some code + LDI R1, 0 + +;***************************************************** +;* Begin assembling into the .data section * +;***************************************************** + .data + .word 1, 2, 3 + +;***************************************************** +;* Resume assembling into the .text section * +;***************************************************** + .text + ADD R2, R0, R1 +``` + +## **.title** *Define Page Title* + +**Syntax** **.title "***string***"** + +**Description** The **.title** directive supplies a title that is printed in the heading on each listing page. The source statement itself is not printed, but the line counter is incremented. + +The *string* is a quote-enclosed title of up to 64 characters. If you supply more than 64 characters, the assembler truncates the string and issues a warning: + +``` +*** WARNING! line x: W0001: String is too long - will be truncated +``` + +The assembler prints the title on the page that follows the directive and on subsequent pages until another .title directive is processed. If you want a title on the first page, the first source statement must contain a .title directive. + +**Example** In this example, one title is printed on the first page and a different title is printed on succeeding pages. + +**Source file:** + +``` +.title "**** Fast Fourier Transforms ****" +; . +; . +; . + .title "**** Floating-Point Routines ****" + .page +``` + +**Listing file:** + +``` +PRU Assembler Version x.xx Day Time Year +Copyright (c) 2012-2014 Texas Instruments Incorporated +**** Fast Fourier Transforms **** PAGE 1 + 2 ; . + 3 ; . + 4 ; . +PRU Assembler Version x.xx Day Time Year +Copyright (c) 2012-2014 Texas Instruments Incorporated +**** Floating-Point Routines **** PAGE 2 +``` + +No Errors, No Warnings + +## **.union/.endunion/.tag** *Declare Union Type* + +**Syntax** + +| [stag] | .union | [expr] | +|--------------------------------------------|--------------------|----------------------------------------------| +| [mem 0 ]
[mem 1 ] | element
element | [expr 0 ]
[expr 1 ] | +| | | | +| • | • | • | +| • | | • | +| [memn] | .tag stag | [exprn] | +| • | | | +| • | | • | +| • | • | • | +| [memN] | element | [exprN] | +| [size] | .endunion | | +| label | .tag | stag | + +**Description** + +The .union directive assigns symbolic offsets to the elements of alternate data structure definitions to be allocated in the same memory space. This enables you to define several alternate structures and then let the assembler calculate the element offset. This is similar to a C union. The .union directive does not allocate any memory; it merely creates a symbolic template that can be used repeatedly. + +A .struct definition can contain a .union definition, and .structs and .unions can be nested. + +The **.endunion** directive terminates the union definition. + +The .tag directive gives structure or union characteristics to a *label*, simplifying the symbolic representation and providing the ability to define structures or unions that contain other structures or unions. The .tag directive does not allocate memory. The structure or union tag of a .tag directive must have been previously defined. + +Following are descriptions of the parameters used with the .struct, .endstruct, and .tag directives: + +- The *utag* is the union's tag. Its value is associated with the beginning of the union. If no utag is present, the assembler puts the union members in the global symbol table with the value of their absolute offset from the top of the union. In this case, each member must have a unique name. +- The *expr* is an optional expression indicating the beginning offset of the union. Unions default to start at 0. This parameter can only be used with a top-level union. It cannot be used when defining a nested union. +- The *memn/N* is an optional label for a member of the union. This label is absolute and equates to the present offset from the beginning of the union. A label for a union member cannot be declared global. +- The *element* is one of the following descriptors: .byte, .char, .int, .long, .word, .double, .half, .short, .string, .float, and .field. An element can also be a complete declaration of a nested structure or union, or a structure or union declared by its tag. Following a .union directive, these directives describe the element's size. They do not allocate memory. +- The *exprn/N* is an optional expression for the number of elements described. This value defaults to 1. A .string element is considered to be one byte in size, and a .field element is one bit. +- The size is an optional label for the total size of the union. + +**Directives that Can Appear in a .union/.endunion Sequence** + +**NOTE:** The only directives that can appear in a .union/.endunion sequence are element descriptors, structure and union tags, and conditional assembly directives. Empty structures are illegal. + +These examples show unions with and without tags. + +| Example 1 | 1
2
3
4
5
6
7
8 000000
9
10
11 000000 0000- | 0000
0000
0000
0002 | xample
ival
fval
sval
real_len
employid | .global employid
.union
.word
.float
.string
.endunion
.bss
employid, real_len
.tag
xample
ADD
employid.fval, A | ; utag
; member1 = int
; member2 = float
; member3 = string
; real_len = 2
;allocate memory
; name an instance
; access union element | +|-----------|---------------------------------------------------------------------------|---------------------------------------------|--------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Example 2 | 1
2
3
4
5
6
7 | 0000
x
0000
y
0000
z
0002 | size_u | ; utag
.long
.float
.word
.endunion | ; member1 = long
; member2 = float
; member3 = word
; real_len = 2 | + +## **.usect** *Reserve Uninitialized Space* + +**Syntax** *symbol* **.usect "***section name***",** *size in bytes*[**,** *alignment*[**,** *bank offset*] ] + +**Description** The **.usect** directive reserves space for variables in an uninitialized, named section. This directive is similar to the .bss directive; both simply reserve space for data and that space has no contents. However, .usect defines additional sections that can be placed anywhere in memory, independently of the .bss section. + +- The *symbol* points to the first location reserved by this invocation of the .usect directive. The symbol corresponds to the name of the variable for which you are reserving space. +- The *section name* must be enclosed in double quotes. This parameter names the uninitialized section. A section name can contain a subsection name in the form *section name* **:** *subsection name*. +- The *size in bytes* is an expression that defines the number of bytes that are reserved in *section name*. +- The *alignment* is an optional parameter that ensures that the space allocated to the symbol occurs on the specified boundary. The boundary can be set to any power of 2. +- The *bank offset* is an optional parameter that ensures that the space allocated to the symbol occurs on a specific memory bank boundary. The bank offset value measures the number of bytes to offset from the alignment specified before assigning the symbol to that location. + +Initialized sections directives (.text, .data, and .sect) tell the assembler to pause assembling into the current section and begin assembling into another section. A .usect or .bss directive encountered in the current section is simply assembled, and assembly continues in the current section. + +Variables that can be located contiguously in memory can be defined in the same specified section; to do so, repeat the .usect directive with the same section name and the subsequent symbol (variable name). + +For more information about sections, see Chapter 2. + +**Example** This example uses the .usect directive to define two uninitialized, named sections, var1 and var2. The symbol ptr points to the first byte reserved in the var1 section. The symbol array points to the first byte in a block of 100 bytes reserved in var1, and dflag points to the first byte in a block of 50 bytes in var1. The symbol vec points to the first byte reserved in the var2 section. + +``` + 1 + 2 **************************************************** + 3 ** Assemble into the .text section. ** + 4 **************************************************** + 4 00000000 .text + 5 00000000 E3A01003 LDI R1, 03h + 6 + 7 **************************************************** + 8 ** Reserve 1 byte in the var1 section. ** + 9 **************************************************** +10 00000000 ptr .usect "var1", 1 +11 +12 **************************************************** +13 ** Reserve 100 bytes in the var1 section. ** +14 **************************************************** +15 00000001 array .usect "var1", 100 +16 +17 00000004 E281001F ADD R0, R1, 037 ; Still in .text +18 +19 **************************************************** +20 ** Reserve 50 bytes in the var1 section. ** +21 **************************************************** +22 00000065 dflag .usect "var1", 50 +23 +24 00000008 E2812064 ADD R2, R1, dflag - array ; Still in .text +25 +26 **************************************************** +27 ** Reserve 100 bytes in the var2 section. ** +28 **************************************************** +29 00000000 vec .usect "var2", 100 +30 +31 0000000c E0824000 ADD R4, R2, R0 ; Still in .text +32 **************************************************** +33 ** Declare a .usect symbol to be external. ** +34 **************************************************** +35 .global array +``` + +Figure 5-8 shows how this example reserves space in two uninitialized sections, var1 and var2. + +![Figure 5-8: The .usect Directive — memory layout diagram showing sections var1 (152 bytes: ptr, array, dflag) and var2 (100 bytes: vec)](_page_133_Figure_5.jpeg) + +**Figure 5-8: The .usect Directive.** Memory layout diagram showing how `.usect` reserves uninitialized space in named sections. Section var1 contains three consecutive allocations: symbol ptr (pointing to offset 00000000), symbol array (offset 00000001, 100 bytes), and symbol dflag (offset 00000065, 50 bytes), totaling 152 bytes. Section var2 contains symbol vec (100 bytes). Each label arrow points to the symbol's starting address within its section. + +## **.unasg/.undefine** *Turn Off Substitution Symbol* + +**Syntax** **.unasg** *symbol* + +**.undefine** *symbol* + +**Description** The **.unasg** and **.undefine** directives remove the definition of a substitution symbol created using .asg or .define. The named *symbol* will removed from the substitution symbol table from the point of the .undefine or .unasg to the end of the assembly file. See Section 4.7.8 for more information on substitution symbols. + +These directives can be used to remove from the assembly environment any C/C++ macros that may cause a problem. See Chapter 13 for more information about using C/C++ headers in assembly source. + +## **.var** *Use Substitution Symbols as Local Variables* + +**Syntax** **.var** *sym1*[**,** *sym2***, ... ,** *symn*] + +**Description** The **.var** directive allows you to use substitution symbols as local variables within a macro. With this directive, you can define up to 32 local macro substitution symbols (including parameters) per macro. + +The .var directive creates temporary substitution symbols with the initial value of the null string. These symbols are not passed in as parameters, and they are lost after expansion. + +See Section 4.7.8 for more information on substitution symbols .See Chapter 6 for information on macros. + +# 6 Macro Language Description + +The PRU assembler supports a macro language that enables you to create your own instructions. This is especially useful when a program executes a particular task several times. The macro language lets you: + +- Define your own macros and redefine existing macros +- Simplify long or complicated assembly code +- Access macro libraries created with the archiver +- Define conditional and repeatable blocks within a macro +- Manipulate strings within a macro +- Control expansion listing + +**Topic** ........................................................................................................................... **Page** + +| 6.1 | Using Macros | 137 | +|------|-----------------------------------------------|-----| +| 6.2 | Defining Macros | 137 | +| 6.3 | Macro Parameters/Substitution Symbols | 139 | +| 6.4 | Macro Libraries | 145 | +| 6.5 | Using Conditional Assembly in Macros | 145 | +| 6.6 | Using Labels in Macros | 147 | +| 6.7 | Producing Messages in Macros | 148 | +| 6.8 | Using Directives to Format the Output Listing | 149 | +| 6.9 | Using Recursive and Nested Macros | 150 | +| 6.10 | Macro Directives Summary | 151 | + +## 6.1 Using Macros + +Programs often contain routines that are executed several times. Instead of repeating the source statements for a routine, you can define the routine as a macro, then call the macro in the places where you would normally repeat the routine. This simplifies and shortens your source program. + +If you want to call a macro several times but with different data each time, you can assign parameters within a macro. This enables you to pass different information to the macro each time you call it. The macro language supports a special symbol called a *substitution symbol*, which is used for macro parameters. See Section 6.3 for more information. + +Using a macro is a 3-step process. + +- Step 1. **Define the macro.** You must define macros before you can use them in your program. There are two methods for defining macros: + - a. Macros can be defined at the beginning of a *source file* or in a copy/include file. See Section 6.2, *Defining Macros*, for more information. + - b. Macros can also be defined in a *macro library*. A macro library is a collection of files in archive format created by the archiver. Each member of the archive file (macro library) may contain one macro definition corresponding to the member name. You can access a macro library by using the .mlib directive. For more information, see Section 6.4. +- Step 2. **Call the macro.** After you have defined a macro, call it by using the macro name as a mnemonic in the source program. This is referred to as a *macro call*. +- Step 3. **Expand the macro.** The assembler expands your macros when the source program calls them. During expansion, the assembler passes arguments by variable to the macro parameters, replaces the macro call statement with the macro definition, then assembles the source code. By default, the macro expansions are printed in the listing file. You can turn off expansion listing by using the .mnolist directive. For more information, see Section 6.8. + +When the assembler encounters a macro definition, it places the macro name in the opcode table. This redefines any previously defined macro, library entry, directive, or instruction mnemonic that has the same name as the macro. This allows you to expand the functions of directives and instructions, as well as to add new instructions. + +## 6.2 Defining Macros + +You can define a macro anywhere in your program, but you must define the macro before you can use it. Macros can be defined at the beginning of a source file or in a .copy/.include file (see Copy Source File); they can also be defined in a macro library. For more information about macro libraries, see Section 6.4. + +Macro definitions can be nested, and they can call other macros, but all elements of the macro must be defined in the same file. Nested macros are discussed in Section 6.9. + +A macro definition is a series of source statements in the following format: + +| macname | .macro
[parameter1
] [, , parametern
] | | +|---------|-------------------------------------------------|--| +| | model statements or macro directives | | +| | [.mexit] | | +| | .endm | | + +*macname* names the macro. You must place the name in the source statement's label field. + +Only the first 128 characters of a macro name are significant. The assembler places the macro name in the internal opcode table, replacing any instruction or previous macro definition with the same name. + +**.macro** is the directive that identifies the source statement as the first line of a macro definition. You must place .macro in the opcode field. + +*parameter* 1 , *parameter* n are optional substitution symbols that appear as operands for the .macro directive. + +Parameters are discussed in Section 6.3. + +*model statements* are instructions or assembler directives that are executed each time the macro is called. + +*macro directives* are used to control macro expansion. + +**.mexit** is a directive that functions as a *goto .endm*. The .mexit directive is useful when error testing confirms that macro expansion fails and completing the rest of the macro is unnecessary. + +**.endm** is the directive that terminates the macro definition. + +If you want to include comments with your macro definition but *do not* want those comments to appear in the macro expansion, use an exclamation point to precede your comments. If you *do* want your comments to appear in the macro expansion, use an asterisk or semicolon. See Section 6.7 for more information about macro comments. + +Example 6-1 shows the definition, call, and expansion of a macro. + +### Example 6-1. Macro Definition, Call, and Expansion + +Macro definition: The following code defines a macro, add3, with four parameters: + +``` +1 * +2 +3 * add3 +4 * +5 * ADDRP = P1 + P2 + P3 +6 +7 add3 .macro P1, P2, P3, ADDRP +8 +9 ADD ADDRP, P1, P2 +10 ADD ADDRP, ADDRP, P3 +11 .endm +``` + +Macro call: The following code calls the add3 macro with four arguments: + +``` +12 +13 00000000 add3 R1, R2, R3, R0 +``` + +Macro expansion: The following code shows the substitution of the macro definition for the macro call. The assembler substitutes R1, R2, R3, and R0 for the P1, P2, P3, and ADDRP parameters of add3. + +``` +1 +1 00000000 E0810002 ADD R0, R1, R2 +1 00000004 E0800003 ADD R0, R0, R3 +``` + +## 6.3 Macro Parameters/Substitution Symbols + +If you want to call a macro several times with different data each time, you can assign parameters within the macro. The macro language supports a special symbol, called a *substitution symbol*, which is used for macro parameters. + +Macro parameters are substitution symbols that represent a character string. These symbols can also be used outside of macros to equate a character string to a symbol name (see Section 4.7.8). + +Valid substitution symbols can be up to 128 characters long and *must begin with a letter*. The remainder of the symbol can be a combination of alphanumeric characters, underscores, and dollar signs. + +Substitution symbols used as macro parameters are local to the macro they are defined in. You can define up to 32 local substitution symbols (including substitution symbols defined with the .var directive) per macro. For more information about the .var directive, see Section 6.3.6. + +During macro expansion, the assembler passes arguments by variable to the macro parameters. The character-string equivalent of each argument is assigned to the corresponding parameter. Parameters without corresponding arguments are set to the null string. If the number of arguments exceeds the number of parameters, the last parameter is assigned the character-string equivalent of all remaining arguments. + +If you pass a list of arguments to one parameter or if you pass a comma or semicolon to a parameter, you must surround these terms with quotation marks. + +At assembly time, the assembler replaces the macro parameter/substitution symbol with its corresponding character string, then translates the source code into object code. + +Example 6-2 shows the expansion of a macro with varying numbers of arguments. + +### Example 6-2. Calling a Macro With Varying Numbers of Arguments + +``` +Macro definition: +Parms .macro a,b,c +; a = :a: +; b = :b: +; c = :c: + .endm +Calling the macro: + Parms 100,label Parms 100,label,x,y +; a = 100 ; a = 100 +; b = label ; b = label +; c = "" ; c = x,y + Parms 100, , x Parms "100,200,300",x,y +; a = 100 ; a = 100,200,300 +; b = "" ; b = x +; c = x ; c = y + Parms """string""",x,y +; a = "string" +; b = x +; c = y +``` + +### 6.3.1 Directives That Define Substitution Symbols + +You can manipulate substitution symbols with the **.asg** and **.eval** directives. + +• The **.asg** directive assigns a character string to a substitution symbol. + +For the .asg directive, the quotation marks are optional. If there are no quotation marks, the assembler reads characters up to the first comma and removes leading and trailing blanks. In either case, a character string is read and assigned to the *substitution symbol*. The syntax of the .asg directive is: + +``` +.asg["]character string["], substitution symbol +``` + +Example 6-3 shows character strings being assigned to substitution symbols. + +### Example 6-3. The .asg Directive + +``` +.asg R2, stack_ptr ; stack pointer +``` + +• The **.eval** directive performs arithmetic on numeric substitution symbols. + +The .eval directive evaluates the *expression* and assigns the string value of the result to the *substitution symbol*. If the expression is not well defined, the assembler generates an error and assigns the null string to the symbol. The syntax of the .eval directive is: + +``` +.eval well-defined expression , substitution symbol +``` + +Example 6-4 shows arithmetic being performed on substitution symbols. + +### Example 6-4. The .eval Directive + +``` +.asg 1,counter +.loop 100 +.word counter +.eval counter + 1,counter +.endloop +``` + +In Example 6-4, the .asg directive could be replaced with the .eval directive (.eval 1, counter) without changing the output. In simple cases like this, you can use .eval and .asg interchangeably. However, you must use .eval if you want to calculate a *value* from an expression. While .asg only assigns a character string to a substitution symbol, .eval evaluates an expression and then assigns the character string equivalent to a substitution symbol. + +See Assign a Substitution Symbol for more information about the .asg and .eval assembler directives. + +### 6.3.2 Built-In Substitution Symbol Functions + +The following built-in substitution symbol functions enable you to make decisions on the basis of the string value of substitution symbols. These functions always return a value, and they can be used in expressions. Built-in substitution symbol functions are especially useful in conditional assembly expressions. Parameters of these functions are substitution symbols or character-string constants. + +In the function definitions shown in Table 6-1, *a* and *b* are parameters that represent substitution symbols or character-string constants. The term *string* refers to the string value of the parameter. The symbol *ch* represents a character constant. + +**Table 6-1. Substitution Symbol Functions and Return Values** + +| Function | Return Value | +|------------------|--------------------------------------------------------------------| +| \$symlen (a) | Length of string a | +| \$symcmp (a,b) | < 0 if a < b; 0 if a = b; > 0 if a > b | +| \$firstch (a,ch) | Index of the first occurrence of character constant ch in string a | +| \$lastch (a,ch) | Index of the last occurrence of character constant ch in string a | +| \$isdefed (a) | 1 if string a is defined in the symbol table | +| | 0 if string a is not defined in the symbol table | +| \$ismember (a,b) | Top member of list b is assigned to string a | +| | 0 if b is a null string | +| \$iscons (a) | 1 if string a is a binary constant | +| | 2 if string a is an octal constant | +| | 3 if string a is a hexadecimal constant | +| | 4 if string a is a character constant | +| | 5 if string a is a decimal constant | +| \$isname (a) | 1 if string a is a valid symbol name | +| | 0 if string a is not a valid symbol name | +| \$isreg (a) (1) | 1 if string a is a valid predefined register name | +| | 0 if string a is not a valid predefined register name | +| | | + +(1) For more information about predefined register names, see Section 4.7.6. + +Example 6-5 shows built-in substitution symbol functions. + +### Example 6-5. Using Built-In Substitution Symbol Functions + +``` +.asg label, ADDR ; ADDR = label +.if ($symcmp(ADDR, "label") = 0) ; evaluates to true +LDI R4, ADDR +.endif +.asg "x,y,z" , list ; list = x,y,z +.if ($ismember(ADDR,list)) ; ADDR = x, list = y,z +SUB R4, R4, 4 ; sub x +.endif +``` + +### 6.3.3 Recursive Substitution Symbols + +When the assembler encounters a substitution symbol, it attempts to substitute the corresponding character string. If that string is also a substitution symbol, the assembler performs substitution again. The assembler continues doing this until it encounters a token that is not a substitution symbol or until it encounters a substitution symbol that it has already encountered during this evaluation. + +In Example 6-6, the x is substituted for z; z is substituted for y; and y is substituted for x. The assembler recognizes this as infinite recursion and ceases substitution. + +### Example 6-6. Recursive Substitution + +``` +.asg "x",z ; declare z and assign z = "x" + .asg "z",y ; declare y and assign y = "z" + .asg "y",x ; declare x and assign x = "y" + LDI R0, x +* LDI R0, x ; recursive expansion +``` + +### 6.3.4 Forced Substitution + +In some cases, substitution symbols are not recognizable to the assembler. The forced substitution operator, which is a set of colons surrounding the symbol, enables you to force the substitution of a symbol's character string. Simply enclose a symbol with colons to force the substitution. Do not include any spaces between the colons and the symbol. The syntax for the forced substitution operator is: + +``` +:symbol: +``` + +The assembler expands substitution symbols surrounded by colons before expanding other substitution symbols. + +You can use the forced substitution operator only inside macros, and you cannot nest a forced substitution operator within another forced substitution operator. + +Example 6-7 shows how the forced substitution operator is used. + +### Example 6-7. Using the Forced Substitution Operator + +``` +1 + force + .macro + 2 + .asg 0,x + 3 + .loop 8 + AUX:x: .set x + 4 + 5 + .eval x+1,x + 6 + .endloop + 7 + .endm + 8 + 9 00000000 + force + .asg 0,x +1 + .loop 8 +1 + AUX:x: .set x +1 + .eval x+1,x +1 + .endloop +2 + 00000000 AUX0 .set 0 +2 + .eval 0+1,x +2 + 00000001 AUX1 .set 1 + .eval 1+1,x +2 +2 + 00000002 AUX2 .set 2 +2 + .eval 2+1,x +2 + 00000003 AUX3 .set 3 +2 + .eval 3+1,x +2 + 00000004 AUX4 .set 4 +2 + .eval 4+1,x +2 + 00000005 AUX5 .set 5 +2 + .eval 5+1,x +2 + 00000006 AUX6 .set 6 +2 + .eval 6+1,x +2 + 00000007 AUX7 .set 7 +2 + .eval 7+1,x +``` + +### 6.3.5 Accessing Individual Characters of Subscripted Substitution Symbols + +In a macro, you can access the individual characters (substrings) of a substitution symbol with subscripted substitution symbols. You must use the forced substitution operator for clarity. + +You can access substrings in two ways: + +- :symbol (well-defined expression): + - This method of subscripting evaluates to a character string with one character. +- :symbol (well-defined expression 1, well-defined expression 2): + - In this method, expression1 represents the substring's starting position, and expression2 represents the substring's length. You can specify exactly where to begin subscripting and the exact length of the resulting character string. *The index of substring characters begins with 1, not 0.* + +Example 6-8 and Example 6-9 show built-in substitution symbol functions used with subscripted substitution symbols. In Example 6-8, subscripted substitution symbols redefine the ADD instruction so that it handles short immediate values. In Example 6-9, the subscripted substitution symbol is used to find a substring strg1 beginning at position start in the string strg2. The position of the substring strg1 is assigned to the substitution symbol pos. + +### Example 6-8. Using Subscripted Substitution Symbols to Redefine an Instruction + +``` +ADDX .macro dst, imm + .var TMP + .asg :imm(1):, TMP + .if $symcmp(TMP,"#") = 0 + ADD dst, dst, imm + .else + .emsg "Bad Macro Parameter" + .endif + .endm + ADDX R9, 100 ; macro call + ADDX R9, R8 ; macro call +``` + +### Example 6-9. Using Subscripted Substitution Symbols to Find Substrings + +``` +substr .macro start,strg1,strg2,pos + .var LEN1,LEN2,I,TMP + .if $symlen(start) = 0 + .eval 1,start + .endif + .eval 0,pos + .eval 1,i + .eval $symlen(strg1),LEN1 + .eval $symlen(strg2),LEN2 + .loop + .break I = (LEN2 - LEN1 + 1) + .asg ":strg2(I,LEN1):",TMP + .eval i,pos + .break + .else + .eval I + 1,i + .endif + .endloop + .endm + .asg 0,pos + .asg "ar1 ar2 ar3 ar4",regs + substr 1,"ar2",regs,pos + .word pos +``` + +### 6.3.6 Substitution Symbols as Local Variables in Macros + +If you want to use substitution symbols as local variables within a macro, you can use the **.var** directive to define up to 32 local macro substitution symbols (including parameters) per macro. The .var directive creates temporary substitution symbols with the initial value of the null string. These symbols are not passed in as parameters, and they are lost after expansion. + +``` +.var sym1 + [,sym2 + , ... ,symn + ] +``` + +The .var directive is used in Example 6-8 and Example 6-9. + +## 6.4 Macro Libraries + +One way to define macros is by creating a macro library. A macro library is a collection of files that contain macro definitions. You must use the archiver to collect these files, or members, into a single file (called an archive). Each member of a macro library contains one macro definition. The files in a macro library must be unassembled source files. The macro name and the member name must be the same, and the macro filename's extension must be .asm. For example: + +| Macro Name | Filename in Macro Library | +|------------|---------------------------| +| simple | simple.asm | +| add3 | add3.asm | + +You can access the macro library by using the .mlib assembler directive (described in Define Macro Library\). The syntax is: + +**.mlib** *filename* + +When the assembler encounters the .mlib directive, it opens the library named by filename and creates a table of the library's contents. The assembler enters the names of the individual members within the library into the opcode tables as library entries; this redefines any existing opcodes or macros that have the same name. If one of these macros is called, the assembler extracts the entry from the library and loads it into the macro table. + +The assembler expands the library entry the same way it expands other macros. See Section 6.1 for how the assembler expands macros. You can control the listing of library entry expansions with the .mlist directive. For information about the .mlist directive, see Section 6.8 and Start/Stop Macro Expansion Listing. Only macros that are actually called from the library are extracted, and they are extracted only once. + +You can use the archiver to create a macro library by including the desired files in an archive. A macro library is no different from any other archive, except that the assembler expects the macro library to contain macro definitions. The assembler expects *only* macro definitions in a macro library; putting object code or miscellaneous source files into the library may produce undesirable results. For information about creating a macro library archive, see Section 7.1. + +## 6.5 Using Conditional Assembly in Macros + +The conditional assembly directives are **.if/.elseif/.else/.endif** and **.loop/ .break/.endloop**. They can be nested within each other up to 32 levels deep. The format of a conditional block is: + +**.if** *well-defined expression* [**.elseif** *well-defined expression*] [**.else**] **.endif** + +The **.elseif** and **.else** directives are optional in conditional assembly. The .elseif directive can be used more than once within a conditional assembly code block. When .elseif and .else are omitted and when the .if expression is false (0), the assembler continues to the code following the .endif directive. See Assemble Conditional Blocks for more information on the .if/ .elseif/.else/.endif directives. + +The **.loop/.break/.endloop** directives enable you to assemble a code block repeatedly. The format of a repeatable block is: + +**.loop** [*well-defined expression*] [**.break** [*well-defined expression*]] **.endloop** + +The **.loop** directive's optional *well-defined expression* evaluates to the loop count (the number of loops to be performed). If the expression is omitted, the loop count defaults to 1024 unless the assembler encounters a .break directive with an expression that is true (nonzero). See Assemble Conditional Blocks Repeatedly for more information on the .loop/.break/.endloop directives. + +The **.break** directive and its expression are optional in repetitive assembly. If the expression evaluates to false, the loop continues. The assembler breaks the loop when the .break expression evaluates to true or when the .break expression is omitted. When the loop is broken, the assembler continues with the code after the .endloop directive. For more information, see Section 5.7. + +Example 6-10, Example 6-11, and Example 6-12 show the .loop/.break/ .endloop directives, properly nested conditional assembly directives, and built-in substitution symbol functions used in a conditional assembly code block. + +### Example 6-10. The .loop/.break/.endloop Directives + +``` +.asg 1,x +.loop +.break (x == 10) ; if x == 10, quit loop/break with expression +.eval x+1,x +.endloop +``` + +### Example 6-11. Nested Conditional Assembly Directives + +``` +.asg 1,x +.loop +.if (x == 10) ; if x == 10, quit loop +.break (x == 10) ; force break +.endif +.eval x+1,x +.endloop +``` + +### Example 6-12. Built-In Substitution Symbol Functions in a Conditional Assembly Code Block + +``` +.fcnolist +* +*Double Add or Subtract +* +DBL .macro ABC, dsth, dstl, srch, srcl ; add or subtract double + .if $symcmp(ABC,"+") + ADD dstl, dstl, srcl ; add double + ADC dsth, dsth, srch + .elseif $symcmp(ABC,"-") + SUB dstl, dstl, srcl ; subtract double + SUBC dsth, dsth, srch + .else + .emsg "Incorrect Operator Parameter" + .endif + .endm +*Macro Call + DBL -, R4, R5, R6, R7 +``` + +## 6.6 Using Labels in Macros + +All labels in an assembly language program must be unique. This includes labels in macros. If a macro is expanded more than once, its labels are defined more than once. *Defining a label more than once is illegal*. The macro language provides a method of defining labels in macros so that the labels are unique. Simply follow each label with a question mark, and the assembler replaces the question mark with a period followed by a unique number. When the macro is expanded, *you do not see the unique number in the listing file*. Your label appears with the question mark as it did in the macro definition. You cannot declare this label as global. See Section 4.7.3 for more about labels. + +The syntax for a unique label is: + +``` +label ? +``` + +unique label generation in a macro. The maximum label length is shortened to allow for the unique suffix. For example, if the macro is expanded fewer than 10 times, the maximum label length is 126 characters. If the macro is expanded from 10 to 99 times, the maximum label length is 125. The label with its unique suffix is shown in the cross-listing file. To obtain a cross-listing file, invoke the assembler with the --cross\_reference option (see Section 4.3). + +### Example 6-13. Unique Labels in a Macro + +``` +1 + 2 + 3 + 4 sign_extend_32_8 .macro dest, src + 5 MOV dest, src + 6 QBBC $1, dest, 7 + 7 FILL &dest.b1, 3 + 8end?: + 9 .endm + 10 + 11 + 12 .global sign_extend + 13 00000000 sign_extend + 14 00000000 sign_extend_32_8 R14, R14.b0 +1 00000000 000000100E0EEE MOV R14, R14.b0 +1 00000004 000000C907EE02 QBBC $1, R14, 7 +1 00000008 0000002EFF012E FILL &R14.b1, 3 +1 end? + 15 0000000c 00000020C30000 JMP R3.w2 +``` + +## 6.7 Producing Messages in Macros + +The macro language supports three directives that enable you to define your own assembly-time error and warning messages. These directives are especially useful when you want to create messages specific to your needs. The last line of the listing file shows the error and warning counts. These counts alert you to problems in your code and are especially useful during debugging. + +**.emsg** sends error messages to the listing file. The .emsg directive generates errors in the same manner as the assembler, incrementing the error count and preventing the assembler from producing an object file. + +**.mmsg** sends assembly-time messages to the listing file. The .mmsg directive functions in the same manner as the .emsg directive but does not set the error count or prevent the creation of an object file. + +**.wmsg** sends warning messages to the listing file. The .wmsg directive functions in the same manner as the .emsg directive, but it increments the warning count and does not prevent the generation of an object file. + +**Macro comments** are comments that appear in the definition of the macro *but do not show up in the expansion of the macro*. An exclamation point in column 1 identifies a macro comment. If you want your comments to appear in the macro expansion, precede your comment with an asterisk or semicolon. + +Example 6-14 shows user messages in macros and macro comments that do not appear in the macro expansion. + +For more information about the .emsg, .mmsg, and .wmsg assembler directives, see Define Messages. + +### Example 6-14. Producing Messages in a Macro + +``` +1 MUL_I .macro x,y + 2 .if ($symlen(x) ==0) + 3 .emsg "ERROR -- Missing Parameter" + 4 .mexit + 5 .elseif ($symlen(y) == 0) + 6 .emsg "ERROR -- Missing Parameter" + 7 .mexit + 8 .else + ... + 12 .endif + 13 .endm + 14 + 15 00000000 MUL_I 50, 51 +1 .if ($symlen(x) ==0) +1 .emsg "ERROR -- Missing Parameter" +1 .mexit +1 .elseif ($symlen(y) == 0) +1 .emsg "ERROR -- Missing Parameter" +1 .mexit +1 .else + ... +1 .endif + 16 + 17 0000000c MUL_I +1 .if ($symlen(x) ==0) +1 .emsg "ERROR -- Missing Parameter" +***** USER ERROR ***** - : ERROR -- Missing Parameter +1 .mexit +1 Error, No Warnings +``` + +## 6.8 Using Directives to Format the Output Listing + +Macros, substitution symbols, and conditional assembly directives may hide information. You may need to see this hidden information, so the macro language supports an expanded listing capability. + +By default, the assembler shows macro expansions and false conditional blocks in the list output file. You may want to turn this listing off or on within your listing file. Four sets of directives enable you to control the listing of this information: + +**Macro and loop expansion listing** + +**.mlist** expands macros and .loop/.endloop blocks. The .mlist directive prints all code + +encountered in those blocks. + +**.mnolist** suppresses the listing of macro expansions and .loop/ .endloop blocks. + +For macro and loop expansion listing, .mlist is the default. + +**False conditional block listing** + +**.fclist** causes the assembler to include in the listing file all conditional blocks that do not + +generate code (false conditional blocks). Conditional blocks appear in the listing + +exactly as they appear in the source code. + +**.fcnolist** suppresses the listing of false conditional blocks. Only the code in conditional blocks + +that actually assemble appears in the listing. The .if, .elseif, .else, and .endif directives + +do not appear in the listing. + +For false conditional block listing, .fclist is the default. + +**Substitution symbol expansion listing** + +**.sslist** expands substitution symbols in the listing. This is useful for debugging the expansion + +of substitution symbols. The expanded line appears below the actual source line. + +**.ssnolist** turns off substitution symbol expansion in the listing. + +For substitution symbol expansion listing, .ssnolist is the default. + +**Directive listing** + +**.drlist** causes the assembler to print to the listing file all directive lines. + +**.drnolist** suppresses the printing of certain directives in the listing file. These directives are + +.asg, .eval, .var, .sslist, .mlist, .fclist, .ssnolist, .mnolist, .fcnolist, .emsg, .wmsg, + +.mmsg, .length, .width, and .break. + +For directive listing, .drlist is the default. + +## 6.9 Using Recursive and Nested Macros + +The macro language supports recursive and nested macro calls. This means that you can call other macros in a macro definition. You can nest macros up to 32 levels deep. When you use recursive macros, you call a macro from its own definition (the macro calls itself). + +When you create recursive or nested macros, you should pay close attention to the arguments that you pass to macro parameters because the assembler uses dynamic scoping for parameters. This means that the called macro uses the environment of the macro from which it was called. + +Example 6-15 shows nested macros. The y in the in\_block macro hides the y in the out\_block macro. The x and z from the out\_block macro, however, are accessible to the in\_block macro. + +### Example 6-15. Using Nested Macros + +``` +in_block .macro y,a + . ; visible parameters are y,a and x,z from the calling macro + .endm +out_block .macro x,y,z + . ; visible parameters are x,y,z + . + in_block x,y ; macro call with x and y as arguments + . + . + .endm + out_block ; macro call +``` + +recursive and fact macros. The fact macro produces assembly code necessary to calculate the factorial of n, where n is an immediate value. The result is placed in data memory address loc. The fact macro accomplishes this by calling fact1, which calls itself recursively. + +### Example 6-16. Using Recursive Macros + +``` +fact .macro N, R26 ; N is an integer constant. Register R26 address = N! + .if N < 2 ; 0! = 1! = 1 + LDI R26, 1 + .else + LDI R26, N ; N >= 2 so, store N in R26. + .eval -1, N ; Decrement N, and do the factorial of N - 1. + fact1 ; Call fact with current environment. + .endm +fact1 .macro + .if N > 1 + LDI R28, N ; N > 1 so, store N in R0 + MOV R29, R26 ; hardware multiplier result register is R26 + XIN 0, &R26, 4 + .eval N - 1, N ; Decrement position. + fact1 ; Recursive call. + .endif + .endm +``` + +## 6.10 Macro Directives Summary + +The directives listed in Table 6-2 through Table 6-6 can be used with macros. The .macro, .mexit, .endm and .var directives are valid only with macros; the remaining directives are general assembly language directives. + +### Table 6-2. Creating Macros + +| | | See | | +|--------------------------------------------------------|-----------------------------------------------|-------------|-------------| +| Mnemonic and Syntax | Description | Macro Use | Directive | +| .endm | End macro definition | Section 6.2 | .endm | +| macname .macro
[parameter1
][, , parametern
] | Define macro by macname | Section 6.2 | .macro | +| .mexit | Go to .endm | Section 6.2 | Section 6.2 | +| .mlib filename | Identify library containing macro definitions | Section 6.4 | .mlib | + +### Table 6-3. Manipulating Substitution Symbols + +| | | | See | | +|----------------------------------------------------|----------------------------------------------------|---------------|-----------|--| +| Mnemonic and Syntax | Description | Macro Use | Directive | | +| .asg ["]character string["], substitution symbol | Assign character string to substitution symbol | Section 6.3.1 | .asg | | +| .eval well-defined expression, substitution symbol | Perform arithmetic on numeric substitution symbols | Section 6.3.1 | .eval | | +| .var
sym1
[, sym2
,, symn
] | Define local macro symbols | Section 6.3.6 | .var | | + +### Table 6-4. Conditional Assembly + +| Mnemonic and Syntax | Description | See | | +|----------------------------------|-------------------------------------|-------------|-----------| +| | | Macro Use | Directive | +| .break [well-defined expression] | Optional repeatable block assembly | Section 6.5 | .break | +| .endif | End conditional assembly | Section 6.5 | .endif | +| .endloop | End repeatable block assembly | Section 6.5 | .endloop | +| .else | Optional conditional assembly block | Section 6.5 | .else | +| .elseif well-defined expression | Optional conditional assembly block | Section 6.5 | .elseif | +| .if well-defined expression | Begin conditional assembly | Section 6.5 | .if | +| .loop [well-defined expression] | Begin repeatable block assembly | Section 6.5 | .loop | + +### Table 6-5. Producing Assembly-Time Messages + +| Mnemonic and Syntax | Description | See | | +|---------------------|-----------------------------------------------|-------------|-----------| +| | | Macro Use | Directive | +| .emsg | Send error message to standard output | Section 6.7 | .emsg | +| .mmsg | Send assembly-time message to standard output | Section 6.7 | .mmsg | +| .wmsg | Send warning message to standard output | Section 6.7 | .wmsg | + +### Table 6-6. Formatting the Listing + +| Mnemonic and Syntax | Description | See | | +|---------------------|---------------------------------------------------------|-------------|-----------| +| | | Macro Use | Directive | +| .fclist | Allow false conditional code block listing (default) | Section 6.8 | .fclist | +| .fcnolist | Suppress false conditional code block listing | Section 6.8 | .fcnolist | +| .mlist | Allow macro listings (default) | Section 6.8 | .mlist | +| .mnolist | Suppress macro listings | Section 6.8 | .mnolist | +| .sslist | Allow expanded substitution symbol listing | Section 6.8 | .sslist | +| .ssnolist | Suppress expanded substitution symbol listing (default) | Section 6.8 | .ssnolist | + +# 7 Archiver Description + +The PRU archiver lets you combine several individual files into a single archive file. For example, you can collect several macros into a macro library. The assembler searches the library and uses the members that are called as macros by the source file. You can also use the archiver to collect a group of object files into an object library. The linker includes in the library the members that resolve external references during the link. The archiver allows you to modify a library by deleting, replacing, extracting, or adding members. + +**Topic** ........................................................................................................................... **Page** + +| 7.1 | Archiver Overview | 153 | +|-----|------------------------------------------------------|-----| +| 7.2 | The Archiver's Role in the Software Development Flow | 154 | +| 7.3 | Invoking the Archiver | 155 | +| 7.4 | Archiver Examples | 156 | +| 7.5 | Library Information Archiver Description | 157 | +| | | | + +## 7.1 Archiver Overview + +You can build libraries from any type of files. Both the assembler and the linker accept archive libraries as input; the assembler can use libraries that contain individual source files, and the linker can use libraries that contain individual object files. + +One of the most useful applications of the archiver is building libraries of object modules. For example, you can write several arithmetic routines, assemble them, and use the archiver to collect the object files into a single, logical group. You can then specify the object library as linker input. The linker searches the library and includes members that resolve external references. + +You can also use the archiver to build macro libraries. You can create several source files, each of which contains a single macro, and use the archiver to collect these macros into a single, functional group. You can use the .mlib directive during assembly to specify that macro library to be searched for the macros that you call. Chapter 6 discusses macros and macro libraries in detail, while this chapter explains how to use the archiver to build libraries. + +## 7.2 The Archiver's Role in the Software Development Flow + +Figure 7-1 shows the archiver's role in the software development process. The shaded portion highlights the most common archiver development path. Both the assembler and the linker accept libraries as input. + +**Figure 7-1: The Archiver in the PRU Software Development Flow.** Block diagram showing the PRU software development flow with the archiver highlighted. Inputs (macro source files, object files) flow into the Archiver, producing a Macro library or Library of object files. The library feeds into the Linker alongside object files from the Assembler. The shaded central path shows the most common development flow: source → Assembler → object files → Linker → executable module. + +## 7.3 Invoking the Archiver + +To invoke the archiver, enter: + +**arpru** [-]*command* [*options*] *libname* [*filename1* ... *filenamen*] + +**arpru** is the command that invokes the archiver. + +[-]*command* tells the archiver how to manipulate the existing library members and any specified. A command can be preceded by an optional hyphen. You must use one of the following commands when you invoke the archiver, but you can use only one command per invocation. The archiver commands are as follows: + +- **@** uses the contents of the specified file instead of command line entries. You can use this command to avoid limitations on command line length imposed by the host operating system. Use a ; at the beginning of a line in the command file to include comments. (See Example 7-1 for an example using an archiver command file.) +- **a** adds the specified files to the library. This command does not replace an existing member that has the same name as an added file; it simply *appends* new members to the end of the archive. +- **d** deletes the specified members from the library. +- **r** replaces the specified members in the library. If you do not specify filenames, the archiver replaces the library members with files of the same name in the current directory. If the specified file is not found in the library, the archiver adds it instead of replacing it. +- **t** prints a table of contents of the library. If you specify filenames, only those files are listed. If you do not specify any filenames, the archiver lists all the members in the specified library. +- **x** extracts the specified files. If you do not specify member names, the archiver extracts all library members. When the archiver extracts a member, it simply copies the member into the current directory; it *does not* remove it from the library. + +*options* In addition to one of the *commands,* you can specify options. To use options, combine them with a command; for example, to use the a command and the s option, enter -as or as. The hyphen is optional for archiver options only. These are the archiver options: + +- **-q** (quiet) suppresses the banner and status messages. +- **-s** prints a list of the global symbols that are defined in the library. (This option is valid only with the a, r, and d commands.) +- **-u** replaces library members only if the replacement has a more recent modification date. You must use the r command with the -u option to specify which members to replace. +- **-v** (verbose) provides a file-by-file description of the creation of a new library from an old library and its members. + +*libname* names the archive library to be built or modified. If you do not specify an extension for *libname,* the archiver uses the default extension *.lib*. + +*filenames* names individual files to be manipulated. These files can be existing library members or new files to be added to the library. When you enter a filename, you must enter a complete filename including extension, if applicable. + +**Naming Library Members** + +**NOTE:** It is possible (but not desirable) for a library to contain several members with the same name. If you attempt to delete, replace, or extract a member whose name is the same as another library member, the archiver deletes, replaces, or extracts the first library member with that name. + +## 7.4 Archiver Examples + +The following are examples of typical archiver operations: + +• If you want to create a library called function.lib that contains the files sine.obj, cos.obj, and flt.obj, enter: + +``` +arpru -a function sine.obj cos.obj flt.obj +``` + +The archiver responds as follows: + +``` +==> new archive 'function.lib' +==> building new archive 'function.lib' +``` + +• You can print a table of contents of function.lib with the -t command, enter: + +``` +arpru -t function +``` + +The archiver responds as follows: + +| FILE NAME | SIZE | DATE | +|-----------|------|--------------------------| +| | | | +| sine.obj | 300 | Wed Jun 15 10:00:24 2011 | +| cos.obj | 300 | Wed Jun 15 10:00:30 2011 | +| flt.obj | 300 | Wed Jun 15 09:59:56 2011 | + +• If you want to add new members to the library, enter: + +``` +arpru -as function atan.obj +``` + +The archiver responds as follows: + +``` +==> symbol defined: '_sin' +==> symbol defined: '$sin' +==> symbol defined: '_cos' +==> symbol defined: '$cos' +==> symbol defined: '_tan' +==> symbol defined: '$tan' +==> symbol defined: '_atan +==> symbol defined: '$atan' +==> building archive 'function.lib' +``` + +Because this example does not specify an extension for the libname, the archiver adds the files to the library called function.lib. If function.lib does not exist, the archiver creates it. (The -s option tells the archiver to list the global symbols that are defined in the library.) + +• If you want to modify a library member, you can extract it, edit it, and replace it. In this example, assume there is a library named macros.lib that contains the members push.asm, pop.asm, and swap.asm. + +``` +arpru -x macros push.asm +``` + +The archiver makes a copy of push.asm and places it in the current directory; it does not remove push.asm from the library. Now you can edit the extracted file. To replace the copy of push.asm in the library with the edited copy, enter: + +``` +arpru -r macros push.asm +``` + +• If you want to use a command file, specify the command filename after the -@ command. For example: + +``` +arpru -@modules.cmd +``` + +The archiver responds as follows: + +``` +==> building archive 'modules.lib' +``` + +Example 7-1 is the modules.cmd command file. The r command specifies that the filenames given in the command file replace files of the same name in the modules.lib library. The -u option specifies that these files are replaced only when the current file has a more recent revision date than the file that is in the library. + +### Example 7-1. Archiver Command File + +``` +; Command file to replace members of the +; modules library with updated files +; Use r command and u option: +ru +; Specify library name: +modules.lib +; List filenames to be replaced if updated: +align.asm +bss.asm +data.asm +text.asm +sect.asm +copy.asm +double.asm +drnolist.asm +emsg.asm +end.asm +``` + +## 7.5 Library Information Archiver Description + +Section 7.1 explains how to use the archiver to create libraries of object files for use in the linker of one or more applications. You can have multiple versions of the same object file libraries, each built with different sets of build options. For example, you might have different versions of your object file library for big and little endian, for different architecture revisions, or for different ABIs depending on the typical build environments of client applications. However, if you have several versions of a library, it can be cumbersome to keep track of which version of the library needs to be linked in for a particular application. + +When several versions of a single library are available, the library information archiver can be used to create an index library of all of the object file library versions. This index library is used in the linker in place of a particular version of your object file library. The linker looks at the build options of the application being linked, and uses the specified index library to determine which version of your object file library to include in the linker. If one or more compatible libraries were found in the index library, the most suitable compatible library is linked in for your application. + +### 7.5.1 Invoking the Library Information Archiver + +To invoke the library information archiver, enter: + +| libinfopru [options] -o=libname libname1
[libname2
libnamen
] | | +|------------------------------------------------------------------------|--| + +| libinfopru
options | is the command that invokes the library information archiver.
changes the default behavior of the library information archiver. These options are: | | | +|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|--| +| | -o libname | specifies the name of the index library to create or update. This option is
required. | | +| | -u | updates any existing information in the index library specified with the -o
option instead of creating a new index. | | +| | | | | + +*libnames* names individual object file libraries to be manipulated. When you enter a libname, you must enter a complete filename including extension, if applicable. + +### 7.5.2 Library Information Archiver Example + +Consider these object file libraries that all have the same members, but are built with different build options: + +| Object File Library Name | Build Options | +|--------------------------|--------------------------------| +| mylib_pruv1_le.lib | silicon_version=1endian=little | +| mylib_pruv1_be.lib | silicon_version=1endian=big | +| mylib_pruv2_le.lib | silicon_version=2endian=little | +| mylib_pruv2_be.lib | silicon_version=2endian=big | +| mylib_pruv3_le.lib | silicon_version=3endian=little | +| mylib_pruv3_be.lib | silicon_version=3endian=big | +| mylib_pruv4_le.lib | silicon_version=4endian=little | +| mylib_pruv4_be.lib | silicon_version=4endian=big | + +Using the library information archiver, you can create an index library called mylib.lib from the above libraries: + +``` +libinfopru -o mylib.lib mylib_pruv3_be.lib mylib_pruv2_be.lib + mylib__pruv1_be.lib +``` + +You can now specify mylib.lib as a library for the linker of an application. The linker uses the index library to choose the appropriate version of the library to use. If the --issue\_remarks option is specified before the --run\_linker option, the linker reports which library was chosen. + +• **Example 1** (little endian): + +### 7.5.3 Listing the Contents of an Index Library + +The archiver's -t option can be used on an index library to list the archives indexed by an index library: + +arpru t mylib.lib + +| SIZE | DATE | FILE NAME | +|------|--------------------------|----------------------------| +| | | | +| 119 | Mon Apr 23 12:45:22 2007 | mylib_pruv3_le.lib.libinfo | +| 119 | Mon Apr 23 12:45:22 2007 | mylib_pruv3_be.lib.libinfo | +| 119 | Mon Apr 23 12:45:22 2007 | mylib_pruv2_le.lib.libinfo | +| 119 | Mon Apr 23 12:45:22 2007 | mylib_pruv2_be.lib.libinfo | +| 119 | Mon Apr 23 12:45:22 2007 | mylib_pruv1_le.lib.libinfo | +| 119 | Mon Apr 23 12:45:22 2007 | mylib_pruv1_be.lib.libinfo | +| 0 | Mon Apr 23 12:45:22 2007 | TI_\$\$LIBINFO | + +The indexed object file libraries have an additional .libinfo extension in the archiver listing. The \_\_TI\_\$\$LIBINFO member is a special member that designates *mylib.lib* as an index library, rather than a regular library. + +If the archiver's -d command is used on an index library to delete a .libinfo member, the linker will no longer choose the corresponding library when the index library is specified. + +Using any other archiver option with an index library, or using -d to remove the \_\_TI\_\$\$LIBINFO member, results in undefined behavior, and is not supported. + +### 7.5.4 Requirements + +You must follow these requirements to use library index files: + +- At least one application object file must appear on the linker command line before the index library. +- Each object file library specified as input to the library information archiver must only contain object file members that are built with the same build options. +- The linker expects the index library and all of the libraries it indexes to be in a single directory. + +# 8 Linker Description + +The PRU linker creates executable modules by combining object modules. This chapter describes the linker options, directives, and statements used to create executable modules. Object libraries, command files, and other key concepts are discussed as well. + +The concept of sections is basic to linker operation; Chapter 2 includes a detailed discussion of sections. + +**Topic** ........................................................................................................................... **Page** + +| 8.1 | Linker Overview | 160 | +|------|----------------------------------------------------|-----| +| 8.2 | The Linker's Role in the Software Development Flow | 161 | +| 8.3 | Invoking the Linker | 162 | +| 8.4 | Linker Options | 163 | +| 8.5 | Linker Command Files | 182 | +| 8.6 | Linker Symbols | 216 | +| 8.7 | Default Placement Algorithm | 219 | +| 8.8 | Linker-Generated Copy Tables | 220 | +| 8.9 | Partial (Incremental) Linking | 231 | +| 8.10 | Linking C/C++ Code | 232 | +| 8.11 | Linker Example | 234 | +| | | | + +## 8.1 Linker Overview + +The PRU linker allows you to allocate output sections efficiently in the memory map. As the linker combines object files, it performs the following tasks: + +- Allocates sections into the target system's configured memory +- Relocates symbols and sections to assign them to final addresses +- Resolves undefined external references between input files + +The linker command language controls memory configuration, output section definition, and address binding. The language supports expression assignment and evaluation. You configure system memory by defining and creating a memory model that you design. Two powerful directives, MEMORY and SECTIONS, allow you to: + +- Allocate sections into specific areas of memory +- Combine object file sections +- Define or redefine global symbols at link time + +## 8.2 The Linker's Role in the Software Development Flow + +Figure 8-1 illustrates the linker's role in the software development process. The linker accepts several types of files as input, including object files, command files, libraries, and partially linked files. The linker creates an executable object module that can be downloaded to one of several development tools or executed by a PRU device. + +![Figure 8-1: The Linker in the PRU Software Development Flow — block diagram showing inputs (C/C++ source files, macro source files, object files, libraries, run-time-support library) flowing through the compiler/assembler/archiver toolchain into the Linker, producing an executable object file that connects to the PRU device, debugging tools, and other utilities](_page_160_Figure_5.jpeg) + +**Figure 8-1: The Linker in the PRU Software Development Flow.** Block diagram of the complete PRU software development flow with the Linker highlighted at center. Inputs include: C/C++ source files (compiled by the C/C++ compiler into assembler source), macro source files (processed by the Archiver into a macro library), and existing object files (also archived into a library of object files). The Assembler converts assembler source into object files. The Linker combines object files and libraries (including a run-time-support library from the Library-build utility) into an Executable object file. The executable connects to the PRU device directly, to debugging tools, to an EPROM programmer, to an Absolute lister, to a Cross-reference lister, and to Object file utilities. A C/C++ name demangling utility is also shown. + +## 8.3 Invoking the Linker + +The general syntax for invoking the linker is: + +**clpru --run\_linker** [*options*] *filename1* .... *filenamen* + +**clpru --run\_linker** is the command that invokes the linker. The --run\_linker option's short form is -z. + +*options* can appear anywhere on the command line or in a linker command file. + +(Options are discussed in Section 8.4.) + +*filename1*, *filenamen* can be object files, linker command files, or archive libraries. The default extension for all input files is *.obj*; any other extension must be explicitly specified. The linker can determine whether the input file is an object or ASCII file that contains linker commands. The default output filename is *a.out*, unless you use the --output\_file option to name the output file. + +There are two methods for invoking the linker: + +• Specify options and filenames on the command line. This example links two files, file1.obj and file2.obj, and creates an output module named link.out. + +``` +clpru --run_linker file1.obj file2.obj --output_file=link.out +``` + +• Put filenames and options in a linker command file. Filenames that are specified inside a linker command file must begin with a letter. For example, assume the file linker.cmd contains the following lines: + +``` +--output_file=link.out file1.obj file2.obj +``` + +Now you can invoke the linker from the command line; specify the command filename as an input file: + +``` +clpru --run_linker linker.cmd +``` + +When you use a command file, you can also specify other options and files on the command line. For example, you could enter: + +``` +clpru --run_linker --map_file=link.map linker.cmd file3.obj +``` + +The linker reads and processes a command file as soon as it encounters the filename on the command line, so it links the files in this order: file1.obj, file2.obj, and file3.obj. This example creates an output file called link.out and a map file called link.map. + +For information on invoking the linker for C/C++ files, see Section 8.10. + +## 8.4 Linker Options + +Linker options control linking operations. They can be placed on the command line or in a command file. Linker options must be preceded by a hyphen (-). Options can be separated from arguments (if they have them) by an optional space. + +### Table 8-1. Basic Options Summary + +| Option | Alias | Description | Section | +|-------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------|----------------| +| run_linker | -z | Enables linking | Section 8.3 | +| output_file | -o | Names the executable output module. The default filename is a.out. | Section 8.4.23 | +| map_file | -m | Produces a map or listing of the input and output sections, including holes, and
places the listing in filename | Section 8.4.18 | +| stack_size | -stack | Sets C system stack size to size and defines a global symbol that specifies the
stack size. Default = 256 bytes | Section 8.4.29 | +| heap_size | -heap | Sets heap size (for the dynamic memory allocation in C) to size and defines a
global symbol that specifies the heap size. Default = 256 bytes | Section 8.4.14 | + +### Table 8-2. File Search Path Options Summary + +| Option | Alias | Description | Section | +|------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------| +| library | -l | Names an archive library or link command filename as linker input | Section 8.4.16 | +| search_path | -i | Alters library-search algorithms to look in a directory named with pathname
before looking in the default location. This option must appear before the
library option. | Section 8.4.16.1 | +| priority | -priority | Satisfies unresolved references by the first library that contains a definition for
that symbol | Section 8.4.16.3 | +| reread_libs | -x | Forces rereading of libraries, which resolves back references | Section 8.4.16.3 | +| disable_auto_rts | | Disables the automatic selection of a run-time-support library | Section 8.4.8 | + +### Table 8-3. Command File Preprocessing Options Summary + +| Option | Alias | Description | Section | +|------------|-------|------------------------------------------|----------------| +| define | | Predefines name as a preprocessor macro. | Section 8.4.10 | +| undefine | | Removes the preprocessor macro name. | Section 8.4.10 | +| disable_pp | | Disables preprocessing for command files | Section 8.4.10 | + +### Table 8-4. Diagnostic Options Summary + +| Option | Alias | Description | Section | +|-------------------------|-------|----------------------------------------------------------------------------------------------------------------|----------------| +| diag_error | | Categorizes the diagnostic identified by num as an error | Section 8.4.7 | +| diag_remark | | Categorizes the diagnostic identified by num as a remark | Section 8.4.7 | +| diag_suppress | | Suppresses the diagnostic identified by num | Section 8.4.7 | +| diag_warning | | Categorizes the diagnostic identified by num as a warning | Section 8.4.7 | +| display_error_number | | Displays a diagnostic's identifiers along with its text | Section 8.4.7 | +| emit_warnings_as_errors | -pdew | Treats warnings as errors | Section 8.4.7 | +| issue_remarks | | Issues remarks (nonserious warnings) | Section 8.4.7 | +| no_demangle | | Disables demangling of symbol names in diagnostics | Section 8.4.20 | +| no_warnings | | Suppresses warning diagnostics (errors are still issued) | Section 8.4.7 | +| set_error_limit | | Sets the error limit to num. The linker abandons linking after this number of
errors. (The default is 100.) | Section 8.4.7 | +| verbose_diagnostics | | Provides verbose diagnostics that display the original source with line-wrap | Section 8.4.7 | + +### Table 8-5. Linker Output Options Summary + +| Option | Alias | Description | Section | +|------------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------| +| absolute_exe | -a | Produces an absolute, executable module. This is the default; if neither
absolute_exe norrelocatable is specified, the linker acts as ifabsolute_exe
were specified. | Section 8.4.3.1 | +| ecc={ on off } | | Enable linker-generated Error Correcting Codes (ECC). The default is off. | Section 8.4.11
Section 8.5.9 | +| ecc:data_error | | Inject the specified errors into the output file for testing | Section 8.4.11
Section 8.5.9 | +| ecc:ecc_error | | Inject the specified errors into the Error Correcting Code (ECC) for testing | Section 8.4.11
Section 8.5.9 | +| mapfile_contents | | Controls the information that appears in the map file. | Section 8.4.19 | +| relocatable | -r | Produces a nonexecutable, relocatable output module | Section 8.4.3.2 | +| rom | -r | Create a ROM object | | +| run_abs | -abs | Produces an absolute listing file | Section 8.4.27 | +| xml_link_info | | Generates a well-formed XML file containing detailed information about the
result of a link | Section 8.4.34 | + +### Table 8-6. Symbol Management Options Summary + +| Option | Alias | Description | Section | +|----------------|-----------|-----------------------------------------------------------------------------------------|------------------| +| entry_point | -e | Defines a global symbol that specifies the primary entry point for the output
module | Section 8.4.12 | +| globalize | | Changes the symbol linkage to global for symbols that match pattern | Section 8.4.17 | +| hide | | Hides global symbols that match pattern | Section 8.4.15 | +| localize | | Changes the symbol linkage to local for symbols that match pattern | Section 8.4.17 | +| make_global | -g | Makes symbol global (overrides -h) | Section 8.4.17.1 | +| make_static | -h | Makes all global symbols static | Section 8.4.17.1 | +| no_symtable | -s | Strips symbol table information and line number entries from the output
module | Section 8.4.22 | +| retain | | Retains a list of sections that otherwise would be discarded | Section 8.4.26 | +| scan_libraries | -scanlibs | Scans all libraries for duplicate symbol definitions | Section 8.4.28 | +| symbol_map | | Maps symbol references to a symbol definition of a different name | Section 8.4.31 | +| undef_sym | -u | Places an unresolved external symbol into the output module's symbol table | Section 8.4.32 | +| unhide | | Reveals (un-hides) global symbols that match pattern | Section 8.4.15 | + +#### Table 8-7. Run-Time Environment Options Summary + +| Option | Alias | Description | Section | +|------------|-------|-----------------------------------------------------------------------------------------------|----------------| +| arg_size | args | Allocates memory to be used by the loader to pass arguments | Section 8.4.4 | +| fill_value | -f | Sets default fill values for holes within output sections; fill_value is a 32-bit
constant | Section 8.4.13 | +| ram_model | -cr | Initializes variables at load time | Section 8.4.25 | +| rom_model | -c | Autoinitializes variables at run time | Section 8.4.25 | + +#### Table 8-8. Link-Time Optimization Options Summary + +| Option | Alias | Description | Section | +|------------------------------------------|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------| +| cinit_compression
[=compression_kind] | | Specifies the type of compression to apply to the C auto initialization data. The
default if this option is used with no kind specified is lzss for Lempel-Ziv
Storer-Szymanski compression. Alternately, specifycinit_compression=rle to
use Run Length Encoded compression, which generally provides less efficient
compression. | Section 8.4.5 | +| compress_dwarf | | Aggressively reduces the size of DWARF information from input object files | Section 8.4.6 | + +#### Table 8-8. Link-Time Optimization Options Summary (continued) + +| Option | Alias | Description | Section | +|-----------------------------------------|-------|------------------------------------------------------------------------------------|---------------| +| copy_compression
[=compression_kind] | | Compresses data copied by linker copy tables | Section 8.4.5 | +| unused_section_elimination | | Eliminates sections that are not needed in the executable module; on by
default | Section 8.4.9 | + +#### Table 8-9. Miscellaneous Options Summary + +| Option | Alias | Description | Section | +|----------------------|-------|-----------------------------------------------------------------------------------------|----------------| +| linker_help | -help | Displays information about syntax and available options | – | +| preferred_order | | Prioritizes placement of functions | Section 8.4.24 | +| strict_compatibility | | Performs more conservative and rigorous compatibility checking of input object
files | Section 8.4.30 | +| zero_init | | Controls preinitialization of uninitialized variables. Default is on. | Section 8.4.35 | + +### 8.4.1 Wildcards in File, Section, and Symbol Patterns + +The linker allows file, section, and symbol names to be specified using the asterisk (\*) and question mark (?) wildcards. Using \* matches any number of characters and using ? matches a single character. Using wildcards can make it easier to handle related objects, provided they follow a suitable naming convention. + +#### For example: + +``` +mp3*.obj /* matches anything .obj that begins with mp3 */ +task?.o* /* matches task1.obj, task2.obj, taskX.o55, etc. */ +SECTIONS +{ + .fast_code: { *.obj(*fast*) } > FAST_MEM + .str_code : { rts*.lib(.text) } > S1ROM +} +``` + +### 8.4.2 Specifying C/C++ Symbols with Linker Options + +The link-time symbol is the same as the C/C++ identifier name. The compiler *does not* prepend an underscore to the beginning of C/C++ identifiers. + +See Section 8.6.1 for information about referring to linker symbols in C/C++ code. + +### 8.4.3 Relocation Capabilities (--absolute\_exe and --relocatable Options) + +The linker performs relocation, which is the process of adjusting all references to a symbol when the symbol's address changes \(Section 2.7). + +The linker supports two options (--absolute\_exe and --relocatable) that allow you to produce an absolute or a relocatable output module. The linker also supports a third option (-ar) that allows you to produce an executable, relocatable output module. + +When the linker encounters a file that contains no relocation or symbol table information, it issues a warning message (but continues executing). Relinking an absolute file can be successful only if each input file contains no information that needs to be relocated (that is, each file has no unresolved references and is bound to the same virtual address that it was bound to when the linker created it). + +#### 8.4.3.1 Producing an Absolute Output Module (--absolute\_exe option) + +When you use the --absolute\_exe option without the --relocatable option, the linker produces an *absolute, executable output module*. Absolute files contain *no* relocation information. Executable files contain the following: + +• Special symbols defined by the linker (see Section 8.5.10.4) + +- An header that describes information such as the program entry point +- *No* unresolved references + +The following example links file1.obj and file2.obj and creates an absolute output module called a.out: + +clpru --run\_linker **--absolute\_exe** file1.obj file2.obj + +### The --absolute\_exe and --relocatable Options + +**NOTE:** If you do not use the --absolute\_exe or the --relocatable option, the linker acts as if you specified --absolute\_exe. + +#### 8.4.3.2 Producing a Relocatable Output Module (--relocatable option) + +When you use the --relocatable option, the linker retains relocation entries in the output module. If the output module is relocated (at load time) or relinked (by another linker execution), use --relocatable to retain the relocation entries. + +The linker produces a file that is not executable when you use the --relocatable option without the --absolute\_exe option. A file that is not executable does not contain special linker symbols or an optional header. The file can contain unresolved references, but these references do not prevent creation of an output module. + +This example links file1.obj and file2.obj and creates a relocatable output module called a.out: + +``` +clpru --run_linker --relocatable file1.obj file2.obj +``` + +The output file a.out can be relinked with other object files or relocated at load time. (Linking a file that will be relinked with other files is called partial linking. For more information, see Section 8.9.) + +#### 8.4.3.3 Producing an Executable, Relocatable Output Module (-ar Option) + +If you invoke the linker with both the --absolute\_exe and --relocatable options, the linker produces an *executable, relocatable* object module. The output file contains the special linker symbols, an optional header, and all resolved symbol references; however, the relocation information is retained. + +This example links file1.obj and file2.obj to create an executable, relocatable output module called xr.out: + +``` +clpru --run_linker -ar file1.obj file2.obj --output_file=xr.out +``` + +### 8.4.4 Allocate Memory for Use by the Loader to Pass Arguments (--arg\_size Option) + +The --arg\_size option instructs the linker to allocate memory to be used by the loader to pass arguments from the command line of the loader to the program. The syntax of the --arg\_size option is: + +``` +--arg_size= size +``` + +The *size* is the number of bytes to be allocated in target memory for command-line arguments. + +By default, the linker creates the \_\_c\_args\_\_ symbol and sets it to -1. When you specify --arg\_size=*size*, the following occur: + +- The linker creates an uninitialized section named .args of *size* bytes. +- The \_\_c\_args\_\_ symbol contains the address of the .args section. + +The loader and the target boot code use the .args section and the \_\_c\_args\_\_ symbol to determine whether and how to pass arguments from the host to the target program. See the *PRU Optimizing C/C++ Compiler User's Guide* for information about the loader. + +### 8.4.5 Compression (--cinit\_compression and --copy\_compression Option) + +By default, the linker does not compress data. These two options specify compression through the linker. + +The --cinit\_compression option specifies the compression type the linker applies to the C autoinitialization data. The default is lzss. + +Overlays can be managed by using linker-generated copy tables. To save ROM space the linker can compress the data copied by the copy tables. The compressed data is decompressed during copy. The --copy\_compression option controls the compression of the copy data tables. + +The syntax for the options are: + +- **--cinit\_compression**[=*compression\_kind*] +- **--copy\_compression**[=*compression\_kind*] + +The *compression\_kind* can be one of the following types: + +- **off**. Don't compress the data. +- **rle**. Compress data using Run Length Encoding. +- **lzss**. Compress data using Lempel-Ziv Storer and Symanski compression (the default if no*compression\_kind* is specified). + +See Section 8.8.5 for more information about compression. + +### 8.4.6 Compress DWARF Information (--compress\_dwarf Option) + +The --compress\_dwarf option aggressively reduces the size of DWARF information by eliminating duplicate information from input object files. The --compress\_dwarf option eliminates duplicate information that could not be removed through the use of ELF COMDAT groups. (See the ELF specification for information on COMDAT groups.) + +### 8.4.7 Control Linker Diagnostics + +The linker uses certain C/C++ compiler options to control linker-generated diagnostics. The diagnostic options must be specified before the --run\_linker option. + +| diag_error=num | Categorize the diagnostic identified by num as an error. To find the numeric
identifier of a diagnostic message, use thedisplay_error_number option first
in a separate link. Then usediag_error=num to recategorize the diagnostic
as an error. You can only alter the severity of discretionary diagnostics. | +|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| diag_remark=num | Categorize the diagnostic identified by num as a remark. To find the numeric
identifier of a diagnostic message, use thedisplay_error_number option first
in a separate link. Then usediag_remark=num to recategorize the
diagnostic as a remark. You can only alter the severity of discretionary
diagnostics. | +| diag_suppress=num | Suppress the diagnostic identified by num. To find the numeric identifier of a
diagnostic message, use thedisplay_error_number option first in a
separate link. Then usediag_suppress=num to suppress the diagnostic.
You can only suppress discretionary diagnostics. | +| diag_warning=num | Categorize the diagnostic identified by num as a warning. To find the numeric
identifier of a diagnostic message, use thedisplay_error_number option first
in a separate link. Then usediag_warning=num to recategorize the
diagnostic as a warning. You can only alter the severity of discretionary
diagnostics. | +| display_error_number | Display a diagnostic's numeric identifier along with its text. Use this option in
determining which arguments you need to supply to the diagnostic
suppression options (diag_suppress,diag_error,diag_remark, and
diag_warning). This option also indicates whether a diagnostic is | + +**errors** + +Treat all warnings as errors. This option cannot be used with the --no\_warnings option. The --diag\_remark option takes precedence over this option. This option takes precedence over the --diag\_warning option. **--issue\_remarks** Issue remarks (nonserious warnings), which are suppressed by default. + +discretionary. A discretionary diagnostic is one whose severity can be overridden. A discretionary diagnostic includes the suffix -D; otherwise, no suffix is present. See the *PRU Optimizing C/C++ Compiler User's Guide* for + +more information on understanding diagnostic messages. + +**--emit\_warnings\_as\_** + +**--no\_warnings** Suppress warning diagnostics (errors are still issued). + +**--set\_error\_limit**=*num* Set the error limit to *num*, which can be any decimal value. The linker + +abandons linking after this number of errors. (The default is 100.) + +**--verbose\_diagnostics** Provide verbose diagnostics that display the original source with line-wrap + +and indicate the position of the error in the source line + +### 8.4.8 Automatic Library Selection (--disable\_auto\_rts Option) + +The --disable\_auto\_rts option disables the automatic selection of a run-time-support (RTS) library. See the *PRU Optimizing C/C++ Compiler User's Guide* for details on the automatic selection process. + +### 8.4.9 Do Not Remove Unused Sections (--unused\_section\_elimination Option) + +In order to minimize the foot print, the ELF linker does not include a section that is not needed to resolve any references in the final executable. Use --unused\_section\_elimination=off to disable this optimization. The syntax for the option is: + +**--unused\_section\_elimination**[=*on*|*off*] + +The linker default behavior is equivalent to --unused\_section\_elimination=on. + +### 8.4.10 Linker Command File Preprocessing (--disable\_pp, --define and --undefine Options) + +The linker preprocesses linker command files using a standard C preprocessor. Therefore, the command files can contain well-known preprocessing directives such as #define, #include, and #if / #endif. + +Three linker options control the preprocessor: + +**--disable\_pp** Disables preprocessing for command files **--define**=*name*[=*val*] Predefines *name* as a preprocessor macro + +**--undefine**=*name* Removes the macro *name* + +The compiler has --define and --undefine options with the same meanings. However, the linker options are distinct; only --define and --undefine options specified after --run\_linker are passed to the linker. For example: + +``` +clpru --define=FOO=1 main.c --run_linker --define=BAR=2 lnk.cmd +``` + +The linker sees only the --define for BAR; the compiler only sees the --define for FOO. + +When one command file #includes another, preprocessing context is carried from parent to child in the usual way (that is, macros defined in the parent are visible in the child). However, when a command file is invoked other than through #include, either on the command line or by the typical way of being named in another command file, preprocessing context is **not** carried into the nested file. The exception to this is - define and --undefine options, which apply globally from the point they are encountered. For example: + +``` +--define GLOBAL +#define LOCAL +#include "incfile.cmd" /* sees GLOBAL and LOCAL */ +nestfile.cmd /* only sees GLOBAL */ +``` + +Two cautions apply to the use of --define and --undefine in command files. First, they have global effect as mentioned above. Second, since they are not actually preprocessing directives themselves, they are subject to macro substitution, probably with unintended consequences. This effect can be defeated by quoting the symbol name. For example: + +``` +--define MYSYM=123 +--undefine MYSYM /* expands to --undefine 123 (!) */ +--undefine "MYSYM" /* ahh, that's better */ +``` + +The linker uses the same search paths to find #include files as it does to find libraries. That is, #include files are searched in the following places: + +1. If the #include file name is in quotes (rather than ), in the directory of the current file + +2. In the list of directories specified with --Iibrary options or environment variables (see Section 8.4.16) + +There are two exceptions: relative pathnames (such as "../name") always search the current directory; and absolute pathnames (such as "/usr/tools/name") bypass search paths entirely. + +The linker provides the built-in macro definitions listed in Table 8-10. The availability of these macros within the linker is determined by the command-line options used, not the build attributes of the files being linked. If these macros are not set as expected, confirm that your project's command line uses the correct compiler option settings. + +**Table 8-10. Predefined PRU Macro Names** + +| Macro Name | Description | | +|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--| +| DATE | Expands to the compilation date in the form mmm dd yyyy | | +| FILE | Expands to the current source filename | | +| PRU | Always defined | | +| PRU_V0 | Defined to 1 ifsilicon_version=0; otherwise it is undefined. | | +| PRU_V1 | Defined to 1 ifsilicon_version=1; otherwise it is undefined. | | +| PRU_V2 | Defined to 1 ifsilicon_version=2; otherwise it is undefined. | | +| PRU_V3 | Defined to 1 ifsilicon_version=3; otherwise it is undefined. | | +| PRU_V4 | Defined to 1 ifsilicon_version=4; otherwise it is undefined. | | +| TI_COMPILER_VERSION | Defined to a 7-9 digit integer, depending on if X has 1, 2, or 3 digits. The number does
not contain a decimal. For example, version 3.2.1 is represented as 3002001. The
leading zeros are dropped to prevent the number being interpreted as an octal. | | +| TI_EABI | Defined to 1 if EABI is enabled; otherwise, it is undefined. | | +| TIME | Expands to the compilation time in the form "hh:mm:ss" | | + +### 8.4.11 Error Correcting Code Testing (--ecc Options) + +Error Correcting Codes (ECC) can be generated and placed in separate sections through the linker command file. + +To enable ECC support, include **--ecc=on** as a linker option on the command line. By default ECC generation is off, even if the ECC directive and ECC specifiers are used in the linker command file. This allows you to fully configure ECC in the linker command file while still being able to quickly turn the code generation on and off via the command line. See Section 8.5.9 for details on linker command file syntax to configure ECC support. + +ECC uses extra bits to allow errors to be detected and/or corrected by a device. The ECC support provided by the linker is compatible with the ECC support in TI Flash memory on various TI devices. TI Flash memory uses a modified Hamming(72,64) code, which uses 8 parity bits for every 64 bits. Check the documentation for your Flash memory to see if ECC is supported. (ECC for read-write memory is handled completely in hardware at run time.) + +After enabling ECC with the --ecc=on option, you can use the following command-line options to test ECC by injecting bit errors into the linked executable. These options let you specify an address where an error should appear and a bitmask of bits in the code/data at that address to flip. You can specify the address of the error absolutely or as an offset from a symbol. When a data error is injected, the ECC parity bits for the data are calculated as if the error were not present. This simulates bit errors that might actually occur and tests ECC's ability to correct different levels of errors. + +The **--ecc:data\_error option** injects errors into the load image at the specified location. The syntax is: --ecc:data\_error=(symbol+offset|address)[,page],bitmask + +The *address* is the location of the minimum addressable unit where the error is to be injected. A *symbol+offset* can be used to specify the location of the error to be injected with a signed offset from that symbol. The *page* number is needed to make the location non-ambiguous if the address occurs on multiple memory pages. The *bitmask* is a mask of the bits to flip; its width should be the width of an addressable unit. + +For example, the following command line flips the least-significant bit in the byte at the address 0x100, making it inconsistent with the ECC parity bits for that byte: + +``` +clpru test.c --ecc:data_error=0x100,0x01 -z -o test.out +``` + +The following command flips two bits in the third byte of the code for main(): + +``` +clpru test.c --ecc:data_error=main+2,0x42 -z -o test.out +``` + +The **--ecc:ecc\_error option** injects errors into the ECC parity bits that correspond to the specified location. Note that the ecc\_error option can therefore only specify locations inside ECC input ranges, whereas the data\_error option can also specify errors in the ECC output memory ranges. The syntax is: + +``` +--ecc:ecc_error=(symbol+offset|address)[,page],bitmask +``` + +The parameters for this option are the same as for --ecc:data\_error, except that the *bitmask* must be exactly 8 bits. Mirrored copies of the affected ECC byte will also contain the same injected error. + +An error injected into an ECC byte with --ecc:ecc\_error may cause errors to be detected at run time in any of the 8 data bytes covered by that ECC byte. + +For example, the following command flips every bit in the ECC byte that contains the parity information for the byte at 0x200: + +The linker disallows injecting errors into memory ranges that are neither an ECC range nor the input range for an ECC range. The compiler can only inject errors into initialized sections. + +### 8.4.12 Define an Entry Point (--entry\_point Option) + +The memory address at which a program begins executing is called the *entry point*. When a loader loads a program into target memory, the program counter (PC) must be initialized to the entry point; the PC then points to the beginning of the program. + +The linker can assign one of four values to the entry point. These values are listed below in the order in which the linker tries to use them. If you use one of the first three values, it must be an external symbol in the symbol table. + +• The value specified by the --entry\_point option. The syntax is: + +``` +--entry_point= global_symbol +``` + +where *global\_symbol* defines the entry point and must be defined as an external symbol of the input files. The external symbol name of C or C++ objects may be different than the name as declared in the source language; refer to the *PRU Optimizing C/C++ Compiler User's Guide*. + +- The value of symbol \_c\_int00 (if present). The \_c\_int00 symbol *must* be the entry point if you are linking code produced by the C compiler. +- The value of symbol main (if present) +- 0 (default value) + +This example links file1.obj and file2.obj. The symbol begin is the entry point; begin must be defined as external in file1 or file2. + +``` +clpru --run_linker --entry_point=begin file1.obj file2.obj +``` + +See Section 8.6.1 for information about referring to linker symbols in C/C++ code. + +### 8.4.13 Set Default Fill Value (--fill\_value Option) + +The --fill\_value option fills the holes formed within output sections. The syntax for the option is: + +``` +--fill_value= value +``` + +The argument *value* is a 32-bit constant (up to eight hexadecimal digits). If you do not use --fill\_value, the linker uses 0 as the default fill value. + +This example fills holes with the hexadecimal value ABCDABCD: + +``` +clpru --run_linker --fill_value=0xABCDABCD file1.obj file2.obj +``` + +### 8.4.14 Define Heap Size (--heap\_size Option) + +The C/C++ compiler uses an uninitialized section called .sysmem for the C run-time memory pool used by malloc(). You can set the size of this memory pool at link time by using the --heap\_size option. The syntax for the --heap\_size option is: + +#### **--heap\_size=** *size* + +The *size* must be a constant. This example defines a 4K byte heap: + +``` +clpru --run_linker --heap_size=0x1000 /* defines a 4k heap (.sysmem section)*/ +``` + +The linker creates the .sysmem section only if there is a .sysmem section in an input file. + +The linker also creates a global symbol \_\_TI\_SYSMEM\_SIZE and assigns it a value equal to the size of the heap. The default size is 256 bytes. See Section 8.6.1 for information about referring to linker symbols in C/C++ code. + +### 8.4.15 Hiding Symbols + +Symbol hiding prevents the symbol from being listed in the output file's symbol table. While localization is used to prevent name space clashes in a link unit, symbol hiding is used to obscure symbols which should not be visible outside a link unit. Such symbol's names appear only as empty strings or "no name" in object file readers. The linker supports symbol hiding through the --hide and --unhide options. + +The syntax for these options are: + +- **--hide='** *pattern* **'** +- **--unhide='** *pattern* **'** + +The *pattern* is a string with optional wildcards ? or \*. Use ? to match a single character and use \* to match zero or more characters. + +The --hide option hides global symbols with a linkname matching the *pattern*. It hides symbols matching the pattern by changing the name to an empty string. A global symbol that is hidden is also localized. + +The --unhide option reveals (un-hides) global symbols that match the *pattern* that are hidden by the --hide option. The --unhide option excludes symbols that match pattern from symbol hiding provided the pattern defined by --unhide is more restrictive than the pattern defined by --hide. + +These options have the following properties: + +- The --hide and --unhide options can be specified more than once on the command line. +- The order of --hide and --unhide has no significance. +- A symbol is matched by only one pattern defined by either --hide or --unhide. +- A symbol is matched by the most restrictive pattern. Pattern A is considered more restrictive than Pattern B, if Pattern A matches a narrower set than Pattern B. +- It is an error if a symbol matches patterns from --hide and --unhide and one does not supersede the other. Pattern A supersedes pattern B if A can match everything B can and more. If Pattern A supersedes Pattern B, then Pattern B is said to more restrictive than Pattern A. +- These options affect final and partial linking. + +In map files these symbols are listed under the Hidden Symbols heading. + +### 8.4.16 Alter the Library Search Algorithm (--library Option, --search\_path Option, and PRU\_C\_DIR Environment Variable) + +Usually, when you want to specify a file as linker input, you simply enter the filename; the linker looks for the file in the current directory. For example, suppose the current directory contains the library object.lib. If this library defines symbols that are referenced in the file file1.obj, this is how you link the files: + +``` +clpru --run_linker file1.obj object.lib +``` + +If you want to use a file that is not in the current directory, use the --library linker option. The --library option's short form is -l. The syntax for this option is: + +#### **--library=**[*pathname*] *filename* + +The *filename* is the name of an archive, an object file, or linker command file. You can specify up to 128 search paths. + +The --library option is not required when one or more members of an object library are specified for input to an output section. For more information about allocating archive members, see Section 8.5.5.5. + +You can augment the linker's directory search algorithm by using the --search\_path linker option or the environment variable. The linker searches for object libraries and command files in the following order: + +- 1. It searches directories named with the --search\_path linker option. The --search\_path option must appear before the --Iibrary option on the command line or in a command file. +- 2. It searches directories named with PRU\_C\_DIR. +- 3. If PRU\_C\_DIR is not set, it searches directories named with the assembler's PRU\_A\_DIR environment variable. +- 4. It searches the current directory. + +#### 8.4.16.1 Name an Alternate Library Directory (--search\_path Option) + +The --search\_path option names an alternate directory that contains input files. The --search\_path option's short form is -I. The syntax for this option is: + +#### **--search\_path=** *pathname* + +The *pathname* names a directory that contains input files. + +When the linker is searching for input files named with the --library option, it searches through directories named with --search\_path first. Each --search\_path option specifies only one directory, but you can have several --search\_path options per invocation. When you use the --search\_path option to name an alternate directory, it must precede any --library option used on the command line or in a command file. + +For example, assume that there are two archive libraries called r.lib and lib2.lib that reside in ld and ld2 directories. The table below shows the directories that r.lib and lib2.lib reside in, how to set environment variable, and how to use both libraries during a link. Select the row for your operating system: + +| Operating System | Enter | +|---------------------|-----------------------------------------------------------------------------------------------| +| UNIX (Bourne shell) | clprurun_linker f1.obj f2.objsearch_path=/ldsearch_path=/ld2
library=r.liblibrary=lib2.lib | +| Windows | clprurun_linker f1.obj f2.objsearch_path=\ldsearch_path=\ld2
library=r.liblibrary=lib2.lib | + +#### 8.4.16.2 Name an Alternate Library Directory (PRU\_C\_DIR Environment Variable) + +An environment variable is a system symbol that you define and assign a string to. The linker uses an environment variable named PRU\_C\_DIR to name alternate directories that contain object libraries. The command syntaxes for assigning the environment variable are: + +| Operating System | Enter | +|---------------------|---------------------------------------------------------------| +| UNIX (Bourne shell) | PRU_C_DIR=" pathname1
; pathname2
; "; export PRU_C_DIR | +| Windows | set PRU_C_DIR= pathname1
; pathname2
; | + +The *pathnames* are directories that contain input files. Use the --library linker option on the command line or in a command file to tell the linker which library or linker command file to search for. The pathnames must follow these constraints: + +- Pathnames must be separated with a semicolon. +- Spaces or tabs at the beginning or end of a path are ignored. For example the space before and after the semicolon in the following is ignored: + +``` +set PRU_C_DIR= c:\path\one\to\tools ; c:\path\two\to\tools +``` + +• Spaces and tabs are allowed within paths to accommodate Windows directories that contain spaces. For example, the pathnames in the following are valid: + +``` +set PRU_C_DIR=c:\first path\to\tools;d:\second path\to\tools +``` + +In the example below, assume that two archive libraries called r.lib and lib2.lib reside in ld and ld2 directories. The table below shows how to set the environment variable, and how to use both libraries during a link. Select the row for your operating system: + +| Operating System | Invocation Command | +|-------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------| +| PRU_C_DIR="/ld ;/ld2"; export PRU_C_DIR;
clprurun_linker f1.obj f2.objlibrary=r.liblibrary=lib2.lib
UNIX (Bourne shell) | | +| Windows | PRU_C_DIR=\ld;\ld2
clprurun linker f1.obj f2.objlibrary=r.liblibrary=lib2.lib | + +The environment variable remains set until you reboot the system or reset the variable by entering: + +| Operating System | Enter | +|---------------------|-----------------| +| UNIX (Bourne shell) | unset PRU_C_DIR | +| Windows | set PRU_C_DIR= | + +The assembler uses an environment variable named PRU\_A\_DIR to name alternate directories that contain copy/include files or macro libraries. If PRU\_C\_DIR is not set, the linker searches for object libraries in the directories named with PRU\_C\_DIR. For information about PRU\_C\_DIR, see Section 4.4.2. For more information about object libraries, see Section 8.6.3. + +#### 8.4.16.3 Exhaustively Read and Search Libraries (--reread\_libs and --priority Options) + +There are two ways to exhaustively search for unresolved symbols: + +- Reread libraries if you cannot resolve a symbol reference (--reread\_libs). +- Search libraries in the order that they are specified (--priority). + +The linker normally reads input files, including archive libraries, only once when they are encountered on the command line or in the command file. When an archive is read, any members that resolve references to undefined symbols are included in the link. If an input file later references a symbol defined in a previously read archive library, the reference is not resolved. + +With the --reread\_libs option, you can force the linker to reread all libraries. The linker rereads libraries until no more references can be resolved. Linking using --reread\_libs may be slower, so you should use it only as needed. For example, if a.lib contains a reference to a symbol defined in b.lib, and b.lib contains a reference to a symbol defined in a.lib, you can resolve the mutual dependencies by listing one of the libraries twice, as in: + +``` +clpru --run_linker --library=a.lib --library=b.lib --library=a.lib +or you can force the linker to do it for you: +clpru --run_linker --reread_libs --library=a.lib --library=b.lib +``` + +The --priority option provides an alternate search mechanism for libraries. Using --priority causes each unresolved reference to be satisfied by the first library that contains a definition for that symbol. For example: + +``` +objfile references A +lib1 defines B +lib2 defines A, B; obj defining A references B +% clpru --run_linker objfile lib1 lib2 +``` + +Under the existing model, objfile resolves its reference to A in lib2, pulling in a reference to B, which resolves to the B in lib2. + +Under --priority, objfile resolves its reference to A in lib2, pulling in a reference to B, but now B is resolved by searching the libraries in order and resolves B to the first definition it finds, namely the one in lib1. + +The --priority option is useful for libraries that provide overriding definitions for related sets of functions in other libraries without having to provide a complete version of the whole library. + +For example, suppose you want to override versions of malloc and free defined in the rtspruv3\_le.lib without providing a full replacement for . Using --priority and linking your new library before rtspruv3\_le.lib guarantees that all references to malloc and free resolve to the new library. + +The --priority option is intended to support linking programs with SYS/BIOS where situations like the one illustrated above occur. + +### 8.4.17 Change Symbol Localization + +Symbol localization changes symbol linkage from global to local (static). This is used to obscure global symbols in a library which should not be visible outside the library, but must be global because they are accessed by several modules in the library. The linker supports symbol localization through the --localize and --globalize linker options. + +The syntax for these options are: + +- **--localize='** *pattern* **'** +- **--globalize='** *pattern* **'** + +The *pattern* is a string with optional wildcards ? or \*. Use ? to match a single character and use \* to match zero or more characters. + +The --localize option changes the symbol linkage to local for symbols matching the *pattern*. + +The --globalize option changes the symbol linkage to global for symbols matching the *pattern*. The - globalize option only affects symbols that are localized by the --localize option. The --globalize option excludes symbols that match the pattern from symbol localization, provided the pattern defined by - globalize is more restrictive than the pattern defined by --localize. + +See Section 8.4.2 for information about using C/C++ identifiers in linker options such as --localize and - globalize. + +These options have the following properties: + +- The --localize and --globalize options can be specified more than once on the command line. +- The order of --localize and --globalize options has no significance. +- A symbol is matched by only one pattern defined by either --localize or --globalize. +- A symbol is matched by the most restrictive pattern. Pattern A is considered more restrictive than Pattern B, if Pattern A matches a narrower set than Pattern B. +- It is an error if a symbol matches patterns from --localize and --globalize and if one does not supersede other. Pattern A supersedes pattern B if A can match everything B can, and some more. If Pattern A supersedes Pattern B, then Pattern B is said to more restrictive than Pattern A. +- These options affect final and partial linking. + +In map files these symbols are listed under the Localized Symbols heading. + +#### 8.4.17.1 Make All Global Symbols Static (--make\_static Option) + +The --make\_static option makes all global symbols static. Static symbols are not visible to externally linked modules. By making global symbols static, global symbols are essentially hidden. This allows external symbols with the same name (in different files) to be treated as unique. + +The --make\_static option effectively nullifies all .global assembler directives. All symbols become local to the module in which they are defined, so no external references are possible. For example, assume file1.obj and file2.obj both define global symbols called EXT. By using the --make\_static option, you can link these files without conflict. The symbol EXT defined in file1.obj is treated separately from the symbol EXT defined in file2.obj. + +``` +clpru --run_linker --make_static file1.obj file2.obj +``` + +The --make\_static option makes all global symbols static. If you have a symbol that you want to remain global and you use the --make\_static option, you can use the --make\_global option to declare that symbol to be global. The --make\_global option overrides the effect of the --make\_static option for the symbol that you specify. The syntax for the --make\_global option is: + +**--make\_global=** *global\_symbol* + +### 8.4.18 Create a Map File (--map\_file Option) + +The syntax for the --map\_file option is: + +**--map\_file=** *filename* + +The linker map describes: + +- Memory configuration +- Input and output section allocation +- Linker-generated copy tables +- The addresses of external symbols after they have been relocated +- Hidden and localized symbols + +The map file contains the name of the output module and the entry point; it can also contain up to three tables: + +- A table showing the new memory configuration if any nondefault memory is specified (memory configuration). The table has the following columns; this information is generated on the basis of the information in the MEMORY directive in the linker command file: + - **Name.** This is the name of the memory range specified with the MEMORY directive. + - **Origin.** This specifies the starting address of a memory range. + - **Length.** This specifies the length of a memory range. + - **Unused.** This specifies the total amount of unused (available) memory in that memory area. + - **Attributes.** This specifies one to four attributes associated with the named range: + - R specifies that the memory can be read. + - W specifies that the memory can be written to. + - X specifies that the memory can contain executable code. + - I specifies that the memory can be initialized. + +For more information about the MEMORY directive, see Section 8.5.4. + +- A table showing the linked addresses of each output section and the input sections that make up the output sections (section placement map). This table has the following columns; this information is generated on the basis of the information in the SECTIONS directive in the linker command file: + - **Output section.** This is the name of the output section specified with the SECTIONS directive. + - **Origin.** The first origin listed for each output section is the starting address of that output section. The indented origin value is the starting address of that portion of the output section. + - **Length.** The first length listed for each output section is the length of that output section. The indented length value is the length of that portion of the output section. + - **Attributes/input sections.** This lists the input file or value associated with an output section. If the input section could not be allocated, the map file will indicate this with "FAILED TO ALLOCATE". + +For more information about the SECTIONS directive, see Section 8.5.5. + +- A table showing each external symbol and its address sorted by symbol name. +- A table showing each external symbol and its address sorted by symbol address. + +The following example links file1.obj and file2.obj and creates a map file called map.out: + +``` +clpru --run_linker file1.obj file2.obj --map_file=map.out +``` + +Example 8-23 shows an example of a map file. + +### 8.4.19 Managing Map File Contents (--mapfile\_contents Option) + +The --mapfile\_contents option assists with managing the content of linker-generated map files. The syntax for the --mapfile\_contents option is: + +#### **--mapfile\_contents=** *filter*[, *filter*] + +When the --map\_file option is specified, the linker produces a map file containing information about memory usage, placement information about sections that were created during a link, details about linkergenerated copy tables, and symbol values. + +The --mapfile\_contents option provides a mechanism for you to control what information is included in or excluded from a map file. When you specify --mapfile\_contents=help from the command line, a help screen listing available filter options is displayed. The following filter options are available: + +| Attribute | Description | Default State | +|-------------|-------------------------------|---------------| +| copytables | Copy tables | On | +| entry | Entry point | On | +| load_addr | Display load addresses | Off | +| memory | Memory ranges | On | +| modules | Module view | On | +| sections | Sections | On | +| sym_defs | Defined symbols per file | Off | +| sym_dp | Symbols sorted by data page | On | +| sym_name | Symbols sorted by name | On | +| sym_runaddr | Symbols sorted by run address | On | +| all | Enables all attributes | | +| none | Disables all attributes | | + +The --mapfile\_contents option controls display filter settings by specifying a comma-delimited list of display attributes. When prefixed with the word no, an attribute is disabled instead of enabled. For example: + +By default, those sections that are currently included in the map file when the --map\_file option is specified are included. The filters specified in the --mapfile\_contents options are processed in the order that they appear in the command line. In the third example above, the first filter, none, clears all map file content. The second filter, entry, then enables information about entry points to be included in the generated map file. That is, when --mapfile\_contents=none,entry is specified, the map file contains *only* information about entry points. + +The load\_addr and sym\_defs attributes are both disabled by default. + +If you turn on the load\_addr filter, the map file includes the load address of symbols that are included in the symbol list in addition to the run address (if the load address is different from the run address). + +You can use the sym\_defs filter to include information sorted on a file by file basis. You may find it useful to replace the sym\_name, sym\_dp, and sym\_runaddr sections of the map file with the sym\_defs section by specifying the following --mapfile\_contents option: + +``` +--mapfile_contents=nosym_name,nosym_dp,nosym_runaddr,sym_defs +``` + +By default, information about global symbols defined in an application are included in tables sorted by name, data page, and run address. If you use the --mapfile\_contents=sym\_defs option, static variables are also listed. + +--mapfile\_contents=copytables,noentry + +--mapfile\_contents=all,nocopytables + +--mapfile\_contents=none,entry + +### 8.4.20 Disable Name Demangling (--no\_demangle) + +By default, the linker uses demangled symbol names in diagnostics. For example: + +undefined symbol first referenced in file + +ANewClass::getValue() test.obj + +The --no\_demangle option disables the demangling of symbol names in diagnostics. For example: + +undefined symbol first referenced in file + +\_ZN9ANewClass8getValueEv test.obj + +### 8.4.21 Merging of Symbolic Debugging Information + +By default, the linker eliminates duplicate entries of symbolic debugging information. Such duplicate information is commonly generated when a C program is compiled for debugging. For example: + +``` +-[ header.h ]- +typedef struct +{ + +} XYZ; +-[ f1.c ]- +#include "header.h" +... +-[ f2.c ]- +#include "header.h" +... +``` + +When these files are compiled for debugging, both f1.obj and f2.obj have symbolic debugging entries to describe type XYZ. For the final output file, only one set of these entries is necessary. The linker eliminates the duplicate entries automatically. + +### 8.4.22 Strip Symbolic Information (--no\_symtable Option) + +The --no\_symtable option creates a smaller output module by omitting symbol table information and line number entries. The --no\_sym\_table option is useful for production applications when you do not want to disclose symbolic information to the consumer. + +This example links file1.obj and file2.obj and creates an output module, stripped of line numbers and symbol table information, named nosym.out: + +``` +clpru --run_linker --output_file=nosym.out --no_symtable file1.obj file2.obj +``` + +Using the --no\_symtable option limits later use of a symbolic debugger. + +#### Stripping Symbolic Information + +**NOTE:** The --no\_symtable option is deprecated. To remove symbol table information, use the strippru utility as described in Section 11.4. + +### 8.4.23 Name an Output Module (--output\_file Option) + +The linker creates an output module when no errors are encountered. If you do not specify a filename for the output module, the linker gives it the default name a.out. If you want to write the output module to a different file, use the --output\_file option. The syntax for the --output\_file option is: + +#### **--output\_file=** *filename* + +The *filename* is the new output module name. + +This example links file1.obj and file2.obj and creates an output module named run.out: + +``` +clpru --run_linker --output_file=run.out file1.obj file2.obj +``` + +### 8.4.24 Prioritizing Function Placement (--preferred\_order Option) + +The compiler prioritizes the placement of a function relative to others based on the order in which --preferred\_order options are encountered during the linker invocation. The syntax is: + +``` +--preferred_order=function specification +``` + +Refer to the *PRU Optimizing C/C++ Compiler User's Guide* for details on the program cache layout tool, which is impacted by --preferred\_option. + +### 8.4.25 C Language Options (--ram\_model and --rom\_model Options) + +The --ram\_model and --rom\_model options cause the linker to use linking conventions that are required by the C compiler. + +- The --ram\_model option tells the linker to initialize variables at load time. +- The --rom\_model option tells the linker to autoinitialize variables at run time. + +For more information, see Section 8.10 and Section 3.3.2. + +### 8.4.26 Retain Discarded Sections (--retain Option) + +When --unused\_section\_elimination is on, the ELF linker does not include a section in the final link if it is not needed in the executable to resolve references. The --retain option tells the linker to retain a list of sections that would otherwise not be retained. This option accepts the wildcards '\*' and '?'. When wildcards are used, the argument should be in quotes. The syntax for this option is: + +``` +--retain=sym_or_scn_spec +``` + +The --retain option take one of the following forms: + +• **--retain=** *symbol\_spec* + +Specifying the symbol format retains sections that define *symbol\_spec*. For example, this code retains sections that define symbols that start with init: + +``` +--retain='init*' +``` + +You cannot specify --retain='\*'. + +• **--retain=** *file\_spec*(*scn\_spec*[, *scn\_spec*, ...] + +Specifying the file format retains sections that match one or more *scn\_spec* from files matching the *file\_spec*. For example, this code retains .intvec sections from all input files: + +``` +--retain='*(.int*)' +``` + +You can specify --retain='\*(\*)' to retain all sections from all input files. However, this does not prevent sections from library members from being optimized out. + +• **--retain=** *ar\_spec*<*mem\_spec*, [*mem\_spec*, ...>(*scn\_spec*[, *scn\_spec*, ...] + +Specifying the archive format retains sections matching one or more *scn\_spec* from members matching one or more *mem\_spec* from archive files matching *ar\_spec*. For example, this code retains the .text sections from printf.obj in the rtspruv3\_le.lib library: + +``` +--retain=rtspruv3_le.lib(.text) +``` + +If the library is specified with the --library option (--library=rtspruv3\_le.lib) the library search path is used to search for the library. You cannot specify '\*<\*>(\*)'. + +### 8.4.27 Create an Absolute Listing File (--run\_abs Option) + +The --run\_abs option produces an output file for each file linked. These files are named with the input filenames and an extension of .abs. Header files, however, do not generate a corresponding .abs file. + +### 8.4.28 Scan All Libraries for Duplicate Symbol Definitions (--scan\_libraries) + +The --scan\_libraries option scans all libraries during a link looking for duplicate symbol definitions to those symbols that are actually included in the link. The scan does not consider absolute symbols or symbols defined in COMDAT sections. The --scan\_libraries option helps determine those symbols that were actually chosen by the linker over other existing definitions of the same symbol in a library. + +The library scanning feature can be used to check against unintended resolution of a symbol reference to a definition when multiple definitions are available in the libraries. + +### 8.4.29 Define Stack Size (--stack\_size Option) + +The PRU C/C++ compiler uses an uninitialized section, .stack, to allocate space for the run-time stack. You can set the size of this section in bytes at link time with the --stack\_size option. The syntax for the --stack\_size option is: + +#### **--stack\_size=** *size* + +The *size* must be a constant and is in bytes. This example defines a 4K byte stack: + +``` +clpru --run_linker --stack_size=0x1000 /* defines a 4K heap (.stack section)*/ +``` + +If you specified a different stack size in an input section, the input section stack size is ignored. Any symbols defined in the input section remain valid; only the stack size is different. + +When the linker defines the .stack section, it also defines a global symbol, \_\_TI\_STACK\_SIZE, and assigns it a value equal to the size of the section. The default software stack size is . See Section 8.6.1 for information about referring to linker symbols in C/C++ code. + +### 8.4.30 Enforce Strict Compatibility (--strict\_compatibility Option) + +The linker performs more conservative and rigorous compatibility checking of input object files when you specify the --strict\_compatibility option. Using this option guards against additional potential compatibility issues, but may signal false compatibility errors when linking in object files built with an older toolset, or with object files built with another compiler vendor's toolset. To avoid issues with legacy libraries, the --strict\_compatibility option is turned off by default. + +### 8.4.31 Mapping of Symbols (--symbol\_map Option) + +Symbol mapping allows a symbol reference to be resolved by a symbol with a different name. Symbol mapping allows functions to be overridden with alternate definitions. This feature can be used to patch in alternate implementations, which provide patches (bug fixes) or alternate functionality. The syntax for the - -symbol\_map option is: + +#### **--symbol\_map=** *refname*=*defname* + +For example, the following code makes the linker resolve any references to foo by the definition foo\_patch: + +``` +--symbol_map='foo=foo_patch' +``` + +### 8.4.32 Introduce an Unresolved Symbol (--undef\_sym Option) + +The --undef\_sym option introduces the linkname for an unresolved symbol into the linker's symbol table. This forces the linker to search a library and include the member that defines the symbol. The linker must encounter the --undef\_sym option *before* it links in the member that defines the symbol. The syntax for the --undef\_sym option is: + +### **--undef\_sym=** *symbol* + +For example, suppose a library named rtspruv3\_le.lib contains a member that defines the symbol symtab; none of the object files being linked reference symtab. However, suppose you plan to relink the output module and you want to include the library member that defines symtab in this link. Using the --undef\_sym option as shown below forces the linker to search rtspruv3\_le.lib for the member that defines symtab and to link in the member. + +``` +clpru --run_linker --undef_sym=symtab file1.obj file2.obj rtspruv3_le.lib +``` + +If you do not use --undef\_sym, this member is not included, because there is no explicit reference to it in file1.obj or file2.obj. + +### 8.4.33 Display a Message When an Undefined Output Section Is Created (--warn\_sections) + +In a linker command file, you can set up a SECTIONS directive that describes how input sections are combined into output sections. However, if the linker encounters one or more input sections that do not have a corresponding output section defined in the SECTIONS directive, the linker combines the input sections that have the same name into an output section with that name. By default, the linker does not display a message to tell you that this occurred. + +You can use the --warn\_sections option to cause the linker to display a message when it creates a new output section. + +For more information about the SECTIONS directive, see Section 8.5.5. For more information about the default actions of the linker, see Section 8.7. + +### 8.4.34 Generate XML Link Information File (--xml\_link\_info Option) + +The linker supports the generation of an XML link information file through the --xml\_link\_info=*file* option. This option causes the linker to generate a well-formed XML file containing detailed information about the result of a link. The information included in this file includes all of the information that is currently produced in a linker generated map file. See Appendix B for specifics on the contents of the generated XML file. + +### 8.4.35 Zero Initialization (--zero\_init Option) + +The C and C++ standards require that global and static variables that are not explicitly initialized must be set to 0 before program execution. The C/C++ compiler supports preinitialization of uninitialized variables by default. To turn this off, specify the linker option --zero\_init=off. + +The syntax for the --zero\_init option is: + +**--zero\_init**[={*on*|*off*}] + +#### Disabling Zero Initialization Not Recommended + +**NOTE:** In general, this option it is not recommended. If you turn off zero initialization, automatic initialization of uninitialized global and static objects to zero will not occur. You are then expected to initialize these variables to zero in some other manner. + +## 8.5 Linker Command Files + +Linker command files allow you to put linker options and directives in a file; this is useful when you invoke the linker often with the same options and directives. Linker command files are also useful because they allow you to use the MEMORY and SECTIONS directives to customize your application. You must use these directives in a command file; you cannot use them on the command line. + +Linker command files are ASCII files that contain one or more of the following: + +- Input filenames, which specify object files, archive libraries, or other command files. (If a command file calls another command file as input, this statement must be the *last* statement in the calling command file. The linker does not return from called command files.) +- Linker options, which can be used in the command file in the same manner that they are used on the command line +- The MEMORY and SECTIONS linker directives. The MEMORY directive defines the target memory configuration (see Section 8.5.4). The SECTIONS directive controls how sections are built and allocated (see Section 8.5.5.) +- Assignment statements, which define and assign values to global symbols + +To invoke the linker with a command file, enter the clpru --run\_linker command and follow it with the name of the command file: + +``` +clpru --run_linker command_filename +``` + +The linker processes input files in the order that it encounters them. If the linker recognizes a file as an object file, it links the file. Otherwise, it assumes that a file is a command file and begins reading and processing commands from it. Command filenames are case sensitive, regardless of the system used. + +Example 8-1 shows a sample linker command file called link.cmd. + +### Example 8-1. Linker Command File + +``` +a.obj /* First input filename */ +b.obj /* Second input filename */ +--output_file=prog.out /* Option to specify output file */ +--map_file=prog.map /* Option to specify map file */ +``` + +The sample file in Example 8-1 contains only filenames and options. (You can place comments in a command file by delimiting them with /\* and \*/.) To invoke the linker with this command file, enter: + +``` +clpru --run_linker link.cmd +``` + +You can place other parameters on the command line when you use a command file: + +``` +clpru --run_linker --relocatable link.cmd c.obj d.obj +``` + +The linker processes the command file as soon as it encounters the filename, so a.obj and b.obj are linked into the output module before c.obj and d.obj. + +You can specify multiple command files. If, for example, you have a file called names.lst that contains filenames and another file called dir.cmd that contains linker directives, you could enter: + +``` +clpru --run_linker names.lst dir.cmd +``` + +One command file can call another command file; this type of nesting is limited to 16 levels. If a command file calls another command file as input, this statement must be the *last* statement in the calling command file. + +Blanks and blank lines are insignificant in a command file except as delimiters. This also applies to the format of linker directives in a command file. Example 8-2 shows a sample command file that contains linker directives. + +### Example 8-2. Command File With Linker Directives + +``` +a.obj b.obj c.obj /* Input filenames */ +--output_file=prog.out /* Options */ +--map_file=prog.map +MEMORY /* MEMORY directive */ +{ + FAST_MEM: origin = 0x0100 length = 0x0100 + SLOW_MEM: origin = 0x7000 length = 0x1000 +} +SECTIONS /* SECTIONS directive */ +{ + .text: > SLOW_MEM + .data: > SLOW_MEM + .bss: > FAST_MEM +} +``` + +For more information, see Section 8.5.4 for the MEMORY directive, and Section 8.5.5 for the SECTIONS directive. + +### 8.5.1 Reserved Names in Linker Command Files + +The following names (in both uppercase and lowercase) are reserved as keywords for linker directives. Do not use them as symbol or section names in a command file. + +In addition, any section names used by the TI tools are reserved from being used as the prefix for other names, unless the section will be a subsection of the section name used by the TI tools. For example, section names may not begin with .debug. + +### 8.5.2 Constants in Linker Command Files + +You can specify constants with either of two syntax schemes: the scheme used for specifying decimal, octal, or hexadecimal constants (but not binary constants) used in the assembler (see Section 4.6) or the scheme used for integer constants in C syntax. + +Examples: + +| Format | Decimal | Octal | Hexadecimal | +|------------------|---------|-------|-------------| +| Assembler format | 32 | 40q | 020h | +| C format | 32 | 040 | 0x20 | + +### 8.5.3 Accessing Files and Libraries from a Linker Command File + +Many applications use custom linker command files (or LCFs) to control the placement of code and data in target memory. For example, you may want to place a specific data object from a specific file into a specific location in target memory. This is simple to do using the available LCF syntax to reference the desired object file or library. However, a problem that many developers run into when they try to do this is a linker generated "file not found" error when accessing an object file or library from inside the LCF that has been specified earlier in the command-line invocation of the linker. Most often, this error occurs because the syntax used to access the file on the linker command-line does not match the syntax that is used to access the same file in the LCF. + +Consider a simple example. Imagine that you have an application that requires a table of constants called "app\_coeffs" to be defined in a memory area called "DDR". Assume also that the "app\_coeffs" data object is defined in a .data section that resides in an object file, app\_coeffs.obj. app\_coeffs.obj is then included in the object file library app\_data.lib. In your LCF, you can control the placement of the "app\_coeffs" data object as follows: + +``` +SECTIONS +{ + ... + .coeffs: { app_data.lib(.data) } > DDR + ... +} +``` + +Now assume that the app\_data.lib object library resides in a sub-directory called "lib" relative to where you are building the application. In order to gain access to app\_data.lib from the build command-line, you can use a combination of the –i and –l options to set up a directory search path which the linker can use to find the app\_data.lib library: + +The –i option adds the lib sub-directory to the directory search path and the –l option instructs the linker to look through the directories in the directory search path to find the app\_data.lib library. However, if you do not update the reference to app\_data.lib in mylnk.cmd, the linker will fail to find the app\_data.lib library and generate a "file not found" error. The reason is that when the linker encounters the reference to app\_data.lib inside the SECTIONS directive, there is no –l option preceding the reference. Therefore, the linker tries to open app\_data.lib in the current working directory. + +In essence, the linker has a few different ways of opening files: + +- If there is a path specified, the linker will look for the file in the specified location. For an absolute path, the linker will try to open the file in the specified directory. For a relative path, the linker will follow the specified path starting from the current working directory and try to open the file at that location. +- If there is no path specified, the linker will try to open the file in the current working directory. +- If a –l option precedes the file reference, then the linker will try to find and open the referenced file in one of the directories in the directory search path. The directory search path is set up via –i options and environment variables (like C\_DIR and ). + +As long as a file is referenced in a consistent manner on the command line and throughout any applicable LCFs, the linker will be able to find and open your object files and libraries. + +Returning to the earlier example, you can insert a –l option in front of the reference to app\_data.lib in mylnk.cmd to ensure that the linker will find and open the app\_data.lib library when the application is built: + +``` +SECTIONS +{ + ... + .coeffs: { -l app_data.lib(.data) } > DDR + ... +} +``` + +Another benefit to using the –l option when referencing a file from within an LCF is that if the location of the referenced file changes, you can modify the directory search path to incorporate the new location of the file (using –i option on the command line, for example) without having to modify the LCF. + +### 8.5.4 The MEMORY Directive + +The linker determines where output sections are allocated into memory; it must have a model of target memory to accomplish this. The MEMORY directive allows you to specify a model of target memory so that you can define the types of memory your system contains and the address ranges they occupy. The linker maintains the model as it allocates output sections and uses it to determine which memory locations can be used for object code. + +The memory configurations of PRU systems differ from application to application. The MEMORY directive allows you to specify a variety of configurations. After you use MEMORY to define a memory model, you can use the SECTIONS directive to allocate output sections into defined memory. + +For more information, see Section 2.5. + +#### 8.5.4.1 Default Memory Model + +If you do not use the MEMORY directive, the linker uses a default memory model that is based on the PRU architecture. This model assumes that the full 32-bit address space (232 locations) is present in the system and available for use. For more information about the default memory model, see Section 8.7. + +#### 8.5.4.2 MEMORY Directive Syntax + +The MEMORY directive identifies ranges of memory that are physically present in the target system and can be used by a program. Each range has several characteristics: + +- Name +- Starting address +- Length +- Optional set of attributes +- Optional fill specification + +When you use the MEMORY directive, be sure to identify all memory ranges that are available for the program to access at run time. Memory defined by the MEMORY directive is configured; any memory that you do not explicitly account for with MEMORY is unconfigured. The linker does not place any part of a program into unconfigured memory. You can represent nonexistent memory spaces by simply not including an address range in a MEMORY directive statement. + +The MEMORY directive is specified in a command file by the word MEMORY (uppercase), followed by a list of memory range specifications enclosed in braces. The MEMORY directive in Example 8-3 defines a system that has 4K bytes of fast external memory at address 0x0000 0000, 2K bytes of slow external memory at address 0x0000 1000 and 4K bytes of slow external memory at address 0x1000 0000. It also demonstrates the use of memory range expressions as well as start/end/size address operators (see Example 8-4). + +### Example 8-3. The MEMORY Directive + +``` +/********************************************************/ +/* Sample command file with MEMORY directive */ +/********************************************************/ +file1.obj file2.obj /* Input files */ +--output_file=prog.out /* Options */ +MEMORY +{ + FAST_MEM (RX): origin = 0x00000000 length = 0x00001000 CREGISTER=2 + SLOW_MEM (RW): origin = 0x00001000 length = 0x00000800 + EXT_MEM (RX): origin = 0x10000000 length = 0x00001000 +``` + +The general syntax for the MEMORY directive is: + +``` +MEMORY +{ + name 1 [( attr )] : origin = expression , length = expression [CREGISTER = constant] [, fill = + constant] + . + . + name n [( attr )] : origin = expression , length = expression [, fill = constant] +} +``` + +*name* names a memory range. A memory name can be one to 64 characters; valid characters include A-Z, a-z, \$, ., and \_. The names have no special significance to the linker; they simply identify memory ranges. Memory range names are internal to the linker and are not retained in the output file or in the symbol table. All memory ranges must have unique names and must not overlap. + +*attr* specifies one to four attributes associated with the named range. Attributes are optional; when used, they must be enclosed in parentheses. Attributes restrict the allocation of output sections into certain memory ranges. If you do not use any attributes, you can allocate any output section into any range with no restrictions. Any memory for which no attributes are specified (including all memory in the default model) has all four attributes. Valid attributes are: + +**R** specifies that the memory can be read. + +**W** specifies that the memory can be written to. + +**X** specifies that the memory can contain executable code. + +**I** specifies that the memory can be initialized. + +**origin** specifies the starting address of a memory range; enter as *origin*, *org*, or *o*. The value, specified in bytes, is a 32-bit integer constant expression, which can be decimal, octal, or hexadecimal. + +**length** specifies the length of a memory range; enter as *length*, *len*, or *l*. The value, specified in bytes, is a 32-bit integer constant expression, which can be decimal, octal, or hexadecimal. + +**CREGISTE R** + +The CREGISTER specifier associates a PRU constant table entry with a memory range. That constant table entry is then used when the memory name is specified with the "cregister" type attribute in C code. See the "Type Attributes" section of the *PRU Optimizing C/C++ Compiler User's Guide* ([SPRUHV7\)](http://www.ti.com/lit/pdf/SPRUHV7). + +**fill** specifies a fill character for the memory range; enter as *fill* or *f*. Fills are optional. The value is an integer constant and can be decimal, octal, or hexadecimal. The fill value is used to fill areas of the memory range that are not allocated to a section. (See Section 8.5.9.3 for virtual filling of memory ranges when using Error Correcting Code (ECC).) + +#### Filling Memory Ranges + +**NOTE:** If you specify fill values for large memory ranges, your output file will be very large because filling a memory range (even with 0s) causes raw data to be generated for all unallocated blocks of memory in the range. + +The following example specifies a memory range with the R and W attributes and a fill constant of 0FFFFFFFFh: + +``` +MEMORY +{ + RFILE (RW) : o = 0x0020, l = 0x1000, f = 0xFFFF +} +``` + +The following example uses the CREGISTER specifier: + +``` +MEMORY +{ + PRU_MEM_0 : org = 0x00000000 len = 0x00002000 CREGISTER=24 + PRU_MEM_1 : org = 0x00002000 len = 0x00002000 CREGISTER=25 +}. +``` + +The use of the CREGISTER specifier in the linker command file allows the cregister type attribute to be used in C code as follows: + +``` +int x __attribute__((cregister("PRU_MEM_0", near), peripheral)); +``` + +Linker command files normally use the MEMORY directive in conjunction with the SECTIONS directive to control placement of output sections. For more information about the SECTIONS directive, see Section 8.5.5. + +#### 8.5.4.3 Expressions and Address Operators + +Memory range origin and length can use expressions of integer constants with the following operators: + +``` +Binary operators: * / % + - << >> == = + < <= > >= & | && || +Unary operators: - ~ ! +``` + +Expressions are evaluated using standard C operator precedence rules. + +No checking is done for overflow or underflow, however, expressions are evaluated using a larger integer type. + +Preprocess directive #define constants can be used in place of integer constants. Global symbols cannot be used in Memory Directive expressions. + +Three address operators reference memory range properties from prior memory range entries: + +``` +START(MR) Returns start address for previously defined memory range MR. +SIZE(MR) Returns size of previously defined memory range MR. +END(MR) Returns end address for previously defined memory range MR. +``` + +### Example 8-4. Origin and Length as Expressions + +``` +/********************************************************/ +/* Sample command file with MEMORY directive */ +/********************************************************/ +file1.obj file2.obj /* Input files */ +--output_file=prog.out /* Options */ +#define ORIGIN 0x00000000 +#define BUFFER 0x00000200 +#define CACHE 0x0001000 +MEMORY +{ + FAST_MEM (RX): origin = ORIGIN + CACHE length = 0x00001000 + BUFFER + SLOW_MEM (RW): origin = end(FAST_MEM) length = 0x00001800 - size(FAST_MEM) + EXT_MEM (RX): origin = 0x10000000 length = size(FAST_MEM) - CACHE +``` + +### 8.5.5 The SECTIONS Directive + +After you use MEMORY to specify the target system's memory model, you can use SECTIONS to allocate output sections into specific named memory ranges or into memory that has specific attributes. For example, you could allocate the .text and .data sections into the area named FAST\_MEM and allocate the .bss section into the area named SLOW\_MEM. + +The SECTIONS directive controls your sections in the following ways: + +- Describes how input sections are combined into output sections +- Defines output sections in the executable program +- Allows you to control where output sections are placed in memory in relation to each other and to the entire memory space (Note that the memory placement order is *not* simply the sequence in which sections occur in the SECTIONS directive.) +- Permits renaming of output sections + +For more information, see Section 2.5, Section 2.7, and Section 2.4.6. Subsections allow you to manipulate sections with greater precision. + +If you do not specify a SECTIONS directive, the linker uses a default algorithm for combining and allocating the sections. Section 8.7 describes this algorithm in detail. + +#### 8.5.5.1 SECTIONS Directive Syntax + +The SECTIONS directive is specified in a command file by the word SECTIONS (uppercase), followed by a list of output section specifications enclosed in braces. + +The general syntax for the SECTIONS directive is: + +``` +SECTIONS +{ + name : [property [, property] [, property] . . . ] + name : [property [, property] [, property] . . . ] + name : [property [, property] [, property] . . . ] +} +``` + +Each section specification, beginning with *name*, defines an output section. (An output section is a section in the output file.) Section names can refer to sections, subsections, or archive library members. (See Section 8.5.5.4 for information on multi-level subsections.) After the section name is a list of properties that define the section's contents and how the section is allocated. The properties can be separated by optional commas. Possible properties for a section are as follows: + +• **Load allocation** defines where in memory the section is to be loaded. See Section 3.5, Section 3.1.1, and Section 8.5.6. + +``` +Syntax: load = allocation or + > allocation +``` + +• **Run allocation** defines where in memory the section is to be run. + +``` +Syntax: run = allocation or + run > allocation +``` + +• **Input sections** defines the input sections (object files) that constitute the output section. See Section 8.5.5.3. + +``` +Syntax: { input_sections } +``` + +• **Section type** defines flags for special section types. See Section 8.5.8. + +``` +Syntax: type = COPY or + type = DSECT or +``` + +• **Fill value** defines the value used to fill uninitialized holes. See Section 8.5.11. + +``` +Syntax: fill = value +``` + +Example 8-5 shows a SECTIONS directive in a sample linker command file. + +#### Example 8-5. The SECTIONS Directive + +``` +/* Sample command file with SECTIONS directive */ +/**************************************************/ +file1.obj file2.obj /* Input files */ +--output_file=prog.out /* Options */ +SECTIONS +{ + .text: load = EXT_MEM, run = 0x00000800 + .const: load = FAST_MEM + .bss: load = SLOW_MEM + .data:alpha: align = 16 + .data:beta: align = 16 +} +``` + +Figure 8-2 shows the output sections defined by the SECTIONS directive in Example 8-5 (.text, .const, .bss, .data:alpha, and .data:beta) and shows how these sections are allocated in memory using the MEMORY directive given in Example 8-3. + +**Figure 8-2. Section Placement Defined by Example 8-5** + +#### 8.5.5.2 Section Allocation and Placement + +The linker assigns each output section two locations in target memory: the location where the section will be loaded and the location where it will be run. Usually, these are the same, and you can think of each section as having only a single address. The process of locating the output section in the target's memory and assigning its address(es) is called placement. For more information about using separate load and run placement, see Section 8.5.6. + +If you do not tell the linker how a section is to be allocated, it uses a default algorithm to place the section. Generally, the linker puts sections wherever they fit into configured memory. You can override this default placement for a section by defining it within a SECTIONS directive and providing instructions on how to allocate it. + +You control placement by specifying one or more allocation parameters. Each parameter consists of a keyword, an optional equal sign or greater-than sign, and a value optionally enclosed in parentheses. If load and run placement are separate, all parameters following the keyword LOAD apply to load placement, and those following the keyword RUN apply to run placement. The allocation parameters are: + +**Binding** allocates a section at a specific address. + +.text: load = 0x1000 + +**Named memory** allocates the section into a range defined in the MEMORY directive with the specified name (like SLOW\_MEM) or attributes. + +.text: load > SLOW\_MEM + +**Alignment** uses the align or palign keyword to specify the section must start on an address boundary. + +.text: align = 0x100 + +**Blocking** uses the block keyword to specify the section must fit between two address aligned to the blocking factor. If a section is too large, it starts on an address boundary. + +.text: block(0x100) + +For the load (usually the only) allocation, use a greater-than sign and omit the load keyword: + +``` +.text: > SLOW_MEM +.text: {...} > SLOW_MEM +.text: > 0x4000 +``` + +If more than one parameter is used, you can string them together as follows: + +``` +.text: > SLOW_MEM align 16 +``` + +Or if you prefer, use parentheses for readability: + +``` +.text: load = (SLOW_MEM align(16)) +``` + +You can also use an input section specification to identify the sections from input files that are combined to form an output section. See Section 8.5.5.3. + +Additional information about controlling the order in which code and data are placed in memory is provided in the FAQ topic on section [placement](http://processors.wiki.ti.com/index.php/Code_Generation_Tools_FAQ#Q:_How_can_I_get_the_linker_to_place_a_piece_of_code_or_data_so_that_it_comes_before_all_the_rest.3F). + +#### 8.5.5.2.1 Binding + +You can set the starting address for an output section by following the section name with an address: + +``` +.text: 0x00001000 +``` + +This example specifies that the .text section must begin at location 0x1000. The binding address must be a 32-bit constant. + +Output sections can be bound anywhere in configured memory (assuming there is enough space), but they cannot overlap. If there is not enough space to bind a section to a specified address, the linker issues an error message. + +#### Binding is Incompatible With Alignment and Named Memory + +**NOTE:** You cannot bind a section to an address if you use alignment or named memory. If you try to do this, the linker issues an error message. + +#### 8.5.5.2.2 Named Memory + +You can allocate a section into a memory range that is defined by the MEMORY directive (see Section 8.5.4). This example names ranges and links sections into them: + +``` +MEMORY +{ + SLOW_MEM (RIX) : origin = 0x00000000, length = 0x00001000 + FAST_MEM (RWIX) : origin = 0x03000000, length = 0x00000300 +} +SECTIONS +{ + .text : > SLOW_MEM + .data : > FAST_MEM ALIGN(128) + .bss : > FAST_MEM +} +``` + +In this example, the linker places .text into the area called SLOW\_MEM. The .data and .bss output sections are allocated into FAST\_MEM. You can align a section within a named memory range; the .data section is aligned on a 128-byte boundary within the FAST\_MEM range. + +Similarly, you can link a section into an area of memory that has particular attributes. To do this, specify a set of attributes (enclosed in parentheses) instead of a memory name. Using the same MEMORY directive declaration, you can specify: + +``` +SECTIONS +{ + .text: > (X) /* .text --> executable memory */ + .data: > (RI) /* .data --> read or init memory */ + .bss : > (RW) /* .bss --> read or write memory */ +} +``` + +In this example, the .text output section can be linked into either the SLOW\_MEM or FAST\_MEM area because both areas have the X attribute. The .data section can also go into either SLOW\_MEM or FAST\_MEM because both areas have the R and I attributes. The .bss output section, however, must go into the FAST\_MEM area because only FAST\_MEM is declared with the W attribute. + +You cannot control where in a named memory range a section is allocated, although the linker uses lower memory addresses first and avoids fragmentation when possible. In the preceding examples, assuming no conflicting assignments exist, the .text section starts at address 0. If a section must start on a specific address, use binding instead of named memory. + +#### 8.5.5.2.3 Controlling Placement Using The HIGH Location Specifier + +The linker allocates output sections from low to high addresses within a designated memory range by default. Alternatively, you can cause the linker to allocate a section from high to low addresses within a memory range by using the HIGH location specifier in the SECTION directive declaration. You might use the HIGH location specifier in order to keep RTS code separate from application code, so that small changes in the application do not cause large changes to the memory map. + +For example, given this MEMORY directive: + +``` +MEMORY +{ + RAM : origin = 0x0200, length = 0x0800 + FLASH : origin = 0x1100, length = 0xEEE0 + RESET : origin = 0xFFFE, length = 0x0002 +} +``` + +and an accompanying SECTIONS directive: + +``` +SECTIONS +{ + .bss : {} > RAM + .sysmem : {} > RAM + .stack : {} > RAM (HIGH) +} +``` + +The HIGH specifier used on the .stack section placement causes the linker to attempt to allocate .stack into the higher addresses within the RAM memory range. The .bss and .sysmem sections are allocated into the lower addresses within RAM. Example 8-6 illustrates a portion of a map file that shows where the given sections are allocated within RAM for a typical program. + +#### Example 8-6. Linker Placement With the HIGH Specifier + +| .bss | 0 | 00000200 | 00000270 | UNINITIALIZED | +|---------|---|----------|----------|------------------------------------| +| | | 00000200 | 0000011a | rtsxxx.lib
: defs.obj (.bss) | +| | | 0000031a | 00000088 | : trgdrv.obj (.bss) | +| | | 000003a2 | 00000078 | : lowlev.obj (.bss) | +| | | 0000041a | 00000046 | : exit.obj (.bss) | +| | | 00000460 | 00000008 | : memory.obj (.bss) | +| | | 00000468 | 00000004 | : _lock.obj (.bss) | +| | | 0000046c | 00000002 | : fopen.obj (.bss) | +| | | 0000046e | 00000002 | hello.obj (.bss) | +| .sysmem | 0 | 00000470 | 00000120 | UNINITIALIZED | +| | | 00000470 | 00000004 | rtsxxx .lib : memory.obj (.sysmem) | +| .stack | 0 | 000008c0 | 00000140 | UNINITIALIZED | +| | | 000008c0 | 00000002 | rtsxxx .lib : boot.obj (.stack) | + +As shown in Example 8-6 , the .bss and .sysmem sections are allocated at the lower addresses of RAM (0x0200 - 0x0590) and the .stack section is allocated at address 0x08c0, even though lower addresses are available. + +Without using the HIGH specifier, the linker allocation would result in the code shown in Example 8-7 + +The HIGH specifier is ignored if it is used with specific address binding or automatic section splitting (>> operator). + +### Example 8-7. Linker Placement Without HIGH Specifier + +| .bss | 0 | 00000200 | 00000270 | UNINITIALIZED | +|---------|---|----------|----------|--------------------------------------| +| | | 00000200 | 0000011a | rtsxxx.lib
: defs.obj (.bss) | +| | | 0000031a | 00000088 | : trgdrv.obj (.bss) | +| | | 000003a2 | 00000078 | : lowlev.obj (.bss) | +| | | 0000041a | 00000046 | : exit.obj (.bss) | +| | | 00000460 | 00000008 | : memory.obj (.bss) | +| | | 00000468 | 00000004 | : _lock.obj (.bss) | +| | | 0000046c | 00000002 | : fopen.obj (.bss) | +| | | 0000046e | 00000002 | hello.obj (.bss) | +| .stack | 0 | 00000470 | 00000140 | UNINITIALIZED | +| | | 00000470 | 00000002 | rtsxxx.lib
: boot.obj (.stack) | +| .sysmem | 0 | 000005b0 | 00000120 | UNINITIALIZED | +| | | 000005b0 | 00000004 | rtsxxx.lib
: memory.obj (.sysmem) | + +#### 8.5.5.2.4 Alignment and Blocking + +You can tell the linker to place an output section at an address that falls on an n-byte boundary, where n is a power of 2, by using the align keyword. For example, the following code allocates .text so that it falls on a 32-byte boundary: + +``` +.text: load = align(32) +``` + +Blocking is a weaker form of alignment that allocates a section anywhere *within* a block of size n. The specified block size must be a power of 2. For example, the following code allocates .bss so that the entire section is contained in a single 128-byte or begins on that boundary: + +``` +bss: load = block(0x0080) +``` + +You can use alignment or blocking alone or in conjunction with a memory area, but alignment and blocking cannot be used together. + +#### 8.5.5.2.5 Alignment With Padding + +As with align, you can tell the linker to place an output section at an address that falls on an n-byte boundary, where n is a power of 2, by using the palign keyword. In addition, palign ensures that the size of the section is a multiple of its placement alignment restrictions, padding the section size up to such a boundary, as needed. + +For example, the following code lines allocate .text on a 2-byte boundary within the PMEM area. The .text section size is guaranteed to be a multiple of 2 bytes. Both statements are equivalent: + +``` +.text: palign(2) {} > PMEM +.text: palign = 2 {} > PMEM +``` + +If the linker adds padding to an initialized output section then the padding space is also initialized. By default, padding space is filled with a value of 0 (zero). However, if a fill value is specified for the output section then any padding for the section is also filled with that fill value. For example, consider the following section specification: + +``` +.mytext: palign(8), fill = 0xffffffff {} > PMEM +``` + +In this example, the length of the .mytext section is before the palign operator is applied. The contents of .mytext are as follows: + +``` +addr content +---- ------- +0000 0x1234 +0002 0x1234 +0004 0x1234 +``` + +After the palign operator is applied, the length of .mytext is 8 bytes, and its contents are as follows: + +``` +addr content +---- ------- +0000 0x1234 +0002 0x1234 +0004 0x1234 +0006 0xffff +``` + +The size of .mytext has been bumped to a multiple of 8 bytes and the padding created by the linker has been filled with 0xff. + +The fill value specified in the linker command file is interpreted as a 16-bit constant. If you specify this code: + +``` +.mytext: palign(8), fill = 0xff {} > PMEM +``` + +The fill value assumed by the linker is 0x00ff, and .mytext will then have the following contents: + +``` +addr content +---- ------- +0000 0x1234 +0002 0x1234 +0004 0x1234 +0006 0x00ff +``` + +If the palign operator is applied to an uninitialized section, then the size of the section is bumped to the appropriate boundary, as needed, but any padding created is not initialized. + +The palign operator can also take a parameter of *power2*. This parameter tells the linker to add padding to increase the section's size to the next power of two boundary. In addition, the section is aligned on that power of 2 as well. For example, consider the following section specification: + +``` +.mytext: palign(power2) {} > PMEM +``` + +Assume that the size of the .mytext section is 120 bytes and PMEM starts at address 0x10020. After applying the palign(power2) operator, the .mytext output section will have the following properties: + +``` +name addr size align +------- ---------- ----- ----- +.mytext 0x00010080 0x80 128 +``` + +#### 8.5.5.3 Specifying Input Sections + +An input section specification identifies the sections from input files that are combined to form an output section. In general, the linker combines input sections by concatenating them in the order in which they are specified. However, if alignment or blocking is specified for an input section, all of the input sections within the output section are ordered as follows: + +- All aligned sections, from largest to smallest +- All blocked sections, from largest to smallest +- All other sections, from largest to smallest + +The size of an output section is the sum of the sizes of the input sections that it comprises. + +Example 8-8 shows the most common type of section specification; note that no input sections are listed. + +#### Example 8-8. The Most Common Method of Specifying Section Contents + +``` +SECTIONS +{ + .text: + .data: + .bss: +} +``` + +In Example 8-8, the linker takes all the .text sections from the input files and combines them into the .text output section. The linker concatenates the .text input sections in the order that it encounters them in the input files. The linker performs similar operations with the .data and .bss sections. You can use this type of specification for any output section. + +You can explicitly specify the input sections that form an output section. Each input section is identified by its filename and section name. If the filename is hyphenated (or contains special characters), enclose it within quotes: + +``` +SECTIONS +{ + .text : /* Build .text output section */ + { + f1.obj(.text) /* Link .text section from f1.obj */ + f2.obj(sec1) /* Link sec1 section from f2.obj */ + "f3-new.obj" /* Link ALL sections from f3-new.obj */ + f4.obj(.text,sec2) /* Link .text and sec2 from f4.obj */ + f5.obj(.task??) /* Link .task00, .task01, .taskXX, etc. from f5.obj */ + f6.obj(*_ctable) /* Link sections ending in "_ctable" from f6.obj */ + X*.obj(.text) /* Link .text section for all files starting with */ + /* "X" and ending in ".obj" */ + } +} +``` + +It is not necessary for input sections to have the same name as each other or as the output section they become part of. If a file is listed with no sections,*all* of its sections are included in the output section. If any additional input sections have the same name as an output section but are not explicitly specified by the SECTIONS directive, they are automatically linked in at the end of the output section. For example, if the linker found more .text sections in the preceding example and these .text sections *were not* specified anywhere in the SECTIONS directive, the linker would concatenate these extra sections after f4.obj(sec2). + +The specifications in Example 8-8 are actually a shorthand method for the following: + +``` +SECTIONS +{ + .text: { *(.text) } + .data: { *(.data) } + .bss: { *(.bss) } +} +``` + +The specification \*(.text) means *the unallocated .text sections from all input files.* This format is useful if: + +- You want the output section to contain all input sections that have a specified name, but the output section name is different from the input sections' name. +- You want the linker to allocate the input sections before it processes additional input sections or commands within the braces. + +The following example illustrates the two purposes above: + +``` +SECTIONS +{ + .text : { + abc.obj(xqt) + *(.text) + } + .data : { + *(.data) + fil.obj(table) + } +} +``` + +In this example, the .text output section contains a named section xqt from file abc.obj, which is followed by all the .text input sections. The .data section contains all the .data input sections, followed by a named section table from the file fil.obj. This method includes all the unallocated sections. For example, if one of the .text input sections was already included in another output section when the linker encountered \*(.text), the linker could not include that first .text input section in the second output section. + +Each input section acts as a prefix and gathers longer-named sections. For example, the pattern \*(.data) matches .dataspecial. This mechanism enables the use of subsections, which are described in the following section. + +#### 8.5.5.4 Using Multi-Level Subsections + +Subsections can be identified with the base section name and one or more subsection names separated by colons. For example, A:B and A:B:C name subsections of the base section A. In certain places in a linker command file specifying a base name, such as A, selects the section A as well as any subsections of A, such as A:B or A:C:D. + +A name such as A:B can specify a (sub)section of that name as well as any (multi-level) subsections beginning with that name, such as A:B:C, A:B:OTHER, etc. All subsections of A:B are also subsections of A. A and A:B are supersections of A:B:C. Among a group of supersections of a subsection, the nearest supersection is the supersection with the longest name. Thus, among {A, A:B} the nearest supersection of A:B:C:D is A:B. With multiple levels of subsections, the constraints are the following: + +- 1. When specifying **input** sections within a file (or library unit) the section name selects an input section of the same name and any subsections of that name. +- 2. Input sections that are not explicitly allocated are allocated in an existing **output** section of the same name or in the nearest existing supersection of such an output section. An exception to this rule is that during a partial link (specified by the --relocatable linker option) a subsection is allocated only to an existing output section of the same name. +- 3. If no such output section described in 2) is defined, the input section is put in a **newly created output** section with the same name as the base name of the input section + +Consider linking input sections with the following names: + +europe:north:norway europe:central:france europe:south:spain europe:north:sweden europe:central:germany europe:south:italy europe:north:finland europe:central:denmark europe:south:malta europe:north:iceland + +This SECTIONS specification allocates the input sections as indicated in the comments: + +``` +SECTIONS { + nordic: {*(europe:north) + *(europe:central:denmark)} /* the nordic countries */ + central: {*(europe:central)} /* france, germany */ + therest: {*(europe)} /* spain, italy, malta */ +} +``` + +This SECTIONS specification allocates the input sections as indicated in the comments: + +``` +SECTIONS { + islands: {*(europe:south:malta) + *(europe:north:iceland)} /* malta, iceland */ + europe:north:finland : {} /* finland */ + europe:north : {} /* norway, sweden */ + europe:central : {} /* germany, denmark */ + europe:central:france: {} /* france */ + /* (italy, spain) go into a linker-generated output section "europe" */ +} +``` + +#### Upward Compatibility of Multi-Level Subsections + +**NOTE:** Existing linker commands that use the existing single-level subsection features and which do not contain section names containing multiple colon characters continue to behave as before. However, if section names in a linker command file or in the input sections supplied to the linker contain multiple colon characters, some change in behavior could be possible. You should carefully consider the impact of the rules for multiple levels to see if it affects a particular system link. + +#### 8.5.5.5 Specifying Library or Archive Members as Input to Output Sections + +You can specify one or more members of an object library or archive for input to an output section. Consider this SECTIONS directive: + +#### Example 8-9. Archive Members to Output Sections + +``` +SECTIONS +{ + boot > BOOT1 + { + -l rtsXX.lib (.text) + -l rtsXX.lib (.text) + } + .rts > BOOT2 + { + -l rtsXX.lib (.text) + } + .text > RAM + { + * (.text) + } +} +``` + +In Example 8-9, the .text sections of boot.obj, exit.obj, and strcpy.obj are extracted from the run-timesupport library and placed in the .boot output section. The remainder of the run-time-support library object that is referenced is allocated to the .rts output section. Finally, the remainder of all other .text sections are to be placed in section .text. + +An archive member or a list of members is specified by surrounding the member name(s) with angle brackets < and > after the library name. Any object files separated by commas or spaces from the specified archive file are legal within the angle brackets. + +The --library option (which normally implies a library path search be made for the named file following the option) listed before each library in Example 8-9 is optional when listing specific archive members inside < >. Using < > implies that you are referring to a library. + +To collect a set of the input sections from a library in one place, use the --library option within the SECTIONS directive. For example, the following collects all the .text sections from rtspruv3\_le.lib into the .rtstest section: + +``` +SECTIONS +{ + .rtstest { -l rtspruv3_le.lib(.text) } > RAM +} +``` + +#### SECTIONS Directive Effect on --priority + +**NOTE:** Specifying a library in a SECTIONS directive causes that library to be entered in the list of libraries that the linker searches to resolve references. If you use the --priority option, the first library specified in the command file will be searched first. + +#### 8.5.5.6 Allocation Using Multiple Memory Ranges + +The linker allows you to specify an explicit list of memory ranges into which an output section can be allocated. Consider the following example: + +``` +MEMORY +{ + P_MEM1 : origin = 0x02000, length = 0x01000 + P_MEM2 : origin = 0x04000, length = 0x01000 + P_MEM3 : origin = 0x06000, length = 0x01000 + P_MEM4 : origin = 0x08000, length = 0x01000 +} +SECTIONS +{ + .text : { } > P_MEM1 | P_MEM2 | P_MEM4 +} +``` + +The | operator is used to specify the multiple memory ranges. The .text output section is allocated as a whole into the first memory range in which it fits. The memory ranges are accessed in the order specified. In this example, the linker first tries to allocate the section in P\_MEM1. If that attempt fails, the linker tries to place the section into P\_MEM2, and so on. If the output section is not successfully allocated in any of the named memory ranges, the linker issues an error message. + +With this type of SECTIONS directive specification, the linker can seamlessly handle an output section that grows beyond the available space of the memory range in which it is originally allocated. Instead of modifying the linker command file, you can let the linker move the section into one of the other areas. + +#### 8.5.5.7 Automatic Splitting of Output Sections Among Non-Contiguous Memory Ranges + +The linker can split output sections among multiple memory ranges for efficient allocation. Use the >> operator to indicate that an output section can be split, if necessary, into the specified memory ranges: + +``` +MEMORY +{ + P_MEM1 : origin = 0x2000, length = 0x1000 + P_MEM2 : origin = 0x4000, length = 0x1000 + P_MEM3 : origin = 0x6000, length = 0x1000 + P_MEM4 : origin = 0x8000, length = 0x1000 +} +SECTIONS +{ + .text: { *(.text) } >> P_MEM1 | P_MEM2 | P_MEM3 | P_MEM4 +} +``` + +In this example, the >> operator indicates that the .text output section can be split among any of the listed memory areas. If the .text section grows beyond the available memory in P\_MEM1, it is split on an input section boundary, and the remainder of the output section is allocated to P\_MEM2 | P\_MEM3 | P\_MEM4. + +The | operator is used to specify the list of multiple memory ranges. + +You can also use the >> operator to indicate that an output section can be split within a single memory range. This functionality is useful when several output sections must be allocated into the same memory range, but the restrictions of one output section cause the memory range to be partitioned. Consider the following example: + +``` +MEMORY +{ + RAM : origin = 0x1000, length = 0x8000 +} +SECTIONS +{ + .special: { f1.obj(.text) } load = 0x4000 + .text: { *(.text) } >> RAM +} +``` + +The .special output section is allocated near the middle of the RAM memory range. This leaves two unused areas in RAM: from 0x1000 to 0x4000, and from the end of f1.obj(.text) to 0x8000. The specification for the .text section allows the linker to split the .text section around the .special section and use the available space in RAM on either side of .special. + +The >> operator can also be used to split an output section among all memory ranges that match a specified attribute combination. For example: + +``` +MEMORY +{ + P_MEM1 (RWX) : origin = 0x1000, length = 0x2000 + P_MEM2 (RWI) : origin = 0x4000, length = 0x1000 +} +SECTIONS +{ + .text: { *(.text) } >> (RW) +} +``` + +The linker attempts to allocate all or part of the output section into any memory range whose attributes match the attributes specified in the SECTIONS directive. + +This SECTIONS directive has the same effect as: + +``` +SECTIONS +{ +.text: { *(.text) } >> P_MEM1 | P_MEM2} +} +``` + +Certain sections should not be split: + +- Certain sections created by the compiler, including + - The .cinit section, which contains the autoinitialization table for C/C++ programs + - The .pinit section, which contains the list of global constructors for C++ programs +- An output section with an input section specification that includes an expression to be evaluated. The expression may define a symbol that is used in the program to manage the output section at run time. +- An output section that has a START(), END(), OR SIZE() operator applied to it. These operators provide information about a section's load or run address, and size. Splitting the section may compromise the integrity of the operation. +- The run allocation of a UNION. (Splitting the load allocation of a UNION is allowed.) + +If you use the >> operator on any of these sections, the linker issues a warning and ignores the operator. + +### 8.5.6 Placing a Section at Different Load and Run Addresses + +At times, you may want to load code into one area of memory and run it in another. For example, you may have performance-critical code in slow external memory. The code must be loaded into slow external memory, but it would run faster in fast external memory. + +The linker provides a simple way to accomplish this. You can use the SECTIONS directive to direct the linker to allocate a section twice: once to set its load address and again to set its run address. For example: + +``` +.fir: load = SLOW_MEM, run = FAST_MEM +``` + +Use the *load* keyword for the load address and the *run* keyword for the run address. + +See Section 3.5 for an overview on run-time relocation. + +The application must copy the section from its load address to its run address; this does *not* happen automatically when you specify a separate run address. (The TABLE operator instructs the linker to produce a copy table; see Section 8.8.4.1.) + +#### 8.5.6.1 Specifying Load and Run Addresses + +The load address determines where a loader places the raw data for the section. Any references to the section (such as labels in it) refer to its run address. See Section 3.1.1 for an overview of load and run addresses. + +If you provide only one allocation (either load or run) for a section, the section is allocated only once and loads and runs at the same address. If you provide both allocations, the section is allocated as if it were two sections of the same size. This means that both allocations occupy space in the memory map and cannot overlay each other or other sections. (The UNION directive provides a way to overlay sections; see Section 8.5.7.2.) + +If either the load or run address has additional parameters, such as alignment or blocking, list them after the appropriate keyword. Everything related to allocation after the keyword *load* affects the load address until the keyword *run* is seen, after which, everything affects the run address. The load and run allocations are completely independent, so any qualification of one (such as alignment) has no effect on the other. You can also specify run first, then load. Use parentheses to improve readability. + +The examples that follow specify load and run addresses. + +In this example, align applies only to load: + +``` +.data: load = SLOW_MEM, align = 32, run = FAST_MEM +``` + +The following example uses parentheses, but has effects that are identical to the previous example: + +``` +.data: load = (SLOW_MEM align 32), run = FAST_MEM +``` + +The following example aligns FAST\_MEM to 32 bits for run allocations and aligns all load allocations to 16 bits: + +``` +.data: run = FAST_MEM, align 32, load = align 16 +``` + +For more information on run-time relocation see Section 3.5. + +Uninitialized sections (such as .bss) are not loaded, so their only significant address is the run address. The linker allocates uninitialized sections only once: if you specify both run and load addresses, the linker warns you and ignores the load address. Otherwise, if you specify only one address, the linker treats it as a run address, regardless of whether you call it load or run. + +This example specifies load and run addresses for an uninitialized section: + +``` +.bss: load = 0x1000, run = FAST_MEM +``` + +A warning is issued, load is ignored, and space is allocated in FAST\_MEM. All of the following examples have the same effect. The .bss section is allocated in FAST\_MEM. + +``` +.dbss: load = FAST_MEM +.bss: run = FAST_MEM +.bss: > FAST_MEM +``` + +### 8.5.7 Using GROUP and UNION Statements + +Two SECTIONS statements allow you to organize or conserve memory: GROUP and UNION. Grouping sections causes the linker to allocate them contiguously in memory. Unioning sections causes the linker to allocate them to the same run address. + +#### 8.5.7.1 Grouping Output Sections Together + +The SECTIONS directive's GROUP option forces several output sections to be allocated contiguously and in the order listed, unless the UNORDERED operator is used. For example, assume that a section named term\_rec contains a termination record for a table in the .data section. You can force the linker to allocate .data and term\_rec together: + +## Example 8-10. Allocate Sections Together + +``` +SECTIONS +{ + .text /* Normal output section */ + .bss /* Normal output section */ + GROUP 0x00001000 : /* Specify a group of sections */ + { + .data /* First section in the group */ + term_rec /* Allocated immediately after .data */ + } +} +``` + +You can use binding, alignment, or named memory to allocate a GROUP in the same manner as a single output section. In the preceding example, the GROUP is bound to address 0x1000. This means that .data is allocated at 0x1000, and term\_rec follows it in memory. + +#### You Cannot Specify Addresses for Sections Within a GROUP + +**NOTE:** When you use the GROUP option, binding, alignment, or allocation into named memory can be specified for the group only. You cannot use binding, named memory, or alignment for sections within a group. + +#### 8.5.7.2 Overlaying Sections With the UNION Statement + +For some applications, you may want to allocate more than one section that occupies the same address during run time. For example, you may have several routines you want in fast external memory at different stages of execution. Or you may want several data objects that are not active at the same time to share a block of memory. The UNION statement within the SECTIONS directive provides a way to allocate several sections at the same run-time address. + +In Example 8-11, the .bss sections from file1.obj and file2.obj are allocated at the same address in FAST\_MEM. In the memory map, the union occupies as much space as its largest component. The components of a union remain independent sections; they are simply allocated together as a unit. + +#### Example 8-11. The UNION Statement + +``` +SECTIONS +{ + .text: load = SLOW_MEM + UNION: run = FAST_MEM + { + .bss:part1: { file1.obj(.bss) } + .bss:part2: { file2.obj(.bss) } + } + .bss:part3: run = FAST_MEM { globals.obj(.bss) } +} +``` + +Allocation of a section as part of a union affects only its *run address.* Under no circumstances can sections be overlaid for loading. If an initialized section is a union member (an initialized section, such as .text, has raw data), its load allocation *must* be separately specified. See Example 8-12. (There is an exception to this rule when combining an initialized section with uninitialized sections; see Section 8.5.7.3.) + +## Example 8-12. Separate Load Addresses for UNION Sections + +``` +UNION run = FAST_MEM +{ + .text:part1: load = SLOW_MEM, { file1.obj(.text) } + .text:part2: load = SLOW_MEM, { file2.obj(.text) } +} +``` + +**Figure 8-3. Memory Allocation Shown in Example 8-11 and Example 8-12** + +![Figure 8-3: Memory Allocation in Examples 8-11 and 8-12 — two diagrams showing FAST_MEM and SLOW_MEM with .bss union sections (run only) and separate .text load/run addresses](_page_202_Figure_6.jpeg) + +**Figure 8-3: Memory Allocation Shown in Example 8-11 and Example 8-12.** Two side-by-side memory diagrams. Left diagram: FAST_MEM contains .bss:part2 and .bss:part1 (overlapping as a union — run-time allocation only) and .bss:part3 separately; SLOW_MEM contains .text. Right diagram: FAST_MEM contains .text 2 (run) and .text 1 (run) with an arrow labeled "Copies at run time" from SLOW_MEM; SLOW_MEM contains .text 1 (load) and .text 2 (load) labeled "Sections cannot load as a union." The diagrams illustrate that uninitialized (.bss) sections can run as a union sharing the same address space, while initialized (.text) sections must each have a distinct load address. + +Since the .text sections contain raw data, they cannot *load* as a union, although they can be *run* as a union. Therefore, each requires its own load address. If you fail to provide a load allocation for an initialized section within a UNION, the linker issues a warning and allocates load space anywhere it can in configured memory. + +Uninitialized sections are not loaded and do not require load addresses. + +The UNION statement applies only to allocation of run addresses, so it is meaningless to specify a load address for the union itself. For purposes of allocation, the union is treated as an uninitialized section: any one allocation specified is considered a run address, and if both run and load addresses are specified, the linker issues a warning and ignores the load address. + +#### 8.5.7.3 Using Memory for Multiple Purposes + +One way to reduce an application's memory requirement is to use the same range of memory for multiple purposes. You can first use a range of memory for system initialization and startup. Once that phase is complete, the same memory can be repurposed as a collection of uninitialized data variables or a heap. To implement this scheme, use the following variation of the UNION statement to allow one section to be initialized and the remaining sections to be uninitialized. + +Generally, an initialized section (one with raw data, such as .text) in a union must have its load allocation specified separately. However, one and only one initialized section in a union can be allocated at the union's run address. By listing it in the UNION statement with no load allocation at all, it will use the union's run address as its own load address. + +## For example: + +``` +UNION run = FAST_MEM +{ .cinit .bss } +``` + +In this example, the .cinit section is an initialized section. It will be loaded into FAST\_MEM at the run address of the union. In contrast, .bss is an uninitialized section. Its run address will also be that of the union. + +#### 8.5.7.4 Nesting UNIONs and GROUPs + +The linker allows arbitrary nesting of GROUP and UNION statements with the SECTIONS directive. By nesting GROUP and UNION statements, you can express hierarchical overlays and groupings of sections. Example 8-13 shows how two overlays can be grouped together. + +## Example 8-13. Nesting GROUP and UNION Statements + +``` +SECTIONS +{ + GROUP 0x1000 : run = FAST_MEM + { + UNION: + { + mysect1: load = SLOW_MEM + mysect2: load = SLOW_MEM + } + UNION: + { + mysect3: load = SLOW_MEM + mysect4: load = SLOW_MEM + } + } +} +``` + +For this example, the linker performs the following allocations: + +- The four sections (mysect1, mysect2, mysect3, mysect4) are assigned unique, non-overlapping load addresses. This assignment is determined by the particular load allocations given for each section. +- Sections mysect1 and mysect2 are assigned the same run address in FAST\_MEM. +- Sections mysect3 and mysect4 are assigned the same run address in FAST\_MEM. +- The run addresses of mysect1/mysect2 and mysect3/mysect4 are allocated contiguously, as directed by the GROUP statement (subject to alignment and blocking restrictions). + +To refer to groups and unions, linker diagnostic messages use the notation: + +``` +GROUP_n UNION_n +``` + +where *n* is a sequential number (beginning at 1) that represents the lexical ordering of the group or union in the linker control file without regard to nesting. Groups and unions each have their own counter. + +#### 8.5.7.5 Checking the Consistency of Allocators + +The linker checks the consistency of load and run allocations specified for unions, groups, and sections. The following rules are used: + +- Run allocations are only allowed for top-level sections, groups, or unions (sections, groups, or unions that are not nested under any other groups or unions). The linker uses the run address of the top-level structure to compute the run addresses of the components within groups and unions. +- The linker does not accept a load allocation for UNIONs. +- The linker does not accept a load allocation for uninitialized sections. +- In most cases, you must provide a load allocation for an initialized section. However, the linker does not accept a load allocation for an initialized section that is located within a group that already defines a load allocator. +- As a shortcut, you can specify a load allocation for an entire group, to determine the load allocations for every initialized section or subgroup nested within the group. However, a load allocation is accepted for an entire group only if all of the following conditions are true: + - The group is initialized (that is, it has at least one initialized member). + - The group is not nested inside another group that has a load allocator. + - The group does not contain a union containing initialized sections. +- If the group contains a union with initialized sections, it is necessary to specify the load allocation for each initialized section nested within the group. Consider the following example: + +``` +SECTIONS +{ + GROUP: load = SLOW_MEM, run = SLOW_MEM + { + .text1: + UNION: + { + .text2: + .text3: + } + } +} +``` + +The load allocator given for the group does not uniquely specify the load allocation for the elements within the union: .text2 and .text3. In this case, the linker issues a diagnostic message to request that these load allocations be specified explicitly. + +#### 8.5.7.6 Naming UNIONs and GROUPs + +You can give a name to a UNION or GROUP by entering the name in parentheses after the declaration. For example: + +``` +GROUP(BSS_SYSMEM_STACK_GROUP) +{ + .bss :{} + .sysmem :{} + .stack :{} +} load=D_MEM, run=D_MEM +``` + +The name you defined is used in diagnostics for easy identification of the problem LCF area. For example: + +``` +warning: LOAD placement ignored for "BSS_SYSMEM_STACK_GROUP": object is uninitialized + UNION(TEXT_CINIT_UNION) + { + .const :{}load=D_MEM, table(table1) + .pinit :{}load=D_MEM, table(table1) + }run=P_MEM +warning:table(table1) operator ignored: table(table1) has already been applied to a section +in the "UNION(TEXT_CINIT_UNION)" in which ".pinit" is a descendant +``` + +### 8.5.8 Special Section Types (DSECT, COPY, NOLOAD, and NOINIT) + +You can assign the following special types to output sections: DSECT, COPY, NOLOAD, and NOINIT. These types affect the way that the program is treated when it is linked and loaded. You can assign a type to a section by placing the type after the section definition. For example: + +``` +SECTIONS + { + sec1: load = 0x00002000, type = DSECT {f1.obj} + sec2: load = 0x00004000, type = COPY {f2.obj} + sec3: load = 0x00006000, type = NOLOAD {f3.obj} + sec4: load = 0x00008000, type = NOINIT {f4.obj} + } +``` + +- The DSECT type creates a dummy section with the following characteristics: + - It is not included in the output section memory allocation. It takes up no memory and is not included in the memory map listing. + - It can overlay other output sections, other DSECTs, and unconfigured memory. + - Global symbols defined in a dummy section are relocated normally. They appear in the output module's symbol table with the same value they would have if the DSECT had actually been loaded. These symbols can be referenced by other input sections. + - Undefined external symbols found in a DSECT cause specified archive libraries to be searched. + - The section's contents, relocation information, and line number information are not placed in the output module. + +In the preceding example, none of the sections from f1.obj are allocated, but all the symbols are relocated as though the sections were linked at address 0x2000. The other sections can refer to any of the global symbols in sec1. + +- A COPY section is similar to a DSECT section, except that its contents and associated information are written to the output module. The .cinit section that contains initialization tables for the PRU C/C++ compiler has this attribute under the run-time initialization model. +- A NOLOAD section differs from a normal output section in one respect: the section's contents, relocation information, and line number information are not placed in the output module. The linker allocates space for the section, and it appears in the memory map listing. +- A NOINIT section is not C auto-initialized by the linker. It is your responsibility to initialize this section as needed. + +### 8.5.9 Configuring Error Correcting Code (ECC) with the Linker + +Error Correcting Codes (ECC) can be generated and placed in separate sections through the linker command file. ECC uses extra bits to allow errors to be detected and/or corrected by a device. To enable ECC generation, you must include **--ecc=on** as a linker option on the command line. By default ECC generation is off, even if the ECC directive and ECC specifiers are used in the linker command file. This allows you to fully configure ECC in the linker command file while still being able to quickly turn the code generation on and off via the command line. + +The ECC support provided by the linker is compatible with the ECC support in TI Flash memory on various TI devices. TI Flash memory uses a modified Hamming(72,64) code, which uses 8 parity bits for every 64 bits. Check the documentation for your Flash memory to see if ECC is supported. (ECC for readwrite memory is handled completely in hardware at run time.) + +You can control the details of ECC generation using the ECC specifier in the memory map \(Section 8.5.9.1) and the ECC directive (Section 8.5.9.2). + +See Section 8.4.11 for command-line options that introduce bit errors into code that has a corresponding ECC section or into the ECC parity bits themselves. Use these options to test ECC error handling code. + +ECC can be generated during linking. The ECC data is included in the resulting object file, alongside code and data, as a data section located at the appropriate address. No extra ECC generation step is required after compilation, and the ECC can be uploaded to the device along with everything else. + +#### 8.5.9.1 Using the ECC Specifier in the Memory Map + +To generate ECC, add a separate memory range to your memory map to hold ECC data and to indicate which memory range contains the Flash data that corresponds to this ECC data. If you have multiple memory ranges for Flash data, you should add a separate ECC memory range for each Flash data range. + +The definition of an ECC memory range can also provide parameters for how to generate the ECC data. + +The memory map for a device supporting Flash ECC may look something like this: + +``` +MEMORY { + VECTORS : origin=0x00000000 length=0x000020 + FLASH0 : origin=0x00000020 length=0x17FFE0 + FLASH1 : origin=0x00180000 length=0x180000 + STACKS : origin=0x08000000 length=0x000500 + RAM : origin=0x08000500 length=0x03FB00 + ECC_VEC : origin=0xf0400000 length=0x000004 ECC={ input_range=VECTORS } + ECC_FLA0 : origin=0xf0400004 length=0x02FFFC ECC={ input_range=FLASH0 } + ECC_FLA1 : origin=0xf0430000 length=0x030000 ECC={ input_range=FLASH1 } +} +``` + +The specification syntax for ECC memory ranges is as follows: + +``` +MEMORY { + : [ vfill= ] + : ECC = { + input_range = + [ algorithm = ] + [ fill = [ true, false ] ] + } +} +``` + +The "ECC" specifier attached to the ECC memory ranges indicates the data memory range that the ECC range covers. The ECC specifier supports the following parameters: + +input\_range = <*range*> The data memory range covered by this ECC data range. Required. + +algorithm = <*ECC alg name*> The name of an ECC algorithm defined later in the command file using the ECC directive. Optional if only one algorithm is defined. (See Section 8.5.9.2.) + +fill = true | false Whether to generate ECC data for holes in the initialized data of the input range. The default is "true". Using fill=false produces behavior similar to the nowECC tool. The input range can be filled normally or using a virtual fill (see Section 8.5.9.3). + +#### 8.5.9.2 Using the ECC Directive + +In addition to specifying ECC memory ranges in the memory map, the linker command file must specify parameters for the algorithm that generates ECC data. You might need multiple ECC algorithm specifications if you have multiple Flash devices. + +Each TI device supporting Flash ECC has exactly one set of valid values for these parameters. The linker command files provided with Code Composer Studio include the ECC parameters necessary for ECC support on the Flash memory accessible by the device. Documentation is provided here for completeness. + +You specify algorithm parameters with the top-level ECC directive in the linker command file. The specification syntax is as follows: + +``` +ECC { + : parity_mask = <8-bit integer> + mirroring = [ F021, F035 ] + address_mask = <32-bit mask> +} +For example: +MEMORY { + FLASH0 : origin=0x00000020 length=0x17FFE0 + ECC_FLA0 : origin=0xf0400004 length=0x02FFFC ECC={ input_range=FLASH0 algorithm=F021 } +} +ECC { F021 : parity_mask = 0xfc + mirroring = F021 } +``` + +This ECC directive accepts the following attributes: + +| algorithm_name | Specify the name you would like to use for referencing the algorithm. | +|---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| address_mask = <32-bit
mask> | This mask determines which bits of the address of each 64-bit piece of
memory are used in the calculation of the ECC byte for that memory.
Default is 0xffffffff, so that all bits of the address are used. (Note that the
ECC algorithm itself ignores the lowest bits, which are always zero for a
correctly-aligned input block.) | +| parity_mask = <8-bit mask> | This mask determines which ECC bits encode even parity and which bits
encode odd parity. Default is 0, meaning that all bits encode even parity. | +| mirroring = F021 F035 | This setting determines the order of the ECC bytes and their duplication
pattern for redundancy. Default is F021. | + +#### 8.5.9.3 Using the VFILL Specifier in the Memory Map + +Normally, specifying a fill value for a MEMORY range creates initialized data sections to cover any previously uninitialized areas of memory. To generate ECC data for an entire memory range, the linker either needs to have initialized data in the entire range, or needs to know what value uninitialized memory areas will have at run time. + +In cases where you want to generate ECC for an entire memory range, but do not want to initialize the entire range by specifying a fill value, you can use the "vfill" specifier instead of a "fill" specifier to virtually fill the range: + +``` +MEMORY { + FLASH : origin=0x0000 length=0x4000 vfill=0xffffffff +} +``` + +The vfill specifier is functionally equivalent to omitting a fill specifier, except that it allows ECC data to be generated for areas of the input memory range that remain uninitialized. This has the benefit of reducing the size of the resulting object file. + +The vfill specifier has no effect other than in ECC data generation. It cannot be specified along with a fill specifier, since that would introduce ambiguity. + +If fill is specified in the ECC specifier, but vfill is not specified, vfill defaults to 0xff. + +### 8.5.10 Assigning Symbols at Link Time + +Linker assignment statements allow you to define external (global) symbols and assign values to them at link time. You can use this feature to initialize a variable or pointer to an allocation-dependent value. See Section 8.6.1 for information about referring to linker symbols in C/C++ code. + +#### 8.5.10.1 Syntax of Assignment Statements + +The syntax of assignment statements in the linker is similar to that of assignment statements in the C language: + +``` +symbol = expression; assigns the value of expression to symbol +symbol + = expression; adds the value of expression to symbol +symbol - = expression; subtracts the value of expression from symbol +symbol * = expression; multiplies symbol by expression +symbol / = expression; divides symbol by expression +``` + +The symbol should be defined externally. If it is not, the linker defines a new symbol and enters it into the symbol table. The expression must follow the rules defined in Section 8.5.10.3. Assignment statements *must* terminate with a semicolon. + +The linker processes assignment statements *after* it allocates all the output sections. Therefore, if an expression contains a symbol, the address used for that symbol reflects the symbol's address in the executable output file. + +For example, suppose a program reads data from one of two tables identified by two external symbols, Table1 and Table2. The program uses the symbol cur\_tab as the address of the current table. The cur\_tab symbol must point to either Table1 or Table2. You could accomplish this in the assembly code, but you would need to reassemble the program to change tables. Instead, you can use a linker assignment statement to assign cur\_tab at link time: + +``` +prog.obj /* Input file */ +cur_tab = Table1; /* Assign cur_tab to one of the tables */ +``` + +#### 8.5.10.2 Assigning the SPC to a Symbol + +A special symbol, denoted by a dot (.), represents the current value of the section program counter (SPC) during allocation. The SPC keeps track of the current location within a section. The linker's . symbol is analogous to the assembler's \$ symbol. The . symbol can be used only in assignment statements within a SECTIONS directive because . is meaningful only during allocation and SECTIONS controls the allocation process. (See Section 8.5.5.) + +The . symbol refers to the current run address, not the current load address, of the section. + +For example, suppose a program needs to know the address of the beginning of the .data section. By using the .global directive (see Identify Global Symbols), you can create an external undefined variable called Dstart in the program. Then, assign the value of . to Dstart: + +``` +SECTIONS +{ + .text: {} + .data: {Dstart = .;} + .bss : {} +} +``` + +This defines Dstart to be the first linked address of the .data section. (Dstart is assigned *before* .data is allocated.) The linker relocates all references to Dstart. + +A special type of assignment assigns a value to the . symbol. This adjusts the SPC within an output section and creates a hole between two input sections. Any value assigned to . to create a hole is relative to the beginning of the section, not to the address actually represented by the . symbol. Holes and assignments to . are described in Section 8.5.11. + +#### 8.5.10.3 Assignment Expressions + +These rules apply to linker expressions: + +- Expressions can contain global symbols, constants, and the C language operators listed in Table 8-11. + +- All numbers are treated as long (32-bit) integers. +- Constants are identified by the linker in the same way as by the assembler. That is, numbers are recognized as decimal unless they have a suffix (H or h for hexadecimal and Q or q for octal). C language prefixes are also recognized (0 for octal and 0x for hex). Hexadecimal constants must begin with a digit. No binary constants are allowed. +- Symbols within an expression have only the value of the symbol's *address*. No type-checking is performed. +- Linker expressions can be absolute or relocatable. If an expression contains *any* relocatable symbols (and 0 or more constants or absolute symbols), it is relocatable. Otherwise, the expression is absolute. If a symbol is assigned the value of a relocatable expression, it is relocatable; if it is assigned the value of an absolute expression, it is absolute. + +The linker supports the C language operators listed in Table 8-11 in order of precedence. Operators in the same group have the same precedence. Besides the operators listed in Table 8-11, the linker also has an align operator that allows a symbol to be aligned on an n-byte boundary within an output section (n is a power of 2). For example, the following expression aligns the SPC within the current section on the next 16-byte boundary. Because the align operator is a function of the current SPC, it can be used only in the same context as . —that is, within a SECTIONS directive. + +``` +. = align(16); +``` + +**Table 8-11. Groups of Operators Used in Expressions (Precedence)** + +| | Group 1 (Highest Precedence) | | Group 6 | | | +|-----------------------------------|------------------------------------------------------------------------------------------------------------|-------------------------------|--------------------------------------------------------|------------------------------------------------------------------------------|--------------------------------------------------| +| !
~
- | Logical NOT
Bitwise NOT
Negation | & | | Bitwise AND | | +| | Group 2 | | Group 7 | | | +| *
/
% | Multiplication
Division
Modulus | \| | Bitwise OR | | | +| | Group 3 | Group 8 | | | | +| +
- | Addition
Subtraction | && | | Logical AND | | +| | Group 4 | Group 9 | | | | +| >>
<< | Arithmetic right shift
Arithmetic left shift | \|\| | Logical OR | | | +| | Group 5 | Group 10 (Lowest Precedence) | | | | +| ==
! =
>
<
< =
> = | Equal to
Not equal to
Greater than
Less than
Less than or equal to
Greater than or equal to | =
+ =
- =
* =
/ = | Assignment
A + = B
A - = B
A * = B
A / = B | is equivalent to
is equivalent to
is equivalent to
is equivalent to | A = A + B
A = A - B
A = A * B
A = A / B | + +#### 8.5.10.4 Symbols Automatically Defined by the Linker + +The linker automatically defines the following symbols for C/C++ support when the --ram\_model or --rom\_model option is used. + +| __TI_STACK_END | is assigned the end of the .stack size. | +|------------------|-------------------------------------------------| +| __TI_STACK_SIZE | is assigned the size of the .stack section for. | +| __TI_SYSMEM_SIZE | is assigned the size of the .sysmem section. | + +These linker-defined symbols can be accessed in any assembly language module if they are declared with a .global directive (see Identify Global Symbols). + +See Section 8.6.1 for information about referring to linker symbols in C/C++ code. + +#### 8.5.10.5 Why the Dot Operator Does Not Always Work + +The dot operator (.) is used to define symbols at link-time with a particular address inside of an output section. It is interpreted like a PC. Whatever the current offset within the current section is, that is the value associated with the dot. Consider an output section specification within a SECTIONS directive: + +``` +outsect: +{ + s1.obj(.text) + end_of_s1 = .; + start_of_s2 = .; + s2.obj(.text) + end_of_s2 = .; +} +``` + +This statement creates three symbols: + +- end\_of\_s1—the end address of .text in s1.obj +- start\_of\_s2—the start address of .text in s2.obj +- end\_of\_s2—the end address of .text in s2.obj + +Suppose there is padding between s1.obj and s2.obj created as a result of alignment. Then start\_of\_s2 is not really the start address of the .text section in s2.obj, but it is the address before the padding needed to align the .text section in s2.obj. This is due to the linker's interpretation of the dot operator as the current PC. It is also true because the dot operator is evaluated independently of the input sections around it. + +Another potential problem in the above example is that end\_of\_s2 may not account for any padding that was required at the end of the output section. You cannot reliably use end\_of\_s2 as the end address of the output section. One way to get around this problem is to create a dummy section immediately after the output section in question. For example: + +``` +GROUP +{ + outsect: + { + start_of_outsect = .; + ... + } + dummy: { size_of_outsect = . - start_of_outsect; } +} +``` + +#### 8.5.10.6 Address and Dimension Operators + +Six operators allow you to define symbols for load-time and run-time addresses and sizes: + +| LOAD_START( sym )
START( sym ) | Defines sym with the load-time start address of related allocation unit | +|-----------------------------------|-------------------------------------------------------------------------| +| LOAD_END( sym )
END( sym ) | Defines sym with the load-time end address of related allocation unit | +| LOAD_SIZE( sym )
SIZE( sym ) | Defines sym with the load-time size of related allocation unit | +| RUN_START( sym ) | Defines sym with the run-time start address of related allocation unit | +| RUN_END( sym ) | Defines sym with the run-time end address of related allocation unit | +| RUN_SIZE(sym ) | Defines sym with the run-time size of related allocation unit | + +#### Linker Command File Operator Equivalencies -- + +**NOTE:** LOAD\_START() and START() are equivalent, as are LOAD\_END()/END() and LOAD\_SIZE()/SIZE(). The LOAD names are recommended for clarity. + +These address and dimension operators can be associated with several different kinds of allocation units, including input items, output sections, GROUPs, and UNIONs. The following sections provide some examples of how the operators can be used in each case. + +These symbols defined by the linker can be accessed at runtime using the \_symval operator, which is essentially a cast operation. For example, suppose your linker command file contains the following: + +``` +.text: RUN_START(text_run_start), RUN_SIZE(text_run_size) { *(.text) } +``` + +Your C program can access these symbols as follows: + +``` +extern char text_run_start, text_run_size; +printf(".text load start is %lx\n", _symval(&text_run_start)); +printf(".text load size is %lx\n", _symval(&text_run_size)); +``` + +See Section 8.6.1 for more information about referring to linker symbols in C/C++ code. + +#### 8.5.10.6.1 Input Items + +Consider an output section specification within a SECTIONS directive: + +``` +outsect: +{ + s1.obj(.text) + end_of_s1 = .; + start_of_s2 = .; + s2.obj(.text) + end_of_s2 = .; +} +``` + +This can be rewritten using the START and END operators as follows: + +``` +outsect: +{ + s1.obj(.text) { END(end_of_s1) } + s2.obj(.text) { START(start_of_s2), END(end_of_s2) } +} +``` + +The values of end\_of\_s1 and end\_of\_s2 will be the same as if you had used the dot operator in the original example, but start\_of\_s2 would be defined after any necessary padding that needs to be added between the two .text sections. Remember that the dot operator would cause start\_of\_s2 to be defined before any necessary padding is inserted between the two input sections. + +The syntax for using these operators in association with input sections calls for braces { } to enclose the operator list. The operators in the list are applied to the input item that occurs immediately before the list. + +#### 8.5.10.6.2 Output Section + +The START, END, and SIZE operators can also be associated with an output section. Here is an example: + +``` +outsect: START(start_of_outsect), SIZE(size_of_outsect) +{ + +} +``` + +In this case, the SIZE operator defines size\_of\_outsect to incorporate any padding that is required in the output section to conform to any alignment requirements that are imposed. + +The syntax for specifying the operators with an output section does not require braces to enclose the operator list. The operator list is simply included as part of the allocation specification for an output section. + +#### 8.5.10.6.3 GROUPs + +Here is another use of the START and SIZE operators in the context of a GROUP specification: + +``` +GROUP +{ + outsect1: { ... } + outsect2: { ... } +} load = ROM, run = RAM, START(group_start), SIZE(group_size); +``` + +This can be useful if the whole GROUP is to be loaded in one location and run in another. The copying code can use group\_start and group\_size as parameters for where to copy from and how much is to be copied. + +#### 8.5.10.6.4 UNIONs + +The RUN\_SIZE and LOAD\_SIZE operators provide a mechanism to distinguish between the size of a UNION's load space and the size of the space where its constituents are going to be copied before they are run. Here is an example: + +``` +UNION: run = RAM, LOAD_START(union_load_addr), + LOAD_SIZE(union_ld_sz), RUN_SIZE(union_run_sz) +{ + .text1: load = ROM, SIZE(text1_size) { f1.obj(.text) } + .text2: load = ROM, SIZE(text2_size) { f2.obj(.text) } +} +``` + +Here union\_ld\_sz is going to be equal to the sum of the sizes of all output sections placed in the union. The union\_run\_sz value is equivalent to the largest output section in the union. Both of these symbols incorporate any padding due to blocking or alignment requirements. + +### 8.5.11 Creating and Filling Holes + +The linker provides you with the ability to create areas *within output sections* that have nothing linked into them. These areas are called *holes*. In special cases, uninitialized sections can also be treated as holes. This section describes how the linker handles holes and how you can fill holes (and uninitialized sections) with values. + +#### 8.5.11.1 Initialized and Uninitialized Sections + +There are two rules to remember about the contents of output sections. An output section contains either: + +- Raw data for the *entire* section +- *No* raw data + +A section that has raw data is referred to as *initialized*. This means that the object file contains the actual memory image contents of the section. When the section is loaded, this image is loaded into memory at the section's specified starting address. The .text and .data sections *always* have raw data if anything was assembled into them. Named sections defined with the .sect assembler directive also have raw data. + +By default, the .bss section (see Reserve Space in the .bss Section) and sections defined with the .usect directive (see Reserve Uninitialized Space) have no raw data (they are *uninitialized*). They occupy space in the memory map but have no actual contents. Uninitialized sections typically reserve space in fast external memory for variables. In the object file, an uninitialized section has a normal section header and can have symbols defined in it; no memory image, however, is stored in the section. + +#### 8.5.11.2 Creating Holes + +You can create a hole in an initialized output section. A hole is created when you force the linker to leave extra space between input sections within an output section. When such a hole is created, *the linker must supply raw data for the hole.* + +Holes can be created only *within* output sections. Space can exist *between* output sections, but such space is not a hole. To fill the space between output sections, see Section 8.5.4.2. + +To create a hole in an output section, you must use a special type of linker assignment statement within an output section definition. The assignment statement modifies the SPC (denoted by .) by adding to it, assigning a greater value to it, or aligning it on an address boundary. The operators, expressions, and syntaxes of assignment statements are described in Section 8.5.10. + +The following example uses assignment statements to create holes in output sections: + +``` +SECTIONS +{ + outsect: + { + file1.obj(.text) + . += 0x0100 /* Create a hole with size 0x0100 */ + file2.obj(.text) + . = align(16); /* Create a hole to align the SPC */ + file3.obj(.text) + } +} +``` + +The output section outsect is built as follows: + +1. The .text section from file1.obj is linked in. +2. The linker creates a 256-byte hole. +3. The .text section from file2.obj is linked in after the hole. +4. The linker creates another hole by aligning the SPC on a 16-byte boundary. +5. Finally, the .text section from file3.obj is linked in. + +All values assigned to the . symbol within a section refer to the *relative address within the section.* The linker handles assignments to the . symbol as if the section started at address 0 (even if you have specified a binding address). Consider the statement . = align(16) in the example. This statement effectively aligns the file3.obj .text section to start on a 16-byte boundary within outsect. If outsect is ultimately allocated to start on an address that is not aligned, the file3.obj .text section will not be aligned either. + +The . symbol refers to the current run address, not the current load address, of the section. + +Expressions that decrement the . symbol are illegal. For example, it is invalid to use the -= operator in an assignment to the . symbol. The most common operators used in assignments to the . symbol are += and align. + +If an output section contains all input sections of a certain type (such as .text), you can use the following statements to create a hole at the beginning or end of the output section. + +``` +.text: { .+= 0x0100; } /* Hole at the beginning */ +.data: { *(.data) + . += 0x0100; } /* Hole at the end */ +``` + +Another way to create a hole in an output section is to combine an uninitialized section with an initialized section to form a single output section. *In this case, the linker treats the uninitialized section as a hole and supplies data for it.* The following example illustrates this method: + +``` +SECTIONS +{ + outsect: + { + file1.obj(.text) + file1.obj(.bss) /* This becomes a hole */ + } +} +``` + +Because the .text section has raw data, all of outsect must also contain raw data. Therefore, the uninitialized .bss section becomes a hole. + +Uninitialized sections become holes only when they are combined with initialized sections. If several uninitialized sections are linked together, the resulting output section is also uninitialized. + +#### 8.5.11.3 Filling Holes + +When a hole exists in an initialized output section, the linker must supply raw data to fill it. The linker fills holes with a 32-bit fill value that is replicated through memory until it fills the hole. The linker determines the fill value as follows: + +1. If the hole is formed by combining an uninitialized section with an initialized section, you can specify a fill value for the uninitialized section. Follow the section name with an = sign and a 32-bit constant. For example: + +``` +SECTIONS +{ outsect: + { + file1.obj(.text) + file2.obj(.bss)= 0xFF00FF00 /* Fill this hole with 0xFF00FF00 */ + } +} +``` + +2. You can also specify a fill value for all the holes in an output section by supplying the fill value after the section definition: + +``` +SECTIONS +{ outsect:fill = 0xFF00FF00 /* Fills holes with 0xFF00FF00 */ + { + . += 0x0010; /* This creates a hole */ + file1.obj(.text) + file1.obj(.bss) /* This creates another hole */ + } +} +``` + +3. If you do not specify an initialization value for a hole, the linker fills the hole with the value specified with the --fill\_value option (see Section 8.4.13). For example, suppose the command file link.cmd contains the following SECTIONS directive: + +``` +SECTIONS { .text: { .= 0x0100; } /* Create a 100 word hole */ } +``` + +Now invoke the linker with the --fill\_value option: + +``` +clpru --run_linker --fill_value=0xFFFFFFFF link.cmd +``` + +This fills the hole with 0xFFFFFFFF. + +4. If you do not invoke the linker with the --fill\_value option or otherwise specify a fill value, the linker fills holes with 0s. + +Whenever a hole is created and filled in an initialized output section, the hole is identified in the link map along with the value the linker uses to fill it. + +#### 8.5.11.4 Explicit Initialization of Uninitialized Sections + +You can force the linker to initialize an uninitialized section by specifying an explicit fill value for it in the SECTIONS directive. This causes the entire section to have raw data (the fill value). For example: + +``` +SECTIONS +{ + .bss: fill = 0x12341234 /* Fills .bss with 0x12341234 */ +} +``` + +#### Filling Sections + +**NOTE:** Because filling a section (even with 0s) causes raw data to be generated for the entire section in the output file, your output file will be very large if you specify fill values for large sections or holes. + +## 8.6 Linker Symbols + +This section provides information about using and resolving linker symbols. + +### 8.6.1 Using Linker Symbols in C/C++ Applications + +Linker symbols have a name and a value. The value is a 32-bit unsigned integer, even if it represents a pointer value on a target that has pointers smaller than 32 bits. + +The most common kind of symbol is generated by the compiler for each function and variable. The value represents the target address where that function or variable is located. When you refer to the symbol by name in the linker command file or in an assembly file, you get that 32-bit integer value. + +However, in C and C++ names mean something different. If you have a variable named x that contains the value Y, and you use the name "x" in your C program, you are actually referring to the contents of variable x. If "x" is used on the right-hand side of an expression, the compiler fetches the value Y. To realize this variable, the compiler generates a linker symbol named x with the value &x. Even though the C/C++ variable and the linker symbol have the same name, they don't represent the same thing. In C, x is a variable name with the address &x and content Y. For linker symbols, x is an address, and that address contains the value Y. + +Because of this difference, there are some tricks to referring to linker symbols in C code. The basic technique is to cause the compiler to creating a "fake" C variable or function and take its address. The details differ depending on the type of linker symbol. + +**Linker symbols that represent a function address:** In C code, declare the function as an extern function. Then, refer to the value of the linker symbol using the same name. This works because function pointers "decay" to their address value when used without adornment. For example: + +``` +extern void _c_int00(void); +printf("_c_int00 %lx\n", (unsigned long)&_c_int00); +``` + +Suppose your linker command file defines the following linker symbol: + +``` +func_sym=printf+100; +``` + +Your C application can refer to this symbol as follows: + +``` +extern void func_sym(void); +printf("func_sym %lx\n", _symval(&func_sym)); /* these two are equivalent */ +printf("func_sym %lx\n", (unsigned long)&func_sym); +``` + +**Linker symbols that represent a data address:** In C code, declare the variable as an extern variable. Then, refer to the value of the linker symbol using the & operator. Because the variable is at a valid data address, we know that a data pointer can represent the value. + +Suppose your linker command file defines the following linker symbols: + +``` +data_sym=.data+100; +xyz=12345 +``` + +Your C application can refer to these symbols as follows: + +``` +extern char data_sym; +extern int xyz; +printf("data_sym %lx\n", _symval(&data_sym)); /* these two are equivalent */ +printf("data_sym %p\n", &data_sym); +myvar = &xyz; +``` + +**Linker symbols for an arbitrary address:** In C code, declare this as an extern symbol. The type does not matter. If you are using GCC extensions, declare it as "extern void". If you are not using GCC extensions, declare it as "extern char". Then, refer to the value of the linker symbol mySymbol as \_symval(&mySymbol). You must use the \_symval operator, which is equivalent to a cast, because the 32-bit value of the linker symbol could be wider than a data pointer. The compiler treats \_symval(&mySymbol) in a special way that can represent all 32 bits, even when pointers are 16 bits. Targets that have 32-bit pointers can usually use &mySymbol instead of the \_symval operator. However, the portable way to access such linker symbols across TI targets is to use \_symval(&mySymbol). + +Suppose your linker command file defines the following linker symbol: + +``` +abs_sym=0x12345678; +``` + +Your C application can refer to this symbol as follows: + +``` +extern char abs_sym; +printf("abs_sym %lx\n", _symval(&abs_sym)); +``` + +### 8.6.2 Declaring Weak Symbols + +In a linker command file, an assignment expression outside a MEMORY or SECTIONS directive can be used to define a linker-defined symbol. To define a weak symbol in a linker command file, use the "weak" operator in an assignment expression to designate that the symbol as eligible for removal from the output file's symbol table if it is not referenced. For example, you can define "ext\_addr\_sym" as follows: + +``` +weak(ext_addr_sym) = 0x12345678; +``` + +When the linker command file is used to perform the final link, then "ext\_addr\_sym" is presented to the linker as a weak absolute symbol; it will not be included in the resulting output file if the symbol is not referenced. + +See Section 2.6.2 for details about how weak symbols are handled by the linker. + +### 8.6.3 Resolving Symbols with Object Libraries + +An object library is a partitioned archive file that contains object files as members. Usually, a group of related modules are grouped together into a library. When you specify an object library as linker input, the linker includes any members of the library that define existing unresolved symbol references. You can use the archiver to build and maintain libraries. Section 7.1 contains more information about the archiver. + +Using object libraries can reduce link time and the size of the executable module. Normally, if an object file that contains a function is specified at link time, the file is linked whether the function is used or not; however, if that same function is placed in an archive library, the file is included only if the function is referenced. + +The order in which libraries are specified is important, because the linker includes only those members that resolve symbols that are undefined at the time the library is searched. The same library can be specified as often as necessary; it is searched each time it is included. Alternatively, you can use the --reread\_libs option to reread libraries until no more references can be resolved (see Section 8.4.16.3). A library has a table that lists all external symbols defined in the library; the linker searches through the table until it determines that it cannot use the library to resolve any more references. + +The following examples link several files and libraries, using these assumptions: + +- Input files f1.obj and f2.obj both reference an external function named *clrscr*. +- Input file f1.obj references the symbol *origin*. +- Input file f2.obj references the symbol *fillclr*. +- Member 0 of library libc.lib contains a definition of *origin*. +- Member 3 of library liba.lib contains a definition of *fillclr*. +- Member 1 of both libraries defines *clrscr*. + +If you enter: + +**clpru --run\_linker f1.obj f2.obj liba.lib libc.lib** + +then: + +- Member 1 of liba.lib satisfies the f1.obj and f2.obj references to *clrscr* because the library is searched and the definition of *clrscr* is found. +- Member 0 of libc.lib satisfies the reference to *origin*. +- Member 3 of liba.lib satisfies the reference to *fillclr*. + +If, however, you enter: + +``` +clpru --run_linker f1.obj f2.obj libc.lib liba.lib +``` + +then the references to *clrscr* are satisfied by member 1 of libc.lib. + +If none of the linked files reference symbols defined in a library, you can use the --undef\_sym option to force the linker to include a library member. (See Section 8.4.32.) The next example creates an undefined symbol rout1 in the linker's global symbol table: + +``` +clpru --run_linker --undef_sym=rout1 libc.lib +``` + +If any member of libc.lib defines rout1, the linker includes that member. + +Library members are allocated according to the SECTIONS directive default allocation algorithm; see Section 8.5.5. + +Section 8.4.16 describes methods for specifying directories that contain object libraries. + +## 8.7 Default Placement Algorithm + +The MEMORY and SECTIONS directives provide flexible methods for building, combining, and allocating sections. However, any memory locations or sections you choose *not* to specify must still be handled by the linker. The linker uses algorithms to build and allocate sections in coordination with any specifications you do supply. + +If you do not use the MEMORY and SECTIONS directives, the linker allocates output sections as though the memory map and section definitions were as shown in Example 8-14 were specified. + +### Example 8-14. Default Allocation for PRU Devices + +``` +{ + RAM : origin = 0x00000000, length = 0xFFFFFFFF +} +SECTIONS +{ + .text : ALIGN(4) {} > RAM + .const: ALIGN(4) {} > RAM + .data : ALIGN(4) {} > RAM + .bss : ALIGN(4) {} > RAM + .cinit: ALIGN(4) {} > RAM /* -c option only */ + .pinit: ALIGN(4) {} > RAM /* -c option only */ +} +``` + +Also see Section 2.5.1 for information about default memory allocation. + +All .text input sections are concatenated to form a .text output section in the executable output file, and all .data input sections are combined to form a .data output section. + +If you use a SECTIONS directive, the linker performs *no part* of this default allocation. Instead, allocation is performed according to the rules specified by the SECTIONS directive and the general algorithm described next in Section 8.7.1. + +### 8.7.1 How the Allocation Algorithm Creates Output Sections + +An output section can be formed in one of two ways: + +- **Method 1** As the result of a SECTIONS directive definition +- **Method 2** By combining input sections with the same name into an output section that is not defined in a SECTIONS directive + +If an output section is formed as a result of a SECTIONS directive, this definition completely determines the section's contents. (See Section 8.5.5 for examples of how to define an output section's content.) + +If an output section is formed by combining input sections not specified by a SECTIONS directive, the linker combines all such input sections that have the same name into an output section with that name. For example, suppose the files f1.obj and f2.obj both contain named sections called Vectors and that the SECTIONS directive does not define an output section for them. The linker combines the two Vectors sections from the input files into a single output section named Vectors, allocates it into memory, and includes it in the output file. + +By default, the linker does not display a message when it creates an output section that is not defined in the SECTIONS directive. You can use the --warn\_sections linker option (see Section 8.4.33) to cause the linker to display a message when it creates a new output section. + +After the linker determines the composition of all output sections, it must allocate them into configured memory. The MEMORY directive specifies which portions of memory are configured. If there is no MEMORY directive, the linker uses the default configuration as shown in Example 8-14. (See Section 8.5.4 for more information on configuring memory.) + +### 8.7.2 Reducing Memory Fragmentation + +The linker's allocation algorithm attempts to minimize memory fragmentation. This allows memory to be used more efficiently and increases the probability that your program will fit into memory. The algorithm comprises these steps: + +1. Each output section for which you supply a specific binding address is placed in memory at that address. +2. Each output section that is included in a specific, named memory range or that has memory attribute restrictions is allocated. Each output section is placed into the first available space within the named area, considering alignment where necessary. +3. Any remaining sections are allocated in the order in which they are defined. Sections not defined in a SECTIONS directive are allocated in the order in which they are encountered. Each output section is placed into the first available memory space, considering alignment where necessary. + +If you want to control the order in which code and data are placed in memory, see the FAQ [topic](http://processors.wiki.ti.com/index.php/Code_Generation_Tools_FAQ#Q:_How_can_I_get_the_linker_to_place_a_piece_of_code_or_data_so_that_it_comes_before_all_the_rest.3F) on section [placement.](http://processors.wiki.ti.com/index.php/Code_Generation_Tools_FAQ#Q:_How_can_I_get_the_linker_to_place_a_piece_of_code_or_data_so_that_it_comes_before_all_the_rest.3F) + +## 8.8 Linker-Generated Copy Tables + +The linker supports extensions to the linker command file syntax that enable the following: + +- Make it easier for you to copy objects from load-space to run-space at boot time +- Make it easier for you to manage memory overlays at run time +- Allow you to split GROUPs and output sections that have separate load and run addresses + +### 8.8.1 Using Copy Tables for Boot Loading + +In some embedded applications, there is a need to copy or download code and/or data from one location to another at boot time before the application actually begins its main execution thread. For example, an application may have its code and/or data in FLASH memory and need to copy it into on-chip memory before the application begins execution. + +One way to develop such an application is to create a copy table in assembly code that contains three elements for each block of code or data that needs to be moved from FLASH to on-chip memory at boot time: + +- The load address +- The run address +- The size + +The process you follow to develop such an application might look like this: + +1. Build the application to produce a .map file that contains the load and run addresses of each section that has a separate load and run placement. +2. Edit the copy table (used by the boot loader) to correct the load and run addresses as well as the size of each block of code or data that needs to be moved at boot time. +3. Build the application again, incorporating the updated copy table. +4. Run the application. + +This process puts a heavy burden on you to maintain the copy table (by hand, no less). Each time a piece of code or data is added or removed from the application, you must repeat the process in order to keep the contents of the copy table up to date. + +### 8.8.2 Using Built-in Link Operators in Copy Tables + +You can avoid some of this maintenance burden by using the LOAD\_START(), RUN\_START(), and SIZE() operators that are already part of the linker command file syntax . For example, instead of building the application to generate a .map file, the linker command file can be annotated: + +``` +SECTIONS +{ + .flashcode: { app_tasks.obj(.text) } + load = FLASH, run = PMEM, + LOAD_START(_flash_code_ld_start), + RUN_START(_flash_code_rn_start), + SIZE(_flash_code_size) + ... +} +``` + +In this example, the LOAD\_START(), RUN\_START(), and SIZE() operators instruct the linker to create three symbols: + +| Symbol | Description | | +|----------------------|------------------------------------|--| +| _flash_code_ld_start | Load address of .flashcode section | | +| _flash_code_rn_start | Run address of .flashcode section | | +| _flash_code_size | Size of .flashcode section | | + +These symbols can then be referenced from the copy table. The actual data in the copy table will be updated automatically each time the application is linked. This approach removes step 1 of the process described in Section 8.8.1. + +While maintenance of the copy table is reduced markedly, you must still carry the burden of keeping the copy table contents in sync with the symbols that are defined in the linker command file. Ideally, the linker would generate the boot copy table automatically. This would avoid having to build the application twice *and* free you from having to explicitly manage the contents of the boot copy table. + +For more information on the LOAD\_START(), RUN\_START(), and SIZE() operators, see Section 8.5.10.6. + +### 8.8.3 Overlay Management Example + +Consider an application that contains a memory overlay that must be managed at run time. The memory overlay is defined using a UNION in the linker command file as illustrated in Example 8-15: + +## Example 8-15. Using a UNION for Memory Overlay + +``` +SECTIONS +{ + ... + UNION + { + GROUP + { + .task1: { task1.obj(.text) } + .task2: { task2.obj(.text) } + } load = ROM, LOAD_START(_task12_load_start), SIZE(_task12_size) + GROUP + { + .task3: { task3.obj(.text) } + .task4: { task4.obj(.text) } + } load = ROM, LOAD_START(_task34_load_start), SIZE(_task34_size) + } run = RAM, RUN_START(_task_run_start) + ... +} +``` + +The application must manage the contents of the memory overlay at run time. That is, whenever any services from .task1 or .task2 are needed, the application must first ensure that .task1 and .task2 are resident in the memory overlay. Similarly for .task3 and .task4. + +To affect a copy of .task1 and .task2 from ROM to RAM at run time, the application must first gain access to the load address of the tasks (\_task12\_load\_start), the run address (\_task\_run\_start), and the size (\_task12\_size). Then this information is used to perform the actual code copy. + +### 8.8.4 Generating Copy Tables With the table() Operator + +The linker supports extensions to the linker command file syntax that enable you to do the following: + +- Identify any object components that may need to be copied from load space to run space at some point during the run of an application +- Instruct the linker to automatically generate a copy table that contains (at least) the load address, run address, and size of the component that needs to be copied +- Instruct the linker to generate a symbol specified by you that provides the address of a linker-generated copy table. For instance, Example 8-15 can be written as shown in Example 8-16: + +## Example 8-16. Produce Address for Linker Generated Copy Table + +``` +SECTIONS +{ + ... + UNION + { + GROUP + { + .task1: { task1.obj(.text) } + .task2: { task2.obj(.text) } + } load = ROM, table(_task12_copy_table) + GROUP + { + .task3: { task3.obj(.text) } + .task4: { task4.obj(.text) } + } load = ROM, table(_task34_copy_table) + } run = RAM + ... +} +``` + +Using the SECTIONS directive from Example 8-16 in the linker command file, the linker generates two copy tables named: \_task12\_copy\_table and \_task34\_copy\_table. Each copy table provides the load address, run address, and size of the GROUP that is associated with the copy table. This information is accessible from application source code using the linker-generated symbols, \_task12\_copy\_table and \_task34\_copy\_table, which provide the addresses of the two copy tables, respectively. + +Using this method, you need not worry about the creation or maintenance of a copy table. You can reference the address of any copy table generated by the linker in C/C++ or assembly source code, passing that value to a general purpose copy routine, which will process the copy table and affect the actual copy. + +#### 8.8.4.1 The table() Operator + +You can use the table() operator to instruct the linker to produce a copy table. A table() operator can be applied to an output section, a GROUP, or a UNION member. The copy table generated for a particular table() specification can be accessed through a symbol specified by you that is provided as an argument to the table() operator. The linker creates a symbol with this name and assigns it the address of the copy table as the value of the symbol. The copy table can then be accessed from the application using the linker-generated symbol. + +Each table() specification you apply to members of a given UNION must contain a unique name. If a table() operator is applied to a GROUP, then none of that GROUP's members may be marked with a table() specification. The linker detects violations of these rules and reports them as warnings, ignoring each offending use of the table() specification. The linker does not generate a copy table for erroneous table() operator specifications. + +Copy tables can be generated automatically; see Section 8.8.4. + +#### 8.8.4.2 Boot-Time Copy Tables + +The linker supports a special copy table name, BINIT (or binit), that you can use to create a boot-time copy table. This table is handled before the .cinit section is used to initialize variables at startup. For example, the linker command file for the boot-loaded application described in Section 8.8.2 can be rewritten as follows: + +``` +SECTIONS +{ + .flashcode: { app_tasks.obj(.text) } + load = FLASH, run = PMEM, + table(BINIT) + ... +} +``` + +For this example, the linker creates a copy table that can be accessed through a special linker-generated symbol, \_\_binit\_\_, which contains the list of all object components that need to be copied from their load location to their run location at boot-time. If a linker command file does not contain any uses of table(BINIT), then the \_\_binit\_\_ symbol is given a value of -1 to indicate that a boot-time copy table does not exist for a particular application. + +You can apply the table(BINIT) specification to an output section, GROUP, or UNION member. If used in the context of a UNION, only one member of the UNION can be designated with table(BINIT). If applied to a GROUP, then none of that GROUP's members may be marked with table(BINIT).The linker detects violations of these rules and reports them as warnings, ignoring each offending use of the table(BINIT) specification. + +#### 8.8.4.3 Using the table() Operator to Manage Object Components + +If you have several pieces of code that need to be managed together, then you can apply the same table() operator to several different object components. In addition, if you want to manage a particular object component in multiple ways, you can apply more than one table() operator to it. Consider the linker command file excerpt in Example 8-17: + +## Example 8-17. Linker Command File to Manage Object Components + +``` +SECTIONS +{ + UNION + { + .first: { a1.obj(.text), b1.obj(.text), c1.obj(.text) } + load = EMEM, run = PMEM, table(BINIT), table(_first_ctbl) + .second: { a2.obj(.text), b2.obj(.text) } + load = EMEM, run = PMEM, table(_second_ctbl) + } + .extra: load = EMEM, run = PMEM, table(BINIT) + ... +} +``` + +In this example, the output sections .first and .extra are copied from external memory (EMEM) into program memory (PMEM) at boot time while processing the BINIT copy table. After the application has started executing its main thread, it can then manage the contents of the overlay using the two overlay copy tables named: \_first\_ctbl and \_second\_ctbl. + +#### 8.8.4.4 Linker-Generated Copy Table Sections and Symbols + +The linker creates and allocates a separate input section for each copy table that it generates. Each copy table symbol is defined with the address value of the input section that contains the corresponding copy table. + +The linker generates a unique name for each overlay copy table input section. For example, table(\_first\_ctbl) would place the copy table for the .first section into an input section called .ovly:\_first\_ctbl. The linker creates a single input section, .binit, to contain the entire boot-time copy table. + +Example 8-18 illustrates how you can control the placement of the linker-generated copy table sections using the input section names in the linker command file. + +#### Example 8-18. Controlling the Placement of the Linker-Generated Copy Table Sections + +``` +SECTIONS +{ + UNION + { + .first: { a1.obj(.text), b1.obj(.text), c1.obj(.text) } + load = EMEM, run = PMEM, table(BINIT), table(_first_ctbl) + .second: { a2.obj(.text), b2.obj(.text) } + load = EMEM, run = PMEM, table(_second_ctbl) + } + .extra: load = EMEM, run = PMEM, table(BINIT) + ... + .ovly: { } > BMEM + .binit: { } > BMEM +} +``` + +For the linker command file in Example 8-18, the boot-time copy table is generated into a .binit input section, which is collected into the .binit output section, which is mapped to an address in the BMEM memory area. The \_first\_ctbl is generated into the .ovly:\_first\_ctbl input section and the \_second\_ctbl is generated into the .ovly:\_second\_ctbl input section. Since the base names of these input sections match the name of the .ovly output section, the input sections are collected into the .ovly output section, which is then mapped to an address in the BMEM memory area. + +If you do not provide explicit placement instructions for the linker-generated copy table sections, they are allocated according to the linker's default placement algorithm. + +The linker does not allow other types of input sections to be combined with a copy table input section in the same output section. The linker does not allow a copy table section that was created from a partial link session to be used as input to a succeeding link session. + +#### 8.8.4.5 Splitting Object Components and Overlay Management + +It is possible to split sections that have separate load and run placement instructions. The linker can access both the load address and run address of every piece of a split object component. Using the table() operator, you can tell the linker to generate this information into a copy table. The linker gives each piece of the split object component a COPY\_RECORD entry in the copy table object. + +For example, consider an application which has seven tasks. Tasks 1 through 3 are overlaid with tasks 4 through 7 (using a UNION directive). The load placement of all of the tasks is split among four different memory areas (LMEM1, LMEM2, LMEM3, and LMEM4). The overlay is defined as part of memory area PMEM. You must move each set of tasks into the overlay at run time before any services from the set are used. + +You can use table() operators in combination with splitting operators, >>, to create copy tables that have all the information needed to move either group of tasks into the memory overlay as shown in Example 8-19. + +#### Example 8-19. Creating a Copy Table to Access a Split Object Component + +``` +SECTIONS +{ + UNION + { + .task1to3: { *(.task1), *(.task2), *(.task3) } + load >> LMEM1 | LMEM2 | LMEM4, table(_task13_ctbl) + GROUP + { + .task4: { *(.task4) } + .task5: { *(.task5) } + .task6: { *(.task6) } + .task7: { *(.task7) } + } load >> LMEM1 | LMEM3 | LMEM4, table(_task47_ctbl) + } run = PMEM + ... + .ovly: > LMEM4 +} +``` + +Example 8-20 illustrates a possible driver for such an application. + +## Example 8-20. Split Object Component Driver + +``` +#include +extern far COPY_TABLE task13_ctbl; +extern far COPY_TABLE task47_ctbl; +extern void task1(void); +... +extern void task7(void); +main() +{ + ... + copy_in(&task13_ctbl); + task1(); + task2(); + task3(); + ... + copy_in(&task47_ctbl); + task4(); + task5(); + task6(); + task7(); + ... +} +``` + +You must declare a COPY\_TABLE object as *far* to allow the overlay copy table section placement to be independent from the other sections containing data objects (such as .bss). + +The contents of the .task1to3 section are split in the section's load space and contiguous in its run space. The linker-generated copy table, \_task13\_ctbl, contains a separate COPY\_RECORD for each piece of the split section .task1to3. When the address of \_task13\_ctbl is passed to copy\_in(), each piece of .task1to3 is copied from its load location into the run location. + +The contents of the GROUP containing tasks 4 through 7 are also split in load space. The linker performs the GROUP split by applying the split operator to each member of the GROUP in order. The copy table for the GROUP then contains a COPY\_RECORD entry for every piece of every member of the GROUP. These pieces are copied into the memory overlay when the \_task47\_ctbl is processed by copy\_in(). + +The split operator can be applied to an output section, GROUP, or the load placement of a UNION or UNION member. The linker does not permit a split operator to be applied to the run placement of either a UNION or of a UNION member. The linker detects such violations, emits a warning, and ignores the offending split operator usage. + +### 8.8.5 Compression + +When automatically generating copy tables, the linker provides a way to compress the load-space data. This can reduce the read-only memory foot print. This compressed data can be decompressed while copying the data from load space to run space. + +You can specify compression in two ways: + +- The linker command line option --copy\_compression=compression\_kind can be used to apply the specified compression to any output section that has a table() operator applied to it. +- The table() operator accepts an optional compression parameter. The syntax is: + +**table(** *name* **, compression=** *compression\_kind* **)** + +The *compression\_kind* can be one of the following types: + +- **off**. Don't compress the data. +- **rle**. Compress data using Run Length Encoding. +- **lzss**. Compress data using Lempel-Ziv-Storer-Szymanski compression. + +A table() operator without the compression keyword uses the compression kind specified using the command line option --copy\_compression. + +When you choose compression, it is not guaranteed that the linker will compress the load data. The linker compresses load data only when such compression reduces the overall size of the load space. In some cases even if the compression results in smaller load section size the linker does not compress the data if the decompression routine offsets for the savings. + +For example, assume RLE compression reduces the size of section1 by 30 bytes. Also assume the RLE decompression routine takes up 40 bytes in load space. By choosing to compress section1 the load space is increased by 10 bytes. Therefore, the linker will not compress section1. On the other hand, if there is another section (say section2) that can benefit by more than 10 bytes from applying the same compression then both sections can be compressed and the overall load space is reduced. In such cases the linker compresses both the sections. + +You cannot force the linker to compress the data when doing so does not result in savings. + +You cannot compress the decompression routines or any member of a GROUP containing .cinit. + +#### 8.8.5.1 Compressed Copy Table Format + +The copy table format is the same irrespective of the *compression\_kind*. The size field of the copy record is overloaded to support compression. Figure 8-4 illustrates the compressed copy table layout. + +**Figure 8-4. Compressed Copy Table** + +![Figure 8-4: Compressed Copy Table — two-row table structure showing Rec size, Rec cnt, Load address, Run address, and Size fields](_page_226_Figure_21.jpeg) + +**Figure 8-4: Compressed Copy Table.** Diagram of the compressed copy table record layout. The header row contains two fields: "Rec size" and "Rec cnt". The data row contains three fields: "Load address", "Run address", and "Size (0 if load data is compressed)". When Size is non-zero it equals the size of the data to be copied; when Size is 0, the load data is compressed. + +In Figure 8-4, if the size in the copy record is non-zero it represents the size of the data to be copied, and also means that the size of the load data is the same as the run data. When the size is 0, it means that the load data is compressed. + +#### 8.8.5.2 Compressed Section Representation in the Object File + +The linker creates a separate input section to hold the compressed data. Consider the following table() operation in the linker command file. + +``` +SECTIONS +{ + .task1: load = ROM, run = RAM, table(_task1_table) +} +``` + +The output object file has one output section named .task1 which has different load and run addresses. This is possible because the load space and run space have identical data when the section is not compressed. + +Alternatively, consider the following: + +``` +SECTIONS +{ + .task1: load = ROM, run = RAM, table(_task1_table, compression=rle) +} +``` + +If the linker compresses the .task1 section then the load space data and the run space data are different. The linker creates the following two sections: + +- **.task1** : This section is uninitialized. This output section represents the run space image of section task1. +- **.task1.load** : This section is initialized. This output section represents the load space image of the section task1. This section usually is considerably smaller in size than .task1 output section. + +The linker allocates load space for the .task1.load input section in the memory area that was specified for load placement for the .task1 section. There is only a single load section to represent the load placement of .task1 - .task1.load. If the .task1 data had not been compressed, there would be two allocations for the .task1 input section: one for its load placement and another for its run placement. + +#### 8.8.5.3 Compressed Data Layout + +The compressed load data has the following layout: + +| -bit index | Compressed data | +|------------|-----------------| + +The first bits of the load data are the handler index. This handler index is used to index into a handler table to get the address of a handler function that knows how to decode the data that follows. The handler table is a list of 32-bit function pointers as shown in Figure 8-5. + +**Figure 8-5. Handler Table** + +\_TI\_Handler\_Table\_Base: + +![Figure 8-5: Handler Table — box diagram showing 32-bit handler address 1 through 32-bit handler address N](_page_227_Picture_15.jpeg) + +**Figure 8-5: Handler Table.** Diagram of the handler table structure. The table is a contiguous array of 32-bit function pointers bounded by `_TI_Handler_Table_Base` and `_TI_Handler_Table_Limit`. The first entry is labeled "32-bit handler address 1", an ellipsis (...) indicates additional entries, and the last entry is "32-bit handler address N". The handler index from the compressed load data is used to index into this table to obtain the address of the appropriate decompression routine. + +\_TI\_Handler\_Table\_Limit: + +The linker creates a separate output section for the load and run space. For example, if .task1.load is compressed using RLE, the handler index points to an entry in the handler table that has the address of the run-time-support routine \_\_TI\_decompress\_rle(). + +#### 8.8.5.4 Run-Time Decompression + +During run time you call the run-time-support routine copy\_in() to copy the data from load space to run space. The address of the copy table is passed to this routine. First the routine reads the record count. Then it repeats the following steps for each record: + +1. Read load address, run address and size from record. +2. If size is zero go to step 5. +3. Call memcpy passing the run address, load address and size. +4. Go to step 1 if there are more records to read. +5. Read the first from the load address. +6. Read the handler address from (&\_\_TI\_Handler\_Base)[index]. +7. Call the handler and pass load address + 1 and run address. +8. Go to step 1 if there are more records to read. + +The routines to handle the decompression of load data are provided in the run-time-support library. + +#### 8.8.5.5 Compression Algorithms + +The following subsections provide information about decompression algorithms for the RLE and LZSS formats. To see example decompression algorithms, refer to the following functions in the Run-Time Support library: + +- **RLE:** The \_\_TI\_decompress\_rle() function in the copy\_decompress\_rle.c file. +- **LZSS:** The \_\_TI\_decompress\_lzss() function in the copy\_decompress\_lzss.c file. + +##### Run Length Encoding (RLE): + +| -bit index | Initialization data compressed using run length encoding | +|------------|----------------------------------------------------------| + +The data following the -bit index is compressed using run length encoded (RLE) format. PRU uses a simple run length encoding that can be decompressed using the following algorithm: + +1. Read the first , Delimiter (D). +2. Read the next (B). +3. If B != D, copy B to the output buffer and go to step 2. +4. Read the next (L). + a. If L == 0, then length is either a value, or we've reached the end of the data, read next (L). + b. Else if L > 0 and L < 4, copy D to the output buffer L times. Go to step 2. + c. Else, length is -bit value (L). +5. Read the next (C); C is the repeat character. +6. Write C to the output buffer L times; go to step 2. +7. End of processing. + +The PRU run-time support library has a routine \_\_TI\_decompress\_rle() to decompress data compressed using RLE. The first argument to this function is the address pointing to the after the -bit index. The second argument is the run address from the C auto initialization record. + +##### Lempel-Ziv-Storer-Szymanski Compression (LZSS): + +| -bit index | Data compressed using LZSS | +|------------|----------------------------| + +The data following the 8-bit index is compressed using LZSS compression. The PRU run-time-support library has the routine \_\_TI\_decompress\_lzss() to decompress the data compressed using LZSS. The first argument to this function is the address pointing to the after the -bit Index, and the second argument is the run address from the C auto initialization record. + +### 8.8.6 Copy Table Contents + +To use a copy table generated by the linker, you must know the contents of the copy table. This information is included in a run-time-support library header file, cpy\_tbl.h, which contains a C source representation of the copy table data structure that is generated by the linker. + +For each object component that is marked for a copy, the linker creates a COPY\_RECORD object for it. Each COPY\_RECORD contains at least the following information for the object component: + +- The load address +- The run address +- The size + +The linker collects all COPY\_RECORDs that are associated with the same copy table into a COPY\_TABLE object. The COPY\_TABLE object contains the size of a given COPY\_RECORD, the number of COPY\_RECORDs in the table, and the array of COPY\_RECORDs in the table. For instance, in the BINIT example in Section 8.8.4.2, the .first and .extra output sections will each have their own COPY\_RECORD entries in the BINIT copy table. The BINIT copy table will then look like this: + +``` +/******************************************************************************/ +/* Copy Record Data Structure */ +/******************************************************************************/ +typedef struct copy_record +{ + unsigned int load_addr; + unsigned int run_addr; + unsigned int size; +} COPY_RECORD; + +/******************************************************************************/ +/* Copy Table Data Structure */ +/******************************************************************************/ +typedef struct copy_table +{ + unsigned short rec_size; + unsigned short num_recs; + COPY_RECORD recs[1]; +} COPY_TABLE; +``` + +### 8.8.7 General Purpose Copy Routine + +The cpy\_tbl.h file also contains a prototype for a general-purpose copy routine, copy\_in(), which is provided as part of the run-time-support library. The copy\_in() routine takes a single argument: the address of a linker-generated copy table. The routine then processes the copy table data object and performs the copy of each object component specified in the copy table. + +The copy\_in() function definition is provided in the cpy\_tbl.c run-time-support source file shown in Example 8-21. + +#### Example 8-21. Run-Time-Support cpy\_tbl.c File + +``` +/******************************************************************************/ +/* cpy_tbl.c v#### */ +/* Copyright (c) 2014 Texas Instruments Incorporated */ +/* */ +/* General purpose copy routine. Given the address of a linker-generated */ +/* COPY_TABLE data structure, effect the copy of all object components */ +/* that are designated for copy via the corresponding LCF table() operator. */ +/******************************************************************************/ +#include +#include + +typedef void (*handler_fptr)(const unsigned char *in, unsigned char *out) +#define HANDLER_TABLE __TI_Handler_Table_Base +#pragma WEAK(HANDLER_TABLE) +``` + +#### Example 8-21. Run-Time-Support cpy\_tbl.c File (continued) + +``` +extern unsigned short HANDLER_TABLE; + +/******************************************************************************/ +/* COPY_IN() */ +/******************************************************************************/ +void copy_in(COPY_TABLE *tp) +{ + unsigned short i; + for (i = 0; i < tp->num_recs; i++) + { + COPY_RECORD crp = tp->recs[i]; + unsigned char *ld_addr = (unsigned char *)crp.load_addr; + unsigned char *rn_addr = (unsigned char *)crp.run_addr; + if (crp.size) + { + /*-----------------------------------------------------------------*/ + /* Copy record has a non-zero size so the data is not compressed. */ + /* Just copy the data. */ + /*-----------------------------------------------------------------*/ + memcpy(rn_addr, ld_addr, crp.size); + } + else if (HANDLER_TABLE) + { + unsigned char index = *((unsigned char *)ld_addr++); + handler_fptr hndl = (handler_fptr)(&HANDLER_TABLE)[index]; + (*hndl)((const unsigned char *)ld_addr, (unsigned char *)rn_addr); + } + } +} +``` + +#### 8.9 Partial (Incremental) Linking + +An output file that has been linked can be linked again with additional modules. This is known as *partial linking* or *incremental linking*. Partial linking allows you to partition large applications, link each part separately, and then link all the parts together to create the final executable program. + +Follow these guidelines for producing a file that you will relink: + +- The intermediate files produced by the linker *must* have relocation information. Use the --relocatable option when you link the file the first time. (See Section 8.4.3.2.) +- Intermediate files *must* have symbolic information. By default, the linker retains symbolic information in its output. Do not use the --no\_sym\_table option if you plan to relink a file, because --no\_sym\_table strips symbolic information from the output module. (See Section 8.4.22.) +- Intermediate link operations should be concerned only with the formation of output sections and not + with allocation. All allocation, binding, and MEMORY directives should be performed in the final link. + Since the ELF object file format is used, input sections are not combined into output sections during a + partial link unless a matching SECTIONS directive is specified in the link step command file. +- If the intermediate files have global symbols that have the same name as global symbols in other files and you want them to be treated as static (visible only within the intermediate file), you must link the files with the --make\_static option (see Section 8.4.17.1). +- If you are linking C code, do not use --ram\_model or --rom\_model until the final linker. Every time you invoke the linker with the --ram\_model or --rom\_model option, the linker attempts to create an entry point. (See Section 8.4.25 and Section 3.3.2.) + +The following example shows how you can use partial linking: + +**Step 1:** Link the file file1.com; use the --relocatable option to retain relocation information in the output file tempout1.out. + +``` +clpru --run_linker --relocatable --output_file=tempout1 file1.com +file1.com contains: +SECTIONS +{ + ss1: { + f1.obj + f2.obj + . + . + . + fn.obj + } +} +``` + +**Step 2:** Link the file file2.com; use the --relocatable option to retain relocation information in the output file tempout2.out. + +``` +clpru --run_linker --relocatable --output_file=tempout2 file2.com +file2.com contains: +SECTIONS +{ + ss2: { + g1.obj + g2.obj + . + . + . + gn.obj + } +} +``` + +**Step 3:** Link tempout1.out and tempout2.out. + +**clpru --run\_linker --map\_file=final.map --output\_file=final.out tempout1.out tempout2.out** + +## 8.10 Linking C/C++ Code + +The C/C++ compiler produces assembly language source code that can be assembled and linked. For example, a C program consisting of modules prog1, prog2, etc., can be assembled and then linked to produce an executable file called prog.out: + +``` +clpru --run_linker --rom_model -- +output_file prog.out prog1.obj prog2.obj ... rtspruv3_le.lib +``` + +The --rom\_model option tells the linker to use special conventions that are defined by the C/C++ environment. + +The archive libraries shipped by TI contain C/C++ run-time-support functions. + +C, C++, and mixed C and C++ programs can use the same run-time-support library. Run-time-support functions and variables that can be called and referenced from both C and C++ will have the same linkage. + +For more information about the PRU C/C++ language, including the run-time environment and run-timesupport functions, see the *PRU Optimizing C/C++ Compiler User's Guide*. + +### 8.10.1 Run-Time Initialization + +All C/C++ programs must be linked with code to initialize and execute the program, called a *bootstrap* routine, also known as the *boot.obj* object module. The symbol \_c\_int00 is defined as the program entry point and is the start of the C boot routine in boot.obj; referencing \_c\_int00 ensures that boot.obj is automatically linked in from the run-time-support library. When a program begins running, it executes boot.obj first. The boot.obj symbol contains code and data for initializing the run-time environment and performs the following tasks: + +- Changes from system mode to user mode +- Sets up the user mode stack +- Processes the run-time *.cinit* initialization table and autoinitializes global variables (when the linker is invoked with the --rom\_model option) +- Calls main + +The run-time-support object libraries contain boot.obj. You can: + +- Use the archiver to extract boot.obj from the library and then link the module in directly. +- Include the appropriate run-time-support library as an input file (the linker automatically extracts boot.obj when you use the --ram\_model or --rom\_model option). + +### 8.10.2 Object Libraries and Run-Time Support + +The *PRU Optimizing C/C++ Compiler User's Guide* describes additional run-time-support functions that are included in rts.src. If your program uses any of these functions, you must link the appropriate run-timesupport library with your object files. + +You can also create your own object libraries and link them. The linker includes and links only those library members that resolve undefined references. + +### 8.10.3 Setting the Size of the Stack and Heap Sections + +The C/C++ language uses two uninitialized sections called .sysmem and .stack for the memory pool used by the malloc( ) functions and the run-time stacks, respectively. You can set the size of these by using the --heap\_size or --stack\_size option and specifying the size of the section as a 4-byte constant immediately after the option. If the options are not used, the default size of the heap is 256 bytes and the default size of the stack is 256 bytes. + +See Section 8.4.14 for setting heap sizes Section 8.4.29 for setting stack sizes. + +### 8.10.4 Initializing and AutoInitialzing Variables at Run Time + +Autoinitializing variables at run time is the default method of autoinitialization. To use this method, invoke the linker with the --rom\_model option. See Section 3.3.2 for details. + +Initialization of variables at load time enhances performance by reducing boot time and by saving the memory used by the initialization tables. To use this method, invoke the linker with the --ram\_model option. See Section 3.3.2 for details. + +## 8.11 Linker Example + +This example links three object files named demo.obj, ctrl.obj, and tables.obj and creates a program called demo.out. + +Assume that target memory has the following program memory configuration: + +| Address Range | Contents | +|--------------------------|----------| +| 0x00000000 to 0x00001000 | SLOW_MEM | +| 0x00001000 to 0x00002000 | FAST_MEM | +| 0x08000000 to 0x08000400 | EEPROM | + +The output sections are constructed in the following manner: + +- Executable code, contained in the .text sections of demo.obj, fft.obj, and tables.obj, is linked into program memory ROM. +- Variables, contained in the var\_defs section of demo.obj, are linked into data memory in block FAST\_MEM\_2. +- Tables of coefficients in the .data sections of demo.obj, tables.obj, and fft.obj are linked into FAST\_MEM\_1. A hole is created with a length of 100 and a fill value of 0x07A1C. +- The xy section form demo.obj, which contains buffers and variables, is linked by default into page 1 of the block STACK, since it is not explicitly linked. +- Executable code, contained in the .text sections of demo.obj, ctrl.obj, and tables.obj, must be linked into FAST\_MEM. +- A table of coefficients, contained in the .data section of tables.obj, must be linked into EEPROM. The remainder of block FLASH must be initialized to the value 0xFF00FF00. +- A set of variables, contained in the .bss section of ctrl.obj, must be linked into SLOW\_MEM and preinitialized to 0x00000100. +- The .bss sections of demo.obj and tables.obj must be linked into SLOW\_MEM. + +Example 8-22 shows the linker command file for this example. Example 8-23 shows the map file. + +#### Example 8-22. Linker Command File, demo.cmd + +``` +/******************************************************************************/ +/*** Specify Link Options ***/ +/******************************************************************************/ +--entry_point SETUP /* Define the program entry point */ +--output_file=demo.out /* Name the output file */ +--map_file=demo.map /* Create an output map file */ +/******************************************************************************/ +/*** Specify the Input Files ***/ +/******************************************************************************/ +demo.obj +ctrl.obj +tables.obj +/******************************************************************************/ +/*** Specify the Memory Configurations ***/ +/******************************************************************************/ +MEMORY +{ + FAST_MEM : org = 0x00000000 len = 0x00001000 /* PROGRAM MEMORY (ROM) */ + SLOW_MEM : org = 0x00001000 len = 0x00001000 /* DATA MEMORY (RAM) */ + EEPROM : org = 0x08000000 len = 0x00000400 /* COEFFICIENTS (EEPROM) */ +} +/******************************************************************************/ +/* Specify the Output Sections */ +/******************************************************************************/ +SECTIONS +{ + .text : {} > FAST_MEM /* Link all .text sections into ROM */ + .data : /* Link .data sections */ + { + tables.obj(.data) + . = 0x400; /* Create hole at end of block */ + } > EEPROM, fill = 0xFF00FF00 /* Fill and link into EEPROM */ + ctrl_vars: /* Create sections for ctrl variables */ + { + ctrl.obj(.bss) + } > SLOW_MEM, fill = 0x00000100 /* Fill with 0x100 and link into RAM */ + .bss : {} > SLOW_MEM /* Link remaining .bss sections into RAM */ +} +/******************************************************************************/ +/*** End of Command File ***/ +/******************************************************************************/ +``` + +Invoke the linker by entering the following command: + +``` +clpru --run_linker demo.cmd +``` + +This creates the map file shown in Example 8-23 and an output file called demo.out that can be run on a PRU device. + +### Example 8-23. Output Map File, demo.map + +| OUTPUT FILE NAME: | |
ENTRY POINT SYMBOL: "SETUP"
| address: 000000d4 | | | +|------------------------------------------------------------------|------------------------------------|----------------------------------------------------------|----------------------------------------------------------|------------------------------------------------------------------|-----------------------------------| +| MEMORY CONFIGURATION | | | | | | +| | name | origin | length | attributes | fill | +| |
FAST_MEM
SLOW_MEM
EEPROM |
00000000
00001000
08000000 |
000001000
000001000
000000400 |
RWIX
RWIX
RWIX | | +| SECTION ALLOCATION MAP | | | | | | +| output
section | page | origin | length | attributes/
input sections | | +|
.text |
0 |
00000020
00000020
000000c0
000000c0 |
00000138
000000a0
00000000
00000098 |
ctrl.obj (.text)
tables.obj (.text)
demo.obj (.text) | | +| .data | 0 | 08000000
08000000
08000168
08000400
08000400 | 00000400
00000168
00000298
00000000
00000000 | tables.obj (.data)
ctrl.obj (.data)
demo.obj (.data) | HOLE [fill = ff00ff00] | +| ctrl_var | 0 | 00001000
00001000 | 00000500
00000500 | | ctrl.obj (.bss) [fill = 00000100] | +| .bss | 0 | 00001500
00001500
00001600 | 00000100
00000100
00000000 | UNINITIALIZED
demo.obj (.bss)
tables.obj (.bss) | | +| GLOBAL SYMBOLS | | | | | | +| address
| name | | | address
name
| | +| 000000d4 SETUP
00000020 clear
000000b8 set
000000c0 x42 | | | | 00000020 clear
000000b8 set
000000c0 x42
000000d4 SETUP | | +| [4 symbols] | | | | | | + +# 9 Absolute Lister Description + +The PRU absolute lister is a debugging tool that accepts linked object files as input and creates .abs files as output. These .abs files can be assembled to produce a listing that shows the absolute addresses of object code. Manually, this could be a tedious process requiring many operations; however, the absolute lister utility performs these operations automatically. + +**Topic** ........................................................................................................................... **Page** + +| 9.1 | Producing an Absolute Listing | 238 | +|-----|-------------------------------|-----| +| 9.2 | Invoking the Absolute Lister | 239 | +| 9.3 | Absolute Lister Example | 240 | +| | | | + +## 9.1 Producing an Absolute Listing + +Figure 9-1 illustrates the steps required to produce an absolute listing. + +**Figure 9-1. Absolute Lister Development Flow** + +![Figure 9-1: Absolute Lister Development Flow — four-step flowchart from source file through assembler, linker, absolute lister, and final assembly to produce an absolute listing](_page_237_Figure_6.jpeg) + +**Figure 9-1: Absolute Lister Development Flow.** Four-step flowchart. Step 1: Assemble a source file — Assembler source file → Assembler → Object file. Step 2: Link the resulting object file — Object file → Linker → Linked object file. Step 3: Invoke the absolute lister with the linked object file as input; this creates a file with an .abs extension — Linked object file → Absolute lister → .abs file. Step 4: Assemble the .abs file with the compiler --absolute_listing option; this produces a listing file with absolute addresses — .abs file → Assembler → Absolute listing. + +## 9.2 Invoking the Absolute Lister + +The syntax for invoking the absolute lister is: + +**abspru** [-*options*] *input file* + +**abspru** is the command that invokes the absolute lister. + +*options* identifies the absolute lister options that you want to use. Options are not case sensitive and can appear anywhere on the command line following the command. Precede each option with a hyphen (-). The absolute lister options are as follows: +- **-e** enables you to change the default naming conventions for filename extensions on assembly files, C source files, and C header files. The valid options are: + - ea [.]*asmext* for assembly files (default is .asm) + - ec [.]*cext* for C source files (default is .c) + - eh [.]*hext* for C header files (default is .h) + - ep [.]*pext* for CPP source files (default is cpp) + +The . in the extensions and the space between the option and the extension are optional. + +**-q** (quiet) suppresses the banner and all progress information. + +*input file* names the linked object file. If you do not supply an extension, the absolute lister assumes that the input file has the default extension .out. If you do not supply an input filename when you invoke the absolute lister, the absolute lister prompts you for one. + +The absolute lister produces an output file for each file that was linked. These files are named with the input filenames and an extension of .abs. Header files, however, do not generate a corresponding .abs file. + +Assemble these files with the --absolute\_listing assembler option as follows to create the absolute listing: + +**clpru --absolute\_listing** *filename* **.abs** + +The -e options affect both the interpretation of filenames on the command line and the names of the output files. They should always precede any filename on the command line. + +The -e options are useful when the linked object file was created from C files compiled with the debugging option (--symdebug:dwarf compiler option). When the debugging option is set, the resulting linked object file contains the name of the source files used to build it. In this case, the absolute lister does not generate a corresponding .abs file for the C header files. Also, the .abs file corresponding to a C source file uses the assembly file generated from the C source file rather than the C source file itself. + +For example, suppose the C source file hello.csr is compiled with the debugging option set; the debugging option generates the assembly file hello.s. The hello.csr file includes hello.hsr. Assuming the executable file created is called hello.out, the following command generates the proper .abs file: + +``` +abspru -ea s -ec csr -eh hsr hello.out +``` + +An .abs file is not created for hello.hsr (the header file), and hello.abs includes the assembly file hello.s, not the C source file hello.csr. + +## 9.3 Absolute Lister Example + +This example uses three source files. The files module1.asm and module2.asm both include the file globals.def. + +#### module1.asm + +``` +.text +.bss dflag, 1 +.bss array, 100 +.copy globals.def +LDI r4, array +LDI r5, offst +LDI r3, dflag +LBBO &r0, r4, r5, 4 +SBBO &r0, r3, 0, 4 +``` + +#### module2.asm + +``` +.text +.bss offst, 1 +.copy globals.def +LDI r4, offst +SBBO &r0, r4, 0, 4 +``` + +#### globals.def + +``` +.global array +.global offst +.global dflag +``` + +The following steps create absolute listings for the files **module1.asm** and **module2.asm**: + +**Step 1:** First, assemble **module1.asm** and **module2.asm**: + +``` +clpru module1 +clpru module2 +``` + +This creates two object files called module1.obj and module2.obj. + +**Step 2:** Next, link module1.obj and module2.obj using the following linker command file, called bttest.cmd: + +``` +module1.obj +module2.obj +--unused_section_elimination=off +--output_file=bttest.out +MEMORY +{ + PAGE 0: + P_MEM : org = 0x00000008 len = 0x0003FFF8 + PAGE 1: + D_MEM : org = 0x00000008 len = 0x0000FFF8 +} +/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */ +SECTIONS +{ + .data : {} > D_MEM, PAGE 1 + .bss : {} > D_MEM, PAGE 1 + .text : {} > P_MEM, PAGE 0 +} +``` + +Invoke the linker: + +``` +clpru --run_linker bttest.cmd +``` + +This command creates an executable object file called bttest.out; use this file as input for the absolute lister. + +**Step 3:** Now, invoke the absolute lister: + +``` +abspru bttest.out +``` + +This command creates two files called module1.abs and module2.abs: + +**module1.abs:** + +``` +.compiler_opts_source "module1.asm" + .nolist +array .setsym 000000009h +dflag .setsym 000000008h +offst .setsym 00000006dh + .setsect ".text",000000008h + .setsect ".bss",000000008h + .setsect ".debug_info",000000000h + .setsect ".debug_line",000000000h + .list + .text + .copy "module1.asm" +``` + +**module2.abs:** + +``` +.compiler_opts_source "module2.asm" + .nolist +array .setsym 000000009h +dflag .setsym 000000008h +offst .setsym 00000006dh + .setsect ".text",00000001ch + .setsect ".bss",00000006dh + .setsect ".debug_info",0000000c0h + .setsect ".debug_line",00000003eh + .setsect ".debug_aranges",000000000h + .setsect ".debug_pubnames",000000000h + .list + .text + .copy "module2.asm" +``` + +These files contain the following information that the assembler needs for Step 4: + +- They contain .setsym directives, which equate values to global symbols. Both files contain global equates for the symbol *dflag*. The symbol dflag was defined in the file globals.def, which was included in module1.asm and module2.asm. +- They contain .setsect directives, which define the absolute addresses for sections. +- They contain .copy directives, which defines the assembly language source file to include. + +The .setsym and .setsect directives are useful only for creating absolute listings, not normal assembly. + +**Step 4:** Finally, assemble the .abs files created by the absolute lister (remember that you must use the --absolute\_listing option when you invoke the assembler): + +``` +clpru --absolute_listing module1.abs +clpru --absolute_listing module2.abs +``` + +This command sequence creates two listing files called module1.lst and module2.lst; no object code is produced. These listing files are similar to normal listing files; however, the addresses shown are absolute addresses. + +The absolute listing files created are module1.lst (see Example 9-1 ) and module2.lst (see Example 9-2). + +### Example 9-1. module1.lst + +``` +PRU Assembler Unix v2.1.0 Thu Jun 26 21:23:57 2014 +Tools Copyright (c) 2012-2014 Texas Instruments Incorporated +module1.asm PAGE 1 + 1 00000000 .text + 2 00000000 .bss dflag, 1 + 3 00000001 .bss array, 100 + 4 + 5 .copy globals.def +A 1 .global array +A 2 .global offst +A 3 .global dflag + 6 + 7 00000000 000000240000E4! LDI r4, array + 8 00000004 000000240000E5! LDI r5, offst + 9 00000008 000000240000E3! LDI r3, dflag + 10 0000000c 000000F0E52480 LBBO &r0, r4, r5, 4 + 11 00000010 000000E1002380 SBBO &r0, r3, 0, 4 + 12 +No Assembly Errors, No Assembly Warnings +``` + +### Example 9-2. module2.lst + +``` +PRU Assembler Unix v2.1.0 Thu Jun 26 21:24:22 2014 +Tools Copyright (c) 2012-2014 Texas Instruments Incorporated +module2.asm PAGE 1 + 1 00000000 .text + 2 00000000 .bss offst, 1 + 3 + 4 .copy globals.def +A 1 .global array +A 2 .global offst +A 3 .global dflag + 5 00000000 000000240000E4! LDI r4, offst + 6 00000004 000000E1002480 SBBO &r0, r4, 0, 4 +No Assembly Errors, No Assembly Warnings +``` + +# 10 Cross-Reference Lister Description + +The PRU cross-reference lister is a debugging tool. This utility accepts linked object files as input and produces a cross-reference listing as output. This listing shows symbols, their definitions, and their references in the linked source files. + +**Topic** ........................................................................................................................... **Page** + +| 10.1 | Producing a Cross-Reference Listing | 244 | +|------|-------------------------------------|-----| +| 10.2 | Invoking the Cross-Reference Lister | 245 | +| 10.3 | Cross-Reference Listing Example | 246 | +| | | | + +## 10.1 Producing a Cross-Reference Listing + +Figure 10-1 illustrates the steps required to produce a cross-reference listing. + +**Figure 10-1. The Cross-Reference Lister Development Flow** + +![Figure 10-1: Cross-Reference Lister Development Flow — three-step flowchart from source file through assembler with --cross_reference option, linker, and cross-reference lister](_page_243_Figure_6.jpeg) + +**Figure 10-1: The Cross-Reference Lister Development Flow.** Three-step flowchart. Step 1: Invoke the assembler with the compiler --cross_reference option — creates a cross-reference table in the listing file and adds cross-reference information to the object file; by default only global symbols are cross-referenced, but --output_all_syms also adds local symbols — Assembler source file → Assembler → Object file. Step 2: Link the object file (.obj) to obtain an executable object file (.out) — Object file → Linker → Linked object file. Step 3: Invoke the cross-reference lister — Linked object file → Cross-reference lister → Cross-reference listing. + +## 10.2 Invoking the Cross-Reference Lister + +To use the cross-reference utility, the file must be assembled with the correct options and then linked into an executable file. Assemble the assembly language files with the --cross\_reference option. This option creates a cross-reference listing and adds cross-reference information to the object file. By default, the assembler cross-references only global symbols, but if the assembler is invoked with the --output\_all\_syms option, local symbols are also added. Link the object files to obtain an executable file. + +To invoke the cross-reference lister, enter the following: + +**xrefpru** [*options*] [*input filename* [*output filename*]] + +**xrefpru** is the command that invokes the cross-reference utility. + +*options* identifies the cross-reference lister options you want to use. Options are not case sensitive and can appear anywhere on the command line following the command. + +- **-l** (lowercase L) specifies the number of lines per page for the output file. The format of the -l option is -l*num*, where num is a decimal constant. For example, -l30 sets the number of lines per page in the output file to 30. The space between the option and the decimal constant is optional. The default is 60 lines per page. +- **-q** suppresses the banner and all progress information (run quiet). + +*input filename* is a linked object file. If you omit the input filename, the utility prompts for a filename. *output filename* is the name of the cross-reference listing file. If you omit the output filename, the default filename is the input filename with an .xrf extension. + +## 10.3 Cross-Reference Listing Example + +These terms defined appear in the cross-reference listing in Example 10-1: + +**Symbol** Name of the symbol listed + +**Filename** Name of the file where the symbol appears + +**RTYP** The symbol's reference type in this file. The possible reference types are: + +- **STAT** The symbol is defined in this file and is not declared as global. +- **EDEF** The symbol is defined in this file and is declared as global. +- **EREF** The symbol is not defined in this file but is referenced as global. +- **UNDF** The symbol is not defined in this file and is not declared as global. + +**AsmVal** This hexadecimal number is the value assigned to the symbol at assembly time. A value may also be preceded by a character that describes the symbol's attributes. Table 10-1 lists these characters and names. + +**LnkVal** This hexadecimal number is the value assigned to the symbol after linking. + +**DefLn** The statement number where the symbol is defined. + +**RefLn** The line number where the symbol is referenced. If the line number is followed by an asterisk (\*), then that reference can modify the contents of the object. A blank in this column indicates that the symbol was never used. + +**Table 10-1. Symbol Attributes in Cross-Reference Listing** + +| Character | Meaning | | +|-----------|--------------------------------------------|--| +| ' | Symbol defined in a .text section | | +| " | Symbol defined in a .data section | | +| + | Symbol defined in a .sect section | | +| - | Symbol defined in a .bss or .usect section | | + +Example 10-1 is an example of cross-reference listing. + +### Example 10-1. Cross-Reference Listing + +| File:
bttest.out | | Wed Nov 13 17:07:42 xxxx
Page:
1
============================================================================= | | | | | | +|--------------------------------------------------------------------------------------------------|----------|-------------------------------------------------------------------------------------------------------------------------|--------------|-------|--------|-------|-------| +| Symbol: array
Filename | RTYP | AsmVal | LnkVal | DefLn | RefLn | RefLn | RefLn | +|
module1.asm |
EDEF |
-00000001 |
00001001 |
3 |
1A |
5 | | +| =============================================================================
Symbol: array_a | | | | | | | | +| Filename | RTYP | AsmVal | LnkVal | DefLn | RefLn | RefLn | RefLn | +|
module1.asm |
STAT |
'00000004 |
00000004 |
5 |
9 | | | +| =============================================================================
Symbol: dflag | | | | | | | | +| Filename | RTYP | AsmVal | LnkVal | DefLn | RefLn | RefLn | RefLn | +|
module1.asm |
EDEF |
-00000000 |
00001000 |
2 |
3A |
4 | | +| =============================================================================
Symbol: dflag_a | | | | | | | | +| Filename | RTYP | AsmVal | LnkVal | DefLn | RefLn | RefLn | RefLn | +|
module1.asm |
STAT |
'00000000 |
00000000 |
4 |
11 | | | +| =============================================================================
Symbol: offst | | | | | | | | +| Filename | RTYP | AsmVal | LnkVal | DefLn | RefLn | RefLn | RefLn | +|
module1.asm |
EREF |
00000000 |
00001068 | |
2A |
6 | | + +### Example 10-1. Cross-Reference Listing (continued) + +| module2.asm | EDEF | -00000000 | 00001068 | 2 | 2A | 3 | | +|--------------------------------------------------------------------------------------------------|----------|------------|------------|-----------|-----------|-----------|-----------| +| =============================================================================
Symbol: offst_a | | | | | | | | +| Filename
| RTYP
| AsmVal
| LnkVal
| DefLn
| RefLn
| RefLn
| RefLn
| +| module1.asm | STAT | '00000008 | 00000008 | 6 | 10 | | | +| module2.asm | STAT | '00000000 | 00000020 | 3 | 6 | | | +| ============================================================================= | | | | | | | | + +# 11 Object File Utilities + +This chapter describes how to invoke the following utilities: + +- The **object file display utility** prints the contents of object files, executable files, and/or archive libraries in both text and XML formats. +- The **disassembler** accepts object files and executable files as input and produces an assembly listing as output. This listing shows assembly instructions, their opcodes, and the section program counter values. +- The **name utility** prints a list of names defined and referenced in an object file, executable files, and/or archive libraries. +- The **strip utility** removes symbol table and debugging information from object and executable files. + +**Topic** ........................................................................................................................... **Page** + +| 11.1 | Invoking the Object File Display Utility | 249 | +|------|------------------------------------------|-----| +| 11.2 | Invoking the Disassembler | 250 | +| | | | +| 11.3 | Invoking the Name Utility | 252 | +| | Invoking the Strip Utility | | +| 11.4 | | 253 | + +## 11.1 Invoking the Object File Display Utility + +The object file display utility, *ofdpru*, prints the contents of object files (.obj), executable files (.out), and/or archive libraries (.lib) in both text and XML formats. Hidden symbols are listed as *no name*, while localized symbols are listed like any other local symbol. + +To invoke the object file display utility, enter the following: + +**ofdpru** [*options*] *input filename* [*input filename*] + +**ofdpru** is the command that invokes the object file display utility. + +*input filename* names the object file (.obj), executable file (.out), or archive library (.lib) source file. + +The filename must contain an extension. + +*options* identify the object file display utility options that you want to use. Options are not case sensitive and can appear anywhere on the command line following the command. + +Precede each option with a hyphen. + +**-cg** Prints function stack usage and callee information in XML + +format. While the XML output may be accessed by a developer, this option was primarily designed to be used by tools such as Code Composer Studio to display an + +application's worst case stack usage. + +**--dwarf\_display**=*attributes* Controls the DWARF display filter settings by specifying a + +comma-delimited list of *attributes*. When prefixed with no, + +an attribute is disabled instead of enabled. + +Examples: --dwarf\_display=nodabbrev,nodline + +--dwarf\_display=all,nodabbrev --dwarf\_display=none,dinfo,types + +The ordering of attributes is important (see --obj\_display). The list of available display attributes can be obtained by + +invoking ofdpru --dwarf\_display=help. + +**--dynamic\_info** Outputs dynamic linking information. + +**-g** Appends DWARF debug information to program output. + +**-h** Displays help + +**-o**=*filename* Sends program output to *filename* rather than to the + +screen. + +**--obj\_display** *attributes* Controls the object file display filter settings by specifying + +a comma-delimited list of *attributes*. When prefixed with + +no, an attribute is disabled instead of enabled. + +Examples: --obj\_display=rawdata,nostrings + +--obj\_display=all,norawdata + +--obj\_display=none,header + +The ordering of attributes is important. For instance, in "--obj\_display=none,header", ofdpru disables all output, then re-enables file header information. If the attributes are specified in the reverse order, (header,none), the file header is enabled, the all output is disabled, including the file header. Thus, nothing is printed to the screen for the given files. The list of available display attributes can be obtained by invoking ofdpru --obj\_display=help. + +**-v** Prints verbose text output. + +**-x** Displays output in XML format. + +**--xml\_indent**=*num* Sets the number of spaces to indent nested XML tags. + +If an archive file is given as input to the object file display utility, each object file member of the archive is processed as if it was passed on the command line. The object file members are processed in the order in which they appear in the archive file. + +If the object file display utility is invoked without any options, it displays information about the contents of the input files on the console screen. + +#### Object File Display Format + +**NOTE:** The object file display utility produces data in a text format by default. This data is not intended to be used as input to programs for further processing of the information. XML format should be used for mechanical processing. + +## 11.2 Invoking the Disassembler + +The disassembler, *dispru*, examines the output of the assembler or linker. This utility accepts an object file or executable file as input and writes the disassembled object code to standard output or a specified file. + +To invoke the disassembler, enter the following: + +**dispru** [*options*] *input filename*[.] [*output filename*] + +**dispru** is the command that invokes the disassembler. + +*options* identifies the name utility options you want to use. Options are not case sensitive and can appear anywhere on the command line following the invocation. Precede each option with a hyphen (-). The name utility options are as follows: + +- **-1** disassembles all sections, processes .cinit sections +- **-a** disables printing of address along with label names within instructions. +- **-b** displays data as bytes instead of words. +- **-d** disables display of data sections. +- **-e** displays integer values in hexadecimal. +- **-h** shows the current help screen. +- **-i** disassembles data sections as text. +- **-I** disassembles text sections as data. +- **-q** (quiet mode) suppresses the banner and all progress information. +- **-qq** (super quiet mode) suppresses all headers. +- **-s** suppresses printing of address and data words. +- **-t** suppresses the display of text sections in the listing. +- **-y** (aliased as --copy\_talbes) displays copy tables and the sections copied. The table information is dumped first, then each record followed by its load and run data. + +*input filename*[.*ext*] is the name of the input file. If the optional extension is not specified, the file is searched for in this order: + +1. *infile* +2. *infile*.out, an executable file +3. *infile*.obj, an object file + +*output filename* is the name of the optional output file to which the disassembly will be written. If an output filename is not specified, the disassembly is written to standard output. + +As shown in Example 11-1, the disassembler can produce disassembly from an object file, in this case memcpy32.obj. The first two lines are entered on the command line. + +### Example 11-1. Disassembly From memcpy32.asm + +| TEXT Section .text, 0x180 bytes at 0x0 | | | | | +|----------------------------------------|-----------|-----------------|--|--| +| 000000: | C_MEMCPY: | | | | +| 000000: E3520000 | CMP | R2, 0 | | | +| 000004: 012FFF1E | BXEQ | R14 | | | +| 000008: E92D4001 | STMFD | R13!, {R0, R14} | | | +| 00000c: E3110003 | TST | R1, 3 | | | +| 000010: 1A00002B | BNE | 0x000000C4 | | | +| 000014: E3100003 | TST | R0, 3 | | | +| 000018: 1A00002F | BNE | 0x000000DC | | | +| 00001c: E3520010 | CMP | R2, 16 | | | +| 000020: 3A000008 | BCC | 0x00000048 | | | +| 000024: E92D0010 | STMFD | R13!, {R4} | | | +| 000028: E2422010 | SUB | R2, R2, 16 | | | + +Example 11-2 provides an example of how the output would appear if a copy record refers to different load and run sections and the --copy\_table option is used. + +### Example 11-2. Partial Copy Record Output With Different Load and Run Address + +``` +COPY TABLE: _data2_ctbl, 0x30 at 0x5E10, 1 record(s) +_data2_ctbl[0]: load addr=0x200158, size=0x12B, encoding=lzss +DATA Section .data2_scn.load, 0x12B bytes at 0x200158 +200158: $d: +200158: 020f0000 .word 0x020f0000 +20015c: beef0003 .word 0xbeef0003 +. +. +_data2_ctbl[0]: run addr=0x52A0, size=0x960 +DATA Section .data1_scn, 0x960 bytes at 0x52A0 +0052a0: data1: +0052a0: $d: +0052a0: .data1_scn: +0052a0: 0000beef .word 0x0000beef +0052a4: 0000beef .word 0x0000beef +. +. +``` + +## 11.3 Invoking the Name Utility + +The name utility, *nmpru*, prints the list of names defined and referenced in an object file, executable file, or archive library. It also prints the symbol value and an indication of the kind of symbol. Hidden symbols are listed as "". + +To invoke the name utility, enter the following: + +**nmpru** [-*options*] [*input filenames*] + +**nmpru** is the command that invokes the name utility. + +*input filename* is an object file (.obj), executable file (.out), or archive library (.lib). + +*options* identifies the name utility options you want to use. Options are not case sensitive and can appear anywhere on the command line following the invocation. Precede each option with a hyphen (-). The name utility options are as follows: + +- **-a** prints all symbols. +- **-f** prepends file name to each symbol. +- **-g** prints only global symbols. +- **-h** shows the current help screen. +- **-l** produces a detailed listing of the symbol information. +- **-n** sorts symbols numerically rather than alphabetically. +- **-o** *file* outputs to the given file. +- **-p** causes the name utility to not sort any symbols. +- **-q** (quiet mode) suppresses the banner and all progress information. +- **-r** sorts symbols in reverse order. +- **-s** lists symbols in the dynamic symbol table for an ELF object module. +- **-u** only prints undefined symbols. + +## 11.4 Invoking the Strip Utility + +The strip utility, *strippru*, removes symbol table and debugging information from object and executable files. + +To invoke the strip utility, enter the following: + +**strippru** [**-p**] *input filename* [*input filename*] + +**strippru** is the command that invokes the strip utility. *input filename* is an object file (.obj) or an executable file (.out). + +*options* identifies the strip utility options you want to use. Options are not case sensitive and can appear anywhere on the command line following the invocation. Precede each option with a hyphen (-). The strip utility option is as follows: + +**-o** *filename* writes the stripped output to filename. + +**-p** removes all information not required for execution. This option causes more information to be removed than the default behavior, but the object file is left in a state that cannot be linked. This option should be used only with executable (.out) files. + +When the strip utility is invoked without the -o option, the input object files are replaced with the stripped version. + +# 12 Hex Conversion Utility Description + +The PRU assembler and linker create object files which are in binary formats that encourage modular programming and provide powerful and flexible methods for managing code segments and target system memory. + +Most EPROM programmers do not accept object files as input. The hex conversion utility converts an object file into one of several standard ASCII hexadecimal formats, suitable for loading into an EPROM programmer. The utility is also useful in other applications requiring hexadecimal conversion of an object file (for example, when using debuggers and loaders). + +The hex conversion utility can produce these output file formats: + +- ASCII-Hex, supporting 16-bit addresses +- Extended Tektronix (Tektronix) +- Intel MCS-86 (Intel) +- Motorola Exorciser (Motorola-S), supporting 16-bit addresses +- Texas Instruments SDSMAC (TI-Tagged), supporting 16-bit addresses +- Texas Instruments TI-TXT format, supporting 16-bit addresses +- C arrays + +**Topic** ........................................................................................................................... **Page** + +| 12.1 | The Hex Conversion Utility's Role in the Software Development Flow | 255 | +|-------|--------------------------------------------------------------------|-----| +| 12.2 | Invoking the Hex Conversion Utility | 256 | +| 12.3 | Linking with an ARM Executable | 259 | +| 12.4 | Understanding Memory Widths | 259 | +| 12.5 | The ROMS Directive | 263 | +| 12.6 | The SECTIONS Directive | 266 | +| 12.7 | The Load Image Format (--load_image Option) | 267 | +| 12.8 | Excluding a Specified Section | 268 | +| 12.9 | Assigning Output Filenames | 268 | +| 12.10 | Image Mode and the --fill Option | 269 | +| 12.11 | Array Output Format | 270 | +| 12.12 | Controlling the ROM Device Address | 271 | +| 12.13 | Control Hex Conversion Utility Diagnostics | 272 | +| 12.14 | Description of the Object Formats | 273 | + +## 12.1 The Hex Conversion Utility's Role in the Software Development Flow + +Figure 12-1 highlights the role of the hex conversion utility in the software development process. + +**Figure 12-1. The Hex Conversion Utility in the PRU Software Development Flow** + +![Figure 12-1: The Hex Conversion Utility in the PRU Software Development Flow — complete development flow block diagram with Hex-conversion utility highlighted at bottom left](_page_254_Figure_6.jpeg) + +**Figure 12-1: The Hex Conversion Utility in the PRU Software Development Flow.** Complete PRU software development flow block diagram with the Hex-conversion utility highlighted. Inputs include C/C++ source files (compiled by C/C++ compiler to assembler source), macro source files, and object files. The Archiver processes macro source into a Macro library. The Assembler converts assembler source to Object files. Object files and libraries are archived into a Library of object files. A Library-build utility provides a Run-time-support library. The Linker combines all inputs into an Executable object file. The executable feeds into: the PRU device directly, Debugging tools, EPROM programmer, Absolute lister, Cross-reference lister, Object file utilities, and the Hex-conversion utility (highlighted). A C/C++ name demangling utility is also shown connected to the assembler source path. + +## 12.2 Invoking the Hex Conversion Utility + +There are two basic methods for invoking the hex conversion utility: + +• **Specify the options and filenames on the command line.** The following example converts the file firmware.out into TI-Tagged format, producing two output files, firm.lsb and firm.msb. + +``` +hexpru -t firmware -o firm.lsb -o firm.msb +``` + +• **Specify the options and filenames in a command file.** You can create a file that stores command line options and filenames for invoking the hex conversion utility. The following example invokes the utility using a command file called hexutil.cmd: + +``` +hexpru hexutil.cmd +``` + +In addition to regular command line information, you can use the hex conversion utility ROMS and SECTIONS directives in a command file. + +### 12.2.1 Invoking the Hex Conversion Utility From the Command Line + +To invoke the hex conversion utility, enter: + +**hexpru** [*options*] *filename* + +**hexpru** is the command that invokes the hex conversion utility. + +*options* supplies additional information that controls the hex conversion process. You can use options on the command line or in a command file. Table 12-1 lists the basic options. + +- All options are preceded by a hyphen and are not case sensitive. +- Several options have an additional parameter that must be separated from the option by at least one space. +- Options with multi-character names must be spelled exactly as shown in this document; no abbreviations are allowed. +- Options are not affected by the order in which they are used. The exception to this rule is the --quiet option, which must be used before any other options. + +*filename* names an object file or a command file (for more information, see Section 12.2.2). + +**Table 12-1. Basic Hex Conversion Utility Options** + +| Option | Alias | Description | See | +|---------------------------------------------|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------| +| General Options | | | | +| --exclude=(*fname*(*sname*) \| *sname*) | -exclude | If the filename (*fname*) is omitted, all sections matching *sname* will be excluded. | Section 12.8 | +| --fill=*value* | -fill | Fill holes with *value* | Section 12.10.2 | +| --help | -options, -h | Display the syntax for invoking the utility and list available options. If the option is followed by another option or phrase, detailed information about that option or phrase is displayed. | Section 12.2.2 | +| --image | -image | Select image mode | Section 12.10.1 | +| --linkerfill | -linkerfill | Include linker fill sections in images | | +| --map=*filename* | -map | Generate a map file | Section 12.5.2 | +| --memwidth=*value* | -memwidth | Define the system memory word width (default bits) | Section 12.4.2 | +| --outfile=*filename* | -o | Specify an output filename | Section 12.9 | +| --quiet | -q | Run quietly (when used, it must appear before other options) | Section 12.2.2 | +| --romwidth=*value* | -romwidth | Specify the ROM device width (default depends on format used). This option is ignored for the TI-TXT and TI-Tagged formats. | Section 12.4.3 | +| --zero | -zero, -z | Reset the address origin to 0 in image mode | Section 12.10.3 | + +**Table 12-1. Basic Hex Conversion Utility Options (continued)** + +| Option | Alias | Description | See | +|---------------------------------|-------|-----------------------------------------------------------------------------------------------------|-----------------| +| | | Diagnostic Options | | +| --diag_error=*id* | | Categorizes the diagnostic identified by *id* as an error | Section 12.13 | +| --diag_remark=*id* | | Categorizes the diagnostic identified by *id* as a remark | Section 12.13 | +| --diag_suppress=*id* | | Suppresses the diagnostic identified by *id* | Section 12.13 | +| --diag_warning=*id* | | Categorizes the diagnostic identified by *id* as a warning | Section 12.13 | +| --display_error_number | | Displays a diagnostic's identifiers along with its text | Section 12.13 | +| --issue_remarks | | Issues remarks (nonserious warnings) | Section 12.13 | +| --no_warnings | | Suppresses warning diagnostics (errors are still issued) | Section 12.13 | +| --set_error_limit=*count* | | Sets the error limit to *count*. The linker abandons linking after this number of errors. (The default is 100.) | Section 12.13 | +| | | Output Options | | +| --array | | Select array output format | Section 12.11 | +| --ascii | -a | Select ASCII-Hex | Section 12.14.1 | +| --intel | -i | Select Intel | Section 12.14.2 | +| --motorola=1 | -m1 | Select Motorola-S1 | Section 12.14.3 | +| --motorola=2 | -m2 | Select Motorola-S2 | Section 12.14.3 | +| --motorola=3 | -m3 | Select Motorola-S3 (default -m option) | Section 12.14.3 | +| --tektronix | -x | Select Tektronix (default format when no output option is specified) | Section 12.14.4 | +| --ti_tagged | -t | Select TI-Tagged | Section 12.14.5 | +| --ti_txt | | Select TI-Txt | Section 12.14.6 | +| | | Load Image Options | | +| --load_image | | Select load image | Section 12.7 | +| --section_name_prefix=*string* | | Specify the section name prefix for load image object files | Section 12.7 | + +### 12.2.2 Invoking the Hex Conversion Utility With a Command File + +A command file is useful if you plan to invoke the utility more than once with the same input files and options. It is also useful if you want to use the ROMS and SECTIONS hex conversion utility directives to customize the conversion process. + +Command files are ASCII files that contain one or more of the following: + +- **Options and filenames.** These are specified in a command file in exactly the same manner as on the command line. +- **ROMS directive.** The ROMS directive defines the physical memory configuration of your system as a list of address-range parameters. (See Section 12.5.) +- **SECTIONS directive.** The hex conversion utility SECTIONS directive specifies which sections from the object file are selected. (See Section 12.6.) +- **Comments.** You can add comments to your command file by using the /\* and \*/ delimiters. For example: + +``` +/* This is a comment. */ +``` + +To invoke the utility and use the options you defined in a command file, enter: + +**hexpru** *command\_filename* + +You can also specify other options and files on the command line. For example, you could invoke the utility by using both a command file and command line options: + +``` +hexpru firmware.cmd --map=firmware.mxp +``` + +The order in which these options and filenames appear is not important. The utility reads all input from the command line and all information from the command file before starting the conversion process. However, if you are using the -q option, *it must appear as the first option on the command line or in a command file.* + +The **--help** option displays the syntax for invoking the compiler and lists available options. If the --help option is followed by another option or phrase, detailed information about the option or phrase is displayed. For example, to see information about options associated with generating a boot table use --help boot. + +The **--quiet** option suppresses the hex conversion utility's normal banner and progress information. + +• Assume that a command file named firmware.cmd contains these lines: + +``` +firmware.out /* input file */ +--ti-tagged /* TI-Tagged */ +--outfile=firm.lsb /* output file */ +--outfile=firm.msb /* output file */ +``` + +You can invoke the hex conversion utility by entering: + +``` +hexpru firmware.cmd +``` + +• This example shows how to convert a file called appl.out into eight hex files in Intel format. Each output file is one byte wide and 4K bytes long. + +``` +appl.out /* input file */ +--intel /* Intel format */ +--map=appl.mxp /* map file */ +ROMS +{ + ROW1: origin=0x00000000 len=0x4000 romwidth=8 + files={ appl.u0 appl.u1 appl.u2 appl.u3 } + ROW2: origin=0x00004000 len=0x4000 romwidth=8 + files={ appl.u4 appl.u5 appl.u6 appl.u7 } +} +SECTIONS +{ .text, .data, .cinit, .sect1, .const: +} +``` + +## 12.3 Linking with an ARM Executable + +The hexpru tool can be used to convert a PRU executable into an ARM object file that can be linked in with an ARM project. The PRU code and data are converted to ARM data. The ARM application can reference symbols in the PRU file. This is useful for bare metal projects that are not running a high level operating system like Linux. + +The files for this example are provided in the PRU compiler's "example" directory. The resulting executable exposes the shared\_buf and local\_data symbols. + +``` +clpru -o3 test.c -z AM3359_PRU.cmd -o pru.out +``` + +To convert the executable to an ARM object file, use the PRU\_to\_ARM.cmd file as follows: + +``` +hexpru pru.out -o pru.obj PRU_to_ARM.cmd +``` + +The resulting pru.obj file can be linked with the dummy ARM application as follows: + +``` +armcl arm.c pru0.obj -z dummy_ARM.cmd -o arm.out +``` + +## 12.4 Understanding Memory Widths + +The hex conversion utility makes your memory architecture more flexible by allowing you to specify memory and ROM widths. To use the hex conversion utility, you must understand how the utility treats word widths. Three widths are important in the conversion process: + +- Target width +- Memory width +- ROM width + +The terms target word, memory word, and ROM word refer to a word of such a width. + +Figure 12-2 illustrates the separate and distinct phases of the hex conversion utility's process flow. + +![Figure 12-2: Hex Conversion Utility Process Flow — two-phase flowchart from input file through memory-width grouping (Phase I) to ROM-width partitioning and format output (Phase II)](_page_258_Figure_18.jpeg) + +**Figure 12-2: Hex Conversion Utility Process Flow.** Two-phase flowchart. Input: an object file where raw data is represented in the target's addressable units (32 bits for the ARM device). Phase I: the raw data is grouped into words according to the size specified by the --memwidth option. Phase II: the memwidth-sized words are broken up according to the size specified by the --romwidth option and written to output file(s) in the specified format (Intel, Tektronix, etc.). + +### 12.4.1 Target Width + +Target width is the unit size (in bits) of the target processor's word. The width is fixed for each target and cannot be changed. The PRU targets have a width of 32 bits. + +### 12.4.2 Specifying the Memory Width + +Memory width is the physical width (in bits) of the memory system. Usually, the memory system is physically the same width as the target processor width: a 32-bit processor has a 32-bit memory architecture. However, some applications require target words to be broken into multiple, consecutive, and narrower memory words. + +By default, the hex conversion utility sets memory width to the target width (in this case, 32 bits). + +You can change the memory width (except for TI-TXT format) by: + +- Using the **--memwidth** option. This changes the memory width value for the entire file. +- Setting the **memwidth** parameter of the ROMS directive. This changes the memory width value for the address range specified in the ROMS directive and overrides the --memwidth option for that range. See Section 12.5. + +For both methods, use a value that is a power of 2 greater than or equal to 8. + +You should change the memory width default value of 16 only when you need to break single target words into consecutive, narrower memory words. + +#### TI-TXT Format is 8 Bits Wide + +**NOTE:** You cannot change the memory width of the TI-TXT format. The TI-TXT hex format supports an 8-bit memory width only. + +Figure 12-3 demonstrates how the memory width is related to object file data. + +![Figure 12-3: Object File Data and Memory Widths — three-section diagram showing source .word directives, big-endian object file bytes, and data layout for --memwidth=32, 16, and 8](_page_259_Figure_14.jpeg) + +**Figure 12-3: Object File Data and Memory Widths.** Three-section diagram. Top section (Source file): `.word 0AABBCCDDh` and `.word 011223344h`. Middle section (Object file data, assumed big-endian): bytes AA BB CC DD / 11 22 33 44. Bottom section (Memory widths — variable, data after Phase I of armhex): --memwidth=32 (default) produces 32-bit words AABBCCDD and 11223344; --memwidth=16 produces 16-bit words AABB, CCDD, 1122, 3344; --memwidth=8 produces individual bytes AA, BB, CC, DD, 11, 22, 33, 44. + +### 12.4.3 Partitioning Data Into Output Files + +ROM width determines how the hex conversion utility partitions the data into output files. ROM width specifies the physical width (in bits) of each ROM device and corresponding output file (usually one byte or eight bits). After the object file data is mapped to the memory words, the memory words are broken into one or more output files. The number of output files is determined by the following formulas: + +• If memory width ≥ ROM width: number of files = memory width ÷ ROM width + +• If memory width < ROM width: number of files = 1 + +For example, for a memory width of 32, you could specify a ROM width value of 32 and get a single output file containing 32-bit words. Or you can use a ROM width value of 16 to get two files, each containing 16 bits of each word. + +The default ROM width that the hex conversion utility uses depends on the output format: + +- All hex formats except TI-Tagged are configured as lists of 8-bit bytes; the default ROM width for these formats is 8 bits. +- TI-Tagged is a 16-bit format; the default ROM width for TI-Tagged is 16 bits. + +#### The TI-Tagged Format is 16 Bits Wide + +**NOTE:** You cannot change the ROM width of the TI-Tagged format. The TI-Tagged format supports a 16-bit ROM width only. + +#### TI-TXT Format is 8 Bits Wide + +**NOTE:** You cannot change the ROM width of the TI-TXT format. The TI-TXT hex format supports only an 8-bit ROM width. + +You can change ROM width (except for TI-Tagged and TI-TXT formats) by: + +- Using the **--romwidth** option. This option changes the ROM width value for the entire object file. +- Setting the **romwidth** parameter of the ROMS directive. This parameter changes the ROM width value for a specific ROM address range and overrides the --romwidth option for that range. See Section 12.5. + +For both methods, use a value that is a power of 2 greater than or equal to 8. + +If you select a ROM width that is wider than the natural size of the output format, the utility simply writes multibyte fields into the file. The --romwidth option is ignored for the TI-TXT and TI-Tagged formats. + +Figure 12-4 illustrates how the object file data, memory, and ROM widths are related to one another. + +Memory width and ROM width are used only for grouping the object file data; they do not represent values. Thus, the byte ordering of the object file data is maintained throughout the conversion process. To refer to the partitions within a memory word, the bits of the memory word are always numbered from right to left as follows: + +A A B B C C D D 1 1 2 2 3 3 4 4 --memwidth=32 31 0 + +**Figure 12-4. Data, Memory, and ROM Widths** + +![Figure 12-4: Data, Memory, and ROM Widths — diagram showing Phase I memory widths and Phase II ROM output partitioning into multiple output files at various romwidth settings](_page_261_Figure_4.jpeg) + +**Figure 12-4: Data, Memory, and ROM Widths.** Diagram extending Figure 12-3 to show Phase II output file partitioning. Source and object file data are the same as Figure 12-3 (words 0AABBCCDDh and 011223344h, big-endian). Phase I memory width groupings shown for --memwidth=32, 16, and 8. Phase II (data after armhex) output files for --romwidth=8: four files file.b0 (DD 44), file.b1 (CC 33), file.b2 (BB 22), file.b3 (AA 11). For --romwidth=16 with --memwidth=32: one file file.wrd containing AABBCCDD11223344. For --romwidth=8 with --memwidth=16: file.b0 (BB DD 22 44), file.b1 (AA CC 11 33). For --romwidth=8 with --memwidth=32 byte mode: file.byt (AABBCCDD11223344). + +## 12.5 The ROMS Directive + +The ROMS directive specifies the physical memory configuration of your system as a list of address-range parameters. + +Each address range produces one set of files containing the hex conversion utility output data that corresponds to that address range. Each file can be used to program one single ROM device. + +The ROMS directive is similar to the MEMORY directive of the PRU linker: both define the memory map of the target address space. Each line entry in the ROMS directive defines a specific address range. The general syntax is: + +``` +ROMS +{ + romname : [origin=value,] [length=value,] [romwidth=value,] + [memwidth=value,] [fill=value] + [files={ filename 1 + , filename 2 + , ...}] + romname : [origin=value,] [length=value,] [romwidth=value,] + [memwidth=value,] [fill=value] + [files={ filename 1 + , filename 2 + , ...}] + ... +} +``` + +**ROMS** begins the directive definition. + +*romname* identifies a memory range. The name of the memory range can be one to eight characters in length. The name has no significance to the program; it simply identifies the range, except when the output is for a load image in which case it denotes the section name. (Duplicate memory range names are allowed.) + +**origin** specifies the starting address of a memory range. It can be entered as origin, org, or o. The associated value must be a decimal, octal, or hexadecimal constant. If you omit the origin value, the origin defaults to 0. The following table summarizes the notation you can use to specify a decimal, octal, or hexadecimal constant: + +| Constant | Notation | Example | +|-------------|-----------------------|--------------| +| Hexadecimal | 0x prefix or h suffix | 0x77 or 077h | +| Octal | 0 prefix | 077 | +| Decimal | No prefix or suffix | 77 | + +**length** specifies the length of a memory range as the physical length of the ROM device. It can be entered as length, len, or l. The value must be a decimal, octal, or hexadecimal constant. If you omit the length, it defaults to the length of the entire address space. + +**romwidth** specifies the physical ROM width of the range in bits (see Section 12.4.3). Any value you specify here overrides the --romwidth option. The value must be a decimal, octal, or hexadecimal constant that is a power of 2 greater than or equal to 8. + +**memwidth** specifies the memory width of the range in bits (see Section 12.4.2). Any value you specify here overrides the --memwidth option. The value must be a decimal, octal, or hexadecimal constant that is a power of 2 greater than or equal to 8. *When using the memwidth parameter, you must also specify the paddr parameter for each section in the SECTIONS directive.* (See Section 12.6.) + +**fill** specifies a fill value to use for the range. In image mode, the hex conversion utility uses this value to fill any holes between sections in a range. A hole is an area between the input sections that comprises an output section that contains no actual code or data. The fill value must be a decimal, octal, or hexadecimal constant with a width equal to the target width. Any value you specify here overrides the --fill option. When using fill, you must also use the --image command line option. (See Section 12.10.2.) + +**files** identifies the names of the output files that correspond to this range. Enclose the list of names in curly braces and order them from *least significant* to *most significant* output file, where the bits of the memory word are numbered from right to left. The number of file names must equal the number of output files that the range generates. To calculate the number of output files, see Section 12.4.3. The utility warns you if you list too many or too few filenames. + +Unless you are using the --image option, all of the parameters that define a range are optional; the commas and equal signs are also optional. A range with no origin or length defines the entire address space. In image mode, an origin and length are required for all ranges. + +Ranges must not overlap and must be listed in order of ascending address. + +### 12.5.1 When to Use the ROMS Directive + +If you do not use a ROMS directive, the utility defines a single default range that includes the entire address space. This is equivalent to a ROMS directive with a single range without origin or length. + +Use the ROMS directive when you want to: + +- **Program large amounts of data into fixed-size ROMs**. When you specify memory ranges corresponding to the length of your ROMs, the utility automatically breaks the output into blocks that fit into the ROMs. +- **Restrict output to certain segments**. You can also use the ROMS directive to restrict the conversion to a certain segment or segments of the target address space. The utility does not convert the data that falls outside of the ranges defined by the ROMS directive. Sections can span range boundaries; the utility splits them at the boundary into multiple ranges. If a section falls completely outside any of the ranges you define, the utility does not convert that section and issues no messages or warnings. Thus, you can exclude sections without listing them by name with the SECTIONS directive. However, if a section falls partially in a range and partially in unconfigured memory, the utility issues a warning and converts only the part within the range. +- **Use image mode.** When you use the --image option, you must use a ROMS directive. Each range is filled completely so that each output file in a range contains data for the whole range. Holes before, between, or after sections are filled with the fill value from the ROMS directive, with the value specified with the --fill option, or with the default value of 0. + +### 12.5.2 An Example of the ROMS Directive + +The ROMS directive in Example 12-1 shows how 16K bytes of 16-bit memory could be partitioned for two 8K-byte 8-bit EPROMs. Figure 12-5 illustrates the input and output files. + +#### Example 12-1. A ROMS Directive Example + +``` +infile.out +--image +--memwidth 16 +ROMS +{ + EPROM1: org = 0x00004000, len = 0x2000, romwidth = 8 + files = { rom4000.b0, rom4000.b1} + EPROM2: org = 0x00006000, len = 0x2000, romwidth = 8, + fill = 0xFF00FF00, + files = { rom6000.b0, rom6000.b1} +} +``` + +**Figure 12-5. The infile.out File Partitioned Into Four Output Files** + +![Figure 12-5: The infile.out File Partitioned Into Four Output Files — diagram showing .text/.data/.table sections split across EPROM1 and EPROM2, each with two 8-bit output files](_page_264_Figure_3.jpeg) + +**Figure 12-5: The infile.out File Partitioned Into Four Output Files.** Memory layout diagram. Left: infile.out with three sections: .text (0x00004000–0x0000487F), .data (0x00005B80–0x0000633F), and .table (0x00006700–0x00007C7F). Right top (EPROM1, 8K, Width=8 bits): two output files rom4000.b0 and rom4000.b1 (byte-wide slices), each containing .text, a filled gap (0h fill at 0x00004880–0x00005B7F), and .data through 0x00005FFF. Right bottom (EPROM2): two output files rom6000.b0 and rom6000.b1, each containing .data (0x6000–0x633F), a filled gap (FFh/00h fill at 0x6340–0x66FF), and .table. + +The map file (specified with the --map option) is advantageous when you use the ROMS directive with multiple ranges. The map file shows each range, its parameters, names of associated output files, and a list of contents (section names and fill values) broken down by address. Example 12-2 is a segment of the map file resulting from the example in Example 12-1. + +#### Example 12-2. Map File Output From Example 12-1 Showing Memory Ranges + +``` +----------------------------------------------------- +00004000..00005fff Page=0 Width=8 "EPROM1" +----------------------------------------------------- + OUTPUT FILES: rom4000.b0 [b0..b7] + rom4000.b1 [b8..b15] + CONTENTS: 00004000..0000487f .text + 00004880..00005b7f FILL = 00000000 + 00005b80..00005fff .data +----------------------------------------------------- +00006000..00007fff Page=0 Width=8 "EPROM2" +----------------------------------------------------- + OUTPUT FILES: rom6000.b0 [b0..b7] + rom6000.b1 [b8..b15] + CONTENTS: 00006000..0000633f .data + 00006340..000066ff FILL = ff00ff00 + 00006700..00007c7f .table + 00007c80..00007fff FILL = ff00ff00 +``` + +EPROM1 defines the address range from 0x00004000 through 0x00005FFF with the following sections: + +| This section | Has this range | +|--------------|-------------------------------| +| .text | 0x00004000 through 0x0000487F | +| .data | 0x00005B80 through 0x00005FFF | + +The rest of the range is filled with 0h (the default fill value), converted into two output files: + +- rom4000.b0 contains bits 0 through 7 +- rom4000.b1 contains bits 8 through 15 + +EPROM2 defines the address range from 0x00006000 through 0x00007FFF with the following sections: + +| This section | Has this range | +|--------------|-------------------------------| +| .data | 0x00006000 through 0x0000633F | +| .table | 0x00006700 through 0x00007C7F | + +The rest of the range is filled with 0xFF00FF00 (from the specified fill value). The data from this range is converted into two output files: + +- rom6000.b0 contains bits 0 through 7 +- rom6000.b1 contains bits 8 through 15 + +## 12.6 The SECTIONS Directive + +You can convert specific sections of the object file by name with the hex conversion utility SECTIONS directive. You can also specify those sections that you want to locate in ROM at a different address than the *load* address specified in the linker command file. If you: + +- Use a SECTIONS directive, the utility converts only the sections that you list in the directive and ignores all other sections in the object file. +- Do not use a SECTIONS directive, the utility converts all initialized sections that fall within the configured memory. + +Uninitialized sections are *never* converted, whether or not you specify them in a SECTIONS directive. + +#### Sections Generated by the C/C++ Compiler + +**NOTE:** The PRU C/C++ compiler automatically generates these sections: + +- **Initialized sections:** .text, .const, .cinit, and .switch +- **Uninitialized sections:** .bss, .stack, and .sysmem + +Use the SECTIONS directive in a command file. (See Section 12.2.2.) The general syntax is: + +``` +SECTIONS +{ + oname(sname)[:] [paddr=value] + oname(sname)[:] [paddr= boot] + oname(sname)[:] [boot] + ... +} +``` + +**SECTIONS** begins the directive definition. + +*oname* identifies the object filename the section is located within. The filename is optional + +when only a single input file is given, but required otherwise. + +*sname* identifies a section in the input file. If you specify a section that does not exist, the + +utility issues a warning and ignores the name. + +**paddr**=*value* specifies the physical ROM address at which this section should be located. This value overrides the section load address given by the linker. This value must be a decimal, octal, or hexadecimal constant. It can also be the word **boot** (to indicate a boot table section for use with a boot loader). *If your file contains multiple sections, and if one section uses a paddr parameter, then all sections must use a paddr parameter.* + +**boot** configures a section for loading by a boot loader. This is equivalent to using **paddr=boot**. Boot sections have a physical address determined by the location of the boot table. The origin of the boot table is specified with the --bootorg option. + +For more similarity with the linker's SECTIONS directive, you can use colons after the section names (in place of the equal sign on the keyboard). For example, the following statements are equivalent: + +``` +SECTIONS { .text: .data: boot } +SECTIONS { .text: .data = boot } +``` + +In the example below, the object file contains six initialized sections: .text, .data, .const, .coeff, and .tables. Suppose you want only .text and .data to be converted. Use a SECTIONS directive to specify this: + +``` +SECTIONS { .text: .data: } +``` + +To configure both of these sections for boot loading, add the boot keyword: + +``` +SECTIONS { .text = boot .data = boot } +``` + +## 12.7 The Load Image Format (--load\_image Option) + +A load image is an object file which contains the load addresses and initialized sections of one or more executable files. The load image object file can be used for ROM masking or can be relinked in a subsequent link step. + +### 12.7.1 Load Image Section Formation + +The load image sections are formed by collecting the initialized sections from the input executables. There are two ways the load image sections are formed: + +- **Using the ROMS Directive**. Each memory range that is given in the ROMS directive denotes a load image section. The romname is the section name. The origin and length parameters are required. The memwidth, romwidth, and files parameters are invalid and are ignored. + - When using the ROMS directive and the load\_image option, the --image option is required. +- **Default Load Image Section Formation**. If no ROMS directive is given, the load image sections are formed by combining contiguous initialized sections in the input executables. Sections with gaps smaller than the target word size are considered contiguous. + +The default section names are image\_1, image\_2, ... If another prefix is desired, the --section\_name\_prefix=*prefix* option can be used. + +### 12.7.2 Load Image Characteristics + +All load image sections are initialized data sections. In the absence of a ROMS directive, the load/run address of the load image section is the load address of the first input section in the load image section. If the SECTIONS directive was used and a different load address was given using the paddr parameter, this address will be used. + +The load image format always creates a single load image object file. The format of the load image object file is determined based on the input files. The file is not marked executable and does not contain an entry point. The default load image object file name is ti\_load\_image.obj. This can be changed using the --outfile option. Only one --outfile option is valid when creating a load image, all other occurrences are ignored. + +#### Concerning Load Image Format + +**NOTE:** These options are invalid when creating a load image: + +- --memwidth +- --romwidth +- --zero +- --byte + +If a boot table is being created, either using the SECTIONS directive or the --boot option, the ROMS directive must be used. + +## 12.8 Excluding a Specified Section + +The --exclude *section\_name* option can be used to inform the hex utility to ignore the specified section. If a SECTIONS directive is used, it overrides the --exclude option. + +For example, if a SECTIONS directive containing the section name *mysect* is used and an --exclude *mysect* is specified, the SECTIONS directive takes precedence and *mysect* is not excluded. + +The --exclude option has a limited wildcard capability. The \* character can be placed at the beginning or end of the name specifier to indicate a suffix or prefix, respectively. For example, --exclude sect\* disqualifies all sections that begin with the characters sect. + +If you specify the --exclude option on the command line with the \* wildcard, use quotes around the section name and wildcard. For example, --exclude"sect\*". Using quotes prevents the \* from being interpreted by the hex conversion utility. If --exclude is in a command file, do not use quotes. + +If multiple object files are given, the object file in which the section to be excluded can be given in the form oname(sname). If the object filename is not provided, all sections matching the section name are excluded. Wildcards cannot be used for the filename, but can appear within the parentheses. + +## 12.9 Assigning Output Filenames + +When the hex conversion utility translates your object file into a data format, it partitions the data into one or more output files. When multiple files are formed by splitting memory words into ROM words, *filenames are always assigned in order from least to most significant*, where bits in the memory words are numbered from right to left. This is true, regardless of target or endian ordering. + +The hex conversion utility follows this sequence when assigning output filenames: + +1. **It looks for the ROMS directive.** If a file is associated with a range in the ROMS directive and you have included a list of files (files = {. . .}) on that range, the utility takes the filename from the list. + +For example, assume that the target data is 32-bit words being converted to four files, each eight bits wide. To name the output files using the ROMS directive, you could specify: + +``` +ROMS +{ + RANGE1: romwidth=8, files={ xyz.b0 xyz.b1 xyz.b2 xyz.b3 } +} +``` + +The utility creates the output files by writing the least significant bits to xyz.b0 and the most significant bits to xyz.b3. + +2. **It looks for the --outfile options.** You can specify names for the output files by using the --outfile option. If no filenames are listed in the ROMS directive and you use --outfile options, the utility takes the filename from the list of --outfile options. The following line has the same effect as the example above using the ROMS directive: + +``` +--outfile=xyz.b0 --outfile=xyz.b1 --outfile=xyz.b2 --outfile=xyz.b3 +``` + +If both the ROMS directive and --outfile options are used together, the ROMS directive overrides the --outfile options. + +3. **It assigns a default filename.** If you specify no filenames or fewer names than output files, the utility assigns a default filename. A default filename consists of the base name from the input file plus a 2- to 3-character extension. The extension has three parts: + +- a. A format character, based on the output format (see Section 12.14): + - **a** for ASCII-Hex + - **i** for Intel + - **m** for Motorola-S + - **t** for TI-Tagged + - **x** for Tektronix +- b. The range number in the ROMS directive. Ranges are numbered starting with 0. If there is no ROMS directive, or only one range, the utility omits this character. +- c. The file number in the set of files for the range, starting with 0 for the least significant file. + +For example, assume a.out is for a 32-bit target processor and you are creating Intel format output. With no output filenames specified, the utility produces four output files named a.i0, a.i1, a.i2, a.i3. + +If you include the following ROMS directive when you invoke the hex conversion utility, you would have eight output files: + +``` +ROMS +{ + range1: o = 0x00001000 l = 0x1000 + range2: o = 0x00002000 l = 0x1000 +} +``` + +| These output files | Contain data in these locations | +|----------------------------|---------------------------------| +| a.i00, a.i01, a.i02, a.i03 | 0x00001000 through 0x00001FFF | +| a.i10, a.i11, a.i12, a.i13 | 0x00002000 through 0x00002FFF | + +## 12.10 Image Mode and the --fill Option + +This section points out the advantages of operating in image mode and describes how to produce output files with a precise, continuous image of a target memory range. + +### 12.10.1 Generating a Memory Image + +With the --image option, the utility generates a memory image by completely filling all of the mapped ranges specified in the ROMS directive. + +An object file consists of blocks of memory (sections) with assigned memory locations. Typically, all sections are not adjacent: there are holes between sections in the address space for which there is no data. When such a file is converted *without* the use of image mode, the hex conversion utility bridges these holes by using the address records in the output file to skip ahead to the start of the next section. In other words, there may be discontinuities in the output file addresses. Some EPROM programmers do not support address discontinuities. + +In image mode, there are no discontinuities*.* Each output file contains a continuous stream of data that corresponds exactly to an address range in target memory. Any holes before, between, or after sections are filled with a fill value that you supply. + +An output file converted by using image mode still has address records, because many of the hexadecimal formats require an address on each line. However, in image mode, these addresses are always contiguous. + +#### Defining the Ranges of Target Memory + +**NOTE:** If you use image mode, you must also use a ROMS directive. In image mode, each output file corresponds directly to a range of target memory. You must define the ranges. If you do not supply the ranges of target memory, the utility tries to build a memory image of the entire target processor address space. This is potentially a huge amount of output data. To prevent this situation, the utility requires you to explicitly restrict the address space with the ROMS directive. + +### 12.10.2 Specifying a Fill Value + +The --fill option specifies a value for filling the holes between sections. The fill value must be specified as an integer constant following the --fill option. The width of the constant is assumed to be that of a word on the target processor. For example, specifying --fill=0xFFFF results in a fill pattern of 0x0000FFFF. The constant value is not sign extended. + +The hex conversion utility uses a default fill value of 0 if you do not specify a value with the fill option. *The --fill option is valid only when you use --image*; otherwise, it is ignored. + +### 12.10.3 Steps to Follow in Using Image Mode + +- **Step 1:** Define the ranges of target memory with a ROMS directive. See Section 12.5. +- **Step 2:** Invoke the hex conversion utility with the --image option. You can optionally use the --zero option to reset the address origin to 0 for each output file. If you do not specify a fill value with the ROMS directive and you want a value other than the default of 0, use the --fill option. + +## 12.11 Array Output Format + +The --array option causes the output to be generated in C array format. In this format, data contained in initialized sections of an executable file are defined as C arrays. Output arrays may be compiled along with a host program and used to initialize the target at runtime. + +Arrays are formed by collecting the initialized sections from the input executable. There are two ways arrays are formed: + +- **With the ROMS directive.** Each memory range that is given in the ROMS directive denotes an array. The *romname* is used as the array name. The *origin* and *length* parameters of the ROM directive are required. The *memwidth*, *romwidth*, and *files* parameters are invalid and are ignored. +- **No ROMS directive (default).** If no ROMS directive is given, arrays are formed by combining initialized sections within each page, beginning with the first initialized section. Arrays will reflect any gaps that exist between sections. + +The default names for the arrays generated for test.out are test\_image\_0 and test\_image\_1. The --array:name\_prefix option can be used to override the default prefix for array names. For example, use --array:name\_prefix=myarray to cause the names for the arrays to be myarray\_0 and myarray\_1. + +The default data type for page0 array elements is uint32\_t. However, if the --array:page0\_type\_size=8 option is used, page0 array elements have a data type of uint8\_t. The data type for page1 array elements is always uint8\_t. + +## 12.12 Controlling the ROM Device Address + +The hex conversion utility output address field corresponds to the ROM device address. The EPROM programmer burns the data into the location specified by the hex conversion utility output file address field. The hex conversion utility offers some mechanisms to control the starting address in ROM of each section. However, many EPROM programmers offer direct control of the location in ROM in which the data is burned. + +The address field of the hex-conversion utility output file is controlled by the following items, which are listed from low to high priority: + +1. **The linker command file.** By default, the address field of the hex conversion utility output file is the load address (as given in the linker command file). +2. **The paddr parameter of the SECTIONS directive.** When the paddr parameter is specified for a section, the hex conversion utility bypasses the section load address and places the section in the address specified by paddr. +3. **The --zero option.** When you use the --zero option, the utility resets the address origin to 0 for each output file. Since each file starts at 0 and counts upward, any address records represent offsets from the beginning of the file (the address within the ROM) rather than actual target addresses of the data. You must use the --zero option in conjunction with the --image option to force the starting address in each output file to be zero. If you specify the --zero option without the --image option, the utility issues a warning and ignores the --zero option. +4. **The --byte option.** Some EPROM programmers may require the output file address field to contain a byte count rather than a word count. If you use the −byte option, the output file address increments once for each byte. For example, if the starting address is 0h, the first line contains eight words, and you use no −byte option, the second line would start at address 8 (8h). If the starting address is 0h, the first line contains eight words, and you use the −byte option, the second line would start at address 16 (010h). The data in both examples are the same; −byte affects only the calculation of the output file address field, not the actual target processor address of the converted data. + +The --byte option causes the address records in an output file to refer to byte locations within the file, whether the target processor is byte-addressable or not. + +## 12.13 Control Hex Conversion Utility Diagnostics + +The hex conversion utility uses certain C/C++ compiler options to control hex-converter-generated diagnostics. + +**--diag\_error**=*id* Categorizes the diagnostic identified by *id* as an error. To determine the numeric identifier of a diagnostic message, use the --display\_error\_number option first in a separate link. Then use --diag\_error=*id* to recategorize the diagnostic as an error. You can only alter the severity of discretionary diagnostics. + +**--diag\_remark**=*id* Categorizes the diagnostic identified by *id* as a remark. To determine the numeric identifier of a diagnostic message, use the --display\_error\_number option first in a separate link. Then use --diag\_remark=*id* to recategorize the diagnostic as a remark. You can only alter the severity of discretionary diagnostics. + +**--diag\_suppress**=*id* Suppresses the diagnostic identified by *id*. To determine the numeric identifier of a diagnostic message, use the --display\_error\_number option first in a separate link. Then use --diag\_suppress=*id* to suppress the diagnostic. You can only suppress discretionary diagnostics. + +**--diag\_warning**=*id* Categorizes the diagnostic identified by *id* as a warning. To determine the numeric identifier of a diagnostic message, use the --display\_error\_number option first in a separate link. Then use --diag\_warning=*id* to recategorize the diagnostic as a warning. You can only alter the severity of discretionary diagnostics. + +**--display\_error\_number** Displays a diagnostic's numeric identifier along with its text. Use this option in determining which arguments you need to supply to the diagnostic suppression options (--diag\_suppress, --diag\_error, --diag\_remark, and --diag\_warning). This option also indicates whether a diagnostic is discretionary. A discretionary diagnostic is one whose severity can be overridden. A discretionary diagnostic includes the suffix -D; otherwise, no suffix is present. See the *PRU Optimizing C/C++ Compiler User's Guide* for more information on understanding diagnostic messages. + +**--issue\_remarks** Issues remarks (nonserious warnings), which are suppressed by default. + +**--no\_warnings** Suppresses warning diagnostics (errors are still issued). + +**--set\_error\_limit**=*count* Sets the error limit to *count*, which can be any decimal value. The linker abandons linking after this number of errors. (The default is 100.) + +**--verbose\_diagnostics** Provides verbose diagnostics that display the original source with line-wrap and indicate the position of the error in the source line + +## 12.14 Description of the Object Formats + +The hex conversion utility has options that identify each format. Table 12-2 specifies the format options. They are described in the following sections. + +- You should use only one of these options on the command line. If you use more than one option, the last one you list overrides the others. +- The default format is Tektronix (--tektronix option). + +**Table 12-2. Options for Specifying Hex Conversion Formats** + +| Option | Alias | Format | Address Bits | Default Width | +|---------------|-------|-------------|--------------|---------------| +| --ascii | -a | ASCII-Hex | 16 | 8 | +| --intel | -i | Intel | 32 | 8 | +| --motorola=1 | -m1 | Motorola-S1 | 16 | 8 | +| --motorola=2 | -m2 | Motorola-S2 | 24 | 8 | +| --motorola=3 | -m3 | Motorola-S3 | 32 | 8 | +| --ti-tagged | -t | TI-Tagged | 16 | 16 | +| --ti_txt | | TI_TXT | 8 | 8 | +| --tektronix | -x | Tektronix | 32 | 8 | + +**Address bits** determine how many bits of the address information the format supports. Formats with 16 bit addresses support addresses up to 64K only. The utility truncates target addresses to fit in the number of available bits. + +The **default width** determines the default output width of the format. You can change the default width by using the --romwidth option or by using the romwidth parameter in the ROMS directive. You cannot change the default width of the TI-Tagged format, which supports a 16-bit width only. + +### 12.14.1 ASCII-Hex Object Format (--ascii Option) + +The ASCII-Hex object format supports 16-bit addresses. The format consists of a byte stream with bytes separated by spaces. Figure 12-6 illustrates the ASCII-Hex format. + +**Figure 12-6. ASCII-Hex Object Format** + +![Figure 12-6: ASCII-Hex Object Format — record layout showing nonprintable start code ^B, address field $AXXXXXXXX, data bytes, and nonprintable end code ^C](_page_272_Figure_14.jpeg) + +**Figure 12-6: ASCII-Hex Object Format.** Record format diagram. A file begins with a nonprintable start code (^B, ASCII STX, 02h) and ends with a nonprintable end code (^C, ASCII ETX, 03h). Address records use the form `$AXXXXXXXX` where XXXXXXXX is an 8-digit hexadecimal address. Data bytes follow the address field, each separated by spaces, shown as XX pairs. + +The file begins with an ASCII STX character (ctrl-B, 02h) and ends with an ASCII ETX character (ctrl-C, 03h). Address records are indicated with \$AXXXXXXXX, in which XXXXXXXX is a 8-digit (16-bit) hexadecimal address. The address records are present only in the following situations: + +- When discontinuities occur +- When the byte stream does not begin at address 0 + +You can avoid all discontinuities and any address records by using the --image and --zero options. This creates output that is simply a list of byte values. + +### 12.14.2 Intel MCS-86 Object Format (--intel Option) + +The Intel object format supports 16-bit addresses and 32-bit extended addresses. Intel format consists of a 9-character (4-field) prefix (which defines the start of record, byte count, load address, and record type), the data, and a 2-character checksum suffix. + +The 9-character prefix represents three record types: + +| Record Type | Description | +|-------------|--------------------------------| +| 00 | Data record | +| 01 | End-of-file record | +| 04 | Extended linear address record | + +Record type00, the data record, begins with a colon ( : ) and is followed by the byte count, the address of the first data byte, the record type (00), and the checksum. The address is the least significant 16 bits of a 32-bit address; this value is concatenated with the value from the most recent 04 (extended linear address) record to create a full 32-bit address. The checksum is the 2s complement (in binary form) of the preceding bytes in the record, including byte count, address, and data bytes. + +Record type 01, the end-of-file record, also begins with a colon ( : ), followed by the byte count, the address, the record type (01), and the checksum. + +Record type 04, the extended linear address record, specifies the upper 16 address bits. It begins with a colon ( : ), followed by the byte count, a dummy address of 0h, the record type (04), the most significant 16 bits of the address, and the checksum. The subsequent address fields in the data records contain the least significant bytes of the address. + +Figure 12-7 illustrates the Intel hexadecimal object format. + +**Figure 12-7. Intel Hexadecimal Object Format** + +![Figure 12-7: Intel Hexadecimal Object Format — sample records with labeled fields: start character colon, byte count, address, most significant 16 bits, record type, data, checksum, extended linear address record, and end-of-file record](_page_273_Figure_12.jpeg) + +**Figure 12-7: Intel Hexadecimal Object Format.** Sample Intel hex file records with labeled fields. Each record starts with a colon (:) start character followed by: byte count (2 hex digits), address (4 hex digits, with the most-significant 16 bits carried in an extended linear address record), record type (2 hex digits), data bytes, and a checksum (2 hex digits). Shown: an extended linear address record, two data records of 32 bytes each (:20...), and the end-of-file record (:00000001FF). + +### 12.14.3 Motorola Exorciser Object Format (--motorola Option) + +The Motorola S1, S2, and S3 formats support 16-bit, 24-bit, and 32-bit addresses, respectively. The formats consist of a start-of-file (header) record, data records, and an end-of-file (termination) record. Each record consists of five fields: record type, byte count, address, data, and checksum. The three record types are: + +| Record Type | Description | +|-------------|-----------------------------------------------------| +| S0 | Header record | +| S1 | Code/data record for 16-bit addresses (S1 format) | +| S2 | Code/data record for 24-bit addresses (S2 format) | +| S3 | Code/data record for 32-bit addresses (S3 format) | +| S7 | Termination record for 32-bit addresses (S3 format) | +| S8 | Termination record for 24-bit addresses (S2 format) | +| S9 | Termination record for 16-bit addresses (S1 format) | + +The byte count is the character pair count in the record, excluding the type and byte count itself. + +The checksum is the least significant byte of the 1s complement of the sum of the values represented by the pairs of characters making up the byte count, address, and the code/data fields. + +Figure 12-8 illustrates the Motorola-S object format. + +#### Figure 12-8. Motorola-S Format + +![Figure 12-8: Motorola-S Format — sample S-records with labeled fields: record type, address for S3 records, byte count, and checksum. Shows header, data, and termination records](_page_274_Figure_10.jpeg) + +**Figure 12-8: Motorola-S Format.** Sample Motorola-S object file records with labeled fields. Record type is a single character (S0 = header, S3 = data with 4-byte address, S7 = termination for S3 records). Fields: record type, byte count, address (for S3 records: 4 bytes), data, checksum. Example shows header record S0060000..., two 32-byte data records (S322... and S31A...), and termination record S7050000FA. + +### 12.14.4 Extended Tektronix Object Format (--tektronix Option) + +The Tektronix object format supports 32-bit addresses and has two types of records: + +**Data records** contains the header field, the load address, and the object code. + +**Termination records** signifies the end of a module. + +The header field in the data record contains the following information: + +| Item | Number of ASCII
Characters | Description | +|--------------|-------------------------------|---------------------------------------------------------------------------------------------------| +| % | 1 | Data type is Tektronix format | +| Block length | 2 | Number of characters in the record, minus the % | +| Block type | 1 | 6 = data record
8 = termination record | +| Checksum | 2 | A 2-digit hex sum modulo 256 of all values in the record except the % and the
checksum itself. | + +The load address in the data record specifies where the object code will be located. The first digit specifies the address length; this is always 8. The remaining characters of the data record contain the object code, two characters per byte. + +Figure 12-9 illustrates the Tektronix object format. + +![Figure 12-9 title label: Extended Tektronix Object Format](_page_275_Figure_11.jpeg) + +![Figure 12-9: Extended Tektronix Object Format — record layout showing header character %, block type, length of load address, load address, object code, block length, and checksum](_page_275_Figure_12.jpeg) + +**Figure 12-9: Extended Tektronix Object Format.** Record format diagram. Each record begins with a header character (%). Fields: block type (6 = data), length of load address, load address (e.g., 10000000h), object code bytes, block length (e.g., 1Ah = 26), and checksum. Example record: %1562181000000002020202020200 with annotated checksum calculation (21h). + +### 12.14.5 Texas Instruments SDSMAC (TI-Tagged) Object Format (--ti\_tagged Option) + +The Texas Instruments SDSMAC (TI-Tagged) object format supports 16-bit addresses, including start-offile record, data records, and end-of-file record. Each data records consists of a series of small fields and is signified by a tag character: + +| Tag Character | Description | +|---------------|-------------------------------------------| +| K | Followed by the program identifier | +| 7 | Followed by a checksum | +| 8 | Followed by a dummy checksum (ignored) | +| 9 | Followed by a 16-bit load address | +| B | Followed by a data word (four characters) | +| F | Identifies the end of a data record | +| * | Followed by a data byte (two characters) | + +Figure 12-10 illustrates the tag characters and fields in TI-Tagged object format. + +![Figure 12-10 title label: TI-Tagged Object Format](_page_276_Figure_7.jpeg) + +![Figure 12-10: TI-Tagged Object Format — sample records with labeled fields: start-of-file record, program identifier, load address, tag characters, data words, checksum, and end-of-file record](_page_276_Figure_8.jpeg) + +**Figure 12-10: TI-Tagged Object Format.** Sample TI-Tagged (SDSMAC) object file records with labeled fields. The start-of-file record begins with K. Fields include: program identifier, load address, tag characters interspersed with data words, and a checksum. Three data records are shown (e.g., K0000COFFTOTI90000BFFFFBFFFF...). The end-of-file record is a colon (:). Checksum is the 2s complement of the sum of ASCII values from the first tag character to the checksum tag character. + +If any data fields appear before the first address, the first field is assigned address 0000h. Address fields may be expressed but not required for any data byte. The checksum field, preceded by the tag character 7, is the 2s complement of the sum of the 8-bit ASCII values of characters, beginning with the first tag character and ending with the checksum tag character (7 or 8). The end-of-file record is a colon ( : ). + +### 12.14.6 TI-TXT Hex Format (--ti\_txt Option) + +The TI-TXT hex format supports 16-bit hexadecimal data. It consists of section start addresses, data byte, and an end-of-file character. These restrictions apply: + +- The number of sections is unlimited. +- Each hexadecimal start address must be even. +- Each line must have 16 data bytes, except the last line of a section. +- Data bytes are separated by a single space. +- The end-of-file termination tag q is mandatory. + +The data record contains the following information: + +| Item | Description | +|-------|----------------------------------------| +| @ADDR | Hexadecimal start address of a section | +| DATAn | Hexadecimal data byte | +| q | End-of-file termination character | + +#### Figure 12-11. TI-TXT Object Format + +``` +@ADDR1 + DATA01 DATA02 ........ DATA16 + DATA17 DATA32 ........ DATA32 + DATAm ........ DATAn + @ADDR2 + DATA01 .................... DATAn + q + Section + start + End-of-line + character + Data + bytes + Data + bytes +Section + start +``` + +#### Example 12-3. TI-TXT Object Format + +``` +@F000 +31 40 00 03 B2 40 80 5A 20 01 D2 D3 22 00 D2 E3 +21 00 3F 40 E8 FD 1F 83 FE 23 F9 3F +@FFFE +00 F0 +Q +``` + +# 13 Sharing C/C++ Header Files With Assembly Source + +You can use the .cdecls assembler directive to share C headers containing declarations and prototypes between C and assembly code. Any legal C/C++ can be used in a .cdecls block and the C/C++ declarations will cause suitable assembly to be generated automatically, allowing you to reference the C/C++ constructs in assembly code. + +**Topic** ........................................................................................................................... **Page** + +| 13.1 | Overview of the .cdecls Directive | 280 | +|------|-----------------------------------|-----| +| 13.2 | Notes on C/C++ Conversions | 280 | +| 13.3 | Notes on C++ Specific Conversions | 284 | +| 13.4 | Special Assembler Support | 285 | +| | | | + +## 13.1 Overview of the .cdecls Directive + +The .cdecls directive allows programmers in mixed assembly and C/C++ environments to share C headers containing declarations and prototypes between the C and assembly code. Any legal C/C++ can be used in a .cdecls block and the C/C++ declarations will cause suitable assembly to be generated automatically. This allows the programmer to reference the C/C++ constructs in assembly code — calling functions, allocating space, and accessing structure members — using the equivalent assembly mechanisms. While function and variable definitions are ignored, most common C/C++ elements are converted to assembly: enumerations, (non function-like) macros, function and variable prototypes, structures, and unions. + +See the .cdecls directive description for details on the syntax of the .cdecls assembler directive. + +The .cdecls directive can appear anywhere in an assembly source file, and can occur multiple times within a file. However, the C/C++ environment created by one .cdecls is **not** inherited by a later .cdecls; the C/C++ environment starts over for each .cdecls instance. + +For example, the following code causes the warning to be issued: + +``` +.cdecls C,NOLIST +%{ + #define ASMTEST 1 +%} +.cdecls C,NOLIST +%{ + #ifndef ASMTEST + #warn "ASMTEST not defined!" /* will be issued */ + #endif +%} +``` + +Therefore, a typical use of the .cdecls block is expected to be a single usage near the beginning of the assembly source file, in which all necessary C/C++ header files are included. + +Use the compiler --include\_path=*path* options to specify additional include file paths needed for the header files used in assembly, as you would when compiling C files. + +Any C/C++ errors or warnings generated by the code of the .cdecls are emitted as they normally would for the C/C++ source code. C/C++ errors cause the directive to fail, and any resulting converted assembly is not included. + +C/C++ constructs that cannot be converted, such as function-like macros or variable definitions, cause a comment to be output to the converted assembly file. For example: + +``` +; ASM HEADER WARNING - variable definition 'ABCD' ignored +``` + +The prefix ASM HEADER WARNING appears at the beginning of each message. To see the warnings, either the WARN parameter needs to be specified so the messages are displayed on STDERR, or else the LIST parameter needs to be specified so the warnings appear in the listing file, if any. + +Finally, note that the converted assembly code does not appear in the same order as the original C/C++ source code and C/C++ constructs may be simplified to a normalized form during the conversion process, but this should not affect their final usage. + +## 13.2 Notes on C/C++ Conversions + +The following sections describe C and C++ conversion elements that you need to be aware of when sharing header files with assembly source. + +### 13.2.1 Comments + +Comments are consumed entirely at the C level, and do not appear in the resulting converted assembly file. + +### 13.2.2 Conditional Compilation (#if/#else/#ifdef/etc.) + +Conditional compilation is handled entirely at the C level during the conversion step. Define any necessary macros either on the command line (using the compiler --define=*name*=*value* option) or within a .cdecls block using #define. The #if, #ifdef, etc. C/C++ directives are **not** converted to assembly .if, .else, .elseif, and .endif directives. + +### 13.2.3 Pragmas + +Pragmas found in the C/C++ source code cause a warning to be generated as they are not converted. They have no other effect on the resulting assembly file. See the .cdecls topic for the WARN and NOWARN parameter discussion for where these warnings are created. + +### 13.2.4 The #error and #warning Directives + +These preprocessor directives are handled completely by the compiler during the parsing step of conversion. If one of these directives is encountered, the appropriate error or warning message is emitted. These directives are not converted to .emsg or .wmsg in the assembly output. + +### 13.2.5 Predefined symbol \_ \_ASM\_HEADER\_ \_ + +The C/C++ macro \_ \_ASM\_HEADER\_ \_ is defined in the compiler while processing code within .cdecls. This allows you to make changes in your code, such as not compiling definitions, during the .cdecls processing. + +**Be Careful With the \_ \_ASM\_HEADER\_ \_ Macro** + +**NOTE:** You must be very careful not to use this macro to introduce any changes in the code that could result in inconsistencies between the code processed while compiling the C/C++ source and while converting to assembly. + +### 13.2.6 Usage Within C/C++ asm( ) Statements + +The .cdecls directive is not allowed within C/C++ asm( ) statements and will cause an error to be generated. + +### 13.2.7 The #include Directive + +The C/C++ #include preprocessor directive is handled transparently by the compiler during the conversion step. Such #includes can be nested as deeply as desired as in C/C++ source. The assembly directives .include and .copy are not used or needed within a .cdecls. Use the command line --include\_path option to specify additional paths to be searched for included files, as you would for C compilation. + +### 13.2.8 Conversion of #define Macros + +Only object-like macros are converted to assembly. Function-like macros have no assembly representation and so cannot be converted. Pre-defined and built-in C/C++ macros are not converted to assembly (i.e., \_\_FILE\_\_, \_\_TIME\_\_, \_\_TI\_COMPILER\_VERSION\_\_, etc.). For example, this code is converted to assembly because it is an object-like macro: + +``` +#define NAME Charley +``` + +This code is not converted to assembly because it is a function-like macro: + +``` +#define MAX(x,y) (x>y ? x : y) +``` + +Some macros, while they are converted, have no functional use in the containing assembly file. For example, the following results in the assembly substitution symbol FOREVER being set to the value while(1), although this has no useful use in assembly because while(1) is not legal assembly code. + +``` +#define FOREVER while(1) +``` + +Macro values are **not** interpreted as they are converted. For example, the following results in the assembler substitution symbol OFFSET being set to the literal string value 5+12 and **not** the value 17. This happens because the semantics of the C/C++ language require that macros are evaluated in context and not when they are parsed. + +``` +#define OFFSET 5+12 +``` + +Because macros in C/C++ are evaluated in their usage context, C/C++ printf escape sequences such as \n are not converted to a single character in the converted assembly macro. See Section 13.2.11 for suggestions on how to use C/C++ macro strings. + +Macros are converted using the .define directive (see Section 13.4.2), which functions similarly to the .asg assembler directive. The exception is that .define disallows redefinitions of register symbols and mnemonics to prevent the conversion from corrupting the basic assembly environment. To remove a macro from the assembly scope, .undef can be used following the .cdecls that defines it (see Section 13.4.3). + +The macro functionality of # (stringize operator) is only useful within functional macros. Since functional macros are not supported by this process, # is not supported either. The concatenation operator ## is only useful in a functional context, but can be used degenerately to concatenate two strings and so it is supported in that context. + +### 13.2.9 The #undef Directive + +Symbols undefined using the #undef directive before the end of the .cdecls are not converted to assembly. + +### 13.2.10 Enumerations + +Enumeration members are converted to .enum elements in assembly. For example: + +``` +enum state { ACTIVE=0x10, SLEEPING=0x01, INTERRUPT=0x100, POWEROFF, LAST}; +``` + +is converted to the following assembly code: + +``` +state .enum +ACTIVE .emember 16 +SLEEPING .emember 1 +NTERRUPT .emember 256 +POWEROFF .emember 257 +LAST .emember 258 + .endenum +``` + +The members are used via the pseudo-scoping created by the .enum directive. + +The usage is similar to that for accessing structure members, enum\_name.member. + +This pseudo-scoping is used to prevent enumeration member names from corrupting other symbols within the assembly environment. + +### 13.2.11 C Strings + +Because C string escapes such as \n and \t are not converted to hex characters 0x0A and 0x09 until their use in a string constant in a C/C++ program, C macros whose values are strings cannot be represented as expected in assembly substitution symbols. For example: + +``` +#define MSG "\tHI\n" +becomes, in assembly: +.define """\tHI\n""",MSG ; 6 quoted characters! not 5! +``` + +When used in a C string context, you expect this statement to be converted to 5 characters (tab, H, I, newline, NULL), but the .string assembler directive does not know how to perform the C escape conversions. + +You can use the .cstring directive to cause the escape sequences and NULL termination to be properly handled as they would in C/C++. Using the above symbol MSG with a .cstring directive results in 5 characters of memory being allocated, the same characters as would result if used in a C/C++ strong context. (See Section 13.4.7 for the .cstring directive syntax.) + +### 13.2.12 C/C++ Built-In Functions + +The C/C++ built-in functions, such as sizeof( ), are not translated to their assembly counterparts, if any, if they are used in macros. Also, their C expression values are not inserted into the resulting assembly macro because macros are evaluated in context and there is no active context when converting the macros to assembly. + +Suitable functions such as \$sizeof( ) are available in assembly expressions. However, as the basic types such as int/char/float have no type representation in assembly, there is no way to ask for \$sizeof(int), for example, in assembly. + +### 13.2.13 Structures and Unions + +C/C++ structures and unions are converted to assembly .struct and .union elements. Padding and ending alignments are added as necessary to make the resulting assembly structure have the same size and member offsets as the C/C++ source. The primary purpose is to allow access to members of C/C++ structures, as well as to facilitate debugging of the assembly code. For nested structures, the assembly .tag feature is used to refer to other structures/unions. + +The alignment is also passed from the C/C++ source so that the assembly symbol is marked with the same alignment as the C/C++ symbol. (See Section 13.2.3 for information about pragmas, which may attempt to modify structures.) Because the alignment of structures is stored in the assembly symbol, builtin assembly functions like \$sizeof( ) and \$alignof( ) can be used on the resulting structure name symbol. + +When using unnamed structures (or unions) in typedefs, such as: + +``` +typedef struct { int a_member; } mystrname; +``` + +This is really a shorthand way of writing: + +``` +struct temporary_name { int a_member; }; +typedef temporary_name mystrname; +``` + +The conversion processes the above statements in the same manner: generating a temporary name for the structure and then using .define to output a typedef from the temporary name to the user name. You should use your *mystrname* in assembly the same as you would in C/C++, but do not be confused by the assembly structure definition in the list, which contains the temporary name. You can avoid the temporary name by specifying a name for the structure, as in: + +``` +typedef struct a_st_name { ... } mystrname; +``` + +If a shorthand method is used in C to declare a variable with a particular structure, for example: + +``` +extern struct a_name { int a_member; } a_variable; +``` + +Then after the structure is converted to assembly, a .tag directive is generated to declare the structure of the external variable, such as: + +``` +_a_variable .tag a_st_name +``` + +This allows you to refer to \_a\_variable.a\_member in your assembly code. + +### 13.2.14 Function/Variable Prototypes + +Non-static function and variable prototypes (not definitions) will result in a .global directive being generated for each symbol found. + +See Section 13.3.1 for C++ name mangling issues. + +Function and variable definitions will result in a warning message being generated (see the WARN/NOWARN parameter discussion for where these warnings are created) for each, and they will not be represented in the converted assembly. + +The assembly symbol representing the variable declarations will not contain type information about those symbols. Only a .global will be issued for them. Therefore, it is your responsibility to ensure the symbol is used appropriately. + +See Section 13.2.13 for information on variables names which are of a structure/union type. + +### 13.2.15 C Constant Suffixes + +The C constant suffixes u, l, and f are passed to the assembly unchanged. The assembler will ignore these suffixes if used in assembly expressions. + +### 13.2.16 Basic C/C++ Types + +Only complex types (structures and unions) in the C/C++ source code are converted to assembly. Basic types such as int, char, or float are not converted or represented in assembly beyond any existing .int, .char, .float, etc. directives that previously existed in assembly. + +Typedefs of basic types are therefore also not represented in the converted assembly. + +## 13.3 Notes on C++ Specific Conversions + +The following sections describe C++ specific conversion elements that you need to be aware of when sharing header files with assembly source. + +### 13.3.1 Name Mangling + +Symbol names may be mangled in C++ source files. When mangling occurs, the converted assembly will use the mangled names to avoid symbol name clashes. You can use the demangler (dempru) to demangle names and identify the correct symbols to use in assembly. + +To defeat name mangling in C++ for symbols where polymorphism (calling a function of the same name with different kinds of arguments) is not required, use the following syntax: + +``` +extern "C" void somefunc(int arg); +``` + +The above format is the short method for declaring a single function. To use this method for multiple functions, you can also use the following syntax: + +``` +extern "C" + { + void somefunc(int arg); + int anotherfunc(int arg); + ... + } +``` + +### 13.3.2 Derived Classes + +Derived classes are only partially supported when converting to assembly because of issues related to C++ scoping which does not exist in assembly. The greatest difference is that base class members do not automatically become full (top-level) members of the derived class. For example: + +``` +---------------------------------------------------------- + class base + { + public: + int b1; + }; + class derived : public base + { + public: + int d1; + } +``` + +In C++ code, the class derived would contain both integers b1 and d1. In the converted assembly structure "derived", the members of the base class must be accessed using the name of the base class, such as derived.\_\_b\_base.b1 rather than the expected derived.b1. + +A non-virtual, non-empty base class will have \_\_b\_ prepended to its name within the derived class to signify it is a base class name. That is why the example above is derived.\_\_b\_base.b1 and not simply derived.base.b1. + +### 13.3.3 Templates + +No support exists for templates. + +### 13.3.4 Virtual Functions + +No support exists for virtual functions, as they have no assembly representation. + +## 13.4 Special Assembler Support + +### 13.4.1 Enumerations (.enum/.emember/.endenum) + +The following directives support a pseudo-scoping for enumerations: + +*ENUM\_NAME* **.enum** + +*MEMBER1* **.emember** [*value*] + +*MEMBER2* **.emember** [*value*] + +... + +**.endenum** + +The **.enum** directive begins the enumeration definition and **.endenum** terminates it. + +The enumeration name (*ENUM\_NAME*) cannot be used to allocate space; its size is reported as zero. + +The format to use the value of a member is *ENUM\_NAME.MEMBER*, similar to a structure member usage. + +The **.emember** directive optionally accepts the value to set the member to, just as in C/C++. If not specified, the member takes a value one more than the previous member. As in C/C++, member names cannot be duplicated, although values can be. Unless specified with .emember, the first enumeration member will be given the value 0 (zero), as in C/C++. + +The .endenum directive cannot be used with a label, as structure .endstruct directives can, because the .endenum directive has no value like the .endstruct does (containing the size of the structure). + +Conditional compilation directives (.if/.else/.elseif/.endif) are the only other non-enumeration code allowed within the .enum/.endenum sequence. + +### 13.4.2 The .define Directive + +The .define directive functions in the same manner as the .asg directive, except that .define disallows creation of a substitution symbol that has the same name as a register symbol or mnemonic. It does not create a new symbol name space in the assembler, rather it uses the existing substitution symbol name space. The syntax for the directive is: + +**.define** *substitution string* **,** *substitution symbol name* + +The .define directive is used to prevent corruption of the assembly environment when converting C/C++ headers. + +### 13.4.3 The .undefine/.unasg Directives + +The .undef directive is used to remove the definition of a substitution symbol created using .define or .asg. This directive will remove the named symbol from the substitution symbol table from the point of the .undef to the end of the assembly file. The syntax for these directives is: + +**.undefine** *substitution symbol name* + +**.unasg** *substitution symbol name* + +This can be used to remove from the assembly environment any C/C++ macros that may cause a problem. + +Also see Section 13.4.2, which covers the .define directive. + +### 13.4.4 The \$defined( ) Built-In Function + +The \$defined directive returns true/1 or false/0 depending on whether the name exists in the current substitution symbol table or the standard symbol table. In essence \$defined returns TRUE if the assembler has any user symbol in scope by that name. This differs from \$isdefed in that \$isdefed only tests for NON-substitution symbols. The syntax is: + +**\$defined(** *substitution symbol name* **)** + +A statement such as ".if \$defined(macroname)" is then similar to the C code "#ifdef macroname". + +See Section 13.4.2 and Section 13.4.3 for the use of .define and .undef in assembly. + +### 13.4.5 The \$sizeof Built-In Function + +The assembly built-in function \$sizeof( ) can be used to query the size of a structure in assembly. It is an alias for the already existing \$structsz( ). The syntax is: + +**\$sizeof(** *structure name* **)** + +The \$sizeof function can then be used similarly to the C built-in function sizeof( ). + +The assembler's \$sizeof( ) built-in function cannot be used to ask for the size of basic C/C++ types, such as \$sizeof(int), because those basic type names are not represented in assembly. Only complex types are converted from C/C++ to assembly. + +Also see Section 13.2.12, which notes that this conversion does not happen automatically if the C/C++ sizeof( ) built-in function is used within a macro. + +### 13.4.6 Structure/Union Alignment and \$alignof( ) + +The assembly .struct and .union directives take an optional second argument which can be used to specify a minimum alignment to be applied to the symbol name. This is used by the conversion process to pass the specific alignment from C/C++ to assembly. + +The assembly built-in function \$alignof( ) can be used to report the alignment of these structures. This can be used even on assembly structures, and the function will return the minimum alignment calculated by the assembler. + +### 13.4.7 The .cstring Directive + +You can use the .cstring directive to cause the escape sequences and NULL termination to be properly handled as they would in C/C++. + +``` +.cstring "String with C escapes.\nWill be NULL terminated.\012" +``` + +See Section 13.2.11 for more information on the .cstring directive. + +# A Symbolic Debugging Directives + +The assembler supports several directives that the PRU C/C++ compiler uses for symbolic debugging. + +These directives are not meant for use by assembly-language programmers. They require arguments that can be difficult to calculate manually, and their usage must conform to a predetermined agreement between the compiler, the assembler, and the debugger. This appendix documents these directives for informational purposes only. + +**Topic** ........................................................................................................................... **Page** + +| A.1 | DWARF Debugging Format | 288 | +|-----|------------------------|-----| +| A.2 | Debug Directive Syntax | 288 | + +## A.1 DWARF Debugging Format + +A subset of the DWARF symbolic debugging directives are always listed in the assembly language file that the compiler creates for program analysis purposes. To list the complete set used for full symbolic debug, invoke the compiler with the --symdebug:dwarf option, as shown below: + +``` +clpru --symdebug:dwarf --keep_asm input_file +``` + +The --keep\_asm option instructs the compiler to retain the generated assembly file. + +To disable the generation of all symbolic debug directives, invoke the compiler with the --symdebug:none option: + +``` +clpru --symdebug:none --keep_asm input_file +``` + +The DWARF debugging format consists of the following directives: + +- The **.dwtag** and **.dwendtag** directives define a Debug Information Entry (DIE) in the .debug\_info section. +- The **.dwattr** directive adds an attribute to an existing DIE. +- The **.dwpsn** directive identifies the source position of a C/C++ statement. +- The **.dwcie** and **.dwendentry** directives define a Common Information Entry (CIE) in the .debug\_frame section. +- The **.dwfde** and **.dwendentry** directives define a Frame Description Entry (FDE) in the .debug\_frame section. +- The **.dwcfi** directive defines a call frame instruction for a CIE or FDE. + +## A.2 Debug Directive Syntax + +Table A-1 is an alphabetical listing of the symbolic debugging directives. For information on the C/C++ compiler, refer to the *PRU Optimizing C/C++ Compiler User's Guide.* + +**Table A-1. Symbolic Debugging Directives** + +| Label | Directive | Arguments | +|-----------|-------------|-----------------------------------------------------------------------------------------------------------| +| | .dwattr | DIE label , DIE attribute name ( DIE attribute value )[, DIE attribute name ( attribute value ) [,] | +| | .dwcfi | call frame instruction opcode[, operand[, operand]] | +| CIE label | .dwcie | version , return address register | +| | .dwendentry | | +| | .dwendtag | | +| | .dwfde | CIE label | +| | .dwpsn | " filename ", line number , column number | +| DIE label | .dwtag | DIE tag name , DIE attribute name ( DIE attribute value )[, DIE attribute name ( attribute value )
[,] | + +# B XML Link Information File Description + +The PRU linker supports the generation of an XML link information file via the --xml\_link\_info *file* option. This option causes the linker to generate a well-formed XML file containing detailed information about the result of a link. The information included in this file includes all of the information that is currently produced in a linker-generated map file. + +As the linker evolves, the XML link information file may be extended to include additional information that could be useful for static analysis of linker results. + +This appendix enumerates all of the elements that are generated by the linker into the XML link information file. + +**Topic** ........................................................................................................................... **Page** + +| B.1 | XML Information File Element Types | 290 | +|-----|------------------------------------|-----| +| B.2 | Document Elements | 290 | + +## B.1 XML Information File Element Types + +These element types will be generated by the linker: + +- **Container elements** represent an object that contains other elements that describe the object. Container elements have an id attribute that makes them accessible from other elements. +- **String elements** contain a string representation of their value. +- **Constant elements** contain a 32-bit unsigned long representation of their value (with a 0x prefix). +- **Reference elements** are empty elements that contain an idref attribute that specifies a link to another container element. + +In Section B.2, the element type is specified for each element in parentheses following the element description. For instance, the element lists the time of the link execution (string). + +## B.2 Document Elements + +The root element, or the document element, is ****. All other elements contained in the XML link information file are children of the element. The following sections describe the elements that an XML information file can contain. + +### B.2.1 Header Elements + +The first elements in the XML link information file provide general information about the linker and the link session: + +- The **** element lists the name of the executable and the version information (string). +- The **** element lists the TI copyright information (string). +- The **** is a timestamp representation of the link time (unsigned 32-bit int). +- The **** element lists the name of the linked output file generated (string). +- The **** element specifies the program entry point, as determined by the linker (container) with two entries: + - The **** is the entry point symbol name, if any (string). + - The **
** is the entry point address (constant). + +#### Example B-1. Header Element for the hi.out Output File + +``` +PRU Linker Version x.xx +Copyright (c) 2012-2014 Texas Instruments Incorporated +0x43dfd8a4 +hi.out + + _c_int00 +
0xaf80
+
+``` + +### B.2.2 Input File List + +The next section of the XML link information file is the input file list, which is delimited with a **** container element. The can contain any number of elements. + +Each **** instance specifies the input file involved in the link. Each has an id attribute that can be referenced by other elements, such as an . An is a container element enclosing the following elements: + +- The **** element names a directory path, if applicable (string). +- The **** element specifies a file type, either archive or object (string). +- The **** element specifies an archive name or filename (string). +- The **** element specifies an object file name, or archive member name (string). + +#### Example B-2. Input File List for the hi.out Output File + +``` + + + object + hi.obj + hi.obj + + + /tools/lib/ + archive + rtsxxx.lib + boot.obj + + + /tools/lib/ + archive + rtsxxx.lib + exit.obj + + + /tools/lib/ + archive + rtsxxx.lib + printf.obj + +... + +``` + +### B.2.3 Object Component List + +The next section of the XML link information file contains a specification of all of the object components that are involved in the link. An example of an object component is an input section. In general, an object component is the smallest piece of object that can be manipulated by the linker. + +The **** is a container element enclosing any number of elements. + +Each **** specifies a single object component. Each has an id attribute so that it can be referenced directly from other elements, such as a . An is a container element enclosing the following elements: + +- The **** element names the object component (string). +- The **** element specifies the load-time address of the object component (constant). +- The **** element specifies the run-time address of the object component (constant). +- The **** element specifies the size of the object component (constant). +- The **** element specifies the source file where the object component originated (reference). + +#### Example B-3. Object Component List for the fl-4 Input File + +``` + + .text + 0xac00 + 0xac00 + 0xc0 + + + + .data + 0x80000000 + 0x80000000 + 0x0 + + + + .bss + 0x80000000 + 0x80000000 + 0x0 + + +``` + +### B.2.4 Logical Group List + +The **** section of the XML link information file is similar to the output section listing in a linker-generated map file. However, the XML link information file contains a specification of GROUP and UNION output sections, which are not represented in a map file. There are three kinds of list items that can occur in a : + +- The **** is the specification of a section or GROUP that contains a list of object components or logical group members. Each element is given an id so that it may be referenced from other elements. Each is a container element enclosing the following elements: + - The **** element names the logical group (string). + - The **** element specifies the load-time address of the logical group (constant). + - The **** element specifies the run-time address of the logical group (constant). + - The **** element specifies the size of the logical group (constant). + - The **** element lists elements contained in this logical group (container). These elements refer to each of the member objects contained in this logical group: + - The **** is an object component that is contained in this logical group (reference). + - The **** is a logical group that is contained in this logical group (reference). +- The **** is a special kind of logical group that represents a UNION, or a set of objects that share the same memory space (container). Each element is given an id so that it may be referenced from other elements (like from an element in the placement map). Each contains the following elements: + - The **** element names the overlay (string). + - The **** element specifies the run-time address of overlay (constant). + - The **** element specifies the size of logical group (constant). + - The **** container element lists elements contained in this overlay. These elements refer to each of the member objects contained in this logical group: + - The **** is an object component that is contained in this logical group (reference). + - The **** is a logical group that is contained in this logical group (reference). +- The **** is another special kind of logical group that represents a collection of logical groups that is split among multiple memory areas. Each element is given an id so that it may be referenced from other elements. The id consists of the following elements. + - The **** element names the split section (string). + - The **** container element lists elements contained in this split section. The elements refer to each of the member objects contained in this split section, and each element referenced is a logical group that is contained in this split section (reference). + +#### Example B-4. Logical Group List for the fl-4 Input File + +``` + + ... + + .text + 0x20 + 0x20 + 0xb240 + + + + + ... + + + ... + + UNION_1 + 0xb600 + 0xc0 + + + + + + ... + + .task_scn + 0x120 + + + + + ... + +``` + +### B.2.5 Placement Map + +The **** element describes the memory placement details of all named memory areas in the application, including unused spaces between logical groups that have been placed in a particular memory area. + +The **** is a description of the placement details within a named memory area (container). The description consists of these items: + +- The **** names the memory area (string). +- The **** gives the id of the memory page in which this memory area is defined (constant). +- The **** specifies the beginning address of the memory area (constant). +- The **** specifies the length of the memory area (constant). +- The **** specifies the amount of allocated space in this area (constant). +- The **** specifies the amount of available space in this area (constant). +- The **** lists the RWXI attributes that are associated with this area, if any (string). +- The **** specifies the fill value that is to be placed in unused space, if the fill directive is specified with the memory area (constant). +- The **** lists details of each allocated or available fragment in this memory area. If the fragment is allocated to a logical group, then a element is provided to facilitate access to the details of that logical group. All fragment specifications include and elements. + - The **** element provides details of an allocated fragment within this memory area (container): + - The **** specifies the address of the fragment (constant). + - The **** specifies the size of the fragment (constant). + - The **** provides a reference to the logical group that is allocated to this fragment (reference). + - The **** specifies the address of the fragment (constant). + - The **** specifies the size of the fragment (constant). + +#### Example B-5. Placement Map for the fl-4 Input File + +``` + + + PMEM + 0x0 + 0x20 + 0x100000 + 0xb240 + 0xf4dc0 + RWXI + + + 0x20 + 0xb240 + + + + 0xb260 + 0xf4dc0 + + + + ... + +``` + +### B.2.6 Symbol Table + +The **** contains a list of all of the global symbols that are included in the link. The list provides information about a symbol's name and value. In the future, the symbol\_table list may provide type information, the object component in which the symbol is defined, storage class, etc. + +The **** is a container element that specifies the name and value of a symbol with these elements: + +- The **** element specifies the symbol name (string). +- The **** element specifies the symbol value (constant). + +#### Example B-6. Symbol Table for the fl-4 Input File + +``` + + + _c_int00 + 0xaf80 + + + _main + 0xb1e0 + + + _printf + 0xac00 + + ... + +``` + +# C Hex Conversion Utility Examples + +The flexible hex conversion utility offers many options and capabilities. Once you understand the proper ways to configure your EPROM system and the requirements of the EPROM programmer, you will find that converting a file for a specific application is easy. + +The three scenarios in this appendix show how to develop a hex conversion command file for avoiding holes, using 16-BIS (16-bit instruction set) code, and using multiple-EPROM systems. The scenarios use this assembly code: + +``` +*************************************************** +* Assemble two words into section "secA" * +*************************************************** + + .sect "secA" + .word 012345678h + .word 0abcd1234h + +*************************************************** +* Assemble two words into section "secB" * +*************************************************** + + .sect "secB" + .word 087654321h + .word 04321dcbah +``` + +Before you use this appendix, read Chapter 12 to understand how to use the hex conversion utility. + +| C.1 | Scenario 1: Building a Hex Conversion Command File for a Single 8-Bit EPROM | 298 | +|-----|-----------------------------------------------------------------------------|-----| +| C.2 | Scenario 2: Building a Hex Conversion Command File for 16-BIS Code | 302 | +| C.3 | Scenario 3: Building a Hex Conversion Command File for Two 8-Bit EPROMs | 305 | + +## C.1 Scenario 1: Building a Hex Conversion Command File for a Single 8-Bit EPROM + +Scenario 1 shows how to build the hex conversion command file for converting an object file for the memory system shown in Figure C-1. In this system, there is one external 128K × 8-bit EPROM interfacing with a TMS470 target processor. + +**Figure C-1. EPROM Memory System for Scenario 1** + +![Figure C-1: EPROM Memory System for Scenario 1 — ARM CPU (32-bit) connected to a 128K x 8-bit ROM0 with 8-bit ROM width and 8-bit EPROM system memory width](_page_297_Figure_6.jpeg) + +**Figure C-1: EPROM Memory System for Scenario 1.** Block diagram showing an ARM CPU (width: 32 bits) connected to a single 128K × 8 ROM0. ROM width: 8 bits; EPROM system memory width: 8 bits. + +A object file consists of blocks of memory (sections) with assigned memory locations. Typically, all sections are not adjacent: there are holes between sections in the address space for which there is no data. Scenario 1 shows how you can use the hex conversion utility's image mode to fill any holes before, between, or after sections with a fill value. + +For this scenario, the application code resides in the program memory (ROM) on the TMS470 CPU, but the data tables used by this code reside in an off-chip EPROM. + +The circuitry of the target board handles the access to the data; the native TMS470 address of 0x1000 accesses location 0x0 on the EPROM. + +To satisfy the address requirements for the code, this scenario requires a linker command file that allocates sections and memory as follows: + +- The program/application code (represented in this scenario by the secA section shown in Example C-1\) must be linked so that its address space resides in the program memory (ROM) on the TMS470 CPU. +- To satisfy the condition that the data be loaded on the EPROM at address 0x0 but be referenced by the application code at address 0x1000, secB (the section that contains the data for this application) must be assigned a linker load address of 0x1000 so that all references to data in this section will be resolved with respect to the TMS470 CPU address. In the hex conversion utility command file, the paddr option must be used to burn the section of data at EPROM address 0x0. This value overrides the section load address given by the linker. + +Example C-1 shows the linker command file that resolves the addresses needed in the stated specifications. + +#### Example C-1. Linker Command File and Link Map for Scenario 1 + +``` +/**************************************************************************/ +/* Scenario 1 Link Command */ +/* */ +/* Usage: lnkpru -o -m lnk32.cmd */ +/* clpru -z -o -m lnk32.cmd */ +/* */ +/* Description: This file is a sample command file that can be used */ +/* for linking programs built with the TMS470 C */ +/* compiler. Use it as a guideline; you may want to change */ +/* the allocation scheme according to the size of your */ +/* program and the memory layout of your target system. */ +/* */ +/* Notes: (1) You must specify the directory in which rts32.lib is */ +/* located. Either add a "-i" line to this */ +/* file, or use the system environment variable C_DIR to */ +/* specify a search path for libraries. */ +/* */ +/* (2) If the runtime-support library you are using is not */ +/* named rts32.lib, be sure to use the correct name here. */ +/**************************************************************************/ +-m example1.map +/* SPECIFY THE SYSTEM MEMORY MAP */ +MEMORY +{ + I_MEM : org = 0x00000000 len = 0x00000020 /* INTERRUPTS */ + D_MEM : org = 0x00000020 len = 0x00010000 /* DATA MEMORY (RAM) */ + P_MEM : org = 0x00010020 len = 0x00100000 /* PROGRAM MEMORY (ROM) */ +} +/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */ +SECTIONS +{ + secA: load = P_MEM + secB: load = 0x1000 +} +``` + +You must create a hex conversion command file to generate a hex output with the correct addresses and format for the EPROM programmer. + +In the memory system outlined in Figure C-1, only the application data is stored on the EPROM; the data resides in secB of the object file created by the linker. By default, the hex conversion utility converts all initialized sections that appear in the object file. To prevent the conversion of the application code in secA, a SECTIONS directive must be defined in the hex conversion command file to list explicitly the section(s) to be converted. In this case, secB must be listed explicitly as the section to be converted. + +The EPROM programmer in this scenario has the following system requirements: + +- The EPROM programmer loads only a complete ROM image. A complete ROM image is one in which there is a contiguous address space (there are no holes in the addresses in the converted file), and each address in the range contains a known value. Creating a complete ROM image requires the use of the –image option and the ROMS directive. + - Using the -image option causes the hex conversion utility to create an output file that has + contiguous addresses over the specified memory range and forces the utility to fill address spaces + that are not previously filled by raw data from sections defined in the input object file. By default, + the value used to fill the unused portions of the memory range is 0. + - Because the -image option operates over a known range of memory addresses, a ROMS directive is needed to specify the origin and length of the memory for the EPROM. +- To burn the section of data at EPROM address 0x0, the paddr option must be used. This value overrides the section load address given by the linker. +- In this scenario, the EPROM is 128K $\times$ 8 bits. Therefore, the memory addresses for the EPROM must range from 0x0 to 0x20000. + +- Because the EPROM memory width is eight bits, the memwidth value must be set to 8. +- Because the physical width of the ROM device is eight bits, the romwidth value must be set to 8. +- Intel format must be used. + +Since memwidth and romwidth have the same value, only one output file is generated (the number of output files is determined by the ratio of memwidth to romwidth). The output file is named with the -o option. + +The hex conversion command file for Scenario 1 is shown in Example C-2. This command file uses the following options to select the requirements of the system: + +| Option | Description | +|-------------------|---------------------------------------------------------| +| -i | Create Intel format | +| -image | Generate a memory image | +| -map example1.mxp | Generate example1.mxp as the map file of the conversion | +| -o example1.hex | Name example1.hex as the output file | +| -memwidth 8 | Set EPROM system memory width to 8 | +| -romwidth 8 | Set physical ROM width to 8 | + +#### Example C-2. Hex Conversion Command File for Scenario 1 + +``` +/* Hex Conversion Command file for Scenario 1 */ +a.out /* linked object file, input */ +-I /* Intel format */ +-image +-map example1.mxp /* Generate a map of the conversion */ +-o example1.hex /* Resulting hex output file */ +-memwidth 8 /* EPROM memory system width */ +-romwidth 8 /* Physical width of ROM */ +ROMS +{ + EPROM: origin = 0x0, length = 0x20000 +} +SECTIONS +{ + secB: paddr = 0x0 /* Select only section, secB, for conversion */ +} +``` + +Example C-3 shows the contents of the resulting map file (example1.mxp). Figure C-2 shows the contents of the resulting hex output file (example1.hex). The hex conversion utility places the data tables, secB, at address 0 and then fills the remainder of the address space with the default fill value of 0. For more information about the Intel MCS-86 object format, see Figure 12-7. + +#### Example C-3. Contents of Hex Map File example1.mxp + +``` +********************************************************** +PRU Hex Converter Version x.xx +********************************************************** +INPUT FILE NAME: +OUTPUT FORMAT: Intel +PHYSICAL MEMORY PARAMETERS + Default data width: 8 + Default memory width: 8 + Default output width: 8 +OUTPUT TRANSLATION MAP +--------------------------------------------------------- +00000000..0001ffff Page=0 ROM Width=8 Memory Width=8 "EPROM" +--------------------------------------------------------- + OUTPUT FILES: example1.hex [b0..b7] + CONTENTS: 00000000..00000007 Data Width=1 secB + 00000007..0001ffff FILL = 00000000 +``` + +**Figure C-2. Contents of Hex Output File example1.hex** + +## C.2 Scenario 2: Building a Hex Conversion Command File for 16-BIS Code + +Scenario 2 shows how to build the hex conversion command file to generate the correct converted file for the application code and data that will reside on a single 16-bit EPROM. The EPROM memory system for this scenario is shown in Figure C-3. For this scenario, the TMS470 CPU operates with the T control bit set, so the processor executes instructions in 16-BIS mode. + +**Figure C-3. EPROM Memory System for Scenario 2** + +![Figure C-3: EPROM Memory System for Scenario 2 — ARM CPU (32-bit) connected to a 128K x 16-bit ROM0 with 16-bit ROM width and 16-bit EPROM system memory width](_page_301_Figure_6.jpeg) + +**Figure C-3: EPROM Memory System for Scenario 2.** Block diagram showing an ARM CPU (width: 32 bits) connected to a single 128K × 16 ROM0. ROM width: 16 bits; EPROM system memory width: 16 bits. + +For this scenario, the application code and data reside on the EPROM: the lower 64K words of EPROM memory are dedicated to application code space and the upper 64K words are dedicated to the data tables. The application code is loaded starting at address 0x0 on the EPROM but maps to the TMS470 CPU at address 0x3000. The data tables are loaded starting at address 0x1000 on the EPROM and map to the TMS470 CPU address 0x20. + +Example C-4 shows the linker command file that resolves the addresses needed for the load on EPROM and the TMS470 CPU access. + +#### Example C-4. Linker Command File for Scenario 2 + +``` +/**************************************************************************/ +/* Scenario 2 Link Command */ +/* */ +/* Usage: lnkpru -o -m lnk16.cmd */ +/* clpru -z -o -m lnk16.cmd */ +/* */ +/* Description: This file is a sample command file that can be used */ +/* for linking programs built with the TMS470 C */ +/* compiler. Use it as a guideline; you may want to change */ +/* the allocation scheme according to the size of your */ +/* program and the memory layout of your target system. */ +/* */ +/* Notes: (1) You must specify the directory in which rts16.lib is */ +/* located. Either add a "-i" line to this */ +/* file, or use the system environment variable C DIR to */ +/* specify a search path for libraries. */ +/* */ +/* (2) If the runtime-support library you are using is not */ +/* named rts16.lib, be sure to use the correct name here. */ +/**************************************************************************/ +-m example2.map +/* SPECIFY THE SYSTEM MEMORY MAP */ +MEMORY +{ + I_MEM : org = 0x00000000 len = 0x00000020 /* INTERRUPTS */ + D_MEM : org = 0x00000020 len = 0x00010000 /* DATA MEMORY (RAM) */ + P_MEM : org = 0x00010020 len = 0x00100000 /* PROGRAM MEMORY (ROM) */ +} +/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */ +SECTIONS +{ + secA: load = 0x3000 + secB: load = 0x20 +} +``` + +You must create a hex conversion command file to generate a hex output with the correct addresses and format for the EPROM programmer. The EPROM programmer in this scenario has the following system requirements: + +- Because the EPROM memory width is 16 bits, the memwidth value must be set to 16. +- Because the physical width of the ROM device is 16 bits, the romwidth value must be set to 16. +- Intel format must be used. + +The EPROM programmer does not require a ROM image, so the addresses in the input hex output file do not need to be contiguous. + +Because memwidth and romwidth have the same value, only one output file is generated (the number of output files is determined by the ratio of memwidth to romwidth). The output file is named with the -o option. + +A ROMS directive is used in this scenario since the paddr option is used to relocate both secA and secB. + +The hex conversion command file for Scenario 2 is shown in Example C-5. This command file uses the following options to select the requirements of the system: + +| Option | Description | +|-------------------|---------------------------------------------------------| +| -i | Create Intel format | +| -map example2.mxp | Generate example2.mxp as the map file of the conversion | +| -o example2.hex | Name example2.hex as the output file | +| -memwidth 8 | Set EPROM system memory width to 8 | +| -romwidth 8 | Set physical ROM width to 8 | + +#### Example C-5. Hex Conversion Command File for Scenario 2 + +``` +/* Hex Conversion Command file for Scenario 2 */ +a.out /* linked object file, input */ +-I /* Intel format */ + /* The following two options are optional */ +-map example2.mxp /* Generate a map of the conversion */ +-o example2.hex /* Resulting Hex Output file */ + /* Specify EPROM system Memory Width and Physical ROM width */ +-memwidth 16 /* EPROM memory system width */ +-romwidth 16 /* Physical width of ROM */ +ROMS +{ + EPROM: origin = 0x0, length = 0x20000 +} +SECTIONS +{ + secA: paddr = 0x0 + secB: paddr = 0x1000 +} +``` + +Example C-6 shows the contents of the resulting map file (example2.mxp). Figure C-4 shows the contents of the resulting hex output file (example2.hex). + +#### Example C-6. Contents of Hex Map File example2.mxp + +``` +***************************************************** +PRU Hex Converter Version x.xx +***************************************************** +INPUT FILE NAME: +OUTPUT FORMAT: Intel + +PHYSICAL MEMORY PARAMETERS + Default data width: 8 + Default memory width: 16 + Default output width: 16 + +OUTPUT TRANSLATION MAP +----------------------------------------------------- +00000000..0001ffff Page=0 ROM Width=16 Memory Width=16 "EPROM" +----------------------------------------------------- + OUTPUT FILES: example2.hex [b0..b15] + + CONTENTS: 00000000..00000003 Data Width=1 secA + 00001000..00001003 Data Width=1 secB +``` + +**Figure C-4. Contents of Hex Output File example2.hex** + +![Figure C-4: Contents of Hex Output File example2.hex — Intel hex records with labeled start character, address, data, byte count, record type, checksum, and end-of-file record](_page_304_Figure_4.jpeg) + +**Figure C-4: Contents of Hex Output File example2.hex.** Intel hex record layout diagram. Shows three records: :0800200056781234C8 (8-byte data record at address 0020), :040028004321DCBADA (4-byte data record at address 0028), and :00000001FF (end-of-file record). Labeled fields: start character (:), byte count, address, data, record type, checksum. + +## C.3 Scenario 3: Building a Hex Conversion Command File for Two 8-Bit EPROMs + +Scenario 3 shows how to build the hex conversion command file for converting a object file for the memory system shown in Figure C-5. In this system, there are two external 64K × 16-bit EPROMs interfacing with the TMS470 target processor. The application code and data will be burned on the EPROM starting at address 0x20. The application code will be burned first, followed by the data tables. + +**Figure C-5. EPROM Memory System for Scenario 3** + +![Figure C-5: EPROM Memory System for Scenario 3 — ARM CPU (32-bit) connected to two 64K x 16-bit EPROMs (ROM0 and ROM1), ROM0 providing upper 16 bits and ROM1 providing lower 16 bits](_page_304_Figure_8.jpeg) + +**Figure C-5: EPROM Memory System for Scenario 3.** Block diagram showing an ARM CPU (width: 32 bits) connected to two 64K × 16-bit EPROMs: ROM0 and ROM1, each with ROM width 16 bits. ROM0 provides the upper 16 bits of the 32-bit CPU word; ROM1 provides the lower 16 bits. EPROM system memory width: 32 bits. + +In this scenario, the EPROM load address for the application code and for the data also corresponds to the TMS470 CPU address that accesses the code and data. Therefore, only a load address needs to be specified. + +Example C-7 shows the linker command file for this scenario. + +#### Example C-7. Linker Command File for Scenario 3 + +``` +/**************************************************************************/ +/* Scenario 3 Link Command */ +/* */ +/* Usage: lnkpru -o -m lnk32.cmd */ +/* clpru -z -o -m lnk32.cmd */ +/* */ +/* Description: This file is a sample command file that can be used */ +/* for linking programs built with the TMS470 C */ +/* compiler. Use it as a guideline; you may want to change */ +/* the allocation scheme according to the size of your */ +/* program and the memory layout of your target system. */ +/* */ +/* Notes: (1) You must specify the directory in which rts32.lib is */ +/* located. Either add a "-i" line to this */ +/* file, or use the system environment variable C_DIR to */ +/* specify a search path for libraries. */ +/* */ +/* (2) If the runtime-support library you are using is not */ +/* named rts32.lib, be sure to use the correct name here. */ +/**************************************************************************/ +-m example3.map +/* SPECIFY THE SYSTEM MEMORY MAP */ +MEMORY +{ + I_MEM : org = 0x00000000 len = 0x00000020 /* INTERRUPTS */ + D_MEM : org = 0x00000020 len = 0x00010000 /* DATA MEMORY (RAM) */ + P_MEM : org = 0x00010020 len = 0x00100000 /* PROGRAM MEMORY (ROM) */ +} +/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */ +SECTIONS +{ + secA: load = 0x20 + secB: load = D_MEM +} +``` + +You must create a hex conversion command file to generate a hex output with the correct addresses and format for the EPROM programmer. + +The EPROM programmer in this scenario has the following system requirements: + +- In the memory system outlined in Figure C-5, the EPROM system memory width is 32 bits because each of the physical ROMs provides 16 bits of a 32-bit word. Because the EPROM system memory width is 32 bits, the memwidth value must be set to 32. +- Because the width of each of the physical ROMs is 16 bits, the romwidth value must be set to 16. +- Intel format must be used. + +With a memwidth of 32 and a romwidth of 16, two output files are generated by the hex conversion utility (the number of files is determined by the ratio of memwidth to romwidth). In previous scenarios, the output filename was specified with the -o option. Another way to specify the output filename is to use the files keyword within a ROMS directive. When you use -o or the files keyword, the first output filename always contains the low-order bytes of the word. + +The hex conversion command file for Scenario 3 is shown in Example C-8. This command file uses the following options to select the requirements of the system: + +| Option | Description | +|-------------------|---------------------------------------------------------| +| -i | Create Intel format | +| -map example3.mxp | Generate example3.mxp as the map file of the conversion | +| -memwidth 32 | Set EPROM system memory width to 32 | +| -romwidth 16 | Set physical ROM width to 16 | + +The files keyword is used within the ROMS directive to specify the output filenames. + +#### Example C-8. Hex Conversion Command File for Scenario 3 + +``` +/* Hex Conversion Command file for Scenario 3 */ +a.out /* linked object file, input */ +-I /* Intel format */ + /* Optional Commands */ +-map example3.mxp /* Generate a map of the conversion */ + /* Specify EPROM system memory width and physical ROM width */ +-memwidth 32 /* EPROM memory system width */ +-romwidth 16 /* Physical width of ROM */ +ROMS +{ + EPROM: org = 0x0, length = 0x20000 + files={ lower16.bit, upper16.bit } +} +``` + +Example C-9 shows the contents of the resulting map file (example3.mxp). + +#### Example C-9. Contents of Hex Map File example3.mxp + +``` +***************************************************** +PRU Hex Converter Version x.xx +***************************************************** +Tue Sep 19 07:41:28 1995 +INPUT FILE NAME: +OUTPUT FORMAT: Intel + +PHYSICAL MEMORY PARAMETERS + Default data width: 8 + Default memory width: 32 + Default output width: 16 + +OUTPUT TRANSLATION MAP +----------------------------------------------------- +00000000..0001ffff Page=0 ROM Width=16 Memory Width=32 "EPROM" +----------------------------------------------------- + OUTPUT FILES: lower16.bit [b0..b15] + upper16.bit [b16..b31] + + CONTENTS: 00000020..00000021 Data Width=1 secA + 00000028..00000029 Data Width=1 secB +``` + +The contents of the output files lower16.bit and upper16.bit are shown in Figure C-6. The first image shows the lower16.bit file, which stores the low-order 16 bits of the 32-bit output word. The second image shows the upper16.bit files, which stores the upper 16 bits. + +**Figure C-6. Contents of Hex Output File** + +![Figure C-6: Contents of Hex Output File — two Intel hex listings showing lower16.bit (low-order 16 bits) and upper16.bit (high-order 16 bits) output files](_page_307_Figure_5.jpeg) + +**Figure C-6: Contents of Hex Output File.** Two Intel hex file listings. Top (lower16.bit, stores low-order 16 bits of the 32-bit output word): :0400200056781234C8, :040028004321DCBADA, :00000001FF. Bottom (upper16.bit, stores upper 16 bits): :040020001234ABCD1E, :040028008765432184, :00000001FF. Labeled fields: start character, address, data, byte count, record type, checksum, end-of-file record. + +# D Glossary + +## D.1 Terminology + +- **ABI —** Application binary interface. +- **absolute address —** An address that is permanently assigned to a PRU memory location. +- **absolute constant expression —** An expression that does not refer to any external symbols or any registers or memory reference. The value of the expression must be knowable at assembly time. +- **absolute lister —** A debugging tool that allows you to create assembler listings that contain absolute addresses. +- **address constant expression —** A symbol with a value that is an address plus an addend that is an absolute constant expression with an integer value. +- **alignment —** A process in which the linker places an output section at an address that falls on an *n-*byte boundary, where *n* is a power of 2. You can specify alignment with the SECTIONS linker directive. +- **allocation —** A process in which the linker calculates the final memory addresses of output sections. +- **ANSI —** American National Standards Institute; an organization that establishes standards voluntarily followed by industries. +- **archive library —** A collection of individual files grouped into a single file by the archiver. +- **archiver —** A software program that collects several individual files into a single file called an archive library. With the archiver, you can add, delete, extract, or replace members of the archive library. +- **ASCII —** American Standard Code for Information Interchange; a standard computer code for representing and exchanging alphanumeric information. +- **assembler —** A software program that creates a machine-language program from a source file that contains assembly language instructions, directives, and macro definitions. The assembler substitutes absolute operation codes for symbolic operation codes and absolute or relocatable addresses for symbolic addresses. +- **assembly-time constant —** A symbol that is assigned a constant value with the .set directive. +- **big endian —** An addressing protocol in which bytes are numbered from left to right within a word. More significant bytes in a word have lower numbered addresses. Endian ordering is hardware-specific and is determined at reset. See also *little endian* +- **binding —** A process in which you specify a distinct address for an output section or a symbol. +- **block —** A set of statements that are grouped together within braces and treated as an entity. +- **.bss section —** One of the default object file sections. You use the assembler .bss directive to reserve a specified amount of space in the memory map that you can use later for storing data. The .bss section is uninitialized. +- **byte —** Per ANSI/ISO C, the smallest addressable unit that can hold a character. +- **C/C++ compiler —** A software program that translates C source statements into assembly language source statements. + +- **command file —** A file that contains options, filenames, directives, or commands for the linker or hex conversion utility. +- **comment —** A source statement (or portion of a source statement) that documents or improves readability of a source file. Comments are not compiled, assembled, or linked; they have no effect on the object file. +- **compiler program —** A utility that lets you compile, assemble, and optionally link in one step. The compiler runs one or more source modules through the compiler (including the parser, optimizer, and code generator), the assembler, and the linker. +- **conditional processing —** A method of processing one block of source code or an alternate block of source code, according to the evaluation of a specified expression. +- **configured memory —** Memory that the linker has specified for allocation. +- **constant —** A type whose value cannot change. +- **constant expression —** An expression that does not in any way refer to a register or memory reference. +- **cross-reference lister —** A utility that produces an output file that lists the symbols that were defined, what file they were defined in, what reference type they are, what line they were defined on, which lines referenced them, and their assembler and linker final values. The cross-reference lister uses linked object files as input. +- **cross-reference listing —** An output file created by the assembler that lists the symbols that were defined, what line they were defined on, which lines referenced them, and their final values. +- **.data section —** One of the default object file sections. The .data section is an initialized section that contains initialized data. You can use the .data directive to assemble code into the .data section. +- **directives —** Special-purpose commands that control the actions and functions of a software tool (as opposed to assembly language instructions, which control the actions of a device). +- **DWARF —** A standardized debugging data format that was originally designed along with ELF, although it is independent of the object file format. +- **EABI —** An embedded application binary interface (ABI) that provides standards for file formats, data types, and more. +- **ELF —** Executable and linking format; a system of object files configured according to the System V Application Binary Interface specification. +- **emulator —** A hardware development system that duplicates the PRU operation. +- **entry point —** A point in target memory where execution starts. +- **environment variable —** A system symbol that you define and assign to a string. Environmental variables are often included in Windows batch files or UNIX shell scripts such as .cshrc or .profile. +- **epilog —** The portion of code in a function that restores the stack and returns. +- **executable module —** A linked object file that can be executed in a target system. +- **expression —** A constant, a symbol, or a series of constants and symbols separated by arithmetic operators. +- **external symbol —** A symbol that is used in the current program module but defined or declared in a different program module. +- **field —** For the PRU, a software-configurable data type whose length can be programmed to be any value in the range of 1-32 bits. +- **global symbol —** A symbol that is either defined in the current module and accessed in another, or accessed in the current module but defined in another. + +- **GROUP —** An option of the SECTIONS directive that forces specified output sections to be allocated contiguously (as a group). +- **hex conversion utility —** A utility that converts object files into one of several standard ASCII hexadecimal formats, suitable for loading into an EPROM programmer. +- **high-level language debugging —** The ability of a compiler to retain symbolic and high-level language information (such as type and function definitions) so that a debugging tool can use this information. +- **hole —** An area between the input sections that compose an output section that contains no code. +- **identifier—** Names used as labels, registers, and symbols. +- **immediate operand —** An operand whose value must be a constant expression. +- **incremental linking —** Linking files in several passes. Incremental linking is useful for large applications, because you can partition the application, link the parts separately, and then link all of the parts together. +- **initialization at load time —** An autoinitialization method used by the linker when linking C/C++ code. The linker uses this method when you invoke it with the --ram\_model link option. This method initializes variables at load time instead of run time. +- **initialized section —** A section from an object file that will be linked into an executable module. +- **input section —** A section from an object file that will be linked into an executable module. +- **ISO —** International Organization for Standardization; a worldwide federation of national standards bodies, which establishes international standards voluntarily followed by industries. +- **label —** A symbol that begins in column 1 of an assembler source statement and corresponds to the address of that statement. A label is the only assembler statement that can begin in column 1. +- **linker —** A software program that combines object files to form an object module that can be allocated into system memory and executed by the device. +- **listing file —** An output file, created by the assembler, that lists source statements, their line numbers, and their effects on the section program counter (SPC). +- **literal constant —** A value that represents itself. It may also be called a *literal* or an *immediate value*. +- **little endian —** An addressing protocol in which bytes are numbered from right to left within a word. More significant bytes in a word have higher numbered addresses. Endian ordering is hardware-specific and is determined at reset. See also *big endian* +- **loader —** A device that places an executable module into system memory. +- **macro —** A user-defined routine that can be used as an instruction. +- **macro call —** The process of invoking a macro. +- **macro definition —** A block of source statements that define the name and the code that make up a macro. +- **macro expansion —** The process of inserting source statements into your code in place of a macro call. +- **macro library —** An archive library composed of macros. Each file in the library must contain one macro; its name must be the same as the macro name it defines, and it must have an extension of .asm. +- **map file —** An output file, created by the linker, that shows the memory configuration, section composition, section allocation, symbol definitions and the addresses at which the symbols were defined for your program. +- **member —** The elements or variables of a structure, union, archive, or enumeration. + +- **memory map —** A map of target system memory space that is partitioned into functional blocks. +- **memory reference operand —** An operand that refers to a location in memory using a target-specific syntax. +- **mnemonic —** An instruction name that the assembler translates into machine code. +- **model statement —** Instructions or assembler directives in a macro definition that are assembled each time a macro is invoked. +- **named section —** An initialized section that is defined with a .sect directive. +- **object file —** An assembled or linked file that contains machine-language object code. +- **object library —** An archive library made up of individual object files. +- **object module —** A linked, executable object file that can be downloaded and executed on a target system. +- **operand —** An argument of an assembly language instruction, assembler directive, or macro directive that supplies information to the operation performed by the instruction or directive. +- **optimizer —** A software tool that improves the execution speed and reduces the size of C programs. +- **options —** Command-line parameters that allow you to request additional or specific functions when you invoke a software tool. +- **output module —** A linked, executable object file that is downloaded and executed on a target system. +- **output section —** A final, allocated section in a linked, executable module. +- **partial linking —** Linking files in several passes. Incremental linking is useful for large applications because you can partition the application, link the parts separately, and then link all of the parts together. +- **quiet run —** An option that suppresses the normal banner and the progress information. +- **raw data —** Executable code or initialized data in an output section. +- **register operand —** A special pre-defined symbol that represents a CPU register. +- **relocatable constant expression—** An expression that refers to at least one external symbol, register, or memory location. The value of the expression is not known until link time. +- **relocation —** A process in which the linker adjusts all the references to a symbol when the symbol's address changes. +- **ROM width —** The width (in bits) of each output file, or, more specifically, the width of a single data value in the hex conversion utility file. The ROM width determines how the utility partitions the data into output files. After the target words are mapped to memory words, the memory words are broken into one or more output files. The number of output files is determined by the ROM width. +- **run address —** The address where a section runs. +- **run-time-support library —** A library file, rts.src, that contains the source for the run time-support functions. +- **section —** A relocatable block of code or data that ultimately will be contiguous with other sections in the memory map. +- **section program counter (SPC) —** An element that keeps track of the current location within a section; each section has its own SPC. +- **sign extend —** A process that fills the unused MSBs of a value with the value's sign bit. +- **source file —** A file that contains C/C++ code or assembly language code that is compiled or assembled to form an object file. + +- **static variable —** A variable whose scope is confined to a function or a program. The values of static variables are not discarded when the function or program is exited; their previous value is resumed when the function or program is reentered. +- **storage class —** An entry in the symbol table that indicates how to access a symbol. +- **string table —** A table that stores symbol names that are longer than eight characters (symbol names of eight characters or longer cannot be stored in the symbol table; instead they are stored in the string table). The name portion of the symbol's entry points to the location of the string in the string table. +- **structure —** A collection of one or more variables grouped together under a single name. +- **subsection —** A relocatable block of code or data that ultimately will occupy continuous space in the memory map. Subsections are smaller sections within larger sections. Subsections give you tighter control of the memory map. +- **symbol —** A name that represents an address or a value. +- **symbolic constant —** A symbol with a value that is an absolute constant expression. +- **symbolic debugging —** The ability of a software tool to retain symbolic information that can be used by a debugging tool such as an emulator. +- **tag —** An optional *type* name that can be assigned to a structure, union, or enumeration. +- **target memory —** Physical memory in a system into which executable object code is loaded. +- **.text section —** One of the default object file sections. The .text section is initialized and contains executable code. You can use the .text directive to assemble code into the .text section. +- **unconfigured memory —** Memory that is not defined as part of the memory map and cannot be loaded with code or data. +- **uninitialized section —** A object file section that reserves space in the memory map but that has no actual contents. These sections are built with the .bss and .usect directives. +- **UNION —** An option of the SECTIONS directive that causes the linker to allocate the same address to multiple sections. +- **union —** A variable that can hold objects of different types and sizes. +- **unsigned value —** A value that is treated as a nonnegative number, regardless of its actual sign. +- **variable —** A symbol representing a quantity that can assume any of a set of values. +- **well-defined expression —** A term or group of terms that contains only symbols or assembly-time constants that have been defined before they appear in the expression. +- **word —** A 32-bit addressable location in target memory + +# E Revision History + +## E.1 Recent Revisions + +This table lists significant changes made to this document. The left column identifies the first version of this document in which a particular change appeared. + +| Version
Added | Chapter | Location | Additions / Modifications / Deletions | +|---------------------|-------------------------------------------------|----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| SPRUHV6C | Archiver and
Linker | Section 7.5.2 and
Section 8.4.10 | Added --silicon_version=4 support. | +| SPRUHV6C | Linker | Section 8.4,
Section 8.4.11, and
Section 8.5.9 | Added the --ecc=on linker option, which enables ECC generation. Note that
ECC generation is now off by default. | +| SPRUHV6C | Linker | Section 8.5.4.2 | Added information about the CREGISTER specifier, which can be used within
the MEMORY directive in a linker command file. | +| SPRUHV6C | Linker | Section 8.5.7.3 | Added linker syntax for combining an initialized section with uninitialized
sections. | +| Previous Revisions: | | | | +| SPRUHV6B | Assembler
Description | Section 4.3 and
Section 4.10 | Added the --code_address_listing_unit command-line option. | +| SPRUHV6B | Hex
Conversion
Utility | Section 12.2.1 and
Section 12.11 | Added the --array option, which causes the array output format to be
generated. | +| SPRUHV6B | Object
Modules,
Directives,
and Linker | Section 2.6.2,
.weak topic, and
Section 8.6.2 | Weak symbols can be declared using assembly or the linker command file. The
linker removes weak symbols from the output file if the symbol is not required
to resolve any references. | +| SPRUHV6B | Linker | Section 8.4.19 | Added modules as a filter for the --mapfile_contents linker command line
option. | +| SPRUHV6A | Linker | Section 8.4.2,
Section 8.5.10.6,
and Section 8.6.1 | Added information about referencing linker symbols. | +| SPRUHV6A | Linker | Section 8.4.10 | Added a list of the linker's predefined macros. | + +### IMPORTANT NOTICE FOR TI DESIGN INFORMATION AND RESOURCES + +Texas Instruments Incorporated ('TI") technical, application or other design advice, services or information, including, but not limited to, reference designs and materials relating to evaluation modules, (collectively, "TI Resources") are intended to assist designers who are developing applications that incorporate TI products; by downloading, accessing or using any particular TI Resource in any way, you (individually or, if you are acting on behalf of a company, your company) agree to use it solely for this purpose and subject to the terms of this Notice. + +TI's provision of TI Resources does not expand or otherwise alter TI's applicable published warranties or warranty disclaimers for TI products, and no additional obligations or liabilities arise from TI providing such TI Resources. TI reserves the right to make corrections, enhancements, improvements and other changes to its TI Resources. + +You understand and agree that you remain responsible for using your independent analysis, evaluation and judgment in designing your applications and that you have full and exclusive responsibility to assure the safety of your applications and compliance of your applications (and of all TI products used in or for your applications) with all applicable regulations, laws and other applicable requirements. You represent that, with respect to your applications, you have all the necessary expertise to create and implement safeguards that (1) anticipate dangerous consequences of failures, (2) monitor failures and their consequences, and (3) lessen the likelihood of failures that might cause harm and take appropriate actions. You agree that prior to using or distributing any applications that include TI products, you will thoroughly test such applications and the functionality of such TI products as used in such applications. TI has not conducted any testing other than that specifically described in the published documentation for a particular TI Resource. + +You are authorized to use, copy and modify any individual TI Resource only in connection with the development of applications that include the TI product(s) identified in such TI Resource. NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE TO ANY OTHER TI INTELLECTUAL PROPERTY RIGHT, AND NO LICENSE TO ANY TECHNOLOGY OR INTELLECTUAL PROPERTY RIGHT OF TI OR ANY THIRD PARTY IS GRANTED HEREIN, including but not limited to any patent right, copyright, mask work right, or other intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information regarding or referencing third-party products or services does not constitute a license to use such products or services, or a warranty or endorsement thereof. Use of TI Resources may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI. + +TI RESOURCES ARE PROVIDED "AS IS" AND WITH ALL FAULTS. TI DISCLAIMS ALL OTHER WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED, REGARDING TI RESOURCES OR USE THEREOF, INCLUDING BUT NOT LIMITED TO ACCURACY OR COMPLETENESS, TITLE, ANY EPIDEMIC FAILURE WARRANTY AND ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHTS. + +TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY CLAIM, INCLUDING BUT NOT LIMITED TO ANY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON ANY COMBINATION OF PRODUCTS EVEN IF DESCRIBED IN TI RESOURCES OR OTHERWISE. IN NO EVENT SHALL TI BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, COLLATERAL, INDIRECT, PUNITIVE, INCIDENTAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES IN CONNECTION WITH OR ARISING OUT OF TI RESOURCES OR USE THEREOF, AND REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +You agree to fully indemnify TI and its representatives against any damages, costs, losses, and/or liabilities arising out of your noncompliance with the terms and provisions of this Notice. + +This Notice applies to TI Resources. Additional terms apply to the use and purchase of certain types of materials, TI products and services. These include; without limitation, TI's standard terms for semiconductor products ), [evaluation](http://www.ti.com/lit/pdf/SSZZ027) [modules](http://www.ti.com/lit/pdf/SSZZ027), and samples [\(http://www.ti.com/sc/docs/sampterms.htm\)](http://www.ti.com/sc/docs/sampterms.htm). + +> Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright © 2018, Texas Instruments Incorporated diff --git a/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_111_Figure_3.jpeg b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_111_Figure_3.jpeg new file mode 100644 index 000000000..4925fbd91 Binary files /dev/null and b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_111_Figure_3.jpeg differ diff --git a/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_119_Figure_8.jpeg b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_119_Figure_8.jpeg new file mode 100644 index 000000000..cb4b10a31 Binary files /dev/null and b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_119_Figure_8.jpeg differ diff --git a/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_11_Figure_5.jpeg b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_11_Figure_5.jpeg new file mode 100644 index 000000000..f0bcd23e1 Binary files /dev/null and b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_11_Figure_5.jpeg differ diff --git a/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_121_Figure_20.jpeg b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_121_Figure_20.jpeg new file mode 100644 index 000000000..3ef1d5ffb Binary files /dev/null and b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_121_Figure_20.jpeg differ diff --git a/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_122_Figure_6.jpeg b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_122_Figure_6.jpeg new file mode 100644 index 000000000..050104172 Binary files /dev/null and b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_122_Figure_6.jpeg differ diff --git a/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_84_Figure_21.jpeg b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_84_Figure_21.jpeg new file mode 100644 index 000000000..3193ce177 Binary files /dev/null and b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/_page_84_Figure_21.jpeg differ diff --git a/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/pru_optimizing_c_compiler_users_guide_v2_3.md b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/pru_optimizing_c_compiler_users_guide_v2_3.md new file mode 100644 index 000000000..07f9ca090 --- /dev/null +++ b/docs_ai/reference/pru_optimizing_c_compiler_users_guide_v2_3/pru_optimizing_c_compiler_users_guide_v2_3.md @@ -0,0 +1,5832 @@ +# Contents + +- Preface ........ 8 +- **1 Introduction to the Software Development Tools** ........ 11 + - 1.1 Software Development Tools Overview ........ 12 + - 1.2 Compiler Interface ........ 13 + - 1.3 ANSI/ISO Standard ........ 14 + - 1.4 Output Files ........ 14 + - 1.5 Utilities ........ 14 +- **2 Using the C/C++ Compiler** ........ 15 + - 2.1 About the Compiler ........ 16 + - 2.2 Invoking the C/C++ Compiler ........ 16 + - 2.3 Changing the Compiler's Behavior with Options ........ 17 + - 2.3.1 Linker Options ........ 23 + - 2.3.2 Frequently Used Options ........ 25 + - 2.3.3 Miscellaneous Useful Options ........ 26 + - 2.3.4 Run-Time Model Options ........ 27 + - 2.3.5 Symbolic Debugging Options ........ 28 + - 2.3.6 Specifying Filenames ........ 28 + - 2.3.7 Changing How the Compiler Interprets Filenames ........ 29 + - 2.3.8 Changing How the Compiler Processes C Files ........ 29 + - 2.3.9 Changing How the Compiler Interprets and Names Extensions ........ 29 + - 2.3.10 Specifying Directories ........ 30 + - 2.3.11 Assembler Options ........ 30 + - 2.4 Controlling the Compiler Through Environment Variables ........ 31 + - 2.4.1 Setting Default Compiler Options (PRU_C_OPTION) ........ 31 + - 2.4.2 Naming One or More Alternate Directories (PRU_C_OPTION) ........ 31 + - 2.5 Controlling the Preprocessor ........ 32 + - 2.5.1 Predefined Macro Names ........ 32 + - 2.5.2 The Search Path for #include Files ........ 33 + - 2.5.3 Support for the #warning and #warn Directives ........ 34 + - 2.5.4 Generating a Preprocessed Listing File (--preproc_only Option) ........ 34 + - 2.5.5 Continuing Compilation After Preprocessing (--preproc_with_compile Option) ........ 34 + - 2.5.6 Generating a Preprocessed Listing File with Comments (--preproc_with_comment Option) ........ 35 + - 2.5.7 Generating Preprocessed Listing with Line-Control Details (--preproc_with_line Option) ........ 35 + - 2.5.8 Generating Preprocessed Output for a Make Utility (--preproc_dependency Option) ........ 35 + - 2.5.9 Generating a List of Files Included with #include (--preproc_includes Option) ........ 35 + - 2.5.10 Generating a List of Macros in a File (--preproc_macros Option) ........ 35 + - 2.6 Passing Arguments to main() ........ 35 + - 2.7 Understanding Diagnostic Messages ........ 36 + - 2.7.1 Controlling Diagnostic Messages ........ 37 + - 2.7.2 How You Can Use Diagnostic Suppression Options ........ 38 + - 2.8 Other Messages ........ 39 + - 2.9 Generating Cross-Reference Listing Information (--gen_cross_reference Option) ........ 39 + - 2.10 Generating a Raw Listing File (--gen_preprocessor_listing Option) ........ 39 + - 2.11 Using Inline Function Expansion ........ 41 + - 2.11.1 Inlining Intrinsic Operators ........ 42 + - 2.11.2 Inlining Restrictions ........ 42 + - 2.12 Using Interlist ........ 43 + - 2.13 Enabling Entry Hook and Exit Hook Functions ........ 44 +- **3 Optimizing Your Code** ........ 45 + - 3.1 Invoking Optimization ........ 46 + - 3.2 Controlling Code Size Versus Speed ........ 47 + - 3.3 Performing File-Level Optimization (--opt_level=3 option) ........ 47 + - 3.3.1 Creating an Optimization Information File (--gen_opt_info Option) ........ 47 + - 3.4 Program-Level Optimization (--program_level_compile and --opt_level=3 options) ........ 48 + - 3.4.1 Controlling Program-Level Optimization (--call_assumptions Option) ........ 49 + - 3.4.2 Optimization Considerations When Mixing C/C++ and Assembly ........ 50 + - 3.5 Automatic Inline Expansion (--auto_inline Option) ........ 51 + - 3.6 Link-Time Optimization (--opt_level=4 Option) ........ 52 + - 3.6.1 Option Handling ........ 52 + - 3.6.2 Incompatible Types ........ 52 + - 3.7 Accessing Aliased Variables in Optimized Code ........ 53 + - 3.8 Use Caution With asm Statements in Optimized Code ........ 53 + - 3.9 Using the Interlist Feature With Optimization ........ 53 + - 3.10 Debugging and Profiling Optimized Code ........ 54 + - 3.11 What Kind of Optimization Is Being Performed? ........ 54 + - 3.11.1 Cost-Based Register Allocation ........ 55 + - 3.11.2 Alias Disambiguation ........ 55 + - 3.11.3 Branch Optimizations and Control-Flow Simplification ........ 55 + - 3.11.4 Data Flow Optimizations ........ 55 + - 3.11.5 Expression Simplification ........ 56 + - 3.11.6 Inline Expansion of Functions ........ 56 + - 3.11.7 Function Symbol Aliasing ........ 56 + - 3.11.8 Induction Variables and Strength Reduction ........ 56 + - 3.11.9 Loop-Invariant Code Motion ........ 56 + - 3.11.10 Loop Rotation ........ 56 + - 3.11.11 Instruction Scheduling ........ 56 + - 3.11.12 Tail Merging ........ 57 + - 3.11.13 Autoincrement Addressing ........ 57 + - 3.11.14 Epilog Inlining ........ 57 + - 3.11.15 Integer Division With Constant Divisor ........ 57 +- **4 Linking C/C++ Code** ........ 58 + - 4.1 Invoking the Linker Through the Compiler (-z Option) ........ 59 + - 4.1.1 Invoking the Linker Separately ........ 59 + - 4.1.2 Invoking the Linker as Part of the Compile Step ........ 60 + - 4.1.3 Disabling the Linker (--compile_only Compiler Option) ........ 60 + - 4.2 Linker Code Optimizations ........ 61 + - 4.2.1 Generating Aggregate Data Subsections (--gen_data_subsections Compiler Option) ........ 61 + - 4.3 Controlling the Linking Process ........ 61 + - 4.3.1 Including the Run-Time-Support Library ........ 61 + - 4.3.2 Run-Time Initialization ........ 62 + - 4.3.3 Global Object Constructors ........ 63 + - 4.3.4 Specifying the Type of Global Variable Initialization ........ 63 + - 4.3.5 Specifying Where to Allocate Sections in Memory ........ 64 + - 4.3.6 A Sample Linker Command File ........ 64 +- **5 C/C++ Language Implementation** ........ 66 + - 5.1 Characteristics of PRU C ........ 67 + - 5.1.1 Implementation-Defined Behavior ........ 67 + - 5.2 Characteristics of PRU C++ ........ 71 + - 5.3 Using MISRA C 2004 ........ 72 + - 5.4 Data Types ........ 73 + - 5.4.1 Size of Enum Types ........ 74 + - 5.5 Keywords ........ 74 + - 5.5.1 The const Keyword ........ 74 + - 5.5.2 The near and far Keywords ........ 75 + - 5.5.3 The volatile Keyword ........ 75 + - 5.6 C++ Exception Handling ........ 76 + - 5.7 Register Variables and Parameters ........ 77 + - 5.7.1 Local Register Variables and Parameters ........ 77 + - 5.7.2 Global Register Variables ........ 77 + - 5.8 The __asm Statement ........ 78 + - 5.9 Pragma Directives ........ 79 + - 5.9.1 The CALLS Pragma ........ 80 + - 5.9.2 The CHECK_MISRA Pragma ........ 80 + - 5.9.3 The CODE_SECTION Pragma ........ 81 + - 5.9.4 The DATA_ALIGN Pragma ........ 81 + - 5.9.5 The DATA_SECTION Pragma ........ 82 + - 5.9.6 The Diagnostic Message Pragmas ........ 82 + - 5.9.7 The FORCEINLINE Pragma ........ 83 + - 5.9.8 The FORCEINLINE_RECURSIVE Pragma ........ 83 + - 5.9.9 The FUNC_ALWAYS_INLINE Pragma ........ 84 + - 5.9.10 The FUNC_CANNOT_INLINE Pragma ........ 84 + - 5.9.11 The FUNC_EXT_CALLED Pragma ........ 85 + - 5.9.12 The FUNCTION_OPTIONS Pragma ........ 85 + - 5.9.13 The LOCATION Pragma ........ 85 + - 5.9.14 The MUST_ITERATE Pragma ........ 86 + - 5.9.15 The NOINIT and PERSISTENT Pragmas ........ 87 + - 5.9.16 The NOINLINE Pragma ........ 88 + - 5.9.17 The NO_HOOKS Pragma ........ 89 + - 5.9.18 The RESET_MISRA Pragma ........ 89 + - 5.9.19 The RETAIN Pragma ........ 89 + - 5.9.20 The SET_CODE_SECTION and SET_DATA_SECTION Pragmas ........ 90 + - 5.9.21 The UNROLL Pragma ........ 91 + - 5.9.22 The WEAK Pragma ........ 91 + - 5.10 The _Pragma Operator ........ 92 + - 5.11 PRU Instruction Intrinsics ........ 93 + - 5.12 Object File Symbol Naming Conventions (Linknames) ........ 94 + - 5.13 Changing the ANSI/ISO C/C++ Language Mode ........ 95 + - 5.13.1 C99 Support (--c99) ........ 95 + - 5.13.2 Strict ANSI Mode and Relaxed ANSI Mode (--strict_ansi and --relaxed_ansi) ........ 97 + - 5.14 GNU Language Extensions ........ 98 + - 5.14.1 Extensions ........ 98 + - 5.14.2 Function Attributes ........ 99 + - 5.14.3 Variable Attributes ........ 100 + - 5.14.4 Type Attributes ........ 100 + - 5.14.5 Built-In Functions ........ 102 + - 5.15 Compiler Limits ........ 102 +- **6 Run-Time Environment** ........ 103 + - 6.1 Memory Model ........ 104 + - 6.1.1 Sections ........ 104 + - 6.1.2 C/C++ System Stack ........ 105 + - 6.1.3 Dynamic Memory Allocation ........ 106 + - 6.2 Object Representation ........ 107 + - 6.2.1 Data Type Storage ........ 107 + - 6.2.2 Bit Fields ........ 108 + - 6.2.3 Character String Constants ........ 109 + - 6.3 Register Conventions ........ 110 + - 6.4 Function Structure and Calling Conventions ........ 111 + - 6.4.1 How a Function Makes a Call ........ 112 + - 6.4.2 How a Called Function Responds ........ 114 + - 6.4.3 Accessing Arguments and Local Variables ........ 114 + - 6.5 Accessing Linker Symbols in C and C++ ........ 115 + - 6.6 Interfacing C and C++ With Assembly Language ........ 115 + - 6.6.1 Using Assembly Language Modules With C/C++ Code ........ 115 + - 6.6.2 Accessing Assembly Language Functions From C/C++ ........ 116 + - 6.6.3 Accessing Assembly Language Variables From C/C++ ........ 116 + - 6.6.4 Sharing C/C++ Header Files With Assembly Source ........ 118 + - 6.6.5 Using Inline Assembly Language ........ 118 + - 6.6.6 Modifying Compiler Output ........ 118 + - 6.7 System Initialization ........ 118 + - 6.7.1 Run-Time Stack ........ 119 + - 6.7.2 Automatic Initialization of Variables ........ 119 +- **7 Using Run-Time-Support Functions and Building Libraries** ........ 124 + - 7.1 C and C++ Run-Time Support Libraries ........ 125 + - 7.1.1 Linking Code With the Object Library ........ 125 + - 7.1.2 Header Files ........ 125 + - 7.1.3 Modifying a Library Function ........ 125 + - 7.1.4 Support for String Handling ........ 126 + - 7.1.5 Minimal Support for Internationalization ........ 126 + - 7.1.6 Allowable Number of Open Files ........ 126 + - 7.1.7 Library Naming Conventions ........ 126 + - 7.2 The C I/O Functions ........ 127 + - 7.2.1 High-Level I/O Functions ........ 128 + - 7.2.2 Overview of Low-Level I/O Implementation ........ 129 + - 7.2.3 Device-Driver Level I/O Functions ........ 132 + - 7.2.4 Adding a User-Defined Device Driver for C I/O ........ 136 + - 7.2.5 The device Prefix ........ 137 + - 7.3 Handling Reentrancy (_register_lock() and _register_unlock() Functions) ........ 139 + - 7.4 Library-Build Process ........ 140 + - 7.4.1 Required Non-Texas Instruments Software ........ 140 + - 7.4.2 Using the Library-Build Process ........ 140 + - 7.4.3 Extending mklib ........ 143 +- **8 C++ Name Demangler** ........ 144 + - 8.1 Invoking the C++ Name Demangler ........ 145 + - 8.2 C++ Name Demangler Options ........ 145 + - 8.3 Sample Usage of the C++ Name Demangler ........ 145 +- **A Glossary** ........ 147 + - A.1 Terminology ........ 147 +- **B Revision History** ........ 152 + - B.1 Recent Revisions ........ 152 + +# List of Figures + +- Figure 1-1. PRU Software Development Flow ........ 12 +- Figure 6-1. Bit-Field Packing in Big-Endian and Little-Endian Formats ........ 109 +- Figure 6-2. Use of the Stack During a Function Call ........ 112 +- Figure 6-3. Autoinitialization at Run Time ........ 120 +- Figure 6-4. Initialization at Load Time ........ 122 +- Figure 6-5. Constructor Table ........ 123 + +# List of Tables + +- Table 2-1. Processor Options ........ 17 +- Table 2-2. Optimization Options ........ 17 +- Table 2-3. Advanced Optimization Options ........ 18 +- Table 2-4. Debug Options ........ 18 +- Table 2-5. Include Options ........ 18 +- Table 2-6. Control Options ........ 18 +- Table 2-7. Language Options ........ 19 +- Table 2-8. Parser Preprocessing Options ........ 19 +- Table 2-9. Predefined Symbols Options ........ 19 +- Table 2-10. Diagnostic Message Options ........ 19 +- Table 2-11. Run-Time Model Options ........ 20 +- Table 2-12. Entry/Exit Hook Options ........ 20 +- Table 2-13. Assembler Options ........ 21 +- Table 2-14. File Type Specifier Options ........ 21 +- Table 2-15. Directory Specifier Options ........ 21 +- Table 2-16. Default File Extensions Options ........ 21 +- Table 2-17. Command Files Options ........ 22 +- Table 2-18. MISRA-C 2004 Options ........ 22 +- Table 2-19. Linker Basic Options ........ 23 +- Table 2-20. File Search Path Options ........ 23 +- Table 2-21. Command File Preprocessing Options ........ 23 +- Table 2-22. Diagnostic Message Options (Linker) ........ 23 +- Table 2-23. Linker Output Options ........ 24 +- Table 2-24. Symbol Management Options ........ 24 +- Table 2-25. Run-Time Environment Options ........ 24 +- Table 2-26. Miscellaneous Options ........ 25 +- Table 2-27. Predefined PRU Macro Names ........ 32 +- Table 2-28. Raw Listing File Identifiers ........ 40 +- Table 2-29. Raw Listing File Diagnostic Identifiers ........ 40 +- Table 3-1. Interaction Between Debugging and Optimization Options ........ 47 +- Table 3-2. Options That You Can Use With --opt_level=3 ........ 47 +- Table 3-3. Selecting a Level for the --gen_opt_info Option ........ 48 +- Table 3-4. Selecting a Level for the --call_assumptions Option ........ 49 +- Table 3-5. Special Considerations When Using the --call_assumptions Option ........ 49 +- Table 3-6. Interaction Between Debugging and Optimization Options ........ 54 +- Table 4-1. Initialized Sections Created by the Compiler ........ 64 +- Table 4-2. Uninitialized Sections Created by the Compiler ........ 64 +- Table 5-1. PRU C/C++ Data Types ........ 73 +- Table 5-2. Enumerator Types ........ 73 +- Table 5-3. PRU Compiler Intrinsics for Register Transfers ........ 93 +- Table 5-4. Additional PRU Compiler Intrinsics ........ 94 +- Table 5-5. GCC Language Extensions ........ 98 +- Table 6-1. Summary of Sections and Memory Placement ........ 105 +- Table 6-2. Data Representation in Registers and Memory ........ 107 +- Table 6-3. How Register Types Are Affected by the Conventions ........ 110 +- Table 6-4. Register Usage ........ 110 +- Table 7-1. The mklib Program Options ........ 142 +- Table B-1. Revision History ........ 152 + +# Read This First + +# About This Manual + +The *PRU Optimizing C/C++ Compiler User's Guide* explains how to use the following Texas Instruments Code Generation compiler tools: + +- Compiler +- Library build utility +- C++ name demangler + +The TI compiler accepts C and C++ code conforming to the International Organization for Standardization (ISO) standards for these languages. The compiler supports both the 1989 and 1999 versions of the C language and the 2003 version of the C++ language. + +This user's guide discusses the characteristics of the TI C/C++ compiler. It assumes that you already know how to write C/C++ programs. *The C Programming Language* (second edition), by Brian W. Kernighan and Dennis M. Ritchie, describes C based on the ISO C standard. You can use the Kernighan and Ritchie (hereafter referred to as K&R) book as a supplement to this manual. References to K&R C (as opposed to ISO C) in this manual refer to the C language as defined in the first edition of Kernighan and Ritchie's *The C Programming Language*. + +# Notational Conventions + +This document uses the following conventions: + +• Program listings, program examples, and interactive displays are shown in a special typeface. Interactive displays use a bold version of the special typeface to distinguish commands that you enter from items that the system displays (such as prompts, command output, error messages, etc.). + +Here is a sample of C code: + +``` +#include +main() +{ printf("Hello World\n"); +} +``` + +- In syntax descriptions, instructions, commands, and directives are in a **bold typeface** and parameters are in an *italic typeface*. Portions of a syntax that are in bold should be entered as shown; portions of a syntax that are in italics describe the type of information that should be entered. +- Square brackets ( [ and ] ) identify an optional parameter. If you use an optional parameter, you specify the information within the brackets. Unless the square brackets are in the **bold typeface**, do not enter the brackets themselves. The following is an example of a command that has an optional parameter: + +``` +clpru [options] [filenames] [--run_linker [link_options] [object files]] +``` + +• Braces ( { and } ) indicate that you must choose one of the parameters within the braces; you do not enter the braces themselves. This is an example of a command with braces that are not included in the actual syntax but indicate that you must specify either the --rom\_model or --ram\_model option: + +``` +clpru --run_linker {--rom_model | --ram_model} filenames [--output_file= name.out] + --library= libraryname +``` + +• In assembler syntax statements, the leftmost column is reserved for the first character of a label or symbol. If the label or symbol is optional, it is usually not shown. If a label or symbol is a required parameter, it is shown starting against the left margin of the box, as in the example below. No instruction, command, directive, or parameter, other than a symbol or label, can begin in the leftmost column. + +*symbol* **.usect** "*section name*", *size in bytes*[, *alignment*] + +- Some directives can have a varying number of parameters. For example, the .byte directive. This syntax is shown as [, ..., *parameter*]. +- The PRU 16-bit instruction set is referred to as 16-BIS. +- The PRU 32-bit instruction set is referred to as 32-BIS. + +# Related Documentation + +You can use the following books to supplement this user's guide: + +**ANSI X3.159-1989, Programming Language - C (Alternate version of the 1989 C Standard)**, American National Standards Institute + +**ISO/IEC 9899:1989, International Standard - Programming Languages - C (The 1989 C Standard)**, International Organization for Standardization + +**ISO/IEC 9899:1999, International Standard - Programming Languages - C (The 1999 C Standard)**, International Organization for Standardization + +**ISO/IEC 14882-2003, International Standard - Programming Languages - C++ (The 2003 C++ Standard)**, International Organization for Standardization + +**The C Programming Language (second edition)**, by Brian W. Kernighan and Dennis M. Ritchie, published by Prentice-Hall, Englewood Cliffs, New Jersey, 1988 + +**The Annotated C++ Reference Manual**, Margaret A. Ellis and Bjarne Stroustrup, published by Addison-Wesley Publishing Company, Reading, Massachusetts, 1990 + +**C: A Reference Manual (fourth edition)**, by Samuel P. Harbison, and Guy L. Steele Jr., published by Prentice Hall, Englewood Cliffs, New Jersey + +**Programming Embedded Systems in C and C++**, by Michael Barr, Andy Oram (Editor), published by O'Reilly & Associates; ISBN: 1565923545, February 1999 + +**Programming in C**, Steve G. Kochan, Hayden Book Company + +**The C++ Programming Language (second edition)**, Bjarne Stroustrup, published by Addison-Wesley Publishing Company, Reading, Massachusetts, 1990 + +**Tool Interface Standards (TIS) DWARF Debugging Information Format Specification Version 2.0**, TIS Committee, 1995 + +**DWARF Debugging Information Format Version 3**, DWARF Debugging Information Format Workgroup, Free Standards Group, 2005 [\(http://dwarfstd.org](http://dwarfstd.org)) + +**DWARF Debugging Information Format Version 4**, DWARF Debugging Information Format Workgroup, Free Standards Group, 2010 [\(http://dwarfstd.org](http://dwarfstd.org)) + +**System V ABI specification** ([http://www.sco.com/developers/gabi/\)](http://www.sco.com/developers/gabi/) + +# Related Documentation From Texas Instruments + +See the following resources for further information about the TI Code Generation Tools: + +- Texas Instruments Wiki: [Compiler](http://processors.wiki.ti.com/index.php/Category:Compiler) topics +- Texas Instruments E2E Community: [Compiler](http://e2e.ti.com/support/development_tools/compiler/f/343) forum + +You can use the following documents to supplement this user's guide: + +- **[SPRUHV6](http://www.ti.com/lit/pdf/spruhv6) —** *PRU Assembly Language Tools User's Guide.* Describes the assembly language tools (assembler, linker, and other tools used to develop assembly language code), assembler directives, macros, common object file format, and symbolic debugging directives for PRU devices. +- **PRU-ICSS on Texas [Instruments](http://processors.wiki.ti.com/index.php/PRU-ICSS) Wiki —**Serves as a hub for the broad market PRU subsystem collateral and related resources, including software user guides, application notes, training modules, and FAQs, +- **[SPRAAB5](http://www.ti.com/lit/pdf/spraab5) —***The Impact of DWARF on TI Object Files.* Describes the Texas Instruments extensions to the DWARF specification. + +# Trademarks + +Code Composer Studio is a trademark of Texas Instruments. All other trademarks are the property of their respective owners. + +# Introduction to the Software Development Tools + +Programmable Real-Time Units (PRU) are 32-bit RISC cores. The instruction set is simple and execution times are deterministic. The programmable PRUs provide flexibility in implementing fast real-time responses, specialized data handling operations, custom peripheral interfaces, and in offloading tasks from the other processor cores of the system-on-chip (SoC). PRUs are part of the Programmable Real-Time Unit Subsystem and Industrial Communication Subsystem (PRU-ICSS), which includes two PRU cores, an interrupt controller, local data and instruction memories, internal peripheral modules, and interfaces to capture and manipulate system-wide events and pins. + +The Programmable Real-Time Unit (PRU) is supported by a set of software development tools, which includes an optimizing C/C++ compiler, an assembler, a linker, and assorted utilities. + +This chapter provides an overview of these tools and introduces the features of the optimizing C/C++ compiler. The assembler and linker are discussed in detail in the *PRU Assembly Language Tools User's Guide*. + +The PRU is optimized for performing embedded tasks that require manipulation of packed memory mapped data structures, handling of system events that have tight real-time constraints and interfacing with systems external to the SoC. The PRU is both very small and very efficient at handling such tasks. For more information about PRU, see the Texas [Instruments](http://processors.wiki.ti.com/index.php/PRU-ICSS) Wiki. + +**Topic** ........................................................................................................................... **Page** + +| | 12 | +|--------------------|-------------------------------------| +| Compiler Interface | 13 | +| ANSI/ISO Standard | 14 | +| Output Files | 14 | +| Utilities | 14 | +| | Software Development Tools Overview | + +## 1.1 Software Development Tools Overview + +Figure 1-1 illustrates the software development flow. The shaded portion of the figure highlights the most common path of software development for C language programs. The other portions are peripheral functions that enhance the development process. + +**Figure 1-1. PRU Software Development Flow** + +![](_page_11_Figure_5.jpeg) + +The following list describes the tools that are shown in Figure 1-1: + +- The **compiler** accepts C/C++ source code and produces PRU assembly language source code. See Chapter 2. +- The **assembler** translates assembly language source files into machine language relocatable object files. See the *PRU Assembly Language Tools User's Guide*. +- The **linker** combines relocatable object files into a single absolute executable object file. As it creates the executable file, it performs relocation and resolves external references. The linker accepts relocatable object files and object libraries as input. See Chapter 4 for an overview of the linker. See the *PRU Assembly Language Tools User's Guide* for details. +- The **archiver** allows you to collect a group of files into a single archive file, called a *library*. The archiver allows you to modify such libraries by deleting, replacing, extracting, or adding members. One of the most useful applications of the archiver is building a library of object files. See the *PRU Assembly Language Tools User's Guide*. +- The **run-time-support libraries** contain the standard ISO C and C++ library functions, compiler-utility functions, floating-point arithmetic functions, and C I/O functions that are supported by the compiler. See Chapter 7. + - The **library-build utility** automatically builds the run-time-support library if compiler and linker options require a custom version of the library. See Section 7.4. Source code for the standard run-time-support library functions for C and C++ is provided in the lib\src subdirectory of the directory where the compiler is installed. +- The **hex conversion utility** converts an object file into other object formats. You can download the converted file to an EPROM programmer. See the *PRU Assembly Language Tools User's Guide*. +- The **absolute lister** accepts linked object files as input and creates .abs files as output. You can assemble these .abs files to produce a listing that contains absolute, rather than relative, addresses. Without the absolute lister, producing such a listing would be tedious and would require many manual operations. See the *PRU Assembly Language Tools User's Guide*. +- The **cross-reference lister** uses object files to produce a cross-reference listing showing symbols, their definitions, and their references in the linked source files. See the *PRU Assembly Language Tools User's Guide*. +- The **C++ name demangler** is a debugging aid that converts names mangled by the compiler back to their original names as declared in the C++ source code. As shown in Figure 1-1, you can use the C++ name demangler on the assembly file that is output by the compiler; you can also use this utility on the assembler listing file and the linker map file. See Chapter 8. +- The **disassembler** decodes object files to show the assembly instructions that they represent. See the *PRU Assembly Language Tools User's Guide*. +- The main product of this development process is an executable object file that can be executed in a **PRU** device. + +## 1.2 Compiler Interface + +The compiler is a command-line program named clpru . This program can compile, optimize, assemble, and link programs in a single step. Within Code Composer Studio™, the compiler is run automatically to perform the steps needed to build a project. + +For more information about compiling a program, see Section 2.1 + +The compiler has straightforward calling conventions, so you can write assembly and C functions that call each other. For more information about calling conventions, see Chapter 6. + +## 1.3 ANSI/ISO Standard + +The compiler supports both the 1989 and 1999 versions of the C language and the 2003 version of the C++ language. The C and C++ language features in the compiler are implemented in conformance with the following ISO standards: + +### • **ISO-standard C** + +The C compiler supports the 1989 and 1999 versions of the C language. + +- **C89.** Compiling with the --c89 option causes the compiler to conform to the ISO/IEC 9899:1990 C standard, which was previously ratified as ANSI X3.159-1989. The names "C89" and "C90" refer to the same programming language. "C89" is used in this document. +- **C99.** Compiling with the --c99 option causes the compiler to conform to the ISO/IEC 9899:1999 C standard. This standard supports several features not part of C89, such as inline functions, new data types, and one-line comments beginning with //. + +The C language is also described in the second edition of Kernighan and Ritchie's *The C Programming Language* (K&R). + +### • **ISO-standard C++** + +The compiler uses the C++03 version of the C++ standard. See the C++ Standard ISO/IEC 14882:2003. The language is also described in Ellis and Stroustrup's *The Annotated C++ Reference Manual* (ARM), but that is not the standard. For a description of *unsupported* C++ features, see Section 5.2. + +# • **ISO-standard run-time support** + +The compiler tools come with an extensive run-time library. Library functions conform to the ISO C/C++ library standard unless otherwise stated. The library includes functions for standard input and output, string manipulation, dynamic memory allocation, data conversion, timekeeping, trigonometry, and exponential and hyperbolic functions. Functions for signal handling are not included, because these are target-system specific. For more information, see Chapter 7. + +See Section 5.13 for command line options to select the C or C++ standard your code uses. + +## 1.4 Output Files + +The following type of output file is created by the compiler: + +### • **ELF object files** + +Executable and Linking Format (ELF) enables supporting modern language features like early template instantiation and exporting inline functions. ELF is part of the System V [Application](http://www.sco.com/developers/gabi/) Binary Interface [\(ABI\).](http://www.sco.com/developers/gabi/) + +## 1.5 Utilities + +These features are compiler utilities: + +## • **Library-build utility** + +The library-build utility lets you custom-build object libraries from source for any combination of runtime models. For more information, see Section 7.4. + +### • **C++ name demangler** + +The C++ name demangler (dempru ) is a debugging aid that translates each mangled name it detects in compiler-generated assembly code, disassembly output, or compiler diagnostic messages to its original name found in the C++ source code. For more information, see Chapter 8. + +### • **Hex conversion utility** + +For stand-alone embedded applications, the compiler has the ability to place all code and initialization data into ROM, allowing C/C++ code to run from reset. The ELF files output by the compiler can be converted to EPROM programmer data files by using the hex conversion utility, as described in the *PRU Assembly Language Tools User's Guide*. + +# Using the C/C++ Compiler + +The compiler translates your source program into machine language object code that the PRU can execute. Source code must be compiled, assembled, and linked to create an executable object file. All of these steps are executed at once by using the compiler. + +**Topic** ........................................................................................................................... **Page** + +| 2.1 | About the Compiler | 16 | +|------|-----------------------------------------------------------------------------|----| +| 2.2 | Invoking the C/C++ Compiler | 16 | +| 2.3 | Changing the Compiler's Behavior with Options | 17 | +| 2.4 | Controlling the Compiler Through Environment Variables | 31 | +| 2.5 | Controlling the Preprocessor | 32 | +| 2.6 | Passing Arguments to main() | 35 | +| 2.7 | Understanding Diagnostic Messages | 36 | +| 2.8 | Other Messages | 39 | +| 2.9 | Generating Cross-Reference Listing Information (--gen_cross_reference Option) | 39 | +| 2.10 | Generating a Raw Listing File (--gen_preprocessor_listing Option) | 39 | +| 2.11 | Using Inline Function Expansion | 41 | +| 2.12 | Using Interlist | 43 | +| 2.13 | Enabling Entry Hook and Exit Hook Functions | 44 | + +## 2.1 About the Compiler + +The compiler lets you compile, optimize, assemble, and optionally link in one step. The compiler performs the following steps on one or more source modules: + +• The **compiler** accepts C/C++ source code and assembly code. It produces object code. You can compile C, C++, and assembly files in a single command. The compiler uses the filename extensions to distinguish between different file types. See Section 2.3.9 for more information. + +• The **linker** combines object files to create object file. The link step is optional, so you can compile and assemble many modules independently and link them later. See Chapter 4 for information about linking the files. + +### Invoking the Linker + +**NOTE:** By default, the compiler does not invoke the linker. You can invoke the linker by using the --run\_linker (-z) compiler option. See Section 4.1.1 for details. + +For a complete description of the assembler and the linker, see the *PRU Assembly Language Tools User's Guide*. + +## 2.2 Invoking the C/C++ Compiler + +To invoke the compiler, enter: + +**clpru** [*options*] [*filenames*] [**--run\_linker** [*link\_options*] *object files*]] + +**clpru** Command that runs the compiler and the assembler. + +*options* Options that affect the way the compiler processes input files. The options are listed + +in Table 2-6 through Table 2-26. + +*filenames* One or more C/C++ source files and assembly language source files. + +**--run\_linker** (**-z**) Option that invokes the linker. The --run\_linker option's short form is -z. See + +Chapter 4 for more information. + +*link\_options* Options that control the linking process. + +*object files* Names of the object files for the linking process. + +The arguments to the compiler are of three types: + +- Compiler options +- Link options +- Filenames + +The --run\_linker option indicates linking is to be performed. If the --run\_linker option is used, any compiler options must precede the --run\_linker option, and all link options must follow the --run\_linker option. + +Source code filenames must be placed before the --run\_linker option. Additional object file filenames can be placed after the --run\_linker option. + +For example, if you want to compile two files named symtab.c and file.c, assemble a third file named seek.asm, and link to create an executable program called myprogram.out, you will enter: + +``` +clpru symtab.c file.c seek.asm --run_linker --library=lnk.cmd + --output_file=myprogram.out +``` + +## 2.3 Changing the Compiler's Behavior with Options + +Options control the operation of the compiler. This section provides a description of option conventions and an option summary table. It also provides detailed descriptions of the most frequently used options, including options used for type-checking and assembling. + +For a help screen summary of the options, enter **clpru** with no parameters on the command line. + +The following apply to the compiler options: + +- There are typically two ways of specifying a given option. The "long form" uses a two hyphen prefix and is usually a more descriptive name. The "short form" uses a single hyphen prefix and a combination of letters and numbers that are not always intuitive. +- Options are usually case sensitive. +- Individual options cannot be combined. +- An option with a parameter should be specified with an equal sign before the parameter to clearly associate the parameter with the option. For example, the option to undefine a constant can be expressed as --undefine=*name*. Likewise, the option to specify the maximum amount of optimization can be expressed as -O=3. You can also specify a parameter directly after certain options, for example -O3 is the same as -O=3. No space is allowed between the option and the optional parameter, so -O 3 is not accepted. +- Files and options except the --run\_linker option can occur in any order. The --run\_linker option must follow all compiler options and precede any linker options. + +You can define default options for the compiler by using the PRU\_C\_OPTION environment variable. For a detailed description of the environment variable, see Section 2.4.1. + +Table 2-6 through Table 2-26 summarize all options (including link options). Use the references in the tables for more complete descriptions of the options. + +**Table 2-1. Processor Options** + +| Option | Alias | Effect | Section | +|---------------------------------------|-------|---------------------------------------------------------------|---------------| +| --silicon_version={ 0 \| 1 \| 2 \| 3 \| 4 } | -v | Selects the silicon version. The default is --silicon_version=3. | Section 2.3.4 | + +**Table 2-2. Optimization Options(1)** + +| Option | Alias | Effect | Section | +|--------------------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------| +| --opt_level=off | | Disables all optimization. | Section 3.1 | +| --opt_level=n | -On | Level 0 (-O0) optimizes register usage only.
Level 1 (-O1) uses Level 0 optimizations and optimizes locally.
Level 2 (-O2) uses Level 1 optimizations and optimizes globally
(default).
Level 3 (-O3) uses Level 2 optimizations and optimizes the file. ()
Level 4 (-O4) uses Level 3 optimizations and performs link-time
optimization. () | Section 3.1,
Section 3.3,
Section 3.6 | +| --opt_for_speed[=n] | -mf | Controls the tradeoff between size and speed (0-5 range). If this
option is specified without n, the default value is 4. If this option is
not specified, the default setting is 1. | Section 3.2 | +| --fp_mode={relaxed\|strict} | | Enables or disables relaxed floating-point mode. | Section 2.3.3 | +| --fp_reassoc={on\|off} | | Enables or disables the reassociation of floating-point arithmetic. | Section 2.3.3 | +| --sat_reassoc={on\|off} | | Enables or disables the reassociation of saturating arithmetic.
Default is --sat_reassoc=off. | Section 2.3.3 | + +(1) **Note:** Machine-specific options (see Table 2-11) can also affect optimization. + +# Table 2-3. Advanced Optimization Options(1) + +| Option | Alias | Effect | Section | +|-----------------------|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------| +| --auto_inline=[size] | -oi | Sets automatic inlining size (--opt_level=3 only). If size is not
specified, the default is 1. | Section 3.5 | +| --call_assumptions=n | -opn | Level 0 (-op0) specifies that the module contains functions and
variables that are called or modified from outside the source code
provided to the compiler.
Level 1 (-op1) specifies that the module contains variables modified
from outside the source code provided to the compiler but does not
use functions called from outside the source code.
Level 2 (-op2) specifies that the module contains no functions or
variables that are called or modified from outside the source code
provided to the compiler (default).
Level 3 (-op3) specifies that the module contains functions that are
called from outside the source code provided to the compiler but
does not use variables modified from outside the source code. | Section 3.4.1 | +| --gen_opt_info=n | -onn | Level 0 (-on0) disables the optimization information file.
Level 1 (-on2) produces an optimization information file.
Level 2 (-on2) produces a verbose optimization information file. | Section 3.3.1 | +| --optimizer_interlist | -os | Interlists optimizer comments with assembly statements. | Section 3.9 | +| --program_level_compile | -pm | Combines source files to perform program-level optimization. | Section 3.4 | +| --aliased_variables | -ma | Assumes called functions create hidden aliases (rare). | Section 3.7 | + +(1) **Note:** Machine-specific options (see Table 2-11) can also affect optimization. + +# Table 2-4. Debug Options + +| Option | Alias | Effect | Section | +|----------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------| +| --symdebug:dwarf | -g | Default behavior. Enables symbolic debugging. The generation of
debug information no longer impacts optimization. Therefore,
generating debug information is enabled by default. If you explicitly
use the -g option but do not specify an optimization level, no
optimization is performed. | Section 2.3.5
Section 3.10 | +| --symdebug:none | | Disables all symbolic debugging. | Section 2.3.5
Section 3.10 | + +### Table 2-5. Include Options + +| Option | Alias | Effect | Section | +|------------------------|-------|-----------------------------------------------------------|-----------------| +| --include_path=directory | -I | Adds the specified directory to the #include search path. | Section 2.5.2.1 | +| --preinclude=filename | | Includes filename at the beginning of compilation. | Section 2.3.3 | + +### Table 2-6. Control Options + +| Option | Alias | Effect | Section | +|----------------|-------|-------------------------------------------------------------------------------------------------------------------------------------|---------------| +| --compile_only | -c | Disables linking (negates --run_linker). | Section 4.1.3 | +| --help | -h | Prints (on the standard output device) a description of the options
understood by the compiler. | Section 2.3.2 | +| --run_linker | -z | Causes the linker to be invoked from the compiler command line. | Section 2.3.2 | +| --skip_assembler | -n | Compiles C/C++ source file, producing an assembly language output
file. The assembler is not run and no object file is produced. | Section 2.3.2 | + +### Table 2-7. Language Options + +| Option | Alias | Effect | Section | +|--------|-------|--------|---------| +| --c89 | | Processes C files according to the ISO C89 standard. | Section 5.13 | +| --c99 | | Processes C files according to the ISO C99 standard. | Section 5.13 | +| --c++03 | | Processes C++ files according to the ISO C++03 standard. | Section 5.13 | +| --cpp_default | -fg | Processes all source files with a C extension as C++ source files. | Section 2.3.7 | +| --exceptions | | Enables C++ exception handling. | Section 5.6 | +| --float_operations_allowed={none\|all\|32\|64} | | Restricts the types of floating point operations allowed. | Section 2.3.3 | +| --gen_cross_reference | -px | Generates a cross-reference listing file (.crl). | Section 2.9 | +| ---gen_preprocessor_listing | -pl | Generates a raw listing file (.rl). | Section 2.10 | +| --pending_instantiations=# | | Specify the number of template instantiations that may be in
progress at any given time. Use 0 to specify an unlimited number. | Section 2.3.4 | +| --plain_char={signed\|unsigned} | -mc | Specifies how to treat plain chars, default is unsigned. | Section 2.3.4 | +| --relaxed_ansi | -pr | Enables relaxed mode; ignores strict ISO violations. This is on by
default. To disable this mode, use the --strict_ansi option. | Section 5.13.2 | +| --rtti | -rtti | Enables C++ run-time type information (RTTI). | –- | +| --strict_ansi | -ps | Enables strict ANSI/ISO mode (for C/C++, not for K&R C). In this
mode, language extensions that conflict with ANSI/ISO C/C++ are
disabled. In strict ANSI/ISO mode, most ANSI/ISO violations are
reported as errors. Violations that are considered discretionary may
be reported as warnings instead. | Section 5.13.2 | + +### Table 2-8. Parser Preprocessing Options + +| Option | Alias | Effect | Section | +|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------| +| --preproc_dependency[=filename] | -ppd | Performs preprocessing only, but instead of writing preprocessed
output, writes a list of dependency lines suitable for input to a
standard make utility. | Section 2.5.8 | +| --preproc_includes[=filename] | -ppi | Performs preprocessing only, but instead of writing preprocessed
output, writes a list of files included with the #include directive. | Section 2.5.9 | +| --preproc_macros[=filename] | -ppm | Performs preprocessing only. Writes list of predefined and user
defined macros to a file with the same name as the input but with a
.pp extension. | Section 2.5.10 | +| --preproc_only | -ppo | Performs preprocessing only. Writes preprocessed output to a file
with the same name as the input but with a .pp extension. | Section 2.5.4 | +| --preproc_with_comment | -ppc | Performs preprocessing only. Writes preprocessed output, keeping
the comments, to a file with the same name as the input but with a
.pp extension. | Section 2.5.6 | +| --preproc_with_compile | -ppa | Continues compilation after preprocessing with any of the -pp
options that normally disable compilation.
| Section 2.5.5 | +| --preproc_with_line | -ppl | Performs preprocessing only. Writes preprocessed output with line
control information (#line directives) to a file with the same name as
the input but with a .pp extension. | Section 2.5.7 | + +### Table 2-9. Predefined Symbols Options + +| Option | Alias | Effect | Section | +|-------------------|-------|------------------|---------------| +| --define=name[=def] | -D | Predefines name. | Section 2.3.2 | +| --undefine=name | -U | Undefines name. | Section 2.3.2 | + +### Table 2-10. Diagnostic Message Options + +| Option | Alias | Effect | Section | +|-------------------|-------|-----------------------------------------------------------|---------------| +| --compiler_revision | | Prints out the compiler release revision and exits. | | +| --diag_error=num | -pdse | Categorizes the diagnostic identified by num as an error. | Section 2.7.1 | + +# Table 2-10. Diagnostic Message Options (continued) + +| Option | Alias | Effect | Section | +|-------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------| +| --diag_remark=num | -pdsr | Categorizes the diagnostic identified by num as a remark. | Section 2.7.1 | +| --diag_suppress=num | -pds | Suppresses the diagnostic identified by num. | Section 2.7.1 | +| --diag_warning=num | -pdsw | Categorizes the diagnostic identified by num as a warning. | Section 2.7.1 | +| --diag_wrap={on\|off} | | Wrap diagnostic messages (default is on). Note that this command
line option cannot be used within the Code Composer Studio IDE. | | +| --display_error_number | -pden | Displays a diagnostic's identifiers along with its text. Note that this
command-line option cannot be used within the Code Composer
Studio IDE. | Section 2.7.1 | +| --emit_warnings_as_errors | -pdew | Treat warnings as errors. | Section 2.7.1 | +| --issue_remarks | -pdr | Issues remarks (non-serious warnings). | Section 2.7.1 | +| --no_warnings | -pdw | Suppresses diagnostic warnings (errors are still issued). | Section 2.7.1 | +| --quiet | -q | Suppresses progress messages (quiet). | | +| --section_sizes={on\|off} | | Generates section size information, including sizes for sections
containing executable code and constants, constant or initialized
data (global and static variables), and uninitialized data. (Default is
off if this option is not included on the command line. Default is on if
this option is used with no value specified.) | Section 2.7.1 | +| --set_error_limit=num | -pdel | Sets the error limit to num. The compiler abandons compiling after
this number of errors. (The default is 100.) | Section 2.7.1 | +| --super_quiet | -qq | Super quiet mode. | | +| --tool_version | -version | Displays version number for each tool. | | +| --verbose | | Display banner and function progress information. | | +| --verbose_diagnostics | -pdv | Provides verbose diagnostic messages that display the original
source with line-wrap. Note that this command-line option cannot be
used within the Code Composer Studio IDE. | Section 2.7.1 | +| --write_diagnostics_file | -pdf | Generates a diagnostic message information file. Compiler only
option. Note that this command-line option cannot be used within the
Code Composer Studio IDE. | Section 2.7.1 | + +### Table 2-11. Run-Time Model Options + +| Option | Alias | Effect | Section | +|-------------------------------------------|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------| +| --endian={ big \| little } | | Specify the endianness of both code and data. If not specified,
compiler defaults to --endian=little. | Section 2.3.4 | +| --gen_data_subsections={on\|off} | | Place all aggregate data (arrays, structs, and unions) into
subsections. This gives the linker more control over removing
unused data during the final link step. The default is on. | Section 4.2.1 | +| --hardware_mac={on\|off} | | Enables use of the hardware MAC available on some PRU cores.
Defaults to --hardware_mac=off. | Section 2.3.4 | +| --mem_model:data={ near \| far } | | Specifies data access model. When not specified, compiler defaults
to --mem_model:data=near. | Section 5.5.2 | +| --printf_support={nofloat\|full\|minimal} | | Enables support for smaller, limited versions of the printf function
family (sprintf, fprintf, etc.) and the scanf function family (sscanf,
fscanf, etc.) run-time-support functions. | Section 2.3.3 | + +### Table 2-12. Entry/Exit Hook Options + +| Option | Alias | Effect | Section | +|------------------------------------|-------|-------------------------------------------------------------------|--------------| +| --entry_hook[=name] | | Enables entry hooks. | Section 2.13 | +| --entry_parm={none\|name\|address} | | Specifies the parameters to the function to the --entry_hook option. | Section 2.13 | +| --exit_hook[=name] | | Enables exit hooks. | Section 2.13 | +| --exit_parm={none\|name\|address} | | Specifies the parameters to the function to the --exit_hook option. | Section 2.13 | +| --remove_hooks_when_inlining | | Removes entry/exit hooks for auto-inlined functions. | Section 2.13 | + +### Table 2-13. Assembler Options + +| Option | Alias | Effect | Section | +|-----------------------------|-------|----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------| +| --keep_asm | -k | Keeps the assembly language (.asm) file. | Section 2.3.11 | +| --asm_listing | -al | Generates an assembly listing file. | Section 2.3.11 | +| --c_src_interlist | -ss | Interlists C source and assembly statements. | Section 2.12
Section 3.9 | +| --src_interlist | -s | Interlists optimizer comments (if available) and assembly source
statements; otherwise interlists C and assembly source statements. | Section 2.3.2 | +| --absolute_listing | -aa | Enables absolute listing. | Section 2.3.11 | +| --asm_define=name[=def] | -ad | Sets the name symbol. | Section 2.3.11 | +| --asm_dependency | -apd | Performs preprocessing; lists only assembly dependencies. | Section 2.3.11 | +| --asm_includes | -api | Performs preprocessing; lists only included #include files. | Section 2.3.11 | +| --asm_undefine=name | -au | Undefines the predefined constant name. | Section 2.3.11 | +| --asm_listing_cross_reference | -ax | Generates the cross-reference file. | Section 2.3.11 | +| --include_file=filename | -ahi | Includes the specified file for the assembly module. | Section 2.3.11 | + +# Table 2-14. File Type Specifier Options + +| Option | Alias | Effect | Section | +|-------------------|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------| +| --asm_file=filename | -fa | Identifies filename as an assembly source file regardless of its
extension. By default, the compiler and assembler treat .asm files as
assembly source files. | Section 2.3.7 | +| --c_file=filename | -fc | Identifies filename as a C source file regardless of its extension. By
default, the compiler treats .c files as C source files. | Section 2.3.7 | +| --cpp_file=filename | -fp | Identifies filename as a C++ file, regardless of its extension. By
default, the compiler treats .C, .cpp, .cc and .cxx files as a C++ files. | Section 2.3.7 | +| --obj_file=filename | -fo | Identifies filename as an object code file regardless of its extension.
By default, the compiler and linker treat .obj files as object code files. | Section 2.3.7 | + +### Table 2-15. Directory Specifier Options + +| Option | Alias | Effect | Section | +|--------------------------|-------|------------------------------------------------------------------------------------------------------------------------------------|----------------| +| --abs_directory=directory | -fb | Specifies an absolute listing file directory. By default, the compiler
uses the .obj directory. | Section 2.3.10 | +| --asm_directory=directory | -fs | Specifies an assembly file directory. By default, the compiler uses
the current directory. | Section 2.3.10 | +| --list_directory=directory | -ff | Specifies an assembly listing file and cross-reference listing file
directory By default, the compiler uses the .obj directory. | Section 2.3.10 | +| --obj_directory=directory | -fr | Specifies an object file directory. By default, the compiler uses the
current directory. | Section 2.3.10 | +| --output_file=filename | -fe | Specifies a compilation output file name; can override
--obj_directory. | Section 2.3.10 | +| --pp_directory=dir | | Specifies a preprocessor file directory. By default, the compiler uses
the current directory. | Section 2.3.10 | +| --temp_directory=directory | -ft | Specifies a temporary file directory. By default, the compiler uses the
current directory. | Section 2.3.10 | + +### Table 2-16. Default File Extensions Options + +| Option | Alias | Effect | Section | +|--------------------------------|-------|-----------------------------------------------------|---------------| +| --asm_extension=[.]extension | -ea | Sets a default extension for assembly source files. | Section 2.3.9 | +| --c_extension=[.]extension | -ec | Sets a default extension for C source files. | Section 2.3.9 | +| --cpp_extension=[.]extension | -ep | Sets a default extension for C++ source files. | Section 2.3.9 | +| --listing_extension=[.]extension | -es | Sets a default extension for listing files. | Section 2.3.9 | +| --obj_extension=[.]extension | -eo | Sets a default extension for object files. | Section 2.3.9 | + +### Table 2-17. Command Files Options + +| Option | Alias | Effect | Section | +|-------------------|-------|----------------------------------------------------------------------------------------------------------|---------------| +| --cmd_file=filename | -@ | Interprets contents of a file as an extension to the command line.
Multiple -@ instances can be used. | Section 2.3.2 | + +### Table 2-18. MISRA-C 2004 Options + +| Option | Alias | Effect | Section | +|---------------------------------------------------------|-------|--------------------------------------------------------------------------|---------------| +| --check_misra[={all\|required\|advisory\|none\|rulespec}] | | Enables checking of the specified MISRA-C:2004 rules. Default is
all. | Section 2.3.3 | +| --misra_advisory={error\|warning\|remark\|suppress} | | Sets the diagnostic severity for advisory MISRA-C:2004 rules. | Section 2.3.3 | +| --misra_required={error\|warning\|remark\|suppress} | | Sets the diagnostic severity for required MISRA-C:2004 rules. | Section 2.3.3 | + +### 2.3.1 Linker Options + +The following tables list the linker options. See Chapter 4 of this document and the *PRU Assembly Language Tools User's Guide* for details on these options. + +# Table 2-19. Linker Basic Options + +| Option | Alias | Description | +|------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------| +| --run_linker | -z | Enables linking. | +| --output_file=file | -o | Names the executable output file. The default filename is a .out file. | +| --map_file=file | -m | Produces a map or listing of the input and output sections, including holes, and places
the listing in file. | +| --stack_size=size | [-]-stack | Sets C system stack size to size bytes and defines a global symbol that specifies the
stack size. Default = 256 bytes. | +| --heap_size=size | [-]-heap | Sets heap size (for the dynamic memory allocation in C) to size bytes and defines a
global symbol that specifies the heap size. Default = 256 bytes. | + +### Table 2-20. File Search Path Options + +| Option | Alias | Description | +|----------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| --library=file | -l | Names an archive library or link command file as linker input. | +| --search_path=pathname | -I | Alters library-search algorithms to look in a directory named with pathname before
looking in the default location. This option must appear before the --library option. | +| --priority | -priority | Satisfies unresolved references by the first library that contains a definition for that
symbol. | +| --reread_libs | -x | Forces rereading of libraries, which resolves back references. | +| --disable_auto_rts | | Disables the automatic selection of a run-time-support library. See Section 4.3.1.1. | + +### Table 2-21. Command File Preprocessing Options + +| Option | Alias | Description | +|-------------------|-------|-------------------------------------------| +| --define=name=value | | Predefines name as a preprocessor macro. | +| --undefine=name | | Removes the preprocessor macro name. | +| --disable_pp | | Disables preprocessing for command files. | + +#### Table 2-22. Diagnostic Message Options + +| Option | Alias | Description | +|-------------------------|-------|------------------------------------------------------------------------------------------------------------------| +| --diag_error=num | | Categorizes the diagnostic identified by num as an error. | +| --diag_remark=num | | Categorizes the diagnostic identified by num as a remark. | +| --diag_suppress=num | | Suppresses the diagnostic identified by num. | +| --diag_warning=num | | Categorizes the diagnostic identified by num as a warning. | +| --display_error_number | | Displays a diagnostic's identifiers along with its text. | +| --emit_warnings_as_errors | -pdew | Treat warnings as errors. | +| --issue_remarks | | Issues remarks (non-serious warnings). | +| --no_demangle | | Disables demangling of symbol names in diagnostic messages. | +| --no_warnings | | Suppresses diagnostic warnings (errors are still issued). | +| --set_error_limit=count | | Sets the error limit to count. The linker abandons linking after this number of errors. (The
default is 100.) | +| --verbose_diagnostics | | Provides verbose diagnostic messages that display the original source with line-wrap. | +| --warn_sections | -w | Displays a message when an undefined output section is created. | + +### Table 2-23. Linker Output Options + +| Option | Alias | Description | +|------------------------------|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| --absolute_exe | -a | Produces an absolute, executable object file. This is the default; if neither --absolute_exe
nor --relocatable is specified, the linker acts as if --absolute_exe were specified. | +| --code_endian={ big \| little } | | Specify the endianness for code sections. The default is that code endianness is the
same as the data endianness, which defaults to little-endian. For relocatable object files,
the endianness must be the same for code and data. However, for memory stored on
the PRU core itself, code and data endianness can be different. | +| --ecc={ on \| off } | | Enable linker-generated Error Correcting Codes (ECC). The default is off. | +| --ecc:data_error | | Inject specified errors into the output file for testing. | +| --ecc:ecc_error | | Inject specified errors into the Error Correcting Code (ECC) for testing. | +| --mapfile_contents=attribute | | Controls the information that appears in the map file. | +| --relocatable | -r | Produces a nonexecutable, relocatable output object file. | +| --rom | | Creates a ROM object. | +| --run_abs | -abs | Produces an absolute listing file. | +| --xml_link_info=file | | Generates a well-formed XML file containing detailed information about the result of a
link. | + +### Table 2-24. Symbol Management Options + +| Option | Alias | Description | +|----------------------------|-----------|---------------------------------------------------------------------------------------------------------------------| +| --entry_point=symbol | -e | Defines a global symbol that specifies the primary entry point for the executable object
file. | +| --globalize=pattern | | Changes the symbol linkage to global for symbols that match pattern. | +| --hide=pattern | | Hides symbols that match the specified pattern. | +| --localize=pattern | | Make the symbols that match the specified pattern local. | +| --make_global=symbol | -g | Makes symbol global (overrides -h). | +| --make_static | -h | Makes all global symbols static. | +| --no_sym_merge | -b | Disables merging of types in symbolic debugging information. | +| --no_symtable | -s | Strips symbol table information and line number entries from the executable object file. | +| --retain | | Retains a list of sections that otherwise would be discarded. | +| --scan_libraries | -scanlibs | Scans all libraries for duplicate symbol definitions. | +| --symbol_map=refname=defname | | Specifies a symbol mapping; references to the refname symbol are replaced with
references to the defname symbol. | +| --undef_sym=symbol | -u | Adds symbol to the symbol table as an unresolved symbol. | +| --unhide=pattern | | Excludes symbols that match the specified pattern from being hidden. | + +#### Table 2-25. Run-Time Environment Options + +| Option | Alias | Description | +|--------------------------|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| --arg_size=size | --args | Reserve size bytes for the argc/argv memory area. | +| --cinit_compression[=type] | | Specifies the type of compression to apply to the C auto initialization data. The default if
this option is specified with no type is lzss for Lempel-Ziv-Storer-Szymanski
compression. | +| --copy_compression[=type] | | Compresses data copied by linker copy tables. The default if this option is specified with
no type is lzss for Lempel-Ziv-Storer-Szymanski compression. | +| --fill_value=value | -f | Sets default fill value for holes within output sections | +| --ram_model | -cr | Initializes variables at load time. | +| --rom_model | -c | Autoinitializes variables at run time. | + +### Table 2-26. Miscellaneous Options + +| Option | Alias | Description | +|-------------------------------------|----------|---------------------------------------------------------------------------------------------------------| +| --compress_dwarf[=off\|on] | | Aggressively reduces the size of DWARF information from input object files. Default is
on. | +| --linker_help | [-]-help | Displays information about syntax and available options. | +| --preferred_order=function | | Prioritizes placement of functions. | +| --strict_compatibility[=off\|on] | | Performs more conservative and rigorous compatibility checking of input object files.
Default is on. | +| --unused_section_elimination[=off\|on] | | Eliminates sections that are not needed in the executable module. Default is on. | +| --zero_init=[off\|on] | | Controls preinitialization of uninitialized variables. Default is on. | + +### 2.3.2 Frequently Used Options + +Following are detailed descriptions of options that you will probably use frequently: + +| --c_src_interlist | Invokes the interlist feature, which interweaves original C/C++ source
with compiler-generated assembly language. The interlisted C
statements may appear to be out of sequence. You can use the interlist
feature with the optimizer by combining the --optimizer_interlist and
--c_src_interlist options. See Section 3.9. The --c_src_interlist option can
have a negative performance and/or code size impact. | | +|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--| +| --cmd_file=filename | Appends the contents of a file to the option set. You can use this option
to avoid limitations on command line length or C style comments
imposed by the host operating system. Use a # or ; at the beginning of a
line in the command file to include comments. You can also include
comments by delimiting them with /* and */. To specify options, surround
hyphens with quotation marks. For example, "--"quiet. | | +| | You can use the --cmd_file option multiple times to specify multiple files.
For instance, the following indicates that file3 should be compiled as
source and file1 and file2 are --cmd_file files:
clpru --cmd_file=file1 --cmd_file=file2 file3 | | +| --compile_only | Suppresses the linker and overrides the --run_linker option, which
specifies linking. The --compile_only option's short form is -c. Use this
option when you have --run_linker specified in the PRU_C_OPTION
environment variable and you do not want to link. See Section 4.1.3. | | +| --define=name[=def] | Predefines the constant name for the preprocessor. This is equivalent to
inserting #define name def at the top of each C source file. If the
optional[=def] is omitted, the name is set to 1. The --define option's short
form is -D. | | +| | If you want to define a quoted string and keep the quotation marks, do
one of the following: | | +| | •
For Windows, use --define=name="\"string def\"". For example, --
define=car="\"sedan\"" | | +| | •
For UNIX, use --define=name='"string def"'. For example, --
define=car='"sedan"' | | +| | •
For Code Composer Studio, enter the definition in a file and include
that file with the --cmd_file option. | | +| --help | Displays the syntax for invoking the compiler and lists available options.
If the --help option is followed by another option or phrase, detailed
information about the option or phrase is displayed. For example, to see
information about debugging options use --help debug. | | + +**--include\_path**=*directory* Adds *directory* to the list of directories that the compiler searches for #include files. The --include\_path option's short form is -I. You can use this option several times to define several directories; be sure to separate the --include\_path options with spaces. If you do not specify a directory name, the preprocessor ignores the --include\_path option. See Section 2.5.2.1. + +**--keep\_asm** Retains the assembly language output from the compiler or assembly optimizer. Normally, the compiler deletes the output assembly language file after assembly is complete. The --keep\_asm option's short form is -k. + +**--quiet** Suppresses banners and progress information from all the tools. Only source filenames and error messages are output. The --quiet option's short form is -q. + +**--run\_linker** Runs the linker on the specified object files. The --run\_linker option and its parameters follow all other options on the command line. All arguments that follow --run\_linker are passed to the linker. The --run\_linker option's short form is -z. See Section 4.1. + +**--skip\_assembler** Compiles only. The specified source files are compiled but not assembled or linked. The --skip\_assembler option's short form is -n. This option overrides --run\_linker. The output is assembly language output from the compiler. + +**--src\_interlist** Invokes the interlist feature, which interweaves optimizer comments *or* C/C++ source with assembly source. If the optimizer is invoked (--opt\_level=*n* option), optimizer comments are interlisted with the assembly language output of the compiler, which may rearrange code significantly. If the optimizer is not invoked, C/C++ source statements are interlisted with the assembly language output of the compiler, which allows you to inspect the code generated for each C/C++ statement. The --src\_interlist option implies the --keep\_asm option. The --src\_interlist option's short form is -s. + +**--tool\_version** Prints the version number for each tool in the compiler. No compiling occurs. + +**--undefine**=*name* Undefines the predefined constant *name*. This option overrides any --define options for the specified constant. The --undefine option's short form is -U. + +**--verbose** Displays progress information and toolset version while compiling. Resets the --quiet option. + +### 2.3.3 Miscellaneous Useful Options + +Following are detailed descriptions of miscellaneous options: + +**--check\_misra**={all|required| advisory|none|*rulespec*} + +Displays the specified amount or type of MISRA-C documentation. This option must be used if you want to enable use of the CHECK\_MISRA and RESET\_MISRA pragmas within the source code. The *rulespec* parameter is a comma-separated list of specifiers. See Section 5.3 for details. + +**--float\_operations\_allowed**= {none|all|32|64} + +Restricts the type of floating point operations allowed in the application. The default is all. If set to none, 32, or 64, the application is checked for operations that will be performed at runtime. For example, if --float\_operations\_allowed=32 is specified on the command line, the compiler issues an error if a double precision operation will be generated. This can be used to ensure that double precision operations are not accidentally introduced into an application. The checks are performed after relaxed mode optimizations have been performed, so illegal operations that are completely removed result in no diagnostic messages. + +**--fp\_mode**={relaxed|strict} The default floating-point mode is strict. To enable relaxed floatingpoint mode use the --fp\_mode=relaxed option. Relaxed floating-point mode causes double-precision floating-point computations and storage to be converted to integers where possible. This behavior does not conform with ISO, but it results in faster code, with some loss in accuracy. The following specific changes occur in relaxed mode: + +- Division by a constant is converted to inverse multiplication. +- Note that the PRU does not provide hardware floating point support. Floating point emulation routines are provided. + +**--fp\_reassoc**={on|off} Enables or disables the reassociation of floating-point arithmetic. Because floating-point values are of limited precision, and because floating-point operations round, floating-point arithmetic is neither associative nor distributive. For instance, (1 + 3e100) - 3e100 is not equal to 1 + (3e100 - 3e100). If strictly following IEEE 754, the compiler cannot, in general, reassociate floating-point operations. Using --fp\_reassoc=on allows the compiler to perform the algebraic reassociation, at the cost of a small amount of precision for some operations. + +**--misra\_advisory**={error| warning|remark|suppress} Sets the diagnostic severity for advisory MISRA-C:2004 rules. + +**--misra\_required**={error| warning|remark|suppress} Sets the diagnostic severity for required MISRA-C:2004 rules. + +**--preinclude**=*filename* Includes the source code of *filename* at the beginning of the compilation. This can be used to establish standard macro definitions. The filename is searched for in the directories on the include search list. The files are processed in the order in which they were specified. + +**--printf\_support**={full| nofloat|minimal} + +Enables support for smaller, limited versions of the printf function family (sprintf, fprintf, etc.) and the scanf function family (sscanf, fscanf, etc.) run-time-support functions. The valid values are: + +- full: Supports all format specifiers. This is the default. +- nofloat: Excludes support for printing and scanning floating-point values. Supports all format specifiers except %a, %A, %f, %F, %g, %G, %e, and %E. +- minimal: Supports the printing and scanning of integer, char, or string values without width or precision flags. Specifically, only the %%, %d, %o, %c, %s, and %x format specifiers are supported + +There is no run-time error checking to detect if a format specifier is used for which support is not included. The --printf\_support option precedes the --run\_linker option, and must be used when performing the final link. + +**--sat\_reassoc**={on|off} Enables or disables the reassociation of saturating arithmetic. + +### 2.3.4 Run-Time Model Options + +These options are specific to the PRU toolset. See the referenced sections for more information. PRU-specific assembler options are listed in Section 2.3.11. + +**--endian**={ big | little } Designates big- or little-endian format for compiled code and data. By default, little-endian format is used. (The linker provides a --code\_endian option, which can be used in certain situations to make the code endianness different from the data endianness.) + +| --hardware_mac={ on \| off } | Enables use of the hardware multiply accumulate (MAC) feature
available on some PRU cores. This feature can be used to speed up
32-bit multiplication or multiply-accumulate instructions that result in a
64-bit result. If not specified, compiler defaults to
--hardware_mac=off. | +|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| --mem_model:data={ near \| far } | Specifies data access model as near or far. The default is near. See
Section 5.5.2. | +| --pending_instantiations=# | Specify the number of template instantiations that may be in progress
at any given time. Use 0 to specify an unlimited number. | +| --plain_char={signed\|unsigned} | Specifies how to treat C/C++ plain char variables. Default is signed. | +| --silicon_version=num | Selects the processor version. The num parameter can be: 0, 1, 2, 3,
or 4. The default is 3. | + +### 2.3.5 Symbolic Debugging Options + +The following options are used to select symbolic debugging: + +| --symdebug:dwarf | (Default) Generates directives that are used by the C/C++ source-level
debugger and enables assembly source debugging in the assembler.
The --symdebug:dwarf option's short form is -g. See Section 3.10. | +|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| | For more information on the DWARF debug format, see The DWARF
Debugging Standard. | +| --symdebug:none | Disables all symbolic debugging output. This option is not recommended;
it prevents debugging and most performance analysis capabilities. | + +### 2.3.6 Specifying Filenames + +The input files that you specify on the command line can be C source files, C++ source files, assembly source files, or object files. The compiler uses filename extensions to determine the file type. + +| Extension | File Type | +|----------------------------------------------|-----------------------------| +| .asm, .abs, or .s* (extension begins with s) | Assembly source | +| .c | C source | +| .C | Depends on operating system | +| .cpp, .cxx, .cc | C++ source | +| .obj .o* .dll .so | Object | + +### NOTE: Case Sensitivity in Filename Extensions + +Case sensitivity in filename extensions is determined by your operating system. If your operating system is not case sensitive, a file with a .C extension is interpreted as a C file. If your operating system is case sensitive, a file with a .C extension is interpreted as a C++ file. + +For information about how you can alter the way that the compiler interprets individual filenames, see Section 2.3.7. For information about how you can alter the way that the compiler interprets and names the extensions of assembly source and object files, see Section 2.3.10. + +You can use wildcard characters to compile or assemble multiple files. Wildcard specifications vary by system; use the appropriate form listed in your operating system manual. For example, to compile all of the files in a directory with the extension .cpp, enter the following: + +**clpru \*.cpp** + +#### NOTE: No Default Extension for Source Files is Assumed + +If you list a filename called example on the command line, the compiler assumes that the entire filename is example not example.c. No default extensions are added onto files that do not contain an extension. + +### 2.3.7 Changing How the Compiler Interprets Filenames + +You can use options to change how the compiler interprets your filenames. If the extensions that you use are different from those recognized by the compiler, you can use the filename options to specify the type of file. You can insert an optional space between the option and the filename. Select the appropriate option for the type of file you want to specify: + +**--asm\_file**=*filename* for an assembly language source file + +**--c\_file**=*filename* for a C source file **--cpp\_file**=*filename* for a C++ source file **--obj\_file**=*filename* for an object file + +For example, if you have a C source file called file.s and an assembly language source file called assy, use the --asm\_file and --c\_file options to force the correct interpretation: + +``` +clpru --c_file=file.s --asm_file=assy +``` + +You cannot use the filename options with wildcard specifications. + +### 2.3.8 Changing How the Compiler Processes C Files + +The --cpp\_default option causes the compiler to process C files as C++ files. By default, the compiler treats files with a .c extension as C files. See Section 2.3.9 for more information about filename extension conventions. + +### 2.3.9 Changing How the Compiler Interprets and Names Extensions + +You can use options to change how the compiler program interprets filename extensions and names the extensions of the files that it creates. The filename extension options must precede the filenames they apply to on the command line. You can use wildcard specifications with these options. An extension can be up to nine characters in length. Select the appropriate option for the type of extension you want to specify: + +**--asm\_extension**=*new extension* for an assembly language file + +**--c\_extension**=*new extension* for a C source file **--cpp\_extension**=*new extension* for a C++ source file + +**--listing\_extension**=*new extension* sets default extension for listing files + +**--obj\_extension**=*new extension* for an object file + +The following example assembles the file fit.rrr and creates an object file named fit.o: + +``` +clpru --asm_extension=.rrr --obj_extension=.o fit.rrr +``` + +The period (.) in the extension is optional. You can also write the example above as: + +``` +clpru --asm_extension=rrr --obj_extension=o fit.rrr +``` + +### 2.3.10 Specifying Directories + +By default, the compiler program places the object, assembly, and temporary files that it creates into the current directory. If you want the compiler program to place these files in different directories, use the following options: + +**--abs\_directory**=*directory* Specifies the destination directory for absolute listing files. The default is + +to use the same directory as the object file directory. For example: + +clpru --abs\_directory=d:\abso\_list + +**--asm\_directory**=*directory* Specifies a directory for assembly files. For example: + +clpru --asm\_directory=d:\assembly + +**--list\_directory**=*directory* Specifies the destination directory for assembly listing files and cross- + +reference listing files. The default is to use the same directory as the + +object file directory. For example: clpru --list\_directory=d:\listing + +**--obj\_directory**=*directory* Specifies a directory for object files. For example: + +clpru --obj\_directory=d:\object + +**--output\_file**=*filename* Specifies a compilation output file name; can override --obj\_directory . For + +example: + +clpru --output\_file=transfer + +**--pp\_directory**=*directory* Specifies a preprocessor file directory for object files (default is .). For + +example: + +clpru --pp\_directory=d:\preproc + +**--temp\_directory**=*directory* Specifies a directory for temporary intermediate files. For example: + +clpru --temp\_directory=d:\temp + +### 2.3.11 Assembler Options + +Following are assembler options that you can use with the compiler. For more information, see the *PRU Assembly Language Tools User's Guide.* + +**--absolute\_listing** Generates a listing with absolute addresses rather than section-relative offsets. + +**--asm\_define**=*name*[=*def*] Predefines the constant *name* for the assembler; produces a .set directive for a constant or an .arg directive for a string. If the optional [=*def*] is omitted, the *name* is set to 1. If you want to define a quoted + +string and keep the quotation marks, do one of the following: + +• For Windows, use --asm\_define=*name*="\"*string def*\"". For example: --asm\_define=car="\"sedan\"" + +• For UNIX, use --asm\_define=*name*='"*string def*"'. For example: --asm\_define=car='"sedan"' +• For Code Composer Studio, enter the definition in a file and include that file with the --cmd\_file option. + +**--asm\_dependency** Performs preprocessing for assembly files, but instead of writing preprocessed output, writes a list of dependency lines suitable for input to a standard make utility. The list is written to a file with the same name as the source file but with a .ppa extension. + +**--asm\_includes** Performs preprocessing for assembly files, but instead of writing preprocessed output, writes a list of files included with the #include directive. The list is written to a file with the same name as the source file but with a .ppa extension. + +**--asm\_listing** Produces an assembly listing file. + +**--asm\_undefine**=*name* Undefines the predefined constant *name*. This option overrides any --asm\_define options for the specified name. + +**--asm\_listing\_cross\_reference** Produces a symbolic cross-reference in the listing file. + +**--include\_file**=*filename* Includes the specified file for the assembly module; acts like an .include directive. The file is included before source file statements. The included file does not appear in the assembly listing files. + +## 2.4 Controlling the Compiler Through Environment Variables + +An environment variable is a system symbol that you define and assign a string to. Setting environment variables is useful when you want to run the compiler repeatedly without re-entering options, input filenames, or pathnames. + +**NOTE: C\_OPTION and C\_DIR --** The C\_OPTION and C\_DIR environment variables are deprecated. Use device-specific environment variables instead. + +### 2.4.1 Setting Default Compiler Options (PRU\_C\_OPTION) + +You might find it useful to set the compiler, assembler, and linker default options using the PRU\_C\_OPTION environment variable. If you do this, the compiler uses the default options and/or input filenames that you name PRU\_C\_OPTION every time you run the compiler. + +Setting the default options with these environment variables is useful when you want to run the compiler repeatedly with the same set of options and/or input files. After the compiler reads the command line and the input filenames, it looks for the PRU\_C\_OPTION environment variable and processes it. + +The table below shows how to set the PRU\_C\_OPTION environment variable. Select the command for your operating system: + +| Operating System | Enter | +|---------------------|---------------------------------------------------------------| +| UNIX (Bourne shell) | PRU_C_OPTION=" option1
[option2
]"; export PRU_C_OPTION | +| Windows | set PRU_C_OPTION= option1
[option2
] | + +Environment variable options are specified in the same way and have the same meaning as they do on the command line. For example, if you want to always run quietly (the --quiet option), enable C/C++ source interlisting (the --src\_interlist option), and link (the --run\_linker option) for Windows, set up the PRU\_C\_OPTION environment variable as follows: + +``` +set PRU_C_OPTION=--quiet --src_interlist --run_linker +``` + +In the following examples, each time you run the compiler, it runs the linker. Any options following --run\_linker on the command line or in PRU\_C\_OPTION are passed to the linker. Thus, you can use the PRU\_C\_OPTION environment variable to specify default compiler and linker options and then specify additional compiler and linker options on the command line. If you have set --run\_linker in the environment variable and want to compile only, use the compiler --compile\_only option. These additional examples assume PRU\_C\_OPTION is set as shown above: + +``` +clpru *c ; compiles and links +clpru --compile_only *.c ; only compiles +clpru *.c --run_linker lnk.cmd ; compiles and links using a command file +clpru --compile_only *.c --run_linker lnk.cmd + ; only compiles (--compile_only overrides --run_linker) +``` + +For details on compiler options, see Section 2.3. For details on linker options, see the *Linker Description* chapter in the *PRU Assembly Language Tools User's Guide*. + +### 2.4.2 Naming One or More Alternate Directories (PRU\_C\_OPTION) + +The linker uses the PRU\_C\_OPTION environment variable to name alternate directories that contain object libraries. The command syntaxes for assigning the environment variable are: + +| Operating System | Enter | +|---------------------|--------------------------------------------------------------------| +| UNIX (Bourne shell) | PRU_C_OPTION=" pathname1
; pathname2
;"; export PRU_C_OPTION | +| Windows | set PRU_C_OPTION= pathname1
; pathname2
; | + +The *pathnames* are directories that contain input files. The pathnames must follow these constraints: + +- Pathnames must be separated with a semicolon. +- Spaces or tabs at the beginning or end of a path are ignored. For example, the space before and after the semicolon in the following is ignored: + +``` +set PRU_C_DIR=c:\path\one\to\tools ; c:\path\two\to\tools +``` + +• Spaces and tabs are allowed within paths to accommodate Windows directories that contain spaces. For example, the pathnames in the following are valid: + +``` +set PRU_C_DIR=c:\first path\to\tools;d:\second path\to\tools +``` + +The environment variable remains set until you reboot the system or reset the variable by entering: + +| Operating System | Enter | +|---------------------|-----------------| +| UNIX (Bourne shell) | unset PRU_C_DIR | +| Windows | set PRU_C_DIR= | + +## 2.5 Controlling the Preprocessor + +This section describes features that control the preprocessor, which is part of the parser. A general description of C preprocessing is in section A12 of K&R. The C/C++ compiler includes standard C/C++ preprocessing functions, which are built into the first pass of the compiler. The preprocessor handles: + +- Macro definitions and expansions +- #include files +- Conditional compilation +- Various preprocessor directives, specified in the source file as lines beginning with the # character + +The preprocessor produces self-explanatory error messages. The line number and the filename where the error occurred are printed along with a diagnostic message. + +### 2.5.1 Predefined Macro Names + +The compiler maintains and recognizes the predefined macro names listed in Table 2-27. + +**Table 2-27. Predefined PRU Macro Names** + +| Macro Name | Description | +|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| (1)
DATE | Expands to the compilation date in the form mmm dd yyyy | +| (1)
FILE | Expands to the current source filename | +| (1)
LINE | Expands to the current line number | +| (1)
STDC | Defined to indicate that compiler conforms to ISO C Standard. See Section 5.1 for
exceptions to ISO C conformance. | +| STDC_VERSION | C standard macro | +| TI_COMPILER_VERSION | Defined to a 7-9 digit integer, depending on if X has 1, 2, or 3 digits. The number does
not contain a decimal. For example, version 3.2.1 is represented as 3002001. The
leading zeros are dropped to prevent the number being interpreted as an octal. | +| TI_GNU_ATTRIBUTE_SUPPORT | Defined if GCC extensions are enabled (which is the default) | +| TI_STRICT_ANSI_MODE | Defined if strict ANSI/ISO mode is enabled (the --strict_ansi option is used); otherwise, it
is undefined. | +| TI_STRICT_FP_MODE | Defined to 1 if --fp_mode=strict is used (or implied); otherwise, it is undefined. | +| (1)
TIME | Expands to the compilation time in the form "hh:mm:ss" | +| _INLINE | Expands to 1 if optimization is used (--opt_level or -O option); undefined otherwise. | + +(1) Specified by the ISO standard + +``` +You can use the names listed in Table 2-27 in the same manner as any other defined name. For example, +printf ( "%s %s" , __TIME__ , __DATE__); +translates to a line such as: +printf ("%s %s" , "13:58:17", "Jan 14 1997"); +``` + +### 2.5.2 The Search Path for #include Files + +The #include preprocessor directive tells the compiler to read source statements from another file. When specifying the file, you can enclose the filename in double quotes or in angle brackets. The filename can be a complete pathname, partial path information, or a filename with no path information. + +- If you enclose the filename in double quotes (" "), the compiler searches for the file in the following directories in this order: + - 1. The directory of the file that contains the #include directive and in the directories of any files that contain that file. + - 2. Directories named with the --include\_path option. + - 3. Directories set with the PRU\_C\_OPTION environment variable. +- If you enclose the filename in angle brackets (< >), the compiler searches for the file in the following directories in this order: + - 1. Directories named with the --include\_path option. + - 2. Directories set with the PRU\_C\_OPTION environment variable. + +See Section 2.5.2.1 for information on using the --include\_path option. See Section 2.4.2 for more information on input file directories. + +#### 2.5.2.1 Adding a Directory to the #include File Search Path (--include\_path Option) + +The --include\_path option names an alternate directory that contains #include files. The --include\_path option's short form is -I. The format of the --include\_path option is: + +``` +--include_path=directory1 [--include_path= directory2 ...] +``` + +There is no limit to the number of --include\_path options per invocation of the compiler; each --include\_path option names one *directory*. In C source, you can use the #include directive without specifying any directory information for the file; instead, you can specify the directory information with the --include\_path option. + +For example, assume that a file called source.c is in the current directory. The file source.c contains the following directive statement: + +``` +#include "alt.h" +``` + +Assume that the complete pathname for alt.h is: + +UNIX /tools/files/alt.h Windows c:\tools\files\alt.h + +The table below shows how to invoke the compiler. Select the command for your operating system: + +| Operating System | Enter | +|------------------|-------------------------------------------| +| UNIX | clpru --include_path=/tools/files source.c | +| Windows | clpru --include_path=c:\tools\files source.c | + +### NOTE: Specifying Path Information in Angle Brackets + +If you specify the path information in angle brackets, the compiler applies that information relative to the path information specified with --include\_path options and the PRU\_C\_OPTION environment variable. + +For example, if you set up PRU\_C\_OPTION with the following command: + +PRU\_C\_DIR "/usr/include;/usr/ucb"; export PRU\_C\_DIR + +or invoke the compiler with the following command: + +clpru --include\_path=/usr/include file.c + +and file.c contains this line: + +#include + +the result is that the included file is in the following path: + +/usr/include/sys/proc.h + +### 2.5.3 Support for the #warning and #warn Directives + +In strict ANSI mode, the TI preprocessor allows you to use the #warn directive to cause the preprocessor to issue a warning and continue preprocessing. The #warn directive is equivalent to the #warning directive supported by GCC, IAR, and other compilers. + +If you use the --relaxed\_ansi option (on by default), both the #warn and #warning preprocessor directives are supported. + +### 2.5.4 Generating a Preprocessed Listing File (--preproc\_only Option) + +The --preproc\_only option allows you to generate a preprocessed version of your source file with an extension of *.*pp. The compiler's preprocessing functions perform the following operations on the source file: + +- Each source line ending in a backslash (\) is joined with the following line. +- Trigraph sequences are expanded. +- Comments are removed. +- #include files are copied into the file. +- Macro definitions are processed. +- All macros are expanded. +- All other preprocessing directives, including #line directives and conditional compilation, are expanded. + +The --preproc\_only option is useful when creating a source file for a technical support case or to ask a question about your code. It allows you to reduce the test case to a single source file, because #include files are incorporated when the preprocessor runs. + +### 2.5.5 Continuing Compilation After Preprocessing (--preproc\_with\_compile Option) + +If you are preprocessing, the preprocessor performs preprocessing only; it does not compile your source code. To override this feature and continue to compile after your source code is preprocessed, use the --preproc\_with\_compile option along with the other preprocessing options. For example, use --preproc\_with\_compile with --preproc\_only to perform preprocessing, write preprocessed output to a file with a .pp extension, and compile your source code. + +### 2.5.6 Generating a Preprocessed Listing File with Comments (--preproc\_with\_comment Option) + +The --preproc\_with\_comment option performs all of the preprocessing functions except removing comments and generates a preprocessed version of your source file with a .pp extension. Use the --preproc\_with\_comment option instead of the --preproc\_only option if you want to keep the comments. + +### 2.5.7 Generating Preprocessed Listing with Line-Control Details (--preproc\_with\_line Option) + +By default, the preprocessed output file contains no preprocessor directives. To include the #line directives, use the --preproc\_with\_line option. The --preproc\_with\_line option performs preprocessing only and writes preprocessed output with line-control information (#line directives) to a file named as the source file but with a .pp extension. + +### 2.5.8 Generating Preprocessed Output for a Make Utility (--preproc\_dependency Option) + +The --preproc\_dependency option performs preprocessing only. Instead of writing preprocessed output, it writes a list of dependency lines suitable for input to a standard make utility. If you do not supply an optional filename, the list is written to a file with the same name as the source file but a .pp extension. + +### 2.5.9 Generating a List of Files Included with #include (--preproc\_includes Option) + +The --preproc\_includes option performs preprocessing only, but instead of writing preprocessed output, writes a list of files included with the #include directive. If you do not supply an optional filename, the list is written to a file with the same name as the source file but with a .pp extension. + +### 2.5.10 Generating a List of Macros in a File (--preproc\_macros Option) + +The --preproc\_macros option generates a list of all predefined and user-defined macros. If you do not supply an optional filename, the list is written to a file with the same name as the source file but with a .pp extension. + +The output includes only those files directly included by the source file. Predefined macros are listed first and indicated by the comment /\* Predefined \*/. User-defined macros are listed next and indicated by the source filename. + +## 2.6 Passing Arguments to main() + +Some programs pass arguments to main() via argc and argv. This presents special challenges in an embedded program that is not run from the command line. In general, argc and argv are made available to your program through the .args section. There are various ways to populate the contents of this section for use by your program. + +To cause the linker to allocate an .args section of the appropriate size, use the --arg\_size=*size* linker option. This option tells the linker to allocate an uninitialized section named .args, which can be used by the loader to pass arguments from the command line of the loader to the program. The *size* is the number of bytes to be allocated. When you use the --arg\_size option, the linker defines the \_\_c\_args\_\_ symbol to contain the address of the .args section. + +It is the responsibility of the loader to populate the .args section. The loader and the target boot code can use the .args section and the \_\_c\_args\_\_ symbol to determine whether and how to pass arguments from the host to the target program. The format of the arguments is an array of pointers to char on the target. Due to variations in loaders, it is not specified how the loader determines which arguments to pass to the target. + +If you are using Code Composer Studio to run your application, you can use the Scripting Console tool to populate the .args section. To open this tool, choose **View > Scripting Console** from the CCS menus. You can use the loadProg command to load an object file and its associated symbol table into memory and pass an array of arguments to main(). These arguments are automatically written to the allocated .args section. + +The loadProg syntax is as follows, where *file* is an executable file and *args* is an object array of arguments. Use JavaScript to declare the array of arguments before using this command. + +``` +loadProg(file, args) +``` + +The .args section is loaded with the following data for non-SYS/BIOS-based executables, where each element in the argv[] array contains a string corresponding to that argument: + +``` +Int argc; +Char * argv[0]; +Char * argv[1]; +... +Char * argv[n]; +``` + +For SYS/BIOS-based executables, the elements in the .args section are as follows: + +``` +Int argc; +Char ** argv; /* points to argv[0] */ +Char * envp; /* ignored by loadProg command */ +Char * argv[0]; +Char * argv[1]; +... +Char * argv[n]; +``` + +For more details, see the "[Scripting](http://processors.wiki.ti.com/index.php/Scripting_Console) Console" topic in the TI Processors Wiki. + +## 2.7 Understanding Diagnostic Messages + +One of the primary functions of the compiler and linker is to report diagnostic messages for the source program. A diagnostic message indicates that something may be wrong with the program. When the compiler or linker detects a suspect condition, it displays a message in the following format: + +**"***file.c***", line** *n* **:** *diagnostic severity* **:** *diagnostic message* + +**"***file.c***"** The name of the file involved + +**line** *n* **:** The line number where the diagnostic applies + +*diagnostic severity* The diagnostic message severity (severity category descriptions follow) + +*diagnostic message* The text that describes the problem + +Diagnostic messages have a severity, as follows: + +- A **fatal error** indicates a problem so severe that the compilation cannot continue. Examples of such problems include command-line errors, internal errors, and missing include files. If multiple source files are being compiled, any source files after the current one will not be compiled. +- An **error** indicates a violation of the syntax or semantic rules of the C/C++ language. Compilation may continue, but object code is not generated. +- A **warning** indicates something that is likely to be a problem, but cannot be proven to be an error. For example, the compiler emits a warning for an unused variable. An unused variable does not affect program execution, but its existence suggests that you might have meant to use it. Compilation continues and object code is generated (if no errors are detected). +- A **remark** is less serious than a warning. It may indicate something that is a potential problem in rare cases, or the remark may be strictly informational. Compilation continues and object code is generated (if no errors are detected). By default, remarks are not issued. Use the --issue\_remarks compiler option to enable remarks. + +Diagnostic messages are written to standard error with a form like the following example: + +``` +"test.c", line 5: error: a break statement may only be used within a loop or switch + break; + ^ +``` + +By default, the source code line is not printed. Use the --verbose\_diagnostics compiler option to display the source line and the error position. The above example makes use of this option. + +The message identifies the file and line involved in the diagnostic, and the source line itself (with the position indicated by the ^ character) follows the message. If several diagnostic messages apply to one source line, each diagnostic has the form shown; the text of the source line is displayed several times, with an appropriate position indicated each time. + +Long messages are wrapped to additional lines, when necessary. + +You can use the --display\_error\_number command-line option to request that the diagnostic's numeric identifier be included in the diagnostic message. When displayed, the diagnostic identifier also indicates whether the diagnostic can have its severity overridden on the command line. If the severity can be overridden, the diagnostic identifier includes the suffix -D (for *discretionary*); otherwise, no suffix is present. For example: + +``` +"Test_name.c", line 7: error #64-D: declaration does not declare anything + struct {}; + ^ +"Test_name.c", line 9: error #77: this declaration has no storage class or type specifier + xxxxx; + ^ +``` + +Because errors are determined to be discretionary based on the severity in a specific context, an error can be discretionary in some cases and not in others. All warnings and remarks are discretionary. + +For some messages, a list of entities (functions, local variables, source files, etc.) is useful; the entities are listed following the initial error message: + +``` +"test.c", line 4: error: more than one instance of overloaded function "f" + matches the argument list: + function "f(int)" + function "f(float)" + argument types are: (double) + f(1.5); + ^ +``` + +In some cases, additional context information is provided. Specifically, the context information is useful when the front end issues a diagnostic while doing a template instantiation or while generating a constructor, destructor, or assignment operator function. For example: + +``` +"test.c", line 7: error: "A::A()" is inaccessible + B x; + ^ + detected during implicit generation of "B::B()" at line 7 +``` + +Without the context information, it is difficult to determine to what the error refers. + +### 2.7.1 Controlling Diagnostic Messages + +The C/C++ compiler provides diagnostic options to control compiler- and linker-generated diagnostic messages. The diagnostic options must be specified before the --run\_linker option. + +| --diag_error=num | Categorizes the diagnostic identified by num as an error. To determine the
numeric identifier of a diagnostic message, use the --display_error_number
option first in a separate compile. Then use --diag_error=num to recategorize
the diagnostic as an error. You can only alter the severity of discretionary
diagnostic messages. | +|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| --diag_remark=num | Categorizes the diagnostic identified by num as a remark. To determine the
numeric identifier of a diagnostic message, use the --display_error_number
option first in a separate compile. Then use --diag_remark=num to
recategorize the diagnostic as a remark. You can only alter the severity of
discretionary diagnostic messages. | +| --diag_suppress=num | Suppresses the diagnostic identified by num. To determine the numeric
identifier of a diagnostic message, use the --display_error_number option first
in a separate compile. Then use --diag_suppress=num to suppress the
diagnostic. You can only suppress discretionary diagnostic messages. | +| --diag_warning=num | Categorizes the diagnostic identified by num as a warning. To determine the
numeric identifier of a diagnostic message, use the --display_error_number
option first in a separate compile. Then use --diag_warning=num to
recategorize the diagnostic as a warning. You can only alter the severity of discretionary diagnostic messages. | + +**--display\_error\_number** Displays a diagnostic's numeric identifier along with its text. Use this option in determining which arguments you need to supply to the diagnostic suppression options (--diag\_suppress, --diag\_error, --diag\_remark, and --diag\_warning). This option also indicates whether a diagnostic is discretionary. A discretionary diagnostic is one whose severity can be overridden. A discretionary diagnostic includes the suffix -D; otherwise, no suffix is present. See Section 2.7. + +**--emit\_warnings\_as\_errors** + +Treats all warnings as errors. This option cannot be used with the --no\_warnings option. The --diag\_remark option takes precedence over this option. This option takes precedence over the --diag\_warning option. + +**--issue\_remarks** Issues remarks (non-serious warnings), which are suppressed by default. + +**--no\_warnings** Suppresses diagnostic warnings (errors are still issued). + +**--set\_error\_limit**=*num* Sets the error limit to *num*, which can be any decimal value. The compiler abandons compiling after this number of errors. (The default is 100.) + +**--verbose\_diagnostics** Provides verbose diagnostic messages that display the original source with line-wrap and indicate the position of the error in the source line. Note that this command-line option cannot be used within the Code Composer Studio IDE. + +**--write\_diagnostics\_file** Produces a diagnostic message information file with the same source file name with an *.err* extension. (The --write\_diagnostics\_file option is not supported by the linker.) Note that this command-line option cannot be used within the Code Composer Studio IDE. + +### 2.7.2 How You Can Use Diagnostic Suppression Options + +The following example demonstrates how you can control diagnostic messages issued by the compiler. You control the linker diagnostic messages in a similar manner. + +``` +int one(); +int I; +int main() +{ + switch (I){ + case 1; + return one (); + break; + default: + return 0; + break; + } +} +``` + +If you invoke the compiler with the --quiet option, this is the result: + +``` +"err.c", line 9: warning: statement is unreachable +"err.c", line 12: warning: statement is unreachable +``` + +Because it is standard programming practice to include break statements at the end of each case arm to avoid the fall-through condition, these warnings can be ignored. Using the --display\_error\_number option, you can find out the diagnostic identifier for these warnings. Here is the result: + +``` +[err.c] +"err.c", line 9: warning #111-D: statement is unreachable +"err.c", line 12: warning #111-D: statement is unreachable +``` + +Next, you can use the diagnostic identifier of 111 as the argument to the --diag\_remark option to treat this warning as a remark. This compilation now produces no diagnostic messages (because remarks are disabled by default). + +**NOTE:** You can suppress any non-fatal errors, but be careful to make sure you only suppress diagnostic messages that you understand and are known not to affect the correctness of your program. + +## 2.8 Other Messages + +Other error messages that are unrelated to the source, such as incorrect command-line syntax or inability to find specified files, are usually fatal. They are identified by the symbol >> preceding the message. + +## 2.9 Generating Cross-Reference Listing Information (--gen\_cross\_reference Option) + +The --gen\_cross\_reference option generates a cross-reference listing file that contains reference information for each identifier in the source file. (The --gen\_cross\_reference option is separate from --asm\_listing\_cross\_reference, which is an assembler rather than a compiler option.) The cross-reference listing file has the same name as the source file with a .*crl* extension. + +The information in the cross-reference listing file is displayed in the following format: + +*sym-id name X filename line number column number* + +*sym-id* An integer uniquely assigned to each identifier + +*name* The identifier name + +*X* One of the following values: + +D Definition + +d Declaration (not a definition) + +M Modification A Address taken + +U Used + +C Changed (used and modified in a single operation) + +R Any other kind of reference E Error; reference is indeterminate + +*filename* The source file + +*line number* The line number in the source file *column number* The column number in the source file + +## 2.10 Generating a Raw Listing File (--gen\_preprocessor\_listing Option) + +The --gen\_preprocessor\_listing option generates a raw listing file that can help you understand how the compiler is preprocessing your source file. Whereas the preprocessed listing file (generated with the --preproc\_only, --preproc\_with\_comment, --preproc\_with\_line, and --preproc\_dependency preprocessor options) shows a preprocessed version of your source file, a raw listing file provides a comparison between the original source line and the preprocessed output. The raw listing file has the same name as the corresponding source file with an .*rl* extension. + +The raw listing file contains the following information: + +- Each original source line +- Transitions into and out of include files +- Diagnostic messages +- Preprocessed source line if nontrivial processing was performed (comment removal is considered trivial; other preprocessing is nontrivial) + +Each source line in the raw listing file begins with one of the identifiers listed in Table 2-28. + +**Table 2-28. Raw Listing File Identifiers** + +| Identifier | Definition | +|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| N | Normal line of source | +| X | Expanded line of source. It appears immediately following the normal line of source
if nontrivial preprocessing occurs. | +| S | Skipped source line (false #if clause) | +| L | Change in source position, given in the following format:
L line number filename key | +| | Where line number is the line number in the source file. The key is present only
when the change is due to entry/exit of an include file. Possible values of key are: | +| | 1 = entry into an include file
2 = exit from an include file | + +The --gen\_preprocessor\_listing option also includes diagnostic identifiers as defined in Table 2-29. + +**Table 2-29. Raw Listing File Diagnostic Identifiers** + +| Diagnostic Identifier | Definition | +|-----------------------|------------| +| E | Error | +| F | Fatal | +| R | Remark | +| W | Warning | + +Diagnostic raw listing information is displayed in the following format: + +| S filename line number column number diagnostic | | | | +|-------------------------------------------------|--|--|--| +|-------------------------------------------------|--|--|--| + +| S | One of the identifiers in Table 2-29 that indicates the severity of the diagnostic | +|---------------|------------------------------------------------------------------------------------| +| filename | The source file | +| line number | The line number in the source file | +| column number | The column number in the source file | +| diagnostic | The message text for the diagnostic | + +Diagnostic messages after the end of file are indicated as the last line of the file with a column number of 0. When diagnostic message text requires more than one line, each subsequent line contains the same file, line, and column information but uses a lowercase version of the diagnostic identifier. For more information about diagnostic messages, see Section 2.7. + +## 2.11 Using Inline Function Expansion + +When an inline function is called, a copy of the C/C++ source code for the function is inserted at the point of the call. This is known as inline function expansion, commonly called *function inlining* or just *inlining*. Inline function expansion can speed up execution by eliminating function call overhead. This is particularly beneficial for very small functions that are called frequently. Function inlining involves a tradeoff between execution speed and code size, because the code is duplicated at each function call site. Large functions that are called in many places are poor candidates for inlining. + +### NOTE: Excessive Inlining Can Degrade Performance + +Excessive inlining can make the compiler dramatically slower and degrade the performance of generated code. + +Function inlining is triggered by the following situations: + +- The use of built-in intrinsic operations. Intrinsic operations look like function calls, and are inlined automatically, even though no function body exists. +- Use of the inline keyword or the equivalent \_\_inline keyword. Functions declared with the inline keyword may be inlined by the compiler if you set --opt\_level=0 or greater. The inline keyword is a suggestion from the programmer to the compiler. Even if your optimization level is high, inlining is still optional for the compiler. The compiler decides whether to inline a function based on the length of the function, the number of times it is called, your --opt\_for\_speed setting, and any contents of the function that disqualify it from inlining (see Section 2.11.2). Functions can be inlined at --opt\_level=0 or above if the function body is visible in the same module or if -pm is also used and the function is visible in one of the modules being compiled. Functions may be inlined at link time if the file containing the definition and the call site were both compiled with --opt\_level=4. Functions defined as both static and inline are more likely to be inlined. +- When --opt\_level=3 or greater is used, the compiler may automatically inline eligible functions even if they are not declared as inline functions. The same list of decision factors listed for functions explicitly defined with the inline keyword is used. For more about automatic function inlining, see Section 3.5. +- The pragma FUNC\_ALWAYS\_INLINE and the equivalent always\_inline attribute force a function to be inlined (where it is legal to do so) unless --opt\_level=off. That is, the pragma FUNC\_ALWAYS\_INLINE forces function inlining even if the function is not declared as inline and the --opt\_level=0 or --opt\_level=1. +- The FORCEINLINE pragma forces functions to be inlined in the annotated statement. That is, it has no effect on those functions in general, only on function calls in a single statement. The FORCEINLINE\_RECURSIVE pragma forces inlining not only of calls visible in the statement, but also in the inlined bodies of calls from that statement. +- The --disable\_inlining option prevents any inlining. The pragma FUNC\_CANNOT\_INLINE prevents a function from being inlined. The NOINLINE pragma prevents calls within a single statement from being inlined. (NOINLINE is the inverse of the FORCEINLINE pragma.) + +### NOTE: Function Inlining Can Greatly Increase Code Size + +Function inlining increases code size, especially inlining a function that is called in a number of places. Function inlining is optimal for functions that are called only from a small number of places and for small functions. + +The semantics of the inline keyword in C code follow the C99 standard. The semantics of the inline keyword in C++ code follow the C++ standard. + +The inline keyword is supported in all C++ modes, in relaxed ANSI mode for all C standards, and in strict ANSI mode for C99. It is disabled in strict ANSI mode for C89, because it is a language extension that could conflict with a strictly conforming program. If you want to define inline functions while in strict ANSI C89 mode, use the alternate keyword \_\_inline. + +Compiler options that affect inlining are: --opt\_level, --auto\_inline, --remove\_hooks\_when\_inlining, --opt\_for\_speed, and --disable\_inlining. + +### 2.11.1 Inlining Intrinsic Operators + +The compiler has a number of built-in function-like operations called intrinsics. The implementation of an intrinsic function is handled by the compiler, which substitutes a sequence of instructions for the function call. This is similar to the way inline functions are handled; however, because the compiler knows the code of the intrinsic function, it can perform better optimization. + +Intrinsics are inlined whether or not you use the optimizer. For details about intrinsics, and a list of the intrinsics, see Section 5.11. In addition to those listed, abs and memcpy are implemented as intrinsics. + +### 2.11.2 Inlining Restrictions + +The compiler makes decisions about which functions to inline based on the factors mentioned in Section 2.11. In addition, there are several restrictions that can disqualify a function from being inlined by automatic inlining or inline keyword-based inlining. + +The compiler will leave calls as they are if the function: + +- Has a different number of arguments than the call site +- Has an argument whose type is incompatible with the corresponding call site argument +- Is not declared inline and returns void but its return value is needed + +The compiler will also not inline a call if the function has features that create difficult situations for the compiler: + +- Has a variable-length argument list +- Never returns +- Is a recursive or nonleaf function that exceeds the depth limit +- Is not declared inline and contains an asm() statement that is not a comment +- Is an interrupt function +- Is the main() function +- Is not declared inline and will require too much stack space for local array or structure variables +- Contains a volatile local variable or argument +- Is a C++ function that contains a catch +- Is not defined in the current compilation unit and -O4 optimization is not used + +A call in a statement that is annotated with a NOINLINE pragma will not be inlined, regardless of other indications (including a FUNC\_ALWAYS\_INLINE pragma or always\_inline attribute on the called function). + +A call in a statement that is annotated with a FORCEINLINE pragma will always be inlined, if it is not disqualified for one of the reasons above, even if the called function has a FUNC\_CANNOT\_INLINE pragma or cannot\_inline attribute. + +In other words, a statement-level pragma overrides a function-level pragma or attribute. If both NOINLINE and FORCEINLINE apply to the same statement, then the one that appears first will be used and the rest will be ignored. + +## 2.12 Using Interlist + +The compiler tools include a feature that interlists C/C++ source statements into the assembly language output of the compiler. The interlist feature enables you to inspect the assembly code generated for each C statement. The interlist behaves differently, depending on whether or not the optimizer is used, and depending on which options you specify. + +The easiest way to invoke the interlist feature is to use the --c\_src\_interlist option. To compile and run the interlist on a program called function.c, enter: + +``` +clpru --c_src_interlist function +``` + +The --c\_src\_interlist option prevents the compiler from deleting the interlisted assembly language output file. The output assembly file, function.asm, is assembled normally. + +When you invoke the interlist feature without the optimizer, the interlist runs as a separate pass between the code generator and the assembler. It reads both the assembly and C/C++ source files, merges them, and writes the C/C++ statements into the assembly file as comments. + +Using the --c\_src\_interlist option can cause performance and/or code size degradation. + +Example 2-1 shows a typical interlisted assembly file. + +For more information about using the interlist feature with the optimizer, see Section 3.9. + +### *Example 2*‑*1. An Interlisted Assembly Language File* + +``` +||main||: +;* --------------------------------------------------------------------------* + SUB r2, r2, 0x06 ; [] + SBBO &r3.b2, r2, 4, 2 ; [] +;---------------------------------------------------------------------- +; 5 | printf("Hello World\n"); +;---------------------------------------------------------------------- + LDI32 r0, $C$SL1 ; [] |5| + SBBO &r0, r2, 0, 4 ; [] |5| + JAL r3.w2, ||printf|| ; [] |5| printf + ZERO &r14, 4 ; [] |6| + LBBO &r3.b2, r2, 4, 2 ; [] + ADD r2, r2, 0x06 ; [] + JMP r3.w2 ; [] +``` + +## 2.13 Enabling Entry Hook and Exit Hook Functions + +An entry hook is a routine that is called upon entry to each function in the program. An exit hook is a routine that is called upon exit of each function. Applications for hooks include debugging, trace, profiling, and stack overflow checking. + +Entry and exit hooks are enabled using the following options: + +**--entry\_hook**[=*name*] Enables entry hooks. If specified, the hook function is called *name*. Otherwise, the default entry hook function name is \_\_entry\_hook. + +**--entry\_parm**{=name| address|none} + +Specify the parameters to the hook function. The name parameter specifies that the name of the calling function is passed to the hook function as an argument. In this case the signature for the hook function is: void hook(const char \*name); + +The address parameter specifies that the address of the calling function is passed to the hook function. In this case the signature for the hook function is: void hook(void (\*addr)()); + +The none parameter specifies that the hook is called with no parameters. This is the default. In this case the signature for the hook function is: void hook(void); + +**--exit\_hook**[=*name*] Enables exit hooks. If specified, the hook function is called *name*. Otherwise, the default exit hook function name is \_\_exit\_hook. + +**--exit\_parm**{=name| address|none} + +Specify the parameters to the hook function. The name parameter specifies that the name of the calling function is passed to the hook function as an argument. In this case the signature for the hook function is: void hook(const char \*name); + +The address parameter specifies that the address of the calling function is passed to the hook function. In this case the signature for the hook function is: void hook(void (\*addr)()); + +The none parameter specifies that the hook is called with no parameters. This is the default. In this case the signature for the hook function is: void hook(void); + +The presence of the hook options creates an implicit declaration of the hook function with the given signature. If a declaration or definition of the hook function appears in the compilation unit compiled with the options, it must agree with the signatures listed above. + +In C++, the hooks are declared extern "C". Thus you can define them in C (or assembly) without being concerned with name mangling. + +Hooks can be declared inline, in which case the compiler tries to inline them using the same criteria as other inline functions. + +Entry hooks and exit hooks are independent. You can enable one but not the other, or both. The same function can be used as both the entry and exit hook. + +You must take care to avoid recursive calls to hook functions. The hook function should not call any function which itself has hook calls inserted. To help prevent this, hooks are not generated for inline functions, or for the hook functions themselves. + +You can use the --remove\_hooks\_when\_inlining option to remove entry/exit hooks for functions that are auto-inlined by the optimizer. + +See Section 5.9.17 for information about the NO\_HOOKS pragma. + +# Optimizing Your Code + +The compiler tools can perform many optimizations to improve the execution speed and reduce the size of C and C++ programs by simplifying loops, rearranging statements and expressions, and allocating variables into registers. + +This chapter describes how to invoke different levels of optimization and describes which optimizations are performed at each level. This chapter also describes how you can use the Interlist feature when performing optimization and how you can debug optimized code. + +**Topic** ........................................................................................................................... **Page** + +| 3.1 | Invoking Optimization | 46 | +|------|---------------------------------------------------------------------------|----| +| 3.2 | Controlling Code Size Versus Speed | 47 | +| 3.3 | Performing File-Level Optimization (--opt_level=3 option) | 47 | +| 3.4 | Program-Level Optimization (--program_level_compile and --opt_level=3 options) | 48 | +| 3.5 | Automatic Inline Expansion (--auto_inline Option) | 51 | +| 3.6 | Link-Time Optimization (--opt_level=4 Option) | 52 | +| 3.7 | Accessing Aliased Variables in Optimized Code | 53 | +| 3.8 | Use Caution With asm Statements in Optimized Code | 53 | +| 3.9 | Using the Interlist Feature With Optimization | 53 | +| 3.10 | Debugging and Profiling Optimized Code | 54 | +| 3.11 | What Kind of Optimization Is Being Performed? | 54 | +| | | | + +## 3.1 Invoking Optimization + +The C/C++ compiler is able to perform various optimizations. High-level optimizations are performed in the optimizer and low-level, target-specific optimizations occur in the code generator. Use high-level optimization levels, such as --opt\_level=2 and --opt\_level=3, to achieve optimal code. + +The easiest way to invoke optimization is to use the compiler program, specifying the --opt\_level=*n* option on the compiler command line. You can use -O*n* to alias the --opt\_level option. The *n* denotes the level of optimization (0, 1, 2, 3), which controls the type and degree of optimization. + +### • **--opt\_level=off** or **-Ooff** + +– Performs no optimization + +### • **--opt\_level=0** or **-O0** + +- Performs control-flow-graph simplification +- Allocates variables to registers +- Performs loop rotation +- Eliminates unused code +- Simplifies expressions and statements +- Expands calls to functions declared inline + +### • **--opt\_level=1** or **-O1** + +Performs all --opt\_level=0 (-O0) optimizations, plus: + +- Performs local copy/constant propagation +- Removes unused assignments +- Eliminates local common expressions + +### • **--opt\_level=2** or **-O2** + +Performs all --opt\_level=1 (-O1) optimizations, plus: + +- Performs loop optimizations +- Eliminates global common subexpressions +- Eliminates global unused assignments +- Performs loop unrolling + +### • **--opt\_level=3** or **-O3** + +Performs all --opt\_level=2 (-O2) optimizations, plus: + +- Removes all functions that are never called +- Simplifies functions with return values that are never used +- Inlines calls to small functions +- Reorders function declarations; the called functions attributes are known when the caller is optimized +- Propagates arguments into function bodies when all calls pass the same value in the same argument position +- Identifies file-level variable characteristics + +If you use --opt\_level=3 (-O3), see Section 3.3 and Section 3.4 for more information. + +For information about how the --opt\_level option along with the --opt\_for\_speed option and various pragmas affect inlining, see Section 2.11. + +By default, debugging is enabled and the default optimization level is unaffected by the generation of debug information. However, the optimization level used is affected by whether or not the command line includes the -g (--symdebug:dwarf) option and the --opt\_level option as shown in the following table: + +**Table 3-1. Interaction Between Debugging and Optimization Options** + +| Optimization | no -g | -g | +|--------------|------------------------|------------------------| +| no --opt_level | --opt_level=off | --opt_level=off | +| --opt_level | --opt_level=2 | --opt_level=2 | +| --opt_level=n | optimized as specified | optimized as specified | + +The levels of optimizations described above are performed by the stand-alone optimization pass. The code generator performs several additional optimizations, particularly processor-specific optimizations. It does so regardless of whether you invoke the optimizer. These optimizations are always enabled, although they are more effective when the optimizer is used. + +## 3.2 Controlling Code Size Versus Speed + +To balance the tradeoff between code size and speed, use the --opt\_for\_speed option. The level of optimization (0-5) controls the type and degree of code size or code speed optimization: + +- --opt\_for\_speed=0 + - Optimizes code size with a *high* risk of worsening or impacting performance. +- --opt\_for\_speed=1 + - Optimizes code size with a *medium* risk of worsening or impacting performance. +- --opt\_for\_speed=2 + - Optimizes code size with a *low* risk of worsening or impacting performance. +- --opt\_for\_speed=3 + - Optimizes code performance/speed with a *low* risk of worsening or impacting code size. +- --opt\_for\_speed=4 + - Optimizes code performance/speed with a *medium* risk of worsening or impacting code size. +- --opt\_for\_speed=5 + - Optimizes code performance/speed with a *high* risk of worsening or impacting code size. + +If you specify the --opt\_for\_speed option without a parameter, the default setting is --opt\_for\_speed=4. If you do not specify the --opt\_for\_speed option, the default setting is 4 + +## 3.3 Performing File-Level Optimization (--opt\_level=3 option) + +The --opt\_level=3 option (aliased as the -O3 option) instructs the compiler to perform file-level optimization. You can use the --opt\_level=3 option alone to perform general file-level optimization, or you can combine it with other options to perform more specific optimizations. The options listed in Table 3-2 work with --opt\_level=3 to perform the indicated optimization: + +**Table 3-2. Options That You Can Use With --opt\_level=3** + +| If You | Use this Option | See | +|-------------------------------------------------|-----------------------|---------------| +| Want to create an optimization information file | --gen_opt_level=n | Section 3.3.1 | +| Want to compile multiple source files | --program_level_compile | Section 3.4 | + +### 3.3.1 Creating an Optimization Information File (--gen\_opt\_info Option) + +When you invoke the compiler with the --opt\_level=3 option, you can use the --gen\_opt\_info option to create an optimization information file that you can read. The number following the option denotes the level (0, 1, or 2). The resulting file has an .nfo extension. Use Table 3-3 to select the appropriate level to append to the option. + +### Table 3-3. Selecting a Level for the --gen\_opt\_info Option + +| If you | Use this option | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------| +| Do not want to produce an information file, but you used the --gen_opt_level=1 or --gen_opt_level=2
option in a command file or an environment variable. The --gen_opt_level=0 option restores the
default behavior of the optimizer. | --gen_opt_info=0 | +| Want to produce an optimization information file | --gen_opt_info=1 | +| Want to produce a verbose optimization information file | --gen_opt_info=2 | + +## 3.4 Program-Level Optimization (--program\_level\_compile and --opt\_level=3 options) + +You can specify program-level optimization by using the --program\_level\_compile option with the --opt\_level=3 option (aliased as -O3). (If you use --opt\_level=4 (-O4), the --program\_level\_compile option cannot be used, because link-time optimization provides the same optimization opportunities as program level optimization.) + +With program-level optimization, all of your source files are compiled into one intermediate file called a *module*. The module moves to the optimization and code generation passes of the compiler. Because the compiler can see the entire program, it performs several optimizations that are rarely applied during filelevel optimization: + +- If a particular argument in a function always has the same value, the compiler replaces the argument with the value and passes the value instead of the argument. +- If a return value of a function is never used, the compiler deletes the return code in the function. +- If a function is not called directly or indirectly by main(), the compiler removes the function. + +The --program\_level\_compile option requires use of --opt\_level=3 in order to perform these optimizations. + +To see which program-level optimizations the compiler is applying, use the --gen\_opt\_level=2 option to generate an information file. See Section 3.3.1 for more information. + +In Code Composer Studio, when the --program\_level\_compile option is used, C and C++ files that have the same options are compiled together. However, if any file has a file-specific option that is not selected as a project-wide option, that file is compiled separately. For example, if every C and C++ file in your project has a different set of file-specific options, each is compiled separately, even though program-level optimization has been specified. To compile all C and C++ files together, make sure the files do not have file-specific options. Be aware that compiling C and C++ files together may not be safe if previously you used a file-specific option. + +### Compiling Files With the --program\_level\_compile and --keep\_asm Options + +**NOTE:** If you compile all files with the --program\_level\_compile and --keep\_asm options, the compiler produces only one .asm file, not one for each corresponding source file. + +### 3.4.1 Controlling Program-Level Optimization (--call\_assumptions Option) + +You can control program-level optimization, which you invoke with --program\_level\_compile --opt\_level=3, by using the --call\_assumptions option. Specifically, the --call\_assumptions option indicates if functions in other modules can call a module's external functions or modify a module's external variables. The number following --call\_assumptions indicates the level you set for the module that you are allowing to be called or modified. The --opt\_level=3 option combines this information with its own file-level analysis to decide whether to treat this module's external function and variable declarations as if they had been declared static. Use Table 3-4 to select the appropriate level to append to the --call\_assumptions option. + +**Table 3-4. Selecting a Level for the --call\_assumptions Option** + +| If Your Module … | Use this Option | +|---------------------------------------------------------------------------------------------------------------------------|--------------------| +| Has functions that are called from other modules and global variables that are modified in other
modules | --call_assumptions=0 | +| Does not have functions that are called by other modules but has global variables that are modified in
other modules | --call_assumptions=1 | +| Does not have functions that are called by other modules or global variables that are modified in other
modules | --call_assumptions=2 | +| Has functions that are called from other modules but does not have global variables that are modified
in other modules | --call_assumptions=3 | + +In certain circumstances, the compiler reverts to a different --call\_assumptions level from the one you specified, or it might disable program-level optimization altogether. Table 3-5 lists the combinations of - call\_assumptions levels and conditions that cause the compiler to revert to other --call\_assumptions levels. + +**Table 3-5. Special Considerations When Using the --call\_assumptions Option** + +| If --call_assumptions is | Under these Conditions | Then the --call_assumptions
Level | +|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------| +| Not specified | The --opt_level=3 optimization level was specified | Defaults to --call_assumptions=2 | +| Not specified | The compiler sees calls to outside functions under the
--opt_level=3 optimization level | Reverts to --call_assumptions=0 | +| Not specified | Main is not defined | Reverts to --call_assumptions=0 | +| --call_assumptions=1 or
--call_assumptions=2 | No function has main defined as an entry point, and no interrupt
functions are defined, and no functions are identified by the
FUNC_EXT_CALLED pragma | Reverts to --call_assumptions=0 | +| --call_assumptions=1 or
--call_assumptions=2 | A main function is defined, or, an interrupt function is defined, or a
function is identified by the FUNC_EXT_CALLED pragma | Remains --call_assumptions=1
or --call_assumptions=2 | +| --call_assumptions=3 | Any condition | Remains --call_assumptions=3 | + +In some situations when you use --program\_level\_compile and --opt\_level=3, you *must* use a --call\_assumptions option or the FUNC\_EXT\_CALLED pragma. + +### 3.4.2 Optimization Considerations When Mixing C/C++ and Assembly + +If you have any assembly functions in your program, you need to exercise caution when using the --program\_level\_compile option. The compiler recognizes only the C/C++ source code and not any assembly code that might be present. Because the compiler does not recognize the assembly code calls and variable modifications to C/C++ functions, the --program\_level\_compile option optimizes out those C/C++ functions. To keep these functions, place the FUNC\_EXT\_CALLED pragma (see Section 5.9.11) before any declaration or reference to a function that you want to keep. + +Another approach you can take when you use assembly functions in your program is to use the --call\_assumptions=*n* option with the --program\_level\_compile and --opt\_level=3 options. See Section 3.4.1 for information about the --call\_assumptions=*n* option. + +In general, you achieve the best results through judicious use of the FUNC\_EXT\_CALLED pragma in combination with --program\_level\_compile --opt\_level=3 and --call\_assumptions=1 or --call\_assumptions=2. + +If any of the following situations apply to your application, use the suggested solution: + +- **Situation —** Your application consists of C/C++ source code that calls assembly functions. Those assembly functions do not call any C/C++ functions or modify any C/C++ variables. +- **Solution —** Compile with --program\_level\_compile --opt\_level=3 --call\_assumptions=2 to tell the compiler that outside functions do not call C/C++ functions or modify C/C++ variables. + +If you compile with the --program\_level\_compile --opt\_level=3 options only, the compiler reverts from the default optimization level (--call\_assumptions=2) to --call\_assumptions=0. The compiler uses --call\_assumptions=0, because it presumes that the calls to the assembly language functions that have a definition in C/C++ may call other C/C++ functions or modify C/C++ variables. + +**Situation —** Your application consists of C/C++ source code that calls assembly functions. The assembly language functions do not call C/C++ functions, but they modify C/C++ variables. + +**Solution —** Try both of these solutions and choose the one that works best with your code: + +- Compile with --program\_level\_compile --opt\_level=3 --call\_assumptions=1. +- Add the volatile keyword to those variables that may be modified by the assembly functions and compile with --program\_level\_compile --opt\_level=3 --call\_assumptions=2. +- **Situation —** Your application consists of C/C++ source code and assembly source code. The assembly functions are entry points to the application; the C/C++ functions that the assembly functions call are never called from C/C++. These C/C++ functions act like main: they function as entry points into C/C++. +- **Solution —** Add the volatile keyword to the C/C++ variables that may be modified by the interrupts. Then, you can optimize your code in one of these ways: + - You achieve the best optimization by applying the FUNC\_EXT\_CALLED pragma to all of the entry-point functions called from the assembly language interrupts, and then compiling with --program\_level\_compile --opt\_level=3 --call\_assumptions=2. *Be sure that you use the pragma with all of the entry-point functions.* If you do not, the compiler might remove the entry-point functions that are not preceded by the FUNC\_EXT\_CALLED pragma. + - Compile with --program\_level\_compile --opt\_level=3 --call\_assumptions=3. Because you do not use the FUNC\_EXT\_CALLED pragma, you must use the --call\_assumptions=3 option, which is less aggressive than the --call\_assumptions=2 option, and your optimization may not be as effective. + +Keep in mind that if you use --program\_level\_compile --opt\_level=3 without additional options, the compiler removes the C functions that the assembly functions call. Use the FUNC\_EXT\_CALLED pragma to keep these functions. + +## 3.5 Automatic Inline Expansion (--auto\_inline Option) + +When optimizing with the --opt\_level=3 option (aliased as -O3), the compiler automatically inlines small functions. A command-line option, --auto\_inline=*size*, specifies the size threshold for automatic inlining. This option controls only the inlining of functions that are not explicitly declared as inline. + +When the --auto\_inline option is not used, the compiler sets the size limit based on the optimization level and the optimization goal (performance versus code size). If the -auto\_inline size parameter is set to 0, automatic inline expansion is disabled. If the --auto\_inline size parameter is set to a non-zero integer, the compiler automatically inlines any function smaller than *size*. (This is a change from previous releases, which inlined functions for which the product of the function size and the number of calls to it was less than *size*. The new scheme is simpler, but will usually lead to more inlining for a given value of *size*.) + +The compiler measures the size of a function in arbitrary units; however the optimizer information file (created with the --gen\_opt\_info=1 or --gen\_opt\_info=2 option) reports the size of each function in the same units that the --auto\_inline option uses. When --auto\_inline is used, the compiler does not attempt to prevent inlining that causes excessive growth in compile time or size; use with care. + +When --auto\_inline option is not used, the decision to inline a function at a particular call-site is based on an algorithm that attempts to optimize benefit and cost. The compiler inlines eligible functions at call-sites until a limit on size or compilation time is reached. + +Inlining behavior varies, depending on which compile-time options are specified: + +- The code size limit is smaller when compiling for code size rather than performance. The --auto\_inline option overrides this size limit. +- At --opt\_level=3, the compiler automatically inlines small functions. + +For information about interactions between command-line options, pragmas, and keywords that affect inlining, see Section 2.11. + +### Some Functions Cannot Be Inlined + +**NOTE:** For a call-site to be considered for inlining, it must be legal to inline the function and inlining must not be disabled in some way. See the inlining restrictions in Section 2.11.2. + +### Optimization Level 3 and Inlining + +**NOTE:** In order to turn on automatic inlining, you must use the --opt\_level=3 option. If you desire the --opt\_level=3 optimizations, but not automatic inlining, use --auto\_inline=0 with the - opt\_level=3 option. + +### Inlining and Code Size + +**NOTE:** Expanding functions inline increases code size, especially inlining a function that is called in a number of places. Function inlining is optimal for functions that are called only from a small number of places and for small functions. To prevent increases in code size because of inlining, use the --auto\_inline=0 option. This option causes the compiler to inline intrinsics only. + +## 3.6 Link-Time Optimization (--opt\_level=4 Option) + +Link-time optimization is an optimization mode that allows the compiler to have visibility of the entire program. The optimization occurs at link-time instead of compile-time like other optimization levels. + +Link-time optimization is invoked by using the --opt\_level=4 option. This option must be used in both the compilation and linking steps. At compile time, the compiler embeds an intermediate representation of the file being compiled into the resulting object file. At link-time this representation is extracted from every object file which contains it, and is used to optimize the entire program. + +If you use --opt\_level=4 (-O4), the --program\_level\_compile option cannot also be used, because link-time optimization provides the same optimization opportunities as program level optimization \(Section 3.4). Link-time optimization provides the following benefits: + +- Each source file can be compiled separately. One issue with program-level compilation is that it requires all source files to be passed to the compiler at one time. This often requires significant modification of a customer's build process. With link-time optimization, all files can be compiled separately. +- References to C/C++ symbols from assembly are handled automatically. When doing program-level compilation, the compiler has no knowledge of whether a symbol is referenced externally. When performing link-time optimization during a final link, the linker can determine which symbols are referenced externally and prevent eliminating them during optimization. +- Third party object files can participate in optimization. If a third party vendor provides object files that were compiled with the --opt\_level=4 option, those files participate in optimization along with usergenerated files. This includes object files supplied as part of the TI run-time support. Object files that were not compiled with –opt\_level=4 can still be used in a link that is performing link-time optimization. Those files that were not compiled with –opt\_level=4 do not participate in the optimization. +- Source files can be compiled with different option sets. With program-level compilation, all source files must be compiled with the same option set. With link-time optimization files can be compiled with different options. If the compiler determines that two options are incompatible, it issues an error. + +### 3.6.1 Option Handling + +When performing link-time optimization, source files can be compiled with different options. When possible, the options that were used during compilation are used during link-time optimization. For options which apply at the program level, --auto\_inline for instance, the options used to compile the main function are used. If main is not included in link-time optimization, the option set used for the first object file specified on the command line is used. Some options, --opt\_for\_speed for instance, can affect a wide range of optimizations. For these options, the program-level behavior is derived from main, and the local optimizations are obtained from the original option set. + +Some options are incompatible when performing link-time optimization. These are usually options which conflict on the command line as well, but can also be options that cannot be handled during link-time optimization. + +### 3.6.2 Incompatible Types + +During a normal link, the linker does not check to make sure that each symbol was declared with the same type in different files. This is not necessary during a normal link. When performing link-time optimization, however, the linker must ensure that all symbols are declared with compatible types in different source files. If a symbol is found which has incompatible types, an error is issued. The rules for compatible types are derived from the C and C++ standards. + +## 3.7 Accessing Aliased Variables in Optimized Code + +Aliasing occurs when a single object can be accessed in more than one way, such as when two pointers point to the same object or when a pointer points to a named object. Aliasing can disrupt optimization because any indirect reference can refer to another object. The optimizer analyzes the code to determine where aliasing can and cannot occur, then optimizes as much as possible while still preserving the correctness of the program. The optimizer behaves conservatively. If there is a chance that two pointers are pointing to the same object, then the optimizer assumes that the pointers do point to the same object. + +The compiler assumes that if the address of a local variable is passed to a function, the function changes the local variable by writing through the pointer. This makes the local variable's address unavailable for use elsewhere after returning. For example, the called function cannot assign the local variable's address to a global variable or return the local variable's address. In cases where this assumption is invalid, use the --aliased\_variables compiler option to force the compiler to assume worst-case aliasing. In worst-case aliasing, any indirect reference can refer to such a variable. + +## 3.8 Use Caution With asm Statements in Optimized Code + +You must be extremely careful when using asm (inline assembly) statements in optimized code. The compiler rearranges code segments, uses registers freely, and can completely remove variables or expressions. Although the compiler never optimizes out an asm statement (except when it is unreachable), the surrounding environment where the assembly code is inserted can differ significantly from the original C/C++ source code. + +It is usually safe to use asm statements to manipulate hardware controls, but asm statements that attempt to interface with the C/C++ environment or access C/C++ variables can have unexpected results. After compilation, check the assembly output to make sure your asm statements are correct and maintain the integrity of the program. + +## 3.9 Using the Interlist Feature With Optimization + +You control the output of the interlist feature when compiling with optimization (the --opt\_level=*n* or -O*n* option) with the --optimizer\_interlist and --c\_src\_interlist options. + +- The --optimizer\_interlist option interlists compiler comments with assembly source statements. +- The --c\_src\_interlist and --optimizer\_interlist options together interlist the compiler comments and the original C/C++ source with the assembly code. + +When you use the --optimizer\_interlist option with optimization, the interlist feature does *not* run as a separate pass. Instead, the compiler inserts comments into the code, indicating how the compiler has rearranged and optimized the code. These comments appear in the assembly language file as comments starting with ;\*\*. The C/C++ source code is not interlisted, unless you use the --c\_src\_interlist option also. + +The interlist feature can affect optimized code because it might prevent some optimization from crossing C/C++ statement boundaries. Optimization makes normal source interlisting impractical, because the compiler extensively rearranges your program. Therefore, when you use the --optimizer\_interlist option, the compiler writes reconstructed C/C++ statements. + +### Impact on Performance and Code Size + +**NOTE:** The --c\_src\_interlist option can have a negative effect on performance and code size. + +When you use the --c\_src\_interlist and --optimizer\_interlist options with optimization, the compiler inserts its comments and the interlist feature runs before the assembler, merging the original C/C++ source into the assembly file. + +## 3.10 Debugging and Profiling Optimized Code + +Generating symbolic debugging information no longer affects the ability to optimize code. The same executable code is generated regardless of whether generation of debug information is turned on or off. For this reason, debug information is now generated by default. You do not need to specify the -g option in order to debug your application. + +If you do not specify the -g option and allow the default generation of debug information to be used, the default level of optimization is used unless you specify some other optimization level. + +The --symdebug:dwarf option no longer disables optimization, because generation of debug information no longer impacts optimization. + +If you specify the -g option explicitly but do not specify an optimization level, no optimization is performed. This is because while generating debug information does not affect the ability to optimize code, optimizing code does make it more difficult to debug code. At higher levels of optimization, the compiler's extensive rearrangement of code and the many-to-many allocation of variables to registers often make it difficult to correlate source code with object code for debugging purposes. It is recommended that you perform debugging using the lowest level of optimization possible. + +If you specify an --opt\_level (aliased as -O) option, that optimization level is used no matter what type of debugging information you enabled. + +The optimization level used if you do not specify the level on the command line is affected by whether or not the command line includes the -g option and the --opt\_level option as shown in the following table: + +**Optimization no -g -g no --opt\_level** --opt\_level=off --opt\_level=off **--opt\_level** --opt\_level=2 --opt\_level=2 **--opt\_level=n** optimized as specified optimized as specified + +**Table 3-6. Interaction Between Debugging and Optimization Options** + +Debug information increases the size of object files, but it does not affect the size of code or data on the target. If object file size is a concern and debugging is not needed, use --symdebug:none to disable the generation of debug information. + +## 3.11 What Kind of Optimization Is Being Performed? + +The PRU C/C++ compiler uses a variety of optimization techniques to improve the execution speed of your C/C++ programs and to reduce their size. + +Following are some of the optimizations performed by the compiler: + +| Optimization | See | +|------------------------------------------------------------------------------------------------------------------------------------|-----------------| +| Cost-based register allocation | Section 3.11.1 | +| Alias disambiguation | Section 3.11.1 | +| Branch optimizations and control-flow simplification | Section 3.11.3 | +| Data flow optimizations
•
Copy propagation
•
Common subexpression elimination
•
Redundant assignment elimination | Section 3.11.4 | +| Expression simplification | Section 3.11.5 | +| Inline expansion of functions | Section 3.11.6 | +| Function Symbol Aliasing | Section 3.11.7 | +| Induction variable optimizations and strength reduction | Section 3.11.8 | +| Loop-invariant code motion | Section 3.11.9 | +| Loop rotation | Section 3.11.10 | +| Instruction scheduling | Section 3.11.11 | + +| PRU-Specific Optimization | See | +|----------------------------------------|-----------------| +| Tail merging | Section 3.11.12 | +| Autoincrement addressing | Section 3.11.13 | +| Epilog inlining | Section 3.11.14 | +| Integer division with constant divisor | Section 3.11.15 | + +### 3.11.1 Cost-Based Register Allocation + +The compiler, when optimization is enabled, allocates registers to user variables and compiler temporary values according to their type, use, and frequency. Variables used within loops are weighted to have priority over others, and those variables whose uses do not overlap can be allocated to the same register. + +Induction variable elimination and loop test replacement allow the compiler to recognize the loop as a simple counting loop and unroll or eliminate the loop. Strength reduction turns the array references into efficient pointer references with autoincrements. + +### 3.11.2 Alias Disambiguation + +C and C++ programs generally use many pointer variables. Frequently, compilers are unable to determine whether or not two or more I values (lowercase L: symbols, pointer references, or structure references) refer to the same memory location. This aliasing of memory locations often prevents the compiler from retaining values in registers because it cannot be sure that the register and memory continue to hold the same values over time. + +Alias disambiguation is a technique that determines when two pointer expressions cannot point to the same location, allowing the compiler to freely optimize such expressions. + +### 3.11.3 Branch Optimizations and Control-Flow Simplification + +The compiler analyzes the branching behavior of a program and rearranges the linear sequences of operations (basic blocks) to remove branches or redundant conditions. Unreachable code is deleted, branches to branches are bypassed, and conditional branches over unconditional branches are simplified to a single conditional branch. + +When the value of a condition is determined at compile time (through copy propagation or other data flow analysis), the compiler can delete a conditional branch. Switch case lists are analyzed in the same way as conditional branches and are sometimes eliminated entirely. Some simple control flow constructs are reduced to conditional instructions, totally eliminating the need for branches. + +### 3.11.4 Data Flow Optimizations + +Collectively, the following data flow optimizations replace expressions with less costly ones, detect and remove unnecessary assignments, and avoid operations that produce values that are already computed. The compiler with optimization enabled performs these data flow optimizations both locally (within basic blocks) and globally (across entire functions). + +- **Copy propagation.** Following an assignment to a variable, the compiler replaces references to the variable with its value. The value can be another variable, a constant, or a common subexpression. This can result in increased opportunities for constant folding, common subexpression elimination, or even total elimination of the variable. +- **Common subexpression elimination.** When two or more expressions produce the same value, the compiler computes the value once, saves it, and reuses it. +- **Redundant assignment elimination.** Often, copy propagation and common subexpression elimination optimizations result in unnecessary assignments to variables (variables with no subsequent reference before another assignment or before the end of the function). The compiler removes these dead assignments. + +### 3.11.5 Expression Simplification + +For optimal evaluation, the compiler simplifies expressions into equivalent forms, requiring fewer instructions or registers. Operations between constants are folded into single constants. For example, a = (b + 4) - (c + 1) becomes a = b - c + 3. + +### 3.11.6 Inline Expansion of Functions + +The compiler replaces calls to small functions with inline code, saving the overhead associated with a function call as well as providing increased opportunities to apply other optimizations. + +For information about interactions between command-line options, pragmas, and keywords that affect inlining, see Section 2.11. + +### 3.11.7 Function Symbol Aliasing + +The compiler recognizes a function whose definition contains only a call to another function. If the two functions have the same signature (same return value and same number of parameters with the same type, in the same order), then the compiler can make the calling function an alias of the called function. + +For example, consider the following: + +``` +int bbb(int arg1, char *arg2); +int aaa(int n, char *str) +{ + return bbb(n, str); +} +``` + +For this example, the compiler makes aaa an alias of bbb, so that at link time all calls to function aaa should be redirected to bbb. If the linker can successfully redirect all references to aaa, then the body of function aaa can be removed and the symbol aaa is defined at the same address as bbb. + +For information about using the GCC function attribute syntax to declare function aliases, see Section 5.14.2 + +### 3.11.8 Induction Variables and Strength Reduction + +Induction variables are variables whose value within a loop is directly related to the number of executions of the loop. Array indices and control variables for loops are often induction variables. + +Strength reduction is the process of replacing inefficient expressions involving induction variables with more efficient expressions. For example, code that indexes into a sequence of array elements is replaced with code that increments a pointer through the array. + +Induction variable analysis and strength reduction together often remove all references to your loopcontrol variable, allowing its elimination. + +### 3.11.9 Loop-Invariant Code Motion + +This optimization identifies expressions within loops that always compute to the same value. The computation is moved in front of the loop, and each occurrence of the expression in the loop is replaced by a reference to the precomputed value. + +### 3.11.10 Loop Rotation + +The compiler evaluates loop conditionals at the bottom of loops, saving an extra branch out of the loop. In many cases, the initial entry conditional check and the branch are optimized out. + +### 3.11.11 Instruction Scheduling + +The compiler performs instruction scheduling, which is the rearranging of machine instructions in such a way that improves performance while maintaining the semantics of the original order. Instruction scheduling is used to improve instruction parallelism and hide latencies. It can also be used to reduce code size. + +### 3.11.12 Tail Merging + +If you are optimizing for code size, tail merging can be very effective for some functions. Tail merging finds basic blocks that end in an identical sequence of instructions and have a common destination. If such a set of blocks is found, the sequence of identical instructions is made into its own block. These instructions are then removed from the set of blocks and replaced with branches to the newly created block. Thus, there is only one copy of the sequence of instructions, rather than one for each block in the set. + +### 3.11.13 Autoincrement Addressing + +For pointer expressions of the form \*p++, the compiler uses efficient PRU autoincrement addressing modes. In many cases, where code steps through an array in a loop such as below, the loop optimizations convert the array references to indirect references through autoincremented register variable pointers. + +for (I = 0; I +remark: linking in "libc.a" +remark: linking in "rtspruv2_le.lib" in place of "libc.a" +``` + +#### 4.3.1.2 Manual Run-Time-Support Library Selection + +You can bypass automatic library selection by explicitly specifying the desired run-time-support library to use. Use the --library linker option to specify the name of the library. The linker will search the path specified by the --search\_path option and then the PRU\_C\_DIR environment variable for the named library. You can use the --library linker option on the command line or in a command file. + +**clpru --run\_linker** {**--rom\_model** | **--ram\_model**} *filenames* **--library=** *libraryname* + +#### 4.3.1.3 Library Order for Searching for Symbols + +Generally, you should specify the run-time-support library as the last name on the command line because the linker searches libraries for unresolved references in the order that files are specified on the command line. If any object files follow a library, references from those object files to that library are not resolved. You can use the --reread\_libs option to force the linker to reread all libraries until references are resolved. Whenever you specify a library as linker input, the linker includes and links only those library members that resolve undefined references. + +By default, if a library introduces an unresolved reference and multiple libraries have a definition for it, then the definition from the same library that introduced the unresolved reference is used. Use the --priority option if you want the linker to use the definition from the first library on the command line that contains the definition. + +### 4.3.2 Run-Time Initialization + +You must link all C/C++ programs with code to initialize and execute the program called a bootstrap routine. The bootstrap routine is responsible for the following tasks: + +1. Switch to user mode and sets up the user mode stack +2. Set up status and configuration registers +3. Set up the stack and secondary system stack +4. Process special binit copy table, if present. +5. Process the run-time initialization table to autoinitialize global variables (when using the --rom\_model option) +6. Call all global constructors +7. Call the main() function +8. Call exit() when main() returns + +### NOTE: The \_c\_int00 Symbol + +If you use the --ram\_model or --rom\_model link option, \_c\_int00 is automatically defined as the entry point for the program. Otherwise, an entry point is not automatically selected and you will receive a linker warning. + +### 4.3.3 Global Object Constructors + +Global C++ variables that have constructors and destructors require their constructors to be called during program initialization and their destructors to be called during program termination. The C++ compiler produces a table of constructors to be called at startup. + +Constructors for global objects from a single module are invoked in the order declared in the source code, but the relative order of objects from different object files is unspecified. + +Global constructors are called after initialization of other global variables and before the main() function is called. Global destructors are invoked during the exit run-time support function, similar to functions registered through atexit. + +Section 6.7.2.6 discusses the format of the global constructor table. + +### 4.3.4 Specifying the Type of Global Variable Initialization + +The C/C++ compiler produces data tables for initializing global variables. Section 6.7.2.4 discusses the format of these initialization tables. The initialization tables are used in one of the following ways: + +- Global variables are initialized at *run time*. Use the --rom\_model linker option (see Section 6.7.2.3). +- Global variables are initialized at *load time*. Use the --ram\_model linker option (see Section 6.7.2.5). + +When you link a C/C++ program, you must use either the --rom\_model or --ram\_model option. These options tell the linker to select initialization at run time or load time. When you compile and link programs, the --rom\_model option is the default. If used, the --rom\_model option must follow the --run\_linker option (see Section 4.1). For details on linking conventions used with --rom\_model and --ram\_model, see Section 6.7.2.3 and Section 6.7.2.5, respectively. + +### NOTE: Boot Loader + +A loader is not included as part of the C/C++ compiler tools. You can use the PRU emulator with the source debugger as a loader. See the "Program Loading and Running" chapter of the *PRU Assembly Language Tools User's Guide* for more about boot loading. + +### 4.3.5 Specifying Where to Allocate Sections in Memory + +The compiler produces relocatable blocks of code and data. These blocks, called *sections*, are allocated in memory in a variety of ways to conform to a variety of system configurations. See Section 6.1.1 for a complete description of how the compiler uses these sections. + +The compiler creates two basic kinds of sections: initialized and uninitialized. Table 4-1 summarizes the initialized sections. Table 4-2 summarizes the uninitialized sections. + +**Table 4-1. Initialized Sections Created by the Compiler** + +| Name | Contents | +|-------------|---------------------------------------------------------------------------------------------------------------------------| +| .binit | Boot time copy tables (See the Assembly Language Tools User's Guide for information on BINIT in
linker command files.) | +| .cinit | Tables for initializing global data at runtime. | +| .data | Initialized non-const near data. | +| .fardata | Initialized non-const far data. | +| .init_array | Table of constructors to be called at startup. | +| .ovly | Copy tables other than boot time (.binit) copy tables. Read-only data. | +| .rodata | Constant read-only near data. | +| .rofardata | Constant read-only far data. | +| .text | Executable code. | +| .TI.crctab | Generated CRC checking tables. Read-only data. | + +**Table 4-2. Uninitialized Sections Created by the Compiler** + +| Name | Contents | +|---------|------------------------------------------------------------------------------------------| +| .args | Linker-created section used to pass arguments in the argv array to main | +| .bss | Uninitialized near data | +| .farbss | Uninitialized far data | +| .stack | Stack space (size is controlled by -stack option) | +| .sysmem | Heap for dynamic memory allocation by malloc, etc. (Size is controlled by -heap option.) | + +When you link your program, you must specify where to allocate the sections in memory. In general, initialized sections are linked into ROM or RAM; uninitialized sections are linked into RAM. All data sections should be allocated on page 1 and all executable sections should be allocated on page 0. + +The linker provides MEMORY and SECTIONS directives for allocating sections. For more information about allocating sections into memory, see the *PRU Assembly Language Tools User's Guide*. + +### 4.3.6 A Sample Linker Command File + +Example 4-2 shows a typical linker command file that links a C program. The command file in this example is named lnk.cmd and lists several link options: + +| -cr | Same asram_model. Tells the linker to initialize variables at load time | +|--------|-------------------------------------------------------------------------| +| -stack | Tells the linker to set the C stack size to 0x8000 bytes | +| -heap | Tells the linker to set the heap size to 0x8000 bytes | + +To link the program, use the following syntax: + +**clpru --run\_linker** *object\_file*(s) **--output\_file** *outfile* **--map\_file** *mapfile* **lnk32.cmd** + +# Example 4-2. Linker Command File + +``` +-cr /* LINK USING C CONVENTIONS */ +-stack 0x8000 /* SOFTWARE STACK SIZE */ +-heap 0x8000 /* HEAP AREA SIZE */ +/*--args 0x100 */ +/* SPECIFY THE SYSTEM MEMORY MAP */ +MEMORY +{ + PAGE 0: + P_MEM : org = 0x00000008 len = 0x0003FFF8 + PAGE 1: + NEAR_MEM : org = 0x00000008 len = 0x0000FFF8 + FAR_MEM : org = 0x00010000 len = 0x80000000 +} +/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */ +SECTIONS +{ + .bss : {} > NEAR_MEM, PAGE 1 + .data : {} > NEAR_MEM, PAGE 1 palign=2 + .rodata : {} > NEAR_MEM, PAGE 1 + .farbss : {} > FAR_MEM, PAGE 1 + .fardata : {} > FAR_MEM, PAGE 1 + .rofardata : {} > FAR_MEM, PAGE 1 + /* In far memory for validation purposes */ + .sysmem : {} > FAR_MEM, PAGE 1 + .stack : {} > FAR_MEM, PAGE 1 + .init_array : {} > FAR_MEM, PAGE 1 + .cinit : {} > FAR_MEM, PAGE 1 + .args : {} > NEAR_MEM, PAGE 1 + .text : {} > P_MEM, PAGE 0 +} +``` + +# C/C++ Language Implementation + +The C/C++ compiler supports the C/C++ language standard that was developed by a committee of the American National Standards Institute (ANSI) and subsequently adopted by the International Standards Organization (IS0). + +The C++ language supported by the PRU is defined by the ANSI/ISO/IEC 14882:2003 standard with certain exceptions. + +**Topic** ........................................................................................................................... **Page** + +| 5.1 | Characteristics of PRU C | 67 | +|------|---------------------------------------------------|-----| +| 5.2 | Characteristics of PRU C++ | 71 | +| 5.3 | Using MISRA C 2004 | 72 | +| 5.4 | Data Types | 73 | +| 5.5 | Keywords | 74 | +| 5.6 | C++ Exception Handling | 76 | +| 5.7 | Register Variables and Parameters | 77 | +| 5.8 | Theasm Statement | 78 | +| 5.9 | Pragma Directives | 79 | +| 5.10 | The _Pragma Operator | 92 | +| 5.11 | PRU Instruction Intrinsics | 93 | +| 5.12 | Object File Symbol Naming Conventions (Linknames) | 94 | +| 5.13 | Changing the ANSI/ISO C/C++ Language Mode | 95 | +| 5.14 | GNU Language Extensions | 98 | +| 5.15 | Compiler Limits | 102 | +| | | | + +## 5.1 Characteristics of PRU C + +The C compiler supports the 1989 and 1999 versions of the C language: + +- **C89.** Compiling with the --c89 option causes the compiler to conform to the ISO/IEC 9899:1990 C standard, which was previously ratified as ANSI X3.159-1989. The names "C89" and "C90" refer to the same programming language. "C89" is used in this document. +- **C99.** Compiling with the --c99 option causes the compiler to conform to the ISO/IEC 9899:1999 C standard. This standard supports several features not part of C89, such as inline functions, new data types, and one-line comments beginning with //. + +The C language is also described in the second edition of Kernighan and Ritchie's *The C Programming Language* (K&R). The compiler can also accept many of the language extensions found in the GNU C compiler (see Section 5.14). + +The compiler supports some features of C99 in the default relaxed ANSI mode with C89 support. It supports all language features of C99 in C99 mode. See Section 5.13. + +The ANSI/ISO standard identifies some features of the C language that may be affected by characteristics of the target processor, run-time environment, or host environment. This set of features can differ among standard compilers. + +Unsupported features of the C library are: + +- The run-time library has minimal support for wide and multibyte characters. The type wchar\_t is implemented as int. The wide character set is equivalent to the set of values of type char. The library includes the header files and , but does not include all the functions specified in the standard. +- The run-time library includes the header file , but with a minimal implementation. The only supported locale is the C locale. That is, library behavior that is specified to vary by locale is hardcoded to the behavior of the C locale, and attempting to install a different locale by way of a call to setlocale() will return NULL. +- Some run-time functions and features in the C99 specification are not supported. See Section 5.13. + +### 5.1.1 Implementation-Defined Behavior + +The C standard requires that conforming implementations provide documentation on how the compiler handles instances of implementation-defined behavior. + +The TI compiler officially supports a freestanding environment. The C standard does not require a freestanding environment to supply every C feature; in particular the library need not be complete. However, the TI compiler strives to provide most features of a hosted environment. + +The section numbers in the lists that follow correspond to section numbers in Appendix J of the C99 standard. The numbers in parentheses at the end of each item are sections in the C99 standard that discuss the topic. Certain items listed in Appendix J of the C99 standard have been omitted from this list. + +### J.3.1 Translation + +- The compiler and related tools emit diagnostic messages with several distinct formats. Diagnostic messages are emitted to stderr; any text on stderr may be assumed to be a diagnostic. If any errors are present, the tool will exit with an exit status indicating failure (non-zero). (3.10, 5.1.1.3) +- Nonempty sequences of white-space characters are preserved and are not replaced by a single space character in translation phase 3. (5.1.1.2) + +### J.3.2 Environment + +- The compiler does not support multibyte characters in identifiers, so there is no mapping from multibyte characters to the source character set. However, the compiler accepts multibyte characters in comments, string literals, and character constants in the physical source file. (5.1.1.2) +- The name of the function called at program startup is "main" (5.1.2.1) + +- Program termination does not affect the environment; there is no way to return an exit code to the environment. By default, the program is known to have halted when execution reaches the special C\$\$EXIT label. (5.1.2.1) +- In relaxed ANSI mode, the compiler accepts "void main(void)" and "void main(int argc, char \*argv[])" as alternate definitions of main. The alternate definitions are rejected in strict ANSI mode. (5.1.2.2.1) +- If space is provided for program arguments at link time with the --args option and the program is run under a system that can populate the .args section (such as CCS), argv[0] will contain the filename of the executable, argv[1] through argv[argc-1] will contain the command-line arguments to the program, and argv[argc] will be NULL. Otherwise, the value of argv and argc are undefined. (5.1.2.2.1) +- Interactive devices include stdin, stdout, and stderr (when attached to a system that honors CIO requests). Interactive devices are not limited to those output locations; the program may access hardware peripherals that interact with the external state. (5.1.2.3) +- Signals are not supported. The function signal is not supported. (7.14) (7.14.1.1) +- The library function getenv is implemented through the CIO interface. If the program is run under a system that supports CIO, the system performs getenv calls on the host system and passes the result back to the program. Otherwise the operation of getenv is undefined. No method of changing the environment from inside the target program is provided. (7.20.4.5) +- The system function is not supported. (7.20.4.6). + +### J.3.3 Identifiers + +- The compiler does not support multibyte characters in identifiers. (6.4.2) +- The number of significant initial characters in an identifier is unlimited. (5.2.4.1, 6.4.2) + +### J.3.4 Characters + +- The number of bits in a byte (CHAR\_BIT) is 8. See Section 5.4 for details about data types. (3.6) +- The execution character set is the same as the basic execution character set: plain ASCII. (5.2.1) +- The values produced for the standard alphabetic escape sequences are as follows: (5.2.2) + +| Escape Sequence | ASCII Meaning | Integer Value | +|-----------------|-------------------------|---------------| +| \a | BEL (bell) | 7 | +| \b | BS (backspace) | 8 | +| \f | FF (form feed) | 12 | +| \n | LF (line feed) | 10 | +| \r | CR (carriage
return) | 13 | +| \t | HT (horizontal tab) | 9 | +| \v | VT (vertical tab) | 11 | + +- The value of a char object into which any character other than a member of the basic execution character set has been stored is the ASCII value of that character. (6.2.5) +- Plain char is identical to signed char, but can be changed to unsigned char with the --plain\_char=unsigned option. (6.2.5, 6.3.1.1) +- The source character set and execution character set are both plain ASCII, so the mapping between them is one-to-one. The compiler does accept multibyte characters in comments, string literals, and character constants. (6.4.4.4, 5.1.1.2) +- The compiler currently supports only one locale, "C". (6.4.4.4). +- The compiler currently supports only one locale, "C". (6.4.5). + +### J.3.5 Integers + +- No extended integer types are provided. (6.2.5) +- Negative values for signed integer types are represented as two's complement, and there are no trap representations. (6.2.6.2) +- No extended integer types are provided, so there is no change to the integer ranks. (6.3.1.1) +- When an integer is converted to a signed integer type which cannot represent the value, the value is + +truncated (without raising a signal) by discarding the bits which cannot be stored in the destination type; the lowest bits are not modified. (6.3.1.3) + +• Right shift of a signed integer value performs an arithmetic (signed) shift. The bitwise operations other than right shift operate on the bits in exactly the same way as on an unsigned value. That is, after the usual arithmetic conversions, the bitwise operation is performed without regard to the format of the integer type, in particular the sign bit. (6.5) + +### J.3.6 Floating point + +- The accuracy of floating-point operations (+ \* /) is bit-exact. The accuracy of library functions that return floating-point results is not specified. (5.2.4.2.2) +- The compiler does not provide non-standard values for FLT\_ROUNDS (5.2.4.2.2) +- The compiler does not provide non-standard negative values of FLT\_EVAL\_METHOD (5.2.4.2.2) +- The rounding direction when an integer is converted to a floating-point number is IEEE-754 "round to even". (6.3.1.4) +- The rounding direction when a floating-point number is converted to a narrower floating-point number is IEEE-754 "round to even". (6.3.1.5) +- For floating-point constants that are not exactly representable, the implementation uses the nearest representable value. (6.4.4.2) +- The compiler does not contract float expressions. (6.5) +- The default state for the FENV\_ACCESS pragma is off. (7.6.1) +- The TI compiler does not define any additional float exceptions (7.6, 7.12) +- The default state for the FP\_CONTRACT pragma is off. (7.12.2) +- The "inexact" floating-point exception cannot be raised if the rounded result equals the mathematical result. (F.9) +- The "underflow" and "inexact" floating-point exceptions cannot be raised if the result is tiny but not inexact. (F.9) + +### J.3.7 Arrays and pointers + +- When converting a pointer to an integer or vice versa, the pointer is considered an unsigned integer of the same size, and the normal integer conversion rules apply. +- When converting a pointer to an integer or vice versa, if the bitwise representation of the destination can hold all of the bits in the bitwise representation of the source, the bits are copied exactly. (6.3.2.3) +- The size of the result of subtracting two pointers to elements of the same array is the size of ptrdiff\_t, which is defined in Section 5.4. (6.5.6) + +### J.3.8 Hints + +- When the optimizer is used, the register storage-class specifier is ignored. When the optimizer is not used, the compiler will preferentially place register storage class objects into registers to the extent possible. The compiler reserves the right to place any register storage class object somewhere other than a register. (6.7.1) +- The inline function specifier is ignored unless the optimizer is used. For other restrictions on inlining, see Section 2.11.2. (6.7.4) + +### J.3.9 Structures, unions, enumerations, and bit-fields + +- A "plain" int bit-field is treated as a signed int bit-field. (6.7.2, 6.7.2.1) +- In addition to \_Bool, signed int, and unsigned int, the compiler allows char, signed char, unsigned char, signed short, unsigned shot, signed long, unsigned long, signed long long, unsigned long long, and enum types as bit-field types. (6.7.2.1) +- Bit-fields may not straddle a storage-unit boundary.(6.7.2.1) +- Bit-fields are allocated in endianness order within a unit. (6.7.2.1) +- Non-bit-field members of structures are aligned as specified in (6.7.2.1) +- The integer type underlying each enumerated type is described in Section 5.4.1. (6.7.2.2) + +### J.3.10 Qualifiers + +• The TI compiler does not shrink or grow volatile accesses. It is the user's responsibility to make sure the access size is appropriate for devices that only tolerate accesses of certain widths. The TI compiler does not change the number of accesses to a volatile variable unless absolutely necessary. This is significant for read-modify-write expressions such as += ; for an architecture which does not have a corresponding read-modify-write instruction, the compiler will be forced to use two accesses, one for the read and one for the write. Even for architectures with such instructions, it is not guaranteed that the compiler will be able to map such expressions to an instruction with a single memory operand. It is not guaranteed that the memory system will lock that memory location for the duration of the instruction. In a multi-core system, some other core may write the location after a RMW instruction reads it, but before it writes the result. The TI compiler will not reorder two volatile accesses, but it may reorder a volatile and a non-volatile access, so volatile cannot be used to create a critical section. Use some sort of lock if you need to create a critical section. (6.7.3) + +### J.3.11 Preprocessing directives + +- Include directives may have one of two forms, " " or < >. For both forms, the compiler will look for a real file on-disk by that name using the include file search path. See Section 2.5.2. (6.4.7). +- The value of a character constant in a constant expression that controls conditional inclusion matches the value of the same character constant in the execution character set (both are ASCII). (6.10.1). +- The compiler uses the file search path to search for an included < > delimited header file. See Section 2.5.2. (6.10.2). +- he compiler uses the file search path to search for an included " " delimited header file. See Section 2.5.2. (6.10.2). (6.10.2). +- There is no arbitrary nesting limit for #include processing. (6.10.2). +- See Section 5.9 for a description of the recognized non-standard pragmas. (6.10.6). +- The date and time of translation are always available from the host. (6.10.8). + +### J.3.12 Library functions + +- Almost all of the library functions required for a hosted implementation are provided by the TI library, with exceptions noted in Section 5.13.1. (5.1.2.1). +- The format of the diagnostic printed by the assert macro is "Assertion failed, (*assertion macro argument*), file *file*, line *line*". (7.2.1.1). +- No strings other than "C" and "" may be passed as the second argument to the setlocale function (7.11.1.1). +- No signal handling is supported. (7.14.1.1). +- The +INF, -INF, +inf, -inf, NAN, and nan styles can be used to print an infinity or NaN. (7.19.6.1, 7.24.2.1). +- The output for %p conversion in the fprintf or fwprintf function is the same as %x of the appropriate size. (7.19.6.1, 7.24.2.1). +- The termination status returned to the host environment by the abort, exit, or \_Exit function is not returned to the host environment. (7.20.4.1, 7.20.4.3, 7.20.4.4). +- The system function is not supported. (7.20.4.6). + +### J.3.13 Architecture + +- The values or expressions assigned to the macros specified in the headers float.h, limits.h, and stdint.h are described along with the sizes and format of integer types are described in Section 5.4. (5.2.4.2, 7.18.2, 7.18.3) +- The number, order, and encoding of bytes in any object are described in Section 6.2.1. (6.2.6.1) +- The value of the result of the sizeof operator is the storage size for each type, in terms of bytes. See Section 6.2.1. (6.5.3.4) + +## 5.2 Characteristics of PRU C++ + +The PRU compiler supports C++ as defined in the ANSI/ISO/IEC 14882:2003 standard (C++03), including these features: + +- Complete C++ standard library support, with exceptions noted below. +- Templates +- Exceptions, which are enabled with the --exceptions option; see Section 5.6. +- Run-time type information (RTTI), which can be enabled with the --rtti compiler option. + +The compiler supports the 2003 standard of C++ as standardized by the ISO. However, the following features are *not* implemented or fully supported: + +- The compiler does not support embedded C++ run-time-support libraries. +- The library supports wide chars (wchar\_t), in that template functions and classes that are defined for char are also available for wchar\_t. For example, wide char stream classes wios, wiostream, wstreambuf and so on (corresponding to char classes ios, iostream, streambuf) are implemented. However, there is no low-level file I/O for wide chars. Also, the C library interface to wide char support (through the C++ headers and ) is limited as described above in the C library. +- The export keyword is not implemented. + +## 5.3 Using MISRA C 2004 + +MISRA C is a set of software development guidelines for the C programming language. It promotes best practices in developing safety-related electronic systems in road vehicles and other embedded systems. MISRA C was originally launched in 1998 by the Motor Industry Software Reliability Association, and has since been adopted across a wide variety of industries. A subsequent update to the guidelines was publishes as MISRA C:2004 + +You can alter your code to work with the MISRA C:2004 rules. The following options and pragmas can be used to enable/disable rules: + +- The --check\_misra option enables checking of the specified MISRA C:2004 rules. This compiler option must be used if you want to enable further control over checking using the CHECK\_MISRA and RESET\_MISRA pragmas. +- The CHECK\_MISRA pragma enables/disables MISRA C:2004 rules at the source level. See Section 5.9.2. +- The RESET\_MISRA pragma resets the specified MISRA C:2004 rules to their state before any CHECK\_MISRA pragmas were processed. See Section 5.9.18. + +The syntax of the option and the pragmas is: + +``` +--check_misra={all|required|advisory|none|rulespec} +#pragma CHECK_MISRA ("{all|required|advisory|none|rulespec}") +#pragma RESET_MISRA ("{all|required|advisory|rulespec}") +``` + +The *rulespec* parameter is a comma-separated list of rule numbers to enable or disable. + +Example: --check\_misra=1.1,1.4,1.5,2.1,2.7,7.1,7.2,8.4 + +• Enables checking of rules 1.1, 1.4, 1.5, 2.1, 2.7, 7.1, 7.2, and 8.4. + +Example: #pragma CHECK\_MISRA("-7.1,-7.2,-8.4") + +• Disables checking of rules 7.1, 7.2, and 8.4. + +A typical use case is to use the --check\_misra option on the command line to specify the rules that should be checked in most of your code. Then, use the CHECK\_MISRA pragma with a *rulespec* to activate or deactivate certain rules for a particular region of code. + +Two options control the severity of certain MISRA C:2004 rules: + +- The --misra\_required option sets the diagnostic severity for required MISRA C:2004 rules. +- The --misra\_advisory option sets the diagnostic severity for advisory MISRA C:2004 rules. + +The syntax for these options is: + +``` +--misra_advisory={error|warning|remark|suppress} +--misra_required={error|warning|remark|suppress} +``` + +## 5.4 Data Types + +Table 5-1 lists the size, representation, and range of each scalar data type for the PRU compiler. Many of the range values are available as standard macros in the header file limits.h. + +**Table 5-1. PRU C/C++ Data Types** + +| | | | | Range | +|-----------------------------------------------------|---------|----------------|----------------------------|----------------------------| +| Type | Size | Representation | Minimum | Maximum | +| signed char
char (unless
--plain_char=unsigned) | 8 bits | ASCII | -128 | 127 | +| unsigned char | 8 bits | ASCII | 0 | 255 | +| short, signed short | 16 bits | Binary | -32 768 | 32 767 | +| unsigned short | 16 bits | Binary | 0 | 65 535 | +| int, signed int | 32 bits | Binary | -2 147 483 648 | 2 147 483 647 | +| unsigned int, wchar_t | 32 bits | Binary | 0 | 4 294 967 295 | +| long, signed long | 32 bits | Binary | -2 147 483 648 | 2 147 483 647 | +| unsigned long | 32 bits | Binary | 0 | 4 294 967 295 | +| long long, signed long long | 64 bits | Binary | -9 223 372 036 854 775 808 | 9 223 372 036 854 775 807 | +| unsigned long long | 64 bits | Binary | 0 | 18 446 744 073 709 551 615 | +| float | 32 bits | IEEE 32-bit | 1.175 494e-38(1) | 3.40 282 346e+38 | +| double | 64 bits | IEEE 64-bit | 2.22 507 385e-308(1) | 1.79 769 313e+308 | +| long double | 64 bits | IEEE 64-bit | 2.22 507 385e-308(1) | 1.79 769 313e+308 | +| data pointers | 32 bits | Binary | 0 | 0xFFFFFFFF | +| code pointers | 16 bits | Binary | 0 | 0xFFFF | + +(1) Figures are minimum precision. + +All data types are single-byte aligned. + +Negative values for signed types are represented using two's complement. + +The type of the storage container for an enumerated type is the smallest integer type that contains all the enumerated values. The container types for enumerators are shown in Table 5-2. + +**Table 5-2. Enumerator Types** + +| Lower Bound Range | Upper Bound Range | Enumerator Type | | +|---------------------------|---------------------------------|---------------------|--| +| 0 to 255 | 0 to 255 | unsigned char | | +| -128 to 1 | -128 to 127 | signed char | | +| 0 to 65 535 | 256 to 65 535 | unsigned short | | +| -128 to 1 | 128 to 32 767 | short, signed short | | +| -32 768 to -129 | -32 768 to 32 767 | | | +| 0 to 4 294 967 295 | 2 147 483 648 to 4 294 967 295 | unsigned int | | +| -32 768 to -1 | 32 767 to 2 147 483 647 | int, signed int | | +| -2 147 483 648 to -32 769 | -2 147 483 648 to 2 147 483 647 | | | +| 0 to 2 147 483 647 | 65 536 to 2 147 483 647 | | | + +The compiler determines the type based on the range of the lowest and highest elements of the enumerator. For example, the following code results in an enumerator type of int: + +``` +enum COLORS +{ green = -200, + blue = 1, + yellow = 2, + red = 60000 +}; +``` + +The following code results in an enumerator type of short: + +``` +enum COLORS +{ green = -200, + blue = 1, + yellow = 2, + red = 3 +}; +``` + +See Section 6.2.1 for additional information about data type storage. + +### 5.4.1 Size of Enum Types + +An enum type is represented by an underlying integer type. The size of the integer type and whether it is signed is based on the range of values of the enumerated constants. + +In strict C89 or C99 mode, the compiler allows only enumeration constants with values that will fit in "int" or "unsigned int". + +For C++ and relaxed C89/C99, the compiler allows enumeration constants up to the largest integral type (64 bits). The default, which is recommended, is for the underlying type to be the first type in the following list in which all the enumerated constant values can be represented: int, unsigned int, long, unsigned long, long long, unsigned long long. + +Enums are always packed and are aligned on a single-byte boundary. + +## 5.5 Keywords + +The PRU C/C++ compiler supports all of the standard C89 keywords, including const, volatile, and register. It also supports all of the standard C99 keywords, including inline and restrict. It also supports TI extension keywords \_\_near, \_\_far, and \_\_asm. Some keywords are not available in strict ANSI mode. + +The following keywords may appear in other target documentation and require the same treatment as the restrict keyword: + +- trap +- reentrant +- cregister + +### 5.5.1 The const Keyword + +The C/C++ compiler supports the ANSI/ISO standard keyword *const* in all modes. + +This keyword gives you greater optimization and control over allocation for certain data objects. You can apply the const qualifier to the definition of any variable or array to ensure that its value is not altered. + +Global objects qualified as const are placed in the .const section. The linker allocates the .const section from ROM or FLASH, which are typically more plentiful than RAM. The const data storage allocation rule has the following exceptions: + +- If *volatile* is also specified in the object definition. For example, volatile const int x. Volatile keywords are assumed to be allocated to RAM. (The program is not allowed to modify a const volatile object, but something external to the program might.) +- If the object has automatic storage (). +- If the object is a C++ object with a "mutable" member. +- If the object is initialized with a value that is not known at compile time (such as the value of another variable). + +In these cases, the storage for the object is the same as if the const keyword were not used. + +The placement of the const keyword within a definition is important. For example, the first statement below defines a constant pointer p to a modifiable int. The second statement defines a modifiable pointer q to a constant int: + +``` +int * const p = &x; +const int * q = &x; +``` + +Using the const keyword, you can define large constant tables and allocate them into system ROM. For example, to allocate a ROM table, you could use the following definition: + +``` +const int digits[] = {0,1,2,3,4,5,6,7,8,9}; +``` + +### 5.5.2 The near and far Keywords + +The PRU can load a 16-bit address into a register with a single instruction. However, pointers are 32 bits and load/store instructions can load from the full 32-bit address space. The near and far keywords allow more efficient loading of data. + +The near and far keywords can be applied to any data symbol. The \_\_near and \_\_far keywords are also accepted and are available even when --strict\_ansi is specified. The \_\_near and \_\_far keywords are guaranteed to not conflict with any user symbols named "near" and "far". + +The near keyword asserts that a symbol will be in the lower 16 bits of memory. By default all symbols are near. The PRU local memory is always in the lower 16 bits; most accesses to the upper memory range will be for peripheral accesses. + +The far keyword asserts that a symbol *may* be in the upper 16 bits of memory. It is legal to place far data in the lower 16 bits of memory. All symbols that will reside in the upper 16 bits of memory must be declared using far, even if they have the cregister attribute. + +A cregister symbol can have a far qualifier and be a near cregister access. See Section 5.14.4 for information about type attributes, including cregister. For example: + +``` +__far int peripheral __attribute__((cregister("PERIPH", near))); +``` + +This means that relative to the cregister access peripheral, this is a near access. However, if accessed using an absolute address, this is a far access. This is important because the compiler may choose to not access a peripheral using a cregister access. + +### 5.5.3 The volatile Keyword + +The C/C++ compiler supports the *volatile* keyword in all modes. In addition, the \_\_volatile keyword is supported in relaxed ANSI mode for C89, C99, and C++. + +The volatile keyword indicates to the compiler that there is something about how the variable is accessed that requires that the compiler not use overly-clever optimization on expressions involving that variable. For example, the variable may also be accessed by an external program, another thread, or a peripheral device. + +The compiler eliminates redundant memory accesses whenever possible, using data flow analysis to figure out when it is legal. However, some memory accesses may be special in some way that the compiler cannot see, and in such cases you should use the volatile keyword to prevent the compiler from optimizing away something important. The compiler does not optimize out any accesses to variables declared volatile. The number of volatile reads and writes will be exactly as they appear in the C/C++ code, no more and no less and in the same order. + +Any variable which might be modified by something external to the obvious control flow of the program must be declared volatile. This tells the compiler that a function might modify the value at any time, so the compiler should not perform optimizations which will change the number or order of accesses of that variable. This is the primary purpose of the volatile keyword. In the following example, the loop intends to wait for a location to be read as 0xFF: + +``` +unsigned int *ctrl; +while (*ctrl !=0xFF); +``` + +However, in this example, \*ctrl is a loop-invariant expression, so the loop is optimized down to a singlememory read. To get the desired result, define ctrl as: + +``` +volatile unsigned int *ctrl; +``` + +Here the \*ctrl pointer is intended to reference a hardware location. + +The volatile keyword must also be used when accessing memory locations that represent memorymapped peripheral devices. Such memory locations might change value in ways that the compiler cannot predict. These locations might change if accessed, or when some other memory location is accessed, or when some signal occurs. + +Volatile must also be used for local variables in a function which calls setjmp, if the value of the local variables needs to remain valid if a longjmp occurs. + +# Example 5-1. Volatile for Local Variables With setjmp + +``` +#include +jmp_buf context; +void function() +{ + volatile int x = 3; + switch(setjmp(context)) + { + case 0: setup(); break; + default: + { + printf("x == %d\n", x); /* We can only reach here if longjmp has occurred; because x's + lifetime begins before the setjmp and lasts through the longjmp, + the C standard requires x be declared "volatile" */ + break; + } + } +} +``` + +## 5.6 C++ Exception Handling + +The compiler supports all the C++ exception handling features as defined by the ANSI/ISO 14882 C++ Standard. More details are discussed in *The C++ Programming Language, Third Edition* by Bjarne Stroustrup. + +The compiler --exceptions option enables exception handling. The compiler's default is no exception handling support. + +For exceptions to work correctly, all C++ files in the application must be compiled with the --exceptions option, regardless of whether exceptions occur in a particular file. Mixing exception-enabled object files and libraries with object files and libraries that do not have exceptions enabled can lead to undefined behavior. + +Exception handling requires support in the run-time-support library, which come in exception-enabled and exception-disabled forms; you must link with the correct form. When using automatic library selection (the default), the linker automatically selects the correct library Section 4.3.1.1. If you select the library manually, you must use run-time-support libraries whose name contains \_eh if you enable exceptions. + +Using the --exceptions option causes the compiler to insert exception handling code. This code will increase the size of the programand the execution time, even if an exception is never thrown. + +See Section 7.1 for details on the run-time libraries. + +## 5.7 Register Variables and Parameters + +The C/C++ compiler allows the use of the keyword register on global and local register variables and parameters. This section describes the compiler implementation for this qualifier. + +### 5.7.1 Local Register Variables and Parameters + +The C/C++ compiler treats register variables (variables defined with the register keyword) differently, depending on whether you use the --opt\_level (-O) option. + +# • **Compiling with optimization** + +The compiler ignores any register definitions and allocates registers to variables and temporary values by using an algorithm that makes the most efficient use of registers. + +# • **Compiling without optimization** + +If you use the register keyword, you can suggest variables as candidates for allocation into registers. The compiler uses the same set of registers for allocating temporary expression results as it uses for allocating register variables. + +The compiler attempts to honor all register definitions. If the compiler runs out of appropriate registers, it frees a register by moving its contents to memory. If you define too many objects as register variables, you limit the number of registers the compiler has for temporary expression results. This limit causes excessive movement of register contents to memory. + +Any object with a scalar type (integral, floating point, or pointer) can be defined as a register variable. The register designator is ignored for objects of other types, such as arrays. + +The register storage class is meaningful for parameters as well as local variables. Normally, in a function, some of the parameters are copied to a location on the stack where they are referenced during the function body. The compiler copies a register parameter to a register instead of the stack, which speeds access to the parameter within the function. + +For more information about register conventions, see Section 6.3. + +### 5.7.2 Global Register Variables + +The C/C++ compiler extends the C language by adding a special convention to the register storage class specifier to allow the allocation of global registers. This special global declaration has the form: + +#### **register** *type regid* + +The *regid* parameter can be \_\_R30 and \_\_R31. The identifiers \_ \_R30 and \_ \_R31 are each bound to their corresponding register R30 and R31, respectively. These are control registers and should always be declared as volatile. For example: + +``` +volatile register unsigned int __R31; +__R31 |= 1; +``` + +## 5.8 The \_\_asm Statement + +The C/C++ compiler can embed assembly language instructions or directives directly into the assembly language output of the compiler. This capability is an extension to the C/C++ language implemented through the *\_\_asm* keyword. The \_\_asm keyword provides access to hardware features that C/C++ cannot provide. + +The alternate keyword, "asm", may also be used except in strict ANSI C mode. It is available in relaxed C and C++ modes. + +Using \_\_asm is syntactically performed as a call to a function named \_\_asm, with one string constant argument: + +**\_\_asm("** *assembler text* **");** + +The compiler copies the argument string directly into your output file. The assembler text must be enclosed in double quotes. All the usual character string escape codes retain their definitions. For example, you can insert a .byte directive that contains quotes as follows: + +``` +__asm("STR: .byte \"abc\""); +``` + +The inserted code must be a legal assembly language statement. Like all assembly language statements, the line of code inside the quotes must begin with a label, a blank, a tab, or a comment (asterisk or semicolon). The compiler performs no checking on the string; if there is an error, the assembler detects it. For more information about the assembly language statements, see the *PRU Assembly Language Tools User's Guide*. + +The \_\_asm statements do not follow the syntactic restrictions of normal C/C++ statements. Each can appear as a statement or a declaration, even outside of blocks. This is useful for inserting directives at the very beginning of a compiled module. + +The \_\_asm statement does not provide any way to refer to local variables. If your assembly code needs to refer to local variables, you will need to write the entire function in assembly code. + +For more information, refer to Section 6.6.5. + +#### NOTE: Avoid Disrupting the C/C++ Environment With asm Statements + +Be careful not to disrupt the C/C++ environment with \_\_asm statements. The compiler does not check the inserted instructions. Inserting jumps and labels into C/C++ code can cause unpredictable results in variables manipulated in or around the inserted code. Directives that change sections or otherwise affect the assembly environment can also be troublesome. + +Be especially careful when you use optimization with \_\_asm statements. Although the compiler cannot remove \_\_asm statements, it can significantly rearrange the code order near them and cause undesired results. + +## 5.9 Pragma Directives + +Pragma directives tell the compiler how to treat a certain function, object, or section of code. The C/C++ compiler supports the following pragmas: + +- CALLS (See Section 5.9.1) +- CHECK\_MISRA (See Section 5.9.2) +- CODE\_SECTION (See Section 5.9.3) +- DATA\_ALIGN (See Section 5.9.4) +- DATA\_SECTION (See Section 5.9.5) +- diag\_suppress, diag\_remark, diag\_warning, diag\_error, diag\_default, diag\_push, diag\_pop (See Section 5.9.6) +- FORCEINLINE (See Section 5.9.7) +- FORCEINLINE\_RECURSIVE (See Section 5.9.8) +- FUNC\_ALWAYS\_INLINE (See Section 5.9.9) +- FUNC\_CANNOT\_INLINE (See Section 5.9.10) +- FUNC\_EXT\_CALLED (See Section 5.9.11) +- FUNCTION\_OPTIONS (See Section 5.9.12) +- LOCATION (See Section 5.9.13) +- MUST\_ITERATE (See Section 5.9.14) +- NOINIT (See Section 5.9.15) +- NOINLINE (See Section 5.9.16) +- NO\_HOOKS (See Section 5.9.17) +- PERSISTENT (See Section 5.9.15) +- RESET\_MISRA (See Section 5.9.18) +- RETAIN (See Section 5.9.19) +- SET\_CODE\_SECTION (See Section 5.9.20) +- SET\_DATA\_SECTION (See Section 5.9.20) +- UNROLL (See Section 5.9.21) +- WEAK (See Section 5.9.22) + +arguments *func* and *symbol* cannot be defined or declared inside the body of a function. You must specify the pragma outside the body of a function; and the pragma specification must occur before any declaration, definition, or reference to the func or symbol argument. If you do not follow these rules, the compiler issues a warning and may ignore the pragma. + +For pragmas that apply to functions or symbols, the syntax differs between C and C++. + +- In C, you must supply the name of the object or function to which you are applying the pragma as the first argument. Because the entity operated on is specified, a pragma in C can appear some distance way from the definition of that entity. +- In C++, pragmas are positional. They do not name the entity on which they operate as an argument. Instead, they always operate on the next entity defined after the pragma. + +### 5.9.1 The CALLS Pragma + +The CALLS pragma specifies a set of functions that can be called indirectly from a specified calling function. + +The CALLS pragma is used by the compiler to embed debug information about indirect calls in object files. Using the CALLS pragma on functions that make indirect calls enables such indirect calls to be included in calculations for such functions' inclusive stack sizes. For more information on generating function stack usage information, see the -cg option of the Object File Display Utility in the "Invoking the Object File Display Utility" section of the *Assembly Language Tools User's Guide*. + +The CALLS pragma can precede either the calling function's definition or its declaration. In C, the pragma must have at least 2 arguments—the first argument is the calling function, followed by at least one function that will be indirectly called from the calling function. In C++, the pragma applies to the next function declared or defined, and the pragma must have at least one argument. + +The syntax for the CALLS pragma in C is as follows. This indicates that calling\_function can indirectly call function\_1 through function\_n. + +``` +#pragma CALLS ( calling_function, function_1, function_2, ..., function_n ) +``` + +The syntax for the CALLS pragma in C++ is: + +``` +#pragma CALLS ( function_1_mangled_name, ..., function_n_mangled_name ) +``` + +Note that in C++, the arguments to the CALLS pragma must be the full mangled names for the functions that can be indirectly called from the calling function. + +The GCC-style "calls" attribute syntax, which has the same effect as the CALLS pragma, is as follows: + +``` +__attribute__((calls("function_1","function_2",..., "function_n"))) +``` + +### 5.9.2 The CHECK\_MISRA Pragma + +The CHECK\_MISRA pragma enables/disables MISRA C:2004 rules at the source level. The compiler option --check\_misra must be used to enable checking in order for this pragma to function at the source level. + +The syntax of the pragma in C is: + +``` +#pragma CHECK_MISRA (" {all|required|advisory|none|rulespec} ") +``` + +The *rulespec* parameter is a comma-separated list of rule numbers. See Section 5.3 for details. + +The RESET\_MISRA pragma can be used to reset any CHECK\_MISRA pragmas; see Section 5.9.18. + +### 5.9.3 The CODE\_SECTION Pragma + +The CODE\_SECTION pragma allocates space for the *symbol* in C, or the next symbol declared in C++, in a section named *section name*. + +The syntax of the pragma in C is: + +``` +#pragma CODE_SECTION (symbol , "section name ") +``` + +The syntax of the pragma in C++ is: + +``` +#pragma CODE_SECTION (" section name ") +``` + +The CODE\_SECTION pragma is useful if you have code objects that you want to link into an area separate from the .text section. + +The following example demonstrates the use of the CODE\_SECTION pragma. + +# Example 5-2. Using the CODE\_SECTION Pragma C Source File + +``` +#pragma CODE_SECTION(fn, "my_sect") +int fn(int x) +{ + return x; +} +In this example, the fn() function will be placed in a section called "my_sect". +``` + +### 5.9.4 The DATA\_ALIGN Pragma + +The DATA\_ALIGN pragma aligns the *symbol* in C, or the next symbol declared in C++, to an alignment boundary. The alignment boundary is the maximum of the symbol's default alignment value or the value of the *constant* in bytes. The constant must be a power of 2. The maximum alignment is 32768. + +The DATA\_ALIGN pragma cannot be used to reduce an object's natural alignment. + +The syntax of the pragma in C is: + +``` +#pragma DATA_ALIGN ( symbol , constant ) +``` + +The syntax of the pragma in C++ is: + +``` +#pragma DATA_ALIGN ( constant ) +``` + +### 5.9.5 The DATA\_SECTION Pragma + +The DATA\_SECTION pragma allocates space for the *symbol* in C, or the next symbol declared in C++, in a section named *section name*. + +The syntax of the pragma in C is: + +``` +#pragma DATA_SECTION ( symbol , " section name ") +``` + +The syntax of the pragma in C++ is: + +``` +#pragma DATA_SECTION (" section name ") +``` + +The DATA\_SECTION pragma is useful if you have data objects that you want to link into an area separate from the .bss section. + +# Example 5-3. Using the DATA\_SECTION Pragma C Source File + +``` +#pragma DATA_SECTION(bufferB, "my_sect") +char bufferA[512]; +char bufferB[512]; +``` + +# Example 5-4. Using the DATA\_SECTION Pragma C++ Source File + +``` +char bufferA[512]; +#pragma DATA_SECTION("my_sect") +char bufferB[512]; +``` + +### 5.9.6 The Diagnostic Message Pragmas + +The following pragmas can be used to control diagnostic messages in the same ways as the corresponding command line options: + +| Pragma | Option | Description | +|-------------------|---------------------------------|-----------------------------------------------------------------------------------------------------------| +| diag_suppress num | -pds=num[, num2
, num3
] | Suppress diagnostic num | +| diag_remark num | -pdsr=num[, num2
, num3
] | Treat diagnostic num as a remark | +| diag_warning num | -pdsw=num[, num2
, num3
] | Treat diagnostic num as a warning | +| diag_error num | -pdse=num[, num2
, num3
] | Treat diagnostic num as an error | +| diag_default num | n/a | Use default severity of the diagnostic | +| diag_push | n/a | Push the current diagnostics severity state to store it for later use. | +| diag_pop | n/a | Pop the most recent diagnostic severity state stored with #pragma
diag_push to be the current setting. | + +The syntax of the diag\_suppress, diag\_remark, diag\_warning, and diag\_error pragmas in C is: + +``` +#pragma diag_xxx [=]num[, num2 + , num3 + ...] +``` + +Notice that the names of these pragmas are in lowercase. + +The diagnostic affected (*num*) is specified using either an error number or an error tag name. The equal sign (=) is optional. Any diagnostic can be overridden to be an error, but only diagnostic messages with a severity of discretionary error or below can have their severity reduced to a warning or below, or be suppressed. The diag\_default pragma is used to return the severity of a diagnostic to the one that was in effect before any pragmas were issued (i.e., the normal severity of the message as modified by any command-line options). + +The diagnostic identifier number is output with the message when you use the -pden command line option. The following example suppresses a diagnostic message and then restores the previous diagnostics severity state: + +``` +#pragma diag_push +#pragma diag_suppress 551 +#pragma CHECK_MISRA("-9.1") +#pragma diag_pop +``` + +### 5.9.7 The FORCEINLINE Pragma + +The FORCEINLINE pragma can be placed before a statement to force any function calls made in that statement to be inlined. It has no effect on other calls to the same functions. + +The compiler only inlines a function if it is legal to inline the function. Functions are never inlined if the compiler is invoked with the --opt\_level=off option. A function can be inlined even if the function is not declared with the inline keyword. A function can be inlined even if the compiler is not invoked with any - opt\_level command-line option. + +The syntax of the pragma in C/C++ is: + +# #pragma FORCEINLINE + +For example, in the following example, the mytest() and getname() functions are inlined, but the error() function is not. + +``` +#pragma FORCEINLINE +if (!mytest(getname(myvar))) { + error(); +} +``` + +Placing the FORCEINLINE pragma before the call to error() would inline that function but not the others. + +For information about interactions between command-line options, pragmas, and keywords that affect inlining, see Section 2.11. + +Notice that the FORCEINLINE, FORCEINLINE\_RECURSIVE, and NOINLINE pragmas affect only the C/C++ statement that follows the pragma. The FUNC\_ALWAYS\_INLINE and FUNC\_CANNOT\_INLINE pragmas affect an entire function. + +### 5.9.8 The FORCEINLINE\_RECURSIVE Pragma + +The FORCEINLINE\_RECURSIVE can be placed before a statement to force any function calls made in that statement to be inlined along with any calls made from those functions. That is, calls that are not visible in the statement but are called as a result of the statement will be inlined. + +The syntax of the pragma in C/C++ is: + +### #pragma FORCEINLINE\_RECURSIVE + +For information about interactions between command-line options, pragmas, and keywords that affect inlining, see Section 2.11. + +### 5.9.9 The FUNC\_ALWAYS\_INLINE Pragma + +The FUNC\_ALWAYS\_INLINE pragma instructs the compiler to always inline the named function. + +The compiler only inlines a function if it is legal to inline the function. Functions are never inlined if the compiler is invoked with the --opt\_level=off option. A function can be inlined even if the function is not declared with the inline keyword. A function can be inlined even if the compiler is not invoked with any - opt\_level command-line option. See Section 2.11 for details about interaction between various types of inlining. + +This pragma must appear before any declaration or reference to the function that you want to inline. In C, the argument *func* is the name of the function that will be inlined. In C++, the pragma applies to the next function declared. + +The syntax of the pragma in C is: + +``` +#pragma FUNC_ALWAYS_INLINE ( func ) +``` + +The syntax of the pragma in C++ is: + +# #pragma FUNC\_ALWAYS\_INLINE + +The following example uses this pragma: + +``` +#pragma FUNC_ALWAYS_INLINE(functionThatMustGetInlined) +static inline void functionThatMustGetInlined(void) { + P1OUT |= 0x01; + P1OUT &= ~0x01; +} +``` + +### Use Caution with the FUNC\_ALWAYS\_INLINE Pragma + +**NOTE:** The FUNC\_ALWAYS\_INLINE pragma overrides the compiler's inlining decisions. Overuse of this pragma could result in increased compilation times or memory usage, potentially enough to consume all available memory and result in compilation tool failures. + +### 5.9.10 The FUNC\_CANNOT\_INLINE Pragma + +The FUNC\_CANNOT\_INLINE pragma instructs the compiler that the named function cannot be expanded inline. Any function named with this pragma overrides any inlining you designate in any other way, such as using the inline keyword. Automatic inlining is also overridden with this pragma; see Section 2.11. + +The pragma must appear before any declaration or reference to the function that you want to keep. In C, the argument *func* is the name of the function that cannot be inlined. In C++, the pragma applies to the next function declared. + +The syntax of the pragma in C is: + +``` +#pragma FUNC_CANNOT_INLINE ( func ) +``` + +The syntax of the pragma in C++ is: + +``` +#pragma FUNC_CANNOT_INLINE +``` + +### 5.9.11 The FUNC\_EXT\_CALLED Pragma + +When you use the --program\_level\_compile option, the compiler uses program-level optimization. When you use this type of optimization, the compiler removes any function that is not called, directly or indirectly, by main(). You might have C/C++ functions that are called instead of main(). + +The FUNC\_EXT\_CALLED pragma specifies that the optimizer should keep these C functions or any functions these C/C++ functions call. These functions act as entry points into C/C++. The pragma must appear before any declaration or reference to the function to keep. In C, the argument *func* is the name of the function to keep. In C++, the pragma applies to the next function declared. + +The syntax of the pragma in C is: + +# **#pragma FUNC\_EXT\_CALLED (** *func* **)** + +The syntax of the pragma in C++ is: + +# #pragma FUNC\_EXT\_CALLED + +The name of the interrupt (the *func* argument) does not need to conform to a naming convention. + +When you use program-level optimization, you may need to use the FUNC\_EXT\_CALLED pragma with certain options. See Section 3.4.2. + +### 5.9.12 The FUNCTION\_OPTIONS Pragma + +The FUNCTION\_OPTIONS pragma allows you to compile a specific function in a C or C++ file with additional command-line compiler options. The affected function will be compiled as if the specified list of options appeared on the command line after all other compiler options. In C, the pragma is applied to the function specified. In C++, the pragma is applied to the next function. + +The syntax of the pragma in C is: + +### **#pragma FUNCTION\_OPTIONS (** *func***, "***additional options***" )** + +The syntax of the pragma in C++ is: + +### **#pragma FUNCTION\_OPTIONS( "***additional options***" )** + +Supported options for this pragma are --opt\_level, --auto\_inline, --code\_state, and --opt\_for\_speed. In order to use --opt\_level and --auto\_inline with the FUNCTION\_OPTIONS pragma, the compiler must be invoked with some optimization level (that is, at least --opt\_level=0). + +### 5.9.13 The LOCATION Pragma + +The compiler supports the ability to specify the run-time address of a variable at the source level. This can be accomplished with the LOCATION pragma or attribute. + +The syntax of the pragma in C is: + +![](_page_84_Figure_21.jpeg) + +The syntax of the pragmas in C++ is: + +# **#pragma LOCATION(***address* **)** + +**int** *x* + +The syntax of the GCC attribute is: + +``` +int x __attribute__((location(address ))) +``` + +The NOINIT pragma may be used in conjunction with the LOCATION pragma to map variables to special memory locations; see Section 5.9.15. + +### 5.9.14 The MUST\_ITERATE Pragma + +The MUST\_ITERATE pragma specifies to the compiler certain properties of a loop. When you use this pragma, you are guaranteeing to the compiler that a loop executes a specific number of times or a number of times within a specified range. + +Any time the UNROLL pragma is applied to a loop, MUST\_ITERATE should be applied to the same loop. For loops the MUST\_ITERATE pragma's third argument, multiple, is the most important and should always be specified. + +Furthermore, the MUST\_ITERATE pragma should be applied to any other loops as often as possible. This is because the information provided via the pragma (especially the minimum number of iterations) aids the compiler in choosing the best loops and loop transformations (that is, nested loop transformations). It also helps the compiler reduce code size. + +No statements are allowed between the MUST\_ITERATE pragma and the for, while, or do-while loop to which it applies. However, other pragmas, such as UNROLL, can appear between the MUST\_ITERATE pragma and the loop. + +#### 5.9.14.1 The MUST\_ITERATE Pragma Syntax + +The syntax of the pragma for C and C++ is: + +### **#pragma MUST\_ITERATE (** *min*, *max*, *multiple* **)** + +The arguments *min* and *max* are programmer-guaranteed minimum and maximum trip counts. The trip count is the number of times a loop iterates. The trip count of the loop must be evenly divisible by *multiple*. All arguments are optional. For example, if the trip count could be 5 or greater, you can specify the argument list as follows: + +``` +#pragma MUST_ITERATE(5) +``` + +However, if the trip count could be any nonzero multiple of 5, the pragma would look like this: + +``` +#pragma MUST_ITERATE(5, , 5) /* Note the blank field for max */ +``` + +It is sometimes necessary for you to provide min and multiple in order for the compiler to perform unrolling. This is especially the case when the compiler cannot easily determine how many iterations the loop will perform (that is, the loop has a complex exit condition). + +When specifying a multiple via the MUST\_ITERATE pragma, results of the program are undefined if the trip count is not evenly divisible by multiple. Also, results of the program are undefined if the trip count is less than the minimum or greater than the maximum specified. + +If no min is specified, zero is used. If no max is specified, the largest possible number is used. If multiple MUST\_ITERATE pragmas are specified for the same loop, the smallest max and largest min are used. + +#### 5.9.14.2 Using MUST\_ITERATE to Expand Compiler Knowledge of Loops + +Through the use of the MUST\_ITERATE pragma, you can guarantee that a loop executes a certain number of times. The example below tells the compiler that the loop is guaranteed to run exactly 10 times: + +``` +#pragma MUST_ITERATE(10,10) +for(i = 0; i < trip_count; i++) { ... +``` + +In this example, the compiler attempts to generate a loop even without the pragma. However, if MUST\_ITERATE is not specified for a loop such as this, the compiler generates code to bypass the loop, to account for the possibility of 0 iterations. With the pragma specification, the compiler knows that the loop iterates at least once and can eliminate the loop-bypassing code. + +MUST\_ITERATE can specify a range for the trip count as well as a factor of the trip count. The following example tells the compiler that the loop executes between 8 and 48 times and the trip\_count variable is a multiple of 8 (8, 16, 24, 32, 40, 48). The multiple argument allows the compiler to unroll the loop. + +``` +#pragma MUST_ITERATE(8, 48, 8) +for(i = 0; i < trip_count; i++) { ... +``` + +You should consider using MUST\_ITERATE for loops with complicated bounds. In the following example, the compiler would have to generate a divide function call to determine, at run time, the number of iterations performed. + +``` +for(i2 = ipos[2]; i2 < 40; i2 += 5) { ... +``` + +The compiler will not do the above. In this case, using MUST\_ITERATE to specify that the loop always executes eight times allows the compiler to attempt to generate a loop: + +``` +#pragma MUST_ITERATE(8, 8) +for(i2 = ipos[2]; i2 < 40; i2 += 5) { ... +``` + +### 5.9.15 The NOINIT and PERSISTENT Pragmas + +Global and static variables are zero-initialized. However, in applications that use non-volatile memory, it may be desirable to have variables that are not initialized. Noinit variables are global or static variables that are not zero-initialized at startup or reset. + +Persistent and noinit variables behave identically with the exception of whether or not they are initialized at load time. + +The NOINIT pragma may be used in conjunction with the LOCATION pragma to map variables to special memory locations, like memory-mapped registers, without generating unwanted writes. The NOINIT pragma may only be used with uninitialized variables. + +The PERSISTENT pragma is similar to the NOINIT pragma, except that it may only be used with statically-initialized variables. Persistent variables disable startup initialization; they are given an initial value when the code is loaded, but are never again initialized. + +**NOTE:** When using these pragmas in non-volatile FRAM memory, the memory region could be protected against unintended writes through the device's Memory Protection Unit. Some devices have memory protection enabled by default. Please see the information about memory protection in the datasheet for your device. If the Memory Protection Unit is enabled, it first needs to be disabled before modifying the variables. + +If you are using non-volatile RAM, you can define a persistent variable with an initial value of zero loaded into RAM. The program can increment that variable over time as a counter, and that count will not disappear if the device loses power and restarts, because the memory is non-volatile and the boot routines do not initialize it back to zero. For example: + +``` +#pragma PERSISTENT(x) +#pragma location = 0xC200 // memory address in RAM +int x = 0; +void main() { + run_init(); + while (1) { + run_actions(x); + __delay_cycles(1000000); + x++; + } +} +``` + +The syntax of the pragmas in C is: + +``` +#pragma NOINIT (x ) +``` + +**int** *x***;** + +# **#pragma PERSISTENT (***x* **)** + +**int** *x***=10;** + +The syntax of the pragmas in C++ is: + +### #pragma NOINIT + +**int** *x***;** + +### #pragma PERSISTENT + +**int** *x***=10;** + +The syntax of the GCC attributes is: + +``` +int x __attribute__((noinit)); +``` + +``` +int x __attribute__((persistent)) = 0; +``` + +### 5.9.16 The NOINLINE Pragma + +The NOINLINE pragma can be placed before a statement to prevent any function calls made in that statement from being inlined. It has no effect on other calls to the same functions. + +The syntax of the pragma in C/C++ is: + +### #pragma NOINLINE + +For information about interactions between command-line options, pragmas, and keywords that affect inlining, see Section 2.11. + +### 5.9.17 The NO\_HOOKS Pragma + +The NO\_HOOKS pragma prevents entry and exit hook calls from being generated for a function. + +The syntax of the pragma in C is: + +**#pragma NO\_HOOKS (** *func* **)** + +The syntax of the pragma in C++ is: + +**#pragma NO\_HOOKS** + +See Section 2.13 for details on entry and exit hooks. + +### 5.9.18 The RESET\_MISRA Pragma + +The RESET\_MISRA pragma resets the specified MISRA C:2004 rules to the state they were before any CHECK\_MISRA pragmas (see Section 5.9.2) were processed. For instance, if a rule was enabled on the command line but disabled in the source, the RESET\_MISRA pragma resets it to enabled. This pragma accepts the same format as the --check\_misra option, except for the "none" keyword. + +The --check\_misra compiler command-line option must be used to enable MISRA C:2004 rule checking in order for this pragma to function at the source level. + +The syntax of the pragma in C is: + +**#pragma RESET\_MISRA ("** {all|required|advisory|*rulespec*} **")** + +The *rulespec* parameter is a comma-separated list of rule numbers. See Section 5.3 for details. + +### 5.9.19 The RETAIN Pragma + +The RETAIN pragma can be applied to a code or data symbol. It causes a .retain directive to be generated into the section that contains the definition of the symbol. The .retain directive indicates to the linker that the section is ineligible for removal during conditional linking. Therefore, regardless whether or not the section is referenced by another section in the application that is being compiled and linked, it will be included in the output file result of the link. + +The syntax of the pragma in C is: + +**#pragma RETAIN (** *symbol* **)** + +The syntax of the pragma in C++ is: + +**#pragma RETAIN** + +### 5.9.20 The SET\_CODE\_SECTION and SET\_DATA\_SECTION Pragmas + +These pragmas can be used to set the section for all declarations below the pragma. + +The syntax of the pragmas in C/C++ is: + +``` +#pragma SET_CODE_SECTION ("section name") +``` + +``` +#pragma SET_DATA_SECTION ("section name") +``` + +In Example 5-5 x and y are put in the section mydata. To reset the current section to the default used by the compiler, a blank parameter should be passed to the pragma. An easy way to think of the pragma is that it is like applying the CODE\_SECTION or DATA\_SECTION pragma to all symbols below it. + +# Example 5-5. Setting Section With SET\_DATA\_SECTION Pragma + +``` +#pragma SET_DATA_SECTION("mydata") +int x; +int y; +#pragma SET_DATA_SECTION() +``` + +The pragmas apply to both declarations and definitions. If applied to a declaration and not the definition, the pragma that is active at the declaration is used to set the section for that symbol. Here is an example: + +### Example 5-6. Setting a Section With SET\_CODE\_SECTION Pragma + +``` +#pragma SET_CODE_SECTION("func1") +extern void func1(); +#pragma SET_CODE_SECTION() +... +void func1() { ... } +``` + +In Example 5-6 func1 is placed in section func1. If conflicting sections are specified at the declaration and definition, a diagnostic is issued. + +The current CODE\_SECTION and DATA\_SECTION pragmas and GCC attributes can be used to override the SET\_CODE\_SECTION and SET\_DATA\_SECTION pragmas. For example: + +### Example 5-7. Overriding SET\_DATA\_SECTION Setting + +``` +#pragma DATA_SECTION(x, "x_data") +#pragma SET_DATA_SECTION("mydata") +int x; +int y; +#pragma SET_DATA_SECTION() +``` + +In Example 5-7 x is placed in x\_data and y is placed in mydata. No diagnostic is issued for this case. + +The pragmas work for both C and C++. In C++, the pragmas are ignored for templates and for implicitly created objects, such as implicit constructors and virtual function tables. + +### 5.9.21 The UNROLL Pragma + +The UNROLL pragma specifies to the compiler how many times a loop should be unrolled. The optimizer must be invoked (use --opt\_level=[1|2|3] or -O1, -O2, or -O3) in order for pragma-specified loop unrolling to take place. The compiler has the option of ignoring this pragma. + +No statements are allowed between the UNROLL pragma and the for, while, or do-while loop to which it applies. However, other pragmas, such as MUST\_ITERATE, can appear between the UNROLL pragma and the loop. + +The syntax of the pragma for C and C++ is: + +# **#pragma UNROLL(** *n* **)** + +If possible, the compiler unrolls the loop so there are *n* copies of the original loop. The compiler only unrolls if it can determine that unrolling by a factor of *n* is safe. In order to increase the chances the loop is unrolled, the compiler needs to know certain properties: + +- The loop iterates a multiple of *n* times. This information can be specified to the compiler via the multiple argument in the MUST\_ITERATE pragma. +- The smallest possible number of iterations of the loop +- The largest possible number of iterations of the loop + +The compiler can sometimes obtain this information itself by analyzing the code. However, sometimes the compiler can be overly conservative in its assumptions and therefore generates more code than is necessary when unrolling. This can also lead to not unrolling at all. Furthermore, if the mechanism that determines when the loop should exit is complex, the compiler may not be able to determine these properties of the loop. In these cases, you must tell the compiler the properties of the loop by using the MUST\_ITERATE pragma. + +Specifying #pragma UNROLL(1) asks that the loop not be unrolled. Automatic loop unrolling also is not performed in this case. + +If multiple UNROLL pragmas are specified for the same loop, it is undefined which pragma is used, if any. + +### 5.9.22 The WEAK Pragma + +The WEAK pragma gives weak binding to a symbol. + +The syntax of the pragma in C is: + +### **#pragma WEAK (** *symbol* **)** + +The syntax of the pragma in C++ is: + +### #pragma WEAK + +The WEAK pragma makes *symbol* a weak reference if it is a reference, or a weak definition, if it is a definition. The symbol can be a data or function variable. In effect, unresolved weak *references* do not cause linker errors and do not have any effect at run time. The following apply for weak references: + +- Libraries are not searched to resolve weak references. It is not an error for a weak reference to remain unresolved. +- During linking, the value of an undefined weak reference is: + - Zero if the relocation type is absolute + - The address of the place if the relocation type is PC-relative + - The address of the nominal base address if the relocation type is base-relative. + +A weak *definition* does not change the rules by which object files are selected from libraries. However, if a link set contains both a weak definition and a non-weak definition, the non-weak definition is always used. + +## 5.10 The \_Pragma Operator + +The PRU C/C++ compiler supports the C99 preprocessor \_Pragma() operator. This preprocessor operator is similar to #pragma directives. However, \_Pragma can be used in preprocessing macros (#defines). + +The syntax of the operator is: + +``` +_Pragma (" string_literal "); +``` + +The argument *string\_literal* is interpreted in the same way the tokens following a #pragma directive are processed. The string\_literal must be enclosed in quotes. A quotation mark that is part of the string\_literal must be preceded by a backward slash. + +You can use the \_Pragma operator to express #pragma directives in macros. For example, the DATA\_SECTION syntax: + +``` +#pragma DATA_SECTION( func ," section ") +``` + +Is represented by the \_Pragma() operator syntax: + +``` +_Pragma ("DATA_SECTION( func ,\" section \")") +``` + +The following code illustrates using \_Pragma to specify the DATA\_SECTION pragma in a macro: + +``` +... +#define EMIT_PRAGMA(x) _Pragma(#x) +#define COLLECT_DATA(var) EMIT_PRAGMA(DATA_SECTION(var,"mysection")) +COLLECT_DATA(x) +int x; +... +``` + +The EMIT\_PRAGMA macro is needed to properly expand the quotes that are required to surround the section argument to the DATA\_SECTION pragma. + +## 5.11 PRU Instruction Intrinsics + +Assembly instructions can be generated using intrinsics. + +Table 5-3 shows the calling syntax for intrinsics that perform register transfers. In these intrinsics, the following parameters are used: + +- *device\_id*: Value from 0-255 that specifies the device ID to transfer data from or to. Common device IDs include: + - 10: Scratch pad bank 0 accessible by both PRU cores. + - 11: Scratch pad bank 1 accessible by both PRU cores. + - 12: Scratch pad bank 2 accessible by both PRU cores. + - 13: Reserved. + - 14: Direct connect mode access to other PRU core. +- *base\_register*: Value from 0-32 that corresponds to the register that must be used as the base register for the transfer. +- *use\_remapping*: Boolean value (zero is false, non-zero is true) that specifies whether a register file shift amount is used to move the registers to the appropriate base register. An example of this is the bank shift supported for the scratchpad memory on ICSS. +- *object*: Any object with a size less than 44 bytes. + +**Table 5-3. PRU Compiler Intrinsics for Register Transfers** + +| C/C++ Compiler Intrinsic | Assembly
Instruction | Description | +|---------------------------------------------------------------------------------------------------------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| voidxin ( unsigned int device_id ,
unsigned int base_register , unsigned int
use_remapping , void& object ); | XFR | Read in register values from the device specified by device_id
using the XFR wide transfer bus. For each device_id, specific
registers are tied to the bus. If use_remapping is false, the
intrinsic reads into registers starting at base_register and
continuing for the number of bytes in object. If use_remapping is
true, the compiler puts a shift value in R0.b0, so that the hardware
will shift results to a different register than base_register. A
consequence of this is that when use_remapping is true , the
base_register is not read from. | +| voidxout ( unsigned int device_id ,
unsigned int base_register , unsigned int
use_remapping , void& object ); | XFR | Write out register values using the XFR wide transfer bus. For
each device_id, specific registers are tied to the bus. If
use_remapping is false, the intrinsic writes out registers starting at
base_register and continuing for the number of bytes in object. If
use_remapping is true, the compiler puts a shift value in R0.b0,
so that the hardware willl shift results to a different register than
base_register. A consequence of this is that when use_remapping
is true , the base_register is not written to. | +| voidxchg ( unsigned int device_id ,
unsigned int base_register , unsigned int
use_remapping , void& object ); | XFR | Exchange register values with register values on the device
specified by device_id using the XFR wide transfer bus. For each
device_id, specific registers are tied to the bus. If use_remapping
is false, the intrinsic writes out registers starting at base_register
and continuing for the number of bytes in object. If
use_remapping is true, the compiler puts a shift value in R0.b0,
so that the hardware willl shift results to a different register than
base_register. A consequence of this is that when use_remapping
is true , the base_register is not accessed. | +| voidsxin ( unsigned int device_id ,
unsigned int base_register , unsigned int
use_remapping , void& object ); | XFR | Performs the same action asxin, but also transfers the core
status, which includes the instruction pointer, the carry/borrow bit,
and other information. | +| voidsxout( unsigned int device_id ,
unsigned int base_register , unsigned int
use_remapping , void& object ); | XFR | Performs the same action asxout, but also transfers the core
status, which includes the instruction pointer, the carry/borrow bit,
and other information. | +| voidsxchg( unsigned int device_id ,
unsigned int base_register , unsigned int
use_remapping , void& object ); | XFR | Performs the same action asxchg, but also transfers the core
status, which includes the instruction pointer, the carry/borrow bit,
and other information. | + +Table 5-4 shows the calling syntax for additional intrinsics that can be used to generate assembly instructions. + +**Table 5-4. Additional PRU Compiler Intrinsics** + +| C/C++ Compiler Intrinsic | Assembly
Instruction(s) | Description | +|--------------------------------------------------------------------------|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| unsigned int locationlmbd( unsigned
int src , unsigned int pattern ); | LMBD location , src , pattern | Scans src for the bit pattern in position 0 of pattern and returns
the first position where it is found. This intrinsic scans only for the
value in the last bit (bit 0) of the pattern. | +| voidhalt(); | HALT | This intrinsic disables the PRU. It can be used to implement
software breakpoints for debugging. The PRU program counter
remains at its current location (the location of the HALT). When
the PRU is re-enabled, the instruction is re-fetched from
instruction memory. | +| voiddelay_cycles( unsigned int
cycles ); | varies | Delays PRU execution for the specified number of cycles. The
number of cycles must be a constant. | + +## 5.12 Object File Symbol Naming Conventions (Linknames) + +Each externally visible identifier is assigned a unique symbol name to be used in the object file, a socalled *linkname*. This name is assigned by the compiler according to an algorithm which depends on the name, type, and source language of the symbol. This algorithm may add a prefix to the identifier (typically an underscore), and it may *mangle* the name. + +User-defined symbols in C code and in assembly code are in the same namespace, which means you are responsible for making sure that your C identifiers do not collide with your assembly code identifiers. You may have identifiers that collide with assembly keywords (for instance, register names); in this case, the compiler automatically uses an escape sequence to prevent the collision. The compiler escapes the identifier with double parallel bars, which instructs the assembler not to treat the identifier as a keyword. You are responsible for making sure that C identifiers do not collide with user-defined assembly code identifiers. + +Name mangling encodes the types of the parameters of a function in the linkname for a function. Name mangling only occurs for C++ functions which are not declared 'extern "C"'. Mangling allows function overloading, operator overloading, and type-safe linking. Be aware that the return value of the function is not encoded in the mangled name, as C++ functions cannot be overloaded based on the return value. + +For example, the general form of a C++ linkname for a function named func is: + +``` +__func__F parmcodes +``` + +Where parmcodes is a sequence of letters that encodes the parameter types of func. + +For this simple C++ source file: + +``` +int foo(int i){ } //global C++ function +``` + +This is the resulting assembly code: + +``` +$__foo__Fi +``` + +The linkname of foo is \$\_\_foo\_\_Fi, indicating that foo is a function that takes a single argument of type int. To aid inspection and debugging, a name demangling utility is provided that demangles names into those found in the original C++ source. See Chapter 8 for more information. + +The mangling algorithm follows that described in the Itanium C++ ABI [\(http://www.codesourcery.com/cxx](http://www.codesourcery.com/cxx-abi/abi.html)[abi/abi.html](http://www.codesourcery.com/cxx-abi/abi.html)). + +``` +int foo(int i) { } would be mangled "_Z3fooi" +``` + +## 5.13 Changing the ANSI/ISO C/C++ Language Mode + +The language mode command-line options determine how the compiler interprets your source code. You specify one option to identify which language standard your code follows. You can also specify a separate option to specify how strictly the compiler should expect your code to conform to the standard. + +Specify one of the following language options to control the language standard that the compiler expects the source to follow. The options are: + +- ANSI/ISO C89 (--c89, default for C files) +- ANSI/ISO C99 (--c99, see Section 5.13.1.) +- ISO C++03 (--c++03, used for all C++ files) + +Use one of the following options to specify how strictly the code conforms to the standard: + +- Relaxed ANSI/ISO (--relaxed\_ansi or -pr) This is the default. +- Strict ANSI/ISO (--strict\_ansi or -ps) + +The default is relaxed ANSI/ISO mode. Under relaxed ANSI/ISO mode, the compiler accepts language extensions that could potentially conflict with ANSI/ISO C/C++. Under strict ANSI mode, these language extensions are suppressed so that the compiler will accept all strictly conforming programs. (See Section 5.13.2.) + +### 5.13.1 C99 Support (--c99) + +The compiler supports the 1999 standard of C as standardized by the ISO. However, the following list of run-time functions and features are *not* implemented or fully supported: + +- complex.h +- ctype.h + - isblank() +- fenv.h +- float.h + - DECIMAL\_DIG + - FLT\_EVAL\_METHOD +- inttypes.h + - wcstoimax() / wcstoumax() +- math.h + - FP\_ILOGB0 / FP\_ILOGBNAN macros + - MATH\_ERRNO macro + - copysign() + - float\_t / double\_t types + - math\_errhandling() + - signbit() + - The following sets of C99 functions do not support the "long double" type. C89 math functions using float and long double types are supported. (Section numbers are from the C99 standard.) + - 7.12.4: Trigonometric functions + - 7.12.5: Hyperbolic functions + - 7.12.6: Exponential and logarithmic functions + - 7.12.7: Power and absolute value functions + - 7.12.9: Nearest integer functions + - 7.12.10: Remainder functions + - expm1() + - ilogb() / log1p() / logb() + - scalbn() / scalbln() + +- cbrt() +- hypot() +- erf() / erfc() +- lgamma() / tgamma() +- nearbyint() +- rint() / lrint() / llrint() +- lround() / llround() +- remainder() / remquo() +- nan() +- nextafter() / nexttoward() +- fdim() / fmax() / fmin() / fma() +- isgreater() / isgreaterequal() / isless() / islessequal() / islessgreater() / isunordered() +- stdarg.h + - va\_copy macro +- stdio.h + - %a and %A format specifiers for hexadecimal float + - The %e specifier may produce "-0" when "0" is expected by the standard + - snprintf() does not properly pad with spaces when writing to a wide character array +- stdlib.h + - strtof() atof() / strtod() / strtold() do not support hexadecimal float strings + - vfscanf() / vscanf() / vsscanf() return value on floating point matching failure is incorrect +- tgmath.h +- time.h + - strftime() +- wchar.h + - getws() / fputws() + - mbrlen() + - mbsrtowcs() + - wcscat() + - wcschr() + - wcscmp() / wcsncmp() + - wcscpy() / wcsncpy() + - wcsftime() + - wcsrtombs() + - wcsstr() + - wcstok() + - wcsxfrm() + - Wide character print / scan functions + - Wide character conversion functions + +### 5.13.2 Strict ANSI Mode and Relaxed ANSI Mode (--strict\_ansi and --relaxed\_ansi) + +Under relaxed ANSI/ISO mode (the default), the compiler accepts language extensions that could potentially conflict with a strictly conforming ANSI/ISO C/C++ program. Under strict ANSI mode, these language extensions are suppressed so that the compiler will accept all strictly conforming programs. + +Use the --strict\_ansi option when you know your program is a conforming program and it will not compile in relaxed mode. In this mode, language extensions that conflict with ANSI/ISO C/C++ are disabled and the compiler will emit error messages where the standard requires it to do so. Violations that are considered discretionary by the standard may be emitted as warnings instead. + +# Examples: + +The following is strictly conforming C code, but will not be accepted by the compiler in the default relaxed mode. To get the compiler to accept this code, use strict ANSI mode. The compiler will suppress the far keyword language exception, and far may then be used as an identifier in the code. + +``` +int main() +{ + int far = 0; + return 0; +} +``` + +The default mode is relaxed ANSI. This mode can be selected with the --relaxed\_ansi (or -pr) option. Relaxed ANSI mode accepts the broadest range of programs. It accepts all TI language extensions, even those which conflict with ANSI/ISO, and ignores some ANSI/ISO violations for which the compiler can do something reasonable. Some GCC language extensions described in Section 5.14 may conflict with strict ANSI/ISO standards, but many do not conflict with the standards. + +## 5.14 GNU Language Extensions + +The GNU compiler collection (GCC) defines a number of language features not found in the ANSI/ISO C and C++ standards. The definition and examples of these extensions (for GCC version 4.7) can be found at the GNU web site, . Most of these extensions are also available for C++ source code. + +The compiler also supports the following Clang macro extensions, which are described in the [Clang](https://clang.llvm.org/docs/LanguageExtensions.html) 6 [Documentation](https://clang.llvm.org/docs/LanguageExtensions.html): + +- \_\_has\_feature (up to tests described for Clang 3.5) +- \_\_has\_extension (up to tests described for Clang 3.5) +- \_\_has\_include +- \_\_has\_include\_next +- \_\_has\_builtin (see Section 5.14.5) +- \_\_has\_attribute + +### 5.14.1 Extensions + +Most of the GCC language extensions are available in the TI compiler when compiling in relaxed ANSI mode (--relaxed\_ansi). + +The extensions that the TI compiler supports are listed in Table 5-5, which is based on the list of extensions found at the GNU web site. The shaded rows describe extensions that are not supported. + +**Table 5-5. GCC Language Extensions** + +| Extensions | Descriptions | +|-------------------------|--------------------------------------------------------------------------------------------------| +| Statement expressions | Putting statements and declarations inside expressions (useful for creating smart 'safe' macros) | +| Local labels | Labels local to a statement expression | +| Labels as values | Pointers to labels and computed gotos | +| Nested functions | As in Algol and Pascal, lexical scoping of functions | +| Constructing calls | Dispatching a call to another function | +| Naming types(1) | Giving a name to the type of an expression | +| typeof operator | typeof referring to the type of an expression | +| Generalized lvalues | Using question mark (?) and comma (,) and casts in lvalues | +| Conditionals | Omitting the middle operand of a ?: expression | +| long long | Double long word integers and long long int type | +| Hex floats | Hexadecimal floating-point constants | +| Complex | Data types for complex numbers | +| Zero length | Zero-length arrays | +| Variadic macros | Macros with a variable number of arguments | +| Variable length | Arrays whose length is computed at run time | +| Empty structures | Structures with no members | +| Subscripting | Any array can be subscripted, even if it is not an lvalue. | +| Escaped newlines | Slightly looser rules for escaped newlines | +| Multi-line strings(1) | String literals with embedded newlines | +| Pointer arithmetic | Arithmetic on void pointers and function pointers | +| Initializers | Non-constant initializers | +| Compound literals | Compound literals give structures, unions, or arrays as values | +| Designated initializers | Labeling elements of initializers | +| Cast to union | Casting to union type from any member of the union | +| Case ranges | 'Case 1 9' and such | +| Mixed declarations | Mixing declarations and code | + +(1) Feature defined for GCC 3.0; definition and examples at [http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/C-Extensions.html#C-](http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/C-Extensions.html#C-Extensions)[Extensions](http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/C-Extensions.html#C-Extensions) + +**Table 5-5. GCC Language Extensions (continued)** + +| Extensions | Descriptions | +|-----------------------|-----------------------------------------------------------------------------------------| +| Function attributes | Declaring that functions have no side effects, or that they can never return | +| Attribute syntax | Formal syntax for attributes | +| Function prototypes | Prototype declarations and old-style definitions | +| C++ comments | C++ comments are recognized. | +| Dollar signs | A dollar sign is allowed in identifiers. | +| Character escapes | The character ESC is represented as \e | +| Variable attributes | Specifying the attributes of variables | +| Type attributes | Specifying the attributes of types | +| Alignment | Inquiring about the alignment of a type or variable | +| Inline | Defining inline functions (as fast as macros) | +| Assembly labels | Specifying the assembler name to use for a C symbol | +| Extended asm | Assembler instructions with C operands | +| Constraints | Constraints for asm operands | +| Wrapper headers | Wrapper header files can include another version of the header file using #include_next | +| Alternate keywords | Header files can useconst,asm, etc | +| Explicit reg vars | Defining variables residing in specified registers | +| Incomplete enum types | Define an enum tag without specifying its possible values | +| Function names | Printable strings which are the name of the current function | +| Return address | Getting the return or frame address of a function (limited support) | +| Other built-ins | Other built-in functions (see Section 5.14.5) | +| Vector extensions | Using vector instructions through built-in functions | +| Target built-ins | Built-in functions specific to particular targets | +| Pragmas | Pragmas accepted by GCC | +| Unnamed fields | Unnamed struct/union fields within structs/unions | +| Thread-local | Per-thread variables | +| Binary constants | Binary constants using the '0b' prefix. | + +### 5.14.2 Function Attributes + +The following GCC function attributes are supported: + +- alias +- always\_inline +- const +- constructor +- deprecated +- format +- format\_arg +- interrupt +- malloc +- noinline +- noreturn +- pure +- section +- unused +- used +- visibility + +• warn\_unused\_result + +The following additional TI-specific function attribute is supported: + +• retain + +For example, this function declaration uses the **alias** attribute to make "my\_alias" a function alias for the "myFunc" function: + +``` +void my_alias() __attribute__((alias("myFunc"))); +``` + +The **format** attribute is applied to the declarations of printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf, scanf, fscanf, vfscanf, vscanf, vsscanf, and sscanf in stdio.h. Thus when GCC extensions are enabled, the data arguments of these functions are type checked against the format specifiers in the format string argument and warnings are issued when there is a mismatch. These warnings can be suppressed in the usual ways if they are not desired. + +The **malloc** attribute is applied to the declarations of malloc, calloc, realloc and memalign in stdlib.h. + +The **retain** attribute has the same effect as the RETAIN pragma (Section 5.9.19). That is, the section that contains the function will not be omitted from conditionally linked output even if it is not referenced elsewhere in the application. + +### 5.14.3 Variable Attributes + +The following variable attributes are supported: + +- aligned +- deprecated +- mode +- noinit +- persistent +- retain +- section +- transparent\_union +- unused +- used +- weak + +The **retain** attribute has the same effect as the RETAIN pragma (Section 5.9.19). That is, the section that contains the variable will not be omitted from conditionally linked output even if it is not referenced elsewhere in the application. + +The **used** attribute is defined in GCC 4.2 (see [http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Variable-](http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Variable-Attributes.html#Variable-Attributes)[Attributes.html#Variable-Attributes\)](http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Variable-Attributes.html#Variable-Attributes). + +In addition, the **packed** attribute may be applied to individual fields within a struct or union. + +### 5.14.4 Type Attributes + +The following type attributes are supported: + +- aligned +- cregister +- deprecated +- packed +- transparent\_union +- unused +- visibility + +The **cregister** attribute provides support for using the constant registers. If the cregister attribute is used, the peripheral attribute can be used along with it. The syntax is: + +``` +int x __attribute__((cregister("MEM", [near|far]), peripheral)); +``` + +The name "MEM" can be any name, although it will need to correspond to a memory range name in your linker command file. The near or far parameter tells the compiler whether it can use the immediate addressing mode (near) or register indirect addressing mode (far). If the data will be completely contained within the first 256 bytes from the top of the constant register pointer then use near, otherwise use far. The default is near. + +The linker command file must use the CREGISTER specifier within the MEMORY directive in order for the **cregister** attribute to succeed, otherwise relocation errors occur. See the "MEMORY Directive Syntax" section of the *PRU Assembly Language Tools User's Guide* [\(SPRUHV6](http://www.ti.com/lit/pdf/SPRUHV6)) for details. The linker command file syntax is: + +``` +MEMORY +{ + MEM: origin=xxx length=xxx CREGISTER=4 +} +``` + +The **peripheral** attribute can only be used with the **cregister** attribute and has two effects. First, it puts the object in a section that will not be loaded onto the device. This prevents initialization of the peripheral at runtime. Second, it allows the same object to be defined in multiple source files without a linker error. The intent is that peripherals can be completely described in a header file. + +The **packed** attribute is supported for struct and union types. It is supported if the --relaxed\_ansi option is used. + +Members of a packed structure are stored as closely to each other as possible, omitting additional bytes of padding usually added to preserve word-alignment. For example, assuming a word-size of 4 bytes ordinarily has 3 bytes of padding between members c1 and i, and another 3 bytes of trailing padding after member c2, leading to a total size of 12 bytes: + +``` +struct unpacked_struct { char c1; int i; char c2;}; +``` + +However, the members of a packed struct are byte-aligned. Thus the following does not have any bytes of padding between or after members and totals 6 bytes: + +``` +struct __attribute__((__packed__)) packed_struct { char c1; int i; char c2; }; +``` + +Subsequently, packed structures in an array are packed together without trailing padding between array elements. + +Bit fields of a packed structure are bit-aligned. The byte alignment of adjacent struct members that are not bit fields does not change. However, there are no bits of padding between adjacent bit fields. + +The **packed** attribute can only be applied to the original definition of a structure or union type. It cannot be applied with a typedef to a non-packed structure that has already been defined, nor can it be applied to the declaration of a struct or union object. Therefore, any given structure or union type can only be packed or non-packed, and all objects of that type will inherit its packed or non-packed attribute. + +The packed attribute is not applied recursively to structure types that are contained within a packed structure. Thus, in the following example the member s retains the same internal layout as in the first example above. There is no padding between c and s, so s falls on an unaligned boundary: + +``` +struct __attribute__((__packed__)) outer_packed_struct { char c; struct unpacked_struct s; }; +``` + +It is illegal to implicitly or explicitly cast the address of a packed struct member as a pointer to any nonpacked type except an unsigned char. In the following example, p1, p2, and the call to foo are all illegal. + +``` +void foo(int *param); +struct packed_struct ps; +int *p1 = &ps.i; +int *p2 = (int *)&ps.i; +foo(&ps.i); +``` + +However, it is legal to explicitly cast the address of a packed struct member as a pointer to an unsigned char: + +``` +unsigned char *pc = (unsigned char *)&ps.i; +``` + +Enumerated types are always packed, and the smallest integral type available for the fields in the type is used. + +The TI compiler also supports an **unpacked** attribute for an enumeration type to allow you to indicate that the representation is to be an integer type that is no smaller than int; in other words, it is not *packed*. + +### 5.14.5 Built-In Functions + +The following built-in functions are supported: + +- \_\_builtin\_abs() +- \_\_builtin\_constant\_p() +- \_\_builtin\_expect() +- \_\_builtin\_fabs() +- \_\_builtin\_fabsf() +- \_\_builtin\_frame\_address() +- \_\_builtin\_labs() +- \_\_builtin\_llabs() +- \_\_builtin\_memcpy() +- \_\_builtin\_return\_address() + +The \_\_builtin\_frame\_address function always returns zero. + +The \_\_builtin\_return\_address() function always returns zero. + +## 5.15 Compiler Limits + +Due to the variety of host systems supported by the C/C++ compiler and the limitations of some of these systems, the compiler may not be able to successfully compile source files that are excessively large or complex. In general, exceeding such a system limit prevents continued compilation, so the compiler aborts immediately after printing the error message. Simplify the program to avoid exceeding a system limit. + +Some systems do not allow filenames longer than 500 characters. Make sure your filenames are shorter than 500. + +The compiler has no arbitrary limits but is limited by the amount of memory available on the host system. On smaller host systems such as PCs, the optimizer may run out of memory. If this occurs, the optimizer terminates and the shell continues compiling the file with the code generator. This results in a file compiled with no optimization. The optimizer compiles one function at a time, so the most likely cause of this is a large or extremely complex function in your source module. To correct the problem, your options are: + +- Don't optimize the module in question. +- Identify the function that caused the problem and break it down into smaller functions. +- Extract the function from the module and place it in a separate module that can be compiled without optimization so that the remaining functions can be optimized. + +# Run-Time Environment + +This chapter describes the PRU C/C++ run-time environment. To ensure successful execution of C/C++ programs, it is critical that all run-time code maintain this environment. It is also important to follow the guidelines in this chapter if you write assembly language functions that interface with C/C++ code. + +**Topic** ........................................................................................................................... **Page** + +| 6.1 | Memory Model | 104 | +|-----|----------------------------------------------|-----| +| 6.2 | Object Representation | 107 | +| 6.3 | Register Conventions | 110 | +| 6.4 | Function Structure and Calling Conventions | 111 | +| 6.5 | Accessing Linker Symbols in C and C++ | 115 | +| 6.6 | Interfacing C and C++ With Assembly Language | 115 | +| 6.7 | System Initialization | 118 | +| | | | + +## 6.1 Memory Model + +The PRU compiler treats memory as a single linear block that is partitioned into subblocks of code and data. Each subblock of code or data generated by a C program is placed in its own continuous memory space. The compiler assumes that a full 32-bit address space is available in target memory. + +#### The Linker Defines the Memory Map + +**NOTE:** The linker, not the compiler, defines the memory map and allocates code and data into target memory. The compiler assumes nothing about the types of memory available, about any locations not available for code or data (holes), or about any locations reserved for I/O or control purposes. The compiler produces relocatable code that allows the linker to allocate code and data into the appropriate memory spaces. For example, you can use the linker to allocate global variables into on-chip RAM or to allocate executable code into external ROM. You can allocate each block of code or data individually into memory, but this is not a general practice (an exception to this is memory-mapped I/O, although you can access physical memory locations with C/C++ pointer types). + +### 6.1.1 Sections + +The compiler produces relocatable blocks of code and data called *sections*. The sections are allocated into memory in a variety of ways to conform to a variety of system configurations. For more information about sections and allocating them, see the introductory object file information in the *PRU Assembly Language Tools User's Guide*. + +There are two basic types of sections: + +- **Initialized sections** contain data or executable code. Initialized sections are usually, but not always, read-only. The C/C++ compiler creates the following initialized sections: + - The **.args section** contains arguments in the argv array to be passed to main. This section is readonly. + - The **.binit section** contains boot time copy tables. This is a read-only section. For details on BINIT, see the *PRU Assembly Language Tools User's Guide*. + - The **.cinit section** contains tables for initializing global data at runtime. + - The **.ovly section** contains copy tables other than boot time (.binit) copy tables. This is a read-only section. + - The **.data section** contains initialized near data. + - The **.fardata section** contains initialized far data. + - The **.init\_array section** contains global constructor tables to be called at startup. + - The **.rodata section** contains constant read-only near data. + - The **.rofardata section** contains constant read-only far data. + - The **.text section** contains all the executable code. This section is usually read-only. + - The **.TI.crctab section** contains CRC checking tables. This is a read-only section. +- **Uninitialized sections** reserve space in memory (usually RAM). A program can use this space at run time to create and store variables. The compiler creates the following uninitialized sections: + - The **.bss section** reserves space for uninitialized near data (stored at addresses reachable with a 16-bit address). + - The **.farbss section** reserves space for uninitialized far data (stored at addresses only reachable with a 32-bit address). + - The **.stack section** reserves memory for the C/C++ software stack. + - The **.sysmem section** reserves space for dynamic memory allocation. The reserved space is used by dynamic memory allocation routines, such as malloc(), calloc(), realloc(), or new(). If a C/C++ program does not use these functions, the compiler does not create the .sysmem section. + +The assembler creates the default sections .text, .bss, and .data. You can instruct the compiler to create additional sections by using the CODE\_SECTION and DATA\_SECTION pragmas (see Section 5.9.3 and Section 5.9.5). + +The linker takes the individual sections from different object files and combines sections that have the same name. The resulting output sections and the appropriate placement in memory for each section are listed in Table 6-1. You can place these output sections anywhere in the address space as needed to meet system requirements. + +| Section | Type of Memory | Section | Type of Memory | | +|----------|----------------|-------------|----------------|--| +| .args | ROM or RAM | .init_array | ROM or RAM | | +| .bss | RAM | .rodata | ROM or RAM | | +| .cinit | ROM or RAM | .rofardata | ROM or RAM | | +| .data | RAM | .stack | RAM | | +| .farbss | RAM | .sysmem | RAM | | +| .fardata | ROM or RAM | .text | ROM or RAM | | + +**Table 6-1. Summary of Sections and Memory Placement** + +You can use the SECTIONS directive in the linker command file to customize the section-allocation process. For more information about allocating sections into memory, see the linker description chapter in the *PRU Assembly Language Tools User's Guide*. + +### 6.1.2 C/C++ System Stack + +The C/C++ compiler uses a stack to: + +- Allocate local variables +- Pass arguments to functions +- Save register contents + +The run-time stack grows from the high addresses to the low addresses. The compiler uses the R2 register to manage this stack. R2 is the *stack pointer* (SP), which points to the next unused location on the stack. + +The linker sets the stack size, creates a global symbol, \_\_STACK\_SIZE, and assigns it a value equal to the stack size in bytes. The default stack size is 256 bytes. You can change the stack size at link time by using the --stack\_size option with the linker command. For more information on the --stack\_size option, see the linker description chapter in the *PRU Assembly Language Tools User's Guide*. + +At system initialization, SP is set to a designated address for the top of the stack. This address is the first location past the end of the .stack section. Since the position of the stack depends on where the .stack section is allocated, the actual address of the stack is determined at link time. + +The C/C++ environment automatically decrements SP at the entry to a function to reserve all the space necessary for the execution of that function. The stack pointer is incremented at the exit of the function to restore the stack to the state before the function was entered. If you interface assembly language routines to C/C++ programs, be sure to restore the stack pointer to the same state it was in before the function was entered. + +For more information about using the stack pointer, see Section 6.3; for more information about the stack, see Section 6.4. + +#### Stack Overflow + +**NOTE:** The compiler provides no means to check for stack overflow during compilation or at run time. A stack overflow disrupts the run-time environment, causing your program to fail. Be sure to allow enough space for the stack to grow. You can use the --entry\_hook option to add code to the beginning of each function to check for stack overflow; see Section 2.13. + +### 6.1.3 Dynamic Memory Allocation + +The run-time-support library supplied with the PRU compiler contains several functions (such as malloc, calloc, and realloc) that allow you to allocate memory dynamically for variables at run time. + +Memory is allocated from a global pool, or heap, that is defined in the .sysmem section. You can set the size of the .sysmem section by using the --heap\_size=*size* option with the linker command. The linker also creates a global symbol, \_\_SYSMEM\_SIZE, and assigns it a value equal to the size of the heap in bytes. The default size is 256 bytes. For more information on the --heap\_size option, see the linker description chapter in the *PRU Assembly Language Tools User's Guide*. + +If you use any C I/O function, the RTS library allocates an I/O buffer for each file you access. This buffer will be a bit larger than BUFSIZ, which is defined in stdio.h and defaults to 256. Make sure you allocate a heap large enough for these buffers or use setvbuf to change the buffer to a statically-allocated buffer. + +Dynamically allocated objects are not addressed directly (they are always accessed with pointers) and the memory pool is in a separate section (.sysmem); therefore, the dynamic memory pool can have a size limited only by the amount of available memory in your system. To conserve space in the .bss section, you can allocate large arrays from the heap instead of defining them as global or static. For example, instead of a definition such as: + +``` +struct big table[100]; +``` + +Use a pointer and call the malloc function: + +``` +struct big *table +table = (struct big *)malloc(100*sizeof(struct big)); +``` + +When allocating from a heap, make sure the size of the heap is large enough for the allocation. This is particularly important when allocating variable-length arrays. + +## 6.2 Object Representation + +For general information about data types, see Section 5.4. This section explains how various data objects are sized, aligned, and accessed. + +### 6.2.1 Data Type Storage + +Table 6-2 lists register and memory storage for various data types: + +**Table 6-2. Data Representation in Registers and Memory** + +| Data Type | Register Storage | Memory Storage | +|-------------------------|----------------------------------------------------------|------------------------------------------------------------------------------------------------------| +| char, signed char | Bits 0-7 or 8-15 or 16-23 or 24-31 of register | 8 bits aligned to 8-bit boundary | +| unsigned char, bool | Bits 0-7 or 8-15 or 16-23 or 24-31 of register | 8 bits aligned to 8-bit boundary | +| short, signed short | Bits 0-15 or 8-23 or 16-31 of register | 16 bits aligned to 8-bit boundary | +| unsigned short, wchar_t | Bits 0-15 or 8-23 or 16-31 of register | 16 bits aligned to 8-bit boundary | +| int, signed int | Bits 0-15 or 8-23 or 16-31 of register | 32 bits aligned to 8-bit boundary | +| unsigned int | Bits 0-15 or 8-23 or 16-31 of register | 32 bits aligned to 8-bit boundary | +| enum | Bits 0-15 or 8-23 or 16-31 of register | 32 bits aligned to 8-bit boundary | +| long, signed long | Bits 0-15 or 8-23 or 16-31 of register | 32 bits aligned to 8-bit boundary | +| unsigned long | Bits 0-15 or 8-23 or 16-31 of register | 32 bits aligned to 8-bit boundary | +| long long | Register pair | 64 bits aligned to 8-bit boundary | +| unsigned long long | Register pair | 64 bits aligned to 8-bit boundary | +| float | Bits 0-15 or 8-23 or 16-31 of register | 32 bits aligned to 8-bit boundary | +| double | Register pair | 64 bits aligned to 8-bit boundary | +| long double | Register pair | 64 bits aligned to 8-bit boundary | +| struct | Members are stored as their individual types
require. | Members are stored as their individual types
require. All types are aligned to an 8-bit boundary. | +| array | Members are stored as their individual types
require. | Members are stored as their individual types
require. All types are aligned to an 8-bit boundary. | +| pointer to data | Bits 0-31 of register | 32 bits aligned to 8-bit boundary | +| pointer to code | Bits 0-15 of register | 64 bits aligned to 8-bit boundary | + +For signed char and signed short types, negative values are not sign-extended. For larger signed types, negative values are sign-extended to bit 31. + +For enum storage information, see Table 5-2. + +### 6.2.2 Bit Fields + +Bit fields are the only objects that are packed within a byte. That is, two bit fields can be stored in the same byte. Bit fields can range in size from 1 to 32 bits, but they never span a 4-byte boundary. + +For little-endian mode (the default), bit fields are packed into registers from the LSB to the MSB in the order in which they are defined, and packed in memory from LSbyte to MSbyte. + +For big-endian mode, bit fields are packed into registers from most significant bit (MSB) to least significant bit (LSB) in the order in which they are defined. Bit fields are packed in memory from most significant byte (MSbyte) to least significant byte (LSbyte). + +• Plain int bit fields are unsigned. Consider the following C code: + +``` +struct st +{ + int a:5; +} S; +foo() +{ + if (S.a < 0) + bar(); +} +``` + +The bar() function is never called as bit field 'a' is unsigned. Use signed int if you need a signed bit field. + +- Bit fields are handled using the declared type, . +- Bit fields of type long long are supported. +- As is true for all other PRU types, bit fields are aligned on single-byte intervals. +- The size of a struct containing the bit field depends on the declared type of the bit field. For example, both of these structs have a size of 4 bytes: + +``` +struct st {int a:4}; +struct st {char a:4; int :22;}; +``` + +• Bit fields declared volatile are accessed according to the bit field's declared type. A volatile bit field reference generates exactly one reference to its storage; multiple volatile bit field accesses are not merged. + +Figure 6-1 illustrates bit-field packing, using the following bit field definitions: + +``` +struct{ + int A:7 + int B:10 + int C:3 + int D:2 + int E:9 +}x; +``` + +A0 represents the least significant bit of the field A; A1 represents the next least significant bit, etc. Again, storage of bit fields in memory is done with a byte-by-byte, rather than bit-by-bit, transfer. + +| | Figure 6-1. Bit-Field Packing in Big-Endian and Little-Endian Formats | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +|----|-----------------------------------------------------------------------|---|---|------------------------|---|---|---|---|---|---|---|--------|---|---|---|---|---|---|---|--------|---|---|---|---|---|---|---|--------|---|---|----| +| | Big-endian register | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +| MS | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LS | +| A | A | A | A | A | A | A | B | B | B | B | B | B | B | B | B | B | C | C | C | D | D | E | E | E | E | E | E | E | E | E | X | +| 6 | 5 | 4 | 3 | 2 | 1 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 2 | 1 | 0 | 1 | 0 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | X | +| 31 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | +| | Big-endian memory | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +| | | | | Byte 0 | | | | | | | | Byte 1 | | | | | | | | Byte 2 | | | | | | | | Byte 3 | | | | +| A | A | A | A | A | A | A | B | B | B | B | B | B | B | B | B | B | C | C | C | D | D | E | E | E | E | E | E | E | E | E | X | +| 6 | 5 | 4 | 3 | 2 | 1 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 2 | 1 | 0 | 1 | 0 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | X | +| | | | | Little-endian register | | | | | | | | | | | | | | | | | | | | | | | | | | | | +| MS | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LS | +| X | E | E | E | E | E | E | E | E | E | D | D | C | C | C | B | B | B | B | B | B | B | B | B | B | A | A | A | A | A | A | A | +| X | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 1 | 0 | 2 | 1 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +| 31 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | +| | Little-endian memory | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +| | Byte 0
Byte 1
Byte 2
Byte 3 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +| B | A | A | A | A | A | A | A | B | B | B | B | B | B | B | B | E | E | D | D | C | C | C | B | X | E | E | E | E | E | E | E | +| 0 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 1 | 0 | 2 | 1 | 0 | 9 | X | 8 | 7 | 6 | 5 | 4 | 3 | 2 | + +LEGEND: X = not used, MS = most significant, LS = least significant + +### 6.2.3 Character String Constants + +In C, a character string constant is used in one of the following ways: + +• To initialize an array of characters. For example: + +``` +char s[] = "abc"; +``` + +When a string is used as an initializer, it is simply treated as an initialized array; each character is a separate initializer. For more information about initialization, see Section 6.7. + +• In an expression. For example: + +``` +strcpy (s, "abc"); +``` + +When a string is used in an expression, the string itself is defined in the .rodata:.string section with the .string assembler directive, along with a unique label that points to the string; the terminating 0 byte is included. For example, the following lines define the string abc, and the terminating 0 byte (the label SL5 points to the string): + +``` +.sect ".rodata:.string" +SL5: .string "abc",0 +``` + +String labels have the form SL*n*, where *n* is a number assigned by the compiler to make the label unique. The number begins at 0 and is increased by 1 for each string defined. All strings used in a source module are defined at the end of the compiled assembly language module. + +The label SL*n* represents the address of the string constant. The compiler uses this label to reference the string expression. + +Because strings are stored in the .rodata:.string section (possibly in ROM) and shared, it is bad practice for a program to modify a string constant. The following code is an example of incorrect string use: + +``` +const char *a = "abc" +a[1] = 'x'; /* Incorrect! undefined behavior */ +``` + +## 6.3 Register Conventions + +Strict conventions associate specific registers with specific operations in the C/C++ environment. If you plan to interface an assembly language routine to a C/C++ program, you must understand and follow these register conventions. + +The register conventions dictate how the compiler uses registers and how values are preserved across function calls. Table 6-3 shows the types of registers affected by these conventions. Table 6-4 summarizes how the compiler uses registers and whether their values are preserved across calls. For information about how values are preserved across calls, see Section 6.4. + +**Table 6-3. How Register Types Are Affected by the Conventions** + +| Register Type | Description | +|---------------------|---------------------------------------------------------------------------------------------------| +| Argument register | Passes arguments during a function call | +| Return register | Holds the return value from a function call | +| Expression register | Holds a value | +| Argument pointer | Used as a base value from which a function's parameters (incoming
arguments) are accessed (AP) | +| Stack pointer | Holds the address of the top of the software stack (SP) | +| Link register | Contains the return address of a function call (LR) | +| Program counter | Contains the current address of code being executed | + +**Table 6-4. Register Usage** + +| Register | Usage | Save on Call | Save on Entry | +|----------|------------------------------------------------------------------------------------|--------------|---------------| +| R0.w0 | Expression register | Yes | | +| R1 | Expression register | Yes | | +| R2 | Stack pointer (SP) | | | +| R3.w0 | Expression register | | | +| R3.w2 | Expression register (usually used as Link register to store the
return address) | | Yes | +| R4 | Argument pointer (AP) | | Yes | +| R5 | Expression register | | Yes | +| R6 | Expression register | | Yes | +| R7 | Expression register | | Yes | +| R8 | Expression register | | Yes | +| R9 | Expression register | | Yes | +| R10 | Expression register | | Yes | +| R11 | Expression register | | Yes | +| R12 | Expression register | | Yes | +| R13 | Expression register | | Yes | +| R14 | Return register | Yes | | +| R15 | Expression register | Yes | | +| R16 | Expression register | Yes | | +| R17 | Expression register | Yes | | +| R18 | Expression register | Yes | | +| R19 | Expression register | Yes | | +| R20 | Expression register | Yes | | +| R21 | Expression register | Yes | | +| R22 | Expression register | Yes | | +| R23 | Expression register | Yes | | +| R24 | Expression register | Yes | | +| R25 | Expression register | Yes | | + +**Table 6-4. Register Usage (continued)** + +| Register | Usage | Save on Call | Save on Entry | +|----------|---------------------|--------------|---------------| +| R26 | Expression register | Yes | | +| R27 | Expression register | Yes | | +| R28 | Expression register | Yes | | +| R29 | Expression register | Yes | | +| R30 | Control register | | | +| R31 | Control register | | | + +## 6.4 Function Structure and Calling Conventions + +The C/C++ compiler imposes a strict set of rules on function calls. Except for special run-time support functions, any function that calls or is called by a C/C++ function must follow these rules. Failure to adhere to these rules can disrupt the C/C++ environment and cause a program to fail. + +The following sections use this terminology to describe the function-calling conventions of the C/C++ compiler: + +- **Argument block**. The part of the local frame used to pass arguments to other functions. Arguments are passed to a function by moving them into the argument block rather than pushing them on the stack. The local frame and argument block are allocated at the same time. +- **Register save area**. The part of the local frame that is used to save the registers when the program calls the function and restore them when the program exits the function. +- **Save-on-call registers**. Registers R0-R1 and R14-R29. The called function does not preserve the values in these registers; therefore, the calling function must save them if their values need to be preserved. +- **Save-on-entry registers**. Registers R3.w2 through R13. It is the called function's responsibility to preserve the values in these registers. If the called function modifies these registers, it saves them when it gains control and preserves them when it returns control to the calling function. + +Figure 6-2 illustrates a typical function call. In this example, arguments are passed to the function, and the function uses local variables and calls another function. Registers F14-R29 are used to pass arguments 1 through 16. If there are additional arguments, the stack is used. This example also shows allocation of a local frame and argument block for the called function. Functions that have no local variables and do not require an argument block do not allocate a local frame. + +**Figure 6-2. Use of the Stack During a Function Call** + +![](_page_111_Figure_3.jpeg) + +### 6.4.1 How a Function Makes a Call + +A function (parent function) performs the following tasks when it calls another function (child function). + +1. The calling function (parent) is responsible for preserving any save-on-call registers across the call that are live across the call. (The save-on-call registers are R0-R1 and R14-R29) +2. If the called function (child) returns a structure, the caller allocates space for the structure and passes the address of that space to the called function as the first argument. +3. The caller places the first arguments in registers R14-R29, in that order. The caller moves the remaining arguments to the argument block in reverse order, placing the leftmost remaining argument at the lowest address. Thus, the leftmost remaining argument is placed at the top of the stack. + +#### 6.4.1.1 Layout of Arguments Passed in Registers + +The argument registers for PRU are R14-R29. PRU supports efficient sub-register accesses of the form Rx.by and Rx.wy. For example, F14.b1 or F14.w2. + +Because of this capability, arguments are packed into registers based on their size. 8-bit scalars are passed using 8-bits of a register and are accessed using Rx.by register operands. 16-bit scalars are passed using 16-bits of a register and are accessed using Rx.wy register operands. 32-bit scalars are passed using a full register. 64-bit scalars are passed in two registers referred to as a register pair. For register pairs, the lowest-numbered register holds the LSW (least significant word). Structures can be passed and returned in registers. Structures of size 8, 16, 24, 32, and 64 bits are passed and returned in registers (see Section 6.4.1.3). + +Arguments are assigned, in declared order, to the first available slot within the argument registers. Holes can be left in the argument registers if 8-bit and 16-bit variables are passed. In this case those holes are filled with subsequent arguments. For example: + +``` +foo(int a1, short a2, int a3, short a4) +``` + +In this example, a1 is assigned to R14, a2 is assigned to R15.w0, a3 is assigned to R16, and a4 is assigned to R15.w2 to fill the hole left by a2. + +#### 6.4.1.2 Stack Layout of Arguments Not Passed in Registers + +Any arguments not passed in registers are placed on the stack at increasing addresses, starting at 0(SP). Each argument is placed at the next available address correctly aligned for its type, subject to the following additional considerations: + +- The stack alignment of a scalar is that of its declared type. +- Each argument reserves an amount of stack space equal to its size rounded up to the next multiple of its stack alignment. + +For a variadic C function (that is, a function declared with an ellipsis indicating that it is called with varying numbers of arguments), the last explicitly declared argument and all remaining arguments are passed on the stack, so that its stack address can act as a reference for accessing the undeclared arguments. Undeclared scalar arguments to a variadic function that are smaller than int are promoted to and passed as int, in accordance with the C language. Alignment "holes" can occur between arguments passed on the stack, but "back-fill" does not occur. + +#### 6.4.1.3 Layout of Structures or Unions Passed and Returned by Reference + +Structures (including classes) and unions larger than 64 bits are passed and returned by reference. To pass a structure or union by reference, the caller places its address in the appropriate location: either in a register or on the stack, according to its position in the argument list. To preserve pass-by-value semantics (required for C and C++), the callee may need to make its own copy of the pointed-to object. In some cases, the callee need not make a copy, such as if the callee is a leaf and it does not modify the pointed-to object. + +If the called function returns a structure or union larger than 64 bits, the caller must pass an additional argument containing a destination address for the returned value, or NULL if the returned value is not used. + +This additional argument is passed in the first argument register as an implicit first argument. The callee returns the object by copying it to the given address. The caller is responsible for allocating memory if required. Typically this involves reserving space on the stack, but in some cases the address of an already-existing object can be passed and no allocation is required. For example, if f returns a structure, the assignment s = f() can be compiled by passing &s in the first argument register. + +### 6.4.2 How a Called Function Responds + +A called function (child function) must perform the following tasks: + +1. If the function is declared with an ellipsis, it can be called with a variable number of arguments. The called function pushes these arguments on the stack if they meet both of these criteria: + - The argument includes or follows the last explicitly declared argument. + - The argument is passed in a register. +2. The called function pushes register values of all the registers that are modified by the function and that must be preserved upon exit of the function onto the stack. Normally, these registers are the save-on-entry registers--R3.w2 through R13--if the function contains calls. +3. The called function allocates memory for the local variables and argument block by subtracting a constant from the SP. This constant is computed with the following formula: + +``` +size of all local variables + max = constant +``` + +The *max* argument specifies the size of all parameters placed in the argument block for each call. + +4. The called function executes the code for the function. +5. If the called function returns a value, it places the value in R14. +6. If the called function returns a structure, it copies the structure to the memory block that the first argument, R14, points to. If the caller does not use the return value, R14 is set to 0. This directs the called function not to copy the return structure. + +In this way, the caller can be smart about telling the called function where to return the structure. For example, in the statement s = f(x), where s is a structure and f is a function that returns a structure, the caller can simply pass the address of s as the first argument and call f. The function f then copies the return structure directly into s, performing the assignment automatically. + +You must be careful to properly declare functions that return structures, both at the point where they are called (so the caller properly sets up the first argument) and at the point where they are declared (so the function knows to copy the result). + +7. The called function deallocates the frame and argument block by adding the constant computed in Step 3. +8. The called function restores all registers that were saved in Step 2. +9. The called function ( \_f) branches to the return address.. + +The following example is typical of how a called function responds to a call: + +``` +; called function entry point +SUB r2, r2, 0x06 ; allocate frame +SBBO &r3.b2, r2, 0, 6 ; save R3.w2 and R2 +... ; body of the function +LBBO &r3.b2, r2, 0, 6 ; restore R3.w2 and R2 +ADD r2, r2, 0x06 ; deallocate frame +``` + +### 6.4.3 Accessing Arguments and Local Variables + +A function accesses its local nonregister variables indirectly through the stack pointer (SP, which is R2) and its stack arguments indirectly through the argument pointer (AP, which is R4). If all stack arguments can be referenced with the SP, they are, and the AP is not reserved. The SP always points to the top of the stack (points to the most recently pushed value) and the AP points to the leftmost stack argument (the one closest to the top of the stack). For example: + +``` +LBBO &R0, R2, 4, 4 ; load local var from stack +LBBO &R0, R4, 0, 4 ; load argument from stack +``` + +Since the stack grows toward smaller addresses, the local and argument data on the stack for the C/C++ function is accessed with a positive offset from the SP or the AP register. + +## 6.5 Accessing Linker Symbols in C and C++ + +See the section on "Using Linker Symbols in C/C++ Applications" in the *PRU Assembly Language Tools User's Guide* for information about referring to linker symbols in C/C++ code. + +## 6.6 Interfacing C and C++ With Assembly Language + +The following are ways to use assembly language with C/C++ code: + +- Use separate modules of assembled code and link them with compiled C/C++ modules (see Section 6.6.1). +- Use assembly language variables and constants in C/C++ source (see Section 6.6.3). +- Use inline assembly language embedded directly in the C/C++ source (see Section 6.6.5). +- Modify the assembly language code that the compiler produces (see Section 6.6.6). + +### 6.6.1 Using Assembly Language Modules With C/C++ Code + +Interfacing C/C++ with assembly language functions is straightforward if you follow the calling conventions defined in Section 6.4, and the register conventions defined in Section 6.3. C/C++ code can access variables and call functions defined in assembly language, and assembly code can access C/C++ variables and call C/C++ functions. + +Follow these guidelines to interface assembly language and C: + +- You must preserve any dedicated registers modified by a function. Dedicated registers include: + - Save-on-entry registers (R3.w2-R13) + - Stack pointer (R2) + +If the SP is used normally, it does not need to be explicitly preserved. In other words, the assembly function is free to use the stack as long as anything that is pushed onto the stack is popped back off before the function returns (thus preserving SP). + +Any register that is not dedicated can be used freely without first being saved. + +- When you call a C/C++ function from assembly language, load the designated registers with arguments and push the remaining arguments onto the stack as described in Section 6.4.1. + - Remember that a function can alter any register not designated as being preserved without having to restore it. If the contents of any of these registers must be preserved across the call, you must explicitly save them. +- Functions must return values correctly according to their C/C++ declarations. Every value is returned starting with R14. 64-bit types are returned in R14-R15, and structures are returned as described in Step 2 of Section 6.4.1. +- No assembly module should use the .cinit section for any purpose other than autoinitialization of global variables. The C/C++ startup routine assumes that the .cinit section consists *entirely* of initialization tables. Disrupting the tables by putting other information in .cinit can cause unpredictable results. +- The compiler assigns linknames to all external objects. Thus, when you write assembly language code, you must use the same linknames as those assigned by the compiler. See Section 5.12 for details. +- Any object or function declared in assembly language that is accessed or called from C/C++ must be declared with the .def or .global directive in the assembly language modifier. This declares the symbol as external and allows the linker to resolve references to it. + - Likewise, to access a C/C++ function or object from assembly language, declare the C/C++ object with the .ref or .global directive in the assembly language module. This creates an undeclared external reference that the linker resolves. + +### 6.6.2 Accessing Assembly Language Functions From C/C++ + +Functions defined in C++ that will be called from assembly should be defined as extern "C" in the C++ file. Functions defined in assembly that will be called from C++ must be prototyped as extern "C" in C++. + +Example 6-1 illustrates a C++ function called main, which calls an assembly language function called asmfunc, Example 6-2. The asmfunc function takes its single argument, adds it to the C++ global variable called gvar, and returns the result. + +### Example 6-1. Calling an Assembly Language Function From a C/C++ Program + +``` +extern "C" { +extern int asmfunc(int a); /* declare external asm function */ +int gvar = 0; /* define global variable */ +} +void main() +{ + int I = 5; + I = asmfunc(I); /* call function normally */ +``` + +### Example 6-2. Assembly Language Program Called by Example 6-1 + +``` +.global asmfunc + .global gvar +asmfunc: + LDI r0, gvar + LBBO &r1, r0, 0, 4 + ADD r14, r1, r14 + SBBO &r14, r0, 0, 4 + JMP r3.w2 +``` + +In the C++ program in Example 6-1, the extern "C" declaration tells the compiler to use C naming conventions (that is, no name mangling). When the linker resolves the .global asmfunc reference, the corresponding definition in the assembly file will match. + +The parameter i is passed in R0, and the result is returned in R0. R1 holds the address of the global gvar. R2 holds the value of gvar before adding the value i to it. + +### 6.6.3 Accessing Assembly Language Variables From C/C++ + +It is sometimes useful for a C/C++ program to access variables or constants defined in assembly language. There are several methods that you can use to accomplish this, depending on where and how the item is defined: a variable defined in the .bss section, a variable not defined in the .bss section, or a linker symbol. + +#### 6.6.3.1 Accessing Assembly Language Global Variables + +Accessing variables from the .bss section or a section named with .usect is straightforward: + +1. Use the .bss or .usect directive to define the variable. +2. Use the .def or .global directive to make the definition external. +3. Use the appropriate linkname in assembly language. +4. In C/C++, declare the variable as *extern* and access it normally. + +Example 6-4 and Example 6-3 show how you can access a variable defined in .bss. + +### Example 6-3. Assembly Language Variable Program + +``` +.bss var,4,4 ; Define the variable +.global var ; Declare the variable as external +``` + +### Example 6-4. C Program to Access Assembly Language From Example 6-3 + +``` +extern int var; /* External variable */ +var = 1; /* Use the variable */ +``` + +#### 6.6.3.2 Accessing Assembly Language Constants + +You can define global constants in assembly language by using the .set directive in combination with either the .def or .global directive, or you can define them in a linker command file using a linker assignment statement. These constants are accessible from C/C++ only with the use of special operators. + +For **variables** defined in C/C++ or assembly language, the symbol table contains the *address of the value* contained by the variable. When you access an assembly variable by name from C/C++, the compiler gets the value using the address in the symbol table. + +For **assembly constants**, however, the symbol table contains the actual *value* of the constant. The compiler cannot tell which items in the symbol table are addresses and which are values. If you access an assembly (or linker) constant by name, the compiler tries to use the value in the symbol table as an address to fetch a value. To prevent this behavior, you must use the & (address of) operator to get the value (\_symval). In other words, if x is an assembly language constant, its value in C/C++ is &x. See the section on "Using Linker Symbols in C/C++ Applications" in the *PRU Assembly Language Tools User's Guide* for more examples that use \_symval. + +For more about symbols and the symbol table, refer to the section on "Symbols" in the *PRU Assembly Language Tools User's Guide*. + +You can use casts and #defines to ease the use of these symbols in your program, as in Example 6-5 and Example 6-6. + +#### Example 6-5. Accessing an Assembly Language Constant From C + +``` +extern int table_size; /*external ref */ +#define TABLE_SIZE ((int) (&table_size)) + . /* use cast to hide address-of */ + . + . +for (I=0; i 0 and L < 4, copy D to the output buffer L times. Go to step 2. +- c. Else, length is 8-bit value (L). +5. Read the next byte (C); C is the repeat character. +6. Write C to the output buffer L times; go to step 2. +7. End of processing. + +The run-time support library has a routine \_\_TI\_decompress\_rle24() to decompress data compressed using RLE. The first argument to this function is the address pointing to the byte after the 8-bit index. The second argument is the run address from the C auto initialization record. + +#### RLE Decompression Routine + +**NOTE:** The previous decompression routine, \_\_TI\_decompress\_rle(), is included in the run-time-support library for decompressing RLE encodings generated by older versions of the linker. + +#### 6.7.2.4.4 Lempel-Ziv-Storer-Szymanski Compression (LZSS) Format + +| 8-bit index | Initialization data compressed using LZSS | +|-------------|-------------------------------------------| + +The data following the 8-bit index is compressed using LZSS compression. The run-time support library has the routine \_\_TI\_decompress\_lzss() to decompress the data compressed using LZSS. The first argument to this function is the address pointing to the byte after the 8-bit index. The second argument is the run address from the C auto initialization record. + +#### 6.7.2.5 Initialization of Variables at Load Time + +Initialization of variables at load time enhances performance by reducing boot time and by saving the memory used by the initialization tables. To use this method, invoke the linker with the --ram\_model option. + +When you use the --ram\_model link option, the linker does not generate C autoinitialization tables and data. The direct initialized sections (.data) in the compiled object files are combined according to the linker command file to generate initialized output sections. The loader loads the initialized output sections into memory. After the load, the variables are assigned their initial values. + +Since the linker does not generate the C autoinitialization tables, no boot time initialization is performed. + +Figure 6-4 illustrates the initialization of variables at load time. + +![](_page_121_Figure_20.jpeg) + +#### 6.7.2.6 Global Constructors + +All global C++ variables that have constructors must have their constructor called before main(). The compiler builds a table of global constructor addresses that must be called, in order, before main() in a section called .init\_array. The linker combines the .init\_array section form each input file to form a single table in the .init\_array section. The boot routine uses this table to execute the constructors. The linker defines two symbols to identify the combined .init\_array table as shown below. This table is not null terminated by the linker. + +**Figure 6-5. Constructor Table** + +SHT\$\$INIT\_ARRAY\$\$Base: + +![](_page_122_Figure_6.jpeg) + +SHT\$\$INIT\_ARRAY\$\$Limit: + +# Using Run-Time-Support Functions and Building Libraries + +Some of the features of C/C++ (such as I/O, dynamic memory allocation, string operations, and trigonometric functions) are provided as an ANSI/ISO C/C++ standard library, rather than as part of the compiler itself. The TI implementation of this library is the run-time-support library (RTS). The C/C++ compiler implements the ISO standard library except for those facilities that handle exception conditions, signal and locale issues (properties that depend on local language, nationality, or culture). Using the ANSI/ISO standard library ensures a consistent set of functions that provide for greater portability. + +In addition to the ANSI/ISO-specified functions, the run-time-support library includes routines that give you processor-specific commands and direct C language I/O requests. These are detailed in Section 7.1 and Section 7.2. + +A library-build utility is provided with the code generation tools that lets you create customized run-time-support libraries. This process is described in Section 7.4 . + +**Topic** ........................................................................................................................... **Page** + +| 7.1 | C and C++ Run-Time Support Libraries | 125 | +|-----|-------------------------------------------------------------------------|-----| +| 7.2 | The C I/O Functions | 127 | +| 7.3 | Handling Reentrancy (_register_lock() and _register_unlock() Functions) | 139 | +| 7.4 | Library-Build Process | 140 | + +## 7.1 C and C++ Run-Time Support Libraries + +PRU compiler releases include pre-built run-time support (RTS) libraries that provide all the standard capabilities. Separate libraries are provided for big and little endian support for each of PRU silicon versions 1 through 3, and C++ exception support. See Section 7.1.7 for information on the library-naming conventions. + +The run-time-support library contains the following: + +- ANSI/ISO C/C++ standard library +- C I/O library +- Low-level support functions that provide I/O to the host operating system +- Fundamental arithmetic routines +- System startup routine, \_c\_int00 +- Compiler helper functions (to support language features that are not directly efficiently expressible in C/C++) + +The run-time-support libraries do not contain functions involving signals and locale issues. + +The C++ library supports wide chars, in that template functions and classes that are defined for char are also available for wide char. For example, wide char stream classes wios, wiostream, wstreambuf and so on (corresponding to char classes ios, iostream, streambuf) are implemented. However, there is no low-level file I/O for wide chars. Also, the C library interface to wide char support (through the C++ headers and ) is limited as described in Section 5.1. + +TI does not provide documentation that covers the functionality of the C++ library. TI suggests referring to one of the following sources: + +- *The Standard C++ Library: A Tutorial and Reference*,Nicolai M. Josuttis, Addison-Wesley, ISBN 0-201- 37926-0 +- *The C++ Programming Language* (Third or Special Editions), Bjarne Stroustrup, Addison-Wesley, ISBN 0-201-88954-4 or 0-201-70073-5 + +### 7.1.1 Linking Code With the Object Library + +When you link your program, you must specify the object library as one of the linker input files so that references to the I/O and run-time-support functions can be resolved. You can either specify the library or allow the compiler to select one for you. See Section 4.3.1 for further information. + +When a library is linked, the linker includes only those library members required to resolve undefined references. For more information about linking, see the *PRU Assembly Language Tools User's Guide*. + +C, C++, and mixed C and C++ programs can use the same run-time-support library. Run-time-support functions and variables that can be called and referenced from both C and C++ will have the same linkage. + +### 7.1.2 Header Files + +You must use the header files provided with the compiler run-time support when using functions from C/C++ standard library. Set the PRU\_C\_DIR environment variable to the include directory where the tools are installed. + +### 7.1.3 Modifying a Library Function + +You can inspect or modify library functions by examining the source code in the lib/src subdirectory of the compiler installation. For example, C:\ti\ccsv7\tools\compiler\pru\_#.#.#\lib\src. + +One you have located the relevant source code, change the specific function file and rebuild the library. + +You can use this source tree to rebuild the rtspruv3\_le.lib library or to build a new library. See Section 7.4 for details on building. + +### 7.1.4 Support for String Handling + +The library includes the header files and , which provide the following functions for string handling beyond those required. + +- string.h + - strdup(), which duplicates a string +- strings.h + - bcmp(), which is equivalent to memcmp() + - bcopy(), which is equivalent to memmove() + - bzero(), which replaces memory locations with zero-valued bytes + - ffs(), which finds the first bit set and returns the index of that bit + - index(), which is equivalent to strchr() + - rindex(), which is equivalent to strrchr() + - strcasecmp() and strncasecmp(), which perform case-insensitive string comparisons + +### 7.1.5 Minimal Support for Internationalization + +The library includes the header files , , and , which provide APIs to support non-ASCII character sets and conventions. Our implementation of these APIs is limited in the following ways: + +- The library has minimal support for wide and multibyte characters. The type wchar\_t is implemented as int. The wide character set is equivalent to the set of values of type char. The library includes the header files and but does not include all the functions specified in the standard. So-called multibyte characters are limited to single characters. There are no shift states. The mapping between multibyte characters and wide characters is simple equivalence; that is, each wide character maps to and from exactly a single multibyte character having the same value. +- The C library includes the header file but with a minimal implementation. The only supported locale is the C locale. That is, library behavior that is specified to vary by locale is hardcoded to the behavior of the C locale, and attempting to install a different locale via a call to setlocale() will return NULL. + +### 7.1.6 Allowable Number of Open Files + +In the header file, the value for the macro FOPEN\_MAX has the value of the macro \_NFILE, which is set to 10. The impact is that you can only have 10 files simultaneously open at one time (including the pre-defined streams - stdin, stdout, stderr). + +The C standard requires that the minimum value for the FOPEN\_MAX macro is 8. The macro determines the maximum number of files that can be opened at one time. The macro is defined in the stdio.h header file and can be modified by changing the value of the \_NFILE macro and recompiling the library. + +### 7.1.7 Library Naming Conventions + +By default, the linker uses automatic library selection to select the correct run-time-support library (see Section 4.3.1.1) for your application. If you select the library manually, you must select the matching library according to the following naming scheme: + +**rtspru**[v#]\_[endian][\_eh].lib + +rtspru Indicates the library is built for PRU support + +\_v# Indicates the silicon version number of the device for which the library is built + +\_endian "le" indicates library is built for little endian support; "be" indicates library is built for big + +endian support + +\_eh Indicates the library has exception handling support + +## 7.2 The C I/O Functions + +The C I/O functions make it possible to access the host's operating system to perform I/O. The capability to perform I/O on the host gives you more options when debugging and testing code. + +The I/O functions are logically divided into layers: high level, low level, and device-driver level. + +With properly written device drivers, the C-standard high-level I/O functions can be used to perform I/O on custom user-defined devices. This provides an easy way to use the sophisticated buffering of the high-level I/O functions on an arbitrary device. + +The formatting rules for long long data types require ll (lowercase LL) in the format string. For example: + +``` +printf("%lld", 0x0011223344556677); +printf("llx", 0x0011223344556677); +``` + +#### Debugger Required for Default HOST + +**NOTE:** For the default HOST device to work, there must be a debugger to handle the C I/O requests; the default HOST device cannot work by itself in an embedded system. To work in an embedded system, you will need to provide an appropriate driver for your system. + +#### NOTE: C I/O Mysteriously Fails + +If there is not enough space on the heap for a C I/O buffer, operations on the file will silently fail. If a call to printf() mysteriously fails, this may be the reason. The heap needs to be at least large enough to allocate a block of size BUFSIZ (defined in stdio.h) for every file on which I/O is performed, including stdout, stdin, and stderr, plus allocations performed by the user's code, plus allocation bookkeeping overhead. Alternately, declare a char array of size BUFSIZ and pass it to setvbuf to avoid dynamic allocation. To set the heap size, use the --heap\_size option when linking (refer to the *Linker Description* chapter in the *PRU Assembly Language Tools User's Guide*). + +#### NOTE: Open Mysteriously Fails + +The run-time support limits the total number of open files to a small number relative to general-purpose processors. If you attempt to open more files than the maximum, you may find that the open will mysteriously fail. You can increase the number of open files by extracting the source code from rts.src and editing the constants controlling the size of some of the C I/O data structures. The macro \_NFILE controls how many FILE (fopen) objects can be open at one time (stdin, stdout, and stderr count against this total). (See also FOPEN\_MAX.) The macro \_NSTREAM controls how many low-level file descriptors can be open at one time (the low-level files underlying stdin, stdout, and stderr count against this total). The macro \_NDEVICE controls how many device drivers are installed at one time (the HOST device counts against this total). + +### 7.2.1 High-Level I/O Functions + +The high-level functions are the standard C library of stream I/O routines (printf, scanf, fopen, getchar, and so on). These functions call one or more low-level I/O functions to carry out the high-level I/O request. The high-level I/O routines operate on FILE pointers, also called *streams*. + +Portable applications should use only the high-level I/O functions. + +To use the high-level I/O functions: + +- Include the header file stdio.h for each module that references a function. +- Allow for 320 bytes of heap space for each I/O stream used in your program. A stream is a source or destination of data that is associated with a peripheral, such as a terminal or keyboard. Streams are buffered using dynamically allocated memory that is taken from the heap. More heap space may be required to support programs that use additional amounts of dynamically allocated memory (calls to malloc()). To set the heap size, use the --heap\_size option when linking; see Table 2-19. + +For example, given the following C program in a file named main.c: + +``` +#include +void main() +{ + FILE *fid; + fid = fopen("myfile","w"); + fprintf(fid,"Hello, world\n"); + fclose(fid); + printf("Hello again, world\n"); +} +``` + +Issuing the following compiler command compiles, links, and creates the file main.out from the run-time-support library: + +``` +clpru main.c --run_linker --heap_size=400 --library=rtspru_v3_le.lib --output_file=main.out +``` + +Executing main.out results in + +``` +Hello, world +``` + +being output to a file and + +``` +Hello again, world +``` + +being output to your host's stdout window. + +#### 7.2.1.1 Formatting and the Format Conversion Buffer + +The internal routine behind the C I/O functions—such as printf(), vsnprintf(), and snprintf()—reserves stack space for a format conversion buffer. The buffer size is set by the macro FORMAT\_CONVERSION\_BUFFER, which is defined in format.h. Consider the following issues before reducing the size of this buffer: + +- The default buffer size is 510 bytes. If MINIMAL is defined, the size is set to 32, which allows integer values without width specifiers to be printed. +- Each conversion specified with %xxxx (except %s) must fit in FORMAT\_CONVERSION\_BUFSIZE. This means any individual formatted float or integer value, accounting for width and precision specifiers, needs to fit in the buffer. Since the actual value of any representable number should easily fit, the main concern is ensuring the width and/or precision size meets the constraints. +- The length of converted strings using %s are unaffected by any change in FORMAT\_CONVERSION\_BUFSIZE. For example, you can specify printf("%s value is %d", some\_really\_long\_string, intval) without a problem. +- The constraint is for each individual item being converted. For example a format string of %d item1 %f item2 %e item3 does not need to fit in the buffer. Instead, each converted item specified with a % format must fit. +- There is no buffer overrun check. + +### 7.2.2 Overview of Low-Level I/O Implementation + +The low-level functions are comprised of seven basic I/O functions: open, read, write, close, lseek, rename, and unlink. These low-level routines provide the interface between the high-level functions and the device-level drivers that actually perform the I/O command on the specified device. + +The low-level functions are designed to be appropriate for all I/O methods, even those which are not actually disk files. Abstractly, all I/O channels can be treated as files, although some operations (such as lseek) may not be appropriate. See Section 7.2.3 for more details. + +The low-level functions are inspired by, but not identical to, the POSIX functions of the same names. + +The low-level functions operate on file descriptors. A file descriptor is an integer returned by open, representing an opened file. Multiple file descriptors may be associated with a file; each has its own independent file position indicator. + +# **open** *Open File for I/O* + +**Syntax** #include + +**int open (const char \*** *path* **, unsigned** *flags* **, int** *file\_descriptor* **);** + +**Description** The open function opens the file specified by *path* and prepares it for I/O. + +- The *path* is the filename of the file to be opened, including an optional directory path and an optional device specifier (see Section 7.2.5). +- The *flags* are attributes that specify how the file is manipulated. The flags are specified using the following symbols: + +``` +O_RDONLY (0x0000) /* open for reading */ +O_WRONLY (0x0001) /* open for writing */ +O_RDWR (0x0002) /* open for read & write */ +O_APPEND (0x0008) /* append on each write */ +O_CREAT (0x0200) /* open with file create */ +O_TRUNC (0x0400) /* open with truncation */ +O_BINARY (0x8000) /* open in binary mode */ +``` + +Low-level I/O routines allow or disallow some operations depending on the flags used when the file was opened. Some flags may not be meaningful for some devices, depending on how the device implements files. + +• The *file\_descriptor* is assigned by open to an opened file. + +The next available file descriptor is assigned to each new file opened. + +**Return Value** The function returns one of the following values: + +non-negative file descriptor if successful + +-1 on failure + +**close** *Close File for I/O* + +**Syntax** #include + +**int close (int** *file\_descriptor* **);** + +**Description** The close function closes the file associated with *file\_descriptor*. + +The *file\_descriptor* is the number assigned by open to an opened file. + +**Return Value** The return value is one of the following: + +0 if successful -1 on failure + +**read** *Read Characters from a File* + +**Syntax** #include + +**int read (int** *file\_descriptor* **, char \*** *buffer* **, unsigned** *count* **);** + +**Description** The read function reads *count* characters into the *buffer* from the file associated with *file\_descriptor*. + +• The *file\_descriptor* is the number assigned by open to an opened file. + +• The *buffer* is where the read characters are placed. + +• The *count* is the number of characters to read from the file. + +**Return Value** The function returns one of the following values: + +0 if EOF was encountered before any characters were read + +\# number of characters read (may be less than *count*) + +-1 on failure + +**write** *Write Characters to a File* + +**Syntax** #include + +**int write (int** *file\_descriptor* **, const char \*** *buffer* **, unsigned** *count* **);** + +**Description** The write function writes the number of characters specified by *count* from the *buffer* to the file associated with *file\_descriptor*. + +• The *file\_descriptor* is the number assigned by open to an opened file. + +• The *buffer* is where the characters to be written are located. + +• The *count* is the number of characters to write to the file. + +**Return Value** The function returns one of the following values: + +\# number of characters written if successful (may be less than *count*) + +-1 on failure + +# **lseek** *Set File Position Indicator* + +**Syntax for C** #include + +**off\_t lseek (int** *file\_descriptor* **, off\_t** *offset* **, int** *origin* **);** + +**Description** The lseek function sets the file position indicator for the given file to a location relative to the specified origin. The file position indicator measures the position in characters from the beginning of the file. + +- The *file\_descriptor* is the number assigned by open to an opened file. +- The *offset* indicates the relative offset from the *origin* in characters. +- The *origin* is used to indicate which of the base locations the *offset* is measured from. The *origin* must be one of the following macros: + +**SEEK\_SET** (0x0000) Beginning of file + +**SEEK\_CUR** (0x0001) Current value of the file position indicator + +**SEEK\_END** (0x0002) End of file + +**Return Value** The return value is one of the following: + +\# new value of the file position indicator if successful + +(off\_t)-1 on failure + +# **unlink** *Delete File* + +**Syntax** #include + +**int unlink (const char \*** *path* **);** + +**Description** The unlink function deletes the file specified by *path*. Depending on the device, a deleted file may still remain until all file descriptors which have been opened for that file have been closed. See Section 7.2.3. + +> The *path* is the filename of the file, including path information and optional device prefix. (See Section 7.2.5.) + +**Return Value** The function returns one of the following values: + +- 0 if successful +- -1 on failure + +| rename | Rename File | +|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Syntax for C | #include { } | +| | int rename (const char * old_name , const char * new_name ); | +| Syntax for C++ | #include { } | +| | int std::rename (const char * old_name , const char * new_name ); | +| Description | The rename function changes the name of a file. | +| | •
The old_name is the current name of the file. | +| | •
The new_name is the new name for the file. | +| | NOTE:
The optional device specified in the new name must match the device of
the old name. If they do not match, a file copy would be required to
perform the rename, and rename is not capable of this action. | +| Return Value | The function returns one of the following values: | +| | 0
if successful | +| | -1
on failure | +| | NOTE:
Although rename is a low-level function, it is defined by the C standard
and can be used by portable applications. | + +### 7.2.3 Device-Driver Level I/O Functions + +At the next level are the device-level drivers. They map directly to the low-level I/O functions. The default device driver is the HOST device driver, which uses the debugger to perform file operations. The HOST device driver is automatically used for the default C streams stdin, stdout, and stderr. + +The HOST device driver shares a special protocol with the debugger running on a host system so that the host can perform the C I/O requested by the program. Instructions for C I/O operations that the program wants to perform are encoded in a special buffer named \_CIOBUF\_ in the .cio section. The debugger halts the program at a special breakpoint (C\$\$IO\$\$), reads and decodes the target memory, and performs the requested operation. The result is encoded into \_CIOBUF\_, the program is resumed, and the target decodes the result. + +The HOST device is implemented with seven functions, HOSTopen, HOSTclose, HOSTread, HOSTwrite, HOSTlseek, HOSTunlink, and HOSTrename, which perform the encoding. Each function is called from the low-level I/O function with a similar name. + +A device driver is composed of seven required functions. Not all function need to be meaningful for all devices, but all seven must be defined. Here we show the names of all seven functions as starting with DEV, but you may choose any name except for HOST. + +#### **DEV\_open** *Open File for I/O* + +**Syntax int DEV\_open (const char \*** *path* **, unsigned** *flags* **, int** *llv\_fd* **);** + +**Description** This function finds a file matching *path* and opens it for I/O as requested by *flags*. + +- The *path* is the filename of the file to be opened. If the name of a file passed to open has a device prefix, the device prefix will be stripped by open, so DEV\_open will not see it. (See Section 7.2.5 for details on the device prefix.) +- The *flags* are attributes that specify how the file is manipulated. The flags are specified using the following symbols: + +``` +O_RDONLY (0x0000) /* open for reading */ +O_WRONLY (0x0001) /* open for writing */ +O_RDWR (0x0002) /* open for read & write */ +O_APPEND (0x0008) /* append on each write */ +O_CREAT (0x0200) /* open with file create */ +O_TRUNC (0x0400) /* open with truncation */ +O_BINARY (0x8000) /* open in binary mode */ +``` + +See POSIX for further explanation of the flags. + +• The *llv\_fd* is treated as a suggested low-level file descriptor. This is a historical artifact; newly-defined device drivers should ignore this argument. This differs from the low-level I/O open function. + +This function must arrange for information to be saved for each file descriptor, typically including a file position indicator and any significant flags. For the HOST version, all the bookkeeping is handled by the debugger running on the host machine. If the device uses an internal buffer, the buffer can be created when a file is opened, or the buffer can be created during a read or write. + +**Return Value** This function must return -1 to indicate an error if for some reason the file could not be opened; such as the file does not exist, could not be created, or there are too many files open. The value of errno may optionally be set to indicate the exact error (the HOST device does not set errno). Some devices might have special failure conditions; for instance, if a device is read-only, a file cannot be opened O\_WRONLY. + +> On success, this function must return a non-negative file descriptor unique among all open files handled by the specific device. The file descriptor need not be unique across devices. The device file descriptor is used only by low-level functions when calling the device-driver-level functions. The low-level function open allocates its own unique file descriptor for the high-level functions to call the low-level functions. Code that uses only high-level I/O functions need not be aware of these file descriptors. + +**DEV\_close** *Close File for I/O* + +**Syntax int DEV\_close (int** *dev\_fd* **);** + +**Description** This function closes a valid open file descriptor. + +On some devices, DEV\_close may need to be responsible for checking if this is the last file descriptor pointing to a file that was unlinked. If so, it is responsible for ensuring that the file is actually removed from the device and the resources reclaimed, if appropriate. + +**Return Value** This function should return -1 to indicate an error if the file descriptor is invalid in some way, such as being out of range or already closed, but this is not required. The user should not call close() with an invalid file descriptor. + +#### **DEV\_read** *Read Characters from a File* + +**Syntax int DEV\_read (int** *dev\_fd* **, char \*** *buf* **, unsigned** *count* **);** + +**Description** The read function reads *count* bytes from the input file associated with *dev\_fd*. + +- The *dev\_fd* is the number assigned by open to an opened file. +- The *buf* is where the read characters are placed. +- The *count* is the number of characters to read from the file. + +**Return Value** This function must return -1 to indicate an error if for some reason no bytes could be read from the file. This could be because of an attempt to read from a O\_WRONLY file, or for device-specific reasons. + +If count is 0, no bytes are read and this function returns 0. + +This function returns the number of bytes read, from 0 to count. 0 indicates that EOF was reached before any bytes were read. It is not an error to read less than count bytes; this is common if the are not enough bytes left in the file or the request was larger than an internal device buffer size. + +#### **DEV\_write** *Write Characters to a File* + +**Syntax int DEV\_write (int** *dev\_fd* **, const char \*** *buf* **, unsigned** *count* **);** + +**Description** This function writes *count* bytes to the output file. + +- The *dev\_fd* is the number assigned by open to an opened file. +- The *buffer* is where the write characters are placed. +- The *count* is the number of characters to write to the file. + +**Return Value** This function must return -1 to indicate an error if for some reason no bytes could be written to the file. This could be because of an attempt to read from a O\_RDONLY file, or for device-specific reasons. + +**DEV\_lseek** *Set File Position Indicator* + +**Syntax off\_t lseek (int** *dev\_fd* **, off\_t** *offset* **, int** *origin* **);** + +**Description** This function sets the file's position indicator for this file descriptor as lseek. + +If lseek is supported, it should not allow a seek to before the beginning of the file, but it should support seeking past the end of the file. Such seeks do not change the size of + +the file, but if it is followed by a write, the file size will increase. + +**Return Value** If successful, this function returns the new value of the file position indicator. + +This function must return -1 to indicate an error if for some reason no bytes could be written to the file. For many devices, the lseek operation is nonsensical (e.g. a computer + +monitor). + +**DEV\_unlink** *Delete File* + +**Syntax int DEV\_unlink (const char \*** *path* **);** + +**Description** Remove the association of the pathname with the file. This means that the file may no longer be opened using this name, but the file may not actually be immediately removed. + +> Depending on the device, the file may be immediately removed, but for a device which allows open file descriptors to point to unlinked files, the file will not actually be deleted + +until the last file descriptor is closed. See Section 7.2.3. + +**Return Value** This function must return -1 to indicate an error if for some reason the file could not be + +unlinked (delayed removal does not count as a failure to unlink.) + +If successful, this function returns 0. + +**DEV\_rename** *Rename File* + +**Syntax int DEV\_rename (const char \*** *old\_name* **, const char \*** *new\_name* **);** + +**Description** This function changes the name associated with the file. + +• The *old\_name* is the current name of the file. + +• The *new\_name* is the new name for the file. + +**Return Value** This function must return -1 to indicate an error if for some reason the file could not be renamed, such as the file doesn't exist, or the new name already exists. + +**NOTE:** It is inadvisable to allow renaming a file so that it is on a different device. + +In general this would require a whole file copy, which may be more + +expensive than you expect. + +If successful, this function returns 0. + +### 7.2.4 Adding a User-Defined Device Driver for C I/O + +The function add\_device allows you to add and use a device. When a device is registered with add\_device, the high-level I/O routines can be used for I/O on that device. + +You can use a different protocol to communicate with any desired device and install that protocol using add\_device; however, the HOST functions should not be modified. The default streams stdin, stdout, and stderr can be remapped to a file on a user-defined device instead of HOST by using freopen() as in Example 7-1. If the default streams are reopened in this way, the buffering mode will change to \_IOFBF (fully buffered). To restore the default buffering behavior, call setvbuf on each reopened file with the appropriate value (\_IOLBF for stdin and stdout, \_IONBF for stderr). + +The default streams stdin, stdout, and stderr can be mapped to a file on a user-defined device instead of HOST by using freopen() as shown in Example 7-1. Each function must set up and maintain its own data structures as needed. Some function definitions perform no action and should just return. + +#### Example 7-1. Mapping Default Streams to Device + +``` +#include +#include +#include "mydevice.h" +void main() +{ + add_device("mydevice", _MSA, + MYDEVICE_open, MYDEVICE_close, + MYDEVICE_read, MYDEVICE_write, + MYDEVICE_lseek, MYDEVICE_unlink, MYDEVICE_rename); + /*-----------------------------------------------------------------------*/ + /* Re-open stderr as a MYDEVICE file */ + /*-----------------------------------------------------------------------*/ + if (!freopen("mydevice:stderrfile", "w", stderr)) + { + puts("Failed to freopen stderr"); + exit(EXIT_FAILURE); + } + /*-----------------------------------------------------------------------*/ + /* stderr should not be fully buffered; we want errors to be seen as */ + /* soon as possible. Normally stderr is line-buffered, but this example */ + /* doesn't buffer stderr at all. This means that there will be one call */ + /* to write() for each character in the message. */ + /*-----------------------------------------------------------------------*/ + if (setvbuf(stderr, NULL, _IONBF, 0)) + { + puts("Failed to setvbuf stderr"); + exit(EXIT_FAILURE); + } + /*-----------------------------------------------------------------------*/ + /* Try it out! */ + /*-----------------------------------------------------------------------*/ + printf("This goes to stdout\n"); + fprintf(stderr, "This goes to stderr\n"); } +``` + +#### NOTE: Use Unique Function Names + +The function names open, read, write, close, lseek, rename, and unlink are used by the low-level routines. Use other names for the device-level functions that you write. + +Use the low-level function add\_device() to add your device to the device\_table. The device table is a statically defined array that supports *n* devices, where *n* is defined by the macro \_NDEVICE found in stdio.h/cstdio. + +The first entry in the device table is predefined to be the host device on which the debugger is running. The low-level routine add\_device() finds the first empty position in the device table and initializes the device fields with the passed-in arguments. For a complete description, see the add\\_device function. + +### 7.2.5 The device Prefix + +A file can be opened to a user-defined device driver by using a device prefix in the pathname. The device prefix is the device name used in the call to add\_device followed by a colon. For example: + +``` +FILE *fptr = fopen("mydevice:file1", "r"); +int fd = open("mydevice:file2, O_RDONLY, 0); +``` + +If no device prefix is used, the HOST device will be used to open the file. + +# **add\_device** *Add Device to Device Table* + +**Syntax for C** #include + +``` +int add_device(char * name, + unsigned flags , + int (* dopen )(const char *path, unsigned flags, int llv_fd), + int (* dclose )( int dev_fd), + int (* dread )(intdev_fd, char *buf, unsigned count), + int (* dwrite )(int dev_fd, const char *buf, unsigned count), + off_t (* dlseek )(int dev_fd, off_t ioffset, int origin), + int (* dunlink )(const char * path), + int (* drename )(const char *old_name, const char *new_name)); +``` + +**Defined in** lowlev.c (in the lib/src subdirectory of the compiler installation) + +**Description** The add\_device function adds a device record to the device table allowing that device to be used for I/O from C. The first entry in the device table is predefined to be the HOST device on which the debugger is running. The function add\_device() finds the first empty position in the device table and initializes the fields of the structure that represent a device. + +> To open a stream on a newly added device use fopen( ) with a string of the format *devicename* **:** *filename* as the first argument. + +- The *name* is a character string denoting the device name. The name is limited to 8 characters. +- The *flags* are device characteristics. The flags are as follows: + - **\_SSA** Denotes that the device supports only one open stream at a time + - **\_MSA** Denotes that the device supports multiple open streams + - More flags can be added by defining them in file.h. +- The *dopen*, *dclose*, *dread*, *dwrite*, *dlseek*, *dunlink*, and *drename* specifiers are function pointers to the functions in the device driver that are called by the low-level functions to perform I/O on the specified device. You must declare these functions with the interface specified in Section 7.2.2. The device driver for the HOST that the PRU debugger is run on are included in the C I/O library. + +**Return Value** The function returns one of the following values: + +- 0 if successful +- -1 on failure + +#### Example + +#### Example 7-2 does the following: + +- Adds the device mydevice to the device table +- Opens a file named test on that device and associates it with the FILE pointer fid +- Writes the string Hello, world into the file +- · Closes the file + +Example 7-2 illustrates adding and using a device for C I/O: + +### Example 7-2. Program for C I/O Device + +``` +#include +#include +/************************************** +/* Declarations of the user-defined device drivers +/************************************** +extern int MYDEVICE_open(const char *path, unsigned flags, int fno); +extern int MYDEVICE_close(int fno); +extern int MYDEVICE_read(int fno, char *buffer, unsigned count); +extern int MYDEVICE_write(int fno, const char *buffer, unsigned count); +extern off_t MYDEVICE_lseek(int fno, off_t offset, int origin); +extern int MYDEVICE_unlink(const char *path); +extern int MYDEVICE_rename(const char *old_name, char *new_name); +main() + FILE *fid; + add_device("mydevice", _MSA, MYDEVICE_open, MYDEVICE_close, MYDEVICE_read, + MYDEVICE_write, MYDEVICE_lseek, MYDEVICE_unlink, MYDEVICE_rename); + fid = fopen("mydevice:test","w"); + fprintf(fid, "Hello, world\n"); + fclose(fid); +``` + +## 7.3 Handling Reentrancy (\_register\_lock() and \_register\_unlock() Functions) + +The C standard assumes only one thread of execution, with the only exception being extremely narrow support for signal handlers. The issue of reentrancy is avoided by not allowing you to do much of anything in a signal handler. However, SYS/BIOS applications have multiple threads which need to modify the same global program state, such as the CIO buffer, so reentrancy is a concern. + +Part of the problem of reentrancy remains your responsibility, but the run-time-support environment does provide rudimentary support for multi-threaded reentrancy by providing support for critical sections. This implementation does not protect you from reentrancy issues; this remains your responsibility. + +The run-time-support environment provides hooks to install critical section primitives. By default, a singlethreaded model is assumed, and the critical section primitives are not employed. In a multi-threaded system such as SYS/BIOS, the kernel arranges to install semaphore lock primitive functions in these hooks, which are then called when the run-time-support enters code that needs to be protected by a critical section. + +Throughout the run-time-support environment where a global state is accessed, and thus needs to be protected with a critical section, there are calls to the function \_lock(). This calls the provided primitive, if installed, and acquires the semaphore before proceeding. Once the critical section is finished, \_unlock() is called to release the semaphore. + +Usually SYS/BIOS is responsible for creating and installing the primitives, so you do not need to take any action. However, this mechanism can be used in multi-threaded applications that do not use the SYS/BIOS locking mechanism. + +You should not define the functions \_lock() and \_unlock() functions directly; instead, the installation functions are called to instruct the run-time-support environment to use these new primitives: + +``` +void _register_lock (void ( *lock)()); +void _register_unlock(void (*unlock)()); +``` + +The arguments to \_register\_lock() and \_register\_unlock() should be functions which take no arguments and return no values, and which implement some sort of global semaphore locking: + +``` +extern volatile sig_atomic_t *sema = SHARED_SEMAPHORE_LOCATION; +static int sema_depth = 0; +static void my_lock(void) +{ + while (ATOMIC_TEST_AND_SET(sema, MY_UNIQUE_ID) != MY_UNIQUE_ID); + sema_depth++; +} +static void my_unlock(void) +{ + if (!--sema_depth) ATOMIC_CLEAR(sema); +} +``` + +The run-time-support nests calls to \_lock(), so the primitives must keep track of the nesting level. + +## 7.4 Library-Build Process + +When using the C/C++ compiler, you can compile your code under a number of different configurations and options that are not necessarily compatible with one another. Because it would be infeasible to include all possible run-time-support library variants, compiler releases pre-build only a small number of very commonly-used libraries such as rtspru\_v3\_le.lib. + +To provide maximum flexibility, the run-time-support source code is provided as part of each compiler release. You can build the missing libraries as desired. The linker can also automatically build missing libraries. This is accomplished with a new library build process, the core of which is the executable mklib, which is available beginning with CCS 5.1. + +### 7.4.1 Required Non-Texas Instruments Software + +To use the self-contained run-time-support build process to rebuild a library with custom options, the following are required: + +- sh (Bourne shell) +- gmake (GNU make 3.81 or later) + +More information is available from GNU at . GNU make (gmake) is also available in earlier versions of Code Composer Studio. GNU make is also included in some UNIX support packages for Windows, such as the MKS Toolkit, Cygwin, and Interix. The GNU make used on Windows platforms should explicitly report "This program build for Windows32" when the following is executed from the Command Prompt window: + +``` +gmake -h +``` + +All three of these programs are provided as a non-optional feature of CCS 5.1. They are also available as part of the optional XDC Tools feature if you are using an earlier version of CCS. + +The mklib program looks for these executables in the following order: + +1. in your PATH +2. in the directory getenv("CCS\_UTILS\_DIR")/cygwin +3. in the directory getenv("CCS\_UTILS\_DIR")/bin +4. in the directory getenv("XDCROOT") +5. in the directory getenv("XDCROOT")/bin + +If you are invoking mklib from the command line, and these executables are not in your path, you must set the environment variable CCS\_UTILS\_DIR such that getenv("CCS\_UTILS\_DIR")/bin contains the correct programs. + +### 7.4.2 Using the Library-Build Process + +You should normally let the linker automatically rebuild libraries as needed. If necessary, you can run mklib directly to populate libraries. See Section 7.4.2.2 for situations when you might want to do this. + +#### 7.4.2.1 Automatic Standard Library Rebuilding by the Linker + +The linker looks for run-time-support libraries primarily through the PRU\_C\_DIR environment variable. Typically, one of the pathnames in PRU\_C\_DIR is *your install directory*/lib, which contains all of the prebuilt libraries, as well as the index library libc.a. The linker looks in PRU\_C\_DIR to find a library that is the best match for the build attributes of the application. The build attributes are set indirectly according to the command-line options used to build the application. Build attributes include things like CPU revision. If the library name is explicitly specified (e.g. -library=rtspru\_v3\_le.lib), run-time support looks for that library exactly. If the library name is not specified, the linker uses the index library libc.a to pick an appropriate library. If the library is specified by path (e.g. –library=/foo/rtspru\_v3\_le.lib), it is assumed the library already exists and it will not be built automatically. + +The index library describes a set of libraries with different build attributes. The linker will compare the build attributes for each potential library with the build attributes of the application and will pick the best fit. For details on the index library, see the archiver chapter in the *PRU Assembly Language Tools User's Guide*. + +Now that the linker has decided which library to use, it checks whether the run-time-support library is present in PRU\_C\_DIR . The library must be in exactly the same directory as the index library libc.a. If the library is not present, the linker invokes mklib to build it. This happens when the library is missing, regardless of whether the user specified the name of the library directly or allowed the linker to pick the best library from the index library. + +The mklib program builds the requested library and places it in 'lib' directory part of PRU\_C\_DIR in the same directory as the index library, so it is available for subsequent compilations. + +Things to watch out for: + +- The linker invokes **mklib** and waits for it to finish before finishing the link, so you will experience a onetime delay when an uncommonly-used library is built for the first time. Build times of 1-5 minutes have been observed. This depends on the power of the host (number of CPUs, etc). +- In a shared installation, where an installation of the compiler is shared among more than one user, it is possible that two users might cause the linker to rebuild the same library at the same time. The **mklib** program tries to minimize the race condition, but it is possible one build will corrupt the other. In a shared environment, all libraries which might be needed should be built at install time; see Section 7.4.2.2 for instructions on invoking **mklib** directly to avoid this problem. +- The index library must exist, or the linker is unable to rebuild libraries automatically. +- The index library must be in a user-writable directory, or the library is not built. If the compiler installation must be installed read-only (a good practice for shared installation), any missing libraries must be built at installation time by invoking **mklib** directly. +- The **mklib** program is specific to a certain version of a certain library; you cannot use one compiler version's run-time support's **mklib** to build a different compiler version's run-time support library. + +#### 7.4.2.2 Invoking mklib Manually + +You may need to invoke **mklib** directly in special circumstances: + +- The compiler installation directory is read-only or shared. +- You want to build a variant of the run-time-support library that is not pre-configured in the index library **libc.a** or known to mklib. (e.g. a variant with source-level debugging turned on.) + +#### 7.4.2.2.1 Building Standard Libraries + +You can invoke mklib directly to build any or all of the libraries indexed in the index library **libc.a**. The libraries are built with the standard options for that library; the library names and the appropriate standard option sets are known to mklib. + +This is most easily done by changing the working directory to be the compiler run-time-support library directory 'lib' and invoking the **mklib** executable there: + +**mklib --pattern=rtspru\_v3\_le.lib** + +#### 7.4.2.2.2 Shared or Read-Only Library Directory + +If the compiler tools are to be installed in shared or read-only directory, mklib cannot build the standard libraries at link time; the libraries must be built before the library directory is made shared or read-only. + +At installation time, the installing user must build all of the libraries which will be used by any user. To build all possible libraries, change the working directory to be the compiler RTS library directory 'lib' and invoke the mklib executable there: + +**mklib --all** + +Some targets have many libraries, so this step can take a long time. To build a subset of the libraries, invoke mklib individually for each desired library. + +#### 7.4.2.2.3 Building Libraries With Custom Options + +You can build a library with any extra custom options desired. This is useful for building a debugging version of the library, or with silicon exception workarounds enabled. The generated library is not a standard library, and must not be placed in the 'lib' directory. It should be placed in a directory local to the project which needs it. To build a debugging version of the library , change the working directory to the 'lib' directory and run the command: + +``` +mklib --pattern=rtspru_v3_le.lib --name=rtspru_v3_le_debug.lib + --install_to=$Project/Debug --extra_options="-g" +``` + +#### 7.4.2.2.4 The mklib Program Option Summary + +Run the following command to see the full list of options. These are described in Table 7-1. **mklib --help** + +**Table 7-1. The mklib Program Options** + +| Option | Effect | +|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| index=filename | The index library (libc.a) for this release. Used to find a template library for custom builds, and to find the
source files (in the lib/src subdirectory of the compiler installation). REQUIRED. | +| pattern=filename | Pattern for building a library. If neitherextra_options noroptions are specified, the library will be the
standard library with the standard options for that library. If eitherextra_options oroptions are
specified, the library is a custom library with custom options. REQUIRED unlessall is used. | +| all | Build all standard libraries at once. | +| install_to=directory | The directory into which to write the library. For a standard library, this defaults to the same directory as
the index library (libc.a). For a custom library, this option is REQUIRED. | +| compiler_bin_dir=
directory | The directory where the compiler executables are. When invoking mklib directly, the executables should
be in the path, but if they are not, this option must be used to tell mklib where they are. This option is
primarily for use when mklib is invoked by the linker. | +| name=filename | File name for the library with no directory part. Only useful for custom libraries. | +| options='str' | Options to use when building the library. The default options (see below) are replaced by this string. If
this option is used, the library will be a custom library. | +| extra_options='str' | Options to use when building the library. The default options (see below) are also used. If this option is
used, the library will be a custom library. | +| list_libraries | List the libraries this script is capable of building and exit. ordinary system-specific directory. | +| log=filename | Save the build log as filename. | +| tmpdir=directory | Use directory for scratch space instead of the ordinary system-specific directory. | +| gmake=filename | Gmake-compatible program to invoke instead of "gmake" | +| parallel=N | Compile N files at once ("gmake -j N"). | +| query=filename | Does this script know how to build FILENAME? | +| help orh | Display this help. | +| quiet orq | Operate silently. | +| verbose orv | Extra information to debug this executable. | + +#### Examples: + +To build all standard libraries and place them in the compiler's library directory: + +``` +mklib --all --index=$C_DIR/lib +``` + +To build one standard library and place it in the compiler's library directory: + +``` +mklib --pattern=rtspru_v3_le.lib --index=$C_DIR/lib +``` + +To build a custom library that is just like rtspru\_v3\_le.lib, but has symbolic debugging support enabled: + +``` +mklib --pattern=rtspru_v3_le.lib --extra_options="-g" --index=$C_DIR/lib -- +install_to=$Project/Debug + --name=rtspru_v3_le_debug.lib +``` + +### 7.4.3 Extending mklib + +The **mklib** API is a uniform interface that allows Code Composer Studio to build libraries without needing to know exactly what underlying mechanism is used to build it. Each library vendor (e.g. the TI compiler) provides a library-specific copy of 'mklib' in the library directory that can be invoked, which understands a standardized set of options, and understands how to build the library. This allows the linker to automatically build application-compatible versions of any vendor's library without needing to register the library in advance, as long as the vendor supports mklib. + +#### 7.4.3.1 Underlying Mechanism + +The underlying mechanism can be anything the vendor desires. For the compiler run-time-support libraries, mklib is just a wrapper that knows how to use the files in the lib/src subdirectory of the compiler installation and invoke gmake with the appropriate options to build each library. If necessary, mklib can be bypassed and the Makefile used directly, but this mode of operation is not supported by TI, and you are responsible for any changes to the Makefile. The format of the Makefile and the interface between mklib and the Makefile is subject to change without notice. The mklib program is the forward-compatible path. + +#### 7.4.3.2 Libraries From Other Vendors + +Any vendor who wishes to distribute a library that can be rebuilt automatically by the linker must provide: + +- An index library (like 'libc.a', but with a different name) +- A copy of mklib specific to that library +- A copy of the library source code (in whatever format is convenient) + +These things must be placed together in one directory that is part of the linker's library search path (specified either in PRU\_C\_DIR or with the linker --search\_path option). + +If mklib needs extra information that is not possible to pass as command-line options to the compiler, the vendor will need to provide some other means of discovering the information (such as a configuration file written by a wizard run from inside CCS). + +The vendor-supplied mklib must at least accept all of the options listed in Table 7-1 without error, even if they do not do anything. + +# C++ Name Demangler + +The C++ compiler implements function overloading, operator overloading, and type-safe linking by encoding a function's prototype and namespace in its link-level name. The process of encoding the prototype into the linkname is often referred to as name mangling. When you inspect mangled names, such as in assembly files, disassembler output, or compiler or linker diagnostic messages, it can be difficult to associate a mangled name with its corresponding name in the C++ source code. The C++ name demangler is a debugging aid that translates each mangled name it detects to its original name found in the C++ source code. + +These topics tell you how to invoke and use the C++ name demangler. The C++ name demangler reads in input, looking for mangled names. All unmangled text is copied to output unaltered. All mangled names are demangled before being copied to output. + +**Topic** ........................................................................................................................... **Page** + +| 8.1 | Invoking the C++ Name Demangler | 145 | +|-----|----------------------------------------|-----| +| 8.2 | C++ Name Demangler Options | 145 | +| 8.3 | Sample Usage of the C++ Name Demangler | 145 | + +## 8.1 Invoking the C++ Name Demangler + +The syntax for invoking the C++ name demangler is: + +#### **dempru** [*options* ] [*filenames*] + +**dempru** Command that invokes the C++ name demangler. + +*options* Options affect how the name demangler behaves. Options can appear anywhere on the + +command line. (Options are discussed in Section 8.2.) + +*filenames* Text input files, such as the assembly file output by the compiler, the assembler listing file, + +the disassembly file, and the linker map file. If no filenames are specified on the command + +line, dempru uses standard input. + +By default, the C++ name demangler outputs to standard output. You can use the -o file option if you want to output to a file. + +## 8.2 C++ Name Demangler Options + +The following options apply only to the C++ name demangler: + +**--debug** Prints debug messages. + +**--diag\_wrap**[=on,off] Sets diagnostic messages to wrap at 79 columns (on, which is the default) + +or not (off). + +**--help** Prints a help screen that provides an online summary of the C++ name + +demangler options. + +**--output**= *file* Outputs to the specified file rather than to standard out. + +**--quiet** Reduces the number of messages generated during execution. + +**-u** Specifies that external names do not have a C++ prefix. + +**-v** Enables verbose mode (outputs a banner). + +## 8.3 Sample Usage of the C++ Name Demangler + +The examples in this section illustrate the demangling process. Example 8-1 shows a sample C++ program. Example 8-2 shows the resulting assembly that is output by the compiler. In this example, the linknames of all the functions are mangled; that is, their signature information is encoded into their names. + +### *Example 8*‑*1. C++ Code for calories\_in\_a\_banana* + +``` +class banana { +public: + int calories(void); + banana(); + ~banana(); +}; +int calories_in_a_banana(void) +{ + banana x; + return x.calories(); +} +``` + +#### *Example 8*‑*2. Resulting Assembly for calories\_in\_a\_banana* + +``` +||_Z20calories_in_a_bananav||: +SUB r2, r2, 0x07 +SBBO &r3.b2, r2, 1, 6 +ADD r14, r2, 0 +JAL r3.w2, ||_ZN6bananaC1Ev|| +ADD r14, r2, 0 +JAL r3.w2, ||_ZN6banana8caloriesEv|| +MOV r4, r14 +ADD r14, r2, 0 +JAL r3.w2, ||_ZN6bananaD1Ev|| +MOV r14, r4 +LBBO &r3.b2, r2, 1, 6 +ADD r2, r2, 0x07 +JMP r3.w2 +``` + +Executing the C++ name demangler demangles all names that it believes to be mangled. Enter: + +``` +dempru calories_in_a_banana.asm +``` + +The result is shown in Example 8-3. The linknames in Example 8-2 \_\_\_ct\_\_6bananaFv, \_calories\_\_6bananaFv, and \_\_\_dt\_\_6bananaFv are demangled. + +### *Example 8*‑*3. Result After Running the C++ Name Demangler* + +``` +||calories_in_a_banana()||: +;* --------------------------------------------------------------------------* + SUB r2, r2, 0x07 + SBBO &r3.b2, r2, 1, 6 + ADD r14, r2, 0 + JAL r3.w2, ||banana::banana()|| + ADD r14, r2, 0 + JAL r3.w2, ||banana::calories()|| + MOV r4, r14 + ADD r14, r2, 0 + JAL r3.w2, ||banana::~banana()|| + MOV r14, r4 + LBBO &r3.b2, r2, 1, 6 + ADD r2, r2, 0x07 + JMP r3.w2 +``` + +# Glossary + +## A.1 Terminology + +- **absolute lister—** A debugging tool that allows you to create assembler listings that contain absolute addresses. +- **Application Binary Interface (ABI)—** A standard that specifies the interface between two object modules. An ABI specifies how functions are called and how information is passed from one program component to another. +- **assignment statement—** A statement that initializes a variable with a value. +- **autoinitialization—** The process of initializing global C variables (contained in the .cinit section) before program execution begins. +- **autoinitialization at run time—** An autoinitialization method used by the linker when linking C code. The linker uses this method when you invoke it with the --rom\_model link option. The linker loads the .cinit section of data tables into memory, and variables are initialized at run time. +- **alias disambiguation—** A technique that determines when two pointer expressions cannot point to the same location, allowing the compiler to freely optimize such expressions. +- **aliasing—** The ability for a single object to be accessed in more than one way, such as when two pointers point to a single object. It can disrupt optimization, because any indirect reference could refer to any other object. +- **allocation—** A process in which the linker calculates the final memory addresses of output sections. +- **ANSI—** American National Standards Institute; an organization that establishes standards voluntarily followed by industries. +- **archive library—** A collection of individual files grouped into a single file by the archiver. +- **archiver—** A software program that collects several individual files into a single file called an archive library. With the archiver, you can add, delete, extract, or replace members of the archive library. +- **assembler—** A software program that creates a machine-language program from a source file that contains assembly language instructions, directives, and macro definitions. The assembler substitutes absolute operation codes for symbolic operation codes and absolute or relocatable addresses for symbolic addresses. +- **assignment statement—** A statement that initializes a variable with a value. +- **autoinitialization—** The process of initializing global C variables (contained in the .cinit section) before program execution begins. +- **autoinitialization at run time—** An autoinitialization method used by the linker when linking C code. The linker uses this method when you invoke it with the --rom\_model link option. The linker loads the .cinit section of data tables into memory, and variables are initialized at run time. +- **big endian—** An addressing protocol in which bytes are numbered from left to right within a word. More significant bytes in a word have lower numbered addresses. Endian ordering is hardware-specific and is determined at reset. See also *little endian* +- **BIS—** Bit instruction set. + +- **block—** A set of statements that are grouped together within braces and treated as an entity. +- **.bss section—** One of the default object file sections. You use the assembler .bss directive to reserve a specified amount of space in the memory map that you can use later for storing data. The .bss section is uninitialized. +- **byte—** Per ANSI/ISO C, the smallest addressable unit that can hold a character. +- **C/C++ compiler—** A software program that translates C source statements into assembly language source statements. +- **code generator—** A compiler tool that takes the file produced by the parser or the optimizer and produces an assembly language source file. +- **command file—** A file that contains options, filenames, directives, or commands for the linker or hex conversion utility. +- **comment—** A source statement (or portion of a source statement) that documents or improves readability of a source file. Comments are not compiled, assembled, or linked; they have no effect on the object file. +- **compiler program—** A utility that lets you compile, assemble, and optionally link in one step. The compiler runs one or more source modules through the compiler (including the parser, optimizer, and code generator), the assembler, and the linker. +- **configured memory—** Memory that the linker has specified for allocation. +- **constant—** A type whose value cannot change. +- **cross-reference listing—** An output file created by the assembler that lists the symbols that were defined, what line they were defined on, which lines referenced them, and their final values. +- **.data section—** One of the default object file sections. The .data section is an initialized section that contains initialized data. You can use the .data directive to assemble code into the .data section. +- **direct call—** A function call where one function calls another using the function's name. +- **directives—** Special-purpose commands that control the actions and functions of a software tool (as opposed to assembly language instructions, which control the actions of a device). +- **disambiguation—** See *alias disambiguation* +- **dynamic memory allocation—** A technique used by several functions (such as malloc, calloc, and realloc) to dynamically allocate memory for variables at run time. This is accomplished by defining a large memory pool (heap) and using the functions to allocate memory from the heap. +- **ELF—** Executable and Linkable Format; a system of object files configured according to the System V Application Binary Interface specification. +- **emulator—** A hardware development system that duplicates the PRU operation. +- **entry point—** A point in target memory where execution starts. +- **environment variable—** A system symbol that you define and assign to a string. Environmental variables are often included in Windows batch files or UNIX shell scripts such as .cshrc or .profile. +- **epilog—** The portion of code in a function that restores the stack and returns. +- **executable object file—** A linked, executable object file that is downloaded and executed on a target system. +- **expression—** A constant, a symbol, or a series of constants and symbols separated by arithmetic operators. +- **external symbol—** A symbol that is used in the current program module but defined or declared in a different program module. + +- **file-level optimization—** A level of optimization where the compiler uses the information that it has about the entire file to optimize your code (as opposed to program-level optimization, where the compiler uses information that it has about the entire program to optimize your code). +- **function inlining—** The process of inserting code for a function at the point of call. This saves the overhead of a function call and allows the optimizer to optimize the function in the context of the surrounding code. +- **global symbol—** A symbol that is either defined in the current module and accessed in another, or accessed in the current module but defined in another. +- **high-level language debugging—** The ability of a compiler to retain symbolic and high-level language information (such as type and function definitions) so that a debugging tool can use this information. +- **indirect call—** A function call where one function calls another function by giving the address of the called function. +- **initialization at load time—** An autoinitialization method used by the linker when linking C/C++ code. The linker uses this method when you invoke it with the --ram\_model link option. This method initializes variables at load time instead of run time. +- **initialized section—** A section from an object file that will be linked into an executable object file. +- **input section—** A section from an object file that will be linked into an executable object file. +- **integrated preprocessor—** A C/C++ preprocessor that is merged with the parser, allowing for faster compilation. Stand-alone preprocessing or preprocessed listing is also available. +- **interlist feature—** A feature that inserts as comments your original C/C++ source statements into the assembly language output from the assembler. The C/C++ statements are inserted next to the equivalent assembly instructions. +- **intrinsics—** Operators that are used like functions and produce assembly language code that would otherwise be inexpressible in C, or would take greater time and effort to code. +- **ISO—** International Organization for Standardization; a worldwide federation of national standards bodies, which establishes international standards voluntarily followed by industries. +- **K&R C—** Kernighan and Ritchie C, the de facto standard as defined in the first edition of *The C Programming Language* (K&R). Most K&R C programs written for earlier, non-ISO C compilers should correctly compile and run without modification. +- **label—** A symbol that begins in column 1 of an assembler source statement and corresponds to the address of that statement. A label is the only assembler statement that can begin in column 1. +- **linker—** A software program that combines object files to form an executable object file that can be allocated into system memory and executed by the device. +- **listing file—** An output file, created by the assembler, which lists source statements, their line numbers, and their effects on the section program counter (SPC). +- **little endian—** An addressing protocol in which bytes are numbered from right to left within a word. More significant bytes in a word have higher numbered addresses. Endian ordering is hardware-specific and is determined at reset. See also *big endian* +- **loader—** A device that places an executable object file into system memory. +- **loop unrolling—** An optimization that expands small loops so that each iteration of the loop appears in your code. Although loop unrolling increases code size, it can improve the performance of your code. +- **macro—** A user-defined routine that can be used as an instruction. +- **macro call—** The process of invoking a macro. + +- **macro definition—** A block of source statements that define the name and the code that make up a macro. +- **macro expansion—** The process of inserting source statements into your code in place of a macro call. +- **map file—** An output file, created by the linker, which shows the memory configuration, section composition, section allocation, symbol definitions and the addresses at which the symbols were defined for your program. +- **memory map—** A map of target system memory space that is partitioned into functional blocks. +- **name mangling—** A compiler-specific feature that encodes a function name with information regarding the function's arguments return types. +- **object file—** An assembled or linked file that contains machine-language object code. +- **object library—** An archive library made up of individual object files. +- **operand—** An argument of an assembly language instruction, assembler directive, or macro directive that supplies information to the operation performed by the instruction or directive. +- **optimizer—** A software tool that improves the execution speed and reduces the size of C programs. +- **options—** Command-line parameters that allow you to request additional or specific functions when you invoke a software tool. +- **output section—** A final, allocated section in a linked, executable module. +- **parser—** A software tool that reads the source file, performs preprocessing functions, checks the syntax, and produces an intermediate file used as input for the optimizer or code generator. +- **partitioning—** The process of assigning a data path to each instruction. +- **pop—** An operation that retrieves a data object from a stack. +- **pragma—** A preprocessor directive that provides directions to the compiler about how to treat a particular statement. +- **preprocessor—** A software tool that interprets macro definitions, expands macros, interprets header files, interprets conditional compilation, and acts upon preprocessor directives. +- **program-level optimization—** An aggressive level of optimization where all of the source files are compiled into one intermediate file. Because the compiler can see the entire program, several optimizations are performed with program-level optimization that are rarely applied during file-level optimization. +- **prolog—** The portion of code in a function that sets up the stack. +- **push—** An operation that places a data object on a stack for temporary storage. +- **quiet run—** An option that suppresses the normal banner and the progress information. +- **raw data—** Executable code or initialized data in an output section. +- **relocation—** A process in which the linker adjusts all the references to a symbol when the symbol's address changes. +- **run-time environment—** The run time parameters in which your program must function. These parameters are defined by the memory and register conventions, stack organization, function call conventions, and system initialization. +- **run-time-support functions—** Standard ISO functions that perform tasks that are not part of the C language (such as memory allocation, string conversion, and string searches). +- **run-time-support library—** A library file, rts.src, which contains the source for the run time-support functions. + +- **section—** A relocatable block of code or data that ultimately will be contiguous with other sections in the memory map. +- **sign extend—** A process that fills the unused MSBs of a value with the value's sign bit. +- **source file—** A file that contains C/C++ code or assembly language code that is compiled or assembled to form an object file. +- **stand-alone preprocessor—** A software tool that expands macros, #include files, and conditional compilation as an independent program. It also performs integrated preprocessing, which includes parsing of instructions. +- **static variable—** A variable whose scope is confined to a function or a program. The values of static variables are not discarded when the function or program is exited; their previous value is resumed when the function or program is reentered. +- **storage class—** An entry in the symbol table that indicates how to access a symbol. +- **string table—** A table that stores symbol names that are longer than eight characters (symbol names of eight characters or longer cannot be stored in the symbol table; instead they are stored in the string table). The name portion of the symbol's entry points to the location of the string in the string table. +- **structure—** A collection of one or more variables grouped together under a single name. +- **subsection—** A relocatable block of code or data that ultimately will occupy continuous space in the memory map. Subsections are smaller sections within larger sections. Subsections give you tighter control of the memory map. +- **symbol—** A string of alphanumeric characters that represents an address or a value. +- **symbolic debugging—** The ability of a software tool to retain symbolic information that can be used by a debugging tool such as an emulator. +- **target system—** The system on which the object code you have developed is executed. +- **.text section—** One of the default object file sections. The .text section is initialized and contains executable code. You can use the .text directive to assemble code into the .text section. +- **trigraph sequence—** A 3-character sequence that has a meaning (as defined by the ISO 646-1983 Invariant Code Set). These characters cannot be represented in the C character set and are expanded to one character. For example, the trigraph ??' is expanded to ^. +- **trip count—** The number of times that a loop executes before it terminates. +- **unconfigured memory—** Memory that is not defined as part of the memory map and cannot be loaded with code or data. +- **uninitialized section—** A object file section that reserves space in the memory map but that has no actual contents. These sections are built with the .bss and .usect directives. +- **unsigned value—** A value that is treated as a nonnegative number, regardless of its actual sign. +- **variable—** A symbol representing a quantity that can assume any of a set of values. +- **word—** A 32-bit addressable location in target memory + +# Revision History + +## B.1 Recent Revisions + +Table B-1 lists significant changes made to this document. The left column identifies the first version of this document in which that particular change appeared. + +**Table B-1. Revision History** + +| Version
Added | Chapter | Location | Additions / Modifications / Deletions | +|------------------|------------------------------------|---------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| SPRUHV7C | Using the Compiler | Section 2.3.1 | Added the --ecc=on linker option, which enables ECC generation. Note that ECC generation is now off by default. | +| SPRUHV7C | Using the Compiler | Section 2.3.4 | Added --silicon_version=4 support. | +| SPRUHV7C | Using the Compiler, C/C++ Language | Section 2.11 and
Section 5.9 | Revised the section on inline function expansion and its subsections to include new pragmas and changes to the compilers decision-making about what functions to inline. The FORCEINLINE, FORCEINLINE_RECURSIVE, and NOINLINE pragmas have been added. | +| SPRUHV7C | C/C++ Language | Section 5.2 | Removed several C++ features from the exception list because they have been supported for several releases. | +| SPRUHV7C | C/C++ Language | Section 5.14.2 and
Section 5.14.3 | Added "retain" as a function attribute and variable attribute. | +| SPRUHV7C | C/C++ Language | Section 5.14.5 | Removed some unsupported built-in functions. | +| SPRUHV7C | Run-Time
Environment | Section 6.4.1.1 | 24-bit structures are also passed in registers. | +| Previous Re | visions: | | | +| SPRUHV7B | Using the Compiler | Section 2.3 and
Section 4.2.1 | The --gen_data_subsections option has been added. | +| SPRUHV7B | C/C++ Language | Section 5.9.1 | A CALLS pragma has been added to specify a set of functions that can be called indirectly from a specified calling function. Using this pragma allows such indirect calls to be included in the calculation of a functions' inclusive stack size. | +| SPRUHV7A | Using the Compiler | Section 2.6 | Added section on techniques for passing arguments to main(). | +| SPRUHV7A | C/C++ Language | Section 5.14.2 | The GCC alias function attribute is now supported. | +| SPRUHV7A | C/C++ Language | Section 5.9.6 | Added the diag_push and diag_pop diagnostic message pragmas. | +| SPRUHV7A | C/C++ Language | Section 5.9.9,
Section 5.9.10, and
Section 5.9.15 | Added the FUNC_ALWAYS_INLINE, FUNC_CANNOT_INLINE, NOINIT, and PERSISTENT pragmas. | +| SPRUHV7A | Run-Time
Environment | Section 6.5 | Added reference to section on accessing linker symbols in C and C++ in the Assembly Language Tools User's Guide. | + +#### IMPORTANT NOTICE FOR TI DESIGN INFORMATION AND RESOURCES + +Texas Instruments Incorporated ('TI") technical, application or other design advice, services or information, including, but not limited to, reference designs and materials relating to evaluation modules, (collectively, "TI Resources") are intended to assist designers who are developing applications that incorporate TI products; by downloading, accessing or using any particular TI Resource in any way, you (individually or, if you are acting on behalf of a company, your company) agree to use it solely for this purpose and subject to the terms of this Notice. + +TI's provision of TI Resources does not expand or otherwise alter TI's applicable published warranties or warranty disclaimers for TI products, and no additional obligations or liabilities arise from TI providing such TI Resources. TI reserves the right to make corrections, enhancements, improvements and other changes to its TI Resources. + +You understand and agree that you remain responsible for using your independent analysis, evaluation and judgment in designing your applications and that you have full and exclusive responsibility to assure the safety of your applications and compliance of your applications (and of all TI products used in or for your applications) with all applicable regulations, laws and other applicable requirements. You represent that, with respect to your applications, you have all the necessary expertise to create and implement safeguards that (1) anticipate dangerous consequences of failures, (2) monitor failures and their consequences, and (3) lessen the likelihood of failures that might cause harm and take appropriate actions. You agree that prior to using or distributing any applications that include TI products, you will thoroughly test such applications and the functionality of such TI products as used in such applications. TI has not conducted any testing other than that specifically described in the published documentation for a particular TI Resource. + +You are authorized to use, copy and modify any individual TI Resource only in connection with the development of applications that include the TI product(s) identified in such TI Resource. NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE TO ANY OTHER TI INTELLECTUAL PROPERTY RIGHT, AND NO LICENSE TO ANY TECHNOLOGY OR INTELLECTUAL PROPERTY RIGHT OF TI OR ANY THIRD PARTY IS GRANTED HEREIN, including but not limited to any patent right, copyright, mask work right, or other intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information regarding or referencing third-party products or services does not constitute a license to use such products or services, or a warranty or endorsement thereof. Use of TI Resources may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI. + +TI RESOURCES ARE PROVIDED "AS IS" AND WITH ALL FAULTS. TI DISCLAIMS ALL OTHER WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED, REGARDING TI RESOURCES OR USE THEREOF, INCLUDING BUT NOT LIMITED TO ACCURACY OR COMPLETENESS, TITLE, ANY EPIDEMIC FAILURE WARRANTY AND ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHTS. + +TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY CLAIM, INCLUDING BUT NOT LIMITED TO ANY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON ANY COMBINATION OF PRODUCTS EVEN IF DESCRIBED IN TI RESOURCES OR OTHERWISE. IN NO EVENT SHALL TI BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, COLLATERAL, INDIRECT, PUNITIVE, INCIDENTAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES IN CONNECTION WITH OR ARISING OUT OF TI RESOURCES OR USE THEREOF, AND REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +You agree to fully indemnify TI and its representatives against any damages, costs, losses, and/or liabilities arising out of your noncompliance with the terms and provisions of this Notice. + +This Notice applies to TI Resources. Additional terms apply to the use and purchase of certain types of materials, TI products and services. These include; without limitation, TI's standard terms for semiconductor products ), [evaluation](http://www.ti.com/lit/pdf/SSZZ027) [modules](http://www.ti.com/lit/pdf/SSZZ027), and samples [\(http://www.ti.com/sc/docs/sampterms.htm\)](http://www.ti.com/sc/docs/sampterms.htm). + +> Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright © 2018, Texas Instruments Incorporated diff --git a/docs_ai/reference/pru_subsystem_features_comparison_g/pru_subsystem_features_comparison_g.md b/docs_ai/reference/pru_subsystem_features_comparison_g/pru_subsystem_features_comparison_g.md new file mode 100644 index 000000000..daaa4c1aa --- /dev/null +++ b/docs_ai/reference/pru_subsystem_features_comparison_g/pru_subsystem_features_comparison_g.md @@ -0,0 +1,254 @@ +# PRU Subsystem Features Comparison + +*Catalog Processors* + +#### ABSTRACT + +This application report documents the feature differences between the PRU Subsystems available on different TI processors. + +# Table of Contents + +| 1 Introduction | | +|---|--| +| 1.1 PRU-ICSS: The Programmable Real-time Unit and Industrial Communication Subsystem | | +| 1.2 PRU_ICSSG: The Programmable Real-time Unit and Industrial Communication Subsystem - Gigabit | | +| 1.3 PRUSS: The Programmable Real-time Unit Subsystem | | +| 1.4 PRU Subsystem Feature Comparison | | +| 2 PRU-ICSS Feature Comparison | | +| 3 PRU_ICSSG Feature Comparison | | +| 4 PRUSS Features | | +| 5 References | | +| 6 Revision History | | +| | | +| List of Tables | | +| Table 1-1. PRU Subsystem Feature Comparison | | +| Table 2-1. PRU-ICSS Feature Comparison | | +| Table 3-1. PRU_ICSSG Feature Comparison Across Devices | | +| Table 4-1. PRUSS Features | | + +## Trademarks + +All trademarks are the property of their respective owners. + +## 1 Introduction + +The Programmable Real-time Unit (PRU) is a small processor core that is tightly integrated with an IO subsystem, offering low-latency control of IO pins. The TI Sitara family of devices offer three flavors of PRU Subsystem. + +## 1.1 PRU-ICSS: The Programmable Real-time Unit and Industrial Communication Subsystem + +The Programmable Real-time Unit and Industrial Communication Subsystem (PRU-ICSS) consists of dual 32 bit RISC cores (the PRUs), shared data, instruction memories, internal peripheral modules, and an interrupt controller (INTC). The programmable nature of the PRU, along with its access to pins (IOs), events and all System-on-Chip (SoC) resources, provides flexibility in implementing fast real-time responses, specialized data handling operations, custom peripheral interfaces, and in off-loading tasks from the other processor cores of the SoC. + +Devices offering the PRU-ICSS capability include AM263x, AM335x, AM437x, AM57x and K2G. + +## 1.2 PRU\_ICSSG: The Programmable Real-time Unit and Industrial Communication Subsystem - Gigabit + +The Programmable Real-time Unit and Industrial Communication Subsystem - Gigabit (PRU\_ICSSG) can be considered a superset of the PRU-ICSS. In addition to all PRU-ICSS features, the PRU\_ICSSG adds two Auxiliary Programmable Real-Time Unit (RTU) cores, two Transmit PRU (TX\_PRU) cores, broadside memories, improved event management with the task manager, data processing and data movement accelerators, and new peripherals such as PWM. + +Devices offering the PRU\_ICSSG capability include AM65x, AM64x and AM243x. + +## 1.3 PRUSS: The Programmable Real-time Unit Subsystem + +The Programmable Real-time Unit Subsystem (PRUSS) consists of dual 32-bit RISC cores (the PRUs), shared data, instruction memories, internal peripheral modules, and an interrupt controller (INTC). The programmable nature of the PRU cores, along with their access to pins, events and all device resources, provides flexibility in implementing fast real-time responses, specialized data handling operations, custom peripheral interfaces, and in offloading tasks from the other processor cores of the device. + +Industrial Communication Subsystem features including Ethernet (MII signals and MDIO signals are not pinned out) are not supported. + +Devices offering the PRUSS capability include AM62x. + +## 1.4 PRU Subsystem Feature Comparison + +Table 1-1 shows a high-level feature of the PRU subsystems.. The subsequent sections show the feature differences between each device that supports the given subsystem flavor. For a more detailed comparison, see the *[PRU-ICSS/PRU\\_ICSSG Migration Guide](https://www.ti.com/lit/pdf/SPRACJ8)*. + +**Table 1-1. PRU Subsystem Feature Comparison** + +| Category | Feature | PRUSS | PRU-ICSS | PRU_ICSSG | +|---|---|---|---|---| +| General PRU Specifications | PRU cores | Yes | Yes | Yes | +| General PRU Specifications | RTU_PRU (Auxiliary PRU) cores | No | No | Yes | +| General PRU Specifications | TX PRU (Transmit PRU) cores | No | No | Yes | +| General PRU Specifications | IRAM (per PRU / RTU_PRU / TX_PRU core) | Yes | Yes | Yes | +| General PRU Specifications | DRAM (2 DRAMs per PRU-ICSS/PRU_ICSSG) | Yes | Yes | Yes | +| General PRU Specifications | Shared DRAM | Yes | Yes | Yes | +| General PRU Specifications | INTC | Yes | Yes | Yes | +| General Purpose Inputs | Direct Input | Yes | Yes | Yes | +| General Purpose Inputs | 16-bit Parallel Capture | Yes | Yes | Yes | +| General Purpose Inputs | 28-bit Shift | Yes | Yes | Yes | +| General Purpose Inputs | 3 Ch. Peripheral Interface (EnDAT) | No | Device dependent | Yes | +| General Purpose Inputs | 9 Ch. Sigma Delta | No | Device dependent | Yes | +| General Purpose Outputs | Direct Output | Yes | Yes | Yes | +| General Purpose Outputs | Shift out | Yes | Yes | Yes | +| Accelerators: Data Processing | MPY/MAC | Yes | Yes | Yes | +| Accelerators: Data Processing | CRC 16/32 | Yes | Device dependent | Yes | +| Accelerators: Data Processing | Scratch Pad | Yes | Yes | Yes | +| Accelerators: Data Processing | IPC Scratch Pad | No | No | Yes | +| Accelerators: Data Processing | Broadside RAM | No | No | Yes | +| Accelerators: Data Processing | BSWAP | No | No | Yes | +| Accelerators: Data Processing | SUM32 | No | No | Yes | +| Accelerators: Data Processing | Task Manager | No | No | Yes | +| Accelerators: Data Processing | Spinlock | No | No | Yes | +| Accelerators: Data Processing | Filter Data Base (FDB) | No | No | Yes | +| Accelerators: Data Movement | XFR2VBUS | Yes | No | Yes | +| Accelerators: Data Movement | PSI TX & RX | No | No | Yes | +| Accelerators: Data Movement | XFR2TR | No | No | Yes | +| Peripherals | UART | Yes | Yes | Yes | +| Peripherals | eCAP | Yes | Yes | Yes | +| Peripherals | IEP | Yes | Yes | Yes | +| Peripherals | MII_RT or MII_G_RT | No | Yes (MII) | Yes (MII/RGMII) | +| Peripherals | MDIO | No | Yes | Yes | +| Peripherals | SGMII | No | No | Device Dependent | +| Peripherals | PWM | No | No | Yes | + +# 2 PRU-ICSS Feature Comparison + +**Table 2-1. PRU-ICSS Feature Comparison** + +| Category | Feature | AM335x (PRU-ICSS1) | AM437x (PRU-ICSS1) | AM437x (PRU-ICSS0) | AM570x (2x PRU-ICSS) | AM571x (2x PRU-ICSS) | AM572x (2x PRU-ICSS) | AM574x (2x PRU-ICSS) | K2G (2x PRU-ICSS) | AM263x (1x PRU-ICSS) | +|---|---|---|---|---|---|---|---|---|---|---| +| General Specifications | Number of PRU cores | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | +| General Specifications | Max Frequency | 200 MHz | 225 MHz (2) | 225 MHz (2) | 200 MHz | 200 MHz | 200 MHz | 200 MHz | 200 MHz | 200 MHz | +| General Specifications | IRAM size (per PRU core) | 8 KB | 12 KB | 4 KB | 12 KB | 12 KB | 12 KB | 12 KB | 16 KB | 12 KB | +| General Specifications | DRAM size (2 DRAMs per PRU-ICSS) | 8 KB | 8 KB | 4 KB | 8 KB | 8 KB | 8 KB | 8 KB | 8 KB | 8 KB | +| General Specifications | Shared DRAM size | 12 KB | 32 KB | 0 KB | 32 KB | 32 KB | 32 KB | 32 KB | 64 KB w/ ECC | 32 KB | +| General Specifications | General Purpose Input (per PRU core) | Direct; or 16-bit parallel capture; or 28-bit shift | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | Direct; or 16-bit parallel capture; or 28-bit shift | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | +| General Specifications | General Purpose Output (per PRU core) | Direct; or Shift out | Direct; or Shift out | Direct; or Shift out | Direct; or Shift out | Direct; or Shift out | Direct; or Shift out | Direct; or Shift out | Direct; or Shift out | Direct; or Shift out | +| General Specifications | GPI Pins (PRU0, PRU1) | 17, 17 | 13, 0 | 20, 20 | 0/21 (3), 21/17 | 0/21 (3), 21/21 | 21, 21 | 21, 21 | 20, 20 | 17, 20 | +| General Specifications | GPO Pins (PRU0, PRU1) | 16, 16 | 12, 0 | 20, 20 | 0/21 (3), 21/17 | 0/21 (3), 21/21 | 21, 21 | 21, 21 | 20, 20 | 17, 20 | +| General Specifications | MPY/MAC | Y | Y | Y | Y | Y | Y | Y | Y | Y | +| General Specifications | Scratchpad | Y (3 banks) | Y (3 banks) | N | Y (3 banks) | Y (3 banks) | Y (3 banks) | Y (3 banks) | Y (3 banks) | Y (3 banks) | +| General Specifications | CRC16/32 | 0 | 2 | 2 | 2 | 2 | 2 (4) | 2 | 2 | 2 | +| General Specifications | INTC | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | +| Peripherals | UART | 1 | 1 | 1 | 1 / not pinned out (5) | 1 | 1 | 1 | 1 | 1 | +| Peripherals | eCAP | 1 | 1 | not pinned out | 1 / not pinned out (5) | 1 | 1 | 1 | 1 | 1 | +| Peripherals | IEP | 1 | 1 | not pinned out | 1 / not pinned out (5) | 1 | 1 | 1 | 1 | 1 | +| Peripherals | MII_RT | 2 | 2 | not pinned out | 2 | 2 | 2 | 2 | 2 | 2 | +| Peripherals | MDIO | 1 | 1 | not pinned out | 1 | 1 | 1 | 1 | 1 | 1 | + +(1) The name PRU-ICSS and PRUSS are used interchangeably throughout the AM57xx and K2G documentation to describe the Programmable Real-Time Unit (PRU) and Industrial Communication Subsystem. + +(2) The default frequency for AM437x is 200 MHz. However, the max frequency 225 MHz is achievable through display PLL CLKOUT. For DSS limitations when configuring this PLL for frequencies >200 MHz, see the *[AM437x Sitara Processors Technical Reference Manual](https://www.ti.com/lit/pdf/SPRUHL7)*. + +(3) AM571x and AM570x PRU-ICSS1 does not pin out the PRU0 core GPIs/GPOs. The other AM571x and AM570x PRU cores (PRU-ICSS1 PRU1, PRU-ICSS2 PRU0, PRU-ICSS2 PRU1) each pin out the number of GPIs/GPOs is listed in Table 2-1. + +(4) AM572x SR1.1 does not have CRC16/32. Within the AM57x family, this feature is only available in AM572x SR2.0, AM571x, and AM570x. + +(5) AM570x PRU-ICSS2 does not pin out these sub-modules. However, they are pinned out on the other AM570x subsystem (PRU-ICSS1). + +# 3 PRU\_ICSSG Feature Comparison + +Table 3-1 summarizes the PRU\_ICSSG features. + +**Table 3-1. PRU\_ICSSG Feature Comparison Across Devices** + +| Category | Feature | AM65x SR1.0 | AM65x SR2.0 | AM64x/AM243x | +|---|---|---|---|---| +| General PRU Specifications | Subsystem type | 3x PRU_ICSSG | 3x PRU_ICSSG | 2x PRU_ICSSG | +| General PRU Specifications | Number of PRU cores | 2 | 2 | 2 | +| General PRU Specifications | Number of RTU_PRU (Auxiliary PRU) cores | 2 | 2 | 2 | +| General PRU Specifications | Number of TX_PRU (Transmit PRU) cores | 0 | 2 | 2 | +| General PRU Specifications | Max Frequency | 250 MHz | 250 MHz | 333 MHz | +| General PRU Specifications | IRAM Size (per PRU / RTU_PRU / TX_PRU core) | 12 KB (w/ ECC) / 8 KB (w/ ECC) / 0 KB | 12 KB (w/ ECC) / 8 KB (w/ ECC) / 6 KB (w/ ECC) | 12 KB (w/ ECC) / 8 KB (w/ ECC) / 6 KB (w/ ECC) | +| General PRU Specifications | DRAM Size (2 DRAMs per PRU_ICSSG) | 8 KB (w/ ECC) | 8 KB (w/ ECC) | 8 KB (w/ ECC) | +| General PRU Specifications | Shared DRAM Size | 64 KB (w/ ECC) | 64 KB (w/ ECC) | 64 KB (w/ ECC) | +| General PRU Specifications | INTC | Yes | Yes | Yes | +| General PRU Specifications | General Purpose Inputs (per PRU core) | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | Direct; or 16-bit parallel capture; or 28-bit shift; or 3 ch EnDat 2.2; or 9 ch Sigma Delta | +| General PRU Specifications | General Purpose Outputs (per PRU core) | Direct or Shift out | Direct or Shift out | Direct or Shift out | +| General PRU Specifications | GPI Pins (PRU0, PRU1) | PRU_ICSSG0: 20/20
PRU_ICSSG1: 20/20
PRU_ICSSG2: 18/18 (1) | PRU_ICSSG0: 20/20
PRU_ICSSG1: 20/20
PRU_ICSSG2: 18/18 (1) | PRU_ICSSG0: 20/20
PRU_ICSSG1: 20/20 | +| General PRU Specifications | GPO Pins (PRU0, PRU1) | PRU_ICSSG0: 20/20
PRU_ICSSG1: 20/20
PRU_ICSSG2: 18/18 (1) | PRU_ICSSG0: 20/20
PRU_ICSSG1: 20/20
PRU_ICSSG2: 18/18 (1) | PRU_ICSSG0: 20/20
PRU_ICSSG1: 20/20 | +| Accelerators: Data Processing | MPY/MAC | Yes | Yes | Yes | +| Accelerators: Data Processing | CRC 16/32 | Yes | Yes | Yes | +| Accelerators: Data Processing | Scratch Pad | Yes (PRU cores: 4 banks, RTU_PRU cores: 2 banks) | Yes (PRU cores: 3 banks, RTU_PRU cores: 3 banks, TX_PRU cores: 2 banks) | Yes (PRU cores: 3 banks, RTU_PRU cores: 3 banks, TX_PRU cores: 2 banks) | +| Accelerators: Data Processing | IPC Scratch Pad | Yes | Yes | Yes | +| Accelerators: Data Processing | Broadside RAM | 4 KB | 2 KB | 2 KB | +| Accelerators: Data Processing | BSWAP | Yes | Yes | Yes | +| Accelerators: Data Processing | SUM32 | Yes | Yes | Yes | +| Accelerators: Data Processing | Task Manager | Yes | Yes | Yes | +| Accelerators: Data Processing | Spinlock | Yes | Yes | Yes | +| Accelerators: Data Processing | Filter Data Base (FDB) | Yes | Yes | Yes | +| Accelerators: Data Movement | XFR2VBUS | Yes | Yes | Yes | +| Accelerators: Data Movement | PSI TX & RX | Yes | Yes | Yes | +| Accelerators: Data Movement | XFR2TR | Yes | Yes | Yes | +| Peripherals | UART | 1 | 1 | 1 | +| Peripherals | eCAP | 1 | 1 | 1 | +| Peripherals | IEP | 2 | 2 | 2 | +| Peripherals | MII_G_RT (MII/RGMII) | 2 | 2 | 2 | +| Peripherals | MDIO | 1 | 1 | 1 | +| Peripherals | SGMII | 2 (PRU_ICSSG2 instance only) | 2 (PRU_ICSSG2 instance only) | No | +| Peripherals | PWM | 12 primary and 12 complimentary outputs | 12 primary and 12 complimentary outputs | 12 primary and 12 complimentary outputs | + +(1) PRG2\_PRU0/1\_GPI/O17 does not have a ball named after it, but it is still muxed out + +## 4 PRUSS Features + +Table 4-1 summarizes the PRUSS features. + +**Table 4-1. PRUSS Features** + +| Category | Feature | AM62x | +|---|---|---| +| General PRU Specifications | Subsystem type | 1x PRUSS | +| General PRU Specifications | Number of PRU cores | 2 | +| General PRU Specifications | Number of RTU_PRU (Auxiliary PRU) cores | 0 | +| General PRU Specifications | Number of TX_PRU (Transmit PRU) cores | 0 | +| General PRU Specifications | Max Frequency | 333 MHz | +| General PRU Specifications | IRAM Size (per PRU / RTU_PRU / TX_PRU core) | 16 KB (w/ ECC) | +| General PRU Specifications | DRAM Size (2 DRAMs per PRU_ICSSG) | 8 KB (w/ ECC) | +| General PRU Specifications | Shared DRAM Size | 32 KB (w/ ECC) | +| General PRU Specifications | INTC | Yes | +| General PRU Specifications | General Purpose Inputs (per PRU core) | Direct; or 16-bit parallel capture; or 28-bit shift; | +| General PRU Specifications | General Purpose Outputs (per PRU core) | Direct; or Shift out | +| General PRU Specifications | GPI Pins (PRU0, PRU1) | 20, 20 | +| General PRU Specifications | GPO Pins (PRU0, PRU1) | 20, 20 | +| Accelerators: Data Processing | MPY/MAC | Yes | +| Accelerators: Data Processing | CRC 16/32 | Yes | +| Accelerators: Data Processing | Scratch Pad | Yes (3 banks) | +| Accelerators: Data Processing | IPC Scratch Pad | No | +| Accelerators: Data Processing | Broadside RAM | No | +| Accelerators: Data Processing | BSWAP | No | +| Accelerators: Data Processing | SUM32 | No | +| Accelerators: Data Processing | Task Manager | No | +| Accelerators: Data Processing | Spinlock | No | +| Accelerators: Data Processing | Filter Data Base (FDB) | No | +| Accelerators: Data Movement | XFR2VBUS | Yes | +| Accelerators: Data Movement | PSI TX & RX | No | +| Accelerators: Data Movement | XFR2TR | No | +| Peripherals | UART | 1 | +| Peripherals | eCAP | 1 | +| Peripherals | IEP | 1 | +| Peripherals | MII_G_RT (MII/RGMII) | No | +| Peripherals | MDIO | No | +| Peripherals | SGMII | No | +| Peripherals | PWM | No | + +## 5 References + +- Texas Instruments: *[AM335x and AMIC110 Sitara™ Processors Technical Reference Manual](https://www.ti.com/lit/pdf/spruh73)* +- Texas Instruments: *[AM437x Sitara Processors Technical Reference Manual](https://www.ti.com/lit/pdf/SPRUHL7)* +- Texas Instruments: *[PRU-ICSS/PRU\_ICSSG Migration Guide](https://www.ti.com/lit/pdf/SPRACJ8)* +- Texas Instruments: *[AM64x/AM243x Technical Reference Manual](https://www.ti.com/lit/pdf/SPRUIM2)* +- Texas Instruments: *[AM65x/DRA80xM Processors Technical Reference Manual](https://www.ti.com/lit/pdf/SPRUID7)* +- Texas Instruments: *[AM62x Sitara Processors Technical Reference Manual](https://www.ti.com/lit/pdf/SPRUIV7)* + +# 6 Revision History + +NOTE: Page numbers for previous revisions may differ from page numbers in the current version. + +| | Changes from Revision F (August 2022) to Revision G (October 2022) | Page | +|---|------------------------------------------------------------------------------------------------|------| +| • | Updated the numbering format for tables, figures and cross-references throughout the document | | +| • | Added AM263x to PRU-ICSS capable devices | | +| • | Added AM243x to PRU_ICSSG capable devices | | +| • | Changed table view to landscape and added AM263x to table | | +| • | Added AM243x device to table and updated table formatting | | + +#### IMPORTANT NOTICE AND DISCLAIMER + +TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATA SHEETS), DESIGN RESOURCES (INCLUDING REFERENCE DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES "AS IS" AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS. + +These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable standards, and any other safety, security, regulatory or other requirements. + +These resources are subject to change without notice. TI grants you permission to use these resources only for development of an application that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited. No license is granted to any other TI intellectual property right or to any third party intellectual property right. TI disclaims responsibility for, and you will fully indemnify TI and its representatives against, any claims, damages, costs, losses, and liabilities arising out of your use of these resources. + +TI's products are provided subject to [TI's Terms of Sale](https://www.ti.com/legal/termsofsale.html) or other applicable terms available either on [ti.com](https://www.ti.com) or provided in conjunction with such TI products. TI's provision of these resources does not expand or otherwise alter TI's applicable warranties or warranty disclaimers for TI products. + +TI objects to and rejects any additional or different terms you may have proposed. IMPORTANT NOTICE + +Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright © 2022, Texas Instruments Incorporated diff --git a/docs_ai/reference/pru_subsystem_migration_guide/pru_subsystem_migration_guide.md b/docs_ai/reference/pru_subsystem_migration_guide/pru_subsystem_migration_guide.md new file mode 100644 index 000000000..fcb385167 --- /dev/null +++ b/docs_ai/reference/pru_subsystem_migration_guide/pru_subsystem_migration_guide.md @@ -0,0 +1,647 @@ + +# PRU-ICSS / PRU\_ICSSG Migration Guide + +#### ABSTRACT + +This migration guide details the PRU-ICSS (Programmable Real-time Unit and Industrial Communication Subsystem) and PRU\_ICSSG (Programmable Real-time Unit and Industrial Communication Subsystem - Gigabit) hardware differences, and outlines software modifications required for porting custom PRU firmware and Arm® code from one Sitara device to another. + +| | Contents | +|--------|--------------------------------------------------------------------| +| 1
2 | Introduction | +| 3 | Porting PRU Software Between Devices | +| 4 | Appendix– Device Hardware Comparison | +| | List of Tables | +| 1 | PRU-ICSS / PRU_ICSSG Base Address Comparison for Global Memory Map | +| 2 | PRU-ICSS / PRU_ICSSG Local Memory Map Comparison | +| 3 | GPI/GPO Mode Comparison | +| 4 | IEP Feature Comparison | +| 5 | MII_RT Feature Comparison | +| 6 | PRU_ICSSG MII and RGMII Feature Comparison | +| 7 | PRU Firmware Checklist | +| 8 | ARM Code Checklist | +| 9 | Comparison of Constant Table MMR Address Mapping | +| 10 | Comparison of Constant Table Peripheral Mapping | +| 11 | Comparison of System Events [159-64] | +| 12 | Comparison of System Events [63-32] | +| 13 | Comparison of System Events [31-0] | +| 14 | Host Interrupt Comparison | + +#### Trademarks + +Arm is a registered trademark of Arm Limited. + +All other trademarks are the property of their respective owners. + +## 1 Introduction + +This document serves as a software migration guide to assist in porting custom software developed for the PRU-ICSS (Programmable Real-time Unit and Industrial Communication Subsystem) and PRU\_ICSSG (Programmable Real-time Unit and Industrial Communication Subsystem - Gigabit) from one Sitara device to another. The specific PRU-ICSS / PRU\_ICSSG devices covered by this guide include: + +- PRU-ICSS: AM335x, AM437x, AM574x, AM572x, AM571x, AM570x, and K2G +- PRU\_ICSSG: AM65x + +For more details about the PRU-ICSS / PRU\_ICSSG on each device, see the PRU-ICSS / PRU\_ICSSG chapter in the device-specific Technical Reference Manual (TRM). + +**NOTE:** The focus of this document is the PRU subsystem and broad market, non-industrial applications. Some ICSS or industrial-specific features may be omitted. **NOTE:** No migration changes are required for software available through the processor SDK. + +## 2 PRU-ICSS / PRU\_ICSSG Hardware Differences + +This section provides a detailed overview of the PRU-ICSS / PRU\_ICSSG hardware differences between different Sitara devices. + +## 2.1 Feature Comparison + +For a high-level feature comparison, refer to the *PRU-ICSS / [PRU\\_ICSSG](http://www.ti.com/lit/pdf/SPRAC90) Feature Comparison* application note. The rest of this guide describes the features outlined in the application note, and provides more details regarding specific differences. + +## 2.2 PRU Core and Clock Comparison + +The PRU\_ICSSG has two auxiliary PRU cores, called RTU\_PRUs. Unless explicitly stated in this guide, the RTU\_PRUs function the same as the PRU cores. + +The default PRU frequency is 200 MHz. However, the maximum frequency varies for each device, as summarized in *PRU-ICSS / [PRU\\_ICSSG](http://www.ti.com/lit/pdf/SPRAC90) Feature Comparison* application note. The PRU\_ICSSG devices add a new Core/VBUS sync mode that lets the PRU cores operate in lock-step with the PRU\_ICSSG interconnect, enabling the lowest latency and highest speed. + +## 2.3 PRU-ICSS / PRU\_ICSSG Memory Map Comparison + +### 2.3.1 PRU-ICSS / PRU\_ICSSG Base Address for Global Memory Map + +The PRU-ICSS / PRU\_ICSSG base address within the SoC memory map differs between devices. Table 1 compares these base addresses, which function as the starting address for the PRU-ICSS / PRU\_ICSSG global memory map. + +**Table 1. PRU-ICSS / PRU\_ICSSG Base Address Comparison for Global Memory Map** + +| | AM335x | AM437x(1) | AM57x | K2G | AM65x | +|---------------------------|-------------|-------------|-------------|----------------|----------------| +| PRU-ICSS0 /
PRU_ICSSG0 | | | | 0x00_20A8_0000 | 0x00_0B00_0000 | +| PRU-ICSS1 /
PRU_ICSSG1 | 0x4A30_0000 | 0x5440_0000 | 0x4B20_0000 | 0x00_20AC_0000 | 0x00_0B10_0000 | +| PRU-ICSS2 /
PRU_ICSSG2 | | | 0x4B28_0000 | | 0x00_0B20_0000 | + +(1) On the AM437x, the base address listed above corresponds to PRU-ICSS1. The PRU-ICSS0 memory map is accessed through the PRU-ICSS1 expansion port (address 0x5444\_0000). + +### 2.3.2 PRU-ICSS / PRU\_ICSSG Local Memory Map + +Table 2 shows the differences between the PRU-ICSS / PRU\_ICSSG local memory map on Sitara devices. To summarize, the memory map is mostly the same across devices, with the exception of new features being added into the memory map. + +**Table 2. PRU-ICSS / PRU\_ICSSG Local Memory Map Comparison** + +| Start
Address | AM335x | AM437x | AM570x | AM571x | AM572x
SR2.0 | AM572x
SR1.1 | AM574x | K2G | AM65x | +|------------------|-----------------------|--------|--------|--------|-----------------|-----------------|--------|---------|---------------------| +| 0x0000_0000 | Data
RAM
0/1 | | | | | | | | | +| 0x0000_2000 | Data
RAM
1/0 | | | | | | | | | +| 0x0000_4000 | Reserved | | | | | | | | | +| 0x0000_8000 | Reserved | | | | | | | | RAT_SLICE0 | +| 0x0000_9000 | Reserved | | | | | | | | RAT_SLICE1 | +| 0x0001_0000 | Shared
Data
RAM | 2 | | | | | | | | +| 0x0002_0000 | INTC | | | | | | | | | +| 0x0002_2000 | PRU0
Control | | | | | | | | | +| 0x0002_3000 | Reserved | | | | | | | | RTU_PRU0
Control | +| 0x0002_3800 | Reserved | | | | | | | | RTU_PRU1
Control | +| 0x0002_4000 | PRU1
Control | | | | | | | | | +| 0x0002_4400 | Reserved | | | | | | | | | +| 0x0002_4C00 | Reserved | | | | | | | | PROTECT | +| 0x0002_6000 | CFG | | | | | | | | | +| 0x0002_7000 | Reserved | | | | | | | ECC_CFG | PA_STATS_QRAM | +| 0x0002_8000 | UART
0 | | | | | | | | | +| 0x0002_A000 | Reserved | | | | | | | | TM_CFG_PRU0 | +| 0x0002_A100 | Reserved | | | | | | | | TM_CFG_RTU0 | +| 0x0002_A200 | Reserved | | | | | | | | TM_CFG_PRU1 | +| 0x0002_A300 | Reserved | | | | | | | | TM_CFG_RTU1 | +| 0x0002_C000 | Reserved | | | | | | | | PA_STATS_CRAM | +| 0x0002_E000 | IEP | | | | | | | | IEP0 | +| 0x0002_F000 | Reserved | | | | | | | | IEP1 | +| 0x0003_0000 | eCAP
0 | | | | | | | | | +| 0x0003_2000 | MII_RT_CFG | | | | | | | | | +| 0x0003_2200 | Reserved | | | | | | | | SGMII0_CFG(1) | +| 0x0003_2400 | Reserved | | | | | | | | SGMII1_CFG(1) | +| 0x0003_2400 | MII_MDIO | | | | | | | | | +| 0x0003_3000 | Reserved | | | | | | | | ICSS_G_CFG | + +(1) On the AM65x, SGMII is only supported on PRU\_ICSSG2. + +#### Table 2. PRU-ICSS / PRU\_ICSSG Local Memory Map Comparison (continued) + +| Start
Address | AM335x | AM437x | AM570x | AM571x | AM572x
SR2.0 | AM572x
SR1.1 | AM574x | K2G | AM65x | +|------------------|----------|------------------------|-------------------|--------|-----------------|-----------------|--------|-----|----------| +| 0x0003_4000 | Reserved | | | | | | | | | +| 0x0004_0000 | Reserved | External
port
to | other
PRU-ICSS | | | | | | Reserved | + +### 2.3.3 PRU-ICSS Submodules Register Content and Offsets + +The register content and offsets of the following PRU-ICSS / PRU\_ICSSG submodules are identical on all devices covered by this guide: + +- PRU-ICSS UART +- PRU-ICSS eCAP + +The register content and offsets of the following PRU-ICSS / PRU\_ICSSG submodules differ between devices: + +- PRU-ICSS IEP +- PRU-ICSS CFG +- PRU-ICSS MII\_RT + +The register content and offsets of the following MMRs are the same between PRU-ICSS devices, but differ between PRU-ICSS and PRU\_ICSSG devices: + +- PRU-ICSS PRU Control +- PRU-ICSS PRU Debug +- PRU-ICSS RTU PRU Control +- PRU-ICSS RTU PRU Debug +- PRU-ICSS INTC +- PRU-ICSS MDIO + +## 2.4 Constant Table Differences + +The PRU-ICSS / PRU\_ICSSG constant table on all devices have 24 entries with fixed addresses and 8 entries with partially programmable entries. However, the addresses and associated peripheral or memory may differ between devices. Refer to Section 4.1 for the full comparison. + +## 2.5 PRU Module Interface to PRU I/O Differences + +The basic functionality and basic structure of R30 and R31 are preserved on all devices. R30 serves as an interface to the GPO pins, and R31 serves as an interface to the GPI pins and INTC status. However, the supported GPI/GPO modes differs between devices. + +**Table 3. GPI/GPO Mode Comparison** + +| | AM335x | AM437x | AM570x | AM571x | AM572x
SR2.0 | AM572x
SR1.1 | AM574x | K2G | AM65x | +|---------------------|--------|--------|--------|--------|-----------------|-----------------|--------|-----|-------| +| Direct Input | √ | √ | √ | √ | √ | √ | √ | √ | √ | +| Parallel
Capture | √ | √ | √ | √ | √ | √ | √ | √ | √ | +| Shift In | √ | √ | √ | √ | √ | √ | √ | √ | √ | +| Direct
Output | √ | √ | √ | √ | √ | √ | √ | √ | √ | +| Shift Out | √ | √ | √ | √ | √ | √ | √ | √ | √ | +| EnDat | | √ | √ | √ | | | √ | √ | √ | +| Sigma
Delta | | √ | √ | √ | | | √ | √ | √ | + +The following GPI/O modes in PRU\_ICSSG devices are upgraded versions of the other PRU-ICSS devices: + +- Direct Output Adds optional bidirectional support, enabled through CTRLMMRs. Backwards compatible with PRU-ICSS devices. +- Shift In Adds configuration options. Backwards compatible with PRU-ICSS devices. +- Shift Out Adds configuration options. Backwards compatible with PRU-ICSS devices. +- EnDat Adds option to configure RX Start Bit polarity (previously fixed to "1"). Backwards compatible with PRU-ICSS devices. +- Sigma Delta Increased counter size and adds Fast Detect logic. Not backwards compatible with PRU-ICSS devices. + +|--| + +## 2.6 Interrupt Controller Differences + +The basic structure of the interrupt controller is the same on all devices. The INTC mapping framework of mapping system events to channels to hosts is also the same. + +All PRU-ICSS devices support the same number of total system events (64, made up of 32 external events and 32 internal events), channels (16), and hosts (10). Section 4.2 shows a detailed comparison of the PRU-ICSS devices; below is an executive summary. + +- The INTC system events from modules inside the PRU-ICSS (System Event 0-31) are similar, but not identical, between devices. See Section 4.2 for the specific differences. +- The INTC system events from external sources (System Event 32-63) differ between devices. See Section 4.2 for the specific differences. +- The INTC host assignment the same for most devices, but differs for AM437x, K2G, and AM65x. See Section 4.2 for the specific differences. +- The ARM interrupt numbers mapped to the PRU-ICSS source interrupts are different between devices. + +All PRU\_ICSSG devices support 160 system events (96 external events and 64 internal events), 20 channels, and 20 hosts. The INTC registers on these devices have been updated to support the increased number of system events. + +## 2.7 Peripheral Differences + +### 2.7.1 PRU-ICSS / PRU\_ICSSG UART + +The PRU-ICSS UART is identical on all PRU-ICSS and PRU\_ICSSG devices. + +### 2.7.2 PRU-ICSS / PRU\_ICSSG eCAP + +The PRU-ICSS eCAP is identical on all PRU-ICSS and PRU\_ICSSG devices. + +### 2.7.3 PRU\_ICSSG PWM + +PRU\_ICSSG devices add a new PWM peripheral. This peripheral is not available on any PRU-ICSS device. + +### 2.7.4 PRU-ICSS / PRU\_ICSSG Industrial Ethernet Peripheral (IEP) + +The PRU-ICSS / PRU\_ICSSG IEP features differ between devices. These feature differences also include updates to the PRU-ICSS / PRU\_ICSSG IEP registers. Table 4 summarizes the IEP features that do not appear on every device. + +**Table 4. IEP Feature Comparison** + +| | AM335x | AM437x | AM570x | AM571x | AM572x
SR1.1 | AM572
SR2.0 | AM574x | K2G | AM65x | +|--------------------------------------------------------------|--------|--------|--------|--------|-----------------|----------------|--------|--------|--------| +| IEP timer bit width | 32-bit | 32-bit | 64-bit | 64-bit | 32-bit | 64-bit | 64-bit | 64-bit | 64-bit | +| Slow compensation
mode | | | √ | √ | | √ | √ | √ | √ | +| Number of compare
registers | 8 | 16 | 16 | 16 | 8 | 16 | 16 | 16 | 16 | +| Programmable reset
value | | √ | √ | √ | √ | √ | √ | √ | √ | +| 32-bit shadow mode | | | | | | | | | √ | +| IEP1 slave mode | | | | | | | | | √ | +| Selectable capture
event source (external
or internal) | | | | | | | | | √ | + +### 2.7.5 PRU-ICSS / PRU\_ICSSG MDIO + +The PRU-ICSS MDIO is identical on all PRU-ICSS devices. However, the peripheral has been updated PRU\_ICSSG. + +### 2.7.6 PRU-ICSS MII\_RT + +The PRU-ICSS MII\_RT features differ between devices. These feature differences also include updates to the PRU-ICSS MII\_RT registers. Table 5 summarizes the features that are only present on select devices. + +**Table 5. MII\_RT Feature Comparison** + +| | AM335x | AM437x | AM570x | AM571x | AM572x
SR1.1 | AM572
SR2.0 | AM574x | K2G | AM65x | +|-----------------------------------------------------|--------|----------|----------|----------|-----------------|----------------|----------|----------|----------| +| TX/RX
FIFO levels
(RXFLV0/1
,
TXFLV0/1) | | 64-bytes | 96-bytes | 96-bytes | 96-bytes | | 96-bytes | 96-bytes | 96-bytes | +| Back to
back 32
and 16 TX
push | | | √ | √ | | √ | √ | √ | √ | +| RX_L2 with
hardware
filter | | | | | | | | | √ | +| TX_L2 pre
emption
FIFO | | | | | | | | | √ | +| RX
classifier
with
ingress
filter | | | | | | | | | √ | +| RGMII
mode | | | | | | | | | √ | +| SGMII
mode | | | | | | | | | √ | + +The PRU\_ICSSG devices add RGMII support. Table 6 summarizes the differences between the MII and RGMII modes in PRU\_ICSSG devices. + +#### Table 6. PRU\_ICSSG MII and RGMII Feature Comparison + +| | MII | RGMII | +|------------------------------------|-----|-------| +| RXIPG0/1 | √ | | +| Odd nibble detection and insertion | √ | | + +## 2.8 Broadside Accelerator Differences + +The PRU-ICSS and PRU\_ICSSG devices support the following broadside accelerators: + +- Scratch Pad: + - The PRU-ICSS Scratch Pad is identical on all PRU-ICSS devices and backwards compatible on PRU\_ICSSG devices. The PRU\_ICSSG devices add a new XCHG instruction, which can be used to combine reads and writes to the Scratch Pad into a single instruction. +- Multiplier with optional Accumulation (MPY/MAC): + - The PRU-ICSS MPY/MAC is identical on AM335x, AM437x, and AM57x. On K2G and AM65x, the carry flag performance was updated. +- CRC module: + - The PRU-ICSS CRC module is identical on all applicable PRU-ICSS devices. See the *[PRU-ICSS](http://www.ti.com/lit/pdf/SPRAC90) / [PRU\\_ICSSG](http://www.ti.com/lit/pdf/SPRAC90) Feature Comparison* for which devices include the CRC modules. + - The PRU\_ICSSG CRC module on AM65x adds the CRC16-CCITT polynomial and FIFO to allow 32-byte pushes. + +The PRU\_ICSSG devices also include additional broadside accelerators and data movement accelerators. See the *PRU-ICSS / [PRU\\_ICSSG](http://www.ti.com/lit/pdf/SPRAC90) Feature Comparison* for the full list of accelerators supported on the PRU\_ICSSG devices. For PRU\_ICSSG devices, TI recommends using the XFR2VBUS and XFR2PSI accelerators for external MMR accesses, instead of LBxO/SBxO, as this minimizes PRU stall cycles. + +## 2.9 Instruction Set and Format Compatibility + +The instruction set and format is identical on all devices, with the following exceptions: + +- New XCHG instruction on PRU\_ICSSG devices +- New Task Swap enable/disable instructions on PRU\_ICSSG devices + +## 3 Porting PRU Software Between Devices + +The software changes required to port PRU code from one Sitara device to another are based on the hardware differences between the two devices. This section details the key differences in software, and describes how code can be modified from one device to another. Additional modifications may be required relating to other SoC differences that are external to the PRU-ICSS / PRU\_ICSSG. Some of these modifications are discussed in the modifying software for SoC-related differences section. + +A checklist of typical changes required for both PRU firmware and ARM code is provided in Table 7 and Table 8. + +## Table 7. PRU Firmware Checklist + +| 1 | PRU addresses within global memory map | +|---|------------------------------------------------------------------------| +| 2 | PRU INTC system event numbers | +| 3 | PRU peripheral registers | +| 4 | PRU accelerator | +| 5 | PRU constant table values | +| 6 | SoC related changes (peripheral addressing or registers, and so forth) | + +## Table 8. ARM Code Checklist + +| 1 | PRU addresses within global memory map | +|---|---------------------------------------------------------------------------------------------------------------------------| +| 2 | PRU INTC system event numbers | +| 3 | SoC related changes (peripheral addressing or registers, pinmux configuration, ARM Interrupt Controller, and
so forth) | + +## 3.1 Updating Global Memory Map References + +When porting software, the PRU-ICSS / PRU\_ICSSG base address must be updated in both the PRU firmware and ARM code. Most PRU firmware code should use the local memory map to reduce latencies and does not require any modification. Only firmware that accesses the global memory map requires updates. No change is required for any offsets within the PRU-ICSS global memory map. + +## 3.2 Configuring PRU INTC System Events + +The PRU INTC on each device has some system event differences. If the existing application uses a system event that has changed, the system events must be updated both in the PRU firmware code and in the interrupt controller mapping in the ARM code. + +If an interrupt used is no longer supported on the device being ported to, one option is to poll or periodically read the peripheral's status register, if it exists. For peripheral details, see the device-specific TRM. There are additional latencies when accessing memories outside the PRU-ICSS / PRU\_ICSSG. + +For AM437x and K2G, the functionality of Host interrupt 7 has changed. Any system events mapped to Host 7 when porting to or from the AM437x should be remapped to Host2-6 or Host8-9. This impacts ARM code and could also impact the PRU firmware (such as if the PRU configures the INTC). + +The ARM interrupt controller has also changed with respect to the interrupt numbers mapped to the PRU-ICSS / PRU\_ICSSG host interrupts. In the ARM code, the user must confirm that IRQs are updated for the new PRU-ICSS / PRU\_ICSSG event numbers. + +## 3.3 Updating PRU Peripheral Registers + +Some PRU-ICSS / PRU\_ICSSG peripheral MMRs have changed between devices. If using one of these peripherals, then the register references must be updated. + +## 3.4 Updating PRU Constant Table References + +Differences in the PRU constant table require changes to the PRU firmware code. The PRU constant table entries are partially backwards compatible, as some peripherals and features maintain the same entry numbers. However, other peripherals and features have been removed, added, or remapped to different entry numbers in the table of the device being ported to. For a comparison between the constant tables on each device, see Section 4.1. + +## 3.5 Modifying Software for SoC-Related Differences + +Each device has additional differences at the SoC level that also require changes in both PRU firmware and ARM code. Below is a list of some key differences that require code updates. This is not an exhaustive list. + +Common differences between devices requiring PRU legacy code updates include: + +- Global device memory map: + - Start addresses of peripherals and features + - Base addresses of modules + - Register addresses and offsets +- Peripherals: + - Supported peripherals and number of instances + - Peripherals may have new memory or register maps. The functionality of registers may also change. +- Pinmuxing + +## 4 Appendix– Device Hardware Comparison + +## 4.1 Constant Table Differences + +Table 9 shows a comparison of the physical MMR address associated with each Constant Table entry, and Table 10 compares the Peripheral and Memory Regions associated with each Constant Table entry. + +**Table 9. Comparison of Constant Table MMR Address Mapping** + +| AM335x / AM437x / AM57x
K2G
AM65x
0
0x0002_0000
0x0002_0000
0x0002_0000
1
0x4804_0000
0x0221_0000
0x0002_F000
2
0x4802_A000
0x0253_0000
0x0002_F100
3
0x0003_0000
0x0003_0000
0x0003_0000
4
0x0002_6000
0x0002_6000
0x0002_6000
5
0x4806_0000
0x2300_0000
0x0002_6100
6
0x4803_0000
0x2180_5400
0x0002_0200
7
0x0002_8000
0x0002_8000
0x0002_8000
8
0x4600_0000
0x2180_4000
0x0002_E100
9
0x4A10_0000
0x0400_0000
0x0003_3000
10
0x4831_8000
0x0250_0000
0x0002_A000 (PRU0)
0x0002_A100 (RTU0)
0x0002_A200 (PRU1)
0x0002_A300 (RTU1)
11
0x4802_2000
0x0253_1000
0x0002_2000 (PRU0)
0x0002_4000 (RTU0)
0x0002_3000 (PRU1)
0x0002_3800 (RTU1)
12
0x4802_4000
0x0253_1400
0x0002_7000
13
0x4831_0000
0x0260_0000
0x0002_C000
14
0x481C_C000
0x0260_B200
0x0002_4800
15
0x481D_0000
0x0260_B400
0x6000_0000
16
0x481A_0000
0x2180_5800
0x7000_0000
17
0x4819_C000
0x0253_0400
0x8000_0000
18
0x4830_0000
0x021D_0000
0x9000_0000
19
0x4830_2000
0x021D_1800
0xA000_0000
20
0x4830_4000
0x000A_E000
0xB000_0000
21
0x0003_2400
0x0003_2400
0x0003_2400
22
0x480C_8000
0x0264_0000
0x0000_8000 (PRU0/RTU0)
0x0000_9000 (PRU1/RTU1)
23
0x480C_A000
0x02A5_0000
0xC000_0000
24
0x0000_0n00, n =
0x0000_0n00, n =
c24_blk_index[3:0]
c24_blk_index[3:0]
25
0x0000_2n00, n =
0x0000_2n00, n =
c25_blk_index[3:0]
c25_blk_index[3:0]
26
0x0000_En00, n =
0x0000_En00, n =
c26_blk_index[3:0]
c26_blk_index[3:0]
27
0x0003_2n00, n =
0x0003_2n00, n =
c27_blk_index[3:0]
c27_blk_index[3:0]
28
0x00nn_nn00, nnnn =
0x00nn_nn00, nnnn =
0x00nn_nn00, nnnn =
c28_pointer[15:0]
c28_pointer[15:0]
c28_pointer[15:0]
29
0x49nn_nn00, nnnn =
0x49nn_nn00, nnnn =
0x0Dnn_nn00, nnnn = | Entry No. | Value [31:0] | | | | | | +|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|--------------|-------------------|--|-------------------------------------|--|--| +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | 0x0000_0n00, n = c24_blk_index[3:0] | | | +| | | | | | 0x0000_2n00, n = c25_blk_index[3:0] | | | +| | | | | | 0x0000_En00, n = c26_blk_index[3:0] | | | +| | | | | | 0x0003_2n00, n = c27_blk_index[3:0] | | | +| | | | | | | | | +| | c29_pointer[15:0] | | c29_pointer[15:0] | | c29_pointer[15:0] | | | +| 30
0x40nn_nn00, nnnn =
0x40nn_nn00, nnnn =
0x0Enn_nn00, nnnn =
c30_pointer[15:0]
c30_pointer[15:0]
c30_pointer[15:0] | | | | | | | | + +#### Table 9. Comparison of Constant Table MMR Address Mapping (continued) + +| Entry No. | Value [31:0] | | | +|-----------|------------------------------------------|------------------------------------------|------------------------------------------| +| | AM335x / AM437x / AM57x | K2G | AM65x | +| 31 | 0x80nn_nn00, nnnn =
c31_pointer[15:0] | 0x80nn_nn00, nnnn =
c31_pointer[15:0] | 0x0Fnn_nn00, nnnn =
c31_pointer[15:0] | + +**Table 10. Comparison of Constant Table Peripheral Mapping** + +| Entry No. | Region Pointed To | | | | +|-----------|-------------------------------------|-------------------------------------|------------------------------------------------|--------------------------------------| +| | AM335x / AM437x | AM57x | K2G | AM65x | +| 0 | PRU-ICSS INTC (local) | PRU-ICSS INTC (local) | PRU-ICSS INTC (local) | PRU_ICSSG INTC (local) | +| 1 | DMTIMER2 | Reserved | TIMER1 | PRU_ICSSG IEP1 (local) | +| 2 | I2C1 | Reserved | I2C0 | PRU_ICSSG IEP1_0x100
(local) | +| 3 | PRU-ICSS eCAP (local) | PRU-ICSS eCAP (local) | PRU-ICSS eCAP (local) | PRU_ICSSG ECAP0
(local) | +| 4 | PRU-ICSS CFG (local) | PRU-ICSS CFG (local) | PRU-ICSS CFG (local) | PRU_ICSSG CFG (local) | +| 5 | MMC0 | I2C3 | MMC0 | PRU_ICSSG CFG_0x100
(local) | +| 6 | MCSPI0 | Reserved | SPI0 | PRU_ICSSG INTC_0x200
(local) | +| 7 | PRU-ICSS UART0 (local) | PRU-ICSS UART0 (local) | PRU-ICSS UART0
(local) | PRU_ICSSG UART0
(local) | +| 8 | McASP0 DMA | MCASP3_DAT | McASP0 DMA | PRU_ICSSG IEP0_0x100
(local) | +| 9 | Ethernet | Reserved | NSSUL | PRU_ICSSG0 CFG (local) | +| 10 | Reserved | Reserved | SEC_MGR | TM_CFG (local task
manager) | +| 11 | UART1 | Reserved | UART1 | PRU_ICSSG PRU/RTU
Control (local) | +| 12 | UART2 | Reserved | UART2 | PRU_ICSSG
PA_STATS_QRAM (local) | +| 13 | Reserved | Reserved | CIC | PRU_ICSSG
PA_STATS_CRAM (local) | +| 14 | DCAN0 | Reserved | DCAN0 CFG | PRU_ICSSG PROTECT
(local) | +| 15 | DCAN1 | Reserved | DCAN1 CFG | Reserved(1) | +| 16 | MCSPI 1 | Reserved | SPI1 | Reserved(1) | +| 17 | I2C2 | Reserved | I2C1 | Reserved(1) | +| 18 | eHRPWM1/eCAP1/ eQEP1 | Reserved | EPWM0 | Reserved(1) | +| 19 | eHRPWM2/eCAP2/ePWM2 | Reserved | ECAP0 | Reserved(1) | +| 20 | eHRPWM3/eCAP3/ePWM3 | Reserved | PRU-ICSS0, PRU
ICSS1 IEP (local) +
256MB | Reserved(1) | +| 21 | PRU-ICSS MDIO (local) | PRU-ICSS MDIO (local) | PRU-ICSS MDIO (local) | PRU_ICSSG MDIO (local) | +| 22 | Mailbox 0 | Reserved | Semaphore | RAT SLICE0/1 (local) | +| 23 | Spinlock | Reserved | Message Manager
Queue Proxy Region5 | Reserved(1) | +| 24 | PRU-ICSS PRU0/1 Data RAM
(local) | PRU-ICSS PRU0/1 Data
RAM (local) | PRU-ICSS PRU0/1 Data
RAM (local) | PRU_ICSSG PRU0/1 Data
RAM (local) | +| 25 | PRU-ICSS PRU1/0 Data RAM
(local) | PRU-ICSS PRU1/0 Data
RAM (local) | PRU-ICSS PRU1/0 Data
RAM (local) | PRU_ICSSG PRU1/0 Data
RAM (local) | +| 26 | PRU-ICSS IEP (local) | PRU-ICSS IEP (local) | PRU-ICSS IEP (local) | PRU_ICSSG IEP (local) | +| | | | | | + +(1) In the AM65x, C15-C20, C23, and C29-C31 can be remapped to any SoC address through the RAT. This can be used to achieve backward compatibility. The AM65x only has 4 RAT regions per PRU\_ICSSG slice, so not all of these constant table entries can be remapped concurrently. + +**Table 10. Comparison of Constant Table Peripheral Mapping (continued)** + +| Entry No. | Region Pointed To | | | | | +|-----------|-----------------------------|--------------------------------|--------------------------------|-------------------------------------------------------|--| +| | AM335x / AM437x | AM57x | K2G | AM65x | | +| 27 | PRU-ICSS MII_RT (local) | PRU-ICSS MII_RT (local) | PRU-ICSS MII_RT
(local) | PRU_ICSSG
MII_RT/SGMII0_CFG/SGM
II1_CFG (local) | | +| 28 | PRU-ICSS Shared RAM (local) | PRU-ICSS Shared RAM
(local) | PRU-ICSS Shared RAM
(local) | PRU_ICSSG Shared RAM
(local) | | +| 29 | TPCC (EDMA) | OCMC_RAM2_CBUF | EDMA_0_CC_CFG | Reserved(1) | | +| 30 | L3 OCMC0 SRAM | OCMC_RAM | MSMC SRAM | Reserved(1) | | +| 31 | EMIF0 DDR Base | EMIF1_SDRAM_CS0 | DDR3A DATA | Reserved(1) | | + +## 4.2 Interrupt Controller Differences + +Table 11 shows a comparison of system events for event numbers 159-64. These are not applicable for the AM335x, AM437x, AM57x, or K2G. + +**Table 11. Comparison of System Events [159-64]** + +| Event Number | AM65x | | | | +|--------------|------------------|------------|------------|--| +| | PRU_ICSSG0 | PRU_ICSSG1 | PRU_ICSSG2 | | +| 159 | GPIOMUX_INT31 | | | | +| 158 | GPIOMUX_INT30 | | | | +| 157 | GPIOMUX_INT29 | | | | +| 156 | GPIOMUX_INT28 | | | | +| 155 | GPIOMUX_INT27 | | | | +| 154 | GPIOMUX_INT26 | | | | +| 153 | GPIOMUX_INT25 | | | | +| 152 | GPIOMUX_INT24 | | | | +| 151 | RESERVED | | | | +| 150 | RESERVED | | | | +| 149 | RESERVED | | | | +| 148 | RESERVED | | | | +| 147 | RESERVED | | | | +| 146 | RESERVED | | | | +| 145 | RESERVED | | | | +| 144 | RESERVED | | | | +| 143 | RESERVED | | | | +| 142 | RESERVED | | | | +| 141 | RESERVED | | | | +| 140 | RESERVED | | | | +| 139 | MCU_MCAN_1_INT_1 | | | | +| 138 | MCU_MCAN_1_INT_0 | | | | +| 137 | MCU_MCAN_0_INT_1 | | | | +| 136 | MCU_MCAN_0_INT_0 | | | | +| 135 | USB_1_INT15 | | | | +| 134 | USB_1_INT14 | | | | +| 133 | USB_1_INT13 | | | | +| 132 | USB_1_INT12 | | | | +| 131 | USB_0_INT15 | | | | +| 130 | USB_0_INT14 | | | | + +**Table 11. Comparison of System Events [159-64] (continued)** + +| Event Number | AM65x | | | +|--------------|--------------------|--------------------|--------------------| +| | PRU_ICSSG0 | PRU_ICSSG1 | PRU_ICSSG2 | +| 129 | USB_0_INT13 | | | +| 128 | USB_0_INT12 | | | +| 127 | GPMC_INT | | | +| 126 | USART_2_INT | | | +| 125 | USART_1_INT | | | +| 124 | USART_0_INT | | | +| | | | | +| 123 | McASP_2_RINT | | | +| 122 | McASP_2_XINT | | | +| 121 | McASP_1_RINT | | | +| 120 | McASP_1_XINT | | | +| 119 | McASP_0_RINT | | | +| 118 | McASP_0_XINT | | | +| 117 | NAVSS_ICSSG0_INT_7 | NAVSS_ICSSG1_INT_7 | NAVSS_ICSSG2_INT_7 | +| 116 | NAVSS_ICSSG0_INT_6 | NAVSS_ICSSG1_INT_6 | NAVSS_ICSSG2_INT_6 | +| 115 | NAVSS_ICSSG0_INT_5 | NAVSS_ICSSG1_INT_5 | NAVSS_ICSSG2_INT_5 | +| 114 | NAVSS_ICSSG0_INT_4 | NAVSS_ICSSG1_INT_4 | NAVSS_ICSSG2_INT_4 | +| 113 | NAVSS_ICSSG0_INT_3 | NAVSS_ICSSG1_INT_3 | NAVSS_ICSSG2_INT_3 | +| 112 | NAVSS_ICSSG0_INT_2 | NAVSS_ICSSG1_INT_2 | NAVSS_ICSSG2_INT_2 | +| 111 | NAVSS_ICSSG0_INT_1 | NAVSS_ICSSG1_INT_1 | NAVSS_ICSSG2_INT_1 | +| 110 | NAVSS_ICSSG0_INT_0 | NAVSS_ICSSG1_INT_0 | NAVSS_ICSSG2_INT_0 | +| 109 | PCIE1_INT13 | | | +| 108 | PCIE1_INT9 | | | +| 107 | PCIE1_INT8 | | | +| 106 | PCIE1_INT3 | | | +| 105 | PCIE1_INT2 | | | +| 104 | PCIE0_INT13 | | | +| 103 | PCIE0_INT9 | | | +| 102 | PCIE0_INT8 | | | +| 101 | PCIE0_INT3 | | | +| 100 | PCIE0_INT2 | | | +| 99 | SPI_3_INT | | | +| 98 | SPI_2_INT | | | +| 97 | SPI_1_INT | | | +| 96 | SPI_0_INT | | | +| 95 | I2C_3_INT | | | +| 94 | I2C_2_INT | | | +| 93 | I2C_1_INT | | | +| 92 | I2C_0_INT | | | +| 91 | ECAP_0_INT | | | +| 90 | EQEP_2_INT | | | +| | | | | +| 89 | EQEP_1_INT | | | +| 88 | EQEP_0_INT | | | +| 87 | EPWM_5_TZ_INT | | | +| 86 | EPWM_4_TZ_INT | | | +| 85 | EPWM_3_TZ_INT | | | +| 84 | EPWM_2_TZ_INT | | | + +**Table 11. Comparison of System Events [159-64] (continued)** + +| Event Number | AM65x | | | | +|--------------|-------------------|-------------------|-------------------|--| +| | PRU_ICSSG0 | PRU_ICSSG1 | PRU_ICSSG2 | | +| 83 | EPWM_1_TZ_INT | | | | +| 82 | EPWM_0_TZ_INT | | | | +| 81 | EPWM_5_INT | | | | +| 80 | EPWM_4_INT | | | | +| 79 | EPWM_3_INT | | | | +| 78 | EPWM_2_INT | | | | +| 77 | EPWM_1_INT | | | | +| 76 | EPWM_0_INT | | | | +| 75 | PWM_SOCB | | | | +| 74 | PWM_SOCA | | | | +| 73 | ICSSG_2_HOST_INT7 | ICSSG_0_HOST_INT7 | ICSSG_1_HOST_INT7 | | +| 72 | ICSSG_2_HOST_INT6 | ICSSG_0_HOST_INT6 | ICSSG_1_HOST_INT6 | | +| 71 | ICSSG_2_HOST_INT5 | ICSSG_0_HOST_INT5 | ICSSG_1_HOST_INT5 | | +| 70 | ICSSG_1_HOST_INT7 | ICSSG_2_HOST_INT7 | ICSSG_0_HOST_INT7 | | +| 69 | ICSSG_1_HOST_INT6 | ICSSG_2_HOST_INT6 | ICSSG_0_HOST_INT6 | | +| 68 | ICSSG_1_HOST_INT5 | ICSSG_2_HOST_INT5 | ICSSG_0_HOST_INT5 | | +| 67 | MCU_ADC_1_INT | | | | +| 66 | MCU_ADC_0_INT | | | | +| 65 | IPC_INT21 | IPC_INT23 | IPC_INT25 | | +| 64 | IPC_INT20 | IPC_INT22 | IPC_INT24 | | + +## Table 12. Comparison of System Events [63-32] + +| Event Number | AM335x AM437x | | AM57x | K2G | | MII_RT Mode | AM65x | | +|---------------------|-----------------------------------|-------------------------------|-------------------------------|-------------------------|-------------------------------|-------------------------------|-------------------------------------------|------------------------------------------------| +| | PRU-ICSS | PRU-ICSS1 | PRU-ICSS0 | PRU-ICSS1 and PRU-ICSS2 | PRU-ICSS1 | PRU-ICSS0 | for all PRU-
ICSS devices | All PRU_ICSSG instances | +| 63 | TPCC (EDMA) - tpcc_int_pend_po1 | | | | EDMACC_1
Region 6 | EDMACC_1 Region 7 | | PRU_ICSSG - Any sd_fd_zero/one_m ax/min(of 72) | +| 62 | TPCC (EDMA) - tpcc_errint_pend_po | | | | EDMACC_0
Region 6 | EDMACC_0 Region 7 | | PRU_ICSSG - iep1_sync0_uint_in tr_pend | +| 61 | TPTC0 (EDMA) - tptc_erint_pend_po | | | | MSGMGR - Que
59 | MSGMGR - Que 61 | | PRU_ICSSG - iep1_sync1_uint_in tr_pend | +| 60 | Mailbox0 - mail_u1_irq | | | | MSGMGR - Que
58 | MSGMGR - Que 60 | | PRU_ICSSG - iep1_latch0_uint_in tr_pend | +| 59 | Mailbox0 - mail_u2_irq | | | | MSGMGR - Que 7 | MSGMGR - Que 9 | | PRU_ICSSG - iep1_latch1_uint_in tr_pend | +| 58 | Debugss | | | | MSGMGR - Que 6 | MSGMGR - Que 8 | | PRU_ICSSG - iep1_pdi_wd_exp_ pend | +| 57 | GPIO0 | eHRPWM0-2 Trip
Zone | eHRPWM3-5 Trip
Zone | | BOOT_CFG -
IPC_GR12 | BOOT_CFG -
IPC_GR14 | | PRU_ICSSG - iep1_pd_wd_exp_p end | +| 56 | eHRPWM0-2 Trip
Zone | PRU-ICSS0 Host
Interrupt 7 | PRU-ICSS1 Host
Interrupt 7 | | PRU-ICSS0 Host
Interrupt 7 | PRU-ICSS1 Host
Interrupt 7 | | PRU_ICSSG - iep1_any_cmp_cap _pend | +| 55 | McASP0 TX | | | | IPC_GR11 I | BOOT_CFG -
IPC_GR13 | (*_mii1_col & *_mii1_txen) (external pin) | | +| 54 | McASP0 RX | | | | | PWM_SOCB | PRU1_RX_EOF | | +| 53 | ADC_TSC | | | | CIC - Host Interrupt
101 | PWM_SOCA | MDIO_MII_LINK[1] | | +| 52 | UART2 | | | | CIC - Host Interrup
100 | CIC - Host Interrupt 87 | PORT1_TX_OVERFLOW | | +| 51 | UART0 | | | | CIC - Host Interrupt
99 | CIC - Host Interrupt 86 | PORT1_TX_UN | IDERFLOW | +| 50 | CPSW (c0_rx_thresh_pen d) | CPSW (c2_rx_thresh_pen d) | CPSW (c2_rx_thresh_pen d) | | CIC - Host Interrupt
98 | CIC - Host Interrupt 85 | PRU1_RX_OVE | ERFLOW | + +## Table 12. Comparison of System Events [63-32] (continued) + +| Event Number | AM335x | AM437x | | AM57x | K2G | | MII_RT Mode | AM65x | +|--------------|---------------------|---------------------|------------------------|---------------------------------------------------|----------------------------|--------------------------------------|------------------------------------------|-------------------------| +| | PRU-ICSS | PRU-ICSS1 | PRU-ICSS0 | PRU-ICSS1 and PRU-ICSS2 | PRU-ICSS1 | PRU-ICSS0 | for all PRU-
ICSS devices | All PRU_ICSSG instances | +| 49 | CPSW (c0_rx_pend) | CPSW (c2_rx_pend) | CPSW (c0_rx_pend) | System event sources are | CIC - Host Interrupt
97 | CIC - Host Interrupt 84 | PRU1_RX_NIBBLE_ODD | | +| 48 | CPSW (c0_tx_pend) | CPSW (c2_tx_pend) | CPSW (c0_tx_pend) | configurable
through the AM57x
IRQ_CROSSBAR | CIC - Host Interrupt
96 | CIC - Host Interrupt 83 | PRU1_RX_CRC | | +| 47 | CPSW (c0_misc_pend) | CPSW (c2_misc_pend) | CPSW (c0_misc_pend) | _ III.Q_GITGGGD/III | CIC - Host Interrupt
95 | CIC - Host Interrupt 82 | PRU1_RX_SOF | | +| 46 | eHRPWM1 | eHRPWM1 | eHRPWM4 | | CIC - Host Interrupt
94 | CIC - Host Interrupt 81 | PRU1_RX_SFD | | +| 45 | eQEP0 | | | | CIC - Host Interrupt
93 | nterrupt CIC - Host Interrupt 80 PRU | | 32 | +| 44 | McSPI0 | | | | CIC - Host Interrupt
92 | eQEP2 | PRU1_RX_ERR | | +| 43 | eHRPWM0 | eHRPWM0 | eHRPWM3-5 Trip
Zone | | CIC - Host Interrupt
91 | eQEP1 | (*_mii0_col & *_mii0_txen) (externa pin) | | +| 42 | eCAP0 | | | | CIC - Host Interrupt
90 | eQEP0 | PRU0_RX_EOF | | +| 41 | I2C0 | | | | CIC - Host Interrupt
89 | EPWM3 TZ | MDIO_MII_LINK[0] | | +| 40 | DCAN0 (dcan_intr) | | | | CIC - Host Interrupt
88 | C - Host Interrupt | PORT0_TX_OVERFLOW | | +| 39 | DCAN0 (dcan_int1) | | | | CIC - Host Interrupt
83 | upt ePWM5 PORT0_T | | IDERFLOW | +| 38 | DCAN0 (dcan_uerr) | | | | CIC - Host Interrupt
82 | ePWM4 | PRU0_RX_OVE | ERFLOW | +| 37 | eHRPWM2 | eHRPWM2 | eHRPWM5 | | CIC - Host Interrupt
81 | ePWM3 | PRU0_RX_NIB | BLE_ODD | +| 36 | eCAP2 | | | | CIC - Host Interrupt
80 | ePWM2 | PRU0_RX_CRO | 2 | +| 35 | eCAP1 | | | | I2C0 ePWM1 | | PRU0_RX_SOF | | +| 34 | McASP1 RX | ADC1 (Mag Card) | ADC1 (Mag Card) | | SPI1 (level 0) | ePWM0 | PRU0_RX_SFC | ) | +| 33 | McASP1 TX | QSPI | QSPI | | SPI0 (level 0) | eCAP1 | PRU0_RX_ERF | R32 | +| 32 | UART1 | ART1 | | | QSPI eCAP0 | | PRU0_RX_ERR | | + +#### Table 13. Comparison of System Events [31-0] + +| Event Number | AM335x, AM437x, AM57x | K2G, AM65x | | | | +|--------------|--------------------------------------------------------|--------------------------------------|--|--|--| +| 31 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[15]_intr_req | | | | | +| 30 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[14]_intr_req | | | | | +| 29 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[13]_intr_req | | | | | +| 28 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[12]_intr_req | | | | | +| 27 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[11]_intr_req | | | | | +| 26 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[10]_intr_req | | | | | +| 25 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[9]_intr_req | | | | | +| 24 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[8]_intr_req | | | | | +| 23 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[7]_intr_req | | | | | +| 22 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[6]_intr_req | | | | | +| 21 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[5]_intr_req | | | | | +| 20 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[4]_intr_req | | | | | +| 19 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[3]_intr_req | | | | | +| 18 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[2]_intr_req | | | | | +| 17 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[1]_intr_req | | | | | +| 16 | PRU-ICSS(G) PRU0 or PRU1 - pru_mst_intr[0]_intr_req | | | | | +| 15 | PRU-ICSS(G) eCAP - ecap_intr_req | | | | | +| 14 | PRU-ICSS(G) IEP - sync0_out_pend | | | | | +| 13 | PRU-ICSS(G) IEP - sync1_out_pend | | | | | +| 12 | PRU-ICSS(G) IEP - latch0_in (input to PRU-ICSS) | | | | | +| 11 | PRU-ICSS(G) IEP - latch1_in (input to PRU-ICSS) | | | | | +| 10 | PRU-ICSS(G) IEP - pdi_wd_exp_pend | | | | | +| 9 | PRU-ICSS(G) IEP - pd_wd_exp_pend | | | | | +| 8 | PRU-ICSS(G) IEP - digio_event_req | | | | | +| 7 | PRU-ICSS(G) IEP - iep_tim_cap_cmp_pend | | | | | +| 6 | PRU-ICSS(G) UART - uart_uint_intr_req | | | | | +| 5 | PRU-ICSS(G) UART - uart_utxevt_intr_req | | | | | +| 4 | PRU-ICSS(G) UART - uart_urxevt_intr_req | | | | | +| 3 | PRU-ICSS(G) Scratch Pad - xfr_timeout | | | | | +| 2 | PRU-ICSS(G) PRU1 Shift Capture - pru1_r31_status_cnt16 | | | | | +| 1 | PRU-ICSS(G) PRU0 Shift Capture - pru0_r31_status_cnt16 | | | | | +| 0 | PRU-ICSS Parity Logic - parity_err_intr_pend | PRU-ICSS(G) ECC Logic - ecc_err_intr | | | | + +#### Table 14. Host Interrupt Comparison + +| | AM335x / AM57x | AM437x / K2G | AM65x | | | | +|-------------------|-------------------------------------------------|----------------------------------------------|-------------------------------------------------|--|--|--| +| Host 1 | PRU0/1 R31 bit 30 | | | | | | +| Host 2 | PRU0/1 R31 bit 31 | | | | | | +| Host 3 - Host 6 | | Device level (i.e. ARM) interrupt controller | | | | | +| Host 7 | Device level (i.e. ARM) interrupt
controller | Other PRU-ICSS | Device level (i.e. ARM) interrupt
controller | | | | +| Host 8 - Host 9 | Device level (i.e. ARM) interrupt controller | | | | | | +| Host 10 | N/A | RTU_PRU0/1 R31 bit 30 | | | | | +| Host 11 | N/A | RTU_PRU0/1 R31 bit 31 | | | | | +| Host 12 - Host 19 | N/A | Task Manager | | | | | + +## IMPORTANT NOTICE AND DISCLAIMER + +TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATASHEETS), DESIGN RESOURCES (INCLUDING REFERENCE DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES "AS IS" AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS. + +These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable standards, and any other safety, security, or other requirements. These resources are subject to change without notice. TI grants you permission to use these resources only for development of an application that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited. No license is granted to any other TI intellectual property right or to any third party intellectual property right. TI disclaims responsibility for, and you will fully indemnify TI and its representatives against, any claims, damages, costs, losses, and liabilities arising out of your use of these resources. + +TI's products are provided subject to TI's Terms of Sale ([www.ti.com/legal/termsofsale.html\)](http://www.ti.com/legal/termsofsale.html) or other applicable terms available either on [ti.com](http://www.ti.com) or provided in conjunction with such TI products. TI's provision of these resources does not expand or otherwise alter TI's applicable warranties or warranty disclaimers for TI products. + +> Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright © 2018, Texas Instruments Incorporated \ No newline at end of file diff --git a/docs_ai/task_create_project.md b/docs_ai/task_create_project.md new file mode 100644 index 000000000..caaca3d05 --- /dev/null +++ b/docs_ai/task_create_project.md @@ -0,0 +1,271 @@ +# Task: Create a New OpenPRU Project from Scratch + +## How to run this task + +Before starting: + +1. Read the Pre-read list below. +2. Answer D1–D3 and record the answers — plus the Do-not-do constraints — in a + "Run parameters" note you keep visible. Every section below branches on the + answers; V5 checks the constraints held. +3. Turn each `- [ ]` item in the sections your D1–D3 answers select into + tracked work: + - If your environment provides a task or to-do tracking tool, create one + tracked item per checkbox and mark each done as you complete it. + - Otherwise, copy the relevant checklist into your first response and + re-post it with items marked `[x]` as you finish them. + Either way, your first response must show the materialized list — the tool's + items or the pasted checklist — so tracking is visible before any step runs. +4. A checkbox with sub-bullets is done only when every sub-bullet is done. +5. Do the steps in order; later sections depend on earlier outputs. Do not skip + an item because it "looks unnecessary." If an item is N/A given your D1–D3 + answers, mark it N/A with a one-line reason. + +## Pre-read list + +Read these files before starting: + +1. `docs/open_pru_create_new_project.md` — authoritative step-by-step guide + If the project includes MCU+ code (see Step D1): + also read `docs/open_pru_create_new_mcuplus_project.md` +2. `docs/open_pru_organization.md` — repo layout and project structure +3. `best_practices.md` — coding standards +4. An existing similar project as a structural reference. Two empty starting + projects are available: + - `examples/empty` — PRU firmware in assembly + - `examples/empty_c` — PRU firmware in C or mixed C and assembly + Both include `mcuplus/` directories. Choose based on firmware language. + +## Decision tree + +**Step D1. Which host interface does the project use?** + +- MCU+ R5F host → project needs `firmware/` and `mcuplus/` directories +- Linux A53 host → project needs `firmware/` and `linux/` directories +- Both MCU+ and Linux → project needs `firmware/`, `mcuplus/`, and `linux/` +- PRU standalone (no host) → project needs `firmware/` only + +**Step D2. Which devices and boards will the project support?** + +Valid device identifiers: am243x, am261x, am263px, am263x, am62x, am64x. +Board suffix variants (device-dependent): -evm, -lp, -cc, -som. +→ List all `-` combinations before starting. +→ For each combination, identify the PRU cores needed. Potential cores per-processor: + - PRU_ICSSG (AM243x, AM64x): pru0, pru1, rtu_pru0, rtu_pru1, tx_pru0, tx_pru1 + - PRU-ICSSM (AM263x, AM261x, AM263Px): pru0, pru1 + - PRUSS (AM62x): pru0, pru1 +→ Ask the user whether the new project will use signal I/O — direct R30/R31 + register access, I2C, SPI, UART, I2S, ADC, GPIO, or other peripheral or + physical pin connections. If yes, note that pin routing is a required + manual step — for MCU+ projects via `example.syscfg` (see B5); for Linux + projects via device tree files. Do not attempt to configure it. + +**Step D3. Is this a PR submission to the main branch?** + +- Yes: complete all sections including Section D (documentation). +- No (private use): Sections A–C are required; Section D is recommended. + +→ Record your D1, D2, and D3 answers before proceeding to Section A. + +--- + +## Section A: Copy and rename the starting project + +- [ ] A1. Choose a starting project. Two empty baselines are available: + `examples/empty` (PRU assembly) and `examples/empty_c` (PRU C or mixed C/assembly). + Use an existing project with a similar structure if one exists. + See `docs/open_pru_create_new_project.md` §"Copy existing project". +- [ ] A2. Copy the starting project to the new location: + `cp -r / /` + where `` is `examples/` or `academy//` as appropriate. +- [ ] A3. Remove board/device directories not needed by the new project. + Remove from both `firmware/` and `mcuplus/` (or `linux/`). +- [ ] A4. Find and replace the old project name throughout all copied files. + Key locations: + - Project `makefile`: `PROJECT_NAME`, `PRU_DEPENDENCIES`, + `NON_PRU_DEPENDENCIES`, all board/device target names + - All `ti-pru-cgt/makefile` files: output file names, include paths + - All `ti-pru-cgt/example.projectspec` files: `name=` attribute, all paths + - All `ti-arm-clang/makefile` and `example.projectspec` files (if MCU+) + +- [ ] A5. Checkpoint before customizing. Present the copied, renamed skeleton + (the directory layout and the renamed makefile/projectspec names) and confirm + it matches your recorded D1/D2 scope — the intended host directories, device + and board list, and cores. Fix any interpretation error now, before Section + B; a wrong skeleton propagates into every step that follows. + +--- + +## Section B: Customize the makefiles + +See `docs/open_pru_create_new_project.md` §"Customize the makefiles" for the +authoritative reference. Key items for each file type: + +- [ ] B1. Project `makefile`: + - Set `PROJECT_NAME`. + - Set `SUPPORTED_PROCESSORS` to the device list from Step D2. + - Verify `PRU_DEPENDENCIES` and `NON_PRU_DEPENDENCIES` are correct. + - Update the include path for `imports.mak` (count `../` levels from the + project directory to the repo root). + +- [ ] B2. Each PRU core makefile (`ti-pru-cgt/makefile`): + See `docs/open_pru_create_new_project.md` §"Customize the core makefiles". Key items: + - Update the include path for `imports.mak` (same folder-depth rule as the + project `makefile`). + - Update `OUTPUT_NAME` to match the new project name. + - For MCU+ projects: update `MCU_HEX_NAME`, `HEX_ARRAY_PREFIX`, and + `MCU_HEX_PATH` to point to the new project's firmware board directory. + - For projects without an MCU+ host (Linux host or standalone PRU): only + `OUTPUT_NAME` requires updating; `MCU_HEX_PATH` is not used by any host + project. In `example.projectspec`, leave `postBuildStep` empty or omit it. + - If source files are in a new directory: add that directory to `FILES_PATH`. + `pru_rules.mak` auto-discovers all `.asm` and `.c` files in each listed + directory — there is no separate `ASMFILES` or `CFILES` to update. + - For additional include paths beyond the defaults: append to `INCLUDE` after + the `pru_rules.mak` include. + +- [ ] B3. Each MCU+ core makefile (`ti-arm-clang/makefile`, if MCU+): + See `docs/open_pru_create_new_mcuplus_project.md` + §"Customize the core makefiles (MCU+ side)". Key items: + - If the source came from the MCU+ SDK: replace the `MCU_PLUS_SDK_PATH` + `imports.mak` include with the `OPEN_PRU_PATH` pattern (same folder-depth + rule as the project `makefile`). + - If the source came from another OpenPRU project: update the `OPEN_PRU_PATH` + depth in the existing include. + - Add `${OPEN_PRU_PATH}/source` and the PRU firmware board path to + `INCLUDES_common`. + - Update `FILES_common` to list the actual source files for the new project. + +- [ ] B4. Parent directory `makefile`: + - Add the new project to the appropriate target list so it builds from the + top level. Pattern: copy an existing project entry from the same makefile. + - For `academy/` projects under a topic subdirectory, the entry in + `academy/makefile` uses the topic-relative path `/` (for + example, `uart/uart_echo`), not just ``. There is no intermediate + per-topic `makefile` in the academy directory. + +- [ ] B5. Select and copy a starting-point `example.syscfg`: + - **Skip this step if D1 identified a Linux-only or standalone PRU host.** + Those project types do not use `example.syscfg`. For Linux projects, + pin routing is configured in device tree files (outside the scope of + this runbook). For standalone PRU projects, no host-side configuration + file is needed. If D2 identified signal I/O for either of these project + types, inform the user that pin routing must be configured separately. + - Glob for `example.syscfg` files in the repo under paths matching the + target device/board. Include the appropriate empty project as the + default: `examples/empty` for assembly firmware, `examples/empty_c` + for C or mixed firmware. + - Present the list to the user: "Which of these syscfg files should I + use as a starting point? The empty project is the default." + - Copy the chosen syscfg into the new project's board directory. + - Inform the user: "I copied `example.syscfg` from [chosen project]. + It has not been modified." + - If no syscfg exists for the target device/board, stop and inform the + user: "No existing `example.syscfg` found for [device/board]. You + will need to create one from scratch in SysConfig." + - The following items in `example.syscfg` require manual review in + SysConfig — do not attempt to edit them: + - Device string and memory regions (verify they match the target device) + - I/O pin routing: if the project uses signal I/O (confirmed in D2), + configure pin routing for each target board + - PRUICSS instance: verify the subsystem type, instance number, and + interrupt routing are correct for the target device + +--- + +## Section C: Write the firmware + +- [ ] C1. Start with the correct file structure from `best_practices.md`: + - **Assembly firmware**: use §"File Structure and Organization" — + copyright header, `.retain`, `.retainrefs`, `.global main`, + `.sect ".text"`, register structure definitions, main entry point. + - **PRU C firmware**: use §"PRU C Firmware Best Practices — File Structure" — + copyright header, `void main(void)` entry point, `__halt()` at exit. + +- [ ] C2. Document all macros and functions before implementing them + (NaturalDocs format — see `best_practices.md` §"Function/Macro + Documentation"): + - Pseudo code + - PEAK cycles + - Registers modified + +- [ ] C3. After the first successful build, check the linker map file to + confirm the `.out` size fits within instruction memory. + +- [ ] C4. For host code (R5F MCU+), follow patterns from `best_practices.md` + §"C Code Best Practices (MCU+ Host Cores)": + - Check all API return values with `DebugP_assert` + - Write shared memory data before the command/flag field + - Clean up all resources on error paths + +--- + +## Section D: Documentation and PR requirements + +- [ ] D1. Create `README.md` in the project root directory. Required content: + - Overview of what the project does + - Exact hardware used (board name and board revision number) + - Exact SDK and tool versions validated on hardware + (for example: AM64x MCU+ SDK 11.0, CCS v12.8.1) + - Step-by-step instructions to run the project and validate the outputs. + Do not include generic build and load steps (CCS import, build, launch + debug session, load `.out` file) — those are covered by the PRU Getting + Started Labs. Include only steps specific to this project: pre-run data + setup, which core(s) to use, required run order, and expected output + validation. + +- [ ] D2. Verify the project builds from the project directory and from the + repo top level. See `docs/contributing.md` §"Testing the build" + for the exact commands. + +- [ ] D3. Verify CCS import and build succeed without errors. + +- [ ] D4. Update `academy/readme.md` or `examples/readme.md`: + - Add a 1–2 sentence description under the appropriate heading in the + `## Projects` section. + - Add a row to the `## Supported processors per-project` table. + See `docs/contributing.md` §"Update the section-level readme" for the + exact format of both. + +--- + +## Verification steps + +- [ ] V1. From the project directory: `make -s clean && make` + Paste the actual command output (not a summary). Expected: no errors; + all expected output files generated. +- [ ] V2. From the repo root: `make -s clean && make -s` + Paste the actual command output. Expected: new project is included and + builds without errors. +- [ ] V3. In CCS: import `example.projectspec`, build PRU firmware first, + then R5F (if present). Paste the CCS build console output. Expected: no + errors or warnings about missing files. +- [ ] V4. Confirm `README.md` covers all items in Section D1. List the + headings present so the coverage is visible. +- [ ] V5. Confirm each Do-not-do constraint recorded in your run parameters + held. State the outcome for each — a result that builds can still violate one. + +--- + +## Do-not-do list + +- Do not create a new project without copying an existing one. The build + infrastructure has many interdependent patterns that are easier to replicate + than to reconstruct from scratch. +- Do not submit a PR without a `README.md` that meets the Section D1 + requirements. +- Do not use TODO markers — use FIXME (see `best_practices.md`). +- Do not add the project to the parent `makefile` before the project-level + build succeeds. A broken entry will fail the top-level CI build. +- Do not hard-code absolute paths. Use `$(OPEN_PRU_PATH)` for repo-relative + paths and the `imports.mak` include pattern for tool paths. +- Do not commit build output directories (`debug/`, `release/`). +- Do not retry a failing build indefinitely or invent a workaround. After a few + fix attempts, stop and report the failure with its output. +- Do not guess portability table values when updating `academy/readme.md` or + `examples/readme.md`. If compatibility for a device is not known from + observed sources, mark the entry with a FIXME, then ask the user. +- Do not edit `example.syscfg` pin routing, PRUICSS configuration, or + device settings — not even with user-provided values. Copy a + starting-point syscfg and flag all SysConfig configuration as manual + steps for the user. diff --git a/docs_ai/task_port_project.md b/docs_ai/task_port_project.md new file mode 100644 index 000000000..a21cd2703 --- /dev/null +++ b/docs_ai/task_port_project.md @@ -0,0 +1,257 @@ +# Task: Port an Existing Project to a New Device or Board + +## How to run this task + +Before starting: + +1. Read the Pre-read list below. +2. Work through the Decision tree and record your answers — D1–D3, the + Npru/N-hw/N-sw/I/O findings, the section it routes you to, and the Do-not-do + constraints — in a "Run parameters" note you keep visible. Later sections + branch on the answers; V6 checks the constraints held. +3. Turn each `- [ ]` item in the section your answers select into tracked + work: + - If your environment provides a task or to-do tracking tool, create one + tracked item per checkbox and mark each done as you complete it. + - Otherwise, copy the relevant checklist into your first response and + re-post it with items marked `[x]` as you finish them. + Either way, your first response must show the materialized list — the tool's + items or the pasted checklist — so tracking is visible before any step runs. +4. A checkbox with sub-bullets is done only when every sub-bullet is done. +5. Do the steps in order; later steps depend on earlier outputs. Do not skip an + item because it "looks unnecessary." If an item is N/A for your port, mark + it N/A with a one-line reason. + +## Pre-read list + +Read these files before starting. Do not skip based on familiarity. + +1. `docs/open_pru_organization.md` — repo layout and project structure +2. The project's existing `makefile` — understand current `SUPPORTED_PROCESSORS` +3. The project's existing `firmware///ti-pru-cgt/makefile` for an + existing device/board — understand the build patterns to replicate +4. `academy/readme.md` or `examples/readme.md` §"Supported processors per-project" + — check portability status of the project before assessing manually + +## Decision tree + +**Step D1. Is the target device in this repo's supported list?** + +Check `imports.mak` (or `imports.mak.default`) for valid `DEVICE` values. +→ If not supported: stop. The device is not supported by this repo. + +**Step D2. New board variant for the same device, or a different device?** + +- Same device, new board (for example, am64x-evm → am64x-lp): + → Go to Section A (board-only port). +- Different device (for example, am64x → am243x): + → Go to Section B (device port). Complete Step D3 first. + +**Step D3. Is the project compatible with the target device?** + +First, check the portability table in `academy/readme.md` or `examples/readme.md` +(§"Supported processors per-project"). The table uses these codes: +- **Y** / **Yport**: already supported or can be ported +- **Npru**: PRU subsystem on the target device lacks features the project needs +- **N-hw**: project depends on SoC hardware not present on the target device +- **N-sw**: project's non-PRU software is not compatible with the target device + +If the table covers the source→target combination, use it as your answer and +proceed or stop accordingly. If the project is not in the table, assess each +dimension below. + +**Npru — PRU subsystem compatibility:** +Grep the firmware source for: `XFR`, `xfer`, `RTU`, `TX_PRU`, `xin`, `xout`. +- Found: verify the target device's PRU subsystem supports those features. + - PRU_ICSSG (has RTU_PRU, TX_PRU, accelerators): AM243x, AM64x + - PRU-ICSSM (PRU0/PRU1 only): AM261x, AM263x, AM263Px + - PRUSS (PRU0/PRU1 only): AM62x + - Feature-by-feature comparison: TI app note + [PRU Subsystem Features Comparison](https://www.ti.com/lit/sprac90). + - If the project uses PRU_ICSSG-only features and the target is PRU-ICSSM or + PRUSS → Npru: stop. + +**N-hw — SoC hardware compatibility:** +Identify which SoC peripherals the project uses (SPI, I2C, ADC, LCD, specific +memory interfaces, etc.). Verify those peripherals exist on the target SoC. If +a required peripheral is absent → N-hw: stop or substitute. + +**N-sw — Non-PRU software compatibility:** +Check whether the project's host code assumes MCU+ (R5F) or Linux (A53). +- AM62x uses Linux on A53 and does not support MCU+ R5F host code. +- Projects with hard real-time host requirements may not be compatible with Linux. +- If the host code needs significant rework → N-sw: new host code is required + alongside the PRU firmware port. + +**I/O — Signal I/O and pinmux:** +Pin routing is board-specific and must not be copied from the source project +to a different board. Before proceeding, detect whether the project uses +signal I/O, then ask the user to confirm whether pin routing needs +reconfiguring for the target board. + +Detection — run all of the following: +- PRU firmware (assembly and C): grep for `r30`/`R30` and `r31`/`R31`. + Reads and writes to R30/R31 indicate the PRU is using its I/O interface, + but do not indicate which entity (PRU or host) configures the pinmux. + Also grep for peripheral driver calls and direct peripheral register + access (I2C, SPI, UART, I2S, ADC, GPIO expanders, and similar) in both + assembly and C source files across the entire project. +- MCU+ host: check `example.syscfg` for PRU GPIO signal assignments or + other pin mux configuration. +- Linux host: check for devicetree source files (`.dts`, `.dtsi`, `.dtbo`) + that configure pin mux for the PRU subsystem. + +After running detection, summarize findings and ask the user: +"This project appears to use signal I/O based on [evidence]. Please confirm +whether pin routing must be reconfigured for the target board." + +→ I/O confirmed by user: flag `example.syscfg` pin routing as a required + manual step. The syscfg selection in Section A/B will copy a starting-point + file; the user must configure pin routing in SysConfig afterward. +→ No I/O: no pin routing work needed. + +→ If all three pass: proceed to Section B. +→ If any block: do not proceed without resolving or explicitly scoping the blocker. + +→ Record your D1–D3 answers and the Npru/N-hw/N-sw/I/O findings before + proceeding to Section A or B. + +--- + +## Section A: Board-only port (same device family) + +- [ ] A1. Identify an existing board directory to copy: + `firmware//` +- [ ] A2. Copy it to `firmware//`. Preserve the core subdirectory + names (for example, `icss_g0_pru0_fw/`). +- [ ] A3. In each copied `ti-pru-cgt/makefile`: + - Update the include path for `imports.mak` (count `../` levels from this + file to the repo root). + - Update any board-specific defines or pin macros. +- [ ] A4. In each copied `ti-pru-cgt/linker.cmd`: + - Verify memory sizes match the target board's PRU subsystem. Check the + device TRM or an existing project for that board. +- [ ] A5. In each copied `ti-pru-cgt/example.projectspec`: + - Update `name=` to a unique CCS project name (convention: + `___fw`). + - The `postBuildStep` writes to `../pru0_load_bin.h` (relative to the build + output dir) — this path is board-agnostic and does not need updating. + - Update any board-specific compiler defines. + - Also update `PROJECT_NAME` in `makefile_projectspec` to match the new + `name=` value. +- [ ] A6. If the project has MCU+ code, repeat A2–A5 for the MCU+ directory. + Check the existing project structure first: some projects use + `mcuplus///ti-arm-clang/` (for example, `examples/empty`); + others use `//ti-arm-clang/` directly at the project root + (for example, `academy/intc/intc_mcu`). Match the convention used by the project + being ported. + The MCU+ core directory (`ti-arm-clang/`) must contain: `makefile`, + `makefile_projectspec`, `makefile_ccs_bootimage_gen`, `example.projectspec`, + `syscfg_c.rov.xs`. + The parent board+core directory must contain: `main.c`, `example.syscfg`. + For `example.syscfg`: use the Situation 2 selection algorithm — present the + user with existing syscfg files for the target board and ask which to use as + a template (default: the appropriate empty project). Copy the chosen file. + Compare it against the source project's syscfg and summarize differences. + If D3 flagged signal I/O, inform the user that pin routing must be + configured manually in SysConfig for the new board. Do not edit pin routing. +- [ ] A7. Update the project `makefile`: + - Add the new board to the appropriate device target. + - Pattern: grep the existing `makefile` for the old board name to find all + locations that need updating. +- [ ] A8. Update the parent directory `makefile` if a new device target entry + is needed (required when adding a device not previously in the parent). + +--- + +## Section B: Different device port + +- [ ] B1. Complete Step D3 above. Resolve any Npru/N-hw/N-sw blockers before + continuing. +- [ ] B2. Identify the closest existing device directory as a template. +- [ ] B3. Follow all steps in Section A, treating the new device as the new + board. +- [ ] B4. Enumerate all PRU core types referenced in the project — both in + PRU firmware source and in the host code. The default mapping for any port + is: PRU0 → PRU0, PRU1 → PRU1, RTU_PRU0 → RTU_PRU0, TX_PRU0 → TX_PRU0, + and so on. If the host code or PRU firmware references a core type that is + absent from the source device or the destination device, stop and ask the + user how to handle those cores before continuing. Do not remap core types + or add firmware for unused cores without explicit user instruction (see + Do-not-do list). If the destination device has additional core types not + referenced in the source project, leave those cores unused. +- [ ] B5. Search the new directory for the old device name and update every + match. Device names appear in many forms; search for all variants: + ``` + grep -r "am64x\|AM64x\|AM64X\|AM6432\|Cortex R.AM64" / + ``` + (Replace the old device name pattern with the one you are porting from.) + Common locations: `ti-arm-clang/makefile` (SOC define, lib names, FreeRTOS + config path), `example.projectspec` (deviceId, products list, + package/part flags). +- [ ] B6. Update the project `makefile`: + - Add the new device to `SUPPORTED_PROCESSORS`. + - Add a new device-specific make target block. Pattern: copy an existing + device block and update device name, board name, and core names. +- [ ] B7. Verify `imports.mak.default` lists the new device as a valid + `DEVICE` option. Do not modify `imports.mak` (it is user-local and + git-ignored). + +--- + +## Checkpoint before building + +- [ ] C1. Present the new board/device tree and the renamed CCS project names, + and confirm they match your recorded scope — the target device/board, and the + core mapping (D2, and B4 for a device port). Fix any naming or mapping error + now; it propagates into every makefile and projectspec and is cheapest to fix + before the first build. + +--- + +## Verification steps + +- [ ] V1. Build PRU firmware from the core directory: + `make -s -C firmware///ti-pru-cgt` + Paste the actual command output. Expected: no errors; `.out` generated; + `*_load_bin.h` generated if the project has a MCU+ host (not produced for + AM62x Linux-host projects). +- [ ] V2. Build from the project directory: + `cd && make -s clean && make` + Paste the actual command output. Expected: no errors. +- [ ] V3. Build from the repo top level: + `cd && make -s` + Paste the actual command output. Expected: new board/device builds without + errors, and the already-supported devices still build. +- [ ] V4. Import and build in CCS. Paste the CCS build console output. + Expected: `example.projectspec` opens without errors and builds PRU firmware + and R5F (if present). +- [ ] V5. Update the portability table in `academy/readme.md` or + `examples/readme.md`: change `Yport` to `Y` for each device/board + combination that was just successfully ported and verified. +- [ ] V6. Confirm each Do-not-do constraint recorded in your run parameters + held. State the outcome for each — a result that builds can still violate one. + +--- + +## Do-not-do list + +- Do not commit the `debug/` or `release/` build output directories. +- Do not retry a failing build indefinitely or invent a workaround. After a few + fix attempts, stop and report the failure with its output. +- Do not hard-code absolute paths in makefiles or projectspecs. Use variables + like `$(OPEN_PRU_PATH)` and the `imports.mak` include pattern. +- Do not update `SUPPORTED_PROCESSORS` without also adding the corresponding + make target block in the project `makefile`. +- Do not assume memory sizes are identical across device families. Always + check `linker.cmd` against the target device data sheet. +- Do not skip the top-level build verification (V3). Errors in the parent + makefile will break CI for all contributors. +- Do not remap PRU core types or add firmware for cores absent from the + source project when porting to a device with additional core types. PRU0 + maps to PRU0, PRU1 maps to PRU1; if the host code references a core type + not covered by the PRU firmware source, stop and ask the user. +- Do not edit `example.syscfg` pin routing, PRUICSS configuration, or + device settings. Use the Situation 2 selection algorithm to copy a + starting-point syscfg, highlight differences, and flag all remaining + SysConfig configuration as manual steps for the user. diff --git a/examples/LCD_interface/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg b/examples/LCD_interface/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg index edfead2a2..4a9542176 100644 --- a/examples/LCD_interface/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg +++ b/examples/LCD_interface/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM243x_ALX_beta" --part "ALX" --package "ALX" --context "r5fss0-0" --product "OPEN_PRU@07.03.01" --product "MCU_PLUS_SDK_AM243x@10.00.00" - * @v2CliArgs --device "AM2434" --package "FCCSP (ALX)" --context "r5fss0-0" --product "OPEN_PRU@07.03.01" --product "MCU_PLUS_SDK_AM243x@10.00.00" + * @cliArgs --device "AM243x_ALX_beta" --part "ALX" --package "ALX" --context "r5fss0-0" --product "OPEN_PRU@2026.01.00" --product "MCU_PLUS_SDK_AM243x@10.00.00" + * @v2CliArgs --device "AM2434" --package "FCCSP (ALX)" --context "r5fss0-0" --product "OPEN_PRU@2026.01.00" --product "MCU_PLUS_SDK_AM243x@10.00.00" * @versions {"tool":"1.21.0+3721"} */ diff --git a/examples/LCD_interface/readme.md b/examples/LCD_interface/readme.md index 4367d445f..76a8c10c1 100644 --- a/examples/LCD_interface/readme.md +++ b/examples/LCD_interface/readme.md @@ -1,5 +1,22 @@ # LCD Interface -This project uses PRU direct GPOs to output data from frame buffer memory to parallel RGB24 interface. The LCD display is 800x480 pixel with 24 bit color and 60 Hz frame rate. PRU resources used are limited to 200 MHz clock and functions available across ICSS_M (AM261/AM263) and ICSS_G (AM243/AM64) devices. The demo is built with AM243x LP because of availability of PRU pins on header. Display used is Newhaven NHD-4.3-800480CF-ASXP-CTP (https://newhavendisplay.com/content/specs/NHD-4.3-800480CF-ASXP-CTP.pdf). For back-light power supply we use TPS61169EVM (https://www.ti.com/lit/snvu455). + +## Introduction + +This project uses PRU direct GPOs to output data from frame buffer memory to parallel RGB24 interface. The LCD display is 800x480 pixel with 24 bit color and 60 Hz frame rate. PRU resources used are limited to 200 MHz clock and functions available across ICSS_M (AM261/AM263) and ICSS_G (AM243/AM64) devices. The demo is built with AM243x LP because of availability of PRU pins on header. Display used is Newhaven NHD-4.3-800480CF-ASXP-CTP (https://newhavendisplay.com/content/specs/NHD-4.3-800480CF-ASXP-CTP.pdf). For back-light power supply we use TPS61169EVM (https://www.ti.com/lit/snvu455). + +## Supported Combinations + +Refer to open-pru/examples/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am243x | LP-AM243 | MCU PLUS SDK FIXME, OpenPRU FIXME | ## Overview RGB interface has wide data bus of 24 bit using 8 bits per color. In addition there are vertical and horizontal sync signals to define start and end of lines and frames. The display selected has additional DE (data enable) which is active for one line of data. Each 24 bit data is captured with DCLK (pixel clock) falling edge and there is a setup and hold time of 8 ns in this case. @@ -35,17 +52,28 @@ In the PRU firmware there are two macros which handle both alignment issues. The ## How to Run -The project is split into three parts which are needed to run the demo. Clocking, pin-mux configuration and interrupts are specified graphically using sysconfig tool and example.syscfg file located in folder "C:\ti\GitHub\open-pru\examples\LCD_interface\am243x-lp\r5fss0-0_freertos". ARM project is used to run configuration of the demo including board and SoC configurations in sysconfig file. ARM also has PRU driver to load and run firmware. It is important that PRU1 starts before PRU0 to have core synchronization working. +The project is split into three parts which are needed to run the demo. + +1. Clocking, pin-mux configuration and interrupts are specified graphically using +sysconfig tool and example.syscfg file located in folder +"\path\to\open-pru\examples\LCD_interface\am243x-lp\r5fss0-0_freertos". + +2. The +MCU+ SDK project is used to run configuration of the demo, including board and +SoC configurations in sysconfig file. The MCU+ core uses the PRUICSS driver to +load and run firmware. It is important that PRU1 starts before PRU0 to have core +synchronization working. -Third component is assembly firmware for PRU0 and PRU1 which does the RGB output from frame buffer memory. +3. The third component is assembly firmware for PRU0 and PRU1 which does the RGB +output from frame buffer memory. -Here are the steps to run the demo. +Here are the steps to run the demo. -1. Clone project from Open-PRU github repository. -2. Import project in CCS at LCD_interface folder. CCS will import 3 projects, one for the ARM core and two for PRU0 and PRU1 core. +1. Clone project from Open-PRU github repository. +2. Import project in CCS at LCD_interface folder. CCS will import 3 projects, one for the ARM core and two for PRU0 and PRU1 core. 3. Build PRU0 and PRU1 firmware first which generates header files. -4. Build ARM project which uses newly generated header files for PRU0 and PRU1 firmware. -5. Load and run ARM project. It will also load and run PRU1 first followed by PRU0 code. +4. Build ARM project which uses newly generated header files for PRU0 and PRU1 firmware. +5. Load and run ARM project. It will also load and run PRU1 first followed by PRU0 code. It makes sense to validate output signals with a logic scope. Important signals to capture are DCLK, VSYNC, HSYNC, DE and first bit of data line for each color. The documentation folder has PPT which contains timing plots for verification. After validating correct signal output the display can be connected to the launchpad header. The PPT shows the pin-mapping from Launchpad header perspective. diff --git a/examples/custom_frequency_generator/README.md b/examples/custom_frequency_generator/README.md index 8e2f8dd35..2fd87b98c 100644 --- a/examples/custom_frequency_generator/README.md +++ b/examples/custom_frequency_generator/README.md @@ -1,16 +1,32 @@ # Custom Frequency Generator +## Introduction + The project generates a square wave of the desired average clock frequency from the available system clock. A fractional adder is used to generate a pulse with a configurable average frequency. CFG_setup
Fig.1 Frequency Generator setup
+## Supported Combinations + +Refer to open-pru/examples/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am243x | LP-AM243 | MCU PLUS SDK 11.0, OpenPRU FIXME | + ## Overview Depending on the processor, the PRU cores may only be able to run at a single fixed frequency, or the PRU cores may be able to run at a limited number of clock frequencies. Refer to the hardware documentation for more information about PRU clock sources on your specific processor. Some square wave frequencies are even multiples of the PRU core clock period. These square waves can be easily generated by the PRU, and are not the focus of this project. This project generates output signal frequencies that cannot be created with a simple clock divider. This project generates a square wave with an average frequency very close to a specific desired frequency. It does this by generating two frequencies that are higher and lower than the desired frequency. A fractional adder is used to ensure that the average frequency of the output waveform comes as close as possible to the desired frequency. - For the generation of a particular clock frequency, we generate two signals with time periods that correspond to the closest longer and shorter time perods for a particular clock frequency. The shorter time period is generated in the beginning and the fractional difference between the shorter period and the desired period (whic is calculated from the desired frequency) is accumulated as part of a fractional adder. Whenever this accumulated fraction exceeds a maximum limit, which is the clock time-period or the difference between the two closest longer and shorter time-periods, we generate the longer time period. This process continues indefenitely, thereby generating the two time periods alternatively to give out the average desired time-period required. + For the generation of a particular clock frequency, we generate two signals with time periods that correspond to the closest longer and shorter time periods for a particular clock frequency. The shorter time period is generated in the beginning and the fractional difference between the shorter period and the desired period (which is calculated from the desired frequency) is accumulated as part of a fractional adder. Whenever this accumulated fraction exceeds a maximum limit, which is the clock time-period or the difference between the two closest longer and shorter time-periods, we generate the longer time period. This process continues indefinitely, thereby generating the two time periods alternatively to give out the average desired time-period required. The fractional adder algorithm is integrated within the clock frequency generation code for both time-periods in this project. The duration of high and low signals are kept the same for the signal generation, as the generated signal is assumed to be used as a clock signal. The alternate generation of longer and shorter time periods for a specific example of 16.384 Mhz is shown below as a timing diagram: @@ -22,7 +38,7 @@ Depending on the processor, the PRU cores may only be able to run at a single fi All the configurations mentioned are performed in the 'macros' section of the file "fn_fg_output.asm". -Maximum Genertable Frequency : (Clock Frequency/8) +Maximum Generatable Frequency : (Clock Frequency/8) => minimum of 8 clock cycles time period @@ -69,8 +85,8 @@ For the previous example, 1. Import the device specific project from 'examples/custom_frequency_generator' in the open-pru repository. 2. Keep the default configuration (for 16.384Mhz) or change the configuration according to section [Configuration](#configuration) for a desired frequency. -3. Build and load the "*.out" file into the core 'ICSSG0 PRU0' of AM243x device. -4. Run the core and the desired average frequency is available on PIN PRU0_GPO0(BP.33). To view the signal, connect a channel of a logic scope to the PIN. +3. Build and load the "*.out" file into the core 'ICSSG0 PRU0' of AM243x device. +4. Run the core and the desired average frequency is available on PIN PRU0_GPO0(BP.33). To view the signal, connect a channel of a logic scope to the PIN. ## Results @@ -80,4 +96,4 @@ A portion of the output signal traced using the PRU Logic Scope(see examples/log cfg_results
Fig.3 Resulting wave of Frequency generator
- \ No newline at end of file + diff --git a/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 18d51e3d4..72cc34d77 100644 --- a/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index fb7218972..e46cb47ac 100644 --- a/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 8902c03af..15d7f2928 100644 --- a/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 09c32ae9e..f88cbcfef 100644 --- a/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile index 729ff3abb..b6a3b19c8 100644 --- a/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 8902c03af..15d7f2928 100644 --- a/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 330027040..2e936c549 100644 --- a/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile index e7fa7f3ba..10fb1b3e7 100644 --- a/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index f7e5254f8..d6f49d8fb 100644 --- a/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index dc1d2050c..91bbe902d 100644 --- a/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile index b8e4bb75e..a36bb4b42 100644 --- a/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index f7e5254f8..d6f49d8fb 100644 --- a/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg b/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg index 8561a4a83..34f91d60c 100644 --- a/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg +++ b/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 5e73623fa..98045562a 100644 --- a/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile index f892c4ac4..1fd24cedb 100644 --- a/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index dd481b30f..44b500335 100644 --- a/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index bb9439075..bcfb31858 100644 --- a/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 3104d8c8a..10d4f2be1 100644 --- a/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index dd481b30f..44b500335 100644 --- a/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty/readme.md b/examples/empty/readme.md index c7679d424..caf550f0d 100644 --- a/examples/empty/readme.md +++ b/examples/empty/readme.md @@ -2,40 +2,35 @@ ## Introduction -This example acts as a getting started point for PRU firmware development in assembly. +This example acts as a getting started point for PRU firmware development in +assembly. -# Supported Combinations +## Supported Combinations - Parameter | Value - ---------------|----------- - ICSSG | ICSSG0 - PRU0, PRU1, RTU0, RTU1, TX_PRU0,TX_PRU1 - ICSSM | ICSSM0 - PRU0, PRU1 - | ICSSM1 - PRU0, PRU1 (am261x only) - Toolchain | pru-cgt - Board | am64x-evm, am243x-evm, am243x-lp, am261x-lp, am261x-som, am263px-cc, am263px-lp, am263x-cc, am263x-lp, am62x-sk - Example folder | examples/empty/ +Refer to open-pru/examples/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. -# Steps to Run the Example +## Validated HW & SW -> Prerequisite: [PRU-CGT-2-3](https://www.ti.com/tool/PRU-CGT) (ti-pru-cgt) should be installed at: `C:/ti/` +This project was tested on hardware with these software versions: -- **When using CCS projects to build**, import the CCS project from the above mentioned Example folder path for R5F and PRU, After this `main.asm`, `linker.cmd` files gets copied to ccs workspace of PRU project. The `main.asm` contains sample code to halt PRU program +| Processor | Hardware | Software | +| --------- | ---------- | -------------------------- | +| AM243x | FIXME | FIXME | +| AM261x | FIXME | FIXME | +| AM263Px | FIXME | FIXME | +| AM263x | FIXME | FIXME | +| AM62x | FIXME | FIXME | +| AM64x | FIXME | FIXME | - - Build the PRU project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Build Flow: Once you click on build in PRU project, firmware header file which is generated in release or debug folder of ccs workspace, is moved to `` +## Overview - - Build the R5F project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Firmware header file path is included in R5F project include options by default, Instructions in Firmware header file can be written into PRU IRAM memory using PRUICSS_loadFirmware API (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe)) - - Build Flow: Once you click on build in R5F project, SysConfig files are generated, Finally the R5F project will be generated using both the generated SysConfig and PRU project binaries. +For more information about using this example to write your own PRU firmware, +refer to +[Creating a New Project in the OpenPRU Repo](../../docs/open_pru_create_new_project.md). - - Launch a CCS debug session and run the executable, (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_LAUNCH_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_LAUNCH_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_LAUNCH_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_LAUNCH_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_LAUNCH_PAGE.html)) +## Steps to Run the Example -- **When using makefiles to build**: - - For steps on how to use makefiles, run `make help` from the root folder - of the open-pru repository. - -# Writing PRU code - -* You can modify this example to write your own firmware. For more information, - refer to - [Creating a New Project in the OpenPRU Repo](../../docs/open_pru_create_new_project.md). +Refer to the **PRU Academy > PRU Getting Started Labs** for steps to build, +load, and debug PRU firmware. diff --git a/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 22e2a8467..df0005d39 100644 --- a/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index ebb1f9ebb..f15ab903f 100644 --- a/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 8902c03af..15d7f2928 100644 --- a/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty_c/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec index bd52d9909..d04657884 100644 --- a/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am261x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile index 0c87dfbeb..69c31cb2f 100644 --- a/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index 8902c03af..15d7f2928 100644 --- a/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty_c/mcuplus/am261x-som/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 4e09c7ebb..4adce65b9 100644 --- a/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile index 9014c9258..de637662e 100644 --- a/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index f7e5254f8..d6f49d8fb 100644 --- a/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty_c/mcuplus/am263px-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index aaa21cdf4..614f0c263 100644 --- a/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263PX + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263px" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.debug.lib - -ldrivers.am263px.r5f.ti-arm-clang.debug.lib - -lboard.am263px.r5f.ti-arm-clang.debug.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263px.r5f.ti-arm-clang.release.lib - -ldrivers.am263px.r5f.ti-arm-clang.release.lib - -lboard.am263px.r5f.ti-arm-clang.release.lib + -ldrivers.am263px.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263px.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 254c3d665..0b9d0dfc5 100644 --- a/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263PX \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263px.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263px.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263px:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index f7e5254f8..d6f49d8fb 100644 --- a/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty_c/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg b/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg index 8561a4a83..34f91d60c 100644 --- a/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg +++ b/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/example.syscfg @@ -1,8 +1,8 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" - * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@07.03.01" + * @cliArgs --device "AM263x_beta" --part "AM263x" --package "ZCZ" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" + * @v2CliArgs --device "AM2634" --package "NFBGA (ZCZ)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" --product "OPEN_PRU@2026.01.00" * @versions {"tool":"1.23.0+4000"} */ diff --git a/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec index 7bc3aa1b8..3877f416f 100644 --- a/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile index 7224f54c5..2906c9e48 100644 --- a/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index dd481b30f..44b500335 100644 --- a/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty_c/mcuplus/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec index ea9bcbceb..f9560f5cf 100644 --- a/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec +++ b/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -48,6 +48,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM263X + -DOS_FREERTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib @@ -59,6 +60,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am263x" @@ -81,8 +83,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.debug.lib - -ldrivers.am263x.r5f.ti-arm-clang.debug.lib - -lboard.am263x.r5f.ti-arm-clang.debug.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.debug.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.debug.lib -llibc.a -llibsysbm.a " @@ -93,8 +95,8 @@ " linkerBuildOptions=" -lfreertos.am263x.r5f.ti-arm-clang.release.lib - -ldrivers.am263x.r5f.ti-arm-clang.release.lib - -lboard.am263x.r5f.ti-arm-clang.release.lib + -ldrivers.am263x.r5f.ti-arm-clang.freertos.release.lib + -lboard.am263x.r5f.ti-arm-clang.freertos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile index 44d70d4dd..42275b8d2 100644 --- a/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile +++ b/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=empty_c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=empty_c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=empty_c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=empty_c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=empty_c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=empty_c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=empty_c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=empty_c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -73,6 +74,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM263X \ + -DOS_FREERTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -116,8 +118,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -125,12 +127,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -173,7 +176,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -195,7 +198,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! @echo . @@ -221,6 +224,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -232,6 +236,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -280,8 +285,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -302,54 +305,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(BOOTIMAGE_NAME_MCELF): $(OUTNAME) @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ... - $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig) @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! @echo . -$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen index dd481b30f..44b500335 100644 --- a/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/empty_c/mcuplus/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/empty.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! - @echo . ifeq ($(DEVICE_TYPE), HS) # Sign the appimage using appimage signing script ifeq ($(ENC_ENABLED),no) ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is disabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) else @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss endif else ifeq ($(RSASSAPSS_ENABLED),no) @echo Boot image signing: Encryption is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS) $(RM) $(BOOTIMAGE_NAME_MCELF)-enc else @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled. - $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss $(RM) $(BOOTIMAGE_NAME_MCELF)-enc endif endif - @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/empty_c/readme.md b/examples/empty_c/readme.md index 0309e5991..8c29b3c1e 100644 --- a/examples/empty_c/readme.md +++ b/examples/empty_c/readme.md @@ -5,38 +5,32 @@ This example acts as a getting started point for PRU firmware development in C, or mixed C and assembly. -# Supported Combinations +## Supported Combinations - Parameter | Value - ---------------|----------- - ICSSG | ICSSG0 - PRU0, PRU1, RTU0, RTU1, TX_PRU0,TX_PRU1 - ICSSM | ICSSM0 - PRU0, PRU1 - | ICSSM1 - PRU0, PRU1 (am261x only) - Toolchain | pru-cgt - Board | am64x-evm, am243x-evm, am243x-lp, am261x-lp, am261x-som, am263px-cc, am263px-lp, am263x-cc, am263x-lp, am62x-sk - Example folder | examples/empty_c/ +Refer to open-pru/examples/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. -# Steps to Run the Example +## Validated HW & SW -> Prerequisite: [PRU-CGT-2-3](https://www.ti.com/tool/PRU-CGT) (ti-pru-cgt) should be installed at: `C:/ti/` +This project was tested on hardware with these software versions: -- **When using CCS projects to build**, import the CCS project from the above mentioned Example folder path for R5F and PRU, After this `main.asm`, `linker.cmd` files gets copied to ccs workspace of PRU project. The `main.asm` contains sample code to halt PRU program +| Processor | Hardware | Software | +| --------- | ---------- | -------------------------- | +| AM243x | FIXME | FIXME | +| AM261x | FIXME | FIXME | +| AM263Px | FIXME | FIXME | +| AM263x | FIXME | FIXME | +| AM62x | FIXME | FIXME | +| AM64x | FIXME | FIXME | - - Build the PRU project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Build Flow: Once you click on build in PRU project, firmware header file which is generated in release or debug folder of ccs workspace, is moved to `` +## Overview - - Build the R5F project using the CCS project menu (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_PROJECTS_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_PROJECTS_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_PROJECTS_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_PROJECTS_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_PROJECTS_PAGE.html)). - - Firmware header file path is included in R5F project include options by default, Instructions in Firmware header file can be written into PRU IRAM memory using PRUICSS_loadFirmware API (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/group__DRV__PRUICSS__MODULE.html#ga3e7c763e5343fe98f7011f388a0b7ffe)) - - Build Flow: Once you click on build in R5F project, SysConfig files are generated, Finally the R5F project will be generated using both the generated SysConfig and PRU project binaries. +For more information about using this example to write your own PRU firmware, +refer to +[Creating a New Project in the OpenPRU Repo](../../docs/open_pru_create_new_project.md). - - Launch a CCS debug session and run the executable, (see [for AM64x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/latest/exports/docs/api_guide_am64x/CCS_LAUNCH_PAGE.html), [for AM243x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/CCS_LAUNCH_PAGE.html), [for AM261x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM261X/latest/exports/docs/api_guide_am261x/CCS_LAUNCH_PAGE.html), [for AM263x](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/CCS_LAUNCH_PAGE.html), [for AM263Px](https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/latest/exports/docs/api_guide_am263px/CCS_LAUNCH_PAGE.html)) +## Steps to Run the Example -- **When using makefiles to build**: - - For steps on how to use makefiles, run `make help` from the root folder - of the open-pru repository. - -# Writing PRU code - -* You can modify this example to write your own firmware. For more information, - refer to - [Creating a New Project in the OpenPRU Repo](../../docs/open_pru_create_new_project.md). +Refer to the **PRU Academy > PRU Getting Started Labs** for steps to build, +load, and debug PRU firmware. diff --git a/examples/fft/README.md b/examples/fft/README.md index 565a45174..f3561c1cc 100644 --- a/examples/fft/README.md +++ b/examples/fft/README.md @@ -8,6 +8,21 @@ ## Introduction The code performs a real valued 4096-point Fast-Fourier Transform on 4096 discrete input samples in the ICSS Shared Memory. The implementation makes use of a Real-valued DIT Split-Radix algorithm and has two versions that each runs on ICSSG PRU0 and ICSSM PRU0. +## Supported Combinations + +Refer to open-pru/examples/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | ----------------------------------------------- | +| am243x | FIXME | MCU PLUS SDK 10.01.00.32, OpenPRU FIXME | +| am261x | FIXME | MCU PLUS SDK 10.00.01.10, OpenPRU FIXME | + ## Overview The algorithm assumes input samples in Q24 format to be present in the configured memory space. The current implementation assumes unsigned inputs which are common for ADC measurement values. @@ -18,7 +33,7 @@ After execution, the output samples, in frequency domain, will be present in spe ## Instructions 1. Get the 'fft' folder from the repository which contains the project, data and utility scripts. -2. Naviagte to the 'split_radix_fft_4k_single_core' folder inside the 'fft' folder and import the device specific project into the CCS workspace. +2. Navigate to the 'split_radix_fft_4k_single_core' folder inside the 'fft' folder and import the device specific project into the CCS workspace. 3. Build the Project. 4. Launch Target Configuration and connect to an R5SS core. 5. Edit the 'load_memory.js' file in the 'utilities' folder and configure the following : @@ -119,7 +134,7 @@ We can perform an FFT Magnitude plot of the sample input using CCS in-built 'fft To compare the accuracy of the calculations, the CCS values were exported and the SNR of the magnitude plot for both CCS calculated and PRU calculated magnitude values were calculated. The SNR or Signal to Noise Ratio is given by : $$ SNR = 10 * log (Signal Power/Noise Power) $$ -The signal power and noise power of both magnitudes and claculated SNR is compared in the following table: +The signal power and noise power of both magnitudes and calculated SNR is compared in the following table: | Parameters | CCS | PRU | |----------------|:-------:|:-----------:| @@ -233,7 +248,7 @@ The window coefficients are stored as a Look-up Table (LUT) in the shared memory
Fig.6 Application of Window coefficients
-The window coefficients are loaded into the ICSSG Shared Memory(for AM243x) or a memory external to ICSS like TCMA of ARM R5 core(for AM261x), from where we make use of xfer2vbus data accelerator for loading 8 window coefficients together into the registers. The accelerator works by pre-loading a certain number of window coefficients into an XFR2VBUS RX buffer, from where the broadside connection enables us to load these values to the registers in a single cycle. Before the first set of coefficients are loaded, there is a wait involved to make sure all window coefficients are loaded into the buffer. Auto read mode is enabled such that everytime the coefficients are read from the buffer, the transfer of next set of window coefficients is initiated. This transfer happens in the background while we perform operations using the already loaded coefficients and by the time the next set is needed, it can be loaded into the registers in a single cycle, without any wait time involved. +The window coefficients are loaded into the ICSSG Shared Memory(for AM243x) or a memory external to ICSS like TCMA of ARM R5 core(for AM261x), from where we make use of xfer2vbus data accelerator for loading 8 window coefficients together into the registers. The accelerator works by pre-loading a certain number of window coefficients into an XFR2VBUS RX buffer, from where the broadside connection enables us to load these values to the registers in a single cycle. Before the first set of coefficients are loaded, there is a wait involved to make sure all window coefficients are loaded into the buffer. Auto read mode is enabled such that every time the coefficients are read from the buffer, the transfer of next set of window coefficients is initiated. This transfer happens in the background while we perform operations using the already loaded coefficients and by the time the next set is needed, it can be loaded into the registers in a single cycle, without any wait time involved. The 8 loaded window coefficients have to be multiplied with 16 input values as described earlier. Due to register space limitation, half of these values are moved to the scratchpad after they are loaded. For multiplication, first the window coefficient is moved to one of the multiplication operand registers. The first input to be multiplied with this coefficient is moved to the second operand register ad multiplication is performed. Later, the second input which is present in scratchpad is moved similarly to obtain the second required product. The obtained product has to be stored in a different index to perform bit-order reversed sorting of the inputs which is discussed in the next section. The algorithm can be visualized in the combined image showing both steps below. @@ -286,7 +301,7 @@ If the inputs are real valued, special optimized algorithms that make use of com The in-place algorithm makes use of complex-conjugate symmetry involved to optimally store real and imaginary part of intermediate complex values at different locations. This results in the final arrangement as follows: -The computing algoirthm for real-valued DIT split radix FFT makes use of special indexing to apply the different butterflies over different stages. The algorithm can be found in [[2]](#2) +The computing algorithm for real-valued DIT split radix FFT makes use of special indexing to apply the different butterflies over different stages. The algorithm can be found in [[2]](#2) C code for the FORTRAN algorithm for reference in [rsplitfft.c](https://github.com/dave18/Pandora-Star/blob/master/rsplitfft.c) #### length-2 butterflies @@ -304,7 +319,7 @@ The l-shaped butterflies operate on 4 inputs at a time and the indexing scheme w To deal with general-case butterflies, the twiddle factors for multiplication are pre-computed and stored as a Look-up Table in the order that they are required. When a twiddle factor, which is an exponential function, is decomposed into its constituent Cos and Sin components, the l-shaped butterfly computation loop requires four values namely, $cos(A)$, $sin(A)$, $cos(3*A)$ and $sin(3*A)$. The value of A is given by: $$ A = \frac{2\pi}{N2} $$, where N2 starts at 2 and gets multiplied by 2 every stage. -The twiddle factors, in the case of AM243x implementation, are stored in the FDB-BS RAM that works like a normal Broadside RAM in general purpose mode. To make use of the 16KB space available fully, we store each two sets of these 4 values(4 Bytes each) in each page(32 Bytes) of FDB-BS RAM. The values are pre-computed and stored in exactly the order they are accessed using the reference C-code mentioned before. The auto-increment feature of BS-RAM increments the address by one-page everytime a read happens. Because of this, two set of twiddle factors in the current page are fetched together. The second set is stored in scratch-pad and is used in the next 'fetch cycle', when a new set of twiddle factors are required. A dedicated variable keeps track of the parity of the fetch cycle and loads 2 sets of twiddle factors every even cycle. This mechanism is explained in the figure below: +The twiddle factors, in the case of AM243x implementation, are stored in the FDB-BS RAM that works like a normal Broadside RAM in general purpose mode. To make use of the 16KB space available fully, we store each two sets of these 4 values(4 Bytes each) in each page(32 Bytes) of FDB-BS RAM. The values are pre-computed and stored in exactly the order they are accessed using the reference C-code mentioned before. The auto-increment feature of BS-RAM increments the address by one-page every time a read happens. Because of this, two set of twiddle factors in the current page are fetched together. The second set is stored in scratch-pad and is used in the next 'fetch cycle', when a new set of twiddle factors are required. A dedicated variable keeps track of the parity of the fetch cycle and loads 2 sets of twiddle factors every even cycle. This mechanism is explained in the figure below:
twiddle factor alternate cycle fetch @@ -340,4 +355,3 @@ P. Duhamel, "Implementation of "Split-radix" FFT algorithms for complex, real, a - diff --git a/examples/logic_scope/README.md b/examples/logic_scope/README.md index bb8fbc2a2..ba644014b 100644 --- a/examples/logic_scope/README.md +++ b/examples/logic_scope/README.md @@ -1,11 +1,27 @@ # 8-channel Logic Scope +## Introduction + The project realizes a simple logic scope that uses two cores, PRU0 and RTU0, to continuously sample a configured GPI Pin. The sampling frequency is restricted only by the clock frequency of PRU and for AM243 we could configure the clock upto 333Mhz. This gives us a maximum sampling rate of 333Mhz. The number of samples that need to be captured can be configured in multiples of 100 and the maximum number of samples is only restricted by the size of the configured storage memory. For MSRAM, this is around 2MB of sample size. The Logic-scope reads 1 Byte of data every clock cycle which contains logic data from 8 input channels. The trigger for sampling in current implementation is set to a low to high in the 8th channel (PRU0.GPI7). ![alt text](images/dcls_overview.png) +## Supported Combinations + +Refer to open-pru/examples/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am243x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | + ## Overview -PRU cores can directly read certain input pins using their R30 registers. Since R30 has real-time information on the logic levels of these pins, a zero-overhead loop and indirect register addressing could be used to continuously transfer the samples to other registers, bytewise. The number of samples we can transfer continously in this case, is limited by the number of available registers in a single core. Once we are out of registers, with a single core, we have no other choice but to pause sampling to tranfer the collected samples to memory. +PRU cores can directly read certain input pins using their R30 registers. Since R30 has real-time information on the logic levels of these pins, a zero-overhead loop and indirect register addressing could be used to continuously transfer the samples to other registers, bytewise. The number of samples we can transfer continuously in this case, is limited by the number of available registers in a single core. Once we are out of registers, with a single core, we have no other choice but to pause sampling to transfer the collected samples to memory. The above mentioned restriction can be surpassed by making use of an extra core which can continue sampling after the first core fills up it's registers. This way, one core will always continue sampling while the other core stores the data that it sampled. The cores are selected as PRU and RTU since they will have access to the same input pins simultaneously. A conceptual timing diagram of the same is shown below: @@ -15,7 +31,7 @@ The cores have to be synchronized once before they wait for the trigger together ## Configuration -1. dcls_config_macros.inc contains all the configurations for DCLS. It is imortant to note that required configurations are to be done in this file for both cores +1. dcls_config_macros.inc contains all the configurations for DCLS. It is important to note that required configurations are to be done in this file for both cores 2. 8 channels are sampled simultaneously. Set the channel Byte to be sampled as 0, 1, or 2. For GPI0-GPI7, channel Byte is 0. Note that depending on the availability of pins, changing the Byte number will reduce the number of usable channels. ``` @@ -58,4 +74,4 @@ The cores have to be synchronized once before they wait for the trigger together ![DCLS_trace_collection](images/dcls_trace_collection.png) 5. The collected binary trace can be viewed in a tool like 'PulseView'. In PulseView, import the data as raw binary, set the number of channels as 8 and the sampling frequency(333Mhz by default). 6. The sampled signals over 8 channels can now be viewed as shown below(only one channel is connected) : - ![DCLS_pulse_view_op](images/dcls_pulse_view_out.png) \ No newline at end of file + ![DCLS_pulse_view_op](images/dcls_pulse_view_out.png) diff --git a/examples/makefile b/examples/makefile index 43e67eed0..ffcdb0ad3 100644 --- a/examples/makefile +++ b/examples/makefile @@ -3,7 +3,7 @@ include ../imports.mak SUBDIRS := \ custom_frequency_generator empty empty_c \ fft/split_radix_fft_4k_single_core fft/split_radix_fft_post_processing \ - LCD_interface logic_scope pru_emif pru_i2c spi_loopback \ + LCD_interface logic_scope pru_emif pru_eqep pru_i2c spi_loopback \ fir multicore_scheduler rpmsg_echo_linux # "make" or "make all" builds projects that match $(DEVICE) set in imports.mak diff --git a/examples/pru_emif/readme.md b/examples/pru_emif/readme.md index 12c347381..b5f7009a0 100644 --- a/examples/pru_emif/readme.md +++ b/examples/pru_emif/readme.md @@ -8,9 +8,22 @@ This example demonstrates usage of PRU-ICSSG to emulate EMIF(Extended Memory Interface) client 16-bit/32-bit asynchronous parallel interface to interface with C2K F28379D. The F283879D initiates requests for 16-bit or 32-bit reads/writes over EMIF1 & PRU_ICSSG respond to these requests.PRU firmware (PRUEMIF16) executing on AM243x -ICSSG PRU cores has been implemented to emulate the EMIF interface to repsond to 16 bit reads/writes. -It also responds to 32 bit reads/writes by converting into two 16 bit read/writes request seperately. +ICSSG PRU cores has been implemented to emulate the EMIF interface to respond to 16 bit reads/writes. +It also responds to 32 bit reads/writes by converting into two 16 bit read/writes request separately. +## Supported Combinations + +Refer to open-pru/examples/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | ------------ | -------------------------------------------------------------------------------- | +| am243x | TMDS243GPEVM | MCU PLUS SDK FIXME, C2000Ware 4.02.00.00, C2000 CGT 22.6.1 LTS, OpenPRU FIXME | ## Setup Details @@ -453,7 +466,7 @@ Import the AM243x Test Application from the path mentioned in the project direct Import the F28379D Test Application project from ${C2000ware_path}\driverlib\f2837xd\examples\cpu1\emif\CCS path.Replace Source file & Setup file from pru_emif project directory. -You can build the projects after a successfull export. +You can build the projects after a successful export. Pre-built PRU0 & PRU1 FW(firmware) images are contained in C header files located in: ${open-pru}/examples/pru_emif/pru_emif_app/firmware @@ -463,7 +476,7 @@ firmware unless the firmware is modified. However The PRU EMIF16 firmware code can be modified and rebuilt if desired. The PRU0 and PRU1 firmware images are built separately. -To build the firmware import the firmware project from the project directory and build them seperately for PRU0 & PRU1. +To build the firmware import the firmware project from the project directory and build them separately for PRU0 & PRU1. ## Target Configuration @@ -473,7 +486,7 @@ Please follow the steps below : - Right Click -> New Target Configuration - Create a new target configuration with desired file name (i.e XDS100v2_XDS100.ccxml) - Go to Advanced target configuration - - ![Advaned Target Configuration](images/Target_config_2.png) + - ![Advanced Target Configuration](images/Target_config_2.png) - Initiate two new connections - XDS100v2 Debug Probe - XDS110 USB Debug Probe @@ -481,7 +494,7 @@ Please follow the steps below : - TMS32028379D - AM243x_GP_EVM - Target Configuration should look like this - - ![Advaned Target Configuration](images/Target_Config_3.png) + - ![Advanced Target Configuration](images/Target_Config_3.png) - Save the configuration ## Debug @@ -549,7 +562,7 @@ PRU0 Firmware Top Level Program Flow ![PRU0 FIRMWARE TOP LEVEL](images/PRU0_FIRMWARE_TOP_LEVEL.png) *** -PRU0 Firmware EMIF Read Progarm Flow +PRU0 Firmware EMIF Read Program Flow ![PRU0_Firmware__EMIF_Read](images/PRU0_Firmware__EMIF_Read.png) @@ -587,7 +600,7 @@ PRU1 Firmware Top Level Program Flow ![PRU1 FIRMWARE TOP LEVEL](images/PRU1_Firmware_Top_Level.png) *** -PRU1 Firmware EMIF Read Progarm Flow +PRU1 Firmware EMIF Read Program Flow ![PRU1_Firmware__EMIF_Read](images/PRU1_Firmware_EMIF_Read.png) @@ -628,5 +641,3 @@ PRU1 Firmware EMIF Write Program Flow 21n Write 16-bit Read Back 32-bit, EOBF283879D write n 16-bit, read back n/2 32-bit words to/from AM243x DPM.
Write immediately before read in loop.
Write/read toward end of DPM buffer.PASSn=8 22n Write 32-bit Read Back 16-bit, SOBF283879D write n/2 32-bit, read back n 16-bit words to/from AM243x DPM.
Write immediately before read in loop.
Write/read toward start of DPM buffer.PASSn=8 23n Write 32-bit Read Back 16-bit, EOBF283879D write n/2 32-bit, read back n 16-bit words to/from AM243x DPM.
Write immediately before read in loop.
Write/read toward end of DPM buffer.PASSn=8 - - diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..fdae8dee8 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..ff7b62c76 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x PRU0 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..7048b652c --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := pru_eqep_am243x-lp_icss_g0_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/pru_eqep/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= +INCLUDE += --include_path=$(OPEN_PRU_PATH)/examples/pru_eqep/firmware/include + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DPRU0 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..ef0f7ea93 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=pru_eqep_am243x-lp_icss_g0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..2a652e3d8 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..7d0445552 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x PRU1 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > PRU_IMEM, PAGE 0 + .stack > PRU1_DMEM_1, PAGE 1 + .bss > PRU1_DMEM_1, PAGE 1 + .cio > PRU1_DMEM_1, PAGE 1 + .data > PRU1_DMEM_1, PAGE 1 + .switch > PRU1_DMEM_1, PAGE 1 + .sysmem > PRU1_DMEM_1, PAGE 1 + .cinit > PRU1_DMEM_1, PAGE 1 + .rodata > PRU1_DMEM_1, PAGE 1 + .rofardata > PRU1_DMEM_1, PAGE 1 + .farbss > PRU1_DMEM_1, PAGE 1 + .fardata > PRU1_DMEM_1, PAGE 1 +} diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..da8df128a --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,49 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := pru_eqep_am243x-lp_icss_g0_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +HEX_ARRAY_PREFIX := PRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/pru_eqep/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= +INCLUDE += --include_path=$(OPEN_PRU_PATH)/examples/pru_eqep/firmware/include + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DPRU1 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..6ac181c4d --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=pru_eqep_am243x-lp_icss_g0_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/example.projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..a8f14733c --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/linker.cmd b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..d0a587706 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_RTU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x RTU0 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 8 KB RTU Instruction RAM */ + RTU_IMEM : org = 0x00000000 len = 0x00002000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > RTU_IMEM, PAGE 0 + .stack > RTU0_DMEM_0, PAGE 1 + .bss > RTU0_DMEM_0, PAGE 1 + .cio > RTU0_DMEM_0, PAGE 1 + .data > RTU0_DMEM_0, PAGE 1 + .switch > RTU0_DMEM_0, PAGE 1 + .sysmem > RTU0_DMEM_0, PAGE 1 + .cinit > RTU0_DMEM_0, PAGE 1 + .rodata > RTU0_DMEM_0, PAGE 1 + .rofardata > RTU0_DMEM_0, PAGE 1 + .farbss > RTU0_DMEM_0, PAGE 1 + .fardata > RTU0_DMEM_0, PAGE 1 +} diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/makefile b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..48f468c1f --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,49 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := pru_eqep_am243x-lp_icss_g0_rtu_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := rtupru0_load_bin.h +HEX_ARRAY_PREFIX := RTUPRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/pru_eqep/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= +INCLUDE += --include_path=$(OPEN_PRU_PATH)/examples/pru_eqep/firmware/include + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DRTU_PRU0 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..d0ffe0d7b --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=pru_eqep_am243x-lp_icss_g0_rtu_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/example.projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..e6b4bbcb1 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/linker.cmd b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..a0f7c9977 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_RTU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x RTU1 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 8 KB RTU Instruction RAM */ + RTU_IMEM : org = 0x00000000 len = 0x00002000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > RTU_IMEM, PAGE 0 + .stack > RTU1_DMEM_1, PAGE 1 + .bss > RTU1_DMEM_1, PAGE 1 + .cio > RTU1_DMEM_1, PAGE 1 + .data > RTU1_DMEM_1, PAGE 1 + .switch > RTU1_DMEM_1, PAGE 1 + .sysmem > RTU1_DMEM_1, PAGE 1 + .cinit > RTU1_DMEM_1, PAGE 1 + .rodata > RTU1_DMEM_1, PAGE 1 + .rofardata > RTU1_DMEM_1, PAGE 1 + .farbss > RTU1_DMEM_1, PAGE 1 + .fardata > RTU1_DMEM_1, PAGE 1 +} diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/makefile b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..4d8576147 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,49 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := pru_eqep_am243x-lp_icss_g0_rtu_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := rtupru1_load_bin.h +HEX_ARRAY_PREFIX := RTUPRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/pru_eqep/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= +INCLUDE += --include_path=$(OPEN_PRU_PATH)/examples/pru_eqep/firmware/include + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DRTU_PRU1 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..b76dbc094 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=pru_eqep_am243x-lp_icss_g0_rtu_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/example.projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..f8b87962e --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/linker.cmd b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..4f793ea17 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_TX_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x TX_PRU0 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 6 KB TX_PRU Instruction RAM */ + TX_PRU_IMEM : org = 0x00000000 len = 0x00001800 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > TX_PRU_IMEM, PAGE 0 + .stack > TX_PRU0_DMEM_0, PAGE 1 + .bss > TX_PRU0_DMEM_0, PAGE 1 + .cio > TX_PRU0_DMEM_0, PAGE 1 + .data > TX_PRU0_DMEM_0, PAGE 1 + .switch > TX_PRU0_DMEM_0, PAGE 1 + .sysmem > TX_PRU0_DMEM_0, PAGE 1 + .cinit > TX_PRU0_DMEM_0, PAGE 1 + .rodata > TX_PRU0_DMEM_0, PAGE 1 + .rofardata > TX_PRU0_DMEM_0, PAGE 1 + .farbss > TX_PRU0_DMEM_0, PAGE 1 + .fardata > TX_PRU0_DMEM_0, PAGE 1 +} diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/makefile b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..1376ecabd --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,49 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := pru_eqep_am243x-lp_icss_g0_tx_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := txpru0_load_bin.h +HEX_ARRAY_PREFIX := TXPRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/pru_eqep/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= +INCLUDE += --include_path=$(OPEN_PRU_PATH)/examples/pru_eqep/firmware/include + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DTX_PRU0 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..538fd5046 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=pru_eqep_am243x-lp_icss_g0_tx_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/example.projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..813aec6f8 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/linker.cmd b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..a9870ece0 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_TX_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x TX_PRU1 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 6 KB TX_PRU Instruction RAM */ + TX_PRU_IMEM : org = 0x00000000 len = 0x00001800 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > TX_PRU_IMEM, PAGE 0 + .stack > TX_PRU1_DMEM_1, PAGE 1 + .bss > TX_PRU1_DMEM_1, PAGE 1 + .cio > TX_PRU1_DMEM_1, PAGE 1 + .data > TX_PRU1_DMEM_1, PAGE 1 + .switch > TX_PRU1_DMEM_1, PAGE 1 + .sysmem > TX_PRU1_DMEM_1, PAGE 1 + .cinit > TX_PRU1_DMEM_1, PAGE 1 + .rodata > TX_PRU1_DMEM_1, PAGE 1 + .rofardata > TX_PRU1_DMEM_1, PAGE 1 + .farbss > TX_PRU1_DMEM_1, PAGE 1 + .fardata > TX_PRU1_DMEM_1, PAGE 1 +} diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/makefile b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..42671221e --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,49 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := pru_eqep_am243x-lp_icss_g0_tx_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := txpru1_load_bin.h +HEX_ARRAY_PREFIX := TXPRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/pru_eqep/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= +INCLUDE += --include_path=$(OPEN_PRU_PATH)/examples/pru_eqep/firmware/include + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DTX_PRU1 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..f2abef083 --- /dev/null +++ b/examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=pru_eqep_am243x-lp_icss_g0_tx_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/pru_eqep/firmware/include/macros.inc b/examples/pru_eqep/firmware/include/macros.inc new file mode 100644 index 000000000..9fc0b4d69 --- /dev/null +++ b/examples/pru_eqep/firmware/include/macros.inc @@ -0,0 +1,54 @@ +; Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/ +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; +; Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the +; distribution. +; +; Neither the name of Texas Instruments Incorporated nor the names of +; its contributors may be used to endorse or promote products derived +; from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +; +; file: macros.inc +; +; brief: PRU cycle-counter macros + +M_ENABLE_PRU_CYCLE_COUNTER .macro + lbco &scratch, PRU_CTRL_CONST, 0, 4 + clr scratch, scratch, 3 + sbco &scratch, PRU_CTRL_CONST, 0, 4 + ldi32 scratch2, 0 + sbco &scratch2, PRU_CTRL_CONST, PRU_CYCLCNT, 4 + set scratch, scratch, 3 + sbco &scratch, PRU_CTRL_CONST, 0, 4 + .endm + +; Macro to reset cycle counter +M_RESET_CYCLCNT .macro + ldi32 scratch2, 0 + sbco &scratch2, PRU_CTRL_CONST, PRU_CYCLCNT, 4 + .endm + +; Macro to read cycle counter +M_READ_CYCLCNT .macro dst + lbco &dst, PRU_CTRL_CONST, PRU_CYCLCNT, 4 + .endm diff --git a/examples/pru_eqep/firmware/include/memory.inc b/examples/pru_eqep/firmware/include/memory.inc new file mode 100644 index 000000000..556df1085 --- /dev/null +++ b/examples/pru_eqep/firmware/include/memory.inc @@ -0,0 +1,177 @@ +; Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/ +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; +; Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the +; distribution. +; +; Neither the name of Texas Instruments Incorporated nor the names of +; its contributors may be used to endorse or promote products derived +; from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +; +;--------------------------------------------------------------------------; +; REGISTER ASSIGNMENT + .asg r0, scratch + .asg r1, scratch2 + .asg r17.b0, curr_gpi_sample ; Current GPI state after masking + .asg r17.b1, A_B_Z_edge ; Edge detection for A,B,Z signals + .asg r18, curr_ts ; Timestamp counter + .asg r19.b0, edge ; Edge detection + .asg r20.b0, prev_sample ; Previous state of A,B,Z signals + .asg r21, time_stamp ; Time stamp counter + .asg r22.w0, buffer_addr ; Buffer address pointer + .asg r22.w2, buffer_size ; Buffer size + .asg r23, wr_ptr ; Write pointer + .asg r24.w0, READ_POS_BUFF ; Read position buffer + .asg r24.w2, read_pos_speed_intr ; Read position speed interrupt + .asg r26.b0, a_b_transition ; A/B transition state + .asg r26.b1, qpos_update ; 2-> QPOS--, 1-> QPOS++, 0-> no change + .asg r27, QPOS ; Position counter + .asg r28, DMEM0 ; Data memory pointer + +; Define cur_sample based on core type + .if $isdefed("RTU_PRU0") | $isdefed("RTU_PRU1") + .asg r31.b0, cur_sample ; Use byte0 for GPIs 0-7 + .elseif $isdefed("PRU0") + .asg r31.b0, cur_sample ; Use byte0 for GPIs 0-7 + .elseif $isdefed("TX_PRU0") + .asg r31.b0, cur_sample ; Use byte0 for GPIs 0-7 + .elseif $isdefed("TX_PRU1") + .asg r31.b1, cur_sample ; Use byte1 for GPIs 8-15 + .elseif $isdefed("PRU1") + .asg r31.b1, cur_sample ; Use byte1 for GPIs 8-15 + .endif + +; Constants + .if $isdefed("TX_PRU0") | $isdefed("TX_PRU1") + ; C11 is not set correctly for TXPRUs. So C28 is programmed and used. +PRU_CTRL_CONST .set c28 + .else +PRU_CTRL_CONST .set c11 + .endif +PRU_CYCLCNT .set 0x0c +MAX_BUFFER .set 0x400 ; Buffer size = 8 kB +READ_POS_SPEED_BUFF .set 0x4 + +;--------------------------------------------------------------------------; +; Core-specific definitions + +; RTU_PRU0 Configuration (GPIs 0-7) + .if $isdefed("RTU_PRU0") +DMEM0_BASE .set 0x0 +DMEM1 .set C25 +intr_mask .set 0x20 ; PRU INTC EVENT 16 +A_SIGNAL_GPI .set (0x0) ; +B_SIGNAL_GPI .set (0x1) ; +Z_SIGNAL_GPI .set (0x6) ; +A_B_Z_GPI_mask .set 0x43 ; Byte level mask for GPI0,1 (0b0100_0011) +CH_POS_OFFSET .set 0x1C +WRITE_PTR_OFFSET .set 0x0 +PHASE_ERR_CNT_OFFSET .set 0x34 + .endif + +; PRU0 Configuration (GPIs 8-15) + .if $isdefed("PRU0") +DMEM0_BASE .set 0x400 +DMEM1 .set C25 +intr_mask .set 0x21 ; PRU INTC EVENT 17 +A_SIGNAL_GPI .set (0x2) ; +B_SIGNAL_GPI .set (0x3) ; +Z_SIGNAL_GPI .set (0x6) ; +A_B_Z_GPI_mask .set 0x4C ; Byte level mask for GPI2,3 (0b0100_1100) +CH_POS_OFFSET .set 0x20 +WRITE_PTR_OFFSET .set 0x4 +PHASE_ERR_CNT_OFFSET .set 0x38 + .endif + +; TX_PRU0 Configuration (GPIs 16-19) + .if $isdefed("TX_PRU0") +DMEM0_BASE .set 0x800 +DMEM1 .set C25 +intr_mask .set 0x22 ; PRU INTC EVENT 18 +A_SIGNAL_GPI .set (0x4) ; +B_SIGNAL_GPI .set (0x5) ; +Z_SIGNAL_GPI .set (0x6) ; +A_B_Z_GPI_mask .set 0x70 ; Byte level mask for GPI4,5 (0b0111_0000) +CH_POS_OFFSET .set 0x24 +WRITE_PTR_OFFSET .set 0x8 +PHASE_ERR_CNT_OFFSET .set 0x3C + .endif + +; RTU_PRU1 Configuration (GPIs 0-7) + .if $isdefed("RTU_PRU1") +DMEM0_BASE .set 0x2C00 +DMEM1 .set C24 +intr_mask .set 0x23 ; PRU INTC EVENT 19 +A_SIGNAL_GPI .set (0x0) ; +B_SIGNAL_GPI .set (0x1) ; +Z_SIGNAL_GPI .set (0x2) ; +A_B_Z_GPI_mask .set 0x7 ; Byte level mask for GPI0,1 (0b0000_0111) +CH_POS_OFFSET .set 0x28 +WRITE_PTR_OFFSET .set 0xC +PHASE_ERR_CNT_OFFSET .set 0x40 + .endif + +; PRU1 Configuration (GPIs 8-15) + .if $isdefed("PRU1") +DMEM0_BASE .set 0x3000 +DMEM1 .set C24 +intr_mask .set 0x24 ; PRU INTC EVENT 20 +A_SIGNAL_GPI .set (0xB) - 8 ; +B_SIGNAL_GPI .set (0xC) - 8 ; +Z_SIGNAL_GPI .set (0x2) ; +A_B_Z_GPI_mask .set 0x5C ; Byte level mask for GPI11,12 (0b0101_1100) +CH_POS_OFFSET .set 0x2C +WRITE_PTR_OFFSET .set 0x10 +PHASE_ERR_CNT_OFFSET .set 0x44 + .endif + +; TX_PRU1 Configuration (GPIs 16-19) + .if $isdefed("TX_PRU1") +DMEM0_BASE .set 0x3400 +DMEM1 .set C24 +intr_mask .set 0x25 ; PRU INTC EVENT 21 +A_SIGNAL_GPI .set (0xD) - 8 ; +B_SIGNAL_GPI .set (0xF) - 8 ; +Z_SIGNAL_GPI .set (0x2) ; +A_B_Z_GPI_mask .set 0xA4 ; Byte level mask for GPI13,15 (0b1010_0100) + +CH_POS_OFFSET .set 0x30 +WRITE_PTR_OFFSET .set 0x14 +PHASE_ERR_CNT_OFFSET .set 0x48 + .endif + +;--------------------------------------------------------------------------; +; GPI Byte Selection Guide: +; GPIs 0-7: Use r31.b0 (RTU_PRU0, RTU_PRU1) +; GPIs 8-15: Use r31.b1 (PRU0, PRU1) +; GPIs 16-19: Use r31.b2 (TX_PRU0, TX_PRU1) +; +; Note: GPI numbers are adjusted to byte-level (0-7) for each byte: +; - For GPIs 8-15: Subtract 8 from GPI number +; - For GPIs 16-19: Subtract 16 from GPI number +; +; Register Usage Notes: +; r17.b0 (curr_gpi_sample): Stores masked GPI state +; r17.b1 (A_B_Z_edge): Edge detection for signals +; r31.b0/b1/b2 (cur_sample): Raw GPI input - byte selection based on GPI numbers +;--------------------------------------------------------------------------; diff --git a/examples/pru_eqep/firmware/main.asm b/examples/pru_eqep/firmware/main.asm new file mode 100644 index 000000000..ee1c4ee06 --- /dev/null +++ b/examples/pru_eqep/firmware/main.asm @@ -0,0 +1,180 @@ +; Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/ +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; +; Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the +; distribution. +; +; Neither the name of Texas Instruments Incorporated nor the names of +; its contributors may be used to endorse or promote products derived +; from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +; +; file: main.asm +; +; brief: incremental encoder interface with max 4 MHz + + .include "memory.inc" + .include "macros.inc" + + ; Required directives for CCS/makefile + .retain + .retainrefs + .global main + .sect ".text" + +main: + ; Initialize registers + zero &r0, 116 ; Clear registers + ldi32 DMEM0, DMEM0_BASE + ldi buffer_size, MAX_BUFFER ; Set buffer size to 8 kB + ldi A_B_Z_edge,A_B_Z_GPI_mask + ldi read_pos_speed_intr, READ_POS_SPEED_BUFF + ldi a_b_transition, 0 + mov curr_gpi_sample, cur_sample + and curr_gpi_sample, curr_gpi_sample, A_B_Z_edge + mov prev_sample, curr_gpi_sample ; Initialize previous sample + + ; Initialize A/B transition states + qbbc Curr_A_not_set0, curr_gpi_sample, A_SIGNAL_GPI + SET a_b_transition, a_b_transition, 1 +Curr_A_not_set0: + qbbc Curr_B_not_set0, curr_gpi_sample, B_SIGNAL_GPI + SET a_b_transition, a_b_transition, 0 +Curr_B_not_set0: + + ; Start high-speed capture routine + M_RESET_CYCLCNT + +capture: +capture_wrap: + ; If PRU counter has saturated, reenable the counter + lbco &scratch, PRU_CTRL_CONST, 0, 4 + qbbs skip_counter_reenable, scratch, 3 + M_RESET_CYCLCNT + set scratch, scratch, 3 + sbco &scratch, PRU_CTRL_CONST, 0, 4 +skip_counter_reenable: + + ; Wait for signal change + ; Load current state of A, B, Z signals into a register + mov curr_gpi_sample, cur_sample ; Get current GPI states + and curr_gpi_sample, curr_gpi_sample, A_B_Z_edge ; Mask for GPI3(A), GPI4(B), GPI6(Z) for PRU0 + + ; Compare with previous state + qbeq capture, curr_gpi_sample, prev_sample ; If no change in A,B,Z, keep polling + + ; Capture timestamp + M_READ_CYCLCNT curr_ts + M_RESET_CYCLCNT + add time_stamp, time_stamp, curr_ts + mov edge, curr_gpi_sample + + ; Update A/B transition register + LSL a_b_transition, a_b_transition, 2 + qbbc Curr_A_not_set, curr_gpi_sample, A_SIGNAL_GPI + SET a_b_transition, a_b_transition, 1 +Curr_A_not_set: + qbbc Curr_B_not_set, curr_gpi_sample, B_SIGNAL_GPI + SET a_b_transition, a_b_transition, 0 +Curr_B_not_set: + + ; Save current state + mov prev_sample, curr_gpi_sample + + ; Handle buffer wrap-around before writing, so buffer_addr stays in bounds + qbgt write_in_bounds, buffer_addr, buffer_size + ldi buffer_addr, 0 + ldi READ_POS_BUFF, 0 + +write_in_bounds: + sbbo &time_stamp, DMEM0, buffer_addr, 4 + sbco &buffer_addr, DMEM1, WRITE_PTR_OFFSET, 2 + qbgt no_buffer_wrap, buffer_addr, buffer_size + + ; Handle Z signal reset + qbbs Z_interrupt0, r31, Z_SIGNAL_GPI + ;zero &QPOS, 4 +Z_interrupt0: + + ; Position counter update logic + and a_b_transition, a_b_transition, 0xf + add a_b_transition, a_b_transition, 0xf0 + lbco &qpos_update, DMEM1, a_b_transition, 1 + + ; Handle phase error (simultaneous A/B transition) + qbne no_phase_err0, qpos_update, 3 + lbco &scratch2, DMEM1, PHASE_ERR_CNT_OFFSET, 4 + add scratch2, scratch2, 1 + sbco &scratch2, DMEM1, PHASE_ERR_CNT_OFFSET, 4 + sbco &QPOS, DMEM1, CH_POS_OFFSET, 4 + qba capture_wrap +no_phase_err0: + ; Handle increment/decrement based on direction + qbbc no_increment0, qpos_update, 0 + add QPOS, QPOS, 1 + sbco &QPOS, DMEM1, CH_POS_OFFSET, 4 + qba capture_wrap +no_increment0: + qbbc no_decrement0, qpos_update, 1 + sub QPOS, QPOS, 1 +no_decrement0: + sbco &QPOS, DMEM1, CH_POS_OFFSET, 4 + qba capture_wrap + +no_buffer_wrap: + add buffer_addr, buffer_addr, 4 + add READ_POS_BUFF, READ_POS_BUFF, 4 + + ; Handle Z signal reset + qbbs Z_interrupt1, r31, Z_SIGNAL_GPI + ;zero &QPOS, 4 +Z_interrupt1: + + ; Position counter update logic + and a_b_transition, a_b_transition, 0xf + add a_b_transition, a_b_transition, 0xf0 + lbco &qpos_update, DMEM1, a_b_transition, 1 + + ; Handle phase error (simultaneous A/B transition) + qbne no_phase_err1, qpos_update, 3 + lbco &scratch2, DMEM1, PHASE_ERR_CNT_OFFSET, 4 + add scratch2, scratch2, 1 + sbco &scratch2, DMEM1, PHASE_ERR_CNT_OFFSET, 4 + sbco &QPOS, DMEM1, CH_POS_OFFSET, 4 + qba capture_wrap +no_phase_err1: + ; Handle increment/decrement based on direction + qbbc no_increment, qpos_update, 0 + add QPOS, QPOS, 1 + sbco &QPOS, DMEM1, CH_POS_OFFSET, 4 + qba capture_wrap +no_increment: + qbbc no_decrement, qpos_update, 1 + sub QPOS, QPOS, 1 +no_decrement: + sbco &QPOS, DMEM1, CH_POS_OFFSET, 4 + + ; Check for slow mode transition + qbbc capture_wrap, r31, 30 + +capture_slow: + halt ; Halt PRU when in slow mode diff --git a/examples/pru_eqep/images/A_B_signal.png b/examples/pru_eqep/images/A_B_signal.png new file mode 100644 index 000000000..32b65e8a5 Binary files /dev/null and b/examples/pru_eqep/images/A_B_signal.png differ diff --git a/examples/pru_eqep/images/EQEP.jpg b/examples/pru_eqep/images/EQEP.jpg new file mode 100644 index 000000000..adf3ce6c4 Binary files /dev/null and b/examples/pru_eqep/images/EQEP.jpg differ diff --git a/examples/pru_eqep/images/PRU_firmware_flow.jpg b/examples/pru_eqep/images/PRU_firmware_flow.jpg new file mode 100644 index 000000000..2f592be22 Binary files /dev/null and b/examples/pru_eqep/images/PRU_firmware_flow.jpg differ diff --git a/examples/pru_eqep/images/r5f_application_flow.jpg b/examples/pru_eqep/images/r5f_application_flow.jpg new file mode 100644 index 000000000..ff767334d Binary files /dev/null and b/examples/pru_eqep/images/r5f_application_flow.jpg differ diff --git a/examples/pru_eqep/images/system_block_diagram.jpg b/examples/pru_eqep/images/system_block_diagram.jpg new file mode 100644 index 000000000..4eb14073b Binary files /dev/null and b/examples/pru_eqep/images/system_block_diagram.jpg differ diff --git a/examples/pru_eqep/makefile b/examples/pru_eqep/makefile new file mode 100644 index 000000000..a3afdc826 --- /dev/null +++ b/examples/pru_eqep/makefile @@ -0,0 +1,110 @@ +include ../../imports.mak + +####################### +# project information # +####################### + +PROJECT_NAME := pru_eqep +SUPPORTED_PROCESSORS := am243x +# Does the PRU code have dependencies outside of the open-pru repo? +PRU_DEPENDENCIES := +# Use NON_PRU_DEPENDENCIES to select which makefiles to call for non-PRU cores +NON_PRU_DEPENDENCIES := mcuplus + +################### +# Prebuild checks # +################### +BUILD_PROJECT := y +DEVICE_NON_PRU := + +# Only build project if $(DEVICE) is in $(SUPPORTED_PROCESSORS) +ifeq (,$(findstring $(DEVICE),$(SUPPORTED_PROCESSORS))) +BUILD_PROJECT := n +MESSAGE := Project $(PROJECT_NAME) does not have a build option for $(DEVICE) +endif + +# Only build project if PRU dependencies exist +ifneq (,$(PRU_DEPENDENCIES)) +# MCU+ SDK dependency? +ifeq (mcuplus,$(findstring mcuplus,$(PRU_DEPENDENCIES))) +ifneq ($(BUILD_MCUPLUS),y) +BUILD_PROJECT := n +MESSAGE ?= Project $(PROJECT_NAME) depends on MCU+ SDK, but BUILD_MCUPLUS != y. +endif +endif +# Additional PRU dependency checks go here. For example: +#ifeq (dependency,$(findstring dependency,$(PRU_DEPENDENCIES))) +#if (dependency check fails) +#BUILD_PROJECT := n +#MESSAGE ?= Project $(PROJECT_NAME) depends on dependency, but dependency does not exist. +#endif +#endif +endif + +# Only build non-PRU code if the non-PRU code is enabled in imports.mak +ifeq ($(BUILD_MCUPLUS),y) +ifeq (mcuplus,$(findstring mcuplus,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_mcuplus +endif +endif +ifeq ($(BUILD_LINUX),y) +ifeq (linux,$(findstring linux,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_linux +endif +endif + +########################### +# Make and clean commands # +########################### + +ifeq ($(BUILD_PROJECT),y) +# "make" or "make all" builds projects that match $(DEVICE) set in imports.mak +# "make" builds PRU firmware first, then host (non-PRU) code +all: MESSAGE = "Building $(PROJECT_NAME) for $(DEVICE)" +all: pre_build_message + $(MAKE) pru + $(MAKE) host + +# "make pru" builds only PRU firmware for $(DEVICE) +pru: ARGUMENTS_PRU = all +pru: $(DEVICE) + +# "make host" builds only host (non-PRU) code for $(DEVICE) +host: ARGUMENTS_MCUPLUS = all +host: $(DEVICE_NON_PRU) + +# "make clean" cleans projects that match $(DEVICE) set in imports.mak +clean: ARGUMENTS_PRU = clean +clean: ARGUMENTS_MCUPLUS = scrub +clean: MESSAGE = "Cleaning $(PROJECT_NAME) for $(DEVICE)" +clean: pre_build_message $(DEVICE) $(DEVICE_NON_PRU) + +else +# if a prebuild check failed, print message and exit +all clean pru host: pre_build_message +endif + +pre_build_message: + @echo $(MESSAGE) + +###################### +# Target definitions # +###################### + +# provide target definitions for each supported processor +# PRU firmware should be built before any RTOS code that includes it +am243x: +# am243x-lp + $(MAKE) -C firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +am243x_mcuplus: +# am243x-lp + $(MAKE) -C mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang $(ARGUMENTS_MCUPLUS) + +.PHONY: all clean pru host pre_build_message $(DEVICE) $(DEVICE_NON_PRU) $(SUPPORTED_PROCESSORS) + diff --git a/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg new file mode 100644 index 000000000..d0702068f --- /dev/null +++ b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,323 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM243x_ALX_beta" --part "ALX" --package "ALX" --context "r5fss0-0" --product "OPEN_PRU@2026.02.00" --product "MCU_PLUS_SDK_AM243x@11.01.00" + * @v2CliArgs --device "AM2434" --package "FCCSP (ALX)" --variant "AM2434-E" --context "r5fss0-0" --product "OPEN_PRU@2026.02.00" --product "MCU_PLUS_SDK_AM243x@11.01.00" + * @versions {"tool":"1.26.0+4407"} + */ + +/** + * Import the modules used in this configuration. + */ +const pruicss = scripting.addModule("/drivers/pruicss/pruicss", {}, false); +const pruicss1 = pruicss.addInstance(); +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const default_linker = scripting.addModule("/memory_configurator/default_linker", {}, false); +const default_linker1 = default_linker.addInstance(); +const general = scripting.addModule("/memory_configurator/general", {}, false); +const general1 = general.addInstance(); +const region = scripting.addModule("/memory_configurator/region", {}, false); +const region1 = region.addInstance(); +const section = scripting.addModule("/memory_configurator/section", {}, false); +const section1 = section.addInstance(); +const section2 = section.addInstance(); +const section3 = section.addInstance(); +const section4 = section.addInstance(); +const section5 = section.addInstance(); +const section6 = section.addInstance(); +const section7 = section.addInstance(); +const section8 = section.addInstance(); +const section9 = section.addInstance(); +const section10 = section.addInstance(); +const section11 = section.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.iepClk = 250000000; +pruicss1.coreClk = 300000000; +pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO.create(2); +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].$name = "CONFIG_PRU_ICSS_GPIO1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.$assign = "PRU_ICSSG0_PRU1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI0.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI1.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI10.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI11.$assign = "PRG0_PRU1_GPO11"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI11.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI12.$assign = "PRG0_PRU1_GPO12"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI12.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI13.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI14.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI15.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI16.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI16.$assign = "PRG0_PRU1_GPO16"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI17.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI18.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI19.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI2.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI3.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI4.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI5.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI6.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI6.$assign = "PRG0_PRU1_GPO6"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI7.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI8.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI8.$assign = "PRG0_PRU1_GPO8"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI9.rx = false; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].$name = "CONFIG_PRU_ICSS_GPIO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI0.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI1.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI2.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI3.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI4.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI5.$used = true; +pruicss1.intcMapping.create(6); +pruicss1.intcMapping[0].$name = "CONFIG_ICSS0_INTC_MAPPING0"; +pruicss1.intcMapping[1].$name = "CONFIG_ICSS0_INTC_MAPPING1"; +pruicss1.intcMapping[1].event = "17"; +pruicss1.intcMapping[1].channel = "3"; +pruicss1.intcMapping[2].$name = "CONFIG_ICSS0_INTC_MAPPING2"; +pruicss1.intcMapping[2].event = "18"; +pruicss1.intcMapping[2].channel = "4"; +pruicss1.intcMapping[3].$name = "CONFIG_ICSS0_INTC_MAPPING3"; +pruicss1.intcMapping[3].event = "19"; +pruicss1.intcMapping[3].channel = "5"; +pruicss1.intcMapping[4].$name = "CONFIG_ICSS0_INTC_MAPPING4"; +pruicss1.intcMapping[4].event = "20"; +pruicss1.intcMapping[4].channel = "6"; +pruicss1.intcMapping[5].$name = "CONFIG_ICSS0_INTC_MAPPING5"; +pruicss1.intcMapping[5].event = "21"; +pruicss1.intcMapping[5].channel = "7"; + +debug_log.enableUartLog = true; +debug_log.enableSharedMemLog = true; +debug_log.enableMemLog = true; +debug_log.enableSharedMemLogReader = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.inputClkFreq = 192000000; +debug_log.uartLog.UART.$assign = "USART0"; + +const uart_v0_template = scripting.addModule("/drivers/uart/v0/uart_v0_template", {}, false); +const uart_v0_template1 = uart_v0_template.addInstance({}, false); +uart_v0_template1.$name = "drivers_uart_v0_uart_v0_template0"; +debug_log.uartLog.child = uart_v0_template1; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +default_linker1.$name = "memory_configurator_default_linker0"; + +general1.$name = "CONFIG_GENERAL0"; +general1.linker.$name = "TIARMCLANG0"; + +region1.$name = "MEMORY_REGION_CONFIGURATION0"; +region1.memory_region.create(9); +region1.memory_region[0].type = "TCMA_R5F"; +region1.memory_region[0].$name = "R5F_VECS"; +region1.memory_region[0].size = 0x40; +region1.memory_region[0].auto = false; +region1.memory_region[1].type = "TCMA_R5F"; +region1.memory_region[1].$name = "R5F_TCMA"; +region1.memory_region[1].size = 0x7FC0; +region1.memory_region[2].type = "TCMB_R5F"; +region1.memory_region[2].$name = "R5F_TCMB0"; +region1.memory_region[2].size = 0x8000; +region1.memory_region[3].$name = "NON_CACHE_MEM"; +region1.memory_region[3].auto = false; +region1.memory_region[3].manualStartAddress = 0x70060000; +region1.memory_region[3].size = 0x8000; +region1.memory_region[4].$name = "MSRAM"; +region1.memory_region[4].manualStartAddress = 0x70080000; +region1.memory_region[4].size = 0x40000; +region1.memory_region[4].auto = false; +region1.memory_region[5].type = "FLASH"; +region1.memory_region[5].$name = "FLASH"; +region1.memory_region[5].auto = false; +region1.memory_region[5].manualStartAddress = 0x60100000; +region1.memory_region[5].size = 0x80000; +region1.memory_region[6].$name = "USER_SHM_MEM"; +region1.memory_region[6].auto = false; +region1.memory_region[6].manualStartAddress = 0x701D0000; +region1.memory_region[6].size = 0x180; +region1.memory_region[6].isShared = true; +region1.memory_region[6].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[7].auto = false; +region1.memory_region[7].manualStartAddress = 0x701D0180; +region1.memory_region[7].size = 0x3E80; +region1.memory_region[7].$name = "LOG_SHM_MEM"; +region1.memory_region[7].isShared = true; +region1.memory_region[7].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[8].auto = false; +region1.memory_region[8].manualStartAddress = 0x701D4000; +region1.memory_region[8].size = 0xC000; +region1.memory_region[8].$name = "RTOS_NORTOS_IPC_SHM_MEM"; +region1.memory_region[8].isShared = true; +region1.memory_region[8].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; + +section1.$name = "Vector Table"; +section1.load_memory = "R5F_VECS"; +section1.group = false; +section1.output_section.create(1); +section1.output_section[0].$name = ".vectors"; +section1.output_section[0].palignment = true; + +section2.$name = "Text Segments"; +section2.load_memory = "MSRAM"; +section2.output_section.create(5); +section2.output_section[0].$name = ".text.hwi"; +section2.output_section[0].palignment = true; +section2.output_section[1].$name = ".text.cache"; +section2.output_section[1].palignment = true; +section2.output_section[2].$name = ".text.mpu"; +section2.output_section[2].palignment = true; +section2.output_section[3].$name = ".text.boot"; +section2.output_section[3].palignment = true; +section2.output_section[4].$name = ".text:abort"; +section2.output_section[4].palignment = true; + +section3.$name = "Code and Read-Only Data"; +section3.load_memory = "MSRAM"; +section3.output_section.create(2); +section3.output_section[0].$name = ".text"; +section3.output_section[0].palignment = true; +section3.output_section[1].$name = ".rodata"; +section3.output_section[1].palignment = true; + +section4.$name = "Data Segment"; +section4.load_memory = "MSRAM"; +section4.output_section.create(1); +section4.output_section[0].$name = ".data"; +section4.output_section[0].palignment = true; + +section5.$name = "Memory Segments"; +section5.load_memory = "MSRAM"; +section5.output_section.create(3); +section5.output_section[0].$name = ".bss"; +section5.output_section[0].palignment = true; +section5.output_section[0].output_sections_start = "__BSS_START"; +section5.output_section[0].output_sections_end = "__BSS_END"; +section5.output_section[1].$name = ".sysmem"; +section5.output_section[1].palignment = true; +section5.output_section[2].$name = ".stack"; +section5.output_section[2].palignment = true; + +section6.$name = "Stack Segments"; +section6.load_memory = "MSRAM"; +section6.output_section.create(5); +section6.output_section[0].$name = ".irqstack"; +section6.output_section[0].output_sections_start = "__IRQ_STACK_START"; +section6.output_section[0].output_sections_end = "__IRQ_STACK_END"; +section6.output_section[0].input_section.create(1); +section6.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;"; +section6.output_section[1].$name = ".fiqstack"; +section6.output_section[1].output_sections_start = "__FIQ_STACK_START"; +section6.output_section[1].output_sections_end = "__FIQ_STACK_END"; +section6.output_section[1].input_section.create(1); +section6.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;"; +section6.output_section[2].$name = ".svcstack"; +section6.output_section[2].output_sections_start = "__SVC_STACK_START"; +section6.output_section[2].output_sections_end = "__SVC_STACK_END"; +section6.output_section[2].input_section.create(1); +section6.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;"; +section6.output_section[3].$name = ".abortstack"; +section6.output_section[3].output_sections_start = "__ABORT_STACK_START"; +section6.output_section[3].output_sections_end = "__ABORT_STACK_END"; +section6.output_section[3].input_section.create(1); +section6.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;"; +section6.output_section[4].$name = ".undefinedstack"; +section6.output_section[4].output_sections_start = "__UNDEFINED_STACK_START"; +section6.output_section[4].output_sections_end = "__UNDEFINED_STACK_END"; +section6.output_section[4].input_section.create(1); +section6.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;"; + +section7.$name = "Initialization and Exception Handling"; +section7.load_memory = "MSRAM"; +section7.output_section.create(3); +section7.output_section[0].$name = ".ARM.exidx"; +section7.output_section[0].palignment = true; +section7.output_section[1].$name = ".init_array"; +section7.output_section[1].palignment = true; +section7.output_section[2].$name = ".fini_array"; +section7.output_section[2].palignment = true; + +section8.$name = "User Shared Memory"; +section8.type = "NOLOAD"; +section8.load_memory = "USER_SHM_MEM"; +section8.group = false; +section8.output_section.create(1); +section8.output_section[0].$name = ".bss.user_shared_mem"; +section8.output_section[0].alignment = 0; + +section9.$name = "Log Shared Memory"; +section9.load_memory = "LOG_SHM_MEM"; +section9.type = "NOLOAD"; +section9.group = false; +section9.output_section.create(1); +section9.output_section[0].$name = ".bss.log_shared_mem"; +section9.output_section[0].alignment = 0; + +section10.$name = "IPC Shared Memory"; +section10.type = "NOLOAD"; +section10.load_memory = "RTOS_NORTOS_IPC_SHM_MEM"; +section10.group = false; +section10.output_section.create(1); +section10.output_section[0].$name = ".bss.ipc_vring_mem"; +section10.output_section[0].alignment = 0; + +section11.$name = "Non Cacheable Memory"; +section11.load_memory = "NON_CACHE_MEM"; +section11.group = false; +section11.type = "NOLOAD"; +section11.output_section.create(1); +section11.output_section[0].$name = ".bss.nocache"; +section11.output_section[0].alignment = 0; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI0.$suggestSolution = "PRG0_PRU1_GPO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI1.$suggestSolution = "PRG0_PRU1_GPO1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI13.$suggestSolution = "PRG0_PRU1_GPO13"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI15.$suggestSolution = "PRG0_PRU1_GPO15"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPI2.$suggestSolution = "PRG0_PRU1_GPO2"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.$suggestSolution = "PRU_ICSSG0_PRU0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI0.$suggestSolution = "PRG0_PRU0_GPO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI1.$suggestSolution = "PRG0_PRU0_GPO1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI2.$suggestSolution = "PRG0_PRU0_GPO2"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI3.$suggestSolution = "PRG0_PRU0_GPO3"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI4.$suggestSolution = "PRG0_PRU0_GPO4"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPI5.$suggestSolution = "PRG0_PRU0_GPO5"; +debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD"; diff --git a/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/main.c b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/main.c new file mode 100644 index 000000000..1fda8d5b8 --- /dev/null +++ b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/main.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024-2025 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void pru_eqep_example_main(void *args); + +void freertos_main(void *args) +{ + pru_eqep_example_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 000000000..8c0a6c556 --- /dev/null +++ b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 000000000..1918b04bc --- /dev/null +++ b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,355 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +COV=$(CG_TOOL_ROOT)/bin/tiarmcov +PROFDATA=$(CG_TOOL_ROOT)/bin/tiarmprofdata +COVERAGE_PATH=$(abspath .) +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=pru_eqep.$(PROFILE).out +COREOUTNAME:=pru_eqep.$(PROFILE).optishare.out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=pru_eqep.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=pru_eqep.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=pru_eqep.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=pru_eqep.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=pru_eqep.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=pru_eqep.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=pru_eqep.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=pru_eqep.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) + + +FILES_common := \ + main.c \ + pru_eqep_example.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MCU_PLUS_SDK_PATH}/source \ + -I${OPEN_PRU_PATH}/source \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/config/am243x/r5f \ + -I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \ + -I${OPEN_PRU_PATH}/examples/pru_eqep/firmware/am243x-lp \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM243X \ + -DOS_FREERTOS \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -Wno-vla-cxx-extension \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + generated/linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/board/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ + + +LIBS_NAME = \ + freertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + ${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + ${MCU_PLUS_SDK_PATH}/source/board/lib \ + ${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +ifeq ($(INSTRUMENTATION_MODE), yes) +CFLAGS += -fprofile-instr-generate -fcoverage-mapping +endif +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +SYSTEM_FLAG ?= false + +ifeq ($(SYSTEM_FLAG), false) + SYSTEM_COMMAND := syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) +else + SYSTEM_COMMAND := $(OBJS) $(LNK_FILES) $(LIBS_NAME) +endif + +$(OUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +coreout: $(COREOUTNAME) +$(COREOUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Relinking Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ with OptiShare SSO.. + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml -Wl,--import_sso=$(SSO_PATH) + @echo Relinking with optishare: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am243x:r5fss0-0:freertos:ti-arm-clang pru_eqep ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin + $(RM) \*.lnkxml + $(RM) \*.ossr +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin + $(RM) *.lnkxml + $(RM) *.ossr +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +ifeq ($(SYSTEM_FLAG), false) +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg +endif + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --device AM243x_ALX_beta --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . +endif + + + +.PHONY: coverage +coverage: + @echo Creating Coverage Report for pru_eqep.$(PROFILE) ... + $(MKDIR) coverage + $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o pru_eqep.$(PROFILE).profdata + $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=pru_eqep.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins + $(COV) export --format=text --object=$(OUTNAME) --instr-profile=pru_eqep.$(PROFILE).profdata > coverage/pru_eqep.$(PROFILE).profdata.json + node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/pru_eqep.$(PROFILE).profdata.json --output-json=coverage/pru_eqep.$(PROFILE).analysis.json --output=../pru_eqep.annotations.$(PROFILE).S --top-function-count=500 + @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!! + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 000000000..5bcdc554e --- /dev/null +++ b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,113 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - OPEN_PRU_PATH +# - MCU_PLUS_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs + $(RM) $(BOOTIMAGE_NAME) +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 000000000..9d288b4eb --- /dev/null +++ b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=pru_eqep_am243x-lp_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 000000000..f716f8e9d --- /dev/null +++ b/examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,12 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "kernel/freertos/rov/FreeRTOS.rov.js", +]; + +var objectViewerFiles = [ + "kernel/freertos/rov_theia/FreeRTOS_Theia.rov.js", +]; diff --git a/examples/pru_eqep/mcuplus/eqep_diagnostic.h b/examples/pru_eqep/mcuplus/eqep_diagnostic.h new file mode 100644 index 000000000..0c6d20fb5 --- /dev/null +++ b/examples/pru_eqep/mcuplus/eqep_diagnostic.h @@ -0,0 +1,145 @@ +/* +* Copyright (C) 2025 Texas Instruments Incorporated +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the +* distribution. +* +* Neither the name of Texas Instruments Incorporated nor the names of +* its contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +// Typedef for ABZ handle +typedef struct ABZ_Config_s *ABZ_Handle; + +// Enum for different states +typedef enum +{ + // States for Prev_A_edge=0, Prev_B_edge=0 + STATE_00_00, + STATE_00_01, + STATE_00_10, + STATE_00_11, + + // States for Prev_A_edge=0, Prev_B_edge=1 + STATE_01_00, + STATE_01_01, + STATE_01_10, + STATE_01_11, + + // States for Prev_A_edge=1, Prev_B_edge=0 + STATE_10_00, + STATE_10_01, + STATE_10_10, + STATE_10_11, + + // States for Prev_A_edge=1, Prev_B_edge=1 + STATE_11_00, + STATE_11_01, + STATE_11_10, + STATE_11_11, + +} State; + +// Structure for ABZ configuration +typedef struct ABZ_Config_s { + + uint8_t channel; + // Handle for PRUICSS instance + PRUICSS_Handle icssHandle; + /**< PRUICSS_Handle for icssg0 or icssg1 instance*/ + + // PRUICSS core identifier + uint32_t pru_slice; + /**< PRUICSS core identifier + * Check PRUICSS_PRU0 and check other available macros + */ + + // Base memory address for ABZ channel configuration + uint32_t *baseMemAddr0; // icssHandle->hwAttrs->baseAddr + PRUICSS_DATARAM(PRUICSS_PRUx) + /**< Base Memory Address for ABZ channel configuration */ + + // Base memory address for ABZ channel configuration + uint32_t *baseMemAddr1; // icssHandle->hwAttrs->baseAddr + PRUICSS_DATARAM(PRUICSS_PRUx) + /**< Base Memory Address for ABZ channel configuration */ + + // Pointer to ABZ interface structure + ABZ_Handle *ABZInterface; + /**< ABZ master memory interface structure */ + + // Read and write pointers + uint32_t *read_ptr; + uint32_t *write_ptr; + uint32_t mem_limit; + // Offsets for read and write pointers + uint32_t write_ptr_offset; + uint32_t read_ptr_offset; + + // Edge detection variables + uint32_t edges; + uint32_t prev_ts; //*Previous time stamp* + uint32_t cur_ts; //*Current time stamp* + + // Speed and direction variables + uint32_t speed; + uint32_t delta_t; + uint32_t iter; + uint32_t iter1; + + // Edge status variables + uint32_t A_cur_edge; + uint32_t A_prev_edge; + uint32_t B_prev_edge; + uint32_t B_cur_edge; + + // Quadrature position counter + uint32_t QPOSCOUNT; + + // Previous quadrature position + int32_t prev_QPOS; + + // Edge status register + int32_t A_B_EDGE_STATUS; // 4 bit status for following fields-> [(Prev_A_Edge),(Prev_B_Edge),(Curr_A_Edge),(Curr_B_Edge)] + + + // Direction variable + int32_t direction; + + // Position variable + uint32_t position; + + uint32_t *rev_intr; + int32_t temp_qpos; + // Qpos buffer + uint32_t *position_base; + uint32_t position_buffer[1000]; + + // Phase-error shadow-compare (PRU-write-only counter, R5F-read-only) + uint32_t *phase_err_base; + uint32_t phase_err_count; + uint32_t phase_err_count_last_seen; + uint32_t phase_error_flag; +} ABZ_Config; + + diff --git a/examples/pru_eqep/mcuplus/pru_eqep_example.c b/examples/pru_eqep/mcuplus/pru_eqep_example.c new file mode 100644 index 000000000..08fabf3ef --- /dev/null +++ b/examples/pru_eqep/mcuplus/pru_eqep_example.c @@ -0,0 +1,564 @@ +/* +* Copyright (C) 2025 Texas Instruments Incorporated +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the +* distribution. +* +* Neither the name of Texas Instruments Incorporated nor the names of +* its contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +// Include necessary header files +#include +#include +#include "ti_drivers_config.h" +#include "ti_drivers_open_close.h" +#include "ti_board_open_close.h" +#include +// #include +#include +#include +#include +#include "eqep_diagnostic.h" +#include +#include +#include +#include +#include +#include + +#define CTR_EN (1 << 3) +// Define offsets for each channel in DMEM +#define DMEM_CHANNEL_SIZE 0x400 // 4KB per channel +#define DMEM_CH0_OFFSET 0x0000 // Channel 0 starts at base +#define DMEM_CH1_OFFSET 0x400 // Channel 1 starts at base + 4KB +#define DMEM_CH2_OFFSET 0x800 // Channel 2 starts at base + 8KB +#define DMEM_CH3_OFFSET 0x0C00 // Channel 3 (RTU_PRU1) starts in PRU1's DRAM bank +#define DMEM_CH4_OFFSET 0x1000 // Channel 4 (PRU1) starts in PRU1's DRAM bank +#define DMEM_CH5_OFFSET 0x1400 // Channel 5 (TX_PRU1) starts in PRU1's DRAM bank + +// Define position offsets for each channel (4 bytes each) +#define CH0_POSITION_OFFSET 0x1C // Base starting offset +#define CH1_POSITION_OFFSET 0x20 // 0x1C + 0x4 +#define CH2_POSITION_OFFSET 0x24 // 0x20 + 0x4 +#define CH3_POSITION_OFFSET 0x28 // 0x24 + 0x4 +#define CH4_POSITION_OFFSET 0x2C // 0x28 + 0x4 +#define CH5_POSITION_OFFSET 0x30 // 0x2C + 0x4 + +// Define phase-error counter offsets for each channel (PRU-write-only, R5F-read-only) +#define CH0_PHASE_ERR_OFFSET 0x34 +#define CH1_PHASE_ERR_OFFSET 0x38 +#define CH2_PHASE_ERR_OFFSET 0x3C +#define CH3_PHASE_ERR_OFFSET 0x40 +#define CH4_PHASE_ERR_OFFSET 0x44 +#define CH5_PHASE_ERR_OFFSET 0x48 + +// Define the delay after which we should print the results +#define PRINT_DELAY 1000000U + +// Define to enable mem_limit ring-buffer-wrap debug prints (Ch5 bench test) +// #define TEST_MEM_LIMIT_DEBUG + +// Array of offsets for easier access +static const uint32_t DMEM_OFFSETS[6] = { + DMEM_CH0_OFFSET, + DMEM_CH1_OFFSET, + DMEM_CH2_OFFSET, + DMEM_CH3_OFFSET, + DMEM_CH4_OFFSET, + DMEM_CH5_OFFSET +}; + +// Define constants +#define WRITE_PTR_OFFSET_MASK 0x0000FFFF +#define TIMESTAMP_MASK 0x00FFFFFF + +// Handle for PRUICSS instance +PRUICSS_Handle gPruIcssXHandle; + +// Pointer to PRU DRAM +void *gPru_dramx; +//void *gPru_dramx_0; +//void *gPru_dramx_1; +//void *gPru_dramx_2; +// Pointer to PRU configuration +static void *gPru_cfg; + +ABZ_Handle ABZHandle[6]; +ABZ_Config ABZInstance[6]; +// Define macros +#define PRU_CLK_FREQ 300000000 +#define EQEP_EDGE_THRESHOLD 4 /* edges to accumulate before processing — must match PRU firmware */ + +void EQEP_Get_Speed_ABZ(uint8_t channel); +void EQEP_get_speed_RT(uint8_t channel); +void EQEP_Get_position_ABZ(void); +void EQEP_PRU_clearPhaseErrorFlag(uint8_t channel); +void create_lut(void); // Remove static keyword from the implementation +void ABZ_enable_load_share_mode(void *pruCfg, uint32_t pruSlice); +void EQEP_pruss_load_run_fw(void); +void ABZ_PRU_ICSS_Init(PRUICSS_Handle handle, ABZ_Handle ABZHandle, uint8_t pru_core); +void EQEP_diagnostic_main(void *args); + +/** + * Load and run firmware on specified PRU core + * + * @param handle: PRUICSS handle + * @param pru_core: PRU core number + * @param fw_image: Pointer to firmware image array + * @param fw_size: Size of firmware image in bytes + */ +void EQEP_pruss_load_run_fw(void) +{ +//PRU0 Cores + // Disable all cores + PRUICSS_disableCore(gPruIcssXHandle, PRUICSS_RTU_PRU0); // ch0 + PRUICSS_disableCore(gPruIcssXHandle, PRUICSS_PRU0); // ch1 + PRUICSS_disableCore(gPruIcssXHandle, PRUICSS_TX_PRU0); // ch2 + + /* Enable Load Share mode */ + gPru_cfg = (void *)(((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->cfgRegBase); + ABZ_enable_load_share_mode(gPru_cfg, PRUICSS_PRU0); + + // Load firmware for each channel + PRUICSS_writeMemory(gPruIcssXHandle, PRUICSS_IRAM_RTU_PRU(PRUICSS_PRU0), + 0, (uint32_t *) RTUPRU0Firmware_0, + sizeof(RTUPRU0Firmware_0)); + + PRUICSS_writeMemory(gPruIcssXHandle, PRUICSS_IRAM_PRU(PRUICSS_PRU0), + 0, (uint32_t *) PRU0Firmware_0, + sizeof(PRU0Firmware_0)); + + PRUICSS_writeMemory(gPruIcssXHandle, PRUICSS_IRAM_TX_PRU(PRUICSS_PRU0), + 0, (uint32_t *) TXPRU0Firmware_0, + sizeof(TXPRU0Firmware_0)); + + // Reset cores + PRUICSS_resetCore(gPruIcssXHandle, PRUICSS_RTU_PRU0); + PRUICSS_resetCore(gPruIcssXHandle, PRUICSS_PRU0); + PRUICSS_resetCore(gPruIcssXHandle, PRUICSS_TX_PRU0); + + /* Run firmware */ + PRUICSS_enableCore(gPruIcssXHandle, PRUICSS_RTU_PRU0); + PRUICSS_enableCore(gPruIcssXHandle, PRUICSS_PRU0); + PRUICSS_enableCore(gPruIcssXHandle, PRUICSS_TX_PRU0); + +//PRU1 Cores +// Disable all cores + PRUICSS_disableCore(gPruIcssXHandle, PRUICSS_RTU_PRU1); // ch0 + PRUICSS_disableCore(gPruIcssXHandle, PRUICSS_PRU1); // ch1 + PRUICSS_disableCore(gPruIcssXHandle, PRUICSS_TX_PRU1); // ch2 + + /* Enable Load Share mode */ + gPru_cfg = (void *)(((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->cfgRegBase); + ABZ_enable_load_share_mode(gPru_cfg, PRUICSS_PRU1); + + // Load firmware for each channel + PRUICSS_writeMemory(gPruIcssXHandle, PRUICSS_IRAM_RTU_PRU(PRUICSS_PRU1), + 0, (uint32_t *) RTUPRU1Firmware_0, + sizeof(RTUPRU1Firmware_0)); + + PRUICSS_writeMemory(gPruIcssXHandle, PRUICSS_IRAM_PRU(PRUICSS_PRU1), + 0, (uint32_t *) PRU1Firmware_0, + sizeof(PRU1Firmware_0)); + + PRUICSS_writeMemory(gPruIcssXHandle, PRUICSS_IRAM_TX_PRU(PRUICSS_PRU1), + 0, (uint32_t *) TXPRU1Firmware_0, + sizeof(TXPRU1Firmware_0)); + + // Reset cores + PRUICSS_resetCore(gPruIcssXHandle, PRUICSS_RTU_PRU1); + PRUICSS_resetCore(gPruIcssXHandle, PRUICSS_PRU1); + PRUICSS_resetCore(gPruIcssXHandle, PRUICSS_TX_PRU1); + + /* Run firmware */ + PRUICSS_enableCore(gPruIcssXHandle, PRUICSS_RTU_PRU1); + PRUICSS_enableCore(gPruIcssXHandle, PRUICSS_PRU1); + PRUICSS_enableCore(gPruIcssXHandle, PRUICSS_TX_PRU1); +} +// Function to initialize PRU ICSS +void ABZ_PRU_ICSS_Init(PRUICSS_Handle handle, ABZ_Handle ABZHandle, uint8_t pru_core) +{ + // Disable PRU core + PRUICSS_disableCore(handle, pru_core); + + // Clear ICSS0 PRU data RAM + gPru_dramx = (void *)((((PRUICSS_HwAttrs *)(handle->hwAttrs))->baseAddr) + PRUICSS_DATARAM(pru_core)); + memset(gPru_dramx, 0, (4 * 1024)); + + // Initialize ICSS interrupt controller + gPru_cfg = (void *)(((PRUICSS_HwAttrs *)(handle->hwAttrs))->cfgRegBase); + PRUICSS_intcInit(handle, &icss0_intc_initdata); +} + +int32_t idx=0; + +// Main function +void pru_eqep_example_main(void *args) +{ + int32_t status; + // Open drivers and board + Drivers_open(); + status = Board_driversOpen(); + + DebugP_assert(SystemP_SUCCESS == status); + + // Initialize PRU ICSS with single handle + gPruIcssXHandle = PRUICSS_open(CONFIG_PRU_ICSS0); + + /* + * Set the constant table C28 for TX_PRUs. Configure the constant table C28 to point to the TX cycle + * counter. The counter is needed in firmware for adding waits and time-stamps. + */ + PRUICSS_setConstantTblEntry(gPruIcssXHandle, PRUICSS_TX_PRU0, PRUICSS_CONST_TBL_ENTRY_C28, 0x250); + PRUICSS_setConstantTblEntry(gPruIcssXHandle, PRUICSS_TX_PRU1, PRUICSS_CONST_TBL_ENTRY_C28, 0x258); + + for(int i=0; i<6; i++) + { + ABZHandle[i] = &ABZInstance[i]; + + // Use single handle for all channel configurations + ABZHandle[i]->baseMemAddr0 = (uint32_t *)( + ((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->pru0DramBase + + DMEM_OFFSETS[i] + ); + ABZHandle[i]->baseMemAddr1 = (uint32_t *)( + ((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->pru1DramBase + + i*4 + ); + ABZHandle[i]->icssHandle = gPruIcssXHandle; + ABZHandle[i]->prev_QPOS = 0; + ABZHandle[i]->QPOSCOUNT = 0; + ABZHandle[i]->read_ptr = ABZHandle[i]->baseMemAddr0; + ABZHandle[i]->write_ptr = ABZHandle[i]->baseMemAddr1; + ABZHandle[i]->mem_limit=DMEM_CHANNEL_SIZE; + if(i<3) ABZHandle[i]->pru_slice=0; + else ABZHandle[i]->pru_slice=1; + } + ABZHandle[0]->position_base = (void *)((uint32_t)(ABZHandle[0]->baseMemAddr1) + CH0_POSITION_OFFSET); + ABZHandle[1]->position_base = (void *)((uint32_t)(ABZHandle[1]->baseMemAddr1) + CH0_POSITION_OFFSET); + ABZHandle[2]->position_base = (void *)((uint32_t)(ABZHandle[2]->baseMemAddr1) + CH0_POSITION_OFFSET); + ABZHandle[3]->position_base = (void *)((uint32_t)(ABZHandle[3]->baseMemAddr1) + CH0_POSITION_OFFSET); + ABZHandle[4]->position_base = (void *)((uint32_t)(ABZHandle[4]->baseMemAddr1) + CH0_POSITION_OFFSET); + ABZHandle[5]->position_base = (void *)((uint32_t)(ABZHandle[5]->baseMemAddr1) + CH0_POSITION_OFFSET); + + ABZHandle[0]->phase_err_base = (uint32_t *)((uint32_t)(ABZHandle[0]->baseMemAddr1) + CH0_PHASE_ERR_OFFSET); + ABZHandle[1]->phase_err_base = (uint32_t *)((uint32_t)(ABZHandle[1]->baseMemAddr1) + CH0_PHASE_ERR_OFFSET); + ABZHandle[2]->phase_err_base = (uint32_t *)((uint32_t)(ABZHandle[2]->baseMemAddr1) + CH0_PHASE_ERR_OFFSET); + ABZHandle[3]->phase_err_base = (uint32_t *)((uint32_t)(ABZHandle[3]->baseMemAddr1) + CH0_PHASE_ERR_OFFSET); + ABZHandle[4]->phase_err_base = (uint32_t *)((uint32_t)(ABZHandle[4]->baseMemAddr1) + CH0_PHASE_ERR_OFFSET); + ABZHandle[5]->phase_err_base = (uint32_t *)((uint32_t)(ABZHandle[5]->baseMemAddr1) + CH0_PHASE_ERR_OFFSET); + // Initialize PRU ICSS for each channel + //PRU0 cores + ABZ_PRU_ICSS_Init(gPruIcssXHandle, ABZHandle[0], PRUICSS_RTU_PRU0); + ABZ_PRU_ICSS_Init(gPruIcssXHandle, ABZHandle[1], PRUICSS_PRU0); + ABZ_PRU_ICSS_Init(gPruIcssXHandle, ABZHandle[2], PRUICSS_TX_PRU0); + //PRU1 cores + ABZ_PRU_ICSS_Init(gPruIcssXHandle, ABZHandle[3], PRUICSS_RTU_PRU1); + ABZ_PRU_ICSS_Init(gPruIcssXHandle, ABZHandle[4], PRUICSS_PRU1); + ABZ_PRU_ICSS_Init(gPruIcssXHandle, ABZHandle[5], PRUICSS_TX_PRU1); + /* enable cycle counter */ + HW_WR_REG32((void *)((((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->baseAddr) + CSL_ICSS_G_PR1_RTU0_PR1_RTU0_IRAM_REGS_BASE), CTR_EN); // RTU_PRU Core + HW_WR_REG32((void *)((((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->baseAddr) + CSL_ICSS_G_PR1_PDSP0_IRAM_REGS_BASE), CTR_EN); + HW_WR_REG32((void *)((((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->baseAddr) + CSL_ICSS_G_PR1_PDSP_TX0_IRAM_REGS_BASE), CTR_EN); // TX_PRU Core + + HW_WR_REG32((void *)((((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->baseAddr) + CSL_ICSS_G_PR1_RTU1_PR1_RTU1_IRAM_REGS_BASE), CTR_EN); // RTU_PRU Core + HW_WR_REG32((void *)((((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->baseAddr) + CSL_ICSS_G_PR1_PDSP1_IRAM_REGS_BASE), CTR_EN); + HW_WR_REG32((void *)((((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->baseAddr) + CSL_ICSS_G_PR1_PDSP_TX1_IRAM_REGS_BASE), CTR_EN); // TX_PRU Core + + create_lut(); + + /* Startup sync: initialize read_ptr_offset to current write_ptr_offset so + * stale edges accumulated before R5F init are not processed */ + for (int i = 0; i < 6; i++) + { + ABZHandle[i]->read_ptr_offset = HW_RD_REG32(ABZHandle[i]->baseMemAddr1) & WRITE_PTR_OFFSET_MASK; + ABZHandle[i]->write_ptr_offset = ABZHandle[i]->read_ptr_offset; + } + // Load and run firmware + EQEP_pruss_load_run_fw(); + + + // Log messages + DebugP_log("\r\n ABZ setup finished\n"); + DebugP_log("EQEP Position Speed Test Started ...\r\n"); + + uint64_t last_print_us = ClockP_getTimeUsec(); + + // Main polling loop + while (1) + { + for (int ch = 0; ch < 6; ch++) + { + uint32_t curr_write_ptr_offset = HW_RD_REG32(ABZHandle[ch]->baseMemAddr1) & WRITE_PTR_OFFSET_MASK; + + /* Calculate edges accumulated since last processed (handles ring buffer wraparound) */ + uint32_t edge_delta; + if (curr_write_ptr_offset >= ABZHandle[ch]->read_ptr_offset) + edge_delta = (curr_write_ptr_offset - ABZHandle[ch]->read_ptr_offset) / 4; + else + { + edge_delta = (ABZHandle[ch]->mem_limit - ABZHandle[ch]->read_ptr_offset + curr_write_ptr_offset) / 4; +#ifdef TEST_MEM_LIMIT_DEBUG + DebugP_log("\r\n[MEM_LIMIT BUG] Ch%d wrap: mem_limit=0x%x (should be 0x%x) " + "read_ptr_offset=0x%x write_ptr_offset=0x%x -> edge_delta=%d\n", + ch, ABZHandle[ch]->mem_limit, DMEM_CHANNEL_SIZE, + ABZHandle[ch]->read_ptr_offset, curr_write_ptr_offset, edge_delta); +#endif + } + + /* If no change in edge delta, then set the direction to 0 -> no change */ + ABZHandle[ch]->direction = 0; + + /* Phase error shadow-compare: PRU increments its counter on invalid + * A/B transitions; R5F only ever reads it and diffs against its own + * last-seen value. Checked every pass, not gated by edge_delta, so + * a phase error is never missed even if position/speed processing + * hasn't hit threshold yet. */ + uint32_t curr_phase_err_count = HW_RD_REG32((uint32_t)ABZHandle[ch]->phase_err_base); + if (curr_phase_err_count != ABZHandle[ch]->phase_err_count_last_seen) + { + ABZHandle[ch]->phase_error_flag = 1; + ABZHandle[ch]->phase_err_count_last_seen = curr_phase_err_count; + } + ABZHandle[ch]->phase_err_count = curr_phase_err_count; + + /* QPOS/direction read: same ungated-every-pass treatment as the + * phase-error read above. QPOS is a point-in-time snapshot with + * no batching requirement of its own — gating it behind + * EQEP_EDGE_THRESHOLD (as before) meant a trailing sub-threshold + * edge_delta at idle never got picked up, unlike interrupt-mode + * (eqep_diagnostic.c), which reads QPOS on every ISR entry with + * no equivalent gate. That gating mismatch was the source of the + * position-count divergence between the two modes. */ + ABZHandle[ch]->prev_QPOS = ABZHandle[ch]->QPOSCOUNT; + ABZHandle[ch]->QPOSCOUNT = HW_RD_REG32((uint32_t)ABZHandle[ch]->position_base); + + /* QPOS is a free-running uint32_t in PRU firmware (plain add/sub, + * no QPOSMAX ceiling), so it wraps 0xFFFFFFFF -> 0 (forward) or + * 0 -> 0xFFFFFFFF (reverse). A direct unsigned compare of + * QPOSCOUNT vs prev_QPOS breaks exactly at that wrap: e.g. + * prev=0xFFFFFFFF, curr=0x00000000 is still forward motion, but + * curr < prev as raw unsigned values, so the old ">"/"<" logic + * would report it as reverse. + * + * Fix: subtract as unsigned (which wraps modulo 2^32, exactly + * undoing the counter's own wraparound) and reinterpret the + * result as signed. Since we poll fast relative to the encoder + * rate, the true step between polls is always tiny compared to + * 2^31, so the sign of the reinterpreted result always matches + * the true direction, wrap or no wrap. */ + int32_t qpos_diff = (int32_t)(ABZHandle[ch]->QPOSCOUNT - ABZHandle[ch]->prev_QPOS); + if (qpos_diff > 0) ABZHandle[ch]->direction = 1; + else if (qpos_diff < 0) ABZHandle[ch]->direction = -1; + + if (edge_delta >= EQEP_EDGE_THRESHOLD) + { + ABZHandle[ch]->write_ptr_offset = curr_write_ptr_offset; + EQEP_Get_Speed_ABZ(ch); + } + } + + /* Print status every 1 second + this is just for calculating that atleast 1(PRINT_DELAY) second has passed since the last print */ + uint64_t now_us = ClockP_getTimeUsec(); + if ((now_us - last_print_us) >= PRINT_DELAY) + { + DebugP_log("\r\nSpeeds (Hz): Ch0=%d Ch1=%d Ch2=%d Ch3=%d Ch4=%d Ch5=%d\n", + ABZHandle[0]->speed, ABZHandle[1]->speed, ABZHandle[2]->speed, + ABZHandle[3]->speed, ABZHandle[4]->speed, ABZHandle[5]->speed); + DebugP_log(" Positions: Ch0=0x%x Ch1=0x%x Ch2=0x%x Ch3=0x%x Ch4=0x%x Ch5=0x%x\n", + ABZHandle[0]->QPOSCOUNT, ABZHandle[1]->QPOSCOUNT, ABZHandle[2]->QPOSCOUNT, + ABZHandle[3]->QPOSCOUNT, ABZHandle[4]->QPOSCOUNT, ABZHandle[5]->QPOSCOUNT); + DebugP_log(" Directions: Ch0=%d Ch1=%d Ch2=%d Ch3=%d Ch4=%d Ch5=%d\n", + ABZHandle[0]->direction, ABZHandle[1]->direction, ABZHandle[2]->direction, + ABZHandle[3]->direction, ABZHandle[4]->direction, ABZHandle[5]->direction); + DebugP_log(" PhaseErr: Ch0=%d Ch1=%d Ch2=%d Ch3=%d Ch4=%d Ch5=%d\n", + ABZHandle[0]->phase_error_flag, ABZHandle[1]->phase_error_flag, ABZHandle[2]->phase_error_flag, + ABZHandle[3]->phase_error_flag, ABZHandle[4]->phase_error_flag, ABZHandle[5]->phase_error_flag); + last_print_us = now_us; + } + } + + + + // Close drivers and board + Board_driversClose(); + Drivers_close(); +} + +// Function to get speed and position of ABZ +void EQEP_Get_Speed_ABZ(uint8_t channel) +{ + // Calculate read pointer and write pointer + ABZHandle[channel]->read_ptr = (ABZHandle[channel]->baseMemAddr0) + (ABZHandle[channel]->read_ptr_offset) / 4; + ABZHandle[channel]->write_ptr_offset = HW_RD_REG32(ABZHandle[channel]->baseMemAddr1) & WRITE_PTR_OFFSET_MASK; + ABZHandle[channel]->write_ptr = (ABZHandle[channel]->baseMemAddr0) + (ABZHandle[channel]->write_ptr_offset) / 4; + + // Get timestamps + ABZHandle[channel]->prev_ts = HW_RD_REG32(ABZHandle[channel]->read_ptr) & TIMESTAMP_MASK; + ABZHandle[channel]->cur_ts = HW_RD_REG32(ABZHandle[channel]->write_ptr) & TIMESTAMP_MASK; + + // Calculate speed and position + if (ABZHandle[channel]->read_ptr_offset > ABZHandle[channel]->write_ptr_offset) + { + // Calculate delta time and edges + if (ABZHandle[channel]->prev_ts > ABZHandle[channel]->cur_ts) + ABZHandle[channel]->delta_t = TIMESTAMP_MASK - ABZHandle[channel]->prev_ts + ABZHandle[channel]->cur_ts; + else + ABZHandle[channel]->delta_t = ABZHandle[channel]->cur_ts - ABZHandle[channel]->prev_ts; + + ABZHandle[channel]->edges = (ABZHandle[channel]->mem_limit - ABZHandle[channel]->read_ptr_offset + ABZHandle[channel]->write_ptr_offset) / 4; + + // Calculate speed + ABZHandle[channel]->speed = ABZHandle[channel]->edges * ((PRU_CLK_FREQ) / (ABZHandle[channel]->delta_t)); + +#ifdef TEST_MEM_LIMIT_DEBUG + { + uint32_t correct_edges = (DMEM_CHANNEL_SIZE - ABZHandle[channel]->read_ptr_offset + ABZHandle[channel]->write_ptr_offset) / 4; + uint32_t correct_speed = correct_edges * ((PRU_CLK_FREQ) / (ABZHandle[channel]->delta_t)); + DebugP_log("\r\n[MEM_LIMIT BUG] Ch%d speed-calc wrap: mem_limit=0x%x (should be 0x%x) " + "read_ptr_offset=0x%x write_ptr_offset=0x%x delta_t=%d -> edges=%d speed=%d " + "(correct: edges=%d speed=%d)\n", + channel, ABZHandle[channel]->mem_limit, DMEM_CHANNEL_SIZE, + ABZHandle[channel]->read_ptr_offset, ABZHandle[channel]->write_ptr_offset, + ABZHandle[channel]->delta_t, ABZHandle[channel]->edges, ABZHandle[channel]->speed, + correct_edges, correct_speed); + } +#endif + } + else + { + // Similar calculations for the else case + if (ABZHandle[channel]->prev_ts > ABZHandle[channel]->cur_ts) + ABZHandle[channel]->delta_t = TIMESTAMP_MASK - ABZHandle[channel]->prev_ts + ABZHandle[channel]->cur_ts; + else + ABZHandle[channel]->delta_t = ABZHandle[channel]->cur_ts - ABZHandle[channel]->prev_ts; + + ABZHandle[channel]->edges = (ABZHandle[channel]->write_ptr_offset - ABZHandle[channel]->read_ptr_offset) / 4; + ABZHandle[channel]->speed = ABZHandle[channel]->edges * ((PRU_CLK_FREQ) / (ABZHandle[channel]->delta_t)); + } + + + // Update pointers and counters + ABZHandle[channel]->prev_ts = ABZHandle[channel]->cur_ts; + ABZHandle[channel]->read_ptr = ABZHandle[channel]->write_ptr; + ABZHandle[channel]->read_ptr_offset = ABZHandle[channel]->write_ptr_offset; + ABZHandle[channel]->iter++; +} + +void create_lut(void) +{ + void *a_b_transition_base = (void *)((uint32_t)(ABZHandle[0]->baseMemAddr1) + 0xf0); + + // STATE_00_00 (0000) + HW_WR_REG8((uint32_t)a_b_transition_base + 0x0, 0); // No change + // STATE_00_01 (0001) + HW_WR_REG8((uint32_t)a_b_transition_base + 0x1, 2); // Decrement + // STATE_00_10 (0010) + HW_WR_REG8((uint32_t)a_b_transition_base + 0x2, 1); // Increment + // STATE_00_11 (0011) - diagonal transition (SPRU790D Fig. 6: 00<->11 is invalid) -> phase error + HW_WR_REG8((uint32_t)a_b_transition_base + 0x3, 3); // Phase error + // STATE_01_00 (0100) + HW_WR_REG8((uint32_t)a_b_transition_base + 0x4, 1); // Increment + // STATE_01_01 (0101) + HW_WR_REG8((uint32_t)a_b_transition_base + 0x5, 3); // Invalid state (phase error) + // STATE_01_10 (0110) - diagonal transition (SPRU790D Fig. 6: 01<->10 is invalid) -> phase error + HW_WR_REG8((uint32_t)a_b_transition_base + 0x6, 3); // Phase error + // STATE_01_11 (0111) + HW_WR_REG8((uint32_t)a_b_transition_base + 0x7, 2); // Decrement + // STATE_10_00 (1000) + HW_WR_REG8((uint32_t)a_b_transition_base + 0x8, 2); // Decrement + // STATE_10_01 (1001) - diagonal transition (SPRU790D Fig. 6: 10<->01 is invalid) -> phase error + HW_WR_REG8((uint32_t)a_b_transition_base + 0x9, 3); // Phase error + // STATE_10_10 (1010) + HW_WR_REG8((uint32_t)a_b_transition_base + 0xA, 3); // Invalid state (phase error) + // STATE_10_11 (1011) + HW_WR_REG8((uint32_t)a_b_transition_base + 0xB, 1); // Increment + // STATE_11_00 (1100) - diagonal transition (SPRU790D Fig. 6: 11<->00 is invalid) -> phase error + HW_WR_REG8((uint32_t)a_b_transition_base + 0xC, 3); // Phase error + // STATE_11_01 (1101) + HW_WR_REG8((uint32_t)a_b_transition_base + 0xD, 1); // Increment + // STATE_11_10 (1110) + HW_WR_REG8((uint32_t)a_b_transition_base + 0xE, 2); // Decrement + // STATE_11_11 (1111) + HW_WR_REG8((uint32_t)a_b_transition_base + 0xF, 0); // No change +} + +void ABZ_enable_load_share_mode(void *pruCfg, uint32_t pruSlice) +{ + uint32_t regVal; + if(pruSlice == 1) + { + regVal = HW_RD_REG32((uint8_t *)pruCfg + CSL_ICSSCFG_EDPRU1TXCFGREGISTER); + regVal |= CSL_ICSSCFG_EDPRU1TXCFGREGISTER_PRU1_ENDAT_SHARE_EN_MASK; + HW_WR_REG32((uint8_t *)pruCfg + CSL_ICSSCFG_EDPRU1TXCFGREGISTER, regVal); + } + else + { + regVal = HW_RD_REG32((uint8_t *)pruCfg + CSL_ICSSCFG_EDPRU0TXCFGREGISTER); + regVal |= CSL_ICSSCFG_EDPRU0TXCFGREGISTER_PRU0_ENDAT_SHARE_EN_MASK; + HW_WR_REG32((uint8_t *)pruCfg + CSL_ICSSCFG_EDPRU0TXCFGREGISTER, regVal); + } +} +void EQEP_Get_position_ABZ(void) +{ + // Update position and direction + for(int channel=0;channel<6;channel++) ABZHandle[channel]->prev_QPOS = ABZHandle[channel]->QPOSCOUNT; + for(int channel=0;channel<6;channel++) + { + ABZHandle[channel]->QPOSCOUNT = HW_RD_REG32((uint32_t)ABZHandle[channel]->position_base); + ABZHandle[0]->position_buffer[idx]=ABZHandle[channel]->QPOSCOUNT; + idx++; + } + for(int channel=0;channel<6;channel++) + { + /* See the wraparound-safe signed-diff note in the main polling + * loop above (pru_eqep_example_main) — same QPOS free-running + * uint32_t wrap issue applies here. */ + int32_t qpos_diff = (int32_t)(ABZHandle[channel]->QPOSCOUNT - ABZHandle[channel]->prev_QPOS); + if (qpos_diff > 0) ABZHandle[channel]->direction = 1; + else if (qpos_diff < 0) ABZHandle[channel]->direction = -1; + else ABZHandle[channel]->direction = 0; + } + if(idx>=950) idx=0; +} +void EQEP_PRU_clearPhaseErrorFlag(uint8_t channel) +{ + // Only clears the R5F-local flag; never touches PRU/DMEM (single-owner rule) + ABZHandle[channel]->phase_error_flag = 0; +} + +void EQEP_get_speed_RT(uint8_t channel) +{ + + // Calculate speed + ABZHandle[channel]->write_ptr_offset = HW_RD_REG32(ABZHandle[channel]->baseMemAddr1) & WRITE_PTR_OFFSET_MASK; + ABZHandle[channel]->write_ptr = (ABZHandle[channel]->baseMemAddr0) + (ABZHandle[channel]->write_ptr_offset) / 4; + ABZHandle[channel]->delta_t = HW_RD_REG32(ABZHandle[channel]->write_ptr) & TIMESTAMP_MASK; + ABZHandle[channel]->speed = ((PRU_CLK_FREQ) / (ABZHandle[channel]->delta_t)); + + +} diff --git a/examples/pru_eqep/readme.md b/examples/pru_eqep/readme.md new file mode 100644 index 000000000..e01a12f90 --- /dev/null +++ b/examples/pru_eqep/readme.md @@ -0,0 +1,190 @@ +# PRU EQEP Project + +## 1. Testing Done + +The PRU eQEP implementation has been bench-validated against a real hardware eQEP peripheral (AM263x-LP, `eqep_position_speed` example) and a physical incremental encoder. Full test matrix, pass/fail status, and raw findings are tracked in `TESTING.md` (same folder as this readme). Summary of what has been run: + +| Area | Coverage | +|---|---| +| Multi-channel operation | 3-channel and full 6-channel simultaneous operation, confirming correct GPI byte wiring (`r31.b0/b1/b2`) across all core types (RTU_PRU, PRU, TX_PRU) | +| Position accuracy | A real physical encoder wired to both the PRU firmware and the AM263x-LP's hardware eQEP0 at the same time shows matching position counts on both — PRU `QPOS` and hardware `QPOSCNT` agree for the same edge stream | +| Direction correctness | Verified with a real physical encoder (forward/reverse) and with a deterministic forward-N/reverse-N pulse sequence — `QPOS` returns exactly to its starting value | +| Mixed concurrent sources | 3 channels driven from an ePWM-based signal source, 3 from a real encoder, running at once — confirms cross-channel independence | +| Phase-error detection | Negative test: A and B tied to the same physical signal, forcing every transition through the diagonal/invalid states — counter increments, flag sets, and clears correctly with no false positives on a subsequent normal run | +| Speed calculation | Swept across 1 kHz – 500 kHz — see "Parameter Ranges Tested" below | + +**Not yet exercised** (see `TESTING.md` "Pending" rows): ring-buffer wrap boundary, sustained 24-bit timestamp wrap, edge-threshold variation, idle/cycle-counter-saturation recovery. These are defined as test cases but not yet run — treat behavior in these conditions as unverified, not as "known good." + +## 2. Parameter Ranges Tested + +| Parameter | Range Tested | Result | Comments | +|---|---|---|---| +| A/B signal frequency | 1 kHz – 500 kHz | PASS | Position and speed both correct | +| Edge threshold (`EQEP_EDGE_THRESHOLD` / `READ_POS_SPEED_BUFF`) | Default (4 edges/interrupt) only | PENDING | Not yet swept against `0x10`/`0x40` alternatives — defined as pending test #10 | +| Channel count | 1, 3, 6 simultaneous | PASS | | +| Encoder source type | ePWM-simulated (AM263x-LP) and real physical encoder | PASS | Also tested mixed (3+3) | + +**Practical floor note:** 1 kHz was the lowest frequency reachable with the ePWM test rig used, not a floor imposed by the PRU/R5F design. True near-stall behavior (approaching the ~14.3s PRU cycle-counter saturation window) has not been separately exercised. + +
+Saleae capture of 50kHz A/B quadrature signals at 90° phase difference +
Saleae logic-analyzer capture — 50 kHz A (white) and B (orange) signals at 90° phase difference, 50.02% duty cycle
+
+ +## 3. Connection Details + +Bench setup used for validation (see "Testing Done" above). + +
+pru_eqep bench setup +
Ch0 encoder bench setup — AM243x-LP wired to a physical incremental encoder
+
+ +**This photo shows a single channel (Ch0) connection only** — one encoder wired to Ch0's A/B pins on the AM243x-LP, not the full 6-channel setup. See sections 3a/3b below for how additional channels are wired, and section 6 for the full per-channel pin table. + +### 3a. AM263x-LP (ePWM signal source) → AM243x-LP (device under test) + +The AM263x-LP's ePWM output is a single A/B pair, **fanned out** to every channel under ePWM test — not a separate point-to-point pair per channel. All destination pins below carry the same physical A/B signal. + +| Signal | AM263x-LP header pin | AM243x-LP header pin | Destination channel | +|---|---|---|---| +| A | J4.11 | J4.8 | Ch0 (RTU_PRU0) | +| A | J4.11 | J4.10 | Ch1 (PRU0) | +| A | J4.11 | J2.4 | Ch2 (TX_PRU0) | +| B | J8.59 | J4.9 | Ch0 (RTU_PRU0) | +| B | J8.59 | J2.2 | Ch1 (PRU0) | +| B | J8.59 | J2.8 | Ch2 (TX_PRU0) | + +If only testing a subset of channels (e.g. single-channel sweep tests), wire J4.11/J8.59 to only that channel's A/B pins from the pin table in section 6 — the fan-out above reflects the full 3-channel ePWM test, not a requirement to always wire all three. + +### 3b. Physical Incremental Encoder → AM243x-LP + +Used for direction-correctness and mixed-source tests (Ch3-5 in the mixed-source test). Wire the encoder's A/B outputs directly to the target channel's header pins from section 6 — e.g. for Ch3 (RTU_PRU1): encoder A → J2.10, encoder B → J7.7. Z is not wired (see "Z-Signal / Position-Counter-Reset Behavior" — dropped from scope). + +The photo above shows this pattern for Ch0 (RTU_PRU0): encoder A → AM243x-LP J4.8 (`PRG0_PRU0_GPO0`), encoder B → J4.9 (`PRG0_PRU0_GPO1`) — see section 6 for the full per-channel pin table. + +### 3c. Other Bench Connections + +| Component | Role | Connection | +|---|---|---| +| Saleae logic analyzer | Independent edge-count ground truth, used to validate PRU/hardware-eQEP position counts | Probe leads clipped directly onto the same A/B header pins as the channel under test (section 6) — no dedicated header, just an extra tap on the existing wire | +| Host PC | Debug console / CCS debug session | USB to AM243x-LP UART0 (via onboard USB-UART) and JTAG/XDS for CCS | + +**Multiple simultaneous sources:** in the mixed-source test (3 ePWM + 3 real encoder), both sources were connected at the same time to different channel groups — Ch0-2 fanned out from the AM263x-LP ePWM pair (3a), Ch3-5 from the physical encoder (3b) — with no shared/multiplexed wiring *between* the two source types. + +**If you need to wire a different channel or source than what's listed above:** find the target channel's A/B header pins in section 6's table, then run a wire from your source's A/B output pins directly to those — there's no additional configuration needed on the AM243x-LP side beyond the physical connection, since `example.syscfg`/`memory.inc` already define which GPI (and therefore which header pin) each channel listens on. If you're changing which physical pin a channel uses (not just which source drives it), see "Changing A/B/Z Pin Assignments" in the Configuration Guide instead. + +## 4. System Block Diagram + +
+pru_eqep system block diagram +
System block diagram — encoder signal sources, AM243x-LP ICSSG0 (6 PRU cores, DMEM0/DMEM1), R5F application, UART, host PC
+
+ +Notes: +- TX_PRU0/TX_PRU1 cannot access DMEM directly — `ABZ_enable_load_share_mode()` (R5F init) lets them share their slice's PRU DATARAM (dotted lines above). +- Each channel's encoder is shown independently — nothing prevents wiring multiple channels to the same physical encoder, or using different source types (ePWM-simulated, real encoder) per channel, as covered in "Testing Done" and "Connection Details" above; this diagram shows the logical per-channel signal path, not a specific bench configuration. + +## 5. Flow Diagrams + +### 5a. PRU Firmware Flow (`firmware/main.asm`, identical on all 6 cores) + +
+pru_eqep PRU firmware flow +
PRU firmware flow — edge detection, timestamp capture, LUT lookup, QPOS/phase-error update (main.asm)
+
+ +Note: the diagram shows one merged path — the actual assembly duplicates the Z-check/LUT-lookup/QPOS-update logic once on the buffer-wrap branch and once on the continue branch (see `main.asm`), not because they behave differently, but to avoid an extra branch back into a shared block. Interrupt firing (every `READ_POS_SPEED_BUFF` edges, via `r31.b0`) happens inside the "Write to DMEM0/DMEM1" step and is omitted here for clarity. + +### 5b. R5F Application Flow (`mcuplus/pru_eqep_example.c`, polling mode) + +
+pru_eqep R5F application flow +
R5F application flow — init, LUT write, startup sync, polling loop (pru_eqep_example.c)
+
+ +Note: phase-error and position/direction reads happen every pass, unconditionally — only the speed calculation is gated by `EQEP_EDGE_THRESHOLD`. There are no ISRs anywhere in this flow (see "Switching from Polling Mode to Interrupt Mode" below for the alternative). + +## 6. PRU Pins / Jumper Header Pins Used + +GPI numbers below are **slice-local absolute** values (0-19 within each PRU slice — see `firmware/main.asm`'s `cur_sample` byte selection: RTU_PRU0/PRU0/TX_PRU0 all read `r31.b0` on the PRU0 slice, so their GPI numbers land directly in the `A_SIGNAL_GPI`/`B_SIGNAL_GPI` constants in `memory.inc`; RTU_PRU1 reads its slice's `r31.b0` while PRU1/TX_PRU1 read `r31.b1`, so their `memory.inc` constants are byte1-relative and the `-8` in `memory.inc` converts back to the slice-absolute GPI number used here and in `example.syscfg`). + +| Channel | Core | Signal | GPI # (slice-absolute) | PRU net name (`example.syscfg`) | LaunchPad header pin | +|---|---|---|---|---|---| +| 0 | RTU_PRU0 | A | GPI0 | PRG0_PRU0_GPO0 | J4.8 | +| 0 | RTU_PRU0 | B | GPI1 | PRG0_PRU0_GPO1 | J4.9 | +| 1 | PRU0 | A | GPI2 | PRG0_PRU0_GPO2 | J4.10 | +| 1 | PRU0 | B | GPI3 | PRG0_PRU0_GPO3 | J2.2 | +| 2 | TX_PRU0 | A | GPI4 | PRG0_PRU0_GPO4 | J2.4 | +| 2 | TX_PRU0 | B | GPI5 | PRG0_PRU0_GPO5 | J2.8 | +| 3 | RTU_PRU1 | A | GPI0 | PRG0_PRU1_GPO0 | J2.10 | +| 3 | RTU_PRU1 | B | GPI1 | PRG0_PRU1_GPO1 | J7.7 | +| 4 | PRU1 | A | GPI11 | PRG0_PRU1_GPO11 | J7.10 | +| 4 | PRU1 | B | GPI12 | PRG0_PRU1_GPO12 | J8.9 | +| 5 | TX_PRU1 | A | GPI13 | PRG0_PRU1_GPO13 | J8.10 | +| 5 | TX_PRU1 | B | GPI15 | PRG0_PRU1_GPO15 | J6.2 | + +Z signal pins omitted — not a customer requirement, not wired/tested (see `TESTING.md` #11, dropped from scope). + +## 7. Debug Tips + +- **Check `PhaseErr` first if position looks wrong.** Phase error is detected when A and B transition simultaneously — the PRU firmware's LUT lookup returns `3` (diagonal/invalid state), increments `PHASE_ERR_CNT` in DMEM1 for that channel, and skips the QPOS update for that edge. On the R5F side, the polling loop compares `PHASE_ERR_CNT` against `phase_err_count_last_seen` each pass — if it has moved, `phase_error_flag` is set to `1` (sticky). The 1-second status print logs this as `PhaseErr: Ch0=... Ch5=...`. `QPOS` is not corrupted by phase-error events (the edge is skipped, not miscounted), but a set flag means real edges are being lost or misread — check wiring/noise on that channel's A/B lines. To clear the flag once the root cause is fixed, call `EQEP_PRU_clearPhaseErrorFlag(channel)` — this zeroes only the R5F-local `phase_error_flag` and never touches DMEM1 or the PRU-side `PHASE_ERR_CNT` (single-owner rule: PRU owns that counter, R5F only reads it). +- **`QPOS` lags the ring buffer by one edge.** The firmware publishes the timestamp/write-pointer for the *current* edge before updating `QPOS` for it — this is expected, not a bug, if you see `QPOS` one edge "behind" the buffer contents in a memory dump. +- **Speed reads 0 or garbage after ~55ms of silence on a channel.** `EQEP_Get_Speed_ABZ`'s `delta_t` is derived from a 24-bit-masked timestamp that wraps every ~55ms at 300 MHz — a divide-by-zero guard is not yet in place. If you hit this, it's the known gap, not new. +- **Direction flips unexpectedly.** Already fixed for the 32-bit `QPOS` wraparound boundary (`0xFFFFFFFF → 0`) via a signed-diff comparison — if you see a wrong direction reading anywhere else, it's a new bug, not a recurrence of that one. +- **A channel shows no activity at all.** Confirm `A_B_Z_GPI_mask`/`A_SIGNAL_GPI`/`B_SIGNAL_GPI` in `memory.inc` for that core match the actual pin wiring and `example.syscfg` mux assignment — the two must agree (see "Configuring A/B/Z Pin Assignments"). +- **Check the raw A/B input directly on `r31` before suspecting firmware logic.** Each PRU core's live GPI state is `r31` — halt the core in a CCS debug session (Registers view or `r31` in the Watch window) and confirm the bits toggle as the encoder is rotated by hand: + - RTU_PRU0/PRU0/TX_PRU0 (Ch0/1/2) all read the *same* physical byte, `r31.b0` — use each core's `A_B_Z_GPI_mask` from `memory.inc` to know which bits in that shared byte are that channel's A/B (e.g. Ch0 = bits 0,1; Ch1 = bits 2,3; Ch2 = bits 4,5). + - RTU_PRU1 (Ch3) reads its own slice's `r31.b0`; PRU1/TX_PRU1 (Ch4/Ch5) read `r31.b1` instead — same idea, different byte. + - If `r31` never changes while the encoder is turning, the problem is upstream of the firmware entirely (wiring, `example.syscfg` pinmux, or a dead encoder) — no point debugging `main.asm`'s edge-detection logic until this checks out. + - If `r31` toggles correctly but `QPOS`/`write_ptr_offset` in DMEM1 don't move, the input path is fine and the bug is in the firmware's edge-detect/LUT logic instead — this check is what narrows down which side of that boundary to debug. +- **TX_PRU channels (Ch2/Ch5) behave oddly right after boot.** TX_PRU cores can't access DMEM directly — confirm `ABZ_enable_load_share_mode()` ran successfully for that slice before any channel-2/5 debugging; if load-share mode isn't enabled, TX_PRU0/1 can't reach PRU DATARAM at all. +- **Use the CCS Memory Browser on DMEM1** (`0x00`–`0x14` write pointers, `0x1C`–`0x30` QPOS, `0x34`–`0x48` phase-error counters, `0xF0` LUT) to see raw per-channel state without instrumenting the R5F app. + +## 8. Configuration Guide + +How to change commonly-adjusted parameters in this firmware/application. Each subsection below is a self-contained worked example. + +### 8a. Changing A/B/Z Pin Assignments + +1. Update `A_SIGNAL_GPI`, `B_SIGNAL_GPI`, `Z_SIGNAL_GPI`, and `A_B_Z_GPI_mask` in `firmware/include/memory.inc`, in that core's `.if $isdefed(...)` block. +2. Update the corresponding GPI pin's mux assignment in `example.syscfg` (`PruGPIO[...].PRU_ICSSG0_PRU.GPIx`) — see the pin table in section 6 for current net-name mappings. +3. Rebuild the firmware project for that core and the R5F project. Both `memory.inc` and `example.syscfg` must agree — a mismatch here silently wires the firmware to the wrong physical pin. + +Constraint: pin choice is only free *within* the byte a core type already reads (RTU_PRU → GPI0-7, PRU → GPI8-15, TX_PRU → GPI16-23) — that byte split is hardware-fixed, not configurable. + +### 8b. Switching from Polling Mode to Interrupt Mode + +This example's R5F application (`pru_eqep_example.c`) runs in **polling mode** by default — a single `while(1)` loop round-robins all 6 channels, no ISRs registered. An interrupt-driven variant also exists (`eqep_diagnostic.c`) and was the original design. + +| | Polling mode (default, this example) | Interrupt mode (`eqep_diagnostic.c`) | +|---|---|---| +| R5F structure | Single loop, checks `edge_delta >= EQEP_EDGE_THRESHOLD` per channel per pass | 6 ISRs (`HwiP_construct` per channel), triggered by PRU→R5F PRUICSS interrupt | +| PRU firmware | No change either way — PRU does not fire any INTC event in polling mode; `PRUICSS_clearEvent` is called in the polling loop to drain any stale pending bits | Same firmware, INTC event fired via `r31.b0` every `READ_POS_SPEED_BUFF` edges, consumed by ISR | +| Debugging | Single execution context, no ISR preemption | 6 interrupt contexts, ISR-safe constraints apply | + +To switch to interrupt mode, port the ISR registration pattern from `eqep_diagnostic.c` (`HwiP_construct` per channel, `App_ABZIntrISRx` callbacks) into `pru_eqep_example.c`, and remove the polling `while(1)` edge-delta check. + +### 8c. Z-Signal / Position-Counter-Reset Behavior + +The firmware detects Z-signal transitions but the position-reset-on-Z action is **intentionally commented out**: + +```asm +; Handle Z signal reset +qbbs Z_interrupt0, r31, Z_SIGNAL_GPI +;zero &QPOS, 4 +Z_interrupt0: +``` + +This is disabled because Z-based position reset was raised and then explicitly dropped as a customer requirement — not a bug or an oversight. Real hardware eQEP's `QPOSMAX`/`PCRM` (position-counter-reset-mode) semantics, which this would need to approximate, only make sense with a Z pulse establishing an unambiguous reset point once per revolution; without validating that Z is wired and firing correctly on real hardware, uncommenting this line would silently reset `QPOS` on every Z edge, valid or not. + +To re-enable: uncomment the `zero &QPOS, 4` line in **both** duplicated LUT-handling blocks in `main.asm` (the buffer-wrap-reset path and the normal-continuation path use separate copies of this logic), rebuild, and bench-test against a real encoder's Z pulse before trusting it — this path has no existing test coverage (see `TESTING.md` test #11, dropped from scope). + +## 9. References + +- [PRU-ICSS Documentation](https://www.ti.com/tool/PRU-ICSS) +- [MCU+ SDK AM243x](https://www.ti.com/tool/MCU-PLUS-SDK-AM243X) +- [AM243x-LP LaunchPad tool page](https://www.ti.com/tool/LP-AM243) +- [PRU-CGT (ti-pru-cgt) tool page](https://www.ti.com/tool/PRU-CGT) — required toolchain, see Steps to Run +- SPRU790D — [AM243x/AM64x eQEP peripheral reference](https://www.ti.com/lit/ug/spruim2h/spruim2h.pdf) (real hardware eQEP semantics this PRU implementation approximates: diagonal-transition/phase-error definition, QPOSMAX/PCRM behavior) +- [PRU-ICSS Reference Guide](https://www.ti.com/lit/ug/spruij1/spruij1.pdf) — PRU core architecture, DMEM/load-share mode, INTC diff --git a/examples/rpmsg_echo_linux/makefile b/examples/rpmsg_echo_linux/makefile index e0e875b52..596aca834 100644 --- a/examples/rpmsg_echo_linux/makefile +++ b/examples/rpmsg_echo_linux/makefile @@ -93,7 +93,6 @@ pre_build_message: # provide target definitions for each supported processor # PRU firmware should be built before any RTOS code that includes it -# TODO: what do we want to call the PRU Subsystem folder for AM62x? pruss, pruss0, icssm0, something else? am62x: # am62x-sk $(MAKE) -C firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) diff --git a/examples/spi_loopback/readme.md b/examples/spi_loopback/readme.md index ec49c4d8d..5d48e0bd8 100644 --- a/examples/spi_loopback/readme.md +++ b/examples/spi_loopback/readme.md @@ -5,21 +5,21 @@ This example provides a base for running loopback spi connection between a pair of master and slave PRU cores. The example uses generic SPI macros introduced in files spi_master_macros.inc and spi_slave_macros.inc to emulate generic SPI master and slave interfaces over PRU GPIO pins. - ## Overview - ### Timing Parameters - All cycle level frequency calculations are based on a 333MHz PRU System clock, which gives 3ns per instruction cycle, i.e $t_{f} = 3ns$ - - $t_{slew}$ : Slew rate of Data toggling (slew rate of PRU GPIO mode pin) = $2ns$ - $t_{p}$ : Propagation delay of wire (In the example, a 15 cm wire was used) = $0.5ns$ - #### SPI Master Macros: - - | Macros Name | Description | Peak cycles per bit | Theoretical Max. SCLK | Recommended delay components (50% duty cycle) | Practical Max. SCLK - |--------------|:------------------:|:--------:|:--------:|:-------:|:-------:| - | m_read_packet_spi_msb_gpo_sclk | SPI Master side macro to read 1 data packet through SPI interface MSB first. | (2+d1)+(5+d2) cycles | 33.33MHz | d1 =10, d2 =7 | 13.88MHz - | m_read_packet_spi_lsb_gpo_sclk | SPI Master side macro to read 1 data packet through SPI interface LSB first. | (2+d1)+(5+d2) cycles | 33.33MHz | d1 =10, d2 =7 | 13.88MHz - | m_send_packet_spi_msb_gpo_sclk | SPI Master side macro to send 1 data packet through SPI interface MSB first. | (4+d1)+(3+d2) cycles | 41.66MHz | d1 =0, d2 =1 | 41.66MHz - | m_send_packet_spi_lsb_gpo_sclk | SPI Master side macro to send 1 data packet through SPI interface LSB first. | (4+d1)+(3+d2) cycles | 41.66MHz | d1 =0, d2 =1 | 41.66MHz - | m_transfer_packet_spi_master_gpo_sclk | SPI Master side macro to read 1 data packet and write 1 data packet concurrently through the SPI interface. | (4+d1)+(6+d2) cycles | 27.77MHz | d1 =9, d2 =7 | 12.8MHz +## Overview +### Timing Parameters +All cycle level frequency calculations are based on a 333MHz PRU System clock, which gives 3ns per instruction cycle, i.e $t_{f} = 3ns$ + +$t_{slew}$ : Slew rate of Data toggling (slew rate of PRU GPIO mode pin) = $2ns$ +$t_{p}$ : Propagation delay of wire (In the example, a 15 cm wire was used) = $0.5ns$ +#### SPI Master Macros: + +| Macros Name | Description | Peak cycles per bit | Theoretical Max. SCLK | Recommended delay components (50% duty cycle) | Practical Max. SCLK +|--------------|:------------------:|:--------:|:--------:|:-------:|:-------:| +| m_read_packet_spi_msb_gpo_sclk | SPI Master side macro to read 1 data packet through SPI interface MSB first. | (2+d1)+(5+d2) cycles | 33.33MHz | d1 =10, d2 =7 | 13.88MHz +| m_read_packet_spi_lsb_gpo_sclk | SPI Master side macro to read 1 data packet through SPI interface LSB first. | (2+d1)+(5+d2) cycles | 33.33MHz | d1 =10, d2 =7 | 13.88MHz +| m_send_packet_spi_msb_gpo_sclk | SPI Master side macro to send 1 data packet through SPI interface MSB first. | (4+d1)+(3+d2) cycles | 41.66MHz | d1 =0, d2 =1 | 41.66MHz +| m_send_packet_spi_lsb_gpo_sclk | SPI Master side macro to send 1 data packet through SPI interface LSB first. | (4+d1)+(3+d2) cycles | 41.66MHz | d1 =0, d2 =1 | 41.66MHz +| m_transfer_packet_spi_master_gpo_sclk | SPI Master side macro to read 1 data packet and write 1 data packet concurrently through the SPI interface. | (4+d1)+(6+d2) cycles | 27.77MHz | d1 =9, d2 =7 | 12.8MHz Timing parameters for macros: **m_read_packet_spi_msb_gpo_sclk** and **m_read_packet_spi_lsb_gpo_sclk** are shown below: @@ -78,8 +78,8 @@ Timing parameters for macro **m_transfer_packet_spi_master_gpo_sclk** is shown b |$t_{si}$ | SetUp time: Time SDI needs to be stable before sampling edge | $0$ | | ns | |$t_{hi}$ | Hold time: Time SDI needs to be stable after sampling edge | $t_{f}$ | | ns | - #### SPI Slave Macros: - | Macros Name | Description | Peak cycle per bit| Max. SCLK | Practical Max. SCLK| +#### SPI Slave Macros: + | Macros Name | Description | Peak cycle per bit| Max. SCLK | Practical Max. SCLK| |--------------|:------------------:|:--------:|:--------:|:--------:| | m_read_packet_spi_slave_msb_gpi_sclk | SPI Slave side macro to read 1 data packet through SPI interface MSB first. | 7 cycles | 47.619MHz |47.619MHz | | m_read_packet_spi_slave_lsb_gpi_sclk | SPI Slave side macro to read 1 data packet through SPI interface LSB first. | 7 cycles | 47.619MHz | 47.619MHz | @@ -215,11 +215,17 @@ Note: None of the ICSS Broadside Accelerators are used for this implementation. ## Limitations Some of the macros were not stable at the theoretical maximum. These include: m_send_packet_spi_slave_msb_gpo_sclk, m_send_packet_spi_slave_lsb_gpo_sclk, m_transfer_packet_spi_slave_gpi_sclk, m_read_packet_spi_msb_gpo_sclk, m_read_packet_spi_lsb_gpo_sclk and m_transfer_packet_spi_master_gpo_sclk. Experimentally a frequency limitation was found and is documented in this document a "Practical Max SCLK." at which tests where successfully carried out. -# Supported Combinations - - Parameter | Value - ---------------|----------- - ICSSG | ICSSG0 - PRU0, PRU1 - Toolchain | pru-cgt - Board | am243x-lp - Example folder | examples/spi_loopback + +## Supported Combinations + +Refer to open-pru/examples/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | --------------------------------------- | +| am243x | LP-AM243 | MCU PLUS SDK FIXME, OpenPRU FIXME | diff --git a/examples/spi_loopback/spi_loopback_app/am243x-lp/spi_pru_demo.c b/examples/spi_loopback/spi_loopback_app/am243x-lp/spi_pru_demo.c index 7708d358a..d5c72678a 100644 --- a/examples/spi_loopback/spi_loopback_app/am243x-lp/spi_pru_demo.c +++ b/examples/spi_loopback/spi_loopback_app/am243x-lp/spi_pru_demo.c @@ -78,7 +78,7 @@ void SPI_pru_demo_main(void *args) while (1) { - /*TODO: [PINDSW-8471] Add unit test cases here for CI CD automation */ + /*FIXME: [PINDSW-8471] Add unit test cases here for CI CD automation */ ClockP_usleep(1); } diff --git a/pr_compliance_checklist.yaml b/pr_compliance_checklist.yaml index 751ffe4b2..e35c1e29f 100644 --- a/pr_compliance_checklist.yaml +++ b/pr_compliance_checklist.yaml @@ -212,6 +212,16 @@ pr_compliances: failure_criteria: | - "Any .asm, .inc, .c, or .h file containing tab characters" + - title: "Portable Assembly Include Paths" + compliance_label: true + objective: "Ensure assembly .include paths use PRU assembler-compatible separators (best_practices.md §Header File include rules)" + success_criteria: | + - 'All new or modified .asm and .inc files use the backslash character (`\`) in .include paths' + - "Relative include paths remain valid when built on Windows or Linux hosts" + failure_criteria: | + - "New or modified .include paths use the forward slash character (`/`)" + - "Include paths rely on non-PRU-assembler slash path separators" + - title: "Bugfix: Shared Library Impact" compliance_label: true objective: "Ensure that bugfixes to shared libraries in source/ do not silently break other projects (docs/contributing.md §'Adding a bugfix')" diff --git a/source/firmware/pru_load_bin_copyright.h b/source/firmware/pru_load_bin_copyright.h index 56b9a5c94..bad772bdb 100644 --- a/source/firmware/pru_load_bin_copyright.h +++ b/source/firmware/pru_load_bin_copyright.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2025 Texas Instruments Incorporated + * Copyright (C) 2026 Texas Instruments Incorporated * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/source/linker_cmd/asm_code/README.md b/source/linker_cmd/asm_code/README.md index df41f308b..fada8a237 100644 --- a/source/linker_cmd/asm_code/README.md +++ b/source/linker_cmd/asm_code/README.md @@ -8,5 +8,6 @@ source/linker_cmd/c_code. ## More information For training on how to customize the linker.cmd file for your project, refer to -the PRU Academy. +your processor's PRU Academy > Getting Started Labs > Lab 2: How to Write PRU +Firmware. diff --git a/source/linker_cmd/c_code/README.md b/source/linker_cmd/c_code/README.md index c62820d07..6b3c02e9e 100644 --- a/source/linker_cmd/c_code/README.md +++ b/source/linker_cmd/c_code/README.md @@ -6,13 +6,14 @@ is written in C, or mixed C and assembly. ## More information For training on how to customize the linker.cmd file for your project, refer to -the PRU Academy. +your processor's PRU Academy > Getting Started Labs > Lab 2: How to Write PRU +Firmware. ## Common modifications -Until these examples are ported to OpenPRU, we will refer to the older PRU -Software Support Package (PSSP). - = https://git.ti.com/cgit/pru-software-support-package/pru-software-support-package/tree +The Linux RPMsg echo examples under `examples/rpmsg_echo_linux/firmware/` +show how OpenPRU projects add Linux-specific INTC map and resource table +sections to PRU linker command files. ### Add the INTC map (Linux only) @@ -20,7 +21,7 @@ The INTC map is used in order to allow the Linux PRU remoteproc driver to configure the PRU's interrupt controller (INTC) during initialization. 1. Add the INTC map file to the project. Use this file as a template: - /examples//PRU_Direct_Connect0/intc_map_0.h + `examples/rpmsg_echo_linux/firmware///ti-pru-cgt/intc_map.h` 2. Include the INTC map file in the main.c file. @@ -29,7 +30,7 @@ configure the PRU's interrupt controller (INTC) during initialization. ``` 3. Add the INTC map structure to the linker command file. Reference - /examples//PRU_Direct_Connect0/xxx_PRU0_intc.cmd + `examples/rpmsg_echo_linux/firmware///ti-pru-cgt/linker.cmd` ``` /* Specify the sections allocation into memory */ @@ -53,7 +54,7 @@ communication protocol (IPC) to communicate with Linux. If RPMsg is not used, then a resource table is not needed. 1. Add a resource table file to the project. Use this file as a template: - /examples//xxx_RPMsg_Echo_InterruptX/resource_table.h + `source/include/linux/resource_table.h` 2. Include the resource table in the main.c file: @@ -62,7 +63,7 @@ then a resource table is not needed. ``` 3. Add the resource table to the linker command file. Reference - /examples//xxx_RPMsg_Echo_InterruptX/xxx_PRU0_intc_rscTbl.cmd + `examples/rpmsg_echo_linux/firmware///ti-pru-cgt/linker.cmd` For example, on AM64x RTU1: ```