/
NRF5X.make
569 lines (546 loc) · 28.1 KB
/
NRF5X.make
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
# If we're trying to make a full binary and there's no bootloader,
# create one automatically
ifndef DFU_UPDATE_BUILD
ifdef USE_BOOTLOADER
ifndef BOOTLOADER
ifneq ("$(MAKECMDGOALS)","boardjson")
ifneq ("$(MAKECMDGOALS)","docs")
ifeq ("$(wildcard $(NRF_BOOTLOADER))","")
$(info *************************************************************)
$(info NO BOOTLOADER $(NRF_BOOTLOADER) FOUND)
$(info *************************************************************)
$(info RUNNING MAKE CLEAN)
$(info $(shell BOARD=$(BOARD) RELEASE=1 BOOTLOADER=1 make clean))
$(info RUNNING MAKE TO CREATE BOOTLOADER)
$(info $(shell BOARD=$(BOARD) RELEASE=1 BOOTLOADER=1 make))
$(info RUNNING MAKE CLEAN)
$(info $(shell BOARD=$(BOARD) RELEASE=1 make clean))
$(info *************************************************************)
$(info BOOTLOADER BUILD COMPLETE)
$(info *************************************************************)
endif
endif
endif
endif #BOOTLOADER
endif #USE_BOOTLOADER
endif #DFU_UPDATE_BUILD
# Just try and get rid of the compile warnings.
CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-parameter -fomit-frame-pointer #this is for device manager in nordic sdk
CFLAGS+=-Wno-expansion-to-defined # remove warnings created by Nordic's libs
DEFINES += -D$(CHIP) -DNRF5X -DNRF5X_SDK_$(NRF5X_SDK)
ARM = 1
ARM_HAS_OWN_CMSIS = 1 # Nordic uses its own CMSIS files in its SDK, these are up-to-date.
INCLUDE += -I$(NRF5X_SDK_PATH)
# This is where the common linker for both nRF51 & nRF52 is stored.
ifdef NRF5X_SDK_11
LDFLAGS += -L$(NRF5X_SDK_PATH)/nrf5x_linkers
endif
ifdef NRF5X_SDK_12
LDFLAGS += -L$(NRF5X_SDK_PATH)/nrf5x_linkers
endif
ifdef NRF5X_SDK_14
LDFLAGS += -L$(NRF5X_SDK_PATH)/components/toolchain/gcc
endif
ifdef NRF5X_SDK_15
LDFLAGS += -L$(NRF5X_SDK_PATH)/modules/nrfx/mdk
endif
ifdef NRF5X_SDK_17
LDFLAGS += -L$(NRF5X_SDK_PATH)/modules/nrfx/mdk
endif
# These files are the Espruino HAL implementation.
INCLUDE += -I$(ROOT)/targets/nrf5x
ifdef BOOTLOADER
BUILD_LINKER_FLAGS+=--bootloader
PROJ_NAME=$(BOOTLOADER_PROJ_NAME)
WRAPPERSOURCES =
INCLUDE += -I$(ROOT)/targets/nrf5x_dfu
DEFINES += -DSVC_INTERFACE_CALL_AS_NORMAL_FUNCTION
SOURCES = \
targets/nrf5x_dfu/dfu_public_key.c \
targets/nrf5x_dfu/lcd.c \
targets/nrf5x_dfu/main.c \
targets/nrf5x_dfu/flash.c
ifdef NRF5X_SDK_12
SOURCES += \
targets/nrf5x_dfu/sdk12/dfu-cc.pb.c \
targets/nrf5x_dfu/sdk12/dfu_req_handling.c
endif
else # no BOOTLOADER
DEFINES += -DUSE_APP_CONFIG
SOURCES += \
targets/nrf5x/main.c \
targets/nrf5x/jshardware.c \
targets/nrf5x/bluetooth.c \
targets/nrf5x/nrf5x_utils.c
ifeq ($(FAMILY), NRF52)
# Neopixel support (only NRF52)
SOURCES += targets/nrf5x/i2s_ws2812b_drive.c
endif
endif
# Careful here.. All these includes and sources assume a SoftDevice. Not efficient/clean if softdevice (ble) is not enabled...
ifdef NRF5X_SDK_11
INCLUDE += -I$(NRF5X_SDK_PATH)/components/toolchain/CMSIS/Include
else
INCLUDE += -I$(NRF5X_SDK_PATH)/components/toolchain/cmsis/include
endif
INCLUDE += -I$(NRF5X_SDK_PATH)/components
INCLUDE += -I$(NRF5X_SDK_PATH)/components/toolchain/gcc
INCLUDE += -I$(NRF5X_SDK_PATH)/components/toolchain
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/config
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/util
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/delay
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/uart
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/fds
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/fds/config
INCLUDE += -I$(NRF5X_SDK_PATH)/components/ble/common
INCLUDE += -I$(NRF5X_SDK_PATH)/components/device
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/button
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/timer
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/fstorage
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/fstorage/config
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/queue
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/experimental_section_vars
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/gpiote
INCLUDE += -I$(NRF5X_SDK_PATH)/components/ble/ble_services/ble_nus
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/hal
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/common
INCLUDE += -I$(NRF5X_SDK_PATH)/components/ble/peer_manager
INCLUDE += -I$(NRF5X_SDK_PATH)/components/softdevice/common/softdevice_handler
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/twi_master
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/spi_master
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/ppi
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/hal/nrf_pwm
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/clock
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/rng
ifneq ($(or $(NRF5X_SDK_12),$(NRF5X_SDK_11)),)
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/log
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/log/src
else
INCLUDE += -I$(NRF5X_SDK_PATH)/components/softdevice/common
ifndef NRF5X_SDK_15_3
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/experimental_log
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/experimental_log/src
else # SDK 15.0
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/log
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/log/src
endif
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/atomic
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/atomic_fifo
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/strerror
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/experimental_memobj
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/balloc
endif
ifdef NRF5X_SDK_15
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx/mdk
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx/hal
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx/legacy
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx/drivers/include
INCLUDE += -I$(NRF5X_SDK_PATH)/integration/nrfx
INCLUDE += -I$(NRF5X_SDK_PATH)/integration/nrfx/legacy
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/delay
INCLUDE += -I$(NRF5X_SDK_PATH)/components/ble/ble_link_ctx_manager
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/atomic_flags
ifdef NRF5X_SDK_15_3
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/memobj/nrf_memobj.c
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/mutex
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/memobj
else # SDK 15.0
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/experimental_memobj/nrf_memobj.c
endif
endif
ifdef NRF5X_SDK_17
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx/mdk
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx/hal
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx/legacy
INCLUDE += -I$(NRF5X_SDK_PATH)/modules/nrfx/drivers/include
INCLUDE += -I$(NRF5X_SDK_PATH)/integration/nrfx
INCLUDE += -I$(NRF5X_SDK_PATH)/integration/nrfx/legacy
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/delay
INCLUDE += -I$(NRF5X_SDK_PATH)/components/ble/ble_link_ctx_manager
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/atomic_flags
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/log
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/log/src
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/mutex
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/memobj
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/memobj/nrf_memobj.c
endif
ifneq ($(or $(NRF5X_SDK_15),$(NRF5X_SDK_17)),)
TARGETSOURCES += \
$(NRF5X_SDK_PATH)/modules/nrfx/drivers/src/nrfx_gpiote.c \
$(NRF5X_SDK_PATH)/modules/nrfx/drivers/src/nrfx_spi.c \
$(NRF5X_SDK_PATH)/modules/nrfx/drivers/src/nrfx_spim.c \
$(NRF5X_SDK_PATH)/modules/nrfx/drivers/src/nrfx_twi.c \
$(NRF5X_SDK_PATH)/modules/nrfx/drivers/src/nrfx_uart.c \
$(NRF5X_SDK_PATH)/modules/nrfx/drivers/src/nrfx_uarte.c \
$(NRF5X_SDK_PATH)/integration/nrfx/legacy/nrf_drv_ppi.c \
$(NRF5X_SDK_PATH)/integration/nrfx/legacy/nrf_drv_rng.c \
$(NRF5X_SDK_PATH)/integration/nrfx/legacy/nrf_drv_twi.c \
$(NRF5X_SDK_PATH)/integration/nrfx/legacy/nrf_drv_uart.c \
$(NRF5X_SDK_PATH)/integration/nrfx/legacy/nrf_drv_spi.c \
$(NRF5X_SDK_PATH)/components/libraries/atomic/nrf_atomic.c \
$(NRF5X_SDK_PATH)/components/libraries/atomic_flags/nrf_atflags.c \
$(NRF5X_SDK_PATH)/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.c \
$(NRF5X_SDK_PATH)/components/libraries/util/app_error_handler_gcc.c
else
TARGETSOURCES += \
$(NRF5X_SDK_PATH)/components/drivers_nrf/common/nrf_drv_common.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/uart/nrf_drv_uart.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/hal/nrf_nvmc.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/twi_master/nrf_drv_twi.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/spi_master/nrf_drv_spi.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/ppi/nrf_drv_ppi.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/clock/nrf_drv_clock.c
endif
ifneq (,$(findstring I2C_SLAVE,$(DEFINES)))
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/twis_slave
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/drivers_nrf/twis_slave/nrf_drv_twis.c
endif
ifndef NRF5X_SDK_17
ifndef NRF5X_SDK_15_3
TARGETSOURCES += \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/pm_mutex.c
endif
endif
TARGETSOURCES += \
$(NRF5X_SDK_PATH)/components/ble/common/ble_advdata.c \
$(NRF5X_SDK_PATH)/components/ble/common/ble_conn_params.c \
$(NRF5X_SDK_PATH)/components/ble/common/ble_srv_common.c \
$(NRF5X_SDK_PATH)/components/ble/common/ble_conn_state.c \
$(NRF5X_SDK_PATH)/components/ble/ble_services/ble_nus/ble_nus.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/peer_manager.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/peer_id.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/peer_database.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/peer_data_storage.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/pm_buffer.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/id_manager.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/security_manager.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/security_dispatcher.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/gatt_cache_manager.c \
$(NRF5X_SDK_PATH)/components/ble/peer_manager/gatts_cache_manager.c \
$(NRF5X_SDK_PATH)/components/libraries/timer/app_timer.c \
$(NRF5X_SDK_PATH)/components/libraries/fds/fds.c \
$(NRF5X_SDK_PATH)/components/libraries/queue/nrf_queue.c \
$(NRF5X_SDK_PATH)/components/libraries/util/app_util_platform.c \
$(NRF5X_SDK_PATH)/components/libraries/util/sdk_mapped_flags.c \
$(NRF5X_SDK_PATH)/components/libraries/util/app_error.c \
$(NRF5X_SDK_PATH)/components/libraries/util/nrf_assert.c
ifdef NRF5X_SDK_11
TARGETSOURCES += \
$(NRF5X_SDK_PATH)/components/drivers_nrf/hal/nrf_saadc.c
endif
ifneq ($(or $(NRF5X_SDK_12),$(NRF5X_SDK_11)),)
TARGETSOURCES += \
$(NRF5X_SDK_PATH)/components/softdevice/common/softdevice_handler/softdevice_handler.c \
$(NRF5X_SDK_PATH)/components/libraries/fstorage/fstorage.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/delay/nrf_delay.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/hal/nrf_adc.c
else
TARGETSOURCES += \
$(NRF5X_SDK_PATH)/components/softdevice/common/nrf_sdh.c \
$(NRF5X_SDK_PATH)/components/softdevice/common/nrf_sdh_ble.c \
$(NRF5X_SDK_PATH)/components/softdevice/common/nrf_sdh_soc.c \
$(NRF5X_SDK_PATH)/components/libraries/experimental_section_vars/nrf_section_iter.c \
$(NRF5X_SDK_PATH)/components/libraries/fstorage/nrf_fstorage.c \
$(NRF5X_SDK_PATH)/components/libraries/fstorage/nrf_fstorage_sd.c \
$(NRF5X_SDK_PATH)/components/libraries/queue/nrf_queue.c \
$(NRF5X_SDK_PATH)/components/libraries/atomic_fifo/nrf_atfifo.c \
$(NRF5X_SDK_PATH)/components/libraries/strerror/nrf_strerror.c \
$(NRF5X_SDK_PATH)/components/libraries/balloc/nrf_balloc.c
endif
ifdef USE_BOOTLOADER
ifdef BOOTLOADER
DEFINES += -DBOOTLOADER -DNRF_DFU_SETTINGS_VERSION=1
DEFINES += $(BOOTLOADER_DEFINES)
ifdef BOOTLOADER_ASFLAGS
ASFLAGS += $(BOOTLOADER_ASFLAGS)
endif
ifdef BOOTLOADER_LDFLAGS
LDFLAGS += $(BOOTLOADER_LDFLAGS)
endif
TARGETSOURCES =
ifdef NRF5X_SDK_12
DEFINES += -DuECC_ENABLE_VLI_API -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 -DuECC_SQUARE_FUNC=1 -DuECC_SUPPORTS_secp256r1=1 -DuECC_SUPPORT_COMPRESSED_POINT=0 -DuECC_OPTIMIZATION_LEVEL=3
INCLUDE += -I$(ROOT)/targets/nrf5x_dfu/sdk12
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/bootloader_dfu/ble_transport
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/crc32
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/crypto
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/bootloader
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/bootloader/ble_dfu
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/svc
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/scheduler
INCLUDE += -I$(NRF5X_SDK_PATH)/external/nano-pb
INCLUDE += -I$(NRF5X_SDK_PATH)/external/micro-ecc
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/util/app_error_weak.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/fifo/app_fifo.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/scheduler/app_scheduler.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/timer/app_timer.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/util/app_util_platform.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/crc32/crc32.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/ecc/ecc.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/hci/hci_mem_pool.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/util/nrf_assert.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/queue/nrf_queue.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/ble/common/ble_advdata.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/ble/common/ble_conn_params.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/ble/common/ble_srv_common.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/timer/app_timer_appsh.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/fstorage/fstorage.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/drivers_nrf/common/nrf_drv_common.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/drivers_nrf/rng/nrf_drv_rng.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/drivers_nrf/hal/nrf_nvmc.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/drivers_nrf/delay/nrf_delay.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/toolchain/system_nrf52.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/softdevice/common/softdevice_handler/softdevice_handler.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/softdevice/common/softdevice_handler/softdevice_handler_appsh.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader_app_start.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader_info.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_flash.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_mbr.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_settings.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_transport.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_utils.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/external/nano-pb/pb_common.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/external/nano-pb/pb_decode.c
ifdef NRF_BL_DFU_INSECURE
DEFINES += -DNRF_BL_DFU_INSECURE
else # NRF_BL_DFU_INSECURE
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/ecc
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/sha256
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/crypto/nrf_crypto.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/external/micro-ecc/uECC.c
TARGETSOURCES += $(NRF5X_SDK_PATH)/components/libraries/sha256/sha256.c
endif # NRF_BL_DFU_INSECURE
else # !NRF5X_SDK_12
DEFINES += -DAPP_TIMER_V2
DEFINES += -DAPP_TIMER_V2_RTC1_ENABLED
DEFINES += -DNRF_DFU_SETTINGS_VERSION=1
DEFINES += -DNRF_DFU_SVCI_ENABLED
INCLUDE = \
-I$(ROOT)/gen \
-I$(ROOT)/src \
-I$(ROOT)/targets/nrf5x_dfu \
-I$(ROOT)/targets/nrf5x_dfu/sdk15 \
-I$(NRF5X_SDK_PATH)/external/micro-ecc \
-I$(NRF5X_SDK_PATH)/components/libraries/sha256 \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/micro_ecc \
-I$(NRF5X_SDK_PATH)/modules/nrfx/hal \
-I$(NRF5X_SDK_PATH)/components/softdevice/s140/headers/nrf52 \
-I$(NRF5X_SDK_PATH)/components/libraries/crc32 \
-I$(NRF5X_SDK_PATH)/components/libraries/experimental_section_vars \
-I$(NRF5X_SDK_PATH)/components/libraries/mem_manager \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/nrf_sw \
-I$(NRF5X_SDK_PATH)/components/libraries/util \
-I$(NRF5X_SDK_PATH)/modules/nrfx \
-I$(NRF5X_SDK_PATH)/components/libraries/timer/experimental \
-I$(NRF5X_SDK_PATH)/components/libraries/timer \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/oberon \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/cifra \
-I$(NRF5X_SDK_PATH)/components/libraries/atomic \
-I$(NRF5X_SDK_PATH)/integration/nrfx \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/cc310_bl \
-I$(NRF5X_SDK_PATH)/external/nrf_cc310/include \
-I$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu \
-I$(NRF5X_SDK_PATH)/components/ble/common \
-I$(NRF5X_SDK_PATH)/components/libraries/delay \
-I$(NRF5X_SDK_PATH)/components/libraries/svc \
-I$(NRF5X_SDK_PATH)/components/libraries/stack_info \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/nrf_hw \
-I$(NRF5X_SDK_PATH)/components/libraries/strerror \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/mbedtls \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/cc310 \
-I$(NRF5X_SDK_PATH)/components/libraries/bootloader \
-I$(NRF5X_SDK_PATH)/components/softdevice/s140/headers \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto \
-I$(NRF5X_SDK_PATH)/components/libraries/scheduler \
-I$(NRF5X_SDK_PATH)/external/nrf_cc310_bl/include \
-I$(NRF5X_SDK_PATH)/components/toolchain/cmsis/include \
-I$(NRF5X_SDK_PATH)/components/libraries/balloc \
-I$(NRF5X_SDK_PATH)/components/libraries/atomic_fifo \
-I$(NRF5X_SDK_PATH)/components/libraries/sortlist \
-I$(NRF5X_SDK_PATH)/components/libraries/fstorage \
-I$(NRF5X_SDK_PATH)/modules/nrfx/mdk \
-I$(NRF5X_SDK_PATH)/components/libraries/mutex \
-I$(NRF5X_SDK_PATH)/components/libraries/bootloader/ble_dfu \
-I$(NRF5X_SDK_PATH)/components/softdevice/common \
-I$(NRF5X_SDK_PATH)/external/nano-pb \
-I$(NRF5X_SDK_PATH)/components/libraries/queue \
-I$(NRF5X_SDK_PATH)/components/libraries/experimental_memobj
ifdef NRF5X_SDK_15_3
INCLUDE += \
-I$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/optiga \
-I$(NRF5X_SDK_PATH)/components/libraries/log \
-I$(NRF5X_SDK_PATH)/components/libraries/log/src
else
INCLUDE += \
-I$(NRF5X_SDK_PATH)/components/libraries/experimental_log \
-I$(NRF5X_SDK_PATH)/components/libraries/experimental_log/src
endif
TARGETSOURCES += \
$(NRF5X_SDK_PATH)/external/micro-ecc/uECC.c \
$(NRF5X_SDK_PATH)/components/libraries/sha256/sha256.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.c \
$(NRF5X_SDK_PATH)/components/libraries/util/app_error_weak.c \
$(NRF5X_SDK_PATH)/components/libraries/scheduler/app_scheduler.c \
$(NRF5X_SDK_PATH)/components/libraries/timer/experimental/app_timer2.c \
$(NRF5X_SDK_PATH)/components/libraries/util/app_util_platform.c \
$(NRF5X_SDK_PATH)/components/libraries/crc32/crc32.c \
$(NRF5X_SDK_PATH)/components/libraries/timer/experimental/drv_rtc.c \
$(NRF5X_SDK_PATH)/components/libraries/mem_manager/mem_manager.c \
$(NRF5X_SDK_PATH)/components/libraries/util/nrf_assert.c \
$(NRF5X_SDK_PATH)/components/libraries/atomic_fifo/nrf_atfifo.c \
$(NRF5X_SDK_PATH)/components/libraries/atomic/nrf_atomic.c \
$(NRF5X_SDK_PATH)/components/libraries/balloc/nrf_balloc.c \
$(NRF5X_SDK_PATH)/components/libraries/fstorage/nrf_fstorage.c \
$(NRF5X_SDK_PATH)/components/libraries/fstorage/nrf_fstorage_nvmc.c \
$(NRF5X_SDK_PATH)/components/libraries/fstorage/nrf_fstorage_sd.c \
$(NRF5X_SDK_PATH)/components/libraries/queue/nrf_queue.c \
$(NRF5X_SDK_PATH)/components/libraries/experimental_section_vars/nrf_section_iter.c \
$(NRF5X_SDK_PATH)/components/libraries/sortlist/nrf_sortlist.c \
$(NRF5X_SDK_PATH)/components/libraries/strerror/nrf_strerror.c \
$(NRF5X_SDK_PATH)/modules/nrfx/mdk/system_nrf52840.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecc.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_ecdsa.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_init.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.c \
$(NRF5X_SDK_PATH)/modules/nrfx/hal/nrf_nvmc.c \
$(NRF5X_SDK_PATH)/components/softdevice/common/nrf_sdh.c \
$(NRF5X_SDK_PATH)/components/softdevice/common/nrf_sdh_ble.c \
$(NRF5X_SDK_PATH)/components/softdevice/common/nrf_sdh_soc.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/nrf_crypto_ecc.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/nrf_crypto_ecdsa.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/nrf_crypto_hash.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/nrf_crypto_init.c \
$(NRF5X_SDK_PATH)/components/libraries/crypto/nrf_crypto_shared.c \
$(NRF5X_SDK_PATH)/components/libraries/svc/nrf_svc_handler.c \
$(NRF5X_SDK_PATH)/components/ble/common/ble_srv_common.c \
$(NRF5X_SDK_PATH)/external/nano-pb/pb_common.c \
$(NRF5X_SDK_PATH)/external/nano-pb/pb_decode.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/dfu-cc.pb.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_svci.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_flash.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_mbr.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_req_handler.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_settings.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_transport.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_utils.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_validation.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader_app_start.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader_app_start_final.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader_dfu_timers.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader_fw_activation.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader_info.c \
$(NRF5X_SDK_PATH)/components/libraries/bootloader/nrf_bootloader_wdt.c
endif
endif # BOOTLOADER
ifndef BOOTLOADER_SETTINGS_FAMILY
BOOTLOADER_SETTINGS_FAMILY = NRF52
endif
endif # USE_BOOTLOADER
ifndef BOOTLOADER
ifdef ESPR_BLUETOOTH_ANCS
DEFINES += -DESPR_BLUETOOTH_ANCS=1
INCLUDE += -I$(NRF5X_SDK_PATH)/components/ble/ble_services/ble_ancs_c
INCLUDE += -I$(NRF5X_SDK_PATH)/components/ble/ble_db_discovery
INCLUDE += -I$(NRF5X_SDK_PATH)/components/softdevice/common
INCLUDE += -I$(ROOT)/targets/nrf5x/ble_ams_c
INCLUDE += -I$(ROOT)/targets/nrf5x/ble_cts_c
TARGETSOURCES += \
$(ROOT)/targets/nrf5x/bluetooth_ancs.c \
$(ROOT)/targets/nrf5x/ble_ams_c/ams_tx_buffer.c \
$(ROOT)/targets/nrf5x/ble_ams_c/nrf_ble_ams_c.c \
$(ROOT)/targets/nrf5x/ble_cts_c/ble_cts_c.c \
$(NRF5X_SDK_PATH)/components/ble/ble_services/ble_ancs_c/ancs_app_attr_get.c \
$(NRF5X_SDK_PATH)/components/ble/ble_services/ble_ancs_c/ancs_attr_parser.c \
$(NRF5X_SDK_PATH)/components/ble/ble_services/ble_ancs_c/ancs_tx_buffer.c \
$(NRF5X_SDK_PATH)/components/ble/ble_services/ble_ancs_c/nrf_ble_ancs_c.c \
$(NRF5X_SDK_PATH)/components/ble/ble_db_discovery/ble_db_discovery.c
endif # ESPR_BLUETOOTH_ANCS
endif
# ==============================================================
include make/common/ARM.make
$(PROJ_NAME).app_hex: $(PROJ_NAME).elf
python scripts/check_elf_size.py $(BOARD) $(PROJ_NAME).elf
@echo $(call obj_to_bin,ihex,hex)
@$(call obj_to_bin,ihex,hex)
ifdef INCLUDE_BLANK_STORAGE
@echo Including blank storage contents in hex file
# could use 'board.chip["saved_code"]["pages"] * board.chip["saved_code"]["page_size"]' but we only need first page
# if we include all pages bootloader can complain because it thinks we're overwriting everything
tr "\000" "\377" < /dev/zero | dd bs=1 count=$(shell python scripts/get_board_info.py $(BOARD) 'board.chip["saved_code"]["page_size"]') of=blank_storage.bin
objcopy -I binary -O ihex --change-address $(shell python scripts/get_board_info.py $(BOARD) 'board.chip["saved_code"]["address"]') blank_storage.bin blank_storage.hex
python scripts/hexmerge.py --overlap=replace $(PROJ_NAME).hex blank_storage.hex -o $(PROJ_NAME).app_hex
else
@mv $(PROJ_NAME).hex $(PROJ_NAME).app_hex
endif
$(PROJ_NAME).hex: $(PROJ_NAME).app_hex
ifdef USE_BOOTLOADER
ifdef BOOTLOADER
@echo Bootloader - leaving hex file as-is
@mv $(PROJ_NAME).app_hex $(PROJ_NAME).hex
# for testing:
#python scripts/hexmerge.py --overlap=replace $(SOFTDEVICE) $(PROJ_NAME).app_hex -o $(PROJ_NAME).hex
else
@echo Merging SoftDevice and Bootloader
@# build a DFU settings file we can merge in... family can be NRF52840 or NRF52
nrfutil settings generate --family $(BOOTLOADER_SETTINGS_FAMILY) --application $(PROJ_NAME).app_hex --app-boot-validation VALIDATE_GENERATED_CRC --application-version 0xff --bootloader-version 0xff --bl-settings-version 2 $(OBJDIR)/dfu_settings.hex
@echo FIXME - had to set --overlap=replace
python scripts/hexmerge.py --overlap=replace $(SOFTDEVICE) $(NRF_BOOTLOADER) $(PROJ_NAME).app_hex $(OBJDIR)/dfu_settings.hex -o $(PROJ_NAME).hex
endif
else
@echo Merging SoftDevice
python scripts/hexmerge.py $(SOFTDEVICE) $(PROJ_NAME).app_hex -o $(PROJ_NAME).hex
endif # USE_BOOTLOADER
$(PROJ_NAME).zip: $(PROJ_NAME).app_hex
ifdef NRF5X_SDK_11 # SDK11 requires non-secure DFU that the adafruit tools support
@echo Creating DFU ZIP
# adafruit-nrfutil dfu genpkg --help
@cp $(PROJ_NAME).app_hex $(PROJ_NAME)_app.hex
adafruit-nrfutil dfu genpkg --application $(PROJ_NAME)_app.hex $(DFU_SETTINGS) $(PROJ_NAME).zip
@rm $(PROJ_NAME)_app.hex
else
@echo Creating DFU ZIP
# nrfutil pkg generate --help
@cp $(PROJ_NAME).app_hex $(PROJ_NAME)_app.hex
ifdef BOOTLOADER
nrfutil pkg generate $(PROJ_NAME).zip --bootloader $(PROJ_NAME)_app.hex --bootloader-version 0xff --hw-version 52 --sd-req 0x8C,0x91 --key-file $(DFU_PRIVATE_KEY)
else
nrfutil pkg generate $(PROJ_NAME).zip --application $(PROJ_NAME)_app.hex $(DFU_SETTINGS) --key-file $(DFU_PRIVATE_KEY)
endif
@rm $(PROJ_NAME)_app.hex
endif
flash: all
ifeq ($(BOARD),MICROBIT)
if [ -d "/media/$(USER)/MICROBIT" ]; then cp $(PROJ_NAME).hex /media/$(USER)/MICROBIT;sync; fi
if [ -d "/media/MICROBIT" ]; then cp $(PROJ_NAME).hex /media/MICROBIT;sync; fi
else
nrfjprog --family NRF52 --clockspeed 50000 --recover
nrfjprog --family $(FAMILY) --clockspeed 50000 --program $(PROJ_NAME).hex --chiperase --reset
endif
partflash: all
nrfjprog --family $(FAMILY) --clockspeed 50000 --program $(PROJ_NAME).hex --sectorerase --reset;
ifdef DFU_UPDATE_BUILD_WITH_HEX
proj: $(PROJ_NAME).hex $(PROJ_NAME).zip
else
ifdef DFU_UPDATE_BUILD
proj: $(PROJ_NAME).zip
else
proj: $(PROJ_NAME).hex
endif
endif