diff --git a/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..ccb6bf7ff --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..13fdcb5e9 --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM261x_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM261x 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/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..bd9bb9d09 --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am261x-lp_icss_m0_pru0_fw +HEX_ARRAY_PREFIX := PRU0Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am261x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..4a365761d --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am261x-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/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..07e7c1770 --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..774184ddf --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM261x_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM261x PRU1 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 1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00002000 + /* 8 KB PRU Data RAM 0 */ + PRU0_DMEM_0 : 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 > 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/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..b1b6a1364 --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am261x-lp_icss_m0_pru1_fw +HEX_ARRAY_PREFIX := PRU1Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am261x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..09d8e74d4 --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am261x-lp_icss_m0_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/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..09feec6cf --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..13fdcb5e9 --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM261x_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM261x 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/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..83330a24d --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am261x-som_icss_m0_pru0_fw +HEX_ARRAY_PREFIX := PRU0Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am261x-som/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..b4c22dec3 --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am261x-som_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/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..ce24d5023 --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..774184ddf --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM261x_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM261x PRU1 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 1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00002000 + /* 8 KB PRU Data RAM 0 */ + PRU0_DMEM_0 : 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 > 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/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..98fdad893 --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am261x-som_icss_m0_pru1_fw +HEX_ARRAY_PREFIX := PRU1Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am261x-som/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..a10ea14b8 --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am261x-som_icss_m0_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/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..cef1fa593 --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..5b64bc7ef --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/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/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..1be3a0b58 --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am263px-cc_icss_m0_pru0_fw +HEX_ARRAY_PREFIX := PRU0Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am263px-cc/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..4c4a79d2b --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am263px-cc_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/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..dce254501 --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..57db723f6 --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM263Px_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM263Px PRU1 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 1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00002000 + /* 8 KB PRU Data RAM 0 */ + PRU0_DMEM_0 : 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 > 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/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..7f31497eb --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am263px-cc_icss_m0_pru1_fw +HEX_ARRAY_PREFIX := PRU1Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am263px-cc/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..8e2dbc1e6 --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am263px-cc_icss_m0_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/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..975bca0f2 --- /dev/null +++ b/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..5b64bc7ef --- /dev/null +++ b/examples/double_float/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/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..877c48f38 --- /dev/null +++ b/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am263px-lp_icss_m0_pru0_fw +HEX_ARRAY_PREFIX := PRU0Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am263px-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..666e4b0c1 --- /dev/null +++ b/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_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/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..975463a5a --- /dev/null +++ b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..57db723f6 --- /dev/null +++ b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM263Px_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM263Px PRU1 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 1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00002000 + /* 8 KB PRU Data RAM 0 */ + PRU0_DMEM_0 : 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 > 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/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..38dbe6ab3 --- /dev/null +++ b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am263px-lp_icss_m0_pru1_fw +HEX_ARRAY_PREFIX := PRU1Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am263px-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..074de1613 --- /dev/null +++ b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am263px-lp_icss_m0_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/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..6bbf6859c --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..11542351e --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM263x_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM263x 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/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..3de85ce12 --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am263x-cc_icss_m0_pru0_fw +HEX_ARRAY_PREFIX := PRU0Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am263x-cc/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..9a8c7c3ca --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am263x-cc_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/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..cf1158b7f --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..cf0121bf4 --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM263x_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM263x PRU1 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 1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00002000 + /* 8 KB PRU Data RAM 0 */ + PRU0_DMEM_0 : 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 > 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/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..fddaba898 --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am263x-cc_icss_m0_pru1_fw +HEX_ARRAY_PREFIX := PRU1Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am263x-cc/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..618883c83 --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am263x-cc_icss_m0_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/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..e59603084 --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..11542351e --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM263x_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM263x 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/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..eb19bd8f2 --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am263x-lp_icss_m0_pru0_fw +HEX_ARRAY_PREFIX := PRU0Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am263x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..c2ca28dd0 --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am263x-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/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..36eac2381 --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..cf0121bf4 --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,43 @@ +/* + * AM263x_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM263x PRU1 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 1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00002000 + /* 8 KB PRU Data RAM 0 */ + PRU0_DMEM_0 : 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 > 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/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..2c105e454 --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,149 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := double_float_multiply_am263x-lp_icss_m0_pru1_fw +HEX_ARRAY_PREFIX := PRU1Firmware +GEN_DIR := generated +TARGET := $(GEN_DIR)/$(OUTPUT_NAME).out +TARGET_HEX := $(GEN_DIR)/$(OUTPUT_NAME).h + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/double_float/firmware/am263x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . +vpath %.asm $(FILES_PATH) +vpath %.c $(FILES_PATH) +vpath %.cmd $(FILES_PATH) +vpath %.obj $(GEN_DIR) +C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))) +ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))) + +# Generate an object file for every *.asm and *.c source file in FILES_PATH +OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))) +OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \ + $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))) + +# Linker command file +COMMAND_FILES := linker.cmd + +# Include paths +INCLUDE := \ + --include_path=$(CGT_TI_PRU_PATH)/include \ + --include_path=$(OPEN_PRU_PATH)/source +ifeq ($(BUILD_MCUPLUS),y) +INCLUDE += \ + --include_path=$(MCU_PLUS_SDK_PATH)/source \ + --include_path=$(MCU_PLUS_SDK_PATH)/source/pru_io/firmware/common +endif + +# Compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +# commonly modified flags include: +# silicon version: -v (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +# C code optimization: -O (off, 0, 1, 2, 3, 4) +CFLAGS := \ + -v3 -O2 \ + --display_error_number --diag_wrap=off --diag_warning=225 \ + --asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \ + -ppd -ppa -g --endian=little + +# Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) +LFLAGS := \ + -m$(GEN_DIR)/$(OUTPUT_NAME).map --xml_link_info=$(GEN_DIR)/$(OUTPUT_NAME)_linkInfo.xml \ + --display_error_number --diag_wrap=off --diag_warning=225 --diag_suppress=10063-D \ + --warn_sections --reread_libs + +ifeq ($(C_FILES),) +# PRU firmware is assembly-only +# commonly modified flags include: +# entry point +LFLAGS += \ + --entry_point=main --disable_auto_rts --ram_model + +else +# PRU firmware has C code +# commonly modified flags include: +# stack size, heap size +LFLAGS += \ + --stack_size=0x100 --heap_size=0x100 \ + -i$(CGT_TI_PRU_PATH)/lib -i$(CGT_TI_PRU_PATH)/include --library=libc.a +endif + +# 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 := + +# Only build if tools are defined +ifeq (,$(CGT_TI_PRU_PATH)) +all clean: + @echo 'CGT_TI_PRU_PATH not set. Make sure that:' + @echo ' 1) OPEN_PRU_PATH points to the open-pru repo' + @echo ' 2) imports.mak exists at OPEN_PRU_PATH' + @echo ' 3) Both the open-pru repo and imports.mak are set up as per' + @echo ' OPEN_PRU_PATH/docs/getting_started.md' +else + +# All Target +all: $(OBJECTS) $(COMMAND_FILES) + @$(MAKE) --no-print-directory -Onone "$(TARGET)" + +# Invoke the compiler on all assembly files in vpath to create the object files +$(GEN_DIR)/%.obj: %.asm + $(MKDIR) $(GEN_DIR) + @echo 'Building file: "$^"' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the compiler on all c files in vpath to create the object files +$(GEN_DIR)/%.obj: %.c + $(MKDIR) $(GEN_DIR) + @echo 'Building file: $^' + @echo 'Invoking: PRU Compiler' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(INCLUDE) $(CFLAGS) $(DFLAGS) $^ + @echo 'Finished building: "$^"' + @echo ' ' + +# Invoke the linker (-z flag) to make the .out file +$(TARGET): $(OBJECTS) $(COMMAND_FILES) + @echo 'Building target: "$@"' + @echo 'Invoking: PRU Linker' + "$(CGT_TI_PRU_PATH)/bin/clpru" $(CFLAGS) -z $^ $(LFLAGS) -o $(TARGET) $(LIBS) + @echo 'Finished building target: "$@"' + @echo ' ' + @$(MAKE) --no-print-directory post-build + +# To clean generated files +clean: + -$(RMDIR) $(GEN_DIR) +ifeq ($(BUILD_MCUPLUS),y) + -$(RM) $(MCU_HEX_PATH) +endif + @echo 'Finished clean' + @echo ' ' +endif + +# Generate hex array +post-build: + -$(CGT_TI_PRU_PATH)/bin/hexpru --diag_wrap=off --array --array:name_prefix=$(HEX_ARRAY_PREFIX) -o $(TARGET_HEX) $(TARGET) + -$(CAT) $(OPEN_PRU_PATH)/source/firmware/pru_load_bin_copyright.h $(TARGET_HEX) > $(TARGET_HEX).temp + -$(MOVE) $(TARGET_HEX).temp $(TARGET_HEX) +ifeq ($(BUILD_MCUPLUS),y) + -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) +endif + @echo ' ' + +.PHONY: all clean + +# Include the dependencies that the compiler creates (-ppd and -ppa flags) +-include $(OBJECTS:%.obj=%.pp) diff --git a/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..422baeaf3 --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=double_float_multiply_am263x-lp_icss_m0_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/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs new file mode 100644 index 000000000..472ab3849 --- /dev/null +++ b/examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== 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", +]; diff --git a/examples/double_float/firmware/main.asm b/examples/double_float/firmware/main.asm new file mode 100644 index 000000000..98bc61111 --- /dev/null +++ b/examples/double_float/firmware/main.asm @@ -0,0 +1,320 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright (C) 2024-2025 Texas Instruments Incorporated - http://www.ti.com/ + +;******************************************************************************* +; File: main.asm +; +; Brief: IEEE 754 double-precision (64-bit) floating-point multiplication +; using the PRU MAC broadside accelerator. The 53-bit × 53-bit +; significand product is computed via four 32×32→64-bit hardware +; multiply operations, avoiding the slow software FP library path. +; +; Steps to build: +; - Using CCS: +; Import PRU project, build → generates .out and .h files +; - Using makefile: +; gmake -all +; +; IEEE 754 double (64-bit) format: +; bit 63 : sign (S) +; bits 62:52 : biased exponent (E, bias = 1023) +; bits 51:0 : mantissa fraction (M) +; value = (-1)^S × 2^(E−1023) × 1.M (for normal numbers) +; +; Algorithm: +; Given operands A and B stored in PRU Data RAM: +; 1. Load hi/lo words of A and B from memory +; 2. Restore the 53-bit significands: sigA = 1.M_A, sigB = 1.M_B +; 3. result_sign = signA XOR signB +; 4. result_exp = expA + expB − 1023 +; 5. Multiply the 53-bit significands with four 32-bit MAC operations: +; +; sigA = sigA_hi : sigA_lo (21-bit upper, 32-bit lower) +; sigB = sigB_hi : sigB_lo +; +; p00 = sigA_lo × sigB_lo position [63:0] +; p01 = sigA_hi × sigB_lo position [95:32] +; p10 = sigA_lo × sigB_hi position [95:32] +; p11 = sigA_hi × sigB_hi position [127:64] +; +; 106-bit product P accumulated in {pp3:pp2:pp1}: +; pp1 = P[63:32] +; pp2 = P[95:64] +; pp3 = P[105:96] +; +; 6. Normalise: P ∈ [2^104, 2^106), leading 1 at bit 104 or 105 +; bit 105 clear → mantissa = P[103:52], keep exp +; bit 105 set → mantissa = P[104:53], exp += 1 +; 7. Pack and store result double to PRU Data RAM +; +; PRU Data RAM memory map (byte offsets from address 0x0000): +; 0x00 operand A low word (bits 31:0) +; 0x04 operand A high word (bits 63:32) +; 0x08 operand B low word +; 0x0C operand B high word +; 0x10 result low word (written by this code) +; 0x14 result high word +; +; MAC unit per-operation cost (multiply-only mode): +; MOV R28, op1 (1 cy) — load operand 1 +; MOV R29, op2 (1 cy) — load operand 2, triggers hardware multiply +; NOP (1 cy) — 1-cycle result latency +; XIN &R26, 4 (1 cy) — read result[31:0] +; XIN &R27, 4 (1 cy) — read result[63:32] +; +; Worst-case PRU cycle count : 85 cycles (200 MHz clock → 425 ns) +; Prologue (init + load + sign/exp + significand build) : 28 cy +; 4 × MAC with on-the-fly carry accumulation : 32 cy +; Normalise check (QBBS) : 1 cy +; Normalise path (do_shift, worst case) : 9 cy +; Round-to-nearest (round up + exponent overflow, rare) : 6 cy +; Pack result : 4 cy +; Store + HALT : 4 cy +; ────────────────────────────────────────────────────────────── +; NOTE: Round-to-nearest uses the "ties away from zero" mode. +; The rounding guard bit is taken from the bit immediately below +; the 52-bit mantissa field. Sticky bits (lower product bits) are +; not examined, matching standard IEEE 754 round-to-nearest behaviour +; for all but exact-midpoint cases. +; +; No-special-case handling: NaN, Infinity, denormals and zero are not +; handled to keep focus on the MAC acceleration demonstration. +; See main_c_ref.c for the equivalent C library code. +; +;******************************************************************************* + +; CCS/makefile specific settings + .retain + .retainrefs + + .global main + .sect ".text" + +; ── MAC broadside peripheral constants ─────────────────────────────────────── + .asg 0x0, DEVICE_ID ; MAC broadside device ID (device 0) + .asg 0x0, MULTIPLY_ONLY ; R25 control word: multiply-only mode + +; ── PRU Data RAM byte offsets ───────────────────────────────────────────────── + .asg 0x00, OFFS_A_LO ; operand A bits [31:0] + .asg 0x04, OFFS_A_HI ; operand A bits [63:32] + .asg 0x08, OFFS_B_LO ; operand B bits [31:0] + .asg 0x0C, OFFS_B_HI ; operand B bits [63:32] + .asg 0x10, OFFS_R_LO ; result bits [31:0] + .asg 0x14, OFFS_R_HI ; result bits [63:32] + +; ── Register aliases ────────────────────────────────────────────────────────── + .asg r2, lo_A ; A bits [31:0] + .asg r3, hi_A ; A bits [63:32] → sign[31], exp[30:20], mant[19:0] + .asg r4, lo_B ; B bits [31:0] + .asg r5, hi_B ; B bits [63:32] + .asg r6, sigA_lo ; lower 32 bits of 53-bit significand of A + .asg r7, sigA_hi ; upper 21 bits of 53-bit significand of A (bit 20 = implicit 1) + .asg r8, sigB_lo ; lower 32 bits of 53-bit significand of B + .asg r9, sigB_hi ; upper 21 bits of 53-bit significand of B + .asg r10, expA ; 11-bit biased exponent of A + .asg r11, expB ; 11-bit biased exponent of B + .asg r12, res_sign ; result sign (bit 0) + .asg r13, res_exp ; result biased exponent + .asg r22, pp1 ; accumulated product bits [63:32] + .asg r23, pp2 ; accumulated product bits [95:64] + .asg r24, pp3 ; accumulated product bits [105:96] + +;**************************** +;* MAIN * +;**************************** +main: + +; ── Initialise registers and MAC unit ──────────────────────────────────────── +init: + zero &r0, 120 ; clear R0–R29 (120 bytes = 30 × 4-byte registers) + ; r1 = 0 after zero → used as base address for LBBO/SBBO + LDI r25, MULTIPLY_ONLY ; MAC control word = 0 (multiply-only mode) + XOUT DEVICE_ID, &r25, 1 ; configure MAC unit + +; ── Load the two operands from PRU Data RAM ─────────────────────────────────── + LBBO &lo_A, r1, OFFS_A_LO, 4 + LBBO &hi_A, r1, OFFS_A_HI, 4 + LBBO &lo_B, r1, OFFS_B_LO, 4 + LBBO &hi_B, r1, OFFS_B_HI, 4 + +; ── Extract sign bits ───────────────────────────────────────────────────────── + LSR res_sign, hi_A, 31 ; res_sign = signA (bit 31 of hi word) + LSR r0, hi_B, 31 ; r0 = signB + XOR res_sign, res_sign, r0 ; result sign = signA XOR signB + +; ── Extract 11-bit biased exponents ────────────────────────────────────────── + ; hi word layout: [31]=sign, [30:20]=exponent[10:0], [19:0]=mantissa[51:32] + ; After LSR by 20 the exponent sits in bits [10:0] with sign_bit at [11]. + ; 0x7FF (2047) > 255 so we cannot use the 8-bit OP(255) immediate form of AND; + ; load the mask into a register first. + LSR expA, hi_A, 20 + LDI r0, 0x7FF ; 11-bit mask (fits in 16-bit LDI) + AND expA, expA, r0 ; expA = bits [10:0] = 11-bit exponent + LSR expB, hi_B, 20 + AND expB, expB, r0 ; r0 still = 0x7FF + +; ── Compute result biased exponent: expA + expB − 1023 ─────────────────────── + ADD res_exp, expA, expB + LDI r0, 1023 + SUB res_exp, res_exp, r0 + +; ── Restore 53-bit significands (re-insert the implicit leading 1) ──────────── + ; sigA_lo = lower 32 bits of significand = lo_A (direct copy) + ; sigA_hi = upper 21 bits of significand: + ; bit 20 = implicit leading 1 + ; bits [19:0] = mantissa[51:32] from hi_A[19:0] + ; LSL/LSR by 12 isolates bits [19:0] of hi_A (discards sign and exponent). + MOV sigA_lo, lo_A + LSL sigA_hi, hi_A, 12 ; shift left to discard sign[31] + exp[30:20] + LSR sigA_hi, sigA_hi, 12 ; shift right to right-align mantissa[51:32] + LDI32 r0, 0x100000 ; 0x100000 = bit 20 = implicit leading 1 + ; (LDI32 is a 2-instruction pseudo-op: 2 cycles) + OR sigA_hi, sigA_hi, r0 ; sigA_hi = 21-bit upper significand + + MOV sigB_lo, lo_B + LSL sigB_hi, hi_B, 12 + LSR sigB_hi, sigB_hi, 12 + OR sigB_hi, sigB_hi, r0 ; r0 still = 0x100000 + +; ── Multiply 53-bit significands via four 32-bit MAC operations ─────────────── +; +; sigA = sigA_hi × 2^32 + sigA_lo (sigA_hi ≤ 21 bits, sigA_lo = 32 bits) +; sigB = sigB_hi × 2^32 + sigB_lo +; +; 106-bit product P = sigA × sigB, accumulated in {pp3:pp2:pp1} = P[105:32]: +; +; p00 contributes to P[63:0] → pp1 seed = p00[63:32], p00[31:0] discarded +; p01 contributes to P[95:32] → pp1 += p01[31:0], pp2 += p01[63:32] +; p10 contributes to P[95:32] → pp1 += p10[31:0], pp2 += p10[63:32] +; p11 contributes to P[127:64] → pp2 += p11[31:0], pp3 += p11[63:32] +; +; All carries are propagated immediately with ADC. + + ; --- p00 = sigA_lo × sigB_lo ------------------------------------------------ + MOV r28, sigA_lo + MOV r29, sigB_lo ; writing R29 triggers hardware multiply + NOP ; 1-cycle result latency + XIN DEVICE_ID, &r26, 4 ; r26 = p00[31:0] (below mantissa; read required by MAC protocol) + XIN DEVICE_ID, &r27, 4 ; r27 = p00[63:32] + MOV pp1, r27 ; pp1 = p00_hi (seed, pp2/pp3 still 0 from zero) + + ; --- p01 = sigA_hi × sigB_lo ------------------------------------------------ + MOV r28, sigA_hi + MOV r29, sigB_lo + NOP + XIN DEVICE_ID, &r26, 4 ; r26 = p01[31:0] + XIN DEVICE_ID, &r27, 4 ; r27 = p01[63:32] + ADD pp1, pp1, r26 ; pp1 += p01[31:0]; carry to pp2 + ADC pp2, pp2, 0 ; pp2 += carry (pp2 was 0) + ADD pp2, pp2, r27 ; pp2 += p01[63:32]; carry to pp3 + ADC pp3, pp3, 0 ; pp3 += carry (pp3 was 0) + + ; --- p10 = sigA_lo × sigB_hi ------------------------------------------------ + MOV r28, sigA_lo + MOV r29, sigB_hi + NOP + XIN DEVICE_ID, &r26, 4 ; r26 = p10[31:0] + XIN DEVICE_ID, &r27, 4 ; r27 = p10[63:32] + ADD pp1, pp1, r26 ; pp1 += p10[31:0]; carry to pp2 + ADC pp2, pp2, 0 ; pp2 += carry + ADD pp2, pp2, r27 ; pp2 += p10[63:32]; carry to pp3 + ADC pp3, pp3, 0 ; pp3 += carry + + ; --- p11 = sigA_hi × sigB_hi ------------------------------------------------ + MOV r28, sigA_hi + MOV r29, sigB_hi + NOP + XIN DEVICE_ID, &r26, 4 ; r26 = p11[31:0] + XIN DEVICE_ID, &r27, 4 ; r27 = p11[63:32] (≤10 bits: 21-bit×21-bit=42-bit) + ADD pp2, pp2, r26 ; pp2 += p11[31:0]; carry to pp3 + ADC pp3, pp3, 0 ; pp3 += carry + ADD pp3, pp3, r27 ; pp3 += p11[63:32] + +; ── Normalise ───────────────────────────────────────────────────────────────── +; +; P ∈ [2^104, 2^106) because sigA, sigB ∈ [2^52, 2^53). +; The leading 1 of P is therefore at bit 104 or bit 105. +; +; pp3 holds P[105:96]. P[105] = pp3[9]. +; +; bit 105 clear (no shift): mantissa = P[103:52] +; mantissa_lo[31:0] = {pp2[19:0] << 12, pp1[31:20]} +; mantissa_hi[19:0] = {pp3[7:0] << 12, pp2[31:20]} +; +; bit 105 set (shift right 1, exponent += 1): mantissa = P[104:53] +; mantissa_lo[31:0] = {pp2[20:0] << 11, pp1[31:21]} +; mantissa_hi[19:0] = {pp3[8:0] << 11, pp2[31:21]} + + QBBS do_shift, pp3, 9 ; branch if P[105]=pp3[9] is set + +noshift: + ; mantissa_lo = P[83:52] = {pp2[19:0] << 12, pp1[31:20]} + LSL r0, pp2, 12 ; r0[31:12] = pp2[19:0] + LSR r2, pp1, 20 ; r2[11:0] = pp1[31:20] + OR r0, r0, r2 ; r0 = mantissa_lo (32 bits) + + ; mantissa_hi (20 bits) = P[103:84] = {pp3[7:0] << 12, pp2[31:20]} + AND r2, pp3, 0xFF ; r2 = pp3[7:0] (0xFF = 255, fits OP(255)) + LSL r2, r2, 12 ; r2[19:12] = pp3[7:0] + LSR r3, pp2, 20 ; r3[11:0] = pp2[31:20] + OR r2, r2, r3 ; r2 = mantissa_hi (20 bits) + + ; Round to nearest (ties away from zero): round bit = P[51] = pp1[19] + QBBC rnd_ns_done, pp1, 19 ; skip if round bit = 0 + ADD r0, r0, 1 ; mantissa_lo += 1 + ADC r2, r2, 0 ; propagate carry into mantissa_hi + QBBC rnd_ns_done, r2, 20 ; skip if no exponent overflow + ; Exponent overflow: mantissa was 0xFFFFF and wrapped to 0x100000 (only bit 20 set). + ; LSL by 12 shifts 0x100000 left 12 → 0x100000000 which truncates to 0x00000000. + ; LSR by 12 of 0 = 0. Result: mantissa_hi = 0, mantissa_lo = 0 (already wrapped). + LSL r2, r2, 12 ; (0x100000 << 12) & 0xFFFFFFFF = 0 + LSR r2, r2, 12 ; r2 = 0 (mantissa_hi = 0, implicit 1 consumed) + ADD res_exp, res_exp, 1 ; exponent overflow: result = 1.0 × 2^(exp+1) +rnd_ns_done: + QBA pack_result + +do_shift: + ; Product has an extra factor of 2: normalise by incrementing exponent + ADD res_exp, res_exp, 1 + + ; mantissa_lo = P[84:53] = {pp2[20:0] << 11, pp1[31:21]} + LSL r0, pp2, 11 ; r0[31:11] = pp2[20:0] + LSR r2, pp1, 21 ; r2[10:0] = pp1[31:21] + OR r0, r0, r2 ; r0 = mantissa_lo (32 bits) + + ; mantissa_hi (20 bits) = P[104:85] = {pp3[8:0] << 11, pp2[31:21]} + ; 0x1FF (511) > 255, cannot use as OP(255) immediate — load into register + LDI r3, 0x1FF ; 9-bit mask + AND r2, pp3, r3 ; r2 = pp3[8:0] + LSL r2, r2, 11 ; r2[19:11] = pp3[8:0] + LSR r3, pp2, 21 ; r3[10:0] = pp2[31:21] + OR r2, r2, r3 ; r2 = mantissa_hi (20 bits) + + ; Round to nearest (ties away from zero): round bit = P[52] = pp1[20] + QBBC rnd_ds_done, pp1, 20 ; skip if round bit = 0 + ADD r0, r0, 1 ; mantissa_lo += 1 + ADC r2, r2, 0 ; propagate carry into mantissa_hi + QBBC rnd_ds_done, r2, 20 ; skip if no exponent overflow + ; Exponent overflow: same as noshift path — mantissa wrapped to 0x100000. + LSL r2, r2, 12 ; (0x100000 << 12) & 0xFFFFFFFF = 0 + LSR r2, r2, 12 ; r2 = 0 (mantissa_hi = 0, implicit 1 consumed) + ADD res_exp, res_exp, 1 ; exponent overflow: result = 1.0 × 2^(exp+1) +rnd_ds_done: + +pack_result: +; ── Assemble the result double ──────────────────────────────────────────────── +; hi_result[31] = result sign +; hi_result[30:20] = result exponent (11 bits) +; hi_result[19:0] = mantissa[51:32] (= r2, 20 bits) +; lo_result[31:0] = mantissa[31:0] (= r0, 32 bits) + LSL r3, res_exp, 20 ; r3 = exp << 20 (bits [30:20]) + OR r3, r3, r2 ; r3 |= mantissa_hi (bits [19:0]) + LSL r1, res_sign, 31 ; r1 = sign << 31 + OR r3, r3, r1 ; r3 = hi_result + +; ── Store result to PRU Data RAM ───────────────────────────────────────────── + LDI r1, 0 ; reset base address (r1 was modified above) + SBBO &r0, r1, OFFS_R_LO, 4 ; store mantissa_lo → result bits [31:0] + SBBO &r3, r1, OFFS_R_HI, 4 ; store hi_result → result bits [63:32] + + halt diff --git a/examples/double_float/firmware/main_c_ref.c b/examples/double_float/firmware/main_c_ref.c new file mode 100644 index 000000000..0c2396a6a --- /dev/null +++ b/examples/double_float/firmware/main_c_ref.c @@ -0,0 +1,93 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2024-2025 Texas Instruments Incorporated - http://www.ti.com/ + */ + +/** + * @file main_c_ref.c + * + * @brief IEEE 754 double-precision multiply: C library reference. + * + * This file shows the equivalent C code for the optimised PRU assembly in + * main.asm. When compiled for the PRU (which has no hardware FPU), the C + * compiler generates a call to the software double-precision multiply routine + * from the C runtime library (__mpy2d). That software path does NOT use the + * PRU MAC broadside accelerator, which is why the hand-written assembly in + * main.asm is significantly faster. + * + * Typical cycle counts (200 MHz PRU clock): + * Assembly with MAC hardware accelerator : ~85 cycles (~425 ns) + * C library __mpy2d (software FP) : ~200+ cycles + * + * Memory layout used by both implementations (PRU Data RAM, byte offsets): + * 0x00 operand A low word (bits 31:0) + * 0x04 operand A high word (bits 63:32) + * 0x08 operand B low word + * 0x0C operand B high word + * 0x10 result low word (written by the multiply) + * 0x14 result high word + * + * NOTE: This file is provided as a reference and is NOT compiled into the + * default PRU firmware project (which uses main.asm). To build it instead, + * remove main.asm from the project and add this file. + */ + +#include + +/* PRU Data RAM memory map (byte offsets from address 0x0000) */ +#define OFFS_A_LO 0x00u +#define OFFS_A_HI 0x04u +#define OFFS_B_LO 0x08u +#define OFFS_B_HI 0x0Cu +#define OFFS_R_LO 0x10u +#define OFFS_R_HI 0x14u + +/** + * Union to overlay a 64-bit double over two 32-bit words. + * w[0] = bits [31:0], w[1] = bits [63:32] (little-endian layout). + */ +typedef union +{ + double d; + uint32_t w[2]; +} double_u; + +/** + * double_multiply_c + * + * Reads two doubles from PRU Data RAM, multiplies them using the C '*' + * operator (which the PRU compiler converts to a __mpy2d library call), + * and writes the result back. + * + * For comparison, the equivalent optimised assembly (main.asm) uses four + * 32x32-bit hardware MAC operations to compute the same result in ~78 PRU + * cycles, whereas this software path typically takes 200+ cycles. + */ +static void double_multiply_c(void) +{ + double_u a, b, result; + + /* Load operands directly from PRU Data RAM base addresses */ + a.w[0] = *(volatile uint32_t *)OFFS_A_LO; + a.w[1] = *(volatile uint32_t *)OFFS_A_HI; + b.w[0] = *(volatile uint32_t *)OFFS_B_LO; + b.w[1] = *(volatile uint32_t *)OFFS_B_HI; + + /* + * C library (software FP) multiplication. + * The PRU has no hardware FPU, so the compiler calls __mpy2d from + * the C runtime library. math.h is not required for the '*' operator + * on doubles; it is handled by the compiler's runtime support. + */ + result.d = a.d * b.d; + + /* Store result back to PRU Data RAM */ + *(volatile uint32_t *)OFFS_R_LO = result.w[0]; + *(volatile uint32_t *)OFFS_R_HI = result.w[1]; +} + +int main(void) +{ + double_multiply_c(); + __halt(); +} diff --git a/examples/double_float/makefile b/examples/double_float/makefile new file mode 100644 index 000000000..8c837df20 --- /dev/null +++ b/examples/double_float/makefile @@ -0,0 +1,111 @@ +include ../../imports.mak + +####################### +# project information # +####################### + +PROJECT_NAME := double_float_multiply +SUPPORTED_PROCESSORS := am261x am263px am263x +# 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 +all: ARGUMENTS_PRU = all +all: ARGUMENTS_MCUPLUS = $(ARGUMENTS_PRU) +all: MESSAGE = "Building $(PROJECT_NAME) for $(DEVICE)" +all: pre_build_message $(DEVICE) $(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: 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 +am261x: +# am261x-lp + $(MAKE) -C firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) +# am261x-som + $(MAKE) -C firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +am263px: +# am263px-lp + $(MAKE) -C firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) +# am263px-cc + $(MAKE) -C firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +am263x: +# am263x-lp + $(MAKE) -C firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) +# am263x-cc + $(MAKE) -C firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +.PHONY: all clean pre_build_message $(DEVICE) $(DEVICE_NON_PRU) $(SUPPORTED_PROCESSORS) diff --git a/examples/double_float/readme.md b/examples/double_float/readme.md new file mode 100644 index 000000000..85c54a373 --- /dev/null +++ b/examples/double_float/readme.md @@ -0,0 +1,169 @@ +# Double Float Multiply (64-bit IEEE 754) using PRU MAC Hardware + +## Introduction + +This example implements IEEE 754 double-precision (64-bit) floating-point +multiplication entirely in PRU assembly, using the PRU's 32-bit MAC broadside +accelerator to compute the critical 53-bit × 53-bit significand product. It +demonstrates how hardware acceleration can replace the slow C-library software +floating-point path and provides a precise worst-case PRU cycle count. + +A companion C reference (`firmware/main_c_ref.c`) shows the equivalent code +that the C compiler produces, where the `*` operator on `double` values is +lowered to a call into the software FP runtime library (`__mpy2d`). + +## IEEE 754 Double-Precision Format + +``` +Bit 63 : sign (S) +Bits 62:52 : biased exponent (E, bias = 1023) +Bits 51:0 : mantissa fraction (M) +Value = (−1)^S × 2^(E−1023) × 1.M (normal numbers) +``` + +## Algorithm Overview + +Given two doubles A and B stored in PRU Data RAM: + +1. **Load** the 64-bit operands (two 32-bit words each) from PRU Data RAM. +2. **Sign**: `result_sign = sign_A XOR sign_B` +3. **Exponent**: `result_exp = exp_A + exp_B − 1023` +4. **Restore significands**: Re-insert the implicit leading 1 bit at position 52. + ``` + sigA_hi = (hi_A & 0xFFFFF) | 0x100000 (21-bit upper part) + sigA_lo = lo_A (32-bit lower part) + ``` +5. **Significand product** using four 32×32→64 MAC operations: + ``` + sigA = sigA_hi:sigA_lo (21-bit : 32-bit) + sigB = sigB_hi:sigB_lo + + p00 = sigA_lo × sigB_lo contributes to product bits [63:0] + p01 = sigA_hi × sigB_lo contributes to product bits [95:32] + p10 = sigA_lo × sigB_hi contributes to product bits [95:32] + p11 = sigA_hi × sigB_hi contributes to product bits [127:64] + ``` + Partial products are summed on-the-fly into the 106-bit accumulator + `{pp3:pp2:pp1}` (product bits [105:32]) using `ADD`/`ADC` with + immediate carry propagation. `p00[31:0]` lies below the mantissa + field and is discarded. + +6. **Normalise**: Since sigA, sigB ∈ [2^52, 2^53), their product lies in + [2^104, 2^106). The leading 1 is therefore at product bit 104 or 105: + - bit 105 clear → mantissa = P[103:52], keep `result_exp` + - bit 105 set → mantissa = P[104:53], `result_exp += 1` + +7. **Pack and store**: Assemble `hi_result` and `lo_result` and write + the 64-bit result back to PRU Data RAM. + +## PRU Data RAM Memory Map + +| Offset | Content | +|--------|-------------------------------| +| 0x00 | Operand A – low word (bits 31:0) | +| 0x04 | Operand A – high word (bits 63:32) | +| 0x08 | Operand B – low word | +| 0x0C | Operand B – high word | +| 0x10 | Result – low word (written) | +| 0x14 | Result – high word (written) | + +## PRU MAC Broadside Accelerator + +The MAC unit (device ID 0) performs unsigned 32×32→64-bit multiplication in +hardware. In multiply-only mode: + +```asm +MOV r28, operand_1 ; load first operand (1 cycle) +MOV r29, operand_2 ; load second operand (1 cycle), triggers multiply +NOP ; 1-cycle result latency +XIN 0, &r26, 4 ; read result[31:0] (1 cycle) +XIN 0, &r27, 4 ; read result[63:32] (1 cycle) +``` + +**Cost per hardware multiply: 5 cycles.** Four multiplies are therefore +completed in 20 cycles, compared to a software 32×32 multiply which requires +many more instructions without hardware support. + +## Worst-Case PRU Cycle Count + +| Section | Cycles | +|-----------------------------------------------------|--------| +| Prologue: init + load + sign/exp + significand build | 28 | +| 4 × MAC with on-the-fly carry accumulation | 32 | +| Normalise branch (`QBBS`) | 1 | +| Normalise path (`do_shift`, worst case) | 9 | +| Round-to-nearest check + adjust (worst case) | 6 | +| Pack result | 4 | +| Store + `HALT` | 4 | +| **Total (worst case)** | **85** | + +**Maximum PRU cycle count: 85 cycles** + +At 200 MHz PRU clock → **425 ns** per double-precision multiply. + +> **Rounding mode:** The implementation uses *round to nearest, ties away from zero*. +> The guard bit is taken from the bit immediately below the 52-bit mantissa field +> (P[51] in the no-shift case, P[52] in the shift case). This matches IEEE 754 +> round-to-nearest behaviour for all inputs except exact half-way cases, which +> are extremely rare in practice. + +## Comparison with C Library + +| Implementation | Cycle count (worst case) | +|----------------------------------------|--------------------------| +| Assembly + MAC hardware (this example) | ~85 cycles | +| C library `__mpy2d` (software FP) | ~200+ cycles | + +The C compiler for PRU has no hardware FPU to target, so the `*` operator on +`double` values is compiled to a call to the `__mpy2d` runtime routine, which +performs a purely software multiplication. See `firmware/main_c_ref.c` for +the equivalent C source. + +## Register Map + +| Register | Role | +|----------|------| +| R0 | Scratch / temporary | +| R1 | Memory base address (0) | +| R2 | `lo_A` — operand A bits [31:0] | +| R3 | `hi_A` — operand A bits [63:32] | +| R4 | `lo_B` | +| R5 | `hi_B` | +| R6 | `sigA_lo` — lower 32 bits of significand A | +| R7 | `sigA_hi` — upper 21 bits of significand A | +| R8 | `sigB_lo` | +| R9 | `sigB_hi` | +| R10 | `expA` — 11-bit biased exponent of A | +| R11 | `expB` | +| R12 | `res_sign` — result sign | +| R13 | `res_exp` — result biased exponent | +| R22 | `pp1` — product bits [63:32] | +| R23 | `pp2` — product bits [95:64] | +| R24 | `pp3` — product bits [105:96] | +| R25 | MAC control register | +| R26 | MAC result low 32 bits | +| R27 | MAC result high 32 bits | +| R28 | MAC operand 1 | +| R29 | MAC operand 2 | + +## Special Cases + +This implementation handles **normal numbers only**. The following cases are +not handled in order to keep the focus on the MAC acceleration technique: + +- NaN (Not-a-Number) +- Infinity (±Inf) +- Denormalised (subnormal) numbers +- Zero (±0) + +For production use these cases should be detected and handled prior to the +main multiplication path. + +## 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 | examples/double_float |