Adding Linux build support

Added Makefile , linker file (.lds) , comment semi hosting function from psu.cfg file to facilitate debugging in linux mode
This commit is contained in:
Joshua Jeyaraj
2018-12-21 15:17:37 +05:30
parent f2d5bb8c3e
commit e8c696a126
4 changed files with 257 additions and 3 deletions

123
firmware/psu/Makefile Normal file
View File

@@ -0,0 +1,123 @@
#
# Main makefile for OCWare.
#
######################
# Set proper path.
######################
OCWARE_DIR ?=$(HOME)/PSU_host/OCWare/PSU
TIRTOS_DIR ?= $(HOME)/ti/tirtos_tivac_2_16_01_14
XDCTOOLS_DIR ?= $(HOME)/ti/xdctools_3_32_00_06_core
#TOOLCHAIN ?= /usr
TOOLCHAIN ?= /usr/gcc-arm-none-eabi-7-2018-q2-update
#######################
# Do not change anything below this.
#######################
OUT=bld
BIOS_DIR=$(TIRTOS_DIR)/products/bios_6_45_02_31
TIVAWARE_DIR=$(TIRTOS_DIR)/products/TivaWare_C_Series-2.1.1.71b
UIA_DIR=$(TIRTOS_DIR)/products/uia_2_00_05_50
TIRTOS_DRIVER_DIR=$(TIRTOS_DIR)/products/tidrivers_tivac_2_16_01_13
NDK_PATH = $(TIRTOS_DIR)/products/ndk_2_25_00_09/packages
NDK_INC = $(TIRTOS_DIR)/products/ndk_2_25_00_09/packages/ti/ndk/inc/bsd
BIOS_PATH=$(BIOS_DIR)/packages/ti/sysbios/posix
UIA_PATH_PATH=$(UIA_DIR)/packages
TIDRIVER_PATH=$(TIRTOS_DRIVER_DIR)/packages
XDC_PATH=$(XDCTOOLS_DIR)/packages
XDCPATH_LIST = \
$(TIRTOS_DIR)/packages \
$(TIRTOS_DRIVER_DIR)/packages \
$(BIOS_DIR)/packages \
$(NDK_PATH) \
$(UIA_DIR)/packages
TARGET = gnu.targets.arm.M4F
PLATFORM = ti.platforms.tiva:TM4C1230E6PM
PART=TM4C1230E6PM
ROV_XS_SUFFIX = pm4fg
CONFIG=psu
CONFIGURO_OPTS = -v -o $(OUT)/$(CONFIG)
empty:=
space:= $(empty) $(empty)
XDCPATH = $(subst $(space),;,$(XDCPATH_LIST))
CONFIGURO = $(XDCTOOLS_DIR)/xs --xdcpath="$(XDCPATH)" \
xdc.tools.configuro $(CONFIGURO_OPTS)
# Find all C source/object files.
SRC_FILE = $(shell find . -name '*.c' ! -path './test/*' ! -path './$(OUT)*')
MAIN_OBJS = $(SRC_FILE:.c=.o)
COVERAGE_OBJS = $(SRC_FILE:.c=.gcno)
CC = $(TOOLCHAIN)/bin/arm-none-eabi-gcc
CFLAGS = -Wall -mcpu=cortex-m4 -mthumb -mabi=aapcs -mapcs-frame @$(OUT)/$(CONFIG)/compiler.opt
CFLAGS += -std=c99 -ffunction-sections -fdata-sections
CFLAGS += -DTIVAWARE -DPART_$(PART) -Dgcc
CFLAGS += -I$(OCWARE_DIR)/src/ -I$(OCWARE_DIR)/common/ -I$(OCWARE_DIR)/
CFLAGS += -isystem$(XDC_PATH) -isystem$(BIOS_PATH) -isystem$(TIDRIVER_PATH) -isystem$(NDK_INC) -isystem$(TIVAWARE_DIR)
LD = $(TOOLCHAIN)/bin/arm-none-eabi-gcc
LFLAGS = -nostartfiles -static -Wl,--gc-sections -march=armv7e-m -Wl,-T,TM4C1230E6PM.lds -O3
LFLAGS += --specs=nosys.specs --specs=nano.specs -mfloat-abi=hard -mfpu=fpv4-sp-d16
LFLAGS += -Wl,--print-memory-usage #Optional
LFLAGS += -Xlinker -Map=$(OUT)/main.map #Optional
LLIBS = -L$(TIVAWARE_DIR)/driverlib/gcc/
LLIBS += -L$(TIVAWARE_DIR)/grlib/gcc/
LLIBS += -L$(TIVAWARE_DIR)/usblib/gcc/
LLIBS += -Wl,-T,$(OUT)/$(CONFIG)/linker.cmd
LLIBS += -Wl,--start-group
LLIBS += -ldriver -lgr -lusb -lm -lnosys -lc
LLIBS += -Wl,--end-group
.PRECIOUS: $(OUT)%/compiler.opt $(OUT)%/linker.cmd
OBJCOPY = $(TOOLCHAIN)/bin/arm-none-eabi-objcopy
ALL_FILE = $(shell find . -name '*.c' -o -name '*.h')
LINT = clang-format
LINT_FLAGS = -i -style=file -fallback-style=none
.PRECIOUS: %/compiler.opt %/linker.cmd
all: oc_connect1
oc_connect1: $(OUT)/PSU.bin
$(OUT)/%/compiler.opt $(OUT)/%/linker.cmd : %.cfg
$(CONFIGURO) -c $(TOOLCHAIN) -t $(TARGET) -p $(PLATFORM) -r debug $<
cp $(OUT)/$(CONFIG)/package/cfg/$*_$(ROV_XS_SUFFIX).rov.xs .
$(MAIN_OBJS): %.o: %.c $(OUT)/$(CONFIG)/compiler.opt
$(CC) $(CFLAGS) -c $< -o $@
$(OUT)/PSU.out: $(OUT)/$(CONFIG)/linker.cmd $(MAIN_OBJS)
$(LD) $(LFLAGS) -o $@ $(MAIN_OBJS) $(LLIBS)
$(OUT)/PSU.bin: $(OUT)/PSU.out
$(OBJCOPY) -S -O binary $< $@
lint:
$(LINT) $(LINT_FLAGS) $(ALL_FILE)
clean:
-rm -rf *.o *.out *.d *.rov.xs $(OUT) $(MAIN_OBJS) $(COVERAGE_OBJS)
test:
cd test && $(MAKE) $(TESTFLAGS)
ci: TESTFLAGS = ci
ci: CFLAGS += -ftest-coverage
ci: all test
.PHONY: all oc_connect1 clean test
# Include the automatically generated dependency files.
#
ifneq (${MAKECMDGOALS}, clean)
-include ${wildcard *.d} __dummy__
endif

