initial revision
[ucgine.git] / examples / spi-flash / Makefile
1 #
2 # Copyright 2015, Olivier MATZ <zer0@droids-corp.org>
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
6 #
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.
15 #
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.
26
27 # XXX
28 STLINK ?= /home/zer0/projects/stm32/stlink
29 UCGINE ?= /home/zer0/projects/ucgine
30 STM_COMMON ?= /home/zer0/projects/stm32/stm32_discovery_arm_gcc/STM32F4-Discovery_FW_V1.1.0
31
32 O ?= $(CURDIR)/build
33 PROG = $(O)/spi-flash
34
35 CROSS = arm-none-eabi-
36
37 CFLAGS  = -g -O2 -Wall -Tstm32_flash.ld
38 CFLAGS += -DUSE_STDPERIPH_DRIVER
39 CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
40 CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
41 CFLAGS += -I.
42 CFLAGS += -I$(UCGINE)/arch/stm32/include
43
44 # Include files from STM libraries
45 CFLAGS += -I$(STM_COMMON)/Utilities/STM32F4-Discovery
46 CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/Include
47 CFLAGS += -I$(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Include
48 CFLAGS += -I$(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/inc
49
50 CFLAGS += -I$(UCGINE)/lib/gloss/include
51
52 LDFLAGS  = -Tstm32_flash.ld --specs=rdimon.specs -lc
53 LDFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
54 LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
55
56 # local files
57 exe-y-$(PROG) := main.c uart.c system_stm32f4xx.c
58 # stm32 standard periph lib
59 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c
60 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
61 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
62 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c
63 exe-y-$(PROG) += $(STM_COMMON)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c
64 # startup file
65 exe-y-$(PROG) += $(STM_COMMON)/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f4xx.s
66 # gloss
67 exe-y-$(PROG) += $(UCGINE)/lib/gloss/ucg_gloss_stubs.c
68 exe-y-$(PROG) += $(UCGINE)/lib/gloss/ucg_gloss_chardev.c
69
70 objcopy-hex-y-$(PROG).hex := $(PROG)
71 objcopy-bin-y-$(PROG).bin := $(PROG)
72
73 include $(UCGINE)/mk/ucgine.mk
74
75 .PHONY: all
76 all: $(all-targets)
77
78 .PHONY: clean
79 clean: _ucgine_clean
80
81 # Flash the STM32F4
82 .PHONY: burn
83 burn: all
84         $(STLINK)/st-flash write $(PROG).bin 0x8000000