cmake_minimum_required(VERSION 3.10) project(pinetime-app C CXX ASM) # define some variables just for this example to determine file locations set(NRF_PROJECT_NAME pinetime-app) set(NRF_BOARD pca10040) # check if all the necessary tools paths have been provided. if (NOT NRF5_SDK_PATH) message(FATAL_ERROR "The path to the nRF5 SDK (NRF5_SDK_PATH) must be set.") endif () if (DEFINED ARM_NONE_EABI_TOOLCHAIN_PATH) set(ARM_NONE_EABI_TOOLCHAIN_BIN_PATH ${ARM_NONE_EABI_TOOLCHAIN_PATH}/bin) endif () if (NOT NRF_TARGET MATCHES "nrf52") message(FATAL_ERROR "Only rRF52 boards are supported right now") endif () # Setup toolchain include(${CMAKE_SOURCE_DIR}/cmake-nRF5x/arm-gcc-toolchain.cmake) if (NOT DEFINED ARM_GCC_TOOLCHAIN) message(FATAL_ERROR "The toolchain must be set up before calling this macro") endif () set(CMAKE_OSX_SYSROOT "/") set(CMAKE_OSX_DEPLOYMENT_TARGET "") set(SDK_SOURCE_FILES # Startup "${NRF5_SDK_PATH}/modules/nrfx/mdk/system_nrf52.c" "${NRF5_SDK_PATH}/modules/nrfx/mdk/gcc_startup_nrf52.S" # Base SDK "${NRF5_SDK_PATH}/components/boards/boards.c" "${NRF5_SDK_PATH}/integration/nrfx/legacy/nrf_drv_clock.c" "${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_clock.c" "${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_gpiote.c" "${NRF5_SDK_PATH}/modules/nrfx/soc/nrfx_atomic.c" "${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_saadc.c" # FreeRTOS ${NRF5_SDK_PATH}/external/freertos/source/croutine.c ${NRF5_SDK_PATH}/external/freertos/source/event_groups.c ${NRF5_SDK_PATH}/external/freertos/source/portable/MemMang/heap_4.c ${NRF5_SDK_PATH}/external/freertos/source/list.c ${NRF5_SDK_PATH}/external/freertos/source/queue.c ${NRF5_SDK_PATH}/external/freertos/source/stream_buffer.c ${NRF5_SDK_PATH}/external/freertos/source/tasks.c ${NRF5_SDK_PATH}/external/freertos/source/timers.c ${NRF5_SDK_PATH}/components/libraries/timer/app_timer_freertos.c # Libs "${NRF5_SDK_PATH}/components/libraries/atomic/nrf_atomic.c" "${NRF5_SDK_PATH}/components/libraries/balloc/nrf_balloc.c" "${NRF5_SDK_PATH}/components/libraries/util/nrf_assert.c" "${NRF5_SDK_PATH}/components/libraries/util/app_error.c" "${NRF5_SDK_PATH}/components/libraries/util/app_error_weak.c" "${NRF5_SDK_PATH}/components/libraries/util/app_error_handler_gcc.c" "${NRF5_SDK_PATH}/components/libraries/util/app_util_platform.c" "${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_backend_rtt.c" "${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_backend_serial.c" "${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_default_backends.c" "${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_frontend.c" "${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_str_formatter.c" "${NRF5_SDK_PATH}/components/libraries/memobj/nrf_memobj.c" "${NRF5_SDK_PATH}/components/libraries/ringbuf/nrf_ringbuf.c" "${NRF5_SDK_PATH}/components/libraries/strerror/nrf_strerror.c" # Segger RTT "${NRF5_SDK_PATH}/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c" "${NRF5_SDK_PATH}/external/segger_rtt/SEGGER_RTT.c" "${NRF5_SDK_PATH}/external/segger_rtt/SEGGER_RTT_printf.c" # Other "${NRF5_SDK_PATH}/external/utf_converter/utf.c" "${NRF5_SDK_PATH}/external/fprintf/nrf_fprintf.c" "${NRF5_SDK_PATH}/external/fprintf/nrf_fprintf_format.c" # TWI "${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_twi.c" # GPIOTE "${NRF5_SDK_PATH}/components/libraries/gpiote/app_gpiote.c" ) set(TINYCRYPT_SRC libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c libs/mynewt-nimble/ext/tinycrypt/src/utils.c ) set(NIMBLE_SRC libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c libs/mynewt-nimble/porting/npl/freertos/src/npl_os_freertos.c libs/mynewt-nimble/nimble/host/src/ble_hs.c libs/mynewt-nimble/nimble/host/src/ble_hs_hci_evt.c libs/mynewt-nimble/nimble/host/src/ble_l2cap_sig_cmd.c libs/mynewt-nimble/nimble/host/src/ble_l2cap_sig.c libs/mynewt-nimble/nimble/host/src/ble_l2cap.c libs/mynewt-nimble/nimble/host/src/ble_hs_mbuf.c libs/mynewt-nimble/nimble/host/src/ble_sm.c libs/mynewt-nimble/nimble/host/src/ble_gap.c libs/mynewt-nimble/nimble/host/src/ble_gatts.c libs/mynewt-nimble/nimble/host/src/ble_gattc.c libs/mynewt-nimble/nimble/host/src/ble_hs_conn.c libs/mynewt-nimble/nimble/host/src/ble_att_svr.c libs/mynewt-nimble/nimble/host/src/ble_store.c libs/mynewt-nimble/nimble/host/src/ble_store_util.c libs/mynewt-nimble/nimble/host/src/ble_hs_pvcy.c libs/mynewt-nimble/nimble/host/src/ble_hs_hci.c libs/mynewt-nimble/nimble/host/src/ble_hs_log.c libs/mynewt-nimble/nimble/host/src/ble_hs_hci_util.c libs/mynewt-nimble/nimble/host/src/ble_hs_hci_cmd.c libs/mynewt-nimble/nimble/host/src/ble_hs_cfg.c libs/mynewt-nimble/nimble/host/src/ble_uuid.c libs/mynewt-nimble/nimble/host/src/ble_hs_id.c libs/mynewt-nimble/nimble/host/src/ble_hs_misc.c libs/mynewt-nimble/nimble/host/src/ble_att.c libs/mynewt-nimble/nimble/host/src/ble_att_clt.c libs/mynewt-nimble/nimble/host/src/ble_att_svr.c libs/mynewt-nimble/nimble/host/src/ble_att_cmd.c libs/mynewt-nimble/nimble/host/src/ble_hs_atomic.c libs/mynewt-nimble/nimble/host/src/ble_hs_adv.c libs/mynewt-nimble/nimble/host/src/ble_hs_flow.c libs/mynewt-nimble/nimble/host/src/ble_sm.c libs/mynewt-nimble/nimble/host/src/ble_sm_cmd.c libs/mynewt-nimble/nimble/host/src/ble_sm_lgcy.c libs/mynewt-nimble/nimble/host/src/ble_sm_alg.c libs/mynewt-nimble/nimble/host/src/ble_hs_mqueue.c libs/mynewt-nimble/nimble/host/src/ble_hs_stop.c libs/mynewt-nimble/nimble/host/src/ble_hs_startup.c libs/mynewt-nimble/nimble/host/store/ram/src/ble_store_ram.c libs/mynewt-nimble/nimble/host/src/ble_monitor.c libs/mynewt-nimble/nimble/transport/ram/src/ble_hci_ram.c libs/mynewt-nimble/nimble/controller/src/ble_ll.c libs/mynewt-nimble/nimble/controller/src/ble_ll_rand.c libs/mynewt-nimble/nimble/controller/src/ble_ll_conn.c libs/mynewt-nimble/nimble/controller/src/ble_ll_ctrl.c libs/mynewt-nimble/nimble/controller/src/ble_ll_hci.c libs/mynewt-nimble/nimble/controller/src/ble_ll_conn_hci.c libs/mynewt-nimble/nimble/controller/src/ble_ll_utils.c libs/mynewt-nimble/nimble/controller/src/ble_ll_scan.c libs/mynewt-nimble/nimble/controller/src/ble_ll_whitelist.c libs/mynewt-nimble/nimble/controller/src/ble_ll_adv.c libs/mynewt-nimble/nimble/controller/src/ble_ll_sched.c libs/mynewt-nimble/nimble/controller/src/ble_ll_supp_cmd.c libs/mynewt-nimble/nimble/controller/src/ble_ll_hci_ev.c libs/mynewt-nimble/nimble/controller/src/ble_ll_rfmgmt.c libs/mynewt-nimble/porting/nimble/src/os_cputime.c libs/mynewt-nimble/porting/nimble/src/os_cputime_pwr2.c libs/mynewt-nimble/porting/nimble/src/os_mbuf.c libs/mynewt-nimble/porting/nimble/src/os_mempool.c libs/mynewt-nimble/porting/nimble/src/hal_timer.c libs/mynewt-nimble/porting/nimble/src/mem.c libs/mynewt-nimble/porting/nimble/src/endian.c libs/mynewt-nimble/porting/nimble/src/os_msys_init.c libs/mynewt-nimble/nimble/drivers/nrf52/src/ble_hw.c libs/mynewt-nimble/nimble/drivers/nrf52/src/ble_phy.c libs/mynewt-nimble/nimble/host/services/gap/src/ble_svc_gap.c libs/mynewt-nimble/nimble/host/services/gatt/src/ble_svc_gatt.c libs/mynewt-nimble/nimble/host/util/src/addr.c ) set(LVGL_SRC libs/lv_conf.h libs/lvgl/lvgl.h libs/lvgl/src/lv_core/lv_obj.c libs/lvgl/src/lv_core/lv_obj.h libs/lvgl/src/lv_core/lv_group.c libs/lvgl/src/lv_core/lv_group.h libs/lvgl/src/lv_core/lv_disp.c libs/lvgl/src/lv_core/lv_disp.h libs/lvgl/src/lv_core/lv_debug.h libs/lvgl/src/lv_core/lv_debug.c libs/lvgl/src/lv_core/lv_indev.c libs/lvgl/src/lv_core/lv_indev.h libs/lvgl/src/lv_core/lv_refr.c libs/lvgl/src/lv_core/lv_refr.h libs/lvgl/src/lv_core/lv_style.c libs/lvgl/src/lv_core/lv_style.h libs/lvgl/src/lv_misc/lv_anim.c libs/lvgl/src/lv_misc/lv_anim.h libs/lvgl/src/lv_misc/lv_async.h libs/lvgl/src/lv_misc/lv_async.c libs/lvgl/src/lv_misc/lv_fs.c libs/lvgl/src/lv_misc/lv_fs.h libs/lvgl/src/lv_misc/lv_task.c libs/lvgl/src/lv_misc/lv_task.h libs/lvgl/src/lv_misc/lv_area.c libs/lvgl/src/lv_misc/lv_area.h libs/lvgl/src/lv_misc/lv_bidi.c libs/lvgl/src/lv_misc/lv_bidi.h libs/lvgl/src/lv_misc/lv_circ.c libs/lvgl/src/lv_misc/lv_circ.h libs/lvgl/src/lv_misc/lv_color.c libs/lvgl/src/lv_misc/lv_color.h libs/lvgl/src/lv_misc/lv_fs.c libs/lvgl/src/lv_misc/lv_fs.h libs/lvgl/src/lv_misc/lv_gc.c libs/lvgl/src/lv_misc/lv_gc.h libs/lvgl/src/lv_misc/lv_ll.c libs/lvgl/src/lv_misc/lv_ll.h libs/lvgl/src/lv_misc/lv_log.c libs/lvgl/src/lv_misc/lv_log.h libs/lvgl/src/lv_misc/lv_math.c libs/lvgl/src/lv_misc/lv_math.h libs/lvgl/src/lv_misc/lv_mem.c libs/lvgl/src/lv_misc/lv_mem.h libs/lvgl/src/lv_misc/lv_printf.c libs/lvgl/src/lv_misc/lv_printf.h libs/lvgl/src/lv_misc/lv_task.c libs/lvgl/src/lv_misc/lv_task.h libs/lvgl/src/lv_misc/lv_templ.c libs/lvgl/src/lv_misc/lv_templ.h libs/lvgl/src/lv_misc/lv_txt.c libs/lvgl/src/lv_misc/lv_txt.h libs/lvgl/src/lv_misc/lv_types.h libs/lvgl/src/lv_misc/lv_utils.c libs/lvgl/src/lv_misc/lv_utils.h libs/lvgl/src/lv_draw/lv_draw.c libs/lvgl/src/lv_draw/lv_draw.h libs/lvgl/src/lv_draw/lv_draw_arc.c libs/lvgl/src/lv_draw/lv_draw_arc.h libs/lvgl/src/lv_draw/lv_draw_basic.c libs/lvgl/src/lv_draw/lv_draw_basic.h libs/lvgl/src/lv_draw/lv_draw_img.c libs/lvgl/src/lv_draw/lv_draw_img.h libs/lvgl/src/lv_draw/lv_draw_label.c libs/lvgl/src/lv_draw/lv_draw_label.h libs/lvgl/src/lv_draw/lv_draw_line.c libs/lvgl/src/lv_draw/lv_draw_line.h libs/lvgl/src/lv_draw/lv_draw_rect.c libs/lvgl/src/lv_draw/lv_draw_rect.h libs/lvgl/src/lv_draw/lv_draw_triangle.c libs/lvgl/src/lv_draw/lv_draw_triangle.h libs/lvgl/src/lv_draw/lv_img_cache.c libs/lvgl/src/lv_draw/lv_img_cache.h libs/lvgl/src/lv_draw/lv_img_decoder.c libs/lvgl/src/lv_draw/lv_img_decoder.h libs/lvgl/src/lv_hal/lv_hal.h libs/lvgl/src/lv_hal/lv_hal_disp.c libs/lvgl/src/lv_hal/lv_hal_disp.h libs/lvgl/src/lv_hal/lv_hal_indev.c libs/lvgl/src/lv_hal/lv_hal_indev.h libs/lvgl/src/lv_hal/lv_hal_tick.c libs/lvgl/src/lv_hal/lv_hal_tick.h libs/lvgl/src/lv_font/lv_font.c libs/lvgl/src/lv_font/lv_font.h libs/lvgl/src/lv_font/lv_font_fmt_txt.c libs/lvgl/src/lv_font/lv_font_fmt_txt.h libs/lvgl/src/lv_font/lv_symbol_def.h libs/lvgl/src/lv_themes/lv_theme.c libs/lvgl/src/lv_themes/lv_theme.h libs/lvgl/src/lv_objx/lv_btn.h libs/lvgl/src/lv_objx/lv_btn.c libs/lvgl/src/lv_objx/lv_cont.h libs/lvgl/src/lv_objx/lv_cont.c libs/lvgl/src/lv_objx/lv_label.h libs/lvgl/src/lv_objx/lv_label.c libs/lvgl/src/lv_objx/lv_table.c libs/lvgl/src/lv_themes/lv_theme.c libs/lvgl/src/lv_themes/lv_theme.h libs/lvgl/src/lv_themes/lv_theme_night.h libs/lvgl/src/lv_themes/lv_theme_night.c libs/lvgl/src/lv_objx/lv_list.c libs/lvgl/src/lv_objx/lv_list.h libs/lvgl/src/lv_objx/lv_tileview.c libs/lvgl/src/lv_objx/lv_tileview.h libs/lvgl/src/lv_objx/lv_tabview.c libs/lvgl/src/lv_objx/lv_tabview.h libs/lvgl/src/lv_objx/lv_btnm.c libs/lvgl/src/lv_objx/lv_btnm.h libs/lvgl/src/lv_objx/lv_page.c libs/lvgl/src/lv_objx/lv_page.h libs/lvgl/src/lv_objx/lv_img.c libs/lvgl/src/lv_objx/lv_img.h libs/lvgl/src/lv_objx/lv_lmeter.c libs/lvgl/src/lv_objx/lv_lmeter.h libs/lvgl/src/lv_objx/lv_arc.c libs/lvgl/src/lv_objx/lv_arc.h libs/lvgl/src/lv_objx/lv_gauge.c libs/lvgl/src/lv_objx/lv_gauge.h libs/lvgl/src/lv_objx/lv_mbox.c libs/lvgl/src/lv_objx/lv_mbox.h libs/lvgl/src/lv_objx/lv_bar.c libs/lvgl/src/lv_objx/lv_bar.h libs/lvgl/src/lv_objx/lv_slider.h libs/lvgl/src/lv_objx/lv_slider.c libs/lvgl/src/lv_objx/lv_ddlist.c libs/lvgl/src/lv_objx/lv_ddlist.h libs/lvgl/src/lv_objx/lv_line.c libs/lvgl/src/lv_objx/lv_line.h ) list(APPEND IMAGE_FILES displayapp/icons/battery/os_battery_error.c displayapp/icons/battery/os_battery_100.c displayapp/icons/battery/os_battery_090.c displayapp/icons/battery/os_battery_080.c displayapp/icons/battery/os_battery_070.c displayapp/icons/battery/os_battery_060.c displayapp/icons/battery/os_battery_050.c displayapp/icons/battery/os_battery_040.c displayapp/icons/battery/os_battery_030.c displayapp/icons/battery/os_battery_020.c displayapp/icons/battery/os_battery_010.c displayapp/icons/battery/os_battery_005.c displayapp/icons/battery/os_batterycharging_100.c displayapp/icons/battery/os_batterycharging_090.c displayapp/icons/battery/os_batterycharging_080.c displayapp/icons/battery/os_batterycharging_070.c displayapp/icons/battery/os_batterycharging_060.c displayapp/icons/battery/os_batterycharging_050.c displayapp/icons/battery/os_batterycharging_040.c displayapp/icons/battery/os_batterycharging_030.c displayapp/icons/battery/os_batterycharging_020.c displayapp/icons/battery/os_batterycharging_010.c displayapp/icons/battery/os_batterycharging_005.c displayapp/icons/bluetooth/os_bt_connected.c displayapp/icons/bluetooth/os_bt_disconnected.c displayapp/icons/navigation/arrive-left.c displayapp/icons/navigation/arrive-right.c displayapp/icons/navigation/arrive-straight.c displayapp/icons/navigation/arrive.c displayapp/icons/navigation/close.c displayapp/icons/navigation/continue-left.c displayapp/icons/navigation/continue-right.c displayapp/icons/navigation/continue-slight-left.c displayapp/icons/navigation/continue-slight-right.c displayapp/icons/navigation/continue-straight.c displayapp/icons/navigation/continue-uturn.c displayapp/icons/navigation/continue.c displayapp/icons/navigation/depart-left.c displayapp/icons/navigation/depart-right.c displayapp/icons/navigation/depart-straight.c displayapp/icons/navigation/end-of-road-left.c displayapp/icons/navigation/end-of-road-right.c displayapp/icons/navigation/ferry.c displayapp/icons/navigation/flag.c displayapp/icons/navigation/fork-left.c displayapp/icons/navigation/fork-right.c displayapp/icons/navigation/fork-slight-left.c displayapp/icons/navigation/fork-slight-right.c displayapp/icons/navigation/fork-straight.c displayapp/icons/navigation/invalid.c displayapp/icons/navigation/invalid-left.c displayapp/icons/navigation/invalid-right.c displayapp/icons/navigation/invalid-slight-left.c displayapp/icons/navigation/invalid-slight-right.c displayapp/icons/navigation/invalid-straight.c displayapp/icons/navigation/invalid-uturn.c displayapp/icons/navigation/merge-left.c displayapp/icons/navigation/merge-right.c displayapp/icons/navigation/merge-slight-left.c displayapp/icons/navigation/merge-slight-right.c displayapp/icons/navigation/merge-straight.c displayapp/icons/navigation/new-name-left.c displayapp/icons/navigation/new-name-right.c displayapp/icons/navigation/new-name-sharp-left.c displayapp/icons/navigation/new-name-sharp-right.c displayapp/icons/navigation/new-name-slight-left.c displayapp/icons/navigation/new-name-slight-right.c displayapp/icons/navigation/new-name-straight.c displayapp/icons/navigation/notification-left.c displayapp/icons/navigation/notification-right.c displayapp/icons/navigation/notification-sharp-left.c displayapp/icons/navigation/notification-sharp-right.c displayapp/icons/navigation/notification-slight-left.c displayapp/icons/navigation/notification-slight-right.c displayapp/icons/navigation/notification-straight.c displayapp/icons/navigation/off-ramp-left.c displayapp/icons/navigation/off-ramp-right.c displayapp/icons/navigation/off-ramp-sharp-left.c displayapp/icons/navigation/off-ramp-sharp-right.c displayapp/icons/navigation/off-ramp-slight-left.c displayapp/icons/navigation/off-ramp-slight-right.c displayapp/icons/navigation/off-ramp-straight.c displayapp/icons/navigation/on-ramp-left.c displayapp/icons/navigation/on-ramp-right.c displayapp/icons/navigation/on-ramp-sharp-left.c displayapp/icons/navigation/on-ramp-sharp-right.c displayapp/icons/navigation/on-ramp-slight-left.c displayapp/icons/navigation/on-ramp-slight-right.c displayapp/icons/navigation/on-ramp-straight.c displayapp/icons/navigation/rotary.c displayapp/icons/navigation/rotary-left.c displayapp/icons/navigation/rotary-right.c displayapp/icons/navigation/rotary-sharp-left.c displayapp/icons/navigation/rotary-sharp-right.c displayapp/icons/navigation/rotary-slight-left.c displayapp/icons/navigation/rotary-slight-right.c displayapp/icons/navigation/rotary-straight.c displayapp/icons/navigation/roundabout.c displayapp/icons/navigation/roundabout-left.c displayapp/icons/navigation/roundabout-right.c displayapp/icons/navigation/roundabout-sharp-left.c displayapp/icons/navigation/roundabout-sharp-right.c displayapp/icons/navigation/roundabout-slight-left.c displayapp/icons/navigation/roundabout-slight-right.c displayapp/icons/navigation/roundabout-straight.c displayapp/icons/navigation/turn-left.c displayapp/icons/navigation/turn-right.c displayapp/icons/navigation/turn-sharp-left.c displayapp/icons/navigation/turn-sharp-right.c displayapp/icons/navigation/turn-slight-left.c displayapp/icons/navigation/turn-slight-right.c displayapp/icons/navigation/turn-stright.c displayapp/icons/navigation/updown.c displayapp/icons/navigation/uturn.c ) list(APPEND SOURCE_FILES BootloaderVersion.cpp logging/NrfLogger.cpp displayapp/DisplayApp.cpp displayapp/screens/Screen.cpp displayapp/screens/Clock.cpp displayapp/screens/Tile.cpp displayapp/screens/Meter.cpp displayapp/screens/Gauge.cpp displayapp/screens/InfiniPaint.cpp displayapp/screens/Paddle.cpp displayapp/screens/DropDownDemo.cpp displayapp/screens/Modal.cpp displayapp/screens/BatteryIcon.cpp displayapp/screens/BleIcon.cpp displayapp/screens/NotificationIcon.cpp displayapp/screens/Brightness.cpp displayapp/screens/SystemInfo.cpp displayapp/screens/Label.cpp displayapp/screens/FirmwareUpdate.cpp displayapp/screens/Music.cpp displayapp/screens/Navigation.cpp displayapp/screens/FirmwareValidation.cpp displayapp/screens/ApplicationList.cpp displayapp/screens/Notifications.cpp displayapp/screens/Twos.cpp displayapp/screens/HeartRate.cpp main.cpp drivers/St7789.cpp drivers/SpiNorFlash.cpp drivers/SpiMaster.cpp drivers/Spi.cpp drivers/Watchdog.cpp drivers/DebugPins.cpp drivers/InternalFlash.cpp drivers/Hrs3300.cpp components/battery/BatteryController.cpp components/ble/BleController.cpp components/ble/NotificationManager.cpp components/datetime/DateTimeController.cpp components/brightness/BrightnessController.cpp components/ble/NimbleController.cpp components/ble/DeviceInformationService.cpp components/ble/CurrentTimeClient.cpp components/ble/AlertNotificationClient.cpp components/ble/DfuService.cpp components/ble/CurrentTimeService.cpp components/ble/AlertNotificationService.cpp components/ble/MusicService.cpp components/ble/NavigationService.cpp components/ble/BatteryInformationService.cpp components/ble/ImmediateAlertService.cpp components/ble/ServiceDiscovery.cpp components/ble/HeartRateService.cpp components/firmwarevalidator/FirmwareValidator.cpp drivers/Cst816s.cpp FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis.c displayapp/LittleVgl.cpp displayapp/fonts/jetbrains_mono_extrabold_compressed.c displayapp/fonts/jetbrains_mono_bold_20.c systemtask/SystemTask.cpp drivers/TwiMaster.cpp heartratetask/HeartRateTask.cpp components/heartrate/Ppg.cpp components/heartrate/Biquad.cpp components/heartrate/Ptagc.cpp components/heartrate/HeartRateController.cpp ) list(APPEND RECOVERY_SOURCE_FILES BootloaderVersion.cpp logging/NrfLogger.cpp displayapp/DisplayAppRecovery.cpp main.cpp drivers/St7789.cpp drivers/SpiNorFlash.cpp drivers/SpiMaster.cpp drivers/Spi.cpp drivers/Watchdog.cpp drivers/DebugPins.cpp drivers/InternalFlash.cpp drivers/Hrs3300.cpp components/battery/BatteryController.cpp components/ble/BleController.cpp components/ble/NotificationManager.cpp components/datetime/DateTimeController.cpp components/brightness/BrightnessController.cpp components/ble/NimbleController.cpp components/ble/DeviceInformationService.cpp components/ble/CurrentTimeClient.cpp components/ble/AlertNotificationClient.cpp components/ble/DfuService.cpp components/ble/CurrentTimeService.cpp components/ble/AlertNotificationService.cpp components/ble/MusicService.cpp components/ble/BatteryInformationService.cpp components/ble/ImmediateAlertService.cpp components/ble/ServiceDiscovery.cpp components/ble/NavigationService.cpp components/ble/HeartRateService.cpp components/firmwarevalidator/FirmwareValidator.cpp drivers/Cst816s.cpp FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis.c systemtask/SystemTask.cpp drivers/TwiMaster.cpp components/gfx/Gfx.cpp displayapp/icons/infinitime/infinitime-nb.c components/rle/RleDecoder.cpp components/heartrate/HeartRateController.cpp heartratetask/HeartRateTask.cpp components/heartrate/Ppg.cpp components/heartrate/Biquad.cpp components/heartrate/Ptagc.cpp ) list(APPEND RECOVERYLOADER_SOURCE_FILES # FreeRTOS FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis.c drivers/SpiNorFlash.cpp drivers/SpiMaster.cpp drivers/Spi.cpp logging/NrfLogger.cpp components/rle/RleDecoder.cpp components/gfx/Gfx.cpp drivers/St7789.cpp components/brightness/BrightnessController.cpp displayapp/icons/infinitime/infinitime-nb.c recoveryLoader.cpp ) set(INCLUDE_FILES BootloaderVersion.h logging/Logger.h logging/NrfLogger.h displayapp/DisplayApp.h displayapp/Messages.h displayapp/TouchEvents.h displayapp/screens/Screen.h displayapp/screens/Clock.h displayapp/screens/Tile.h displayapp/screens/Meter.h displayapp/screens/Gauge.h displayapp/screens/InfiniPaint.h displayapp/screens/Paddle.h displayapp/screens/DropDownDemo.h displayapp/screens/Modal.h displayapp/screens/BatteryIcon.h displayapp/screens/BleIcon.h displayapp/screens/NotificationIcon.h displayapp/screens/Brightness.h displayapp/screens/SystemInfo.h displayapp/screens/ScreenList.h displayapp/screens/Label.h displayapp/screens/FirmwareUpdate.h displayapp/screens/FirmwareValidation.h displayapp/screens/ApplicationList.h displayapp/Apps.h displayapp/screens/Notifications.h displayapp/screens/HeartRate.h drivers/St7789.h drivers/SpiNorFlash.h drivers/SpiMaster.h drivers/Spi.h drivers/Watchdog.h drivers/DebugPins.h drivers/InternalFlash.h drivers/Hrs3300.h components/battery/BatteryController.h components/ble/BleController.h components/ble/NotificationManager.h components/datetime/DateTimeController.h components/brightness/BrightnessController.h components/ble/NimbleController.h components/ble/DeviceInformationService.h components/ble/CurrentTimeClient.h components/ble/AlertNotificationClient.h components/ble/DfuService.h components/firmwarevalidator/FirmwareValidator.h components/ble/BatteryInformationService.h components/ble/ImmediateAlertService.h components/ble/ServiceDiscovery.h components/ble/BleClient.h components/ble/HeartRateService.h.h drivers/Cst816s.h FreeRTOS/portmacro.h FreeRTOS/portmacro_cmsis.h libs/date/includes/date/tz.h libs/date/includes/date/chrono_io.h libs/date/includes/date/date.h libs/date/includes/date/islamic.h libs/date/includes/date/iso_week.h libs/date/includes/date/julian.h libs/date/includes/date/ptz.h libs/date/includes/date/tz_private.h systemtask/SystemTask.h systemtask/SystemMonitor.h displayapp/screens/Symbols.h drivers/TwiMaster.h heartratetask/HeartRateTask.h components/heartrate/Ppg.h components/heartrate/Biquad.h components/heartrate/Ptagc.h components/heartrate/HeartRateController.h ) include_directories( . ../ libs/ FreeRTOS/ libs/date/includes libs/mynewt-nimble/porting/npl/freertos/include libs/mynewt-nimble/nimble/include libs/mynewt-nimble/porting/nimble/include libs/mynewt-nimble/nimble/host/include libs/mynewt-nimble/nimble/controller/include libs/mynewt-nimble/nimble/transport/ram/include libs/mynewt-nimble/nimble/drivers/nrf52/include libs/mynewt-nimble/ext/tinycrypt/include libs/mynewt-nimble/nimble/host/services/gap/include libs/mynewt-nimble/nimble/host/services/gatt/include libs/mynewt-nimble/nimble/host/util/include libs/mynewt-nimble/nimble/host/store/ram/include "${NRF5_SDK_PATH}/components/drivers_nrf/nrf_soc_nosd" "${NRF5_SDK_PATH}/components" "${NRF5_SDK_PATH}/components/boards" "${NRF5_SDK_PATH}/components/softdevice/common" "${NRF5_SDK_PATH}/integration/nrfx" "${NRF5_SDK_PATH}/integration/nrfx/legacy" "${NRF5_SDK_PATH}/modules/nrfx" "${NRF5_SDK_PATH}/modules/nrfx/drivers/include" "${NRF5_SDK_PATH}/modules/nrfx/hal" "${NRF5_SDK_PATH}/modules/nrfx/mdk" ${NRF5_SDK_PATH}/external/freertos/source/include "${NRF5_SDK_PATH}/components/toolchain/cmsis/include" "${NRF5_SDK_PATH}/components/libraries/atomic" "${NRF5_SDK_PATH}/components/libraries/atomic_fifo" "${NRF5_SDK_PATH}/components/libraries/atomic_flags" "${NRF5_SDK_PATH}/components/libraries/balloc" "${NRF5_SDK_PATH}/components/libraries/bootloader/ble_dfu" "${NRF5_SDK_PATH}/components/libraries/cli" "${NRF5_SDK_PATH}/components/libraries/crc16" "${NRF5_SDK_PATH}/components/libraries/crc32" "${NRF5_SDK_PATH}/components/libraries/crypto" "${NRF5_SDK_PATH}/components/libraries/csense" "${NRF5_SDK_PATH}/components/libraries/csense_drv" "${NRF5_SDK_PATH}/components/libraries/delay" "${NRF5_SDK_PATH}/components/libraries/ecc" "${NRF5_SDK_PATH}/components/libraries/experimental_section_vars" "${NRF5_SDK_PATH}/components/libraries/experimental_task_manager" "${NRF5_SDK_PATH}/components/libraries/fds" "${NRF5_SDK_PATH}/components/libraries/fstorage" "${NRF5_SDK_PATH}/components/libraries/gfx" "${NRF5_SDK_PATH}/components/libraries/gpiote" "${NRF5_SDK_PATH}/components/libraries/hardfault" "${NRF5_SDK_PATH}/components/libraries/hci" "${NRF5_SDK_PATH}/components/libraries/led_softblink" "${NRF5_SDK_PATH}/components/libraries/log" "${NRF5_SDK_PATH}/components/libraries/log/src" "${NRF5_SDK_PATH}/components/libraries/low_power_pwm" "${NRF5_SDK_PATH}/components/libraries/mem_manager" "${NRF5_SDK_PATH}/components/libraries/memobj" "${NRF5_SDK_PATH}/components/libraries/mpu" "${NRF5_SDK_PATH}/components/libraries/mutex" "${NRF5_SDK_PATH}/components/libraries/pwm" "${NRF5_SDK_PATH}/components/libraries/pwr_mgmt" "${NRF5_SDK_PATH}/components/libraries/queue" "${NRF5_SDK_PATH}/components/libraries/ringbuf" "${NRF5_SDK_PATH}/components/libraries/scheduler" "${NRF5_SDK_PATH}/components/libraries/sdcard" "${NRF5_SDK_PATH}/components/libraries/slip" "${NRF5_SDK_PATH}/components/libraries/sortlist" "${NRF5_SDK_PATH}/components/libraries/spi_mngr" "${NRF5_SDK_PATH}/components/libraries/stack_guard" "${NRF5_SDK_PATH}/components/libraries/strerror" "${NRF5_SDK_PATH}/components/libraries/svc" "${NRF5_SDK_PATH}/components/libraries/timer" "${NRF5_SDK_PATH}/components/libraries/usbd" "${NRF5_SDK_PATH}/components/libraries/usbd/class/audio" "${NRF5_SDK_PATH}/components/libraries/usbd/class/cdc" "${NRF5_SDK_PATH}/components/libraries/usbd/class/cdc/acm" "${NRF5_SDK_PATH}/components/libraries/usbd/class/hid" "${NRF5_SDK_PATH}/components/libraries/usbd/class/hid/generic" "${NRF5_SDK_PATH}/components/libraries/usbd/class/hid/kbd" "${NRF5_SDK_PATH}/components/libraries/usbd/class/hid/mouse" "${NRF5_SDK_PATH}/components/libraries/usbd/class/msc" "${NRF5_SDK_PATH}/components/libraries/util" "${NRF5_SDK_PATH}/external/segger_rtt/" "${NRF5_SDK_PATH}/external/fprintf/" "${NRF5_SDK_PATH}/external/thedotfactory_fonts" "${NRF5_SDK_PATH}/components/libraries/gpiote" ) link_directories( ../ ) set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wno-unknown-pragmas -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type) add_definitions(-DCONFIG_GPIO_AS_PINRESET) add_definitions(-DDEBUG) add_definitions(-DNIMBLE_CFG_CONTROLLER) add_definitions(-DOS_CPUTIME_FREQ) add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64 -DNRF52_PAN_12 -DNRF52_PAN_58 -DNRF52_PAN_54 -DNRF52_PAN_31 -DNRF52_PAN_51 -DNRF52_PAN_36 -DNRF52_PAN_15 -DNRF52_PAN_20 -DNRF52_PAN_55 -DBOARD_PCA10040) add_definitions(-DFREERTOS) add_definitions(-DDEBUG_NRF_USER) add_definitions(-D__STACK_SIZE=8192) add_definitions(-D__HEAP_SIZE=8192) if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif () # NRF SDK add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES}) target_include_directories(nrf-sdk SYSTEM PUBLIC . ../) target_include_directories(nrf-sdk SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(nrf-sdk PRIVATE $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0> $<$,$>: ${COMMON_FLAGS} -O3> $<$: -MP -MD -std=c99 -x assembler-with-cpp> ) # NimBLE add_library(nimble STATIC ${NIMBLE_SRC} ${TINYCRYPT_SRC}) target_include_directories(nimble SYSTEM PUBLIC . ../) target_include_directories(nimble SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(nimble PRIVATE $<$,$>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> $<$,$>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> $<$,$>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> $<$,$>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> $<$: -MP -MD -std=c99 -x assembler-with-cpp> ) # lvgl add_library(lvgl STATIC ${LVGL_SRC}) target_include_directories(lvgl SYSTEM PUBLIC . ../) target_include_directories(lvgl SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(lvgl PRIVATE $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$: -MP -MD -std=c99 -x assembler-with-cpp> ) # Build autonomous binary (without support for bootloader) set(EXECUTABLE_NAME "pinetime-app") set(EXECUTABLE_FILE_NAME ${EXECUTABLE_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld") add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES}) set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME}) target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl) target_compile_options(${EXECUTABLE_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$: -MP -MD -std=c99 -x assembler-with-cpp> ) set_target_properties(${EXECUTABLE_NAME} PROPERTIES SUFFIX ".out" LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_FILE_NAME}.map" CXX_STANDARD 11 C_STANDARD 99 ) add_custom_command(TARGET ${EXECUTABLE_NAME} POST_BUILD COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_FILE_NAME}.out COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_FILE_NAME}.out "${EXECUTABLE_FILE_NAME}.bin" COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_FILE_NAME}.out "${EXECUTABLE_FILE_NAME}.hex" COMMENT "post build steps for ${EXECUTABLE_FILE_NAME}") # Build binary intended to be used by bootloader set(EXECUTABLE_MCUBOOT_NAME "pinetime-mcuboot-app") set(EXECUTABLE_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) set(IMAGE_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-image-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.bin) set(DFU_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip) set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld") add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES}) target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl) set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME}) target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$: -MP -MD -std=c99 -x assembler-with-cpp> ) set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES SUFFIX ".out" LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_MCUBOOT_FILE_NAME}.map" CXX_STANDARD 11 C_STANDARD 99 ) add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME} POST_BUILD COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_MCUBOOT_FILE_NAME}.out COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.bin" COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.hex" COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_MCUBOOT_FILE_NAME}.bin ${IMAGE_MCUBOOT_FILE_NAME} COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_FILE_NAME} ${DFU_MCUBOOT_FILE_NAME} COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_FILE_NAME}" ) # InfiniTime recovery firmware (autonomous) set(EXECUTABLE_RECOVERY_NAME "pinetime-recovery") set(EXECUTABLE_RECOVERY_FILE_NAME ${EXECUTABLE_RECOVERY_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) add_executable(${EXECUTABLE_RECOVERY_NAME} ${RECOVERY_SOURCE_FILES}) target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk) set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_FILE_NAME}) target_compile_definitions(${EXECUTABLE_RECOVERY_NAME} PUBLIC "PINETIME_IS_RECOVERY") target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$: -MP -MD -std=c99 -x assembler-with-cpp> ) set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES SUFFIX ".out" LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_RECOVERY_FILE_NAME}.map" CXX_STANDARD 11 C_STANDARD 99 ) add_custom_command(TARGET ${EXECUTABLE_RECOVERY_NAME} POST_BUILD COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_RECOVERY_FILE_NAME}.out COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_RECOVERY_FILE_NAME}.out "${EXECUTABLE_RECOVERY_FILE_NAME}.bin" COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_RECOVERY_FILE_NAME}.out "${EXECUTABLE_RECOVERY_FILE_NAME}.hex" COMMENT "post build steps for ${EXECUTABLE_RECOVERY_FILE_NAME}" ) # InfiniTime recovery firmware (mcuboot) set(EXECUTABLE_RECOVERY_MCUBOOT_NAME "pinetime-mcuboot-recovery") set(EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) set(IMAGE_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-image-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.bin) set(DFU_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip) add_executable(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} ${RECOVERY_SOURCE_FILES}) target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk) set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}) target_compile_definitions(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC "PINETIME_IS_RECOVERY") target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$: -MP -MD -std=c99 -x assembler-with-cpp> ) set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES SUFFIX ".out" LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.map" CXX_STANDARD 11 C_STANDARD 99 ) add_custom_command(TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME} POST_BUILD COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.out COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.bin" COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_RECOVERYY_MCUBOOT_FILE_NAME}.hex" COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.bin ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} COMMAND python ${CMAKE_SOURCE_DIR}/tools/bin2c.py ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} recoveryImage > recoveryImage.h COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} ${DFU_RECOVERY_MCUBOOT_FILE_NAME} COMMENT "post build steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}" ) # Build binary that writes the recovery image into the SPI flash memory set(EXECUTABLE_RECOVERYLOADER_NAME "pinetime-recovery-loader") set(EXECUTABLE_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_RECOVERYLOADER_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) add_executable(${EXECUTABLE_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE_FILES}) target_link_libraries(${EXECUTABLE_RECOVERYLOADER_NAME} nrf-sdk) set_target_properties(${EXECUTABLE_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERYLOADER_FILE_NAME}) target_compile_options(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$: -MP -MD -std=c99 -x assembler-with-cpp> ) target_include_directories(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC $ ) add_dependencies(${EXECUTABLE_RECOVERYLOADER_NAME} ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}) set_target_properties(${EXECUTABLE_RECOVERYLOADER_NAME} PROPERTIES SUFFIX ".out" LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.map" CXX_STANDARD 11 C_STANDARD 99 ) add_custom_command(TARGET ${EXECUTABLE_RECOVERYLOADER_NAME} POST_BUILD COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.out COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.out "${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.bin" COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.out "${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.hex" COMMENT "post build steps for ${EXECUTABLE_RECOVERYLOADER_FILE_NAME}" ) # Build binary that writes the recovery image (MCUBoot version) set(EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME "pinetime-mcuboot-recovery-loader") set(EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) set(IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}-image-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.bin) set(DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip) add_executable(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE_FILES}) target_link_libraries(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} nrf-sdk) set_target_properties(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}) target_compile_options(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> $<$: -MP -MD -std=c99 -x assembler-with-cpp> ) target_include_directories(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC $ ) add_dependencies(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}) set_target_properties(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PROPERTIES SUFFIX ".out" LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.map" CXX_STANDARD 11 C_STANDARD 99 ) add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} POST_BUILD COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.out COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.bin" COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.hex" COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.bin ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} COMMAND python ${CMAKE_SOURCE_DIR}/tools/bin2c.py ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} recoveryLoaderImage > recoveryLoaderImage.h COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME} COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}" ) # FLASH if (USE_JLINK) add_custom_target(FLASH_ERASE COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET} COMMENT "erasing flashing" ) add_custom_target("FLASH_${EXECUTABLE_NAME}" DEPENDS ${EXECUTABLE_NAME} COMMAND ${NRFJPROG} --program ${EXECUTABLE_FILE_NAME}.hex -f ${NRF_TARGET} --sectorerase COMMAND sleep 0.5s COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET} COMMENT "flashing ${EXECUTABLE_NAME}.hex" ) elseif (USE_GDB_CLIENT) add_custom_target(FLASH_ERASE COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'mon erase_mass' COMMENT "erasing flashing" ) add_custom_target("FLASH_${EXECUTABLE_NAME}" DEPENDS ${EXECUTABLE_NAME} COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${EXECUTABLE_NAME}.hex COMMENT "flashing ${EXECUTABLE_NAME}.hex" ) elseif (USE_OPENOCD) if (USE_CMSIS_DAP) add_custom_target(FLASH_ERASE COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface/cmsis-dap.cfg]' -c 'transport select swd' -c 'source [find target/nrf52.cfg]' -c 'init' -c 'halt' -c 'nrf5 mass_erase' -c 'halt' -c 'reset' -c 'exit' COMMENT "erasing flashing" ) add_custom_target("FLASH_${EXECUTABLE_NAME}" DEPENDS ${EXECUTABLE_NAME} COMMAND ${OPENOCD_BIN_PATH} -c 'tcl_port disabled' -c 'gdb_port 3333' -c 'telnet_port 4444' -c 'source [find interface/cmsis-dap.cfg]' -c 'transport select swd' -c 'source [find target/nrf52.cfg]' -c 'halt' -c "program \"${EXECUTABLE_NAME}.hex\"" -c 'reset' -c 'shutdown' COMMENT "flashing ${EXECUTABLE_NAME}.hex" ) else () add_custom_target(FLASH_ERASE COMMAND ${OPENOCD_BIN_PATH} -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c init -c halt -c 'nrf5 mass_erase' -c reset -c shutdown COMMENT "erasing flashing" ) add_custom_target("FLASH_${EXECUTABLE_NAME}" DEPENDS ${EXECUTABLE_NAME} COMMAND ${OPENOCD_BIN_PATH} -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c "program \"${EXECUTABLE_NAME}.hex\"" -c reset -c shutdown COMMENT "flashing ${EXECUTABLE_NAME}.hex" ) endif () endif ()