forked from LedgerHQ/app-bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
221 lines (183 loc) · 7.09 KB
/
Copy pathMakefile
File metadata and controls
221 lines (183 loc) · 7.09 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
# ****************************************************************************
# Ledger App for Liquid Network
# (c) 2025 Blockstream
#
# 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.
# ****************************************************************************
ifndef DEBUG_LOG_LEVEL
ifdef DEBUG
DEBUG_LOG_LEVEL := $(DEBUG)
else
DEBUG_LOG_LEVEL := 0
endif
endif
ifeq ($(BOLOS_SDK),)
$(error Environment variable BOLOS_SDK is not set)
endif
# Application allowed derivation curves.
CURVE_APP_LOAD_PARAMS = secp256k1
# Allowed SLIP21 paths
PATH_SLIP21_APP_LOAD_PARAMS = "LEDGER-Wallet policy"
# Application version
APPVERSION_M = 2
APPVERSION_N = 2
APPVERSION_P = 3
APPVERSION_SUFFIX = # if not empty, appended at the end. Do not add a dash.
ifeq ($(APPVERSION_SUFFIX),)
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"
else
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)-$(strip $(APPVERSION_SUFFIX))"
endif
# simplify for tests
ifndef COIN
COIN=liquid_regtest
endif
# Setting to allow building variant applications
VARIANT_PARAM = COIN
VARIANT_VALUES = liquid_regtest liquid_testnet liquid
########################################
# Application custom permissions #
########################################
HAVE_APPLICATION_FLAG_GLOBAL_PIN = 1
HAVE_APPLICATION_FLAG_BOLOS_SETTINGS = 1
ifeq ($(COIN),liquid_regtest)
# Application allowed derivation paths (Liquid testnet/regtest).
PATH_APP_LOAD_PARAMS = "*/1'" # purpose=* / coin_type=Testnet(1)
# Liquid regtest
DEFINES += BIP32_PUBKEY_VERSION=0x043587CF
DEFINES += BIP32_PRIVKEY_VERSION=0x04358394
DEFINES += BIP44_COIN_TYPE=1
DEFINES += COIN_P2PKH_VERSION=111
DEFINES += COIN_P2SH_VERSION=75
DEFINES += COIN_PREFIX_CONFIDENTIAL=4
DEFINES += HAVE_LIQUID
DEFINES += LIQUID_NET_REGTEST
DEFINES += COIN_COINID_SHORT=\"tLBTC\"
DEFINES += COIN_NATIVE_SEGWIT_PREFIX=\"ert\"
DEFINES += COIN_NATIVE_SEGWIT_PREFIX_CONFIDENTIAL=\"el\"
APPNAME = "Liquid Regtest"
else ifeq ($(COIN),liquid_testnet)
# Application allowed derivation paths (Liquid testnet/regtest).
PATH_APP_LOAD_PARAMS = "*/1'" # purpose=* / coin_type=Testnet(1)
# Liquid testnet
DEFINES += BIP32_PUBKEY_VERSION=0x043587CF
DEFINES += BIP32_PRIVKEY_VERSION=0x04358394
DEFINES += BIP44_COIN_TYPE=1
DEFINES += COIN_P2PKH_VERSION=36
DEFINES += COIN_P2SH_VERSION=19
DEFINES += COIN_PREFIX_CONFIDENTIAL=23
DEFINES += HAVE_LIQUID
DEFINES += LIQUID_NET_TESTNET
DEFINES += COIN_COINID_SHORT=\"tLBTC\"
DEFINES += COIN_NATIVE_SEGWIT_PREFIX=\"tex\"
DEFINES += COIN_NATIVE_SEGWIT_PREFIX_CONFIDENTIAL=\"tlq\"
APPNAME = "Liquid Testnet"
else ifeq ($(COIN),liquid)
# Application allowed derivation paths (Liquid main network, liquidv1).
PATH_APP_LOAD_PARAMS = "*/1776'" # purpose=* / coin_type=Liquid(1776)
# Liquid
DEFINES += BIP32_PUBKEY_VERSION=0x0488B21E
DEFINES += BIP32_PRIVKEY_VERSION=0x0488ADE4
DEFINES += BIP44_COIN_TYPE=1776
DEFINES += COIN_P2PKH_VERSION=57
DEFINES += COIN_P2SH_VERSION=39
DEFINES += COIN_PREFIX_CONFIDENTIAL=12
DEFINES += HAVE_LIQUID
DEFINES += LIQUID_NET_MAINNET
DEFINES += COIN_COINID_SHORT=\"LBTC\"
DEFINES += COIN_NATIVE_SEGWIT_PREFIX=\"ex\"
DEFINES += COIN_NATIVE_SEGWIT_PREFIX_CONFIDENTIAL=\"lq\"
APPNAME = "Liquid"
else
ifeq ($(filter clean,$(MAKECMDGOALS)),)
$(error Unsupported COIN - use liquid_regtest, liquid_testnet, liquid)
endif
endif
ifneq (,$(findstring liquid,$(COIN)))
# Add the second SLIP-0021 path for the SLIP-0077 derivation.
# HACK: Using '--path_slip21' is a temporary solution due to lack of support for
# multiple SLIP-0021 path entries in the SDK.
PATH_SLIP21_APP_LOAD_PARAMS += --path_slip21 "SLIP-0077"
endif
ifdef DISPLAYED_APPNAME
CFLAGS += -DDISPLAYED_APPNAME=\"$(DISPLAYED_APPNAME)\"
else
CFLAGS += -DDISPLAYED_APPNAME=\"$(APPNAME)\"
endif
# Application icons following guidelines:
# https://developers.ledger.com/docs/embedded-app/design-requirements/#device-icon
ifneq (,$(findstring liquid,$(COIN)))
# Liquid icons
ICON_NANOS = icons/nanos_app_liquid.gif
ICON_NANOX = icons/nanox_app_liquid.gif
ICON_NANOSP = icons/nanox_app_liquid.gif
ICON_STAX = icons/stax_app_liquid.gif
else
$(error Unsupported COIN)
endif
########################################
# Application communication interfaces #
########################################
ENABLE_BLUETOOTH = 1
########################################
# NBGL custom features #
########################################
ENABLE_NBGL_QRCODE = 1
########################################
# Features disablers #
########################################
# Don't use standard app file to avoid conflicts for now
DISABLE_STANDARD_APP_FILES = 1
# Don't use default IO_SEPROXY_BUFFER_SIZE to use another
# value for NANOS for an unknown reason.
DISABLE_DEFAULT_IO_SEPROXY_BUFFER_SIZE = 1
DEFINES += HAVE_BOLOS_APP_STACK_CANARY
ifeq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=72
DEFINES += HAVE_WALLET_ID_SDK
else
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
endif
ifeq ($(TARGET_NAME),TARGET_NANOS)
# enables optimizations using the shared 1K CXRAM region
DEFINES += USE_CXRAM_SECTION
# enables usage of the NVRAM to free up some RAM
DEFINES += USE_NVRAM_STASH
endif
# debugging helper functions and macros
CFLAGS += -include debug-helpers/debug.h
# DEFINES += HAVE_PRINT_STACK_POINTER
# DEFINES += HAVE_LOG_PROCESSOR
# DEFINES += HAVE_APDU_LOG
DEFINES += DEBUG_LOG_LEVEL=$(DEBUG_LOG_LEVEL)
ifeq ($(TEST),1)
$(warning On-device tests should only be run with Speculos!)
DEFINES += RUN_ON_DEVICE_TESTS HAVE_PRINTF HAVE_SEMIHOSTED_PRINTF
else ifeq ($(DEBUG_LOG_LEVEL),10)
$(warning Using semihosted PRINTF. Only run with speculos!)
DEFINES += HAVE_PRINTF HAVE_SEMIHOSTED_PRINTF
else ifeq ($(DEBUG_LOG_LEVEL),11)
$(warning CCMD PRINTF is used! APDU exchage is affected.)
DEFINES += HAVE_CCMD_PRINTF
endif
# Needed to be able to include the definition of G_cx
INCLUDES_PATH += $(BOLOS_SDK)/lib_cxng/src
# Application source files
APP_SOURCE_PATH += src
# Allow usage of function from lib_standard_app/crypto_helpers.c
APP_SOURCE_FILES += ${BOLOS_SDK}/lib_standard_app/crypto_helpers.c
include $(BOLOS_SDK)/Makefile.standard_app
# Makes a detailed report of code and data size in debug/size-report.txt
# More useful for production builds with DEBUG=0
size-report: bin/app.elf
arm-none-eabi-nm --print-size --size-sort --radix=d bin/app.elf >debug/size-report.txt