Refactor CMake files to allow building 2 binaries : one standalone and one compatible with mcuboot bootloader (the offset in memory is different).

Add documentation about mcuboot image generation and OTA.

Re-enable watchdog
This commit is contained in:
JF 2020-05-24 16:36:04 +02:00
parent 3cc76d7673
commit 331481cd0c
9 changed files with 447 additions and 67 deletions

View File

@ -66,5 +66,4 @@ endif()
set(VERSION_EDIT_WARNING "// Do not edit this file, it is automatically generated by CMAKE!") set(VERSION_EDIT_WARNING "// Do not edit this file, it is automatically generated by CMAKE!")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h)
include("cmake-nRF5x/CMake_nRF5x.cmake")
add_subdirectory(src) add_subdirectory(src)

View File

@ -34,11 +34,13 @@ I've tested this project on the actual PineTime hardware.
* Rich user interface (using [LittleVGL](https://littlevgl.com/)) via display, touchpanel and push button. * Rich user interface (using [LittleVGL](https://littlevgl.com/)) via display, touchpanel and push button.
* Digital watch face and 4 demo applications (spinning meter, analog gauche, push button and message box); * Digital watch face and 4 demo applications (spinning meter, analog gauche, push button and message box);
* Watchdog (automatic reset in case of firmware crash) and reset support (push and hold the button for 7 - 10s); * Watchdog (automatic reset in case of firmware crash) and reset support (push and hold the button for 7 - 10s);
* BLE Notification support (still Work-In-Progress, [companion app](https://github.com/JF002/gobbledegook) needed). * BLE Notification support (still Work-In-Progress, [companion app](https://github.com/JF002/gobbledegook) needed);
* **[EXPERIMENTAL]** Firmware update (OTA) via BLE.
## Documentation ## Documentation
* [BLE implementation and API](./doc/ble.md) * [BLE implementation and API](./doc/ble.md)
* [Bootloader and DFU](./bootloader/README.md)
## Stub using NRF52-DK ## Stub using NRF52-DK
![Pinetime stub](./images/pinetimestub1.jpg "PinetimeStub") ![Pinetime stub](./images/pinetimestub1.jpg "PinetimeStub")
@ -116,19 +118,12 @@ $ make -j pinetime-app
$ make FLASH_ERASE $ make FLASH_ERASE
``` ```
* Flash softdevice & application * Flash application
``` ```
$ make FLASH_SOFTDEVICE
$ make FLASH_pinetime-app $ make FLASH_pinetime-app
``` ```
Or, with ```mergehex```
```
$ make FLASH_MERGED_pinetime-app
```
* For your information : list make targets : * For your information : list make targets :
``` ```

50
bootloader/README.md Normal file
View File

@ -0,0 +1,50 @@
# Bootloader
## Bootloader binary
The binary comes from https://github.com/lupyuen/pinetime-rust-mynewt/releases/tag/v4.1.7
It must be flash at address **0x00** in the internal flash memory.
Using OpenOCD:
`
program mynewt_nosemi.elf_4.1.7.bin 0
`
## Application firmware image
Build the binary compatible with the booloader:
`
make pinetime-mcuboot-app
`
The binary is located in *<build directory>/src/pinetime-mcuboot-app.bin*.
It must me converted into a MCUBoot image using *imgtool.py* from [MCUBoot](https://github.com/JuulLabs-OSS/mcuboot/tree/master/scripts).
`
imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header <build directory>/src/pinetime-mcuboot-app.bin image.bin
`
The image must be then flashed at address **0x8000** in the internal flash memory.
Using OpenOCD:
`
program image.bin 0x8000
`
## OTA and DFU
Pack the image into a .zip file for the NRF DFU protocol:
`
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application image.bin dfu.zip
`
Use NRFConnect or dfu.py to upload the zip file to the device:
`
sudo dfu.py -z /home/jf/nrf52/bootloader/dfu.zip -a <pinetime MAC address> --legacy
`
**TODO** : dfu.py

Binary file not shown.

Binary file not shown.

136
gcc_nrf52-mcuboot.ld Normal file
View File

@ -0,0 +1,136 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x08020, LENGTH = 0x78000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
}
SECTIONS
{
}
SECTIONS
{
. = ALIGN(4);
.mem_section_dummy_ram :
{
}
.cli_sorted_cmd_ptrs :
{
PROVIDE(__start_cli_sorted_cmd_ptrs = .);
KEEP(*(.cli_sorted_cmd_ptrs))
PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
} > RAM
.fs_data :
{
PROVIDE(__start_fs_data = .);
KEEP(*(.fs_data))
PROVIDE(__stop_fs_data = .);
} > RAM
.log_dynamic_data :
{
PROVIDE(__start_log_dynamic_data = .);
KEEP(*(SORT(.log_dynamic_data*)))
PROVIDE(__stop_log_dynamic_data = .);
} > RAM
.log_filter_data :
{
PROVIDE(__start_log_filter_data = .);
KEEP(*(SORT(.log_filter_data*)))
PROVIDE(__stop_log_filter_data = .);
} > RAM
} INSERT AFTER .data;
SECTIONS
{
.mem_section_dummy_rom :
{
}
.sdh_soc_observers :
{
PROVIDE(__start_sdh_soc_observers = .);
KEEP(*(SORT(.sdh_soc_observers*)))
PROVIDE(__stop_sdh_soc_observers = .);
} > FLASH
.sdh_ble_observers :
{
PROVIDE(__start_sdh_ble_observers = .);
KEEP(*(SORT(.sdh_ble_observers*)))
PROVIDE(__stop_sdh_ble_observers = .);
} > FLASH
.sdh_req_observers :
{
PROVIDE(__start_sdh_req_observers = .);
KEEP(*(SORT(.sdh_req_observers*)))
PROVIDE(__stop_sdh_req_observers = .);
} > FLASH
.sdh_state_observers :
{
PROVIDE(__start_sdh_state_observers = .);
KEEP(*(SORT(.sdh_state_observers*)))
PROVIDE(__stop_sdh_state_observers = .);
} > FLASH
.sdh_stack_observers :
{
PROVIDE(__start_sdh_stack_observers = .);
KEEP(*(SORT(.sdh_stack_observers*)))
PROVIDE(__stop_sdh_stack_observers = .);
} > FLASH
.nrf_queue :
{
PROVIDE(__start_nrf_queue = .);
KEEP(*(.nrf_queue))
PROVIDE(__stop_nrf_queue = .);
} > FLASH
.nrf_balloc :
{
PROVIDE(__start_nrf_balloc = .);
KEEP(*(.nrf_balloc))
PROVIDE(__stop_nrf_balloc = .);
} > FLASH
.cli_command :
{
PROVIDE(__start_cli_command = .);
KEEP(*(.cli_command))
PROVIDE(__stop_cli_command = .);
} > FLASH
.crypto_data :
{
PROVIDE(__start_crypto_data = .);
KEEP(*(SORT(.crypto_data*)))
PROVIDE(__stop_crypto_data = .);
} > FLASH
.pwr_mgmt_data :
{
PROVIDE(__start_pwr_mgmt_data = .);
KEEP(*(SORT(.pwr_mgmt_data*)))
PROVIDE(__stop_pwr_mgmt_data = .);
} > FLASH
.log_const_data :
{
PROVIDE(__start_log_const_data = .);
KEEP(*(SORT(.log_const_data*)))
PROVIDE(__stop_log_const_data = .);
} > FLASH
.log_backends :
{
PROVIDE(__start_log_backends = .);
KEEP(*(SORT(.log_backends*)))
PROVIDE(__stop_log_backends = .);
} > FLASH
.nrf_balloc :
{
PROVIDE(__start_nrf_balloc = .);
KEEP(*(.nrf_balloc))
PROVIDE(__stop_nrf_balloc = .);
} > FLASH
} INSERT AFTER .text
INCLUDE "./nrf_common.ld"

View File

@ -5,7 +5,7 @@ GROUP(-lgcc -lc -lnosys)
MEMORY MEMORY
{ {
FLASH (rx) : ORIGIN = 0x08020, LENGTH = 0x78000 FLASH (rx) : ORIGIN = 0x00000, LENGTH = 0x78000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
} }

View File

@ -5,29 +5,86 @@ project(pinetime-app C CXX ASM)
# define some variables just for this example to determine file locations # define some variables just for this example to determine file locations
set(NRF_PROJECT_NAME pinetime-app) set(NRF_PROJECT_NAME pinetime-app)
set(NRF_BOARD pca10040) set(NRF_BOARD pca10040)
#set(NRF_SOFTDEVICE s132)
nRF5x_toolchainSetup() # check if all the necessary tools paths have been provided.
nRF5x_setup() 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()
#nRF5x_addAppScheduler() if (NOT NRF_TARGET MATCHES "nrf52")
#nRF5x_addAppFIFO() message(FATAL_ERROR "Only rRF52 boards are supported right now")
#nRF5x_addAppTimer() endif()
#nRF5x_addAppUART()
nRF5x_addAppButton()
nRF5x_addBSP(FALSE FALSE FALSE)
nRF5x_addAppGpiote()
#nRF5x_addBLEGATT()
#
#nRF5x_addBLEService(ble_lbs)
add_definitions(-DCONFIG_GPIO_AS_PINRESET) # Setup toolchain
add_definitions(-DDEBUG) include(${CMAKE_SOURCE_DIR}/cmake-nRF5x/arm-gcc-toolchain.cmake)
add_definitions(-DNIMBLE_CFG_CONTROLLER)
add_definitions(-DOS_CPUTIME_FREQ)
include_directories(.) if(NOT DEFINED ARM_GCC_TOOLCHAIN)
include_directories(libs/) 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_1.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 set(TINYCRYPT_SRC
libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c
@ -37,9 +94,6 @@ set(TINYCRYPT_SRC
set(NIMBLE_SRC set(NIMBLE_SRC
libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c 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/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.c
libs/mynewt-nimble/nimble/host/src/ble_hs_hci_evt.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_cmd.c
@ -78,11 +132,7 @@ set(NIMBLE_SRC
libs/mynewt-nimble/nimble/host/src/ble_hs_stop.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/src/ble_hs_startup.c
libs/mynewt-nimble/nimble/host/store/ram/src/ble_store_ram.c libs/mynewt-nimble/nimble/host/store/ram/src/ble_store_ram.c
libs/mynewt-nimble/nimble/transport/ram/src/ble_hci_ram.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.c
libs/mynewt-nimble/nimble/controller/src/ble_ll_rand.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_conn.c
@ -97,9 +147,6 @@ set(NIMBLE_SRC
libs/mynewt-nimble/nimble/controller/src/ble_ll_supp_cmd.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_hci_ev.c
libs/mynewt-nimble/nimble/controller/src/ble_ll_rfmgmt.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.c
libs/mynewt-nimble/porting/nimble/src/os_cputime_pwr2.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_mbuf.c
@ -108,13 +155,10 @@ set(NIMBLE_SRC
libs/mynewt-nimble/porting/nimble/src/mem.c libs/mynewt-nimble/porting/nimble/src/mem.c
libs/mynewt-nimble/porting/nimble/src/endian.c libs/mynewt-nimble/porting/nimble/src/endian.c
libs/mynewt-nimble/porting/nimble/src/os_msys_init.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_hw.c
libs/mynewt-nimble/nimble/drivers/nrf52/src/ble_phy.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/gap/src/ble_svc_gap.c
libs/mynewt-nimble/nimble/host/services/gatt/src/ble_svc_gatt.c libs/mynewt-nimble/nimble/host/services/gatt/src/ble_svc_gatt.c
libs/mynewt-nimble/nimble/host/util/src/addr.c libs/mynewt-nimble/nimble/host/util/src/addr.c
) )
@ -135,7 +179,6 @@ set(LVGL_SRC
libs/lvgl/src/lv_core/lv_refr.h libs/lvgl/src/lv_core/lv_refr.h
libs/lvgl/src/lv_core/lv_style.c libs/lvgl/src/lv_core/lv_style.c
libs/lvgl/src/lv_core/lv_style.h libs/lvgl/src/lv_core/lv_style.h
libs/lvgl/src/lv_misc/lv_anim.c libs/lvgl/src/lv_misc/lv_anim.c
libs/lvgl/src/lv_misc/lv_anim.h libs/lvgl/src/lv_misc/lv_anim.h
libs/lvgl/src/lv_misc/lv_async.h libs/lvgl/src/lv_misc/lv_async.h
@ -175,7 +218,6 @@ set(LVGL_SRC
libs/lvgl/src/lv_misc/lv_types.h libs/lvgl/src/lv_misc/lv_types.h
libs/lvgl/src/lv_misc/lv_utils.c libs/lvgl/src/lv_misc/lv_utils.c
libs/lvgl/src/lv_misc/lv_utils.h libs/lvgl/src/lv_misc/lv_utils.h
libs/lvgl/src/lv_draw/lv_draw.c libs/lvgl/src/lv_draw/lv_draw.c
libs/lvgl/src/lv_draw/lv_draw.h 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.c
@ -196,7 +238,6 @@ set(LVGL_SRC
libs/lvgl/src/lv_draw/lv_img_cache.h 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.c
libs/lvgl/src/lv_draw/lv_img_decoder.h libs/lvgl/src/lv_draw/lv_img_decoder.h
libs/lvgl/src/lv_hal/lv_hal.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.c
libs/lvgl/src/lv_hal/lv_hal_disp.h libs/lvgl/src/lv_hal/lv_hal_disp.h
@ -204,31 +245,23 @@ set(LVGL_SRC
libs/lvgl/src/lv_hal/lv_hal_indev.h 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.c
libs/lvgl/src/lv_hal/lv_hal_tick.h libs/lvgl/src/lv_hal/lv_hal_tick.h
libs/lvgl/src/lv_font/lv_font.c libs/lvgl/src/lv_font/lv_font.c
libs/lvgl/src/lv_font/lv_font.h 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.c
libs/lvgl/src/lv_font/lv_font_fmt_txt.h libs/lvgl/src/lv_font/lv_font_fmt_txt.h
# libs/lvgl/src/lv_font/lv_font_roboto_16.c
libs/lvgl/src/lv_font/lv_symbol_def.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.c
libs/lvgl/src/lv_themes/lv_theme.h libs/lvgl/src/lv_themes/lv_theme.h
libs/lvgl/src/lv_objx/lv_btn.h libs/lvgl/src/lv_objx/lv_btn.h
libs/lvgl/src/lv_objx/lv_btn.c libs/lvgl/src/lv_objx/lv_btn.c
libs/lvgl/src/lv_objx/lv_cont.h libs/lvgl/src/lv_objx/lv_cont.h
libs/lvgl/src/lv_objx/lv_cont.c libs/lvgl/src/lv_objx/lv_cont.c
libs/lvgl/src/lv_objx/lv_label.h libs/lvgl/src/lv_objx/lv_label.h
libs/lvgl/src/lv_objx/lv_label.c libs/lvgl/src/lv_objx/lv_label.c
libs/lvgl/src/lv_themes/lv_theme.c libs/lvgl/src/lv_themes/lv_theme.c
libs/lvgl/src/lv_themes/lv_theme.h 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.h
libs/lvgl/src/lv_themes/lv_theme_night.c libs/lvgl/src/lv_themes/lv_theme_night.c
libs/lvgl/src/lv_objx/lv_list.c libs/lvgl/src/lv_objx/lv_list.c
libs/lvgl/src/lv_objx/lv_list.h libs/lvgl/src/lv_objx/lv_list.h
libs/lvgl/src/lv_objx/lv_tileview.c libs/lvgl/src/lv_objx/lv_tileview.c
@ -247,20 +280,16 @@ set(LVGL_SRC
libs/lvgl/src/lv_objx/lv_arc.h libs/lvgl/src/lv_objx/lv_arc.h
libs/lvgl/src/lv_objx/lv_gauge.c libs/lvgl/src/lv_objx/lv_gauge.c
libs/lvgl/src/lv_objx/lv_gauge.h libs/lvgl/src/lv_objx/lv_gauge.h
libs/lvgl/src/lv_objx/lv_mbox.c libs/lvgl/src/lv_objx/lv_mbox.c
libs/lvgl/src/lv_objx/lv_mbox.h libs/lvgl/src/lv_objx/lv_mbox.h
libs/lvgl/src/lv_objx/lv_bar.c libs/lvgl/src/lv_objx/lv_bar.c
libs/lvgl/src/lv_objx/lv_bar.h libs/lvgl/src/lv_objx/lv_bar.h
libs/lvgl/src/lv_objx/lv_slider.h libs/lvgl/src/lv_objx/lv_slider.h
libs/lvgl/src/lv_objx/lv_slider.c libs/lvgl/src/lv_objx/lv_slider.c
) )
list(APPEND IMAGE_FILES list(APPEND IMAGE_FILES
DisplayApp/Icons/battery/os_battery_error.c DisplayApp/Icons/battery/os_battery_error.c
DisplayApp/Icons/battery/os_battery_100.c DisplayApp/Icons/battery/os_battery_100.c
DisplayApp/Icons/battery/os_battery_090.c DisplayApp/Icons/battery/os_battery_090.c
DisplayApp/Icons/battery/os_battery_080.c DisplayApp/Icons/battery/os_battery_080.c
@ -331,6 +360,7 @@ list(APPEND SOURCE_FILES
${NIMBLE_SRC} ${NIMBLE_SRC}
${LVGL_SRC} ${LVGL_SRC}
${IMAGE_FILES} ${IMAGE_FILES}
${SDK_SOURCE_FILES}
DisplayApp/LittleVgl.cpp DisplayApp/LittleVgl.cpp
DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c
@ -385,13 +415,14 @@ set(INCLUDE_FILES
libs/date/includes/date/julian.h libs/date/includes/date/julian.h
libs/date/includes/date/ptz.h libs/date/includes/date/ptz.h
libs/date/includes/date/tz_private.h libs/date/includes/date/tz_private.h
DisplayApp/LittleVgl.h DisplayApp/LittleVgl.h
SystemTask/SystemTask.h SystemTask/SystemTask.h
) )
include_directories( include_directories(
.
../
libs/
FreeRTOS/ FreeRTOS/
libs/date/includes libs/date/includes
libs/mynewt-nimble/porting/npl/freertos/include libs/mynewt-nimble/porting/npl/freertos/include
@ -406,10 +437,179 @@ include_directories(
libs/mynewt-nimble/nimble/host/services/gatt/include libs/mynewt-nimble/nimble/host/services/gatt/include
libs/mynewt-nimble/nimble/host/util/include libs/mynewt-nimble/nimble/host/util/include
libs/mynewt-nimble/nimble/host/store/ram/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( link_directories(
../
) )
nRF5x_addExecutable(pinetime-app "${SOURCE_FILES}" ${INCLUDE_FILES})
set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -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)
# Build autonomous binary (without support for bootloader)
set(EXECUTABLE_NAME "pinetime-app")
set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld")
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})
target_compile_options(${EXECUTABLE_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<COMPILE_LANGUAGE:ASM>: -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_NAME}.map"
CXX_STANDARD 11
C_STANDARD 99
)
add_custom_command(TARGET ${EXECUTABLE_NAME}
POST_BUILD
COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_NAME}.out
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_NAME}.out "${EXECUTABLE_NAME}.bin"
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_NAME}.out "${EXECUTABLE_NAME}.hex"
COMMENT "post build steps for ${EXECUTABLE_NAME}")
# Build binary intended to be used by bootloader
set(EXECUTABLE_MCUBOOT_NAME "pinetime-mcuboot-app")
set(EXECUTABLE_MCUBOOT_WITH_BOOTLOADER_NAME "pinetime-mcuboot-app-wth-bootloader")
set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld")
add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES})
target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<COMPILE_LANGUAGE:ASM>: -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_NAME}.map"
CXX_STANDARD 11
C_STANDARD 99
)
add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
POST_BUILD
COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_MCUBOOT_NAME}.out
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_MCUBOOT_NAME}.out "${EXECUTABLE_MCUBOOT_NAME}.bin"
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_NAME}.out "${EXECUTABLE_MCUBOOT_NAME}.hex"
COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_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_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)
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()

View File

@ -60,19 +60,19 @@ void nrf52_nvmc_write_word(uint32_t address, uint32_t value) {
} }
void SystemTask::Work() { void SystemTask::Work() {
// watchdog.Setup(7); watchdog.Setup(7);
// watchdog.Start(); watchdog.Start();
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason())); NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason()));
APP_GPIOTE_INIT(2); APP_GPIOTE_INIT(2);
spi.Init(); spi.Init();
spiNorFlash.Init(); spiNorFlash.Init();
// TODO write magic only if it's not already 1
nrf52_nvmc_write_word(0x7BFE8, 1);
uint32_t* magicptr = reinterpret_cast<uint32_t *>(0x7BFE8); uint32_t* magicptr = reinterpret_cast<uint32_t *>(0x7BFE8);
uint32_t magic = *magicptr; uint32_t magic = *magicptr;
if(magic != 1)
nrf52_nvmc_write_word(0x7BFE8, 1);
NRF_LOG_INFO("MAGIC : %d", magic); NRF_LOG_INFO("MAGIC : %d", magic);
nimbleController.Init(); nimbleController.Init();