From 1c901bd75ff415e633cfc7493c51b66d0a44a021 Mon Sep 17 00:00:00 2001 From: Leonardo Bispo <34199302+ldab@users.noreply.github.com> Date: Thu, 16 Nov 2023 11:16:37 +0100 Subject: [PATCH] Migrate to NCS SDK v2.5.0 (#107) * NCS v2.5.0 * no partition for non ZS hardware * partition for dk * PR feedback * here we go * fix partitions * Use NCS Partition manager to put settings in external flash. * lvgl patch ad NCS 2.5 does not include a patch for touch input which causes accidental presses. --------- Co-authored-by: Jakob Krantz --- .gitignore | 3 ++ app/CMakeLists.txt | 6 ++++ .../zswatch_nrf5340_cpuapp_3.conf | 6 +++- .../zswatch_nrf5340_cpunet_3.conf | 0 app/boards/nrf5340dk_nrf5340_cpuapp.conf | 5 ++- app/boards/nrf5340dk_nrf5340_cpuapp.overlay | 1 + app/partition_zs.yml | 15 ++++++++ app/patches/lvgl_scroll_click.patch | 35 +++++++++++++++++++ app/src/main.c | 2 ++ app/west.yml | 14 ++++---- app/zephyr/module.yml | 20 ----------- 11 files changed, 79 insertions(+), 28 deletions(-) create mode 100644 app/boards/arm/zswatch_nrf5340/zswatch_nrf5340_cpunet_3.conf create mode 100644 app/partition_zs.yml create mode 100644 app/patches/lvgl_scroll_click.patch delete mode 100644 app/zephyr/module.yml diff --git a/.gitignore b/.gitignore index 7de5c200..1d651145 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,8 @@ build* /tools /zephyr __pycache__ +/nrf +/nrfxlib +/test /.vscode diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 989e9762..99f6deb1 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -17,9 +17,15 @@ if(ZSWATCH_BOARD) set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/partition.yml) set(OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/boards/dfu.conf) set(mcuboot_DTC_OVERLAY_FILE ${CMAKE_CURRENT_SOURCE_DIR}/overlays/mcuboot.overlay) + else() + set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/partition_zs.yml) endif() endif() +if("nrf5340dk_nrf5340_cpuapp" STREQUAL "${BOARD}") + set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/partition_zs.yml) +endif() + set(BOARD_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(ZSWatchFW) diff --git a/app/boards/arm/zswatch_nrf5340/zswatch_nrf5340_cpuapp_3.conf b/app/boards/arm/zswatch_nrf5340/zswatch_nrf5340_cpuapp_3.conf index 9b228a84..8682f56a 100644 --- a/app/boards/arm/zswatch_nrf5340/zswatch_nrf5340_cpuapp_3.conf +++ b/app/boards/arm/zswatch_nrf5340/zswatch_nrf5340_cpuapp_3.conf @@ -21,4 +21,8 @@ CONFIG_FILE_SYSTEM_LITTLEFS=y CONFIG_LV_Z_USE_FILESYSTEM=y CONFIG_LV_IMG_CACHE_DEF_SIZE=10 -CONFIG_FS_LITTLEFS_FC_HEAP_SIZE=16384 \ No newline at end of file +CONFIG_FS_LITTLEFS_FC_HEAP_SIZE=16384 + +CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y +CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y +CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x100000 \ No newline at end of file diff --git a/app/boards/arm/zswatch_nrf5340/zswatch_nrf5340_cpunet_3.conf b/app/boards/arm/zswatch_nrf5340/zswatch_nrf5340_cpunet_3.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/nrf5340dk_nrf5340_cpuapp.conf b/app/boards/nrf5340dk_nrf5340_cpuapp.conf index ccd499ca..b3ff09f2 100644 --- a/app/boards/nrf5340dk_nrf5340_cpuapp.conf +++ b/app/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -17,4 +17,7 @@ CONFIG_FILE_SYSTEM_LITTLEFS=y CONFIG_LV_Z_USE_FILESYSTEM=y CONFIG_LV_IMG_CACHE_DEF_SIZE=10 -CONFIG_FS_LITTLEFS_FC_HEAP_SIZE=16384 \ No newline at end of file +CONFIG_FS_LITTLEFS_FC_HEAP_SIZE=16384 + +CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y +CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x100000 \ No newline at end of file diff --git a/app/boards/nrf5340dk_nrf5340_cpuapp.overlay b/app/boards/nrf5340dk_nrf5340_cpuapp.overlay index 459eca87..b4647883 100644 --- a/app/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/app/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -59,6 +59,7 @@ chosen { zephyr,display = &gc9a01; zephyr,keyboard-scan = &cst816s; + nordic,pm-ext-flash = &mx25r64; }; aliases { diff --git a/app/partition_zs.yml b/app/partition_zs.yml new file mode 100644 index 00000000..f0f46f5d --- /dev/null +++ b/app/partition_zs.yml @@ -0,0 +1,15 @@ +#------------------- +# External partition +# ------------------ +lvgl_lfs_partition: + address: 0x0 + region: external_flash + size: 0x200000 +lvgl_raw_partition: + address: 0x200000 + region: external_flash + size: 0x200000 +settings_partition: + address: 0x400000 + region: external_flash + size: 0x100000 diff --git a/app/patches/lvgl_scroll_click.patch b/app/patches/lvgl_scroll_click.patch new file mode 100644 index 00000000..649e4644 --- /dev/null +++ b/app/patches/lvgl_scroll_click.patch @@ -0,0 +1,35 @@ +diff --git a/modules/lvgl/input/lvgl_common_input.c b/modules/lvgl/input/lvgl_common_input.c +index 23b61a230e..9e2cfb5019 100644 +--- a/modules/lvgl/input/lvgl_common_input.c ++++ b/modules/lvgl/input/lvgl_common_input.c +@@ -15,7 +15,18 @@ static void lvgl_input_read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) + { + const struct device *dev = drv->user_data; + const struct lvgl_common_input_config *cfg = dev->config; ++ struct lvgl_common_input_data *common_data = dev->data; ++ ++ if (k_msgq_get(cfg->event_msgq, data, K_NO_WAIT) != 0) { ++ memcpy(data, &common_data->previous_event, sizeof(lv_indev_data_t)); ++ if (drv->type == LV_INDEV_TYPE_ENCODER) { ++ data->enc_diff = 0; /* For encoders, clear last movement */ ++ } ++ data->continue_reading = false; ++ return; ++ } + ++ memcpy(&common_data->previous_event, data, sizeof(lv_indev_data_t)); + k_msgq_get(cfg->event_msgq, data, K_NO_WAIT); + data->continue_reading = k_msgq_num_used_get(cfg->event_msgq) > 0; + } +diff --git a/modules/lvgl/input/lvgl_common_input.h b/modules/lvgl/input/lvgl_common_input.h +index e9d0ef34f8..2c1b2bd9a5 100644 +--- a/modules/lvgl/input/lvgl_common_input.h ++++ b/modules/lvgl/input/lvgl_common_input.h +@@ -23,6 +23,7 @@ struct lvgl_common_input_data { + lv_indev_drv_t indev_drv; + lv_indev_t *indev; + lv_indev_data_t pending_event; ++ lv_indev_data_t previous_event; + }; + + int lvgl_input_register_driver(lv_indev_type_t indev_type, const struct device *dev); diff --git a/app/src/main.c b/app/src/main.c index cc1ced9d..b28b3d22 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -605,6 +605,7 @@ static void on_zbus_ble_data_callback(const struct zbus_channel *chan) } } +#ifndef CONFIG_RESET_ON_FATAL_ERROR void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf) { ARG_UNUSED(esf); @@ -617,3 +618,4 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf) CODE_UNREACHABLE; } +#endif diff --git a/app/west.yml b/app/west.yml index cbd140fe..0bf5ae1a 100644 --- a/app/west.yml +++ b/app/west.yml @@ -3,13 +3,14 @@ manifest: west-commands: scripts/west-commands.yml remotes: - - name: zephyrproject-rtos - url-base: https://github.com/zephyrproject-rtos + - name: sdk + url-base: https://github.com/nrfconnect projects: - - name: zephyr - remote: zephyrproject-rtos - revision: 2ea2d37d60ada33bdf051eb9d699f4db9123c3ff + - name: sdk-nrf + remote: sdk + revision: v2.5.0 + path: nrf import: name-blocklist: - ci-tools @@ -24,9 +25,10 @@ manifest: - hal_ti - loramac-node - net-tools - - openthread - edtt - trusted-firmware-m - sof + clone-depth: 1 + self: west-commands: scripts/west-commands.yml diff --git a/app/zephyr/module.yml b/app/zephyr/module.yml deleted file mode 100644 index 74a02aab..00000000 --- a/app/zephyr/module.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2021 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -build: - # Path to the Kconfig file that will be sourced into Zephyr Kconfig tree under - # Zephyr > Modules > example-application. Path is relative from root of this - # repository. - # kconfig: Kconfig - # Path to the folder that contains the CMakeLists.txt file to be included by - # Zephyr build system. The `.` is the root of this repository. - cmake: . - settings: - # Additional roots for boards and DTS files. Zephyr will use the - # `/boards` for additional boards. The `.` is the root of this - # repository. - board_root: . - # Zephyr will use the `/dts` for additional dts files and - # `/dts/bindings` for additional dts binding files. The `.` is - # the root of this repository. - dts_root: . \ No newline at end of file