# # Copyright 2015, Olivier MATZ # # 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 University of California, Berkeley 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 REGENTS 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 REGENTS AND 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. UCGINE ?= $(abspath ../..) include $(UCGINE)/mk/ucgine-pre.mk O ?= $(CURDIR)/build PROG = $(O)/test-cmd CFLAGS += $(ARCH_CFLAGS) CFLAGS += -g -Werror -I. LDFLAGS += $(ARCH_LDFLAGS) # local files exe-y-$(PROG) := main.c commands.c uart.c ifeq ($(UCGINE_ARCH),avr) MCU = atmega328p F_CPU = 8000000UL AVRDUDE_PORT = /dev/ttyUSB0 AVRDUDE_PROG = arduino AVRDUDE_BAUD = 57600 CFLAGS += -DF_CPU=$(F_CPU) CFLAGS += -I$(UCGINE)/arch/avr/uart/include CFLAGS += -mmcu=$(MCU) CFLAGS += -DUCG_CMD_NO_PAGER LDFLAGS += -mmcu=$(MCU) # uart exe-y-$(PROG) += $(UCGINE)/arch/avr/uart/ucg_avr_uart.c endif ifeq ($(UCGINE_ARCH),stm32) STLINK ?= /home/zer0/projects/stm32/stlink STM_COMMON ?= /home/zer0/projects/stm32/stm32_discovery_arm_gcc/STM32F4-Discovery_FW_V1.1.0 CFLAGS += -Tstm32_flash.ld CFLAGS += -I$(STM_COMMON)/Utilities/STM32F4-Discovery CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/Include CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Include CFLAGS += -I$(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/inc CFLAGS += -I$(UCGINE)/lib/gloss/include CFLAGS += -I$(UCGINE)/arch/stm32/include CFLAGS += -I$(UCGINE)/arch/stm32/uart/include LDFLAGS += -Tstm32_flash.ld exe-y-$(PROG) += system_stm32f4xx.c # stm32 standard periph lib exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c # startup file exe-y-$(PROG) += $(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f4xx.s # gloss exe-y-$(PROG) += $(UCGINE)/lib/gloss/ucg_gloss_stubs.c exe-y-$(PROG) += $(UCGINE)/lib/gloss/ucg_gloss_chardev.c # uart exe-y-$(PROG) += $(UCGINE)/arch/stm32/uart/ucg_stm32_uart.c endif ifeq ($(UCGINE_ARCH),posix) CFLAGS += -DUCG_CMD_HAVE_SOCKET -DUCG_CMD_HAVE_TERMIOS endif # cirbuf CFLAGS += -I$(UCGINE)/lib/cirbuf/include exe-y-$(PROG) += $(UCGINE)/lib/cirbuf/ucg_cirbuf.c # uart CFLAGS += -I$(UCGINE)/lib/uart/include exe-y-$(PROG) += $(UCGINE)/lib/uart/ucg_uart.c # cmd CFLAGS += -I$(UCGINE)/lib/cmd/include exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd.c exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse.c ifeq ($(CROSS),) exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_etheraddr.c exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_file.c exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_ipaddr.c exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_socket.c endif exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_termios.c exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_num.c exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_string.c exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_rdline.c exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_vt100.c objcopy-hex-y-$(PROG).hex := $(PROG) objcopy-bin-y-$(PROG).bin := $(PROG) # XXX where to define the all target? include $(UCGINE)/mk/ucgine-post.mk .PHONY: all all: $(all-targets) $(CROSS)size $(PROG) .PHONY: clean clean: _ucgine_clean .PHONY: burn burn: all ifeq ($(UCGINE_ARCH),stm32) $(STLINK)/st-flash write $(PROG).bin 0x8000000 endif ifeq ($(UCGINE_ARCH),avr) avrdude -e -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROG) \ -b $(AVRDUDE_BAUD) -U flash:w:$(PROG):e endif