-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
152 lines (123 loc) · 4.37 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
top_srcdir = ../../../..
CROSS_STM32W=1
OPT= -Os -ffunction-sections -fdata-sections
include $(top_srcdir)/Makefile.top
#-------------- No changes above this line, please ---------------------------
EXTRA_MRPROPER+= *.a *.o *.hex
LDSCRIPT = -T$(top_srcdir)/stm32/lib/linker/sections-nokeep.ld
GEN_DEPENDS = 0
#VERSION=$(shell git log . |head -1|awk '{print $$2}')
# Esta generacion de versiones necesita una vuelta de tuerca mas,
# ya que un commit relacionado con el Master o la RPi nos incrementaria la version
# talvez deberiamos filtrar solo los que afecten a los archivos de la aplicacion estricamente?
MAJOR_VERSION=1000
REVISION=$(shell git rev-list HEAD | wc -l)
VERSION=$$(( $(MAJOR_VERSION) + $(REVISION) ))
NODE_CONFIG_MASK=$(shell printf "0xFF%06X" $(VERSION))
CFLAGS+=-DVERSION="\"$(VERSION)\""
CFLAGS += -Wno-aggressive-loop-optimizations
####### Mandatory label:
TARGETS = $(ARCH)simpleApp $(ARCH)bootloader $(ARCH)masterApp
BINARY_BOOTLOADER = $(ARCH)bootloader.axf
BINARY_APPLICATION = $(ARCH)simpleApp.axf
BINARY_MASTER = $(ARCH)masterApp.axf
#### Mandatory label:
OBJS= \
$(ARCH)m2c_defs.o \
$(ARCH)led.o \
$(ARCH)stm32w108xx_it.o \
# do not delete this line
EXTRA_OBJS+= \
# do not delete this line
#CFLAGS+= -Werror
#CFLAGS+= -DCORTEXM3_STM32W108=1
#DLIBS+= $(DLIBDIR)/stm32w108xx_stdPeriph.a $(DLIBDIR)/simplemac-library.a
#CFLAGS+= $(LIBLSI_CFLAGS) $(GLIB_CFLAGS) -I$(top_srcdir)/libawd
#LDLIBS+= $(GLIB_LIBS) $(top_srcdir)/libawd/$(ARCH)libawd.a
#LDFLAGS+= -lc
.PHONY: sniffer clean_gdb
all: $(TARGETS) version
#EXTRA_CLEAN += $(TARGETS:%=%.o) $(ARCH)libaldomo.a config.sql
#EXTRA_MRPROPER += $(ARCH)aldomo-sniffer
clean_gdb:
$(TARGETS) : % : $(OBJS) %.o
$(CC) -o [email protected] $^ $(EXTRA_OBJS) [email protected] $(LDFLAGS) $(LDLIBS)
$(SIZE) [email protected]
$(OBJCOPY) -O ihex [email protected] [email protected]
./generate-hex ./[email protected] > ./[email protected]
#BINARY := $(shell pwd)/$(BINARY)
read :
openocd \
-f interface/stlink-v2.cfg \
-f target/stm32w108_stlink.cfg \
-c "init" \
-c "reset halt" \
-c "sleep 100" \
-c "wait_halt 2" \
-c "dump_image test.dump 0x8005000 45056" \
-c "reset halt" \
-c "shutdown"
program_node program : $(BINARY_BOOTLOADER) $(BINARY_APPLICATION)
openocd \
-f interface/stlink-v2.cfg \
-f target/stm32w108_stlink.cfg \
-c "init" \
-c "reset halt" \
-c "sleep 100" \
-c "wait_halt 2" \
-c "flash write_image erase $(BINARY_APPLICATION)" \
-c "sleep 100" \
-c "verify_image $(BINARY_APPLICATION)" \
-c "flash write_image erase $(BINARY_BOOTLOADER)" \
-c "sleep 100" \
-c "verify_image $(BINARY_BOOTLOADER)" \
-c "sleep 100" \
-c "flash erase_address pad 0x800FC00 1" \
-c "flash fillw 0x800FC00 $(NODE_CONFIG_MASK) 1" \
-c "reset" \
-c "shutdown"
program_master master : $(BINARY_MASTER)
openocd \
-f interface/stlink-v2.cfg \
-f target/stm32w108_stlink.cfg \
-c "init" \
-c "reset halt" \
-c "sleep 100" \
-c "wait_halt 2" \
-c "flash write_image erase $(BINARY_MASTER)" \
-c "sleep 100" \
-c "verify_image $(BINARY_MASTER)" \
-c "sleep 100" \
-c "reset" \
-c "shutdown"
debug : $(BINARY)
openocd \
-f interface/stlink-v2.cfg \
-f target/stm32w108_stlink.cfg \
-c "init" \
-c "reset halt"
gdb_bl: $(BINARY)
arm-none-eabi-gdb $(BINARY_BOOTLOADER) \
--eval-command "target remote localhost:3333" \
--eval-command "load" \
--eval-command "monitor reset halt"
gdb_app: $(BINARY)
arm-none-eabi-gdb $(BINARY_APPLICATION) \
--eval-command "target remote localhost:3333" \
--eval-command "load" \
--eval-command "monitor reset halt"
gdb_master: $(BINARY)
arm-none-eabi-gdb $(BINARY_MASTER)\
--eval-command "target remote localhost:3333" \
--eval-command "load" \
--eval-command "monitor reset halt"
pi:
mv cortex-m3-simpleApp.hex image.hex
sshpass -p 'raspberry' scp image.hex pi-main.c image.ver pi@raspberrypi:~/sdg2/uart/
mv image.hex cortex-m3-simpleApp.hex
version:
echo $(VERSION) > image.ver
su: mrproper all program
#-------------- No changes below this line, please ---------------------------
#include $(top_srcdir)/stm32/Makefile.ocd
include $(top_srcdir)/Makefile.bottom