# pylint: disable=E0602 import os import tools TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) if TREZOR_MODEL in ('1', ): # skip boardloader build env = Environment() def build_ble_firmware(target,source,env): print(f'BLE FIRMWARE: nothing to build for Model {TREZOR_MODEL}') program_bin = env.Command( target='ble_firmware.bin', source=None, action=build_ble_firmware ) Return() CCFLAGS_MOD = '' CPPPATH_MOD = [] CPPDEFINES_MOD = [] SOURCE_MOD = [] CCFLAGS_MOD += '-Wno-sequence-point ' if int(ARGUMENTS.get('PRODUCTION', 0)) == 0: # Build for monitor debug mode. MMD = True else: MMD = False # C flags common to all targets CPPDEFINES_MOD += [ 'CONFIG_GPIO_AS_PINRESET', 'FLOAT_ABI_HARD', 'NRF52833_XXAA', 'SOFTDEVICE_PRESENT', ('NRF_SD_BLE_API_VERSION', '7'), 'APP_TIMER_V2', 'APP_TIMER_V2_RTC1_ENABLED', 'S140', ('__HEAP_SIZE','8192'), ('__STACK_SIZE','8192'), ('uECC_ENABLE_VLI_API', '0'), ('uECC_OPTIMIZATION_LEVEL', '3'), ('uECC_SQUARE_FUNC', '0'), ('uECC_SUPPORT_COMPRESSED_POINT', '0'), ('uECC_VLI_NATIVE_LITTLE_ENDIAN', '1'), ] CPPPATH_MOD += [ ] CPPDEFINES_MOD += [ ] SOURCE_MOD += [ ] CPPPATH_MOD += [ 'embed/sdk/nrf52/components/nfc/ndef/generic/message', 'embed/sdk/nrf52/components/nfc/t2t_lib', 'embed/sdk/nrf52/components/nfc/t4t_parser/hl_detection_procedure', 'embed/sdk/nrf52/components/ble/ble_services/ble_ancs_c', 'embed/sdk/nrf52/components/ble/ble_services/ble_ias_c', 'embed/sdk/nrf52/components/libraries/pwm', 'embed/sdk/nrf52/components/libraries/usbd/class/cdc/acm', 'embed/sdk/nrf52/components/libraries/usbd/class/hid/generic', 'embed/sdk/nrf52/components/libraries/usbd/class/msc', 'embed/sdk/nrf52/components/libraries/usbd/class/hid', 'embed/sdk/nrf52/modules/nrfx/hal', 'embed/sdk/nrf52/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser', 'embed/sdk/nrf52/components/libraries/log', 'embed/sdk/nrf52/components/ble/ble_services/ble_gls', 'embed/sdk/nrf52/components/libraries/fstorage', 'embed/sdk/nrf52/components/nfc/ndef/text', 'embed/sdk/nrf52/components/libraries/mutex', 'embed/sdk/nrf52/components/libraries/gfx', 'embed/sdk/nrf52/components/libraries/bootloader/ble_dfu', 'embed/sdk/nrf52/components/nfc/ndef/connection_handover/common', 'embed/sdk/nrf52/components/libraries/fifo', 'embed/sdk/nrf52/components/nfc/ndef/generic/record', 'embed/sdk/nrf52/components/nfc/t4t_parser/cc_file', 'embed/sdk/nrf52/components/ble/ble_advertising', 'embed/sdk/nrf52/external/utf_converter', 'embed/sdk/nrf52/components/ble/ble_services/ble_bas_c', 'embed/sdk/nrf52/modules/nrfx/drivers/include', 'embed/sdk/nrf52/components/libraries/experimental_task_manager', 'embed/sdk/nrf52/components/ble/ble_services/ble_hrs_c', 'embed/sdk/nrf52/components/softdevice/s140/headers/nrf52', 'embed/sdk/nrf52/components/nfc/ndef/connection_handover/le_oob_rec', 'embed/sdk/nrf52/components/libraries/queue', 'embed/sdk/nrf52/components/libraries/pwr_mgmt', 'embed/sdk/nrf52/components/ble/ble_dtm', 'embed/sdk/nrf52/components/toolchain/cmsis/include', 'embed/sdk/nrf52/components/ble/ble_services/ble_rscs_c', 'embed/sdk/nrf52/components/ble/common', 'embed/sdk/nrf52/components/ble/ble_services/ble_lls', 'embed/sdk/nrf52/components/nfc/platform', 'embed/sdk/nrf52/components/nfc/ndef/connection_handover/ac_rec', 'embed/sdk/nrf52/components/ble/ble_services/ble_bas', 'embed/sdk/nrf52/components/libraries/mpu', 'embed/sdk/nrf52/components/libraries/experimental_section_vars', 'embed/sdk/nrf52/components/ble/ble_services/ble_ans_c', 'embed/sdk/nrf52/components/libraries/slip', 'embed/sdk/nrf52/components/libraries/delay', 'embed/sdk/nrf52/components/libraries/csense_drv', 'embed/sdk/nrf52/components/libraries/memobj', 'embed/sdk/nrf52/components/ble/ble_services/ble_nus_c', 'embed/sdk/nrf52/components/softdevice/common', 'embed/sdk/nrf52/components/ble/ble_services/ble_ias', 'embed/sdk/nrf52/components/libraries/usbd/class/hid/mouse', 'embed/sdk/nrf52/components/libraries/low_power_pwm', 'embed/sdk/nrf52/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser', 'embed/sdk/nrf52/components/ble/ble_services/ble_dfu', 'embed/sdk/nrf52/external/fprintf', 'embed/sdk/nrf52/components/libraries/svc', 'embed/sdk/nrf52/components/libraries/atomic', 'embed/sdk/nrf52/components', 'embed/sdk/nrf52/components/libraries/scheduler', 'embed/sdk/nrf52/components/libraries/cli', 'embed/sdk/nrf52/components/ble/ble_services/ble_lbs', 'embed/sdk/nrf52/components/ble/ble_services/ble_hts', 'embed/sdk/nrf52/components/ble/ble_services/ble_cts_c', 'embed/sdk/nrf52/components/libraries/crc16', 'embed/sdk/nrf52/components/nfc/t4t_parser/apdu', 'embed/sdk/nrf52/components/libraries/util', 'embed/sdk/nrf52/components/libraries/usbd/class/cdc', 'embed/sdk/nrf52/components/libraries/csense', 'embed/sdk/nrf52/components/libraries/balloc', 'embed/sdk/nrf52/components/libraries/ecc', 'embed/sdk/nrf52/components/libraries/hardfault', 'embed/sdk/nrf52/components/ble/ble_services/ble_cscs', 'embed/sdk/nrf52/components/libraries/uart', 'embed/sdk/nrf52/components/libraries/hci', 'embed/sdk/nrf52/components/libraries/usbd/class/hid/kbd', 'embed/sdk/nrf52/components/libraries/timer', 'embed/sdk/nrf52/components/libraries/queue', 'embed/sdk/nrf52/components/softdevice/s140/headers', 'embed/sdk/nrf52/integration/nrfx', 'embed/sdk/nrf52/components/nfc/t4t_parser/tlv', 'embed/sdk/nrf52/components/libraries/sortlist', 'embed/sdk/nrf52/components/libraries/spi_mngr', 'embed/sdk/nrf52/components/libraries/led_softblink', 'embed/sdk/nrf52/components/nfc/ndef/conn_hand_parser', 'embed/sdk/nrf52/components/libraries/sdcard', 'embed/sdk/nrf52/components/nfc/ndef/parser/record', 'embed/sdk/nrf52/modules/nrfx/mdk', 'embed/sdk/nrf52/components/ble/ble_link_ctx_manager', 'embed/sdk/nrf52/components/ble/ble_services/ble_nus', 'embed/sdk/nrf52/components/libraries/twi_mngr', 'embed/sdk/nrf52/components/ble/ble_services/ble_hids', 'embed/sdk/nrf52/components/libraries/strerror', 'embed/sdk/nrf52/components/libraries/crc32', 'embed/sdk/nrf52/components/nfc/ndef/connection_handover/ble_oob_advdata', 'embed/sdk/nrf52/components/nfc/t2t_parser', 'embed/sdk/nrf52/components/nfc/ndef/connection_handover/ble_pair_msg', 'embed/sdk/nrf52/components/libraries/usbd/class/audio', 'embed/sdk/nrf52/components/nfc/t4t_lib', 'embed/sdk/nrf52/components/ble/peer_manager', 'embed/sdk/nrf52/components/libraries/mem_manager', 'embed/sdk/nrf52/components/libraries/ringbuf', 'embed/sdk/nrf52/components/ble/ble_services/ble_tps', 'embed/sdk/nrf52/components/nfc/ndef/parser/message', 'embed/sdk/nrf52/components/ble/ble_services/ble_dis', 'embed/sdk/nrf52/components/nfc/ndef/uri', 'embed/sdk/nrf52/components/ble/nrf_ble_gatt', 'embed/sdk/nrf52/components/ble/nrf_ble_qwr', 'embed/sdk/nrf52/components/libraries/gpiote', 'embed/sdk/nrf52/components/libraries/button', 'embed/sdk/nrf52/modules/nrfx', 'embed/sdk/nrf52/components/libraries/twi_sensor', 'embed/sdk/nrf52/integration/nrfx/legacy', 'embed/sdk/nrf52/components/libraries/usbd', 'embed/sdk/nrf52/components/nfc/ndef/connection_handover/ep_oob_rec', 'embed/sdk/nrf52/external/segger_rtt', 'embed/sdk/nrf52/components/libraries/atomic_fifo', 'embed/sdk/nrf52/components/ble/ble_services/ble_lbs_c', 'embed/sdk/nrf52/components/nfc/ndef/connection_handover/ble_pair_lib', 'embed/sdk/nrf52/components/libraries/crypto', 'embed/sdk/nrf52/components/libraries/crypto/backend/cc310', 'embed/sdk/nrf52/components/libraries/crypto/backend/cc310_bl', 'embed/sdk/nrf52/components/libraries/crypto/backend/micro_ecc', 'embed/sdk/nrf52/components/libraries/crypto/backend/mbedtls', 'embed/sdk/nrf52/components/libraries/crypto/backend/oberon', 'embed/sdk/nrf52/components/libraries/crypto/backend/optiga', 'embed/sdk/nrf52/components/libraries/crypto/backend/nrf_sw', 'embed/sdk/nrf52/components/libraries/crypto/backend/nrf_hw', 'embed/sdk/nrf52/components/libraries/crypto/backend/cifra', 'embed/sdk/nrf52/components/ble/ble_racp', 'embed/sdk/nrf52/components/libraries/fds', 'embed/sdk/nrf52/components/nfc/ndef/launchapp', 'embed/sdk/nrf52/components/libraries/atomic_flags', 'embed/sdk/nrf52/components/ble/ble_services/ble_hrs', 'embed/sdk/nrf52/components/ble/ble_services/ble_rscs', 'embed/sdk/nrf52/components/nfc/ndef/connection_handover/hs_rec', 'embed/sdk/nrf52/components/nfc/ndef/conn_hand_parser/ac_rec_parser', 'embed/sdk/nrf52/components/libraries/stack_guard', 'embed/sdk/nrf52/components/libraries/stack_info', 'embed/sdk/nrf52/components/libraries/log/src', 'embed/sdk/nrf52/external/mbedtls/include', 'embed', 'embed/trezorhal/boards', ] SOURCE_MOD += [ ] SOURCE_NRFHAL_AS = [ 'embed/sdk/nrf52/modules/nrfx/mdk/gcc_startup_nrf52833.S', ] SOURCE_NRFHAL = [ 'embed/sdk/nrf52/components/libraries/log/src/nrf_log_frontend.c', 'embed/sdk/nrf52/components/libraries/log/src/nrf_log_str_formatter.c', 'embed/sdk/nrf52/components/libraries/button/app_button.c', 'embed/sdk/nrf52/components/libraries/util/app_error.c', 'embed/sdk/nrf52/components/libraries/util/app_error_handler_gcc.c', 'embed/sdk/nrf52/components/libraries/util/app_error_weak.c', 'embed/sdk/nrf52/components/libraries/fifo/app_fifo.c', 'embed/sdk/nrf52/components/libraries/scheduler/app_scheduler.c', 'embed/sdk/nrf52/components/libraries/timer/app_timer2.c', 'embed/sdk/nrf52/components/libraries/uart/app_uart_fifo.c', 'embed/sdk/nrf52/components/libraries/util/app_util_platform.c', 'embed/sdk/nrf52/components/libraries/timer/drv_rtc.c', 'embed/sdk/nrf52/components/libraries/hardfault/hardfault_implementation.c', 'embed/sdk/nrf52/components/libraries/util/nrf_assert.c', 'embed/sdk/nrf52/components/libraries/atomic_fifo/nrf_atfifo.c', 'embed/sdk/nrf52/components/libraries/atomic_flags/nrf_atflags.c', 'embed/sdk/nrf52/components/libraries/atomic/nrf_atomic.c', 'embed/sdk/nrf52/components/libraries/balloc/nrf_balloc.c', 'embed/sdk/nrf52/external/fprintf/nrf_fprintf.c', 'embed/sdk/nrf52/external/fprintf/nrf_fprintf_format.c', 'embed/sdk/nrf52/components/libraries/memobj/nrf_memobj.c', 'embed/sdk/nrf52/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c', 'embed/sdk/nrf52/components/libraries/ringbuf/nrf_ringbuf.c', 'embed/sdk/nrf52/components/libraries/experimental_section_vars/nrf_section_iter.c', 'embed/sdk/nrf52/components/libraries/sortlist/nrf_sortlist.c', 'embed/sdk/nrf52/components/libraries/strerror/nrf_strerror.c', 'embed/sdk/nrf52/components/libraries/uart/retarget.c', 'embed/sdk/nrf52/components/libraries/queue/nrf_queue.c', 'embed/sdk/nrf52/modules/nrfx/mdk/system_nrf52833.c', 'embed/sdk/nrf52/integration/nrfx/legacy/nrf_drv_clock.c', 'embed/sdk/nrf52/integration/nrfx/legacy/nrf_drv_uart.c', 'embed/sdk/nrf52/integration/nrfx/legacy/nrf_drv_spi.c', 'embed/sdk/nrf52/integration/nrfx/legacy/nrf_drv_rng.c', 'embed/sdk/nrf52/modules/nrfx/soc/nrfx_atomic.c', 'embed/sdk/nrf52/modules/nrfx/drivers/src/nrfx_clock.c', 'embed/sdk/nrf52/modules/nrfx/drivers/src/nrfx_gpiote.c', 'embed/sdk/nrf52/modules/nrfx/drivers/src/prs/nrfx_prs.c', 'embed/sdk/nrf52/modules/nrfx/drivers/src/nrfx_uart.c', 'embed/sdk/nrf52/modules/nrfx/drivers/src/nrfx_uarte.c', 'embed/sdk/nrf52/modules/nrfx/drivers/src/nrfx_rng.c', 'embed/sdk/nrf52/modules/nrfx/drivers/src/nrfx_spi.c', 'embed/sdk/nrf52/modules/nrfx/drivers/src/nrfx_spim.c', 'embed/sdk/nrf52/components/ble/common/ble_advdata.c', 'embed/sdk/nrf52/components/ble/ble_advertising/ble_advertising.c', 'embed/sdk/nrf52/components/ble/common/ble_conn_params.c', 'embed/sdk/nrf52/components/ble/common/ble_conn_state.c', 'embed/sdk/nrf52/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.c', 'embed/sdk/nrf52/components/ble/common/ble_srv_common.c', 'embed/sdk/nrf52/components/ble/nrf_ble_gatt/nrf_ble_gatt.c', 'embed/sdk/nrf52/components/ble/nrf_ble_qwr/nrf_ble_qwr.c', 'embed/sdk/nrf52/external/utf_converter/utf.c', 'embed/sdk/nrf52/components/softdevice/common/nrf_sdh.c', 'embed/sdk/nrf52/components/softdevice/common/nrf_sdh_ble.c', 'embed/sdk/nrf52/components/softdevice/common/nrf_sdh_soc.c', 'embed/sdk/nrf52/components/ble/peer_manager/gatt_cache_manager.c', 'embed/sdk/nrf52/components/ble/peer_manager/gatts_cache_manager.c', 'embed/sdk/nrf52/components/ble/peer_manager/id_manager.c', 'embed/sdk/nrf52/components/ble/peer_manager/peer_data_storage.c', 'embed/sdk/nrf52/components/ble/peer_manager/peer_database.c', 'embed/sdk/nrf52/components/ble/peer_manager/peer_id.c', 'embed/sdk/nrf52/components/ble/peer_manager/peer_manager.c', 'embed/sdk/nrf52/components/ble/peer_manager/peer_manager_handler.c', 'embed/sdk/nrf52/components/ble/peer_manager/pm_buffer.c', 'embed/sdk/nrf52/components/ble/peer_manager/nrf_ble_lesc.c', 'embed/sdk/nrf52/components/libraries/fds/fds.c', 'embed/sdk/nrf52/components/ble/peer_manager/security_manager.c', 'embed/sdk/nrf52/components/ble/peer_manager/security_dispatcher.c', 'embed/sdk/nrf52/components/libraries/fstorage/nrf_fstorage.c', 'embed/sdk/nrf52/components/libraries/fstorage/nrf_fstorage_sd.c', 'embed/sdk/nrf52/components/ble/ble_services/ble_dis/ble_dis.c', 'embed/sdk/nrf52/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.c', 'embed/sdk/nrf52/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.c', 'embed/sdk/nrf52/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.c', 'embed/sdk/nrf52/components/libraries/crypto/backend/nrf_hw/nrf_hw_backend_rng_mbedtls.c', 'embed/sdk/nrf52/components/libraries/crypto/nrf_crypto_ecc.c', 'embed/sdk/nrf52/components/libraries/crypto/nrf_crypto_ecdsa.c', 'embed/sdk/nrf52/components/libraries/crypto/nrf_crypto_ecdh.c', 'embed/sdk/nrf52/components/libraries/crypto/nrf_crypto_hash.c', 'embed/sdk/nrf52/components/libraries/crypto/nrf_crypto_init.c', 'embed/sdk/nrf52/components/libraries/crypto/nrf_crypto_shared.c', 'embed/sdk/nrf52/components/libraries/crypto/nrf_crypto_rng.c', 'embed/sdk/nrf52/external/mbedtls/library/ctr_drbg.c', 'embed/sdk/nrf52/external/mbedtls/library/aes.c', 'embed/sdk/nrf52/external/mbedtls/library/platform.c', 'embed/sdk/nrf52/external/mbedtls/library/platform_util.c', ] SOURCE_NANOPB = [ 'vendor/nanopb/pb_common.c', 'vendor/nanopb/pb_decode.c', 'vendor/nanopb/pb_encode.c', ] SOURCE_BLE_FIRMWARE = [ 'embed/ble_firmware/main.c', 'embed/ble_firmware/ble_nus.c', 'embed/ble_firmware/int_comm.c', 'embed/ble_firmware/dis.c', 'embed/ble_firmware/pm.c', 'embed/ble_firmware/power.c', 'embed/ble_firmware/advertising.c', 'embed/ble_firmware/connection.c', 'embed/bootloader/protob/messages.pb.c', 'embed/lib/protob_helpers.c', 'embed/ble_bootloader/uecc/uECC.c', ] if MMD: CPPDEFINES_MOD += [ 'DEBUG', 'DEBUG_NRF', 'MMD' ] SOURCE_BLE_FIRMWARE += [ 'embed/segger/SEGGER_MMD/JLINK_MONITOR.c', 'embed/segger/SEGGER_MMD/JLINK_MONITOR_ISR_SES.S' ] SOURCE_NRFHAL += [ 'embed/sdk/nrf52/components/libraries/log/src/nrf_log_backend_rtt.c', 'embed/sdk/nrf52/components/libraries/log/src/nrf_log_backend_serial.c', 'embed/sdk/nrf52/components/libraries/log/src/nrf_log_backend_uart.c', 'embed/sdk/nrf52/components/libraries/log/src/nrf_log_default_backends.c', 'embed/sdk/nrf52/external/segger_rtt/SEGGER_RTT.c', 'embed/sdk/nrf52/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c', 'embed/sdk/nrf52/external/segger_rtt/SEGGER_RTT_printf.c', ] CPPPATH_MOD += [ 'embed/segger/SEGGER_MMD' ] env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'))) env.Replace( CP='cp', AS='arm-none-eabi-as', AR='arm-none-eabi-ar', CC='arm-none-eabi-gcc', LINK='arm-none-eabi-gcc', SIZE='arm-none-eabi-size', STRIP='arm-none-eabi-strip', OBJCOPY='arm-none-eabi-objcopy', PYTHON='python', MAKECMAKELISTS='$PYTHON tools/make_cmakelists.py', ) env.Replace( TREZOR_MODEL=TREZOR_MODEL, ) CPU_ASFLAGS = '-mthumb -mabi=aapcs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16' CPU_CCFLAGS = '-mthumb -mabi=aapcs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 ' env.Replace( COPT=env.get('ENV').get('OPTIMIZE', '-Og'), CCFLAGS='$COPT ' '-g3 ' '-std=c99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -Wno-missing-braces -Wno-unused-function ' '-fdata-sections -ffunction-sections ' '-fno-strict-aliasing ' '-fno-builtin ' '-fshort-enums ' + CPU_CCFLAGS + CCFLAGS_MOD, LINKFLAGS='-Lembed/sdk/nrf52/modules/nrfx/mdk -T embed/ble_firmware/memory.ld -Wl,--gc-sections --specs=nano.specs -Wl,-Map=build/ble_firmware/ble_firmware.map -Wl,--warn-common -Wl,--print-memory-usage', CPPPATH=[ 'embed/ble_firmware', 'embed/bootloader/protob', 'embed/sdk/nrf52', 'embed/lib', 'vendor/nanopb', 'embed/ble_bootloader/uecc', ] + CPPPATH_MOD, CPPDEFINES=[ 'BLE_FIRMWARE', 'TREZOR_MODEL_'+TREZOR_MODEL, ] + CPPDEFINES_MOD, ASFLAGS=CPU_ASFLAGS, ASPPFLAGS='$CFLAGS $CCFLAGS', ) # # Program objects # obj_program = [] obj_program += env.Object(source=SOURCE_BLE_FIRMWARE) obj_program += env.Object(source=SOURCE_NRFHAL_AS, COPT='-O0') obj_program += env.Object(source=SOURCE_NRFHAL) obj_program += env.Object(source=SOURCE_NANOPB) obj_program += env.Object(source=SOURCE_MOD) env.Replace( ALLSOURCES=SOURCE_NRFHAL_AS + SOURCE_MOD + SOURCE_BLE_FIRMWARE + SOURCE_NRFHAL, ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES'])) cmake_gen = env.Command( target='CMakeLists.txt', source='', action='$MAKECMAKELISTS --sources $ALLSOURCES --dirs $CPPPATH --defs $ALLDEFS', ) LIB_FILES = [ ] program_elf = env.Command( target='ble_firmware.elf', source=obj_program, action= '$LINK -o $TARGET $CCFLAGS $CFLAGS $LINKFLAGS $SOURCES ' + ' '.join(LIB_FILES) + ' -lc -lnosys -lm', ) BINARY_NAME = f"build/ble_firmware/ble_firmware-{tools.get_model_identifier(TREZOR_MODEL)}" BINARY_NAME += "-" + tools.get_version('embed/ble_firmware/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" BINARY_NAME += ".bin" if CMAKELISTS != 0: env.Depends(program_elf, cmake_gen) program_hex = env.Command( target='ble_firmware.hex', source=program_elf, action='$OBJCOPY -O ihex $SOURCE $TARGET', ) program_pkg = env.Command( target='ble_firmware.zip', source=program_hex, action=[ f'python ../../pc-nrfutil/nordicsemi/ pkg generate --hw-version 52 --sd-req=0x100 --application $SOURCE --app-boot-validation VALIDATE_ECDSA_P256_SHA256 --key-file ./embed/ble_bootloader/priv.pem $TARGET --application-version-string {tools.get_version("embed/ble_firmware/version.h")}' ], ) settings = env.Command( target='settings.hex', source=program_hex, action=f'python ../../pc-nrfutil/nordicsemi/ settings generate --family NRF52 --application $SOURCE --app-boot-validation VALIDATE_ECDSA_P256_SHA256 --application-version-string {tools.get_version("embed/ble_firmware/version.h")} --bootloader-version {tools.get_version_int("embed/ble_bootloader/version.h")} --bl-settings-version 2 --sd-boot-validation VALIDATE_ECDSA_P256_SHA256 --softdevice ./embed/sdk/nrf52/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex --key-file ./embed/ble_bootloader/priv.pem $TARGET', ) program_merge = env.Command( target='ble_firmware_merged.hex', source=[program_hex, settings], action='mergehex -m $SOURCES -o $TARGET', ) program_bin = env.Command( target='ble_firmware.bin', source=program_elf, action=[ '$OBJCOPY -O binary $SOURCE $TARGET', '$CP $TARGET ' + BINARY_NAME, ], ) env.Depends(program_bin, program_hex) env.Depends(program_pkg, program_hex) env.Depends(settings, program_hex) env.Depends(program_bin, program_pkg) env.Depends(program_merge, settings) env.Depends(program_merge, program_hex) env.Depends(program_bin, program_merge)