Skip to content

Commit fe1775f

Browse files
Revert "feat: Changing versioning"
This reverts commit 4b242d2.
1 parent ba440cf commit fe1775f

File tree

1 file changed

+95
-88
lines changed

1 file changed

+95
-88
lines changed

utilities/cmake/firmware/firmware.cmake

Lines changed: 95 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
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)
43
set(LINKER_SCRIPT STM32L486RGTX_FLASH.ld)
54
set(STARTUP_FILE startup_stm32l486xx.s)
65
set(CMAKE_C_STANDARD 11)
@@ -43,9 +42,9 @@ set(CORE_COMMON_GENERAL_SOURCES_FROM_SUBDIRS
4342
# or are genuinely generic.
4443
set(CORE_COMMON_SPECIFIC_FILES
4544
"${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"
4948
# common/core/core_flow_init.c is now covered by CORE_COMMON_CORE_SOURCES glob.
5049
# Ensure it and other common/core/*.c files have internal guards where needed.
5150
)
@@ -78,39 +77,39 @@ set(COMMON_NON_BTC_SOURCES "")
7877
IF(NOT BTC_ONLY)
7978
# Source files from common/coin_support/eth_sign_data/
8079
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")
8281
foreach(file ${ETH_SIGN_DATA_COMMON_SRCS_TMP})
8382
list(APPEND ETH_SIGN_DATA_COMMON_SRCS "${file}")
8483
endforeach()
8584

8685
# Source files from common/coin_support/tron_parse_txn/
8786
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")
8988
foreach(file ${TRON_PARSE_TXN_COMMON_SRCS_TMP})
9089
list(APPEND TRON_PARSE_TXN_COMMON_SRCS "${file}")
9190
endforeach()
92-
91+
9392
list(APPEND COMMON_NON_BTC_SOURCES
9493
${ETH_SIGN_DATA_COMMON_SRCS}
9594
${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"
9796
"${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"
9998
# Add other .c files from common/coin_support that are exclusively for non-BTC chains if any
10099
)
101100
ENDIF()
102101

103102

104103
IF(BTC_ONLY)
105104
# BTC-only build: include only Bitcoin-related apps
106-
set(APP_SOURCES
107-
${MANAGER_APP_SOURCES}
105+
set(APP_SOURCES
106+
${MANAGER_APP_SOURCES}
108107
${BTC_FAMILY_SOURCES}
109108
${INHERITANCE_APP_SOURCES}
110109
)
111-
ELSE()
112-
set(APP_SOURCES
113-
${MANAGER_APP_SOURCES}
110+
ELSE()
111+
set(APP_SOURCES
112+
${MANAGER_APP_SOURCES}
114113
${BTC_FAMILY_SOURCES}
115114
${EVM_FAMILY_SOURCES}
116115
${NEAR_APP_SOURCES}
@@ -128,7 +127,7 @@ IF(UNIT_TESTS_SWITCH)
128127
# Add test sources
129128
file(GLOB_RECURSE TEST_SOURCES "tests/*.*")
130129
set(SOURCES ${BASE_SOURCES} ${APP_SOURCES} ${COMMON_NON_BTC_SOURCES} ${TEST_SOURCES})
131-
130+
132131
#exclude src/main.c from the compilation list as it needs to be overriden by unit_tests_main.c
133132
LIST(REMOVE_ITEM SOURCES "${PROJECT_SOURCE_DIR}/src/main.c")
134133

@@ -139,46 +138,54 @@ ELSE()
139138
set(SOURCES ${BASE_SOURCES} ${APP_SOURCES} ${COMMON_NON_BTC_SOURCES})
140139
ENDIF(UNIT_TESTS_SWITCH)
141140

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}
151150
${STARTUP_FILE})
152151

153-
target_compile_definitions(${PROJECT} PRIVATE
154-
-DUSE_HAL_DRIVER
152+
target_compile_definitions(${EXECUTABLE} PRIVATE
153+
-DUSE_HAL_DRIVER
155154
-DSTM32L486xx )
156155

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.
160156
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
166162
ENABLE_HID_WEBUSB_COMM=1)
167163

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+
168173
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
170176
main/config/
171177
)
172178
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
174181
initial/config/
175182
)
176183
else()
177184
message(FATAL_ERROR "Firmware type not specified. Specify using -DFIRMWARE_TYPE=<Type> Type can be Main or Initial")
178185
endif()
179186

180187
# Base include directories (always included)
181-
target_include_directories(${PROJECT} PRIVATE
188+
target_include_directories(${EXECUTABLE} PRIVATE
182189
apps/manager_app # Manager app is always included
183190

184191
src/
@@ -206,11 +213,11 @@ target_include_directories(${PROJECT} PRIVATE
206213
src/level_four/tap_cards/controller
207214
src/level_four/tap_cards/tasks
208215

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
214221
common/libraries/atecc
215222
common/libraries/atecc/atcacert
216223
common/libraries/atecc/basic
@@ -219,26 +226,26 @@ target_include_directories(${PROJECT} PRIVATE
219226
common/libraries/atecc/hal
220227
common/libraries/atecc/host
221228
common/libraries/atecc/jwt
222-
common/libraries/crypto
229+
common/libraries/crypto
223230
common/libraries/crypto/mpz_operations
224231
common/libraries/crypto/aes
225232
common/libraries/crypto/chacha20poly1305
226233
common/libraries/crypto/ed25519-donna
227234
common/libraries/crypto/monero
228235
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
233240
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
240247
common/lvgl/porting
241-
common/lvgl/src
248+
common/lvgl/src
242249
common/lvgl/src/lv_core
243250
common/lvgl/src/lv_draw
244251
common/lvgl/src/lv_font
@@ -295,14 +302,14 @@ target_include_directories(${PROJECT} PRIVATE
295302
# Conditional include directories based on BTC_ONLY flag
296303
IF(BTC_ONLY)
297304
# BTC-only build: include only Bitcoin family apps
298-
target_include_directories(${PROJECT} PRIVATE
305+
target_include_directories(${EXECUTABLE} PRIVATE
299306
apps/btc_family
300307
apps/btc_family/btc
301308
apps/inheritance_app
302309
)
303310
ELSE()
304311
# Full build: include all cryptocurrency apps and their specific common support includes
305-
target_include_directories(${PROJECT} PRIVATE
312+
target_include_directories(${EXECUTABLE} PRIVATE
306313
apps/btc_family # BTC family is also part of full build
307314
apps/btc_family/btc
308315
apps/btc_family/dash
@@ -328,8 +335,8 @@ ELSE()
328335
apps/stellar_app
329336

330337
# 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
333340
# If other coin-specific helper headers (e.g., solana_txn_helpers.h, near_context.h)
334341
# reside in specific subdirectories under common/coin_support/, add those paths here.
335342
# If they are within the app-specific directories (e.g. apps/solana_app/),
@@ -347,56 +354,56 @@ ELSE()
347354
)
348355
ENDIF(BTC_ONLY)
349356

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
354361
-mfloat-abi=hard
355-
-fdata-sections
362+
-fdata-sections
356363
-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
360367
-Wno-return-type
361368
-D_POSIX_C_SOURCE=200809L
362369
$<$<CONFIG:Debug>:-g3>
363-
$<$<CONFIG:Release>:-Werror>
370+
$<$<CONFIG:Release>:-Werror>
364371
)
365372

366-
target_link_options(${PROJECT} PRIVATE
373+
target_link_options(${EXECUTABLE} PRIVATE
367374
-T${CMAKE_SOURCE_DIR}/STM32L486RGTX_FLASH.ld
368375
-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16
369376
-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
371378
)
372379

373380
# 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"
381388
"stm32-hal/Peripherals/*.c"
382389
"stm32-hal/Peripherals/*.h")
383390
set_source_files_properties(${LIBRARIES_SRC_DIR} PROPERTIES COMPILE_FLAGS "-w")
384391

385392
# Print executable size
386-
add_custom_command(TARGET ${PROJECT}
393+
add_custom_command(TARGET ${EXECUTABLE}
387394
POST_BUILD
388-
COMMAND arm-none-eabi-size $<TARGET_FILE:${PROJECT}>)
395+
COMMAND arm-none-eabi-size ${EXECUTABLE})
389396

390-
# Create hex and bin files
391-
add_custom_command(TARGET ${PROJECT}
397+
# Create hex file
398+
add_custom_command(TARGET ${EXECUTABLE}
392399
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)
395402

396403
if (SIGN_BINARY)
397-
add_custom_command(TARGET ${PROJECT}
404+
add_custom_command(TARGET ${EXECUTABLE}
398405
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

Comments
 (0)