-
Notifications
You must be signed in to change notification settings - Fork 46
/
Makefile
127 lines (111 loc) · 3.67 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
#
# This file is a part of: https://github.com/brilliantlabsAR/frame-codebase
#
# Authored by: Raj Nakarja / Brilliant Labs Ltd. (raj@brilliant.xyz)
# Rohit Rathnam / Silicon Witchery AB (rohit@siliconwitchery.com)
# Uma S. Gupta / Techno Exponent (umasankar@technoexponent.com)
#
# ISC Licence
#
# Copyright © 2023 Brilliant Labs Ltd.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
BUILD_VERSION ?= $(shell TZ= date +v%y.%j.%H%M)
BUILD_VERSION := $(BUILD_VERSION)
GIT_COMMIT := $(shell git rev-parse --short HEAD)
BUILD := build
# Automatically assign Black Magic port depending if MacOS or Linux
ifeq ($(shell uname), Darwin)
PORT = $(shell ls /dev/cu.usbmodem*1 2> /dev/null | grep "cu.")
else
PORT = /dev/ttyACM0
endif
application:
@make -C source/application BUILD_VERSION=$(BUILD_VERSION)
bootloader:
@make -C source/application BUILD_VERSION=$(BUILD_VERSION)
@make -C source/bootloader BUILD_VERSION=$(BUILD_VERSION)
@make settings-hex-zip BUILD_VERSION=$(BUILD_VERSION)
settings-hex-zip:
@echo Building settings file...
@rm -f $(BUILD)/frame-firmware-*
@nrfutil settings generate \
--family NRF52840 \
--application $(BUILD)/application.hex \
--application-version 0 \
--bootloader-version 0 \
--bl-settings-version 2 \
$(BUILD)/settings.hex
@echo Settings file built
@echo Building DFU package...
@mergehex \
-m $(BUILD)/settings.hex \
$(BUILD)/application.hex \
source/bootloader/*.hex \
libraries/softdevice/*.hex \
-o $(BUILD)/frame-firmware-$(BUILD_VERSION).hex
@nrfutil pkg generate \
--hw-version 52 \
--application-version 0 \
--application $(BUILD)/application.hex \
--sd-req 0x0123 \
--key-file source/bootloader/dfu_private_key.pem \
$(BUILD)/frame-firmware-$(BUILD_VERSION).zip
@echo DFU package built
release:
@echo Releasing...
@make clean
@make application BUILD_VERSION=$(BUILD_VERSION)
@make settings-hex-zip BUILD_VERSION=$(BUILD_VERSION)
@echo Released
clean:
@rm -rf $(BUILD)
@echo Cleaned
flash-jlink:
@nrfutil device program \
--options reset=RESET_HARD \
--firmware $(BUILD)/frame-firmware-*.hex
flash-blackmagic:
@echo Flashing...
@arm-none-eabi-gdb -nx \
--batch-silent \
-ex "target extended-remote $(PORT)" \
-ex "monitor swd_scan" \
-ex "attach 1" \
-ex "monitor erase_mass" \
-ex "detach" \
-ex 'monitor swd_scan' \
-ex 'attach 1' \
-ex 'load' \
-ex 'compare-sections' \
-ex 'kill' \
$(BUILD)/frame-firmware-v*.hex \
2> /dev/null
@echo Flashed
erase-jlink:
@nrfutil device recover
erase-blackmagic:
@arm-none-eabi-gdb -nx \
--batch-silent \
-ex "target extended-remote $(PORT)" \
-ex "monitor swd_scan" \
-ex "attach 1" \
-ex "monitor erase_mass" \
-ex "detach" \
-ex "monitor swd_scan" \
-ex "attach 1" \
-ex "monitor erase_mass" \
2> /dev/null
@echo Erased
.PHONY: all clean release flash-jlink flash-blackmagic erase-jlink erase-blackmagic