diff --git a/examples/makefile b/examples/makefile index 085d41f99..ba36bcabb 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_eqep pru_i2s spi_loopback \ + LCD_interface logic_scope mirror_input pru_emif pru_eqep pru_i2s 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/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..0c3c7e3cd --- /dev/null +++ b/examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd b/examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..5b64bc7ef --- /dev/null +++ b/examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM263Px_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM263Px PRU0 cores + */ + +/* 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 + /* 8 KB PRU Data RAM 1 */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00002000 + + 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 +} + +/* 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/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile b/examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..eda196b80 --- /dev/null +++ b/examples/mirror_input/firmware/am263px-lp/icss_m0_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 := mirror_input_am263px-lp_icss_m0_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/mirror_input/firmware/am263px-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 := 3 +EXPECTED_DEVICE := am263px + +# 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/examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..b8a8894d7 --- /dev/null +++ b/examples/mirror_input/firmware/am263px-lp/icss_m0_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=mirror_input_am263px-lp_icss_m0_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/mirror_input/firmware/main.asm b/examples/mirror_input/firmware/main.asm new file mode 100644 index 000000000..a405e096f --- /dev/null +++ b/examples/mirror_input/firmware/main.asm @@ -0,0 +1,63 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright (C) 2024-2025 Texas Instruments Incorporated - http://www.ti.com/ + +;*************************************************************************************** +; File: main.asm +; +; Brief: mirror_input example assembly file (asm) that mirrors input signals to output pins +; +; Steps to build : +; +; - Using ccs: +; - Import pru project to ccs workspace +; - main.asm file gets copied to ccs workspace +; - Modify main.asm file +; - Build the pru project, after which .out (Executable output file) and .h (Firmware header) files gets generated +; - Either .out (Executable output file) can be loaded to PRU using ccs or R5F can write to PRU IRAM using PRUICSS driver +; - Using makefile: +; - Use command gmake -all to build PRU project +; +;*************************************************************************************** + +; CCS/makefile specific settings + .retain ; Required for building .out with assembly file + .retainrefs ; Required for building .out with assembly file + + .global main + .sect ".text" + +;******** +;* MAIN * +;******** + +EPWM_SIGNAL .set 2 ;EPWM signal comes to GPI2 +CMP_SIGNAL .set 0 ;CMP signal comes to GPI0 +ICL_SIGNAL .set 1 ;ICL signal comes to GPI1 + +main: + ; check GPI00 and set/clear GPO1 based on it + ; EPWM signal is coming on GPI2 + ; clear r30 also so PRU0 GPO0 always starts at low + zero &r0,124 +high_pulse: + ; when EPWM becomes high, copy input -> output + wbs r31, EPWM_SIGNAL + ; move CMP input to ICL output + qbbs bit_set0, r31,CMP_SIGNAL +bit_clear0: + clr r30, r30, ICL_SIGNAL + qba low_pulse +bit_set0: + set r30, r30, ICL_SIGNAL + +low_pulse: + ; when EPWM becomes low, again copy input -> output + wbc r31, EPWM_SIGNAL + ; move CMP input to ICL output + qbbs bit_set1, r31,CMP_SIGNAL +bit_clear1: + clr r30, r30, ICL_SIGNAL + qba high_pulse +bit_set1: + set r30, r30, ICL_SIGNAL + qba high_pulse \ No newline at end of file diff --git a/examples/mirror_input/images/flow_diagram_mirror_input.png b/examples/mirror_input/images/flow_diagram_mirror_input.png new file mode 100644 index 000000000..50b4e8668 Binary files /dev/null and b/examples/mirror_input/images/flow_diagram_mirror_input.png differ diff --git a/examples/mirror_input/images/mirror_input_flow.drawio b/examples/mirror_input/images/mirror_input_flow.drawio new file mode 100644 index 000000000..119706976 --- /dev/null +++ b/examples/mirror_input/images/mirror_input_flow.drawio @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/mirror_input/images/time_diff_between_signals.png b/examples/mirror_input/images/time_diff_between_signals.png new file mode 100644 index 000000000..1b4f88175 Binary files /dev/null and b/examples/mirror_input/images/time_diff_between_signals.png differ diff --git a/examples/mirror_input/images/truth_table.png b/examples/mirror_input/images/truth_table.png new file mode 100644 index 000000000..6dc022bcb Binary files /dev/null and b/examples/mirror_input/images/truth_table.png differ diff --git a/examples/mirror_input/makefile b/examples/mirror_input/makefile new file mode 100644 index 000000000..0022f2c86 --- /dev/null +++ b/examples/mirror_input/makefile @@ -0,0 +1,105 @@ +include ../../imports.mak + +####################### +# project information # +####################### + +PROJECT_NAME := mirror_input +SUPPORTED_PROCESSORS := am263px +# 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 +am263px: +# am263px-lp + $(MAKE) -C firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +am263px_mcuplus: +# am263px-lp + $(MAKE) -C mcuplus/am263px-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/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/example.syscfg b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/example.syscfg new file mode 100644 index 000000000..41c6740b0 --- /dev/null +++ b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,328 @@ +/** + * 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 "OPEN_PRU@2026.02.00" --product "MCU_PLUS_SDK_AM263Px@11.00.00" + * @v2CliArgs --device "AM263P4-Q1" --package "NFBGA (ZCZ-C)" --context "r5fss0-0" --product "OPEN_PRU@2026.02.00" --product "MCU_PLUS_SDK_AM263Px@11.00.00" + * @versions {"tool":"1.26.0+4407"} + */ + +/** + * Import the modules used in this configuration. + */ +const ioexp = scripting.addModule("/board/ioexp/ioexp", {}, false); +const ioexp1 = ioexp.addInstance(); +const i2c = scripting.addModule("/drivers/i2c/i2c", {}, false); +const i2c1 = i2c.addInstance(); +const pruicss = scripting.addModule("/drivers/pruicss/pruicss", {}, false); +const pruicss1 = pruicss.addInstance(); +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const dpl_cfg = scripting.addModule("/kernel/dpl/dpl_cfg"); +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 mpu_armv76 = 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(); +const section12 = section.addInstance(); +const section13 = section.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +ioexp1.$name = "CONFIG_IOEXP0"; +ioexp1.i2cAddress = "LP-E2 0x20"; +ioexp1.TCA6416ARTWR_port0_pinAM263P_PRU_MUX_SEL_mode = 0; +ioexp1.TCA6416ARTWR_port0_pinAM263P_PRU_MUX_SEL_state = 1; +ioexp1.TCA6416ARTWR_port1_pinAM263P_PRU_BP_MUX_EN_mode = 0; +ioexp1.TCA6416ARTWR_port0_pinAM263P_BP_MUX_SEL_mode = 0; +ioexp1.TCA6416ARTWR_port0_pinAM263P_BP_MUX_SEL_state = 1; +ioexp1.TCA6416ARTWR_port1_pinAM263P_PRU_BP_MUX_EN_state = 1; + +i2c1.$name = "CONFIG_I2C0"; +ioexp1.peripheralDriver = i2c1; +i2c1.I2C.$assign = "I2C1"; +i2c1.I2C.SCL.$assign = "I2C1_SCL"; +i2c1.I2C.SDA.$assign = "I2C1_SDA"; +i2c1.I2C_child.$name = "drivers_i2c_v1_i2c_v1_template0"; + +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.iepSyncMode = true; +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-ICSS"].$assign = "PRU-ICSS"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO9.pu_pd = "pu"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO10.pu_pd = "pu"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO4.pu_pd = "pu"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO0.rx = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO0.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO1.pu_pd = "pu"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO1.$assign = "PR0_PRU0_GPIO1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO1.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO2.rx = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO2.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO11.pu_pd = "pu"; + +debug_log.enableUartLog = true; +debug_log.enableSharedMemLog = true; +debug_log.enableSharedMemLogReader = true; +debug_log.uartLog.$name = "CONFIG_UART0"; +debug_log.uartLog.UART.$assign = "UART0"; +debug_log.uartLog.UART.RXD.$assign = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$assign = "UART0_TXD"; +debug_log.uartLog.child.$name = "drivers_uart_v2_uart_v2_template0"; + +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 = 0x80000; +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_armv74.attributes = "Cached+Sharable"; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.size = 14; +mpu_armv75.baseAddr = 0x50D00000; +mpu_armv75.allowExecute = false; +mpu_armv75.attributes = "Device"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.size = 14; +mpu_armv76.allowExecute = false; +mpu_armv76.attributes = "NonCached"; +mpu_armv76.baseAddr = 0x72000000; + +default_linker1.$name = "memory_configurator_default_linker0"; + +general1.$name = "CONFIG_GENERAL0"; +general1.linker.$name = "TIARMCLANG0"; + +region1.$name = "MEMORY_REGION_CONFIGURATION0"; +region1.memory_region.create(11); +region1.memory_region[0].type = "TCMA"; +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"; +region1.memory_region[1].$name = "R5F_TCMA"; +region1.memory_region[1].size = 0x7FC0; +region1.memory_region[2].type = "TCMB"; +region1.memory_region[2].size = 0x8000; +region1.memory_region[2].$name = "R5F_TCMB"; +region1.memory_region[3].$name = "OCRAM"; +region1.memory_region[3].auto = false; +region1.memory_region[3].manualStartAddress = 0x70040000; +region1.memory_region[3].size = 0x80000; +region1.memory_region[4].type = "FLASH"; +region1.memory_region[4].auto = false; +region1.memory_region[4].manualStartAddress = 0x60100000; +region1.memory_region[4].size = 0x80000; +region1.memory_region[4].$name = "FLASH"; +region1.memory_region[5].$name = "USER_SHM_MEM"; +region1.memory_region[5].auto = false; +region1.memory_region[5].manualStartAddress = 0x701D0000; +region1.memory_region[5].size = 0x4000; +region1.memory_region[5].isShared = true; +region1.memory_region[5].shared_cores = ["r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[6].$name = "LOG_SHM_MEM"; +region1.memory_region[6].auto = false; +region1.memory_region[6].manualStartAddress = 0x701D4000; +region1.memory_region[6].size = 0x4000; +region1.memory_region[6].isShared = true; +region1.memory_region[6].shared_cores = ["r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[7].type = "CUSTOM"; +region1.memory_region[7].$name = "RTOS_NORTOS_IPC_SHM_MEM"; +region1.memory_region[7].auto = false; +region1.memory_region[7].manualStartAddress = 0x72000000; +region1.memory_region[7].size = 0x3E80; +region1.memory_region[7].isShared = true; +region1.memory_region[7].shared_cores = ["r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[8].type = "CUSTOM"; +region1.memory_region[8].$name = "MAILBOX_HSM"; +region1.memory_region[8].auto = false; +region1.memory_region[8].manualStartAddress = 0x44000000; +region1.memory_region[8].size = 0x3CE; +region1.memory_region[8].isShared = true; +region1.memory_region[8].shared_cores = ["r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[9].type = "CUSTOM"; +region1.memory_region[9].$name = "MAILBOX_R5F"; +region1.memory_region[9].auto = false; +region1.memory_region[9].manualStartAddress = 0x44000400; +region1.memory_region[9].size = 0x3CE; +region1.memory_region[9].isShared = true; +region1.memory_region[9].shared_cores = ["r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[10].auto = false; +region1.memory_region[10].size = 0x10000; +region1.memory_region[10].$name = "ICSS_PKT_BUF_MEM"; + +section1.load_memory = "R5F_VECS"; +section1.group = false; +section1.$name = "Vector Table"; +section1.output_section.create(1); +section1.output_section[0].$name = ".vectors"; +section1.output_section[0].palignment = true; + +section2.load_memory = "OCRAM"; +section2.$name = "Text Segments"; +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.load_memory = "OCRAM"; +section3.$name = "Code and Read-Only Data"; +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.load_memory = "OCRAM"; +section4.$name = "Data Segment"; +section4.output_section.create(1); +section4.output_section[0].$name = ".data"; +section4.output_section[0].palignment = true; + +section5.load_memory = "OCRAM"; +section5.$name = "Memory Segments"; +section5.output_section.create(3); +section5.output_section[0].$name = ".bss"; +section5.output_section[0].output_sections_start = "__BSS_START"; +section5.output_section[0].output_sections_end = "__BSS_END"; +section5.output_section[0].palignment = true; +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.load_memory = "OCRAM"; +section6.$name = "Stack Segments"; +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.load_memory = "OCRAM"; +section7.$name = "Initialization and Exception Handling"; +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.load_memory = "USER_SHM_MEM"; +section8.type = "NOLOAD"; +section8.$name = "User Shared Memory"; +section8.group = false; +section8.output_section.create(1); +section8.output_section[0].$name = ".bss.user_shared_mem"; +section8.output_section[0].alignment = 0; + +section9.load_memory = "LOG_SHM_MEM"; +section9.$name = "Log Shared Memory"; +section9.group = false; +section9.type = "NOLOAD"; +section9.output_section.create(1); +section9.output_section[0].$name = ".bss.log_shared_mem"; +section9.output_section[0].alignment = 0; + +section10.load_memory = "RTOS_NORTOS_IPC_SHM_MEM"; +section10.type = "NOLOAD"; +section10.$name = "IPC Shared Memory"; +section10.group = false; +section10.output_section.create(1); +section10.output_section[0].$name = ".bss.ipc_vring_mem"; +section10.output_section[0].alignment = 0; + +section11.load_memory = "MAILBOX_HSM"; +section11.type = "NOLOAD"; +section11.$name = "SIPC HSM Queue Memory"; +section11.group = false; +section11.output_section.create(1); +section11.output_section[0].$name = ".bss.sipc_hsm_queue_mem"; +section11.output_section[0].alignment = 0; + +section12.load_memory = "MAILBOX_R5F"; +section12.$name = "SIPC R5F Queue Memory"; +section12.group = false; +section12.type = "NOLOAD"; +section12.output_section.create(1); +section12.output_section[0].$name = ".bss.sipc_secure_host_queue_mem"; +section12.output_section[0].alignment = 0; + +section13.$name = "CONFIG_SECTION0"; +section13.type = "NOLOAD"; +section13.load_memory = "ICSS_PKT_BUF_MEM"; +section13.output_section.create(1); +section13.output_section[0].$name = ".bss.icss_emac_pktbuf_mem"; + +/** + * 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-ICSS"].PR0_PRU0_GPIO0.$suggestSolution = "PR0_PRU0_GPIO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS"].PR0_PRU0_GPIO2.$suggestSolution = "PR0_PRU0_GPIO2"; diff --git a/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/main.c b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/main.c new file mode 100644 index 000000000..3350801d5 --- /dev/null +++ b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/main.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2022-23 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 mirror_input_example_main(void *args); + +void freertos_main(void *args) +{ + mirror_input_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/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 000000000..46f9f44f5 --- /dev/null +++ b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 000000000..ba7db4d91 --- /dev/null +++ b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,352 @@ +# +# 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:=mirror_input.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None +BOOTIMAGE_NAME:=mirror_input.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=mirror_input.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=mirror_input.$(PROFILE).appimage.signed +BOOTIMAGE_NAME_MCELF:=mirror_input.$(PROFILE).mcelf +BOOTIMAGE_NAME_MCELF_HS:=mirror_input.$(PROFILE).mcelf.hs +BOOTIMAGE_RPRC_NAME:=mirror_input.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=mirror_input.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=mirror_input.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=mirror_input.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=mirror_input.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME_MCELF) + +ifeq ($(DEVICE_TYPE), HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) +endif + +FILES_common := \ + main.c \ + mirror_input_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/am263px/r5f \ + -I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \ + -I${OPEN_PRU_PATH}/examples/mirror_input/firmware/am263px-lp \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM263PX \ + -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.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 \ + +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.freertos.${ConfigName}.lib \ + board.am263px.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: am263px:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am263px: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: am263px: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: am263px:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am263px:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_MCELF) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am263px:r5fss0-0:freertos:ti-arm-clang mirror_input ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin + $(RM) \*.lnkxml + $(RM) \*.mcelf + $(RM) \*.mcelf_xip + $(RM) \*.mcelf-enc + $(RM) \*.mcelf.hs +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin + $(RM) *.lnkxml + $(RM) *.mcelf + $(RM) *.mcelf_xip + $(RM) *.mcelf-enc + $(RM) *.mcelf.hs +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 AM263P4 --package ZCZ_C --output generated/ ../example.syscfg +endif + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --device AM263Px --context r5fss0-0 --part AM263P4 --package ZCZ_C --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_CORE_ID_r5fss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +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 + +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_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) --otfaConfigFile=$(oeconfig) + @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! + @echo . + +$(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_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_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_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_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_MCELF_HS) Done !!! + @echo . +endif + + + +.PHONY: coverage +coverage: + @echo Creating Coverage Report for mirror_input.$(PROFILE) ... + $(MKDIR) coverage + $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o mirror_input.$(PROFILE).profdata + $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=mirror_input.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins + $(COV) export --format=text --object=$(OUTNAME) --instr-profile=mirror_input.$(PROFILE).profdata > coverage/mirror_input.$(PROFILE).profdata.json + node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/mirror_input.$(PROFILE).profdata.json --output-json=coverage/mirror_input.$(PROFILE).analysis.json --output=../mirror_input.annotations.$(PROFILE).S --top-function-count=500 + @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!! + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 000000000..d6f49d8fb --- /dev/null +++ b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,112 @@ +# +# 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_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf +BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs +TARGETS += $(BOOTIMAGE_NAME_MCELF) +TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) +ifeq ($(DEVICE_TYPE), HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) +endif + +# +# 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 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +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 + +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 multi-core ELF image: am263px:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... + + $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTFILE) --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) + + @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) 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_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_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_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_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_MCELF_HS) Done !!! + @echo . +endif +endif diff --git a/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 000000000..7b1ee8cdd --- /dev/null +++ b/examples/mirror_input/mcuplus/am263px-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=mirror_input_am263px-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/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 000000000..f716f8e9d --- /dev/null +++ b/examples/mirror_input/mcuplus/am263px-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/mirror_input/mcuplus/mirror_input_example.c b/examples/mirror_input/mcuplus/mirror_input_example.c new file mode 100644 index 000000000..504bba136 --- /dev/null +++ b/examples/mirror_input/mcuplus/mirror_input_example.c @@ -0,0 +1,93 @@ +/* + * 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_drivers_open_close.h" +#include "ti_board_open_close.h" +#include + +#include + + + +/* + * This is an example project to show R5F + * loading PRU firmware. + */ + +/** \brief Global Structure pointer holding PRUSS1 memory Map. */ + +PRUICSS_Handle gPruIcss0Handle; + + +void mirror_input_example_main(void *args) +{ + Drivers_open(); // check return status + + int status; + status = Board_driversOpen(); + DebugP_assert(SystemP_SUCCESS == status); + + gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0); + + status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU0)); + DebugP_assert(status != 0); + + status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU1)); + DebugP_assert(status != 0); + + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_PRU0, PRU0Firmware_0, sizeof(PRU0Firmware_0)); + DebugP_assert(SystemP_SUCCESS == status); + // status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_PRU1, PRU1Firmware_0, sizeof(PRU1Firmware_0)); + // DebugP_assert(SystemP_SUCCESS == status); + + #if defined(SOC_AM64X) || defined(SOC_AM243X) + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_RTU_PRU0, RTUPRU0Firmware_0, sizeof(RTUPRU0Firmware_0)); + DebugP_assert(SystemP_SUCCESS == status); + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_RTU_PRU1, RTUPRU1Firmware_0, sizeof(RTUPRU1Firmware_0)); + DebugP_assert(SystemP_SUCCESS == status); + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_TX_PRU0, TXPRU0Firmware_0, sizeof(TXPRU0Firmware_0)); + DebugP_assert(SystemP_SUCCESS == status); + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_TX_PRU1, TXPRU1Firmware_0, sizeof(TXPRU1Firmware_0)); + DebugP_assert(SystemP_SUCCESS == status); + #endif + + while (1) + { + ClockP_usleep(1); + } + + Board_driversClose(); + Drivers_close(); +} diff --git a/examples/mirror_input/readme.md b/examples/mirror_input/readme.md new file mode 100644 index 000000000..854a40423 --- /dev/null +++ b/examples/mirror_input/readme.md @@ -0,0 +1,133 @@ +# mirror_input Project + +## Introduction + +This example demonstrates how to mirror input signals to an output pin using the PRU-ICSS. The PRU firmware polls the EPWM input signal on every edge and samples the CMP input at that edge, mirroring it to the ICL output. Because CMP is only sampled once per EPWM edge, a CMP change between edges is not propagated until the next edge — this is an edge-sampled mirror, not a live mirror. + +## 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 | +| --------- | ---------- | -------------------------- | +| AM263Px | LP-AM263P | MCU PLUS SDK 11.0.0.19, OpenPRU 2026.02.00, TI PRU CGT 2.3.3, TI ARM Clang 4.0.0 | + +## Overview + +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). + +## Timing Analysis + +Worst-case timing budget for the EPWM-edge -> ICL mirror in `firmware/main.asm`, +measured on AM263Px hardware (PRU clock 200 MHz, 5 ns/cycle) with a Saleae +capture. + +Note: all measurements below follow from the 200Mhz PRU clock, 5 ns/cycle + +### Instructions used + +```asm +main: + zero &r0,124 +high_pulse: + wbs r31, EPWM_SIGNAL ; poll: block until EPWM (GPI2) goes high + qbbs bit_set0, r31,CMP_SIGNAL +bit_clear0: + clr r30, r30, ICL_SIGNAL + qba low_pulse +bit_set0: + set r30, r30, ICL_SIGNAL + +low_pulse: + wbc r31, EPWM_SIGNAL ; poll: block until EPWM (GPI2) goes low + qbbs bit_set1, r31,CMP_SIGNAL +bit_clear1: + clr r30, r30, ICL_SIGNAL + qba high_pulse +bit_set1: + set r30, r30, ICL_SIGNAL + qba high_pulse +``` + +- `wbs` -- wait until the selected bit is set. +- `wbc` -- wait until the selected bit is clear. +- `wbs`/`wbc` re-execute in place every cycle until the polled bit matches, so + they add no fixed cost of their own beyond however long the input takes to + change -- the instruction that "completes" is whichever cycle the bit + finally matches. +- `qbbs` tests one bit of `r31` (GPI) and branches if set. +- `set`/`clr` write the mirrored bit into `r30` (GPO). +- `zero &r0,124` only runs once at boot; it is not on the edge-to-output path. + +### Edge-to-output path timing + +The PRU is a single-issue, non-pipelined core: every instruction, taken +branch or not, executes in exactly 1 cycle. From the instant `wbs`/`wbc` +releases (EPWM edge seen) to the instant `r30` is written, the core executes: + +1. `wbs`/`wbc` releases (the cycle the edge is sampled and matched) +2. `qbbs` (bit test + branch) +3. `set` or `clr` (GPO write) + +That is 2 instructions after `wbs`/`wbc` releases (10 ns at 200 MHz). However, +`wbs`/`wbc` samples R31 once per cycle until the bit matches, so the edge +detection itself adds 0–5 ns of sampling jitter. The firmware term is therefore +10–15 ns, not a fixed value -- the mirror latency is data-dependent through the +sampling jitter, not constant. + +At the measured 200 MHz PRU clock: + + +This matches the Saleae capture below: of the total 30 ns delta between the +EPWM edge and the ICL output changing, 10–15 ns is the firmware path and the +remaining 15–20 ns is fixed hardware delay -- GPI pad/synchronizer input +latency plus GPO pad output latency, outside the PRU core entirely and not +reducible by firmware changes. + +Firmware (10–15 ns @200MHz): 10-15 ns +GPI->GPO hardware delay : 15-20 ns (remainder, not controllable in software) + + +### Flow chart + +![mirror_input firmware flow](images/flow_diagram_mirror_input.png) + +Source: `images/mirror_input_flow.drawio` (editable at +[app.diagrams.net](https://app.diagrams.net)). + +### Measured capture + +- Top signal: EPWM input on GPI2 +- Middle signal: CMP input on GPI0 +- Bottom signal: latched output from GPO1 + +![30 ns delta between EPWM/CMP input and ICL mirror output](images/time_diff_between_signals.png) + +The right-hand panel's `P0 -> Δ30 ns (33.22 MHz)` marker is the measured +edge-to-mirror delay described above. + +## Steps to Run the Example + + 1. Open CCS and import the mirror input example (open-pru\examples\mirror_input) from the Open-pru repo. Make sure to import projects corresponding to r5fss0-0, icss_m0_pru0. + + 2. Build the pru0 projects first. This ensures that the header files with the binary for pru0 is generated. + + 3. Now build the project mirror_input_am263px-lp_r5fss0-0_freertos_ti-arm-clang (Here after will be called r5f project). + + 4. Power on the AM263Px Launch Pad. It is recommended to go through the "Getting started" section of MCU + SDK if this is your first time working on the launchpad. + + 5. Set up Target configuration window from View>>Target Configuration. Then launch any project target configuration by right clicking on the AM263Px.ccxml file and selecting "launch selected configuration" + + 6. From the debug window, select the r5f project and load the corresponding .out file and then press the "Resume" button to start the example in debug mode. + + 7. Provide the EPWM signal to PR0_PRU0_GPIO2 and the input signal to PR0_PRU0_GPIO0, probe PR0_PRU0_GPIO1 to check the mirror output according to the following truth table: + +![Truth table for the code logic](images/truth_table.png) diff --git a/examples/readme.md b/examples/readme.md index 6bb74c6f3..f3d7d7985 100644 --- a/examples/readme.md +++ b/examples/readme.md @@ -47,6 +47,9 @@ pru_i2s pru_eqep * PRU implementation of EQEP (Enhanced Quadrature Encoder Pulse) +mirror_input +* Mirror input signals to an output pin using the PRU-ICSS, with constant latency + spi_loopback * Implement a loopback SPI connection between 2 PRU cores that act as SPI master and SPI slave @@ -94,6 +97,7 @@ For more information about the PRU features on each processor, refer to app note | LCD_interface | Y | Yport | Yport | Yport | N-sw | Yport | | logic_scope | Y | Yport | Yport | Yport | Yport | Yport | | pru_eqep | Y | Yport | Yport | Yport | N-sw | Yport | +| mirror_input | Yport | Yport | Y | Yport | N-sw | Yport | | pru_emif | Y | Yport | Yport | Yport | N-sw | Yport | | pru_i2s | Yport | Y | Yport | Y | N-sw | Yport | | spi_loopback | Y | Yport | Yport | Yport | N-sw | Yport |