-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathMakefile.standard_app
More file actions
329 lines (284 loc) · 10.9 KB
/
Makefile.standard_app
File metadata and controls
329 lines (284 loc) · 10.9 KB
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
#*******************************************************************************
# Ledger SDK
# (c) 2022 Ledger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#*******************************************************************************
include $(BOLOS_SDK)/Makefile.target
#####################################################################
# BLUETOOTH #
#####################################################################
ifeq ($(ENABLE_BLUETOOTH), 1)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX TARGET_FLEX TARGET_APEX_P))
HAVE_APPLICATION_FLAG_BOLOS_SETTINGS = 1
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000 HAVE_BLE_APDU
SDK_SOURCE_PATH += lib_blewbxx
endif
endif
#####################################################################
# NFC #
#####################################################################
ifeq ($(ENABLE_NFC), 1)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME), TARGET_STAX TARGET_FLEX TARGET_APEX_P))
HAVE_APPLICATION_FLAG_BOLOS_SETTINGS = 1
DEFINES += HAVE_NFC
SDK_SOURCE_PATH += lib_nfc
endif
endif
ifeq ($(ENABLE_NFC_READER), 1)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME), TARGET_STAX TARGET_FLEX TARGET_APEX_P))
DEFINES += HAVE_NFC_READER
endif
endif
#####################################################################
# SWAP #
#####################################################################
ifeq ($(ENABLE_SWAP), 1)
HAVE_APPLICATION_FLAG_LIBRARY = 1
DEFINES += HAVE_SWAP
endif
ifeq ($(ENABLE_TESTING_SWAP), 1)
# Partial SWAP implementation. Don't give lib permission on the device.
# Do note that HAVE_APPLICATION_FLAG_LIBRARY is not enabled.
DEFINES += HAVE_SWAP
endif
#####################################################################
# TLV LIBRARY #
#####################################################################
ifeq ($(ENABLE_TLV_LIBRARY), 1)
SDK_SOURCE_PATH += lib_tlv
endif
#####################################################################
# PKI LIBRARY #
#####################################################################
ifeq ($(ENABLE_PKI_LIBRARY), 1)
SDK_SOURCE_PATH += lib_pki
endif
#####################################################################
# APP STORAGE #
#####################################################################
ifeq ($(ENABLE_APP_STORAGE), 1)
HAVE_APP_STORAGE = 1
DEFINES += HAVE_APP_STORAGE
ifeq ($(APP_STORAGE_SIZE),)
# Fall back to maximum page size for all the devices
# 512 (Flash page size) - 32 bytes (for the system header with a room to grow)
APP_STORAGE_SIZE := 480
endif
DEFINES += APP_STORAGE_SIZE=$(APP_STORAGE_SIZE)
DEFINES += HAVE_APP_STORAGE_PROP_SETTINGS=$(ENABLE_APP_STORAGE_PROP_SETTINGS)
DEFINES += HAVE_APP_STORAGE_PROP_DATA=$(ENABLE_APP_STORAGE_PROP_DATA)
endif
#####################################################################
# DEBUG #
#####################################################################
ifneq ($(DEBUG), 0)
ifneq ($(DEBUG_OVER_USB), 0)
$(error Can't set both DEBUG & DEBUG_OVER_USB)
endif
DEFINES += HAVE_PRINTF
endif
ifneq ($(DEBUG_OVER_USB), 0)
DEFINES += HAVE_PRINTF
DEFINES += HAVE_PRINTF_CDC
DEFINES += HAVE_CDCUSB
DISABLE_OS_IO_STACK_USE = 1
ifeq ($(TARGET_NAME), TARGET_NANOS2)
ifeq (,$(filter $(DEFINES),HAVE_IO_U2F))
DISABLE_STANDARD_WEBUSB = 1
DISABLE_STANDARD_U2F = 1
else
DEFINES += HAVE_NOT_USB_HID
DISABLE_STANDARD_WEBUSB = 1
endif
endif
endif
ifneq (,$(filter $(DEFINES),HAVE_PRINTF))
DEFINES += PRINTF=mcu_usb_printf
ifneq ($(DISABLE_DEBUG_LEDGER_ASSERT), 1)
DEFINES += HAVE_LEDGER_ASSERT_DISPLAY
DEFINES += LEDGER_ASSERT_CONFIG_FILE_INFO
endif
ifneq ($(DISABLE_DEBUG_THROW), 1)
DEFINES += HAVE_DEBUG_THROWS
endif
else
DEFINES += PRINTF\(...\)=
endif
#####################################################################
# NBGL #
#####################################################################
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_NANOS2))
ifeq ($(ENABLE_NBGL_FOR_NANO_DEVICES), 1)
USE_NBGL = 1
else
USE_NBGL = 0
endif
else
USE_NBGL = 1
endif
ifeq ($(ENABLE_NBGL_QRCODE), 1)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_STAX TARGET_FLEX TARGET_APEX_P TARGET_APEX_M))
DEFINES += NBGL_QRCODE
SDK_SOURCE_PATH += qrcode
endif
endif
ifeq ($(ENABLE_NBGL_KEYBOARD), 1)
DEFINES += NBGL_KEYBOARD
endif
ifeq ($(ENABLE_NBGL_KEYPAD), 1)
DEFINES += NBGL_KEYPAD
endif
#####################################################################
# OS IO STACK USE #
#####################################################################
ifneq ($(DISABLE_OS_IO_STACK_USE), 1)
ifeq (,$(filter $(DEFINES),HAVE_LEGACY_PID))
DEFINES += USE_OS_IO_STACK
endif
endif
#####################################################################
# STANDARD DEFINES #
#####################################################################
DEFINES += $(DEFINES_LIB)
DEFINES += MAJOR_VERSION=$(APPVERSION_M) MINOR_VERSION=$(APPVERSION_N) PATCH_VERSION=$(APPVERSION_P)
DEFINES += IO_HID_EP_LENGTH=64
SDK_SOURCE_PATH += io
SDK_SOURCE_PATH += protocol
ifeq ($(DISABLE_STANDARD_APP_DEFINES), 1)
DISABLE_STANDARD_SNPRINTF = 1
DISABLE_STANDARD_USB = 1
DISABLE_STANDARD_WEBUSB = 1
DISABLE_STANDARD_U2F = 1
DISABLE_STANDARD_BAGL_UX_FLOW = 1
endif
ifneq ($(DISABLE_STANDARD_SNPRINTF), 1)
DEFINES += HAVE_SPRINTF HAVE_SNPRINTF_FORMAT_U HAVE_SNPRINTF_FORMAT_LL
endif
ifneq ($(DISABLE_STANDARD_USB), 1)
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=6 HAVE_USB_APDU
DEFINES += USB_SEGMENT_SIZE=64
SDK_SOURCE_PATH += lib_stusb
SDK_SOURCE_PATH += lib_stusb_impl
endif
ifneq ($(DISABLE_STANDARD_WEBUSB), 1)
APP_WEBUSB_URL ?= ""
WEBUSB_URL_SIZE_B = $(shell echo -n $(APP_WEBUSB_URL) | wc -c)
WEBUSB_URL=$(shell echo -n $(APP_WEBUSB_URL) | sed -e "s/./\\\'\0\\\',/g")
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=$(WEBUSB_URL_SIZE_B) WEBUSB_URL=$(WEBUSB_URL)
endif
ifneq ($(DISABLE_STANDARD_U2F), 1)
DEFINES += HAVE_IO_U2F
SDK_SOURCE_PATH += lib_u2f
endif
ifeq ($(ENABLE_USB_CCID), 1)
DEFINES += HAVE_CCID_USB
SDK_SOURCE_PATH += lib_ccid
SDK_SOURCE_PATH += lib_stusb_impl
endif
ifneq ($(DISABLE_STANDARD_BAGL_UX_FLOW), 1)
ifndef USE_NBGL
DEFINES += HAVE_UX_FLOW
endif
endif
ifneq ($(DISABLE_STANDARD_SEPROXYHAL), 1)
DEFINES += OS_IO_SEPROXYHAL
endif
ifneq ($(DISABLE_STANDARD_APP_FILES), 1)
SDK_SOURCE_PATH += lib_standard_app
endif
ifneq ($(DISABLE_STANDARD_APP_SYNC_RAPDU), 1)
DEFINES += STANDARD_APP_SYNC_RAPDU
endif
#####################################################################
# APP_LOAD_PARAMS #
#####################################################################
CUSTOM_APP_FLAGS ?= 0x000 # Can be personalized by the application
STANDARD_APP_FLAGS = 0x000
# Following flags enables app permissions.
# See SDK include/appflags.h for the purpose of each permission
ifeq ($(HAVE_APPLICATION_FLAG_DERIVE_MASTER), 1)
# APPLICATION_FLAG_DERIVE_MASTER 0x010
STANDARD_APP_FLAGS := $(shell echo $$(($(STANDARD_APP_FLAGS) + 0x010)))
endif
ifeq ($(HAVE_APPLICATION_FLAG_GLOBAL_PIN), 1)
# APPLICATION_FLAG_GLOBAL_PIN 0x040
STANDARD_APP_FLAGS := $(shell echo $$(($(STANDARD_APP_FLAGS) + 0x040)))
endif
ifeq ($(HAVE_APPLICATION_FLAG_BOLOS_SETTINGS), 1)
# APPLICATION_FLAG_BOLOS_SETTINGS 0x200
STANDARD_APP_FLAGS := $(shell echo $$(($(STANDARD_APP_FLAGS) + 0x200)))
endif
ifeq ($(HAVE_APPLICATION_FLAG_LIBRARY), 1)
# APPLICATION_FLAG_LIBRARY 0x800
STANDARD_APP_FLAGS := $(shell echo $$(($(STANDARD_APP_FLAGS) + 0x800)))
endif
ifeq ($(HAVE_APPLICATION_FLAG_NOT_REVIEWED), 1)
# APPLICATION_FLAG_LIBRARY 0x2000
STANDARD_APP_FLAGS := $(shell echo $$(($(STANDARD_APP_FLAGS) + 0x20000)))
endif
APP_FLAGS_APP_LOAD_PARAMS = $(shell printf '0x%x' $$(( $(STANDARD_APP_FLAGS) + $(CUSTOM_APP_FLAGS) )) )
#####################################################################
# COMPILER SETTINGS #
#####################################################################
CC = $(CLANGPATH)clang
AS = $(CLANGPATH)clang
LD = $(CLANGPATH)clang
LDLIBS += -lclang_rt.builtins
AFLAGS += --target=arm-none-eabi
LDLIBS += -lm -lc
#####################################################################
# MISC #
#####################################################################
ifeq ($(TARGET_NAME), TARGET_NANOX)
ICONNAME ?= $(ICON_NANOX)
endif
ifeq ($(TARGET_NAME), TARGET_NANOS2)
ICONNAME ?= $(ICON_NANOSP)
endif
ifeq ($(TARGET_NAME), TARGET_STAX)
ICONNAME ?= $(ICON_STAX)
endif
ifeq ($(TARGET_NAME), TARGET_FLEX)
ICONNAME ?= $(ICON_FLEX)
endif
ifeq ($(TARGET_NAME), TARGET_APEX_P)
ICONNAME ?= $(ICON_APEX_P)
endif
ifeq ($(TARGET_NAME), TARGET_APEX_M)
ICONNAME ?= $(ICON_APEX_M)
endif
include $(BOLOS_SDK)/Makefile.defines
include $(BOLOS_SDK)/Makefile.glyphs
load: all
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS)
load-offline: all
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS) --offline
delete:
python3 -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)
IS_STANDARD_APP = 1
include $(BOLOS_SDK)/Makefile.rules
# Prepare `listvariants` mandatory target.
# This target output must contains:
# - `VARIANTS` which is used as a marker for the tools parsing the output.
# - <VARIANT_PARAM> which is the name of the parameter which should be set
# to specify the variant that should be build.
# - <VARIANT_VALUES> a list of variant that can be build using this app code.
# * It must at least contains one value.
# * Values can be the app ticker or anything else but should be unique.
#
# Deployment scripts will use this Makefile target to retrieve the list of
# available variants and then call `make -j <VARIANT_PARAM>=<VALUE>` for each
# <VALUE> in <VARIANT_VALUES>.
listvariants:
@echo VARIANTS $(VARIANT_PARAM) $(VARIANT_VALUES)