2 # Copyright 2015, Olivier MATZ <zer0@droids-corp.org>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12 # * Neither the name of the University of California, Berkeley nor the
13 # names of its contributors may be used to endorse or promote products
14 # derived from this software without specific prior written permission.
16 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 # DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 UCGINE ?= $(abspath ../..)
28 include $(UCGINE)/mk/ucgine-pre.mk
33 CFLAGS += $(ARCH_CFLAGS)
34 CFLAGS += -g -Werror -I.
36 LDFLAGS += $(ARCH_LDFLAGS)
39 exe-y-$(PROG) := main.c commands.c uart.c
41 ifeq ($(UCGINE_ARCH),avr)
44 AVRDUDE_PORT = /dev/ttyUSB0
45 AVRDUDE_PROG = arduino
47 CFLAGS += -DF_CPU=$(F_CPU)
48 CFLAGS += -I$(UCGINE)/arch/avr/uart/include
49 CFLAGS += -mmcu=$(MCU)
50 CFLAGS += -DUCG_CMD_NO_PAGER
51 LDFLAGS += -mmcu=$(MCU)
53 exe-y-$(PROG) += $(UCGINE)/arch/avr/uart/ucg_avr_uart.c
55 ifeq ($(UCGINE_ARCH),stm32)
56 STLINK ?= /home/zer0/projects/stm32/stlink
57 STM_COMMON ?= /home/zer0/projects/stm32/stm32_discovery_arm_gcc/STM32F4-Discovery_FW_V1.1.0
58 CFLAGS += -Tstm32_flash.ld
59 CFLAGS += -I$(STM_COMMON)/Utilities/STM32F4-Discovery
60 CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/Include
61 CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Include
62 CFLAGS += -I$(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/inc
63 CFLAGS += -I$(UCGINE)/lib/gloss/include
64 CFLAGS += -I$(UCGINE)/arch/stm32/include
65 CFLAGS += -I$(UCGINE)/arch/stm32/uart/include
66 LDFLAGS += -Tstm32_flash.ld
67 exe-y-$(PROG) += system_stm32f4xx.c
68 # stm32 standard periph lib
69 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c
70 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
71 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
72 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c
73 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c
75 exe-y-$(PROG) += $(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f4xx.s
77 exe-y-$(PROG) += $(UCGINE)/lib/gloss/ucg_gloss_stubs.c
78 exe-y-$(PROG) += $(UCGINE)/lib/gloss/ucg_gloss_chardev.c
80 exe-y-$(PROG) += $(UCGINE)/arch/stm32/uart/ucg_stm32_uart.c
82 ifeq ($(UCGINE_ARCH),posix)
83 CFLAGS += -DUCG_CMD_HAVE_SOCKET -DUCG_CMD_HAVE_TERMIOS
87 CFLAGS += -I$(UCGINE)/lib/cirbuf/include
88 exe-y-$(PROG) += $(UCGINE)/lib/cirbuf/ucg_cirbuf.c
90 CFLAGS += -I$(UCGINE)/lib/uart/include
91 exe-y-$(PROG) += $(UCGINE)/lib/uart/ucg_uart.c
93 CFLAGS += -I$(UCGINE)/lib/cmd/include
94 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd.c
95 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse.c
97 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_etheraddr.c
98 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_file.c
99 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_ipaddr.c
100 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_socket.c
102 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_termios.c
103 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_num.c
104 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_parse_string.c
105 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_rdline.c
106 exe-y-$(PROG) += $(UCGINE)/lib/cmd/ucg_cmd_vt100.c
108 objcopy-hex-y-$(PROG).hex := $(PROG)
109 objcopy-bin-y-$(PROG).bin := $(PROG)
111 # XXX where to define the all target?
112 include $(UCGINE)/mk/ucgine-post.mk
123 ifeq ($(UCGINE_ARCH),stm32)
124 $(STLINK)/st-flash write $(PROG).bin 0x8000000
126 ifeq ($(UCGINE_ARCH),avr)
127 avrdude -e -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROG) \
128 -b $(AVRDUDE_BAUD) -U flash:w:$(PROG):e