-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnomagic_probe.mk
241 lines (212 loc) · 8.19 KB
/
nomagic_probe.mk
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
NOMAGIC_SRC_FOLDER = $(NOMAGIC_FOLDER)src/
GITREF = $(shell cd $(NOMAGIC_FOLDER) && git describe --abbrev=40 --dirty --always --tags)
# COMPILER SWITCHES
# =================
# These switches enable or disable functionality
# use BOOT ROM (for flash functions,...)
ifeq ($(USE_BOOT_ROM), yes)
DDEFS += -DBOOT_ROM_ENABLED=1
endif
# enable USB Mass Storage (Thumb Drive)
ifeq ($(HAS_MSC), yes)
DDEFS += -DFEAT_USB_MSC
endif
# enable the command line interface for testing
ifeq ($(HAS_DEBUG_UART), yes)
DDEFS += -DFEAT_DEBUG_UART
endif
ifeq ($(HAS_DEBUG_CDC), yes)
DDEFS += -DFEAT_DEBUG_CDC
endif
# enable the gdb-server
ifeq ($(HAS_GDB_SERVER), yes)
DDEFS += -DFEAT_GDB_SERVER
endif
# enable the USB network interface
ifeq ($(HAS_NCM), yes)
DDEFS += -DFEAT_USB_NCM
LWIP_DIR = $(NOMAGIC_SRC_FOLDER)lwip/
endif
LKR_SCRIPT = $(NOMAGIC_SRC_FOLDER)hal/RP2040.ld
# Files to compile
# ================
# file handling
ifeq ($(HAS_MSC), yes)
SRC += $(NOMAGIC_SRC_FOLDER)file/fake_mbr.c
SRC += $(NOMAGIC_SRC_FOLDER)file/fake_boot_sector.c
SRC += $(NOMAGIC_SRC_FOLDER)file/fake_fat.c
SRC += $(NOMAGIC_SRC_FOLDER)file/fake_root_folder.c
SRC += $(NOMAGIC_SRC_FOLDER)file/fake_text_files.c
SRC += $(NOMAGIC_SRC_FOLDER)file/fake_favicon.c
SRC += $(NOMAGIC_SRC_FOLDER)file/fake_fs.c
SRC += $(NOMAGIC_SRC_FOLDER)file/file_storage.c
SRC += $(NOMAGIC_SRC_FOLDER)file/file_system.c
endif
# gdb server
ifeq ($(HAS_GDB_SERVER), yes)
SRC += $(NOMAGIC_SRC_FOLDER)gdbserver/cmd_qsupported.c
SRC += $(NOMAGIC_SRC_FOLDER)gdbserver/cmd_qxfer.c
SRC += $(NOMAGIC_SRC_FOLDER)gdbserver/commands.c
SRC += $(NOMAGIC_SRC_FOLDER)gdbserver/gdbserver.c
SRC += $(NOMAGIC_SRC_FOLDER)gdbserver/monitor_commands.c
SRC += $(NOMAGIC_SRC_FOLDER)gdbserver/threads.c
SRC += $(NOMAGIC_SRC_FOLDER)gdbserver/util.c
endif
# Hardware abstraction layer
ifeq ($(HAS_DEBUG_UART), yes)
SRC += $(NOMAGIC_SRC_FOLDER)hal/debug_uart.c
endif
SRC += $(NOMAGIC_SRC_FOLDER)hal/target_uart.c
SRC += $(NOMAGIC_SRC_FOLDER)hal/startup.c
SRC += $(NOMAGIC_SRC_FOLDER)hal/hw_divider.c
SRC += $(NOMAGIC_SRC_FOLDER)hal/watchdog.c
ifeq ($(USE_BOOT_ROM), yes)
SRC += $(NOMAGIC_SRC_FOLDER)hal/boot_rom.c
else
SRC += $(NOMAGIC_SRC_FOLDER)hal/qspi.c
endif
SRC += $(NOMAGIC_SRC_FOLDER)hal/flash.c
SRC += $(NOMAGIC_SRC_FOLDER)hal/time_base.c
SRC += $(NOMAGIC_SRC_FOLDER)hal/random.c
SRC += $(NOMAGIC_SRC_FOLDER)hal/swd_gpio.c
# command line interface (debug - UART0 / USB-CDC)
ifeq ($(HAS_CLI), yes)
SRC += $(NOMAGIC_SRC_FOLDER)cli/cli.c
SRC += $(NOMAGIC_SRC_FOLDER)cli/cli_memory.c
SRC += $(NOMAGIC_SRC_FOLDER)cli/cli_swd.c
SRC += $(NOMAGIC_SRC_FOLDER)cli/cli_sys.c
SRC += $(NOMAGIC_SRC_FOLDER)cli/cli_usb.c
endif
# functions usually available from standard libraries
SRC += $(NOMAGIC_SRC_FOLDER)lib/ctype.c
SRC += $(NOMAGIC_SRC_FOLDER)lib/atoi.c
SRC += $(NOMAGIC_SRC_FOLDER)lib/memcmp.c
SRC += $(NOMAGIC_SRC_FOLDER)lib/memcpy.c
SRC += $(NOMAGIC_SRC_FOLDER)lib/memmove.c
SRC += $(NOMAGIC_SRC_FOLDER)lib/memset.c
SRC += $(NOMAGIC_SRC_FOLDER)lib/printf.c
SRC += $(NOMAGIC_SRC_FOLDER)lib/strchr.c
SRC += $(NOMAGIC_SRC_FOLDER)lib/strlen.c
SRC += $(NOMAGIC_SRC_FOLDER)lib/strncmp.c
# configuration
ifeq ($(HAS_NCM), yes)
SRC += $(NOMAGIC_SRC_FOLDER)cfg/network_cfg.c
endif
SRC += $(NOMAGIC_SRC_FOLDER)cfg/serial_cfg.c
SRC += $(NOMAGIC_SRC_FOLDER)cfg/swd_cfg.c
SRC += $(NOMAGIC_SRC_FOLDER)cfg/config_file_reader.c
SRC += $(NOMAGIC_SRC_FOLDER)cfg/read_ini.c
# SWD
SRC += $(NOMAGIC_SRC_FOLDER)swd/swd_engine.c
SRC += $(NOMAGIC_SRC_FOLDER)swd/swd_protocol.c
SRC += $(NOMAGIC_SRC_FOLDER)swd/swd_packets.c
SRC += $(NOMAGIC_SRC_FOLDER)swd/swd_packet_bits.c
# USB driver
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/usb.c
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/usb_descriptors.c
# USB stack (tinyusb
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/src/tusb.c
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/src/device/usbd.c
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/src/device/usbd_control.c
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/src/common/tusb_fifo.c
# USB serial interface (CDC)
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/usb_cdc.c
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/src/class/cdc/cdc_device.c
# USB thumb drive (MSC)
ifeq ($(HAS_MSC), yes)
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/usb_msc.c
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/src/class/msc/msc_device.c
endif
# lwip + USB Network interface (NCM)
ifeq ($(HAS_NCM), yes)
SRC += $(NOMAGIC_SRC_FOLDER)lwip/lwip.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/dhcp_server.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/tcp_pipe.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/api/err.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/init.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/def.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/dns.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/inet_chksum.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ip.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/mem.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/memp.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/netif.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/pbuf.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/raw.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/stats.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/sys.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/altcp.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/altcp_alloc.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/altcp_tcp.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/tcp.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/tcp_in.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/tcp_out.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/timeouts.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/udp.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv4/acd.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv4/autoip.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv4/dhcp.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv4/etharp.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv4/icmp.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv4/igmp.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv4/ip4_frag.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv4/ip4.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv4/ip4_addr.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv6/dhcp6.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv6/ethip6.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv6/icmp6.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv6/inet6.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv6/ip6.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv6/ip6_addr.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv6/ip6_frag.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv6/mld6.c
#SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/core/ipv6/nd6.c
SRC += $(NOMAGIC_SRC_FOLDER)lwip/src/netif/ethernet.c
SRC += $(NOMAGIC_SRC_FOLDER)tinyusb/src/class/net/ncm_device.c
endif
# target
SRC += $(NOMAGIC_SRC_FOLDER)target/activity.c
SRC += $(NOMAGIC_SRC_FOLDER)target/common.c
SRC += $(NOMAGIC_SRC_FOLDER)target/common_actions.c
SRC += $(NOMAGIC_SRC_FOLDER)target/steps.c
SRC += $(NOMAGIC_SRC_FOLDER)target/target_uart_handler.c
# user feedback
SRC += $(NOMAGIC_SRC_FOLDER)led.c
# main
SRC += $(NOMAGIC_SRC_FOLDER)main.c
OBJS = $(addprefix $(BIN_FOLDER),$(SRC:.c=.o))
INCDIRS +=$(NOMAGIC_SRC_FOLDER)
INCDIRS +=$(BIN_FOLDER)
INCDIRS +=$(NOMAGIC_SRC_FOLDER)cfg/
INCDIRS +=$(NOMAGIC_SRC_FOLDER)lib/
INCDIRS +=$(NOMAGIC_SRC_FOLDER)tinyusb/src/
ifeq ($(HAS_NCM), yes)
INCDIRS +=$(NOMAGIC_SRC_FOLDER)lwip/
#LWIP_INCLUDE_DIRS
INCDIRS +=$(NOMAGIC_SRC_FOLDER)lwip/src/include/
INCDIRS +=$(NOMAGIC_SRC_FOLDER)lwip/contrib/
endif
INCDIR = $(patsubst %,-I%, $(INCDIRS))
$(BIN_FOLDER)version.h:
@echo ""
@echo "create version.h"
@echo "================"
@echo -n "#define VERSION \"$(PROBE_NAME)" > $(BIN_FOLDER)version.h
@cat $(NOMAGIC_FOLDER)version.txt >> $(BIN_FOLDER)version.h
@echo " $(GITREF)\"" >> $(BIN_FOLDER)version.h
@cat $(BIN_FOLDER)version.h
$(BIN_FOLDER)$(NOMAGIC_SRC_FOLDER)cli/cli.o: $(NOMAGIC_SRC_FOLDER)cli/cli.c $(BIN_FOLDER)version.h
@echo ""
@echo "=== compiling (cli) $@"
@$(MKDIR_P) $(@D)
$(CC) $(CFLAGS) $(DDEFS) $(INCDIR) $< -o $@
$(BIN_FOLDER)$(NOMAGIC_SRC_FOLDER)gdbserver/monitor_commands.o: $(NOMAGIC_SRC_FOLDER)gdbserver/monitor_commands.c $(BIN_FOLDER)version.h
@echo ""
@echo "=== compiling (monitor commands) $@"
@$(MKDIR_P) $(@D)
$(CC) $(CFLAGS) $(DDEFS) $(INCDIR) $< -o $@
$(BIN_FOLDER)$(NOMAGIC_SRC_FOLDER)lwip/src/%o: $(NOMAGIC_SRC_FOLDER)lwip/src/%c
@echo ""
@echo "=== compiling (lwip) $@"
@$(MKDIR_P) $(@D)
$(CC) $(CFLAGS) -Wno-address -Wno-conversion $(DDEFS) $(INCDIR) $< -o $@