View File

@@ -0,0 +1,130 @@
/*
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
MEMORY
{
FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x00020000
SRAM (WX) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}
REGION_ALIAS("REGION_TEXT", FLASH);
REGION_ALIAS("REGION_BSS", SRAM);
REGION_ALIAS("REGION_DATA", SRAM);
REGION_ALIAS("REGION_STACK", SRAM);
REGION_ALIAS("REGION_HEAP", SRAM);
REGION_ALIAS("REGION_ARM_EXIDX", FLASH);
REGION_ALIAS("REGION_ARM_EXTAB", FLASH);
SECTIONS {
PROVIDE (_intvecs_base_address = 0x0);
.intvecs (_intvecs_base_address) : AT (_intvecs_base_address) {
KEEP (*(.intvecs))
} > REGION_TEXT
PROVIDE (_vtable_base_address = 0x20000000);
.vtable (_vtable_base_address) (NOLOAD) : AT (_vtable_base_address) {
KEEP (*(.vtable))
} > REGION_DATA
.text : {
CREATE_OBJECT_SYMBOLS
*(.text)
*(.text.*)
. = ALIGN(0x4);
KEEP (*(.ctors))
. = ALIGN(0x4);
KEEP (*(.dtors))
. = ALIGN(0x4);
__init_array_start = .;
KEEP (*(.init_array*))
__init_array_end = .;
*(.init)
*(.fini*)
} > REGION_TEXT
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : {
*(.rodata)
*(.rodata*)
} > REGION_TEXT
.data : ALIGN (4) {
__data_load__ = LOADADDR (.data);
__data_start__ = .;
*(.data)
*(.data*)
. = ALIGN (4);
__data_end__ = .;
} > REGION_DATA AT> REGION_TEXT
.ARM.exidx : {
__exidx_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
__exidx_end = .;
} > REGION_ARM_EXIDX
.ARM.extab : {
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > REGION_ARM_EXTAB
.bss : {
__bss_start__ = .;
*(.shbss)
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN (4);
__bss_end__ = .;
} > REGION_BSS
.heap : {
__heap_start__ = .;
end = __heap_start__;
_end = end;
__end = end;
KEEP(*(.heap))
__heap_end__ = .;
__HeapLimit = __heap_end__;
} > REGION_HEAP
.stack (NOLOAD) : ALIGN(0x8) {
_stack = .;
__stack = .;
KEEP(*(.stack))
} > REGION_STACK
}

View File

@@ -307,7 +307,7 @@ if (!Program.build.target.$name.match(/iar/)) {
* Enable Semihosting for GNU targets to print to CCS console
*/
if (Program.build.target.$name.match(/gnu/)) {
var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
//var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
}
/* ================ Semaphore configuration ================ */
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
@@ -554,4 +554,4 @@ Program.global.m3Hwi1 = m3Hwi.create(60, "&uDMAIntHandler", m3Hwi1Params);
m3Hwi2Params.instance.name = "m3Hwi2";
m3Hwi2Params.enableInt = false;
Program.global.m3Hwi2 = m3Hwi.create(61, "&uDMAErrorHandler", m3Hwi2Params);
/* ================ Application Specific Instances ================ */
/* ================ Application Specific Instances ================ */

View File

@@ -52,12 +52,13 @@ static void exit_handler(int unused)
SysCtlReset();
}
extern void initialise_monitor_handles(void);
/*Main Function */
int main(void)
{
/* Install an exit handler to catch if we fault out */
// OcGpio_Pin pin_watchdog = { &ec_io, OC_EC_WD_INPUT };
System_atexit(exit_handler);
openCellular_init();
/* Call board init functions */