2024-06-15 23:22:31 +02:00

71 lines
2.3 KiB
Bash

#/bin/sh
CUR_DIR=$(pwd)
# config
DEVICE=MSP430G2553
OUT_DIR=$CUR_DIR/out
MAIN_FILE=$CUR_DIR/main.c
# GCC directorys
GCC_DIR=$HOME/ti/gcc
GCC_BIN_DIR=$GCC_DIR/bin
GCC_ELF_INC=$GCC_DIR/msp430-elf/include
GCC_MSP_INC=$GCC_DIR/include
GCC_LD=$GCC_MSP_INC/$(echo $DEVICE | tr A-Z a-z).ld
# comands
CC=$GCC_BIN_DIR/msp430-elf-gcc
# optionsh
# -O optimizer; -O0: no optimization, -O1: level 1, -O2: level 2, -O3: level 3, -Os: size, -Ofast: speed, -OG: debug experiance
# -D <name>[=<value>] define; <name>: the name of the defination, <value>: the value for de definition defaults to 1
# -mmcu=<muc> muc name
# -g add debug information for GDB
# -ffunction-sections a specific optimisation thing
# -fdata-sections a specific optimisation thing
# -T <file> add linker script (dl file)
# -L <dir> add source directory for libraries(-l<lib> serches for a librarie)
# -Wl,--gc-sections enable that specific optimisation thing mansiont by -ffunction-sections and -fdata-sections
# -I <dir> adds directory to the search list for header files
# original cmd
# -Os -mmcu=${DEVICE} -g -ffunction-sections -fdata-sections -D __${DEVICE}__ -D DEPRECATED
# my version
# -Og -mmcu=${DEVICE} -g -D __${DEVICE}__
# original cmd
# -T ${GCC_LD} -L ${GCC_MSP_INC} -mmcu=${DEVICE} -g -Wl,--gc-sections
# my version
# -T ${GCC_LD} -L ${GCC_MSP_INC} -mmcu=${DEVICE} -g
# my complete version
# -Og -mmcu=${DEVICE} -g -D__${DEVICE}__ -T ${GCC_LD} -L ${GCC_MSP_INC} -I ${GCC_MSP_INC} -I ${GCC_ELF_INC}
MYFLAGS="-Og -mmcu=${DEVICE} -g -D__${DEVICE}__ -T ${GCC_LD} -L ${GCC_MSP_INC} -I ${GCC_MSP_INC} -I ${GCC_ELF_INC}"
CFLAGS="-Os -D__${DEVICE}__ -mmcu=${DEVICE} -g -ffunction-sections -fdata-sections -DDEPRECATED"
LDFLAGS="-T ${GCC_LD} -L ${GCC_MSP_INC} -mmcu=${DEVICE} -g -Wl,--gc-sections"
INCLUDES="-I ${GCC_MSP_INC} -I ${GCC_ELF_INC}"
# files
EXOBJECT=$OUT_DIR/$DEVICE.elf.o
EXOUTPUT=$OUT_DIR/$DEVICE.elf.out
function execute(){
echo
echo ==========================
echo execute\> $*
$*
}
execute mkdir -p $OUT_DIR
execute $CC $MYFLAGS $MAIN_FILE -o $EXOUTPUT
# execute $CC $INCLUDES $CFLAGS -c $MAIN_FILE -o $EXOBJECT
# execute $CC $LDFLAGS $EXOBJECT -o $EXOUTPUT
# execute mspdebug rf2500 "prog ${EXOUTPUT}"
# execute mspdebug rf2500 "run"