Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate firmware examples to pru-gcc
The firmware examples have been moved to gnupru (https://github.com/dinuxbg/gnupru). The modifications done are: 1. header files - The register declarations for CT_CFG, CT_MBX and CT_INTC have been changed. 2. fimware : main - __R30 and __R31 are not available. Instead write_r30(), read_r30(), write_r31() and read_r31() have been used. 3. firmware: resource tables - modified according to the pru-gcc way of generating elf files. 4. Makefiles - Modified to use pru-gcc
- Loading branch information
1 parent
e4583a0
commit 6260772
Showing
24 changed files
with
482 additions
and
568 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,86 @@ | ||
# PRU_CGT environment variable must point to the TI PRU code gen tools directory. E.g.: | ||
#(Desktop Linux) export PRU_CGT=/path/to/pru/code/gen/tools/ti-cgt-pru_2.1.2 | ||
#(Windows) set PRU_CGT=C:/path/to/pru/code/gen/tools/ti-cgt-pru_2.1.2 | ||
#(ARM Linux*) export PRU_CGT=/usr/share/ti/cgt-pru | ||
# Copyright (c) 2015, Dimitar Dimitrov | ||
# All rights reserved. | ||
# | ||
# *ARM Linux also needs to create a symbolic link to the /usr/bin/ directory in | ||
# order to use the same Makefile | ||
#(ARM Linux) ln -s /usr/bin/ /usr/share/ti/cgt-pru/bin | ||
|
||
ifndef PRU_CGT | ||
define ERROR_BODY | ||
|
||
******************************************************************************* | ||
PRU_CGT environment variable is not set. Examples given: | ||
(Desktop Linux) export PRU_CGT=/path/to/pru/code/gen/tools/ti-cgt-pru_2.1.2 | ||
(Windows) set PRU_CGT=C:/path/to/pru/code/gen/tools/ti-cgt-pru_2.1.2 | ||
(ARM Linux*) export PRU_CGT=/usr/share/ti/cgt-pru | ||
|
||
*ARM Linux also needs to create a symbolic link to the /usr/bin/ directory in | ||
order to use the same Makefile | ||
(ARM Linux) ln -s /usr/bin/ /usr/share/ti/cgt-pru/bin | ||
******************************************************************************* | ||
|
||
endef | ||
$(error $(ERROR_BODY)) | ||
endif | ||
|
||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
CURRENT_DIR := $(notdir $(patsubst %/,%,$(dir $(MKFILE_PATH)))) | ||
PROJ_NAME=$(CURRENT_DIR) | ||
LINKER_COMMAND_FILE=./AM335x_PRU.cmd | ||
LIBS=--library=../../lib/rpmsg_lib.lib | ||
INCLUDE=--include_path=../../include --include_path=../../include/am335x | ||
STACK_SIZE=0x100 | ||
HEAP_SIZE=0x100 | ||
GEN_DIR=gen | ||
|
||
#Common compiler and linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) | ||
CFLAGS=-v3 -O2 --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) -ppd -ppa | ||
#Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) | ||
LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) | ||
|
||
TARGET=$(GEN_DIR)/$(PROJ_NAME).out | ||
MAP=$(GEN_DIR)/$(PROJ_NAME).map | ||
SOURCES=$(wildcard *.c) | ||
#Using .object instead of .obj in order to not conflict with the CCS build process | ||
OBJECTS=$(patsubst %,$(GEN_DIR)/%,$(SOURCES:.c=.object)) | ||
|
||
all: printStart $(TARGET) printEnd | ||
|
||
printStart: | ||
@echo '' | ||
@echo '************************************************************' | ||
@echo 'Building project: $(PROJ_NAME)' | ||
|
||
printEnd: | ||
@echo '' | ||
@echo 'Output files can be found in the "$(GEN_DIR)" directory' | ||
@echo '' | ||
@echo 'Finished building project: $(PROJ_NAME)' | ||
@echo '************************************************************' | ||
@echo '' | ||
|
||
# Invokes the linker (-z flag) to make the .out file | ||
$(TARGET): $(OBJECTS) $(LINKER_COMMAND_FILE) | ||
@echo '' | ||
@echo 'Building target: $@' | ||
@echo 'Invoking: PRU Linker' | ||
$(PRU_CGT)/bin/clpru $(CFLAGS) -z -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $(TARGET) $(OBJECTS) -m$(MAP) $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) | ||
@echo 'Finished building target: $@' | ||
|
||
# Invokes the compiler on all c files in the directory to create the object files | ||
$(GEN_DIR)/%.object: %.c | ||
@mkdir -p $(GEN_DIR) | ||
@echo '' | ||
@echo 'Building file: $<' | ||
@echo 'Invoking: PRU Compiler' | ||
$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< | ||
|
||
.PHONY: all clean | ||
|
||
# Remove the $(GEN_DIR) directory | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in | ||
# the documentation and/or other materials provided with the | ||
# distribution. | ||
# * Neither the name of the copyright holders nor the names of | ||
# contributors may be used to endorse or promote products derived | ||
# from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# Very simple makefile to cross-compile for PRU | ||
|
||
|
||
# Common flags | ||
CROSS_COMPILE ?= pru- | ||
CFLAGS += -g -Os | ||
CFLAGS += -Wall -Wextra | ||
|
||
# Headers needed by the TI rpmsg library. | ||
CFLAGS += -I../../include -I../../include/am335x | ||
|
||
# Define this to squeeze code size by removing atexit, exit, constructors | ||
# and destructors from CRT. | ||
CFLAGS += -minrt | ||
|
||
# Per-PRU core flags. The -mmcu option will select the correct linker | ||
# script and will predefine mcu-specific macros. | ||
CFLAGS0 += -mmcu=am335x.pru0 | ||
CFLAGS1 += -mmcu=am335x.pru1 | ||
|
||
# List of source files to compile for each PRU core. | ||
SRC0 := | ||
SRC1 := PRU_gpioToggle.c | ||
|
||
# GCC's -MMD does not yield the needed C dependencies when compiling all | ||
# C source files at once. So manually list headers here. | ||
HEADERS := $(wildcard *.h) $(wildcard ../include/*.h ../include/am335x/*.h) | ||
|
||
# Where to output compiled objects | ||
OUT := gen | ||
|
||
# Final ELF image file names | ||
ELF0 := | ||
ELF1 := $(OUT)/blinky.elf | ||
|
||
# ============================ DO NOT TOUCH BELOW ============================ | ||
all: $(ELF0) $(ELF1) | ||
@echo Success: $^ | ||
|
||
%.s : %.elf | ||
$(CROSS_COMPILE)objdump -S -d $< > $@ | ||
|
||
$(OUT): | ||
mkdir $(OUT) | ||
|
||
$(ELF0): $(SRC0) $(HEADERS) | $(OUT) | ||
$(CROSS_COMPILE)gcc $(CFLAGS) $(CFLAGS0) $(SRC0) $(LDFLAGS) -o $@ | ||
|
||
$(ELF1): $(SRC1) $(HEADERS) | $(OUT) | ||
$(CROSS_COMPILE)gcc $(CFLAGS) $(CFLAGS1) $(SRC1) $(LDFLAGS) -o $@ | ||
|
||
clean: | ||
@echo '' | ||
@echo '************************************************************' | ||
@echo 'Cleaning project: $(PROJ_NAME)' | ||
@echo '' | ||
@echo 'Removing files in the "$(GEN_DIR)" directory' | ||
@rm -rf $(GEN_DIR) | ||
@echo '' | ||
@echo 'Finished cleaning project: $(PROJ_NAME)' | ||
@echo '************************************************************' | ||
@echo '' | ||
|
||
# Includes the dependencies that the compiler creates (-ppd and -ppa flags) | ||
-include $(OBJECTS:%.object=%.pp) | ||
$(RM) -fr $(ELF0) $(ELF1) $(OUT) | ||
|
||
cscope: | ||
cscope -bRk | ||
|
||
.PHONY: all clean cscope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.