1
1
enable_language (C ASM)
2
- # The EXECUTABLE variable is removed. We will use ${PROJECT} directly,
3
- # which is passed down from the parent CMakeLists.txt and holds the correct name (e.g., "Cypherock-Main-btc").
2
+ set (EXECUTABLE ${PROJECT_NAME} .elf)
4
3
set (LINKER_SCRIPT STM32L486RGTX_FLASH.ld)
5
4
set (STARTUP_FILE startup_stm32l486xx.s)
6
5
set (CMAKE_C_STANDARD 11)
@@ -43,9 +42,9 @@ set(CORE_COMMON_GENERAL_SOURCES_FROM_SUBDIRS
43
42
# or are genuinely generic.
44
43
set (CORE_COMMON_SPECIFIC_FILES
45
44
"${CMAKE_CURRENT_SOURCE_DIR} /common/assert_def.c"
46
- "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/coin_specific_data.c"
47
- "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/coin_utils.c"
48
- "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/wallet.c"
45
+ "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/coin_specific_data.c"
46
+ "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/coin_utils.c"
47
+ "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/wallet.c"
49
48
# common/core/core_flow_init.c is now covered by CORE_COMMON_CORE_SOURCES glob.
50
49
# Ensure it and other common/core/*.c files have internal guards where needed.
51
50
)
@@ -78,39 +77,39 @@ set(COMMON_NON_BTC_SOURCES "")
78
77
IF (NOT BTC_ONLY)
79
78
# Source files from common/coin_support/eth_sign_data/
80
79
set (ETH_SIGN_DATA_COMMON_SRCS "" )
81
- file (GLOB ETH_SIGN_DATA_COMMON_SRCS_TMP "common/coin_support/eth_sign_data/*.c" )
80
+ file (GLOB ETH_SIGN_DATA_COMMON_SRCS_TMP "common/coin_support/eth_sign_data/*.c" )
82
81
foreach (file ${ETH_SIGN_DATA_COMMON_SRCS_TMP} )
83
82
list (APPEND ETH_SIGN_DATA_COMMON_SRCS "${file} " )
84
83
endforeach ()
85
84
86
85
# Source files from common/coin_support/tron_parse_txn/
87
86
set (TRON_PARSE_TXN_COMMON_SRCS "" )
88
- file (GLOB TRON_PARSE_TXN_COMMON_SRCS_TMP "common/coin_support/tron_parse_txn/*.c" )
87
+ file (GLOB TRON_PARSE_TXN_COMMON_SRCS_TMP "common/coin_support/tron_parse_txn/*.c" )
89
88
foreach (file ${TRON_PARSE_TXN_COMMON_SRCS_TMP} )
90
89
list (APPEND TRON_PARSE_TXN_COMMON_SRCS "${file} " )
91
90
endforeach ()
92
-
91
+
93
92
list (APPEND COMMON_NON_BTC_SOURCES
94
93
${ETH_SIGN_DATA_COMMON_SRCS}
95
94
${TRON_PARSE_TXN_COMMON_SRCS}
96
- "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/eth.c"
95
+ "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/eth.c"
97
96
"${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/solana.c"
98
- "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/near.c"
97
+ "${CMAKE_CURRENT_SOURCE_DIR} /common/coin_support/near.c"
99
98
# Add other .c files from common/coin_support that are exclusively for non-BTC chains if any
100
99
)
101
100
ENDIF ()
102
101
103
102
104
103
IF (BTC_ONLY)
105
104
# BTC-only build: include only Bitcoin-related apps
106
- set (APP_SOURCES
107
- ${MANAGER_APP_SOURCES}
105
+ set (APP_SOURCES
106
+ ${MANAGER_APP_SOURCES}
108
107
${BTC_FAMILY_SOURCES}
109
108
${INHERITANCE_APP_SOURCES}
110
109
)
111
- ELSE ()
112
- set (APP_SOURCES
113
- ${MANAGER_APP_SOURCES}
110
+ ELSE ()
111
+ set (APP_SOURCES
112
+ ${MANAGER_APP_SOURCES}
114
113
${BTC_FAMILY_SOURCES}
115
114
${EVM_FAMILY_SOURCES}
116
115
${NEAR_APP_SOURCES}
@@ -128,7 +127,7 @@ IF(UNIT_TESTS_SWITCH)
128
127
# Add test sources
129
128
file (GLOB_RECURSE TEST_SOURCES "tests/*.*" )
130
129
set (SOURCES ${BASE_SOURCES} ${APP_SOURCES} ${COMMON_NON_BTC_SOURCES} ${TEST_SOURCES} )
131
-
130
+
132
131
#exclude src/main.c from the compilation list as it needs to be overriden by unit_tests_main.c
133
132
LIST (REMOVE_ITEM SOURCES "${PROJECT_SOURCE_DIR} /src/main.c" )
134
133
@@ -139,46 +138,54 @@ ELSE()
139
138
set (SOURCES ${BASE_SOURCES} ${APP_SOURCES} ${COMMON_NON_BTC_SOURCES} )
140
139
ENDIF (UNIT_TESTS_SWITCH)
141
140
142
- add_executable (${PROJECT}
143
- ${SOURCES}
144
- ${CMAKE_CURRENT_BINARY_DIR} /version .c
145
- ${MINI_GMP_SRCS}
146
- ${POSEIDON_SRCS}
147
- ${PROTO_SRCS}
148
- ${PROTO_HDRS}
149
- ${INCLUDES}
150
- ${LINKER_SCRIPT}
141
+ add_executable (${EXECUTABLE}
142
+ ${SOURCES}
143
+ ${CMAKE_CURRENT_BINARY_DIR} /version .c
144
+ ${MINI_GMP_SRCS}
145
+ ${POSEIDON_SRCS}
146
+ ${PROTO_SRCS}
147
+ ${PROTO_HDRS}
148
+ ${INCLUDES}
149
+ ${LINKER_SCRIPT}
151
150
${STARTUP_FILE} )
152
151
153
- target_compile_definitions (${PROJECT } PRIVATE
154
- -DUSE_HAL_DRIVER
152
+ target_compile_definitions (${EXECUTABLE } PRIVATE
153
+ -DUSE_HAL_DRIVER
155
154
-DSTM32L486xx )
156
155
157
- # NOTE: The compile definitions for DEV_SWITCH, BTC_ONLY_BUILD, and FIRMWARE_TYPE
158
- # have been removed from this file as they are now centrally managed in the
159
- # main CMakeLists.txt. This avoids redundancy and ensures a single source of truth.
160
156
add_compile_definitions (
161
- USE_SIMULATOR=0
162
- USE_BIP32_CACHE=0
163
- USE_BIP39_CACHE=0
164
- STM32L4
165
- USBD_SOF_DISABLED
157
+ USE_SIMULATOR=0
158
+ USE_BIP32_CACHE=0
159
+ USE_BIP39_CACHE=0
160
+ STM32L4
161
+ USBD_SOF_DISABLED
166
162
ENABLE_HID_WEBUSB_COMM=1)
167
163
164
+ # Add BTC_ONLY compile definition when building BTC-only firmware
165
+ IF (BTC_ONLY)
166
+ add_compile_definitions (BTC_ONLY_BUILD)
167
+ ENDIF (BTC_ONLY)
168
+
169
+ IF (DEV_SWITCH)
170
+ add_compile_definitions (DEV_BUILD)
171
+ ENDIF (DEV_SWITCH)
172
+
168
173
if ("${FIRMWARE_TYPE} " STREQUAL "Main" )
169
- target_include_directories (${PROJECT} PRIVATE
174
+ add_compile_definitions (X1WALLET_INITIAL=0 X1WALLET_MAIN=1)
175
+ target_include_directories (${EXECUTABLE} PRIVATE
170
176
main/config/
171
177
)
172
178
elseif ("${FIRMWARE_TYPE} " STREQUAL "Initial" )
173
- target_include_directories (${PROJECT} PRIVATE
179
+ add_compile_definitions (X1WALLET_INITIAL=1 X1WALLET_MAIN=0)
180
+ target_include_directories (${EXECUTABLE} PRIVATE
174
181
initial/config/
175
182
)
176
183
else ()
177
184
message (FATAL_ERROR "Firmware type not specified. Specify using -DFIRMWARE_TYPE=<Type> Type can be Main or Initial" )
178
185
endif ()
179
186
180
187
# Base include directories (always included)
181
- target_include_directories (${PROJECT } PRIVATE
188
+ target_include_directories (${EXECUTABLE } PRIVATE
182
189
apps/manager_app # Manager app is always included
183
190
184
191
src/
@@ -206,11 +213,11 @@ target_include_directories(${PROJECT} PRIVATE
206
213
src/level_four/tap_cards/controller
207
214
src/level_four/tap_cards/tasks
208
215
209
- common
210
- common/interfaces/card_interface
211
- common/interfaces/desktop_app_interface
212
- common/interfaces/flash_interface
213
- common/interfaces/user_interface
216
+ common
217
+ common/interfaces/card_interface
218
+ common/interfaces/desktop_app_interface
219
+ common/interfaces/flash_interface
220
+ common/interfaces/user_interface
214
221
common/libraries/atecc
215
222
common/libraries/atecc/atcacert
216
223
common/libraries/atecc/basic
@@ -219,26 +226,26 @@ target_include_directories(${PROJECT} PRIVATE
219
226
common/libraries/atecc/hal
220
227
common/libraries/atecc/host
221
228
common/libraries/atecc/jwt
222
- common/libraries/crypto
229
+ common/libraries/crypto
223
230
common/libraries/crypto/mpz_operations
224
231
common/libraries/crypto/aes
225
232
common/libraries/crypto/chacha20poly1305
226
233
common/libraries/crypto/ed25519-donna
227
234
common/libraries/crypto/monero
228
235
common/libraries/crypto/random_gen
229
- common/libraries/proof_of_work
230
- common/libraries/shamir
231
- common/libraries/util
232
- common/startup
236
+ common/libraries/proof_of_work
237
+ common/libraries/shamir
238
+ common/libraries/util
239
+ common/startup
233
240
common/logger
234
- common/coin_support
235
- common/flash
236
- common/Firewall
237
- common/core
238
- common/timers
239
- common/lvgl
241
+ common/coin_support
242
+ common/flash
243
+ common/Firewall
244
+ common/core
245
+ common/timers
246
+ common/lvgl
240
247
common/lvgl/porting
241
- common/lvgl/src
248
+ common/lvgl/src
242
249
common/lvgl/src/lv_core
243
250
common/lvgl/src/lv_draw
244
251
common/lvgl/src/lv_font
@@ -295,14 +302,14 @@ target_include_directories(${PROJECT} PRIVATE
295
302
# Conditional include directories based on BTC_ONLY flag
296
303
IF (BTC_ONLY)
297
304
# BTC-only build: include only Bitcoin family apps
298
- target_include_directories (${PROJECT } PRIVATE
305
+ target_include_directories (${EXECUTABLE } PRIVATE
299
306
apps/btc_family
300
307
apps/btc_family/btc
301
308
apps/inheritance_app
302
309
)
303
310
ELSE ()
304
311
# Full build: include all cryptocurrency apps and their specific common support includes
305
- target_include_directories (${PROJECT } PRIVATE
312
+ target_include_directories (${EXECUTABLE } PRIVATE
306
313
apps/btc_family # BTC family is also part of full build
307
314
apps/btc_family/btc
308
315
apps/btc_family/dash
@@ -328,8 +335,8 @@ ELSE()
328
335
apps/stellar_app
329
336
330
337
# Common coin support sub-module includes for non-BTC builds
331
- common/coin_support/eth_sign_data # Headers for eth_sign_data module
332
- common/coin_support/tron_parse_txn # Headers for tron_parse_txn module
338
+ common/coin_support/eth_sign_data # Headers for eth_sign_data module
339
+ common/coin_support/tron_parse_txn # Headers for tron_parse_txn module
333
340
# If other coin-specific helper headers (e.g., solana_txn_helpers.h, near_context.h)
334
341
# reside in specific subdirectories under common/coin_support/, add those paths here.
335
342
# If they are within the app-specific directories (e.g. apps/solana_app/),
@@ -347,56 +354,56 @@ ELSE()
347
354
)
348
355
ENDIF (BTC_ONLY)
349
356
350
- target_compile_options (${PROJECT } PRIVATE
351
- -mcpu=cortex-m4
352
- -mthumb
353
- -mfpu=fpv4-sp-d16
357
+ target_compile_options (${EXECUTABLE } PRIVATE
358
+ -mcpu=cortex-m4
359
+ -mthumb
360
+ -mfpu=fpv4-sp-d16
354
361
-mfloat-abi=hard
355
- -fdata-sections
362
+ -fdata-sections
356
363
-ffunction-sections
357
- -Wall
358
- -Wno-format-truncation
359
- -Wno-unused-but-set-variable
364
+ -Wall
365
+ -Wno-format-truncation
366
+ -Wno-unused-but-set-variable
360
367
-Wno-return-type
361
368
-D_POSIX_C_SOURCE=200809L
362
369
$<$<CONFIG:Debug>:-g3>
363
- $<$<CONFIG:Release>:-Werror>
370
+ $<$<CONFIG:Release>:-Werror>
364
371
)
365
372
366
- target_link_options (${PROJECT } PRIVATE
373
+ target_link_options (${EXECUTABLE } PRIVATE
367
374
-T${CMAKE_SOURCE_DIR} /STM32L486RGTX_FLASH.ld
368
375
-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16
369
376
-mfloat-abi=hard -u _printf_float -lc -lm -lnosys
370
- -Wl,-Map=${PROJECT } .map,--cref -Wl,--gc-sections
377
+ -Wl,-Map=${PROJECT_NAME } .map,--cref -Wl,--gc-sections
371
378
)
372
379
373
380
# Used to suppress compile time warnings in libraries
374
- file (GLOB_RECURSE LIBRARIES_SRC_DIR
375
- "common/libraries/atecc/*.c"
376
- "common/libraries/atecc/*.h"
377
- "common/lvgl/src/**/*.c"
378
- "common/lvgl/src/**/*.h"
379
- "common/libraries/crypto/*.c"
380
- "common/libraries/crypto/*.h"
381
+ file (GLOB_RECURSE LIBRARIES_SRC_DIR
382
+ "common/libraries/atecc/*.c"
383
+ "common/libraries/atecc/*.h"
384
+ "common/lvgl/src/**/*.c"
385
+ "common/lvgl/src/**/*.h"
386
+ "common/libraries/crypto/*.c"
387
+ "common/libraries/crypto/*.h"
381
388
"stm32-hal/Peripherals/*.c"
382
389
"stm32-hal/Peripherals/*.h" )
383
390
set_source_files_properties (${LIBRARIES_SRC_DIR} PROPERTIES COMPILE_FLAGS "-w" )
384
391
385
392
# Print executable size
386
- add_custom_command (TARGET ${PROJECT }
393
+ add_custom_command (TARGET ${EXECUTABLE }
387
394
POST_BUILD
388
- COMMAND arm-none-eabi-size $<TARGET_FILE: ${PROJECT} > )
395
+ COMMAND arm-none-eabi-size ${EXECUTABLE} )
389
396
390
- # Create hex and bin files
391
- add_custom_command (TARGET ${PROJECT }
397
+ # Create hex file
398
+ add_custom_command (TARGET ${EXECUTABLE }
392
399
POST_BUILD
393
- COMMAND arm-none-eabi-objcopy -O ihex $<TARGET_FILE: ${PROJECT} > ${PROJECT } .hex
394
- COMMAND arm-none-eabi-objcopy -O binary $<TARGET_FILE: ${PROJECT} > ${PROJECT } .bin)
400
+ COMMAND arm-none-eabi-objcopy -O ihex ${EXECUTABLE} ${PROJECT_NAME } .hex
401
+ COMMAND arm-none-eabi-objcopy -O binary ${EXECUTABLE} ${PROJECT_NAME } .bin)
395
402
396
403
if (SIGN_BINARY)
397
- add_custom_command (TARGET ${PROJECT }
404
+ add_custom_command (TARGET ${EXECUTABLE }
398
405
POST_BUILD
399
- COMMAND python3 ${CMAKE_SOURCE_DIR} /utilities/script/index.py add-header --input ="${PROJECT } .bin" --output =${PROJECT } _Header.bin --version =${CMAKE_SOURCE_DIR} /version .txt --private -key=${CMAKE_SOURCE_DIR} /utilities/script/private_key1.h
400
- COMMAND python3 ${CMAKE_SOURCE_DIR} /utilities/script/index.py sign-header --input =${PROJECT } _Header.bin --output =${PROJECT } -signed.bin --private -key=${CMAKE_SOURCE_DIR} /utilities/script/private_key2.h
401
- COMMAND rm ${PROJECT } _Header.bin)
402
- endif ()
406
+ COMMAND python3 ${CMAKE_SOURCE_DIR} /utilities/script/index.py add-header --input ="${PROJECT_NAME } .bin" --output =${PROJECT_NAME } _Header.bin --version =${CMAKE_SOURCE_DIR} /version .txt --private -key=${CMAKE_SOURCE_DIR} /utilities/script/private_key1.h
407
+ COMMAND python3 ${CMAKE_SOURCE_DIR} /utilities/script/index.py sign-header --input =${PROJECT_NAME } _Header.bin --output =${PROJECT_NAME } -signed.bin --private -key=${CMAKE_SOURCE_DIR} /utilities/script/private_key2.h
408
+ COMMAND rm ${PROJECT_NAME } _Header.bin)
409
+ endif ()
0 commit comments