Newer
Older
Birte Kristina Friesel
committed
# vim:ft=make
#
# Copyright 2020 Daniel Friesel
#
# SPDX-License-Identifier: BSD-2-Clause
Birte Kristina Friesel
committed
CPU = 430x
MCU = msp430fr5969
DEBUG_PORT ?= ttyACM0
SERIAL_PORT ?= ttyACM1
MSP430_FLASHER_DIR ?= /opt/msp430/MSP430Flasher_1.3.20
INCLUDES += -I/opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/include
COMMON_FLAGS += -mcpu=${CPU} -mmcu=${MCU} -DMULTIPASS_ARCH_msp430fr5969lp
Birte Kristina Friesel
committed
# LTO seems to be broken.
CC = /opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/bin/msp430-elf-gcc
CXX = /opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/bin/msp430-elf-g++
OBJCOPY = /opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/bin/msp430-elf-objcopy
OBJDUMP = /opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/bin/msp430-elf-objdump
SIZE = /opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/bin/msp430-elf-size
GDB = /opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/bin/msp430-elf-gdb
GDBA = /opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/bin/gdb_agent_console
Birte Kristina Friesel
committed
CXX_TARGETS += src/arch/msp430fr5969lp/arch.cc
CXX_TARGETS += src/arch/msp430fr5969lp/driver/gpio.cc
CXX_TARGETS += src/arch/msp430fr5969lp/driver/stdout.cc
CXX = ag++ -r build/repo.acp -v 0 --c_compiler /opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/bin/msp430-elf-g++ -p . --Xcompiler
ifneq ($(findstring adc,${arch_drivers}), )
CONFIG_arch_msp430fr5969lp_driver_adc = y
ifneq ($(findstring stdin,${arch_drivers}), )
CONFIG_arch_msp430fr5969lp_driver_stdin = y
endif
ifneq ($(findstring softi2c,${drivers}), )
else ifneq ($(findstring i2c,${arch_drivers}), )
CONFIG_arch_msp430fr5969lp_driver_i2c = y
endif
ifneq ($(findstring spi,${arch_drivers}), )
CONFIG_arch_msp430fr5969lp_driver_spi = y
endif
ifneq ($(findstring timer,${arch_drivers}), )
CONFIG_arch_msp430fr5969lp_driver_timer = y
endif
ifneq ($(findstring counter,${arch_drivers}), )
CONFIG_arch_msp430fr5969lp_driver_counter = y
endif
ifeq (${timer_s}, 1)
CONFIG_arch_msp430fr5969lp_driver_uptime = y
endif
# Kconfig
ifdef CONFIG_arch_msp430fr5969lp_driver_adc
CXX_TARGETS += src/arch/msp430fr5969lp/driver/adc.cc
endif
ifdef CONFIG_arch_msp430fr5969lp_driver_dmx
CXX_TARGETS += src/arch/msp430fr5969lp/driver/dmx.cc
endif
ifdef CONFIG_arch_msp430fr5969lp_driver_stdin
CXX_TARGETS += src/arch/msp430fr5969lp/driver/stdin.cc
endif
ifdef CONFIG_arch_msp430fr5969lp_driver_i2c
CXX_TARGETS += src/arch/msp430fr5969lp/driver/i2c.cc
COMMON_FLAGS += -DDRIVER_I2C
ifdef CONFIG_arch_msp430fr5969lp_driver_spi
CXX_TARGETS += src/arch/msp430fr5969lp/driver/spi.cc
Birte Kristina Friesel
committed
ifdef CONFIG_arch_msp430fr5969lp_driver_timer
CXX_TARGETS += src/arch/msp430fr5969lp/driver/timer.cc
ifdef CONFIG_arch_msp430fr5969lp_driver_counter
CXX_TARGETS += src/arch/msp430fr5969lp/driver/counter.cc
endif
ifdef CONFIG_arch_msp430fr5969lp_driver_uptime
COMMON_FLAGS += -DTIMER_S
CXX_TARGETS += src/arch/msp430fr5969lp/driver/uptime.cc
endif
ifneq (${cpu_freq}, )
COMMON_FLAGS += -DF_CPU=${cpu_freq}UL
else
COMMON_FLAGS += -DF_CPU=16000000UL
endif
OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o} ${ASM_TARGETS:.S=.o}
Birte Kristina Friesel
committed
%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
Birte Kristina Friesel
committed
%.o : %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
%.o : %.S | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} -Wa,-gstabs,-ggdb -x assembler-with-cpp -c -o $@ ${@:.o=.S}
Birte Kristina Friesel
committed
build/system.elf: ${OBJECTS}
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} \
-Wl,--library-path=/opt/msp430/ti/msp430-gcc-full-linux-5.1.2.0/include/ \
-Wl,--gc-sections \
-o $@ ${OBJECTS}
${QUIET}${SIZE} build/system.elf | tail -n1 | awk '{ print " ROM: " int(($$1+$$2)*100/49152) "% RAM: " int(($$2+$$3)*100/2048) "%" }'
Birte Kristina Friesel
committed
build/system.hex: build/system.elf
${QUIET}${OBJCOPY} -O ihex ${@:.hex=.elf} $@
Birte Kristina Friesel
committed
program: build/system.hex
${QUIET}LD_LIBRARY_PATH=${MSP430_FLASHER_DIR} \
${MSP430_FLASHER_DIR}/MSP430Flasher \
-i ${DEBUG_PORT} \
Birte Kristina Friesel
committed
-w build/system.hex -v -g -z '[VCC]'
arch_clean:
${QUIET}rm -f ${OBJECTS} build/system.hex
Birte Kristina Friesel
committed
${QUIET}screen /dev/${SERIAL_PORT} ${uart_freq}
@echo "msp430fr5969lp specific flags:"
@echo " DEBUG_PORT = ${DEBUG_PORT}"
@echo " SERIAL_PORT = ${SERIAL_PORT}"
@echo " cpu_freq = ${cpu_freq} (desired CPU frequency in Hz)"
@echo " supported frequencies: 1 / 4 / 8 / 16 MHz"
@echo " MSP430_FLASHER_DIR = /home/derf/var/projects/msp430/MSP430Flasher_1.3.20"
@echo " (required for flashing, must contain libmsp430.so and MSP430Flasher)"
arch_info:
@echo "CPU Freq: ${cpu_freq} Hz"
@echo "Timer Freq: ${timer_freq} Hz -> $(shell src/arch/msp430fr5969lp/model.py f_timer "${cpu_freq}" "${timer_freq}")"
@echo "I2C Freq: ${i2c_freq} Hz"
@echo "Counter Overflow: 65536/255"
@echo "sleep_ms Overflow: 250 500"
@echo "Monitor: /dev/${SERIAL_PORT} ${uart_freq}"
attributes: build/system.elf
${QUIET}script/size.py ${SIZE} text,data data,bss
nfpvalues: build/system.elf
${QUIET}script/nfpvalues.py ${SIZE} text,data data,bss
.PHONY: arch_clean arch_help arch_info attributes monitor program