From 7a7478df8e603c7df03921d1659d59e07e89dd59 Mon Sep 17 00:00:00 2001 From: Marcin Gasiorek Date: Wed, 28 Aug 2024 13:51:15 +0200 Subject: [PATCH] samples: Adde support for nRF54L Update NCS version and add nRF54L support. Signed-off-by: Marcin Gasiorek --- CMakeLists.txt | 2 +- README.md | 3 +- samples/SWTL001/CMakeLists.txt | 34 +- samples/SWTL001/Kconfig | 57 ++- samples/SWTL001/Kconfig.sensor_monitoring | 36 ++ samples/SWTL001/Kconfig.sysbuild | 54 ++ .../boards/nrf52840dk_nrf52840.overlay | 31 ++ .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 31 ++ .../nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf | 13 + .../nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay | 107 ++++ .../nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf | 7 + .../nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay | 100 ++++ ...4l15pdk_nrf54l15_cpuapp_release_0_2_1.conf | 13 + ...4l15pdk_nrf54l15_cpuapp_release_0_3_0.conf | 7 + .../SWTL001/child_image/hci_ipc/Kconfig.root | 69 --- samples/SWTL001/child_image/hci_ipc/prj.conf | 8 - .../child_image/hci_ipc/prj_no_dfu.conf | 8 - .../child_image/hci_ipc/prj_release.conf | 9 - .../SWTL001/child_image/mcuboot/Kconfig.root | 127 ----- .../boards/nrf52840dk_nrf52840.overlay | 11 - .../nrf52840dk_nrf52840_release.overlay | 11 - .../boards/nrf5340dk_nrf5340_cpuapp.conf | 33 -- .../nrf5340dk_nrf5340_cpuapp_release.conf | 33 -- .../nrf5340dk_nrf5340_cpuapp_release.overlay | 11 - samples/SWTL001/child_image/mcuboot/prj.conf | 22 - .../child_image/mcuboot/prj_release.conf | 22 - .../configuration/pm_static_no_dfu.yml | 5 - samples/SWTL001/include/app.h | 5 + samples/SWTL001/pm_static.yml | 10 - ....yml => pm_static_nrf52840dk_nrf52840.yml} | 0 ...pm_static_nrf52840dk_nrf52840_release.yml} | 0 ...=> pm_static_nrf5340dk_nrf5340_cpuapp.yml} | 0 ...atic_nrf5340dk_nrf5340_cpuapp_release.yml} | 0 .../pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml | 71 +++ ...ic_nrf54l15pdk_nrf54l15_cpuapp_release.yml | 71 +++ ... => pm_static_thingy53_nrf5340_cpuapp.yml} | 0 samples/SWTL001/prj_no_dfu.conf | 22 - samples/SWTL001/sample.yaml | 68 +-- samples/SWTL001/src/main.c | 3 - samples/SWTL001/src/swtl001/app.c | 1 + samples/SWTL001/sysbuild/ipc_radio/prj.conf | 35 ++ .../mcuboot/boards/nrf52840dk_nrf52840.conf | 10 + .../boards/nrf52840dk_nrf52840.overlay} | 3 +- .../boards/nrf5340dk_nrf5340_cpuapp.conf | 28 ++ .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 3 +- .../boards/nrf54l15pdk_nrf54l15_cpuapp.conf | 13 + .../nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay | 7 + .../nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay | 11 + .../boards/thingy53_nrf5340_cpuapp.conf | 3 - .../boards/thingy53_nrf5340_cpuapp.overlay} | 3 +- samples/SWTL001/sysbuild/mcuboot/prj.conf | 39 ++ samples/lbm_sid_end_device/CMakeLists.txt | 24 +- samples/lbm_sid_end_device/Kconfig | 30 +- samples/lbm_sid_end_device/Kconfig.sysbuild | 54 ++ .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 31 ++ .../nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf | 13 + .../nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay | 104 ++++ .../nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf | 7 + .../nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay | 100 ++++ ...4l15pdk_nrf54l15_cpuapp_release_0_2_1.conf | 13 + ...4l15pdk_nrf54l15_cpuapp_release_0_3_0.conf | 7 + .../child_image/hci_ipc/Kconfig.root | 69 --- .../child_image/hci_ipc/prj.conf | 8 - .../child_image/hci_ipc/prj_no_dfu.conf | 8 - .../child_image/hci_ipc/prj_release.conf | 9 - .../child_image/mcuboot/Kconfig.root | 127 ----- .../boards/nrf52840dk_nrf52840.overlay | 11 - .../nrf52840dk_nrf52840_release.overlay | 11 - .../boards/nrf5340dk_nrf5340_cpuapp.conf | 33 -- .../nrf5340dk_nrf5340_cpuapp_release.conf | 33 -- .../nrf5340dk_nrf5340_cpuapp_release.overlay | 11 - .../child_image/mcuboot/prj.conf | 22 - .../child_image/mcuboot/prj_release.conf | 22 - .../configuration/pm_static_no_dfu.yml | 5 - samples/lbm_sid_end_device/include/app.h | 5 + .../include/file_transfer.h | 17 - .../include/sbdt/file_transfer.h | 26 + .../include/sbdt/scratch_buffer.h | 37 ++ samples/lbm_sid_end_device/include/sidewalk.h | 14 + samples/lbm_sid_end_device/pm_static.yml | 10 - .../pm_static_nrf52840dk_nrf52840.yml} | 0 .../pm_static_nrf52840dk_nrf52840_release.yml | 73 +++ .../pm_static_nrf5340dk_nrf5340_cpuapp.yml} | 0 ...tatic_nrf5340dk_nrf5340_cpuapp_release.yml | 119 +++++ .../pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml | 71 +++ ...ic_nrf54l15pdk_nrf54l15_cpuapp_release.yml | 71 +++ ... => pm_static_thingy53_nrf5340_cpuapp.yml} | 0 samples/lbm_sid_end_device/prj_no_dfu.conf | 22 - samples/lbm_sid_end_device/sample.yaml | 68 +-- samples/lbm_sid_end_device/src/cli/app.c | 17 +- samples/lbm_sid_end_device/src/cli/app_dut.c | 12 +- .../lbm_sid_end_device/src/cli/app_shell.c | 29 +- .../src/cli/sid_on_dev_cert_cli.c | 467 ++++++++++++++++++ samples/lbm_sid_end_device/src/hello/app.c | 31 +- .../src/lbm/app_lbm_sidewalk.c | 6 +- .../lbm_sid_end_device/src/lbm/app_nav3_lbm.c | 4 +- .../src/lbm/app_nav3_sidewalk.c | 7 +- .../src/lbm/main_geolocation_lbm.c | 2 + .../src/lbm/main_geolocation_sidewalk.c | 2 + .../src/lbm/main_periodical_uplink.c | 2 + samples/lbm_sid_end_device/src/main.c | 3 - .../src/sensor_monitoring/app.c | 29 +- .../src/sensor_monitoring/app_tx.c | 29 +- samples/lbm_sid_end_device/src/sidewalk.c | 206 ++++++-- .../sysbuild/ipc_radio/prj.conf | 35 ++ .../mcuboot/boards/nrf52840dk_nrf52840.conf | 10 + .../boards/nrf52840dk_nrf52840.overlay | 12 + .../boards/nrf5340dk_nrf5340_cpuapp.conf | 28 ++ .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 3 +- .../boards/nrf54l15pdk_nrf54l15_cpuapp.conf | 13 + .../nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay | 7 + .../nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay | 11 + .../boards/thingy53_nrf5340_cpuapp.conf | 3 - .../boards/thingy53_nrf5340_cpuapp.overlay | 12 + .../sysbuild/mcuboot/prj.conf | 39 ++ samples/sid_end_device/CMakeLists.txt | 24 +- samples/sid_end_device/Kconfig | 38 +- samples/sid_end_device/Kconfig.sysbuild | 54 ++ samples/sid_end_device/VERSION | 5 + .../boards/nrf5340dk_nrf5340_cpuapp.conf | 19 - .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 31 ++ .../nrf5340dk_nrf5340_cpuapp_release.conf | 19 - .../nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf | 13 + .../nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay | 107 ++++ .../nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf | 7 + .../nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay | 100 ++++ ...4l15pdk_nrf54l15_cpuapp_release_0_2_1.conf | 13 + ...4l15pdk_nrf54l15_cpuapp_release_0_3_0.conf | 7 + .../thingy53_nrf5340_cpuapp_no_dfu.conf | 10 - .../child_image/hci_ipc/Kconfig.root | 69 --- .../child_image/hci_ipc/prj.conf | 8 - .../child_image/hci_ipc/prj_no_dfu.conf | 8 - .../child_image/hci_ipc/prj_release.conf | 9 - .../child_image/mcuboot/Kconfig.root | 127 ----- .../boards/nrf52840dk_nrf52840.overlay | 11 - .../nrf52840dk_nrf52840_release.overlay | 11 - .../boards/nrf5340dk_nrf5340_cpuapp.conf | 33 -- .../nrf5340dk_nrf5340_cpuapp_release.conf | 33 -- .../nrf5340dk_nrf5340_cpuapp_release.overlay | 11 - .../thingy53_nrf5340dk_nrf5340_cpuapp.overlay | 11 - .../child_image/mcuboot/prj.conf | 22 - .../child_image/mcuboot/prj_release.conf | 22 - .../configuration/pm_static_no_dfu.yml | 5 - samples/sid_end_device/include/app.h | 5 + .../sid_end_device/include/file_transfer.h | 17 - .../include/sbdt/file_transfer.h | 26 + .../include/sbdt/scratch_buffer.h | 37 ++ samples/sid_end_device/include/sidewalk.h | 14 + samples/sid_end_device/overlay-dut.conf | 3 + samples/sid_end_device/pm_static.yml | 10 - .../pm_static_nrf52840dk_nrf52840.yml | 73 +++ .../pm_static_nrf52840dk_nrf52840_release.yml | 73 +++ .../pm_static_nrf5340dk_nrf5340_cpuapp.yml | 119 +++++ ...tatic_nrf5340dk_nrf5340_cpuapp_release.yml | 119 +++++ .../pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml | 71 +++ ...ic_nrf54l15pdk_nrf54l15_cpuapp_release.yml | 71 +++ ... => pm_static_thingy53_nrf5340_cpuapp.yml} | 0 samples/sid_end_device/prj_no_dfu.conf | 22 - samples/sid_end_device/sample.yaml | 68 +-- samples/sid_end_device/src/cli/app.c | 17 +- samples/sid_end_device/src/cli/app_dut.c | 12 +- samples/sid_end_device/src/cli/app_shell.c | 29 +- .../src/cli/sid_on_dev_cert_cli.c | 467 ++++++++++++++++++ samples/sid_end_device/src/file_transfer.c | 168 ------- samples/sid_end_device/src/hello/app.c | 25 +- samples/sid_end_device/src/main.c | 3 - .../src/sbdt}/file_transfer.c | 145 +++--- .../sid_end_device/src/sbdt/scratch_buffer.c | 82 +++ .../src/sensor_monitoring/app.c | 29 +- .../src/sensor_monitoring/app_tx.c | 29 +- samples/sid_end_device/src/sidewalk.c | 200 ++++++-- .../sysbuild/ipc_radio/prj.conf | 35 ++ .../mcuboot/boards/nrf52840dk_nrf52840.conf | 10 + .../boards/nrf52840dk_nrf52840.overlay | 12 + .../boards/nrf5340dk_nrf5340_cpuapp.conf | 28 ++ .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 3 +- .../boards/nrf54l15pdk_nrf54l15_cpuapp.conf | 13 + .../nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay | 7 + .../nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay | 11 + .../boards/thingy53_nrf5340_cpuapp.conf | 3 - .../boards/thingy53_nrf5340_cpuapp.overlay | 12 + .../sid_end_device/sysbuild/mcuboot/prj.conf | 39 ++ v261_nRF52840_sidewalk_lr11xx.diff | 106 ---- v270_sidewalk_lr11xx.diff | 89 ++++ west.yml | 4 +- 185 files changed, 4650 insertions(+), 2057 deletions(-) create mode 100644 samples/SWTL001/Kconfig.sensor_monitoring create mode 100644 samples/SWTL001/Kconfig.sysbuild create mode 100644 samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf create mode 100644 samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay create mode 100644 samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf create mode 100644 samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay create mode 100644 samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf create mode 100644 samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf delete mode 100644 samples/SWTL001/child_image/hci_ipc/Kconfig.root delete mode 100644 samples/SWTL001/child_image/hci_ipc/prj.conf delete mode 100644 samples/SWTL001/child_image/hci_ipc/prj_no_dfu.conf delete mode 100644 samples/SWTL001/child_image/hci_ipc/prj_release.conf delete mode 100644 samples/SWTL001/child_image/mcuboot/Kconfig.root delete mode 100644 samples/SWTL001/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay delete mode 100644 samples/SWTL001/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay delete mode 100644 samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf delete mode 100644 samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf delete mode 100644 samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay delete mode 100644 samples/SWTL001/child_image/mcuboot/prj.conf delete mode 100644 samples/SWTL001/child_image/mcuboot/prj_release.conf delete mode 100644 samples/SWTL001/configuration/pm_static_no_dfu.yml delete mode 100644 samples/SWTL001/pm_static.yml rename samples/SWTL001/{configuration/nrf52840dk_nrf52840/pm_static_dfu.yml => pm_static_nrf52840dk_nrf52840.yml} (100%) rename samples/{lbm_sid_end_device/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml => SWTL001/pm_static_nrf52840dk_nrf52840_release.yml} (100%) rename samples/SWTL001/{configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml => pm_static_nrf5340dk_nrf5340_cpuapp.yml} (100%) rename samples/{lbm_sid_end_device/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml => SWTL001/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml} (100%) create mode 100644 samples/SWTL001/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml create mode 100644 samples/SWTL001/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml rename samples/SWTL001/{configuration/thingy53_nrf5340_cpuapp/pm_static_dfu.yml => pm_static_thingy53_nrf5340_cpuapp.yml} (100%) delete mode 100644 samples/SWTL001/prj_no_dfu.conf create mode 100644 samples/SWTL001/sysbuild/ipc_radio/prj.conf create mode 100644 samples/SWTL001/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf rename samples/{lbm_sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay => SWTL001/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay} (77%) create mode 100644 samples/SWTL001/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf rename samples/{lbm_sid_end_device/child_image => SWTL001/sysbuild}/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay (77%) create mode 100644 samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf create mode 100644 samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay create mode 100644 samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay rename samples/{lbm_sid_end_device/child_image => SWTL001/sysbuild}/mcuboot/boards/thingy53_nrf5340_cpuapp.conf (93%) rename samples/SWTL001/{child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay => sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay} (77%) create mode 100644 samples/SWTL001/sysbuild/mcuboot/prj.conf create mode 100644 samples/lbm_sid_end_device/Kconfig.sysbuild create mode 100644 samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf create mode 100644 samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay create mode 100644 samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf create mode 100644 samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay create mode 100644 samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf create mode 100644 samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf delete mode 100644 samples/lbm_sid_end_device/child_image/hci_ipc/Kconfig.root delete mode 100644 samples/lbm_sid_end_device/child_image/hci_ipc/prj.conf delete mode 100644 samples/lbm_sid_end_device/child_image/hci_ipc/prj_no_dfu.conf delete mode 100644 samples/lbm_sid_end_device/child_image/hci_ipc/prj_release.conf delete mode 100644 samples/lbm_sid_end_device/child_image/mcuboot/Kconfig.root delete mode 100644 samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay delete mode 100644 samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay delete mode 100644 samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf delete mode 100644 samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf delete mode 100644 samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay delete mode 100644 samples/lbm_sid_end_device/child_image/mcuboot/prj.conf delete mode 100644 samples/lbm_sid_end_device/child_image/mcuboot/prj_release.conf delete mode 100644 samples/lbm_sid_end_device/configuration/pm_static_no_dfu.yml delete mode 100644 samples/lbm_sid_end_device/include/file_transfer.h create mode 100644 samples/lbm_sid_end_device/include/sbdt/file_transfer.h create mode 100644 samples/lbm_sid_end_device/include/sbdt/scratch_buffer.h delete mode 100644 samples/lbm_sid_end_device/pm_static.yml rename samples/{sid_end_device/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml => lbm_sid_end_device/pm_static_nrf52840dk_nrf52840.yml} (100%) create mode 100644 samples/lbm_sid_end_device/pm_static_nrf52840dk_nrf52840_release.yml rename samples/{sid_end_device/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml => lbm_sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp.yml} (100%) create mode 100644 samples/lbm_sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml create mode 100644 samples/lbm_sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml create mode 100644 samples/lbm_sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml rename samples/lbm_sid_end_device/{configuration/thingy53_nrf5340_cpuapp/pm_static_dfu.yml => pm_static_thingy53_nrf5340_cpuapp.yml} (100%) delete mode 100644 samples/lbm_sid_end_device/prj_no_dfu.conf create mode 100644 samples/lbm_sid_end_device/src/cli/sid_on_dev_cert_cli.c create mode 100644 samples/lbm_sid_end_device/sysbuild/ipc_radio/prj.conf create mode 100644 samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf create mode 100644 samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay create mode 100644 samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf rename samples/{sid_end_device/child_image => lbm_sid_end_device/sysbuild}/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay (77%) create mode 100644 samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf create mode 100644 samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay create mode 100644 samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay rename samples/{sid_end_device/child_image => lbm_sid_end_device/sysbuild}/mcuboot/boards/thingy53_nrf5340_cpuapp.conf (93%) create mode 100644 samples/lbm_sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay create mode 100644 samples/lbm_sid_end_device/sysbuild/mcuboot/prj.conf create mode 100644 samples/sid_end_device/Kconfig.sysbuild create mode 100644 samples/sid_end_device/VERSION delete mode 100644 samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.conf delete mode 100644 samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp_release.conf create mode 100644 samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf create mode 100644 samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay create mode 100644 samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf create mode 100644 samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay create mode 100644 samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf create mode 100644 samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf delete mode 100644 samples/sid_end_device/boards/thingy53_nrf5340_cpuapp_no_dfu.conf delete mode 100644 samples/sid_end_device/child_image/hci_ipc/Kconfig.root delete mode 100644 samples/sid_end_device/child_image/hci_ipc/prj.conf delete mode 100644 samples/sid_end_device/child_image/hci_ipc/prj_no_dfu.conf delete mode 100644 samples/sid_end_device/child_image/hci_ipc/prj_release.conf delete mode 100644 samples/sid_end_device/child_image/mcuboot/Kconfig.root delete mode 100644 samples/sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay delete mode 100644 samples/sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay delete mode 100644 samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf delete mode 100644 samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf delete mode 100644 samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay delete mode 100644 samples/sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay delete mode 100644 samples/sid_end_device/child_image/mcuboot/prj.conf delete mode 100644 samples/sid_end_device/child_image/mcuboot/prj_release.conf delete mode 100644 samples/sid_end_device/configuration/pm_static_no_dfu.yml delete mode 100644 samples/sid_end_device/include/file_transfer.h create mode 100644 samples/sid_end_device/include/sbdt/file_transfer.h create mode 100644 samples/sid_end_device/include/sbdt/scratch_buffer.h delete mode 100644 samples/sid_end_device/pm_static.yml create mode 100644 samples/sid_end_device/pm_static_nrf52840dk_nrf52840.yml create mode 100644 samples/sid_end_device/pm_static_nrf52840dk_nrf52840_release.yml create mode 100644 samples/sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp.yml create mode 100644 samples/sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml create mode 100644 samples/sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml create mode 100644 samples/sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml rename samples/sid_end_device/{configuration/thingy53_nrf5340_cpuapp/pm_static_dfu.yml => pm_static_thingy53_nrf5340_cpuapp.yml} (100%) delete mode 100644 samples/sid_end_device/prj_no_dfu.conf create mode 100644 samples/sid_end_device/src/cli/sid_on_dev_cert_cli.c delete mode 100644 samples/sid_end_device/src/file_transfer.c rename samples/{lbm_sid_end_device/src => sid_end_device/src/sbdt}/file_transfer.c (59%) create mode 100644 samples/sid_end_device/src/sbdt/scratch_buffer.c create mode 100644 samples/sid_end_device/sysbuild/ipc_radio/prj.conf create mode 100644 samples/sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf create mode 100644 samples/sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay create mode 100644 samples/sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf rename samples/{SWTL001/child_image => sid_end_device/sysbuild}/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay (77%) create mode 100644 samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf create mode 100644 samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay create mode 100644 samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay rename samples/{SWTL001/child_image => sid_end_device/sysbuild}/mcuboot/boards/thingy53_nrf5340_cpuapp.conf (93%) create mode 100644 samples/sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay create mode 100644 samples/sid_end_device/sysbuild/mcuboot/prj.conf delete mode 100644 v261_nRF52840_sidewalk_lr11xx.diff create mode 100644 v270_sidewalk_lr11xx.diff diff --git a/CMakeLists.txt b/CMakeLists.txt index c2ba1a3..45d5404 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if(CONFIG_RADIO_LR11XX) message( STATUS "patch needs to be applied? ret=" ${ret}) Set(script_name ${CMAKE_CURRENT_SOURCE_DIR}/scripts/patch_ng.py) Set(args "-p 1") - Set(pfile ${CMAKE_CURRENT_SOURCE_DIR}/v261_nRF52840_sidewalk_lr11xx.diff) + Set(pfile ${CMAKE_CURRENT_SOURCE_DIR}/v270_sidewalk_lr11xx.diff) execute_process( COMMAND ${Python3_EXECUTABLE} ${script_name} ${args} ${pfile} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../sidewalk diff --git a/README.md b/README.md index 84b655b..a3538c7 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ west init -m https://github.com/Lora-net/SWSD006 --mr v2.6.1 my-workspace # update nRF Connect SDK modules cd my-workspace west update +west config build.sysbuild True ``` If you intend to build a LoRa Basics Modem project on the windows platform, decide on a workspace location as near the root directory as possible in order to prevent path lengths that exceed the capability of the zephyr build system on windows. This is not a concern on other platforms such as linux. ### configuring project for LR11xx @@ -71,7 +72,7 @@ from the directory ``samples/lbm_sid_end_device`` --> * NAV3 running simultanously with sidewalk (aka NAV3 in bypass mode): * ``-DOVERLAY_CONFIG=overlay-nav3sid.conf`` * NAV3 running in lora basics modem: - * `-DOVERLAY_CONFIG=overlay-nav3lbm.conf`` + * ``-DOVERLAY_CONFIG=overlay-nav3lbm.conf`` * LR11xx firmware update, and almanac erase: * build in ``samples/SWTL001``directory diff --git a/samples/SWTL001/CMakeLists.txt b/samples/SWTL001/CMakeLists.txt index 0a9682f..c2d4d6b 100644 --- a/samples/SWTL001/CMakeLists.txt +++ b/samples/SWTL001/CMakeLists.txt @@ -6,24 +6,6 @@ cmake_minimum_required(VERSION 3.20.0) -# Sidewalk version -include(bootloader_version.cmake) - -# Child images -set(hci_ipc_KCONFIG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/child_image/hci_ipc/Kconfig.root) -set(mcuboot_KCONFIG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/child_image/mcuboot/Kconfig.root) - -# Configurations -if(CONF_FILE) - get_filename_component(CONFIG_FILE_NAME ${CONF_FILE} NAME) -endif() - -if("${CONFIG_FILE_NAME}" STREQUAL "prj_no_dfu.conf") - set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/pm_static_no_dfu.yml) -else() - set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static_dfu.yml) -endif() - # Zephyr CMake project find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(sidewalk_sid_end_device) @@ -34,13 +16,18 @@ target_sources(app PRIVATE src/main.c ) +target_sources_ifdef(CONFIG_SIDEWALK_FILE_TRANSFER app PRIVATE + src/sbdt/file_transfer.c + src/sbdt/scratch_buffer.c +) + if(CONFIG_SID_END_DEVICE_SWTL001) target_sources(app PRIVATE src/swtl001/app.c - src/swtl001/lr11xx_firmware_update.c + src/swtl001/lr11xx_firmware_update.c ) else() - message(SEND_ERROR "only swtl001") + message(SEND_ERROR "only swtl001") endif() if(CONFIG_SID_END_DEVICE_CLI) @@ -48,11 +35,12 @@ if(CONFIG_SID_END_DEVICE_CLI) src/cli/app_dut.c src/cli/app_shell.c ) + target_sources_ifdef(CONFIG_SIDEWALK_ON_DEV_CERT app PRIVATE src/cli/sid_on_dev_cert_cli.c) endif() if(CONFIG_SMTC_CLI) target_sources(app PRIVATE - src/cli/smtc_shell.c - ) - target_compile_definitions(app PRIVATE CONFIG_SMTC_CLI) + src/cli/smtc_shell.c + ) + target_compile_definitions(app PRIVATE CONFIG_SMTC_CLI) endif() diff --git a/samples/SWTL001/Kconfig b/samples/SWTL001/Kconfig index cf063dd..a2099d7 100644 --- a/samples/SWTL001/Kconfig +++ b/samples/SWTL001/Kconfig @@ -13,6 +13,23 @@ config SID_END_DEVICE_SWTL001 bool "LR11xx firmware update application" endchoice #SID_END_DEVICE +if SID_END_DEVICE_HELLO + +config SID_END_DEVICE_ECHO_MSGS + bool "Eable message echo feature" + default y + help + Echo received messages back to Sidewlak cloud. + Works with GET and SET messages types. + +endif #SID_END_DEVICE_HELLO + +if SID_END_DEVICE_SENSOR_MONITORING + +rsource "Kconfig.sensor_monitoring" + +endif #SID_END_DEVICE_SENSOR_MONITORING + config SID_END_DEVICE_CLI bool "Enable Sidewalk CLI (DUT)" imply SHELL @@ -21,10 +38,10 @@ config SID_END_DEVICE_CLI The interface commands are compatilbe with former dut sample. config SMTC_CLI - bool "enable semtech CLI" - imply SHELL - help - Enables semtech radio command line interface. + bool "enable semtech CLI" + imply SHELL + help + Enables semtech radio command line interface. config SID_END_DEVICE_AUTO_START default y @@ -45,6 +62,38 @@ config SID_END_DEVICE_EVENT_HEAP_SIZE int "Heap for Sidewalk event contexts" default 2048 +config SIDEWALK_FILE_TRANSFER + select EXPERIMENTAL + bool "Enable Sidewalk file transfer" + help + Add support for Sidewalk Bulk Data Transfer (SBDT) + in application. + +if SIDEWALK_FILE_TRANSFER + +config SIDEWALK_FILE_TRANSFER_HEAP_SIZE + int "Sidewalk file transfer heap size" + default 10240 + help + Heap size in bytes to be allocated + for Sidewalk Bulk Data Transfer (SBDT). + +config SIDEWALK_FILE_TRANSFER_DFU + bool "Sildewak file transfer and dfu" + default SIDEWALK_FILE_TRANSFER + imply SIDEWALK_DFU_IMG_UTILS + imply DFU_MULTI_IMAGE + imply DFU_TARGET + imply DFU_TARGET_MCUBOOT + imply STREAM_FLASH + imply STREAM_FLASH_ERASE + imply SIDEWALK_THREAD_QUEUE_TIMEOUT + help + Save recived data to flash. Expect CBOR manifest. + Autoatically reset device after file transfer. + +endif + rsource "Kconfig.defconfig" source "Kconfig.zephyr" diff --git a/samples/SWTL001/Kconfig.sensor_monitoring b/samples/SWTL001/Kconfig.sensor_monitoring new file mode 100644 index 0000000..9bc079a --- /dev/null +++ b/samples/SWTL001/Kconfig.sensor_monitoring @@ -0,0 +1,36 @@ +# +# Copyright (c) 2022 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +config SID_END_DEVICE_NOTIFY_DATA_PERIOD_MS + int "Notify period of sensor monitoring demo app" + default 10000 + +config SIDEWALK_THREAD_PRIORITY + default 12 + +config SID_END_DEVICE_TX_THREAD_PRIORITY + int + default 13 + +config SID_END_DEVICE_RX_THREAD_PRIORITY + int + default 14 + +config SID_END_DEVICE_TX_THREAD_STACK_SIZE + int + default 4096 + +config SID_END_DEVICE_RX_THREAD_STACK_SIZE + int + default 4096 + +config SID_END_DEVICE_TX_THREAD_QUEUE_SIZE + int + default 10 + +config SID_END_DEVICE_RX_THREAD_QUEUE_SIZE + int + default 4 diff --git a/samples/SWTL001/Kconfig.sysbuild b/samples/SWTL001/Kconfig.sysbuild new file mode 100644 index 0000000..404f972 --- /dev/null +++ b/samples/SWTL001/Kconfig.sysbuild @@ -0,0 +1,54 @@ +# +# Copyright (c) 2023 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +config NRF_DEFAULT_IPC_RADIO + default y if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP + +choice BOOTLOADER + default BOOTLOADER_MCUBOOT +endchoice + +if BOOTLOADER_MCUBOOT + +config DFU_MULTI_IMAGE_PACKAGE_BUILD + default y + +config DFU_MULTI_IMAGE_PACKAGE_APP + default y + +if (BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP) + +config MCUBOOT_UPDATEABLE_IMAGES + default 2 + +choice MCUBOOT_MODE + default MCUBOOT_MODE_OVERWRITE_ONLY +endchoice + +choice BOOT_SIGNATURE_TYPE + default BOOT_SIGNATURE_TYPE_RSA +endchoice + +config SECURE_BOOT + default y + +config SECURE_BOOT_NETCORE + default y + +config NETCORE_APP_UPDATE + default y + +config DFU_MULTI_IMAGE_PACKAGE_NET + default y + +endif # BOOTLOADER_MCUBOOT + +endif # (BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP) + +config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY + default y if BOARD_NRF52840DK_NRF52840 || BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/SWTL001/boards/nrf52840dk_nrf52840.overlay b/samples/SWTL001/boards/nrf52840dk_nrf52840.overlay index f89f842..46bdb13 100644 --- a/samples/SWTL001/boards/nrf52840dk_nrf52840.overlay +++ b/samples/SWTL001/boards/nrf52840dk_nrf52840.overlay @@ -18,6 +18,37 @@ sid_semtech: &spi2 { }; /{ + state_notifier_gpios{ + compatible = "gpio-keys"; + state_notifier_error: error { + gpios = <&gpio1 0x7 0x0>; + label = "Application state error"; + }; + state_notifier_dfu: dfu { + gpios = <&gpio1 0x1 0x0>; + label = "Application state dfu"; + }; + state_notifier_sending: sending { + gpios = <&gpio1 0x3 0x0>; + label = "Application state sending"; + }; + state_notifier_receiving: receiving { + gpios = <&gpio1 0x2 0x0>; + label = "Application state receiving"; + }; + }; + + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + state-notifier-error = &state_notifier_error; + state-notifier-dfu = &state_notifier_dfu; + state-notifier-sending = &state_notifier_sending; + state-notifier-receiving = &state_notifier_receiving; + }; + semtech_sx1262_gpios{ compatible = "gpio-keys"; semtech_sx1262_cs: cs { diff --git a/samples/SWTL001/boards/nrf5340dk_nrf5340_cpuapp.overlay b/samples/SWTL001/boards/nrf5340dk_nrf5340_cpuapp.overlay index 4395ed1..d0a7679 100644 --- a/samples/SWTL001/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/samples/SWTL001/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -20,6 +20,37 @@ }; /{ + state_notifier_gpios{ + compatible = "gpio-keys"; + state_notifier_error: error { + gpios = <&gpio1 0x8 0x0>; + label = "Application state error"; + }; + state_notifier_dfu: dfu { + gpios = <&gpio1 0x2 0x0>; + label = "Application state dfu"; + }; + state_notifier_sending: sending { + gpios = <&gpio1 0x4 0x0>; + label = "Application state sending"; + }; + state_notifier_receiving: receiving { + gpios = <&gpio1 0x3 0x0>; + label = "Application state receiving"; + }; + }; + + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + state-notifier-error = &state_notifier_error; + state-notifier-dfu = &state_notifier_dfu; + state-notifier-sending = &state_notifier_sending; + state-notifier-receiving = &state_notifier_receiving; + }; + semtech_sx1262_gpios{ compatible = "gpio-keys"; semtech_sx1262_cs: cs { diff --git a/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf new file mode 100644 index 0000000..d6a0780 --- /dev/null +++ b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Workaround: +# The nRF54L15 PDK (PCA10156) revisions v0.2.0 AA0-ES2, v0.2.0 AA0-ES3, +# and v0.2.1 AB0-ES5 have Buttons 3 and 4 connected to the GPIO port +# which does not support interrupts. +CONFIG_DK_LIBRARY_BUTTON_NO_ISR=y + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay new file mode 100644 index 0000000..811a033 --- /dev/null +++ b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/* Application does not use cpuflpr core. Assign whole RRAM to cpuapp. */ +&cpuapp_rram { + reg = < 0x0 DT_SIZE_K(1524) >; +}; +&pinctrl { + spi00_default: spi00_default { + group1 { + psels = , + , + ; + }; + }; + + spi00_sleep: spi00_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + +sid_semtech: &spi00 { + compatible = "nordic,nrf-spim"; + status = "okay"; + pinctrl-0 = <&spi00_default>; + pinctrl-1 = <&spi00_sleep>; + pinctrl-names = "default", "sleep"; + clock-frequency = ; +}; + +/{ + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + }; + + semtech_sx1262_gpios{ + compatible = "gpio-keys"; + semtech_sx1262_cs: cs { + gpios = <&gpio2 0xa GPIO_PULL_UP>; + label = "semtech_sx1262 CS"; + }; + semtech_sx1262_reset_gpios: reset { + gpios = <&gpio1 0xb (GPIO_ACTIVE_LOW|GPIO_PULL_UP)>; + label = "semtech_sx1262 Reset"; + }; + semtech_sx1262_busy_gpios: busy { + gpios = <&gpio1 0xc 0x0>; + label = "semtech_sx1262 Busy"; + }; + semtech_sx1262_antenna_enable_gpios: antena_enable { + gpios = <&gpio2 0x7 0x0>; + label = "semtech_sx1262 Antena Enable"; + }; + semtech_sx1262_dio1_gpios: dio1 { + gpios = <&gpio1 0xa 0x0>; + label = "semtech_sx1262 DIO1"; + }; + radio_gnss_lna: gnss_lna { + gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; + label = "gnss antenna"; + }; + radio_led_sniff: led_sniff { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "yellow LED"; + }; + radio_led_tx: led_tx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "red tx LED"; + }; + radio_led_rx: led_rx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "green rx LED"; + }; + }; + +}; + +&gpiote20 { + status = "okay"; +}; + +&gpiote30 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; diff --git a/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf new file mode 100644 index 0000000..e99da54 --- /dev/null +++ b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay new file mode 100644 index 0000000..5a08ece --- /dev/null +++ b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + +/* Application does not use cpuflpr core. Assign whole RRAM to cpuapp. */ +&cpuapp_rram { + reg = < 0x0 DT_SIZE_K(1524) >; +}; + + &pinctrl { + spi21_default: spi21_default { + group1 { + psels = , + , + ; + }; + }; + + spi21_sleep: spi21_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + + sid_semtech: &spi21 { + compatible = "nordic,nrf-spim"; + status = "okay"; + pinctrl-0 = <&spi21_default>; + pinctrl-1 = <&spi21_sleep>; + pinctrl-names = "default", "sleep"; + clock-frequency = ; +}; + +/{ + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + }; + + semtech_sx1262_gpios{ + compatible = "gpio-keys"; + semtech_sx1262_cs: cs { + gpios = <&gpio2 0xa GPIO_PULL_UP>; + label = "semtech_sx1262 CS"; + }; + semtech_sx1262_reset_gpios: reset { + gpios = <&gpio0 0x2 (GPIO_ACTIVE_LOW|GPIO_PULL_UP)>; + label = "semtech_sx1262 Reset"; + }; + semtech_sx1262_busy_gpios: busy { + gpios = <&gpio0 0x0 0x0>; + label = "semtech_sx1262 Busy"; + }; + semtech_sx1262_antenna_enable_gpios: antena_enable { + gpios = <&gpio0 0x1 0x0>; + label = "semtech_sx1262 Antena Enable"; + }; + semtech_sx1262_dio1_gpios: dio1 { + gpios = <&gpio0 0x3 0x0>; + label = "semtech_sx1262 DIO1"; + }; + radio_gnss_lna: gnss_lna { + gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; + label = "gnss antenna"; + }; + radio_led_sniff: led_sniff { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "yellow LED"; + }; + radio_led_tx: led_tx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "red tx LED"; + }; + radio_led_rx: led_rx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "green rx LED"; + }; + }; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; diff --git a/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf new file mode 100644 index 0000000..d6a0780 --- /dev/null +++ b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Workaround: +# The nRF54L15 PDK (PCA10156) revisions v0.2.0 AA0-ES2, v0.2.0 AA0-ES3, +# and v0.2.1 AB0-ES5 have Buttons 3 and 4 connected to the GPIO port +# which does not support interrupts. +CONFIG_DK_LIBRARY_BUTTON_NO_ISR=y + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf new file mode 100644 index 0000000..e99da54 --- /dev/null +++ b/samples/SWTL001/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/SWTL001/child_image/hci_ipc/Kconfig.root b/samples/SWTL001/child_image/hci_ipc/Kconfig.root deleted file mode 100644 index 60e8bd4..0000000 --- a/samples/SWTL001/child_image/hci_ipc/Kconfig.root +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# The purpose of this file is to create a wrapper Kconfig file that will be set as -# hci_ipc_KCONFIG_ROOT and processed before any other Kconfig for hci_ipc child image. - -config HEAP_MEM_POOL_SIZE - default 8192 - -config MAIN_STACK_SIZE - default 2048 - -config SYSTEM_WORKQUEUE_STACK_SIZE - default 2048 - -config BT - default y - -config BT_HCI_RAW - default y - -config BT_MAX_CONN - default 1 - -config BT_PERIPHERAL - default y - -config BT_CENTRAL - default n - -config BT_BUF_ACL_RX_SIZE - default 502 - -config BT_BUF_ACL_TX_SIZE - default 251 - -config BT_CTLR_DATA_LENGTH_MAX - default 251 - -config BT_CTLR_ASSERT_HANDLER - default y - -config BT_HCI_RAW_RESERVE - default 1 - -# Workaround: Unable to allocate command buffer when using K_NO_WAIT since -# Host number of completed commands does not follow normal flow control. -config BT_BUF_CMD_TX_COUNT - default 10 - -config ASSERT - default y - -config DEBUG_INFO - default y - -config EXCEPTION_STACK_TRACE - default y - -config IPC_SERVICE - default y - -config MBOX - default y - -source "Kconfig.zephyr" diff --git a/samples/SWTL001/child_image/hci_ipc/prj.conf b/samples/SWTL001/child_image/hci_ipc/prj.conf deleted file mode 100644 index c89bda6..0000000 --- a/samples/SWTL001/child_image/hci_ipc/prj.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_LOG=n -CONFIG_SERIAL=n -CONFIG_RESET_ON_FATAL_ERROR=n diff --git a/samples/SWTL001/child_image/hci_ipc/prj_no_dfu.conf b/samples/SWTL001/child_image/hci_ipc/prj_no_dfu.conf deleted file mode 100644 index c89bda6..0000000 --- a/samples/SWTL001/child_image/hci_ipc/prj_no_dfu.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_LOG=n -CONFIG_SERIAL=n -CONFIG_RESET_ON_FATAL_ERROR=n diff --git a/samples/SWTL001/child_image/hci_ipc/prj_release.conf b/samples/SWTL001/child_image/hci_ipc/prj_release.conf deleted file mode 100644 index 86c0d92..0000000 --- a/samples/SWTL001/child_image/hci_ipc/prj_release.conf +++ /dev/null @@ -1,9 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_LOG=n -CONFIG_SERIAL=n -CONFIG_UART_CONSOLE=n -CONFIG_RESET_ON_FATAL_ERROR=y diff --git a/samples/SWTL001/child_image/mcuboot/Kconfig.root b/samples/SWTL001/child_image/mcuboot/Kconfig.root deleted file mode 100644 index d6ecb28..0000000 --- a/samples/SWTL001/child_image/mcuboot/Kconfig.root +++ /dev/null @@ -1,127 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# The purpose of this file is to create a wrapper Kconfig file that will be set as -# mcuboot_KCONFIG_ROOT and processed before any other Kconfig for mcuboot child image. - - -config MAIN_STACK_SIZE - default 10240 - -config BOOT_SWAP_SAVE_ENCTLV - default n - -config BOOT_ENCRYPT_RSA - default n - -config BOOT_ENCRYPT_EC256 - default n - -config BOOT_ENCRYPT_X25519 - default n - -config BOOT_BOOTSTRAP - default n - -config PM - default n - -config FLASH - default y - -config FPROTECT - default y - -config NORDIC_QSPI_NOR - default y - -config NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE - default 4096 - -config NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE - default 16 - -config BOOT_MAX_IMG_SECTORS - default 256 - -config LOG - default n - -choice LIBC_IMPLEMENTATION - default MINIMAL_LIBC -endchoice - -config COMMON_LIBC_CALLOC - default y - -config COMMON_LIBC_MALLOC - default y - -config COMMON_LIBC_REALLOCARRAY - default y - -config NCS_SAMPLES_DEFAULTS - default n - -config PRINTK - default n - -config REBOOT - default n - -config NRF_RTC_TIMER - default y if SOC_SERIES_NRF53X - default n - -config CONSOLE - default n - -config CONSOLE_HANDLER - default n - -config GPIO - default n - -config KERNEL_MEM_POOL - default n - -config ASSERT - default n - -config BOOT_BANNER - default n - -config SERIAL - default n - -config UART_CONSOLE - default n - -config TIMESLICING - default n - -config USE_SEGGER_RTT - default n - -config RESET_ON_FATAL_ERROR - default n - -config SECURE_BOOT_DEBUG - default n - -config MULTITHREADING - default n - -config TICKLESS_KERNEL - default n - -config TIMEOUT_64BIT - default n - -config NRF_ENABLE_ICACHE - default n - -source "${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr/Kconfig" diff --git a/samples/SWTL001/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay b/samples/SWTL001/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay deleted file mode 100644 index 69bf975..0000000 --- a/samples/SWTL001/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -/ { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/SWTL001/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay b/samples/SWTL001/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay deleted file mode 100644 index 69bf975..0000000 --- a/samples/SWTL001/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -/ { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf deleted file mode 100644 index 3664dd3..0000000 --- a/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Increase main stack size -CONFIG_MAIN_STACK_SIZE=10240 - -# Configure MCUboot features -CONFIG_NRF53_MULTI_IMAGE_UPDATE=y -CONFIG_BOOT_UPGRADE_ONLY=y -CONFIG_BOOT_MAX_IMG_SECTORS=256 -CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y - -# Allow for storing two images in MCUboot partitions -CONFIG_UPDATEABLE_IMAGE_NUMBER=2 - -# Store new images inside external flash -CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y - -# Enable flash simulator -CONFIG_PCD_APP=y -CONFIG_FLASH_SIMULATOR=y -CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y -CONFIG_FLASH_SIMULATOR_STATS=n - -# Configure QSPI for external flash -CONFIG_FLASH=y -CONFIG_FPROTECT=y -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf b/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf deleted file mode 100644 index 3664dd3..0000000 --- a/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Increase main stack size -CONFIG_MAIN_STACK_SIZE=10240 - -# Configure MCUboot features -CONFIG_NRF53_MULTI_IMAGE_UPDATE=y -CONFIG_BOOT_UPGRADE_ONLY=y -CONFIG_BOOT_MAX_IMG_SECTORS=256 -CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y - -# Allow for storing two images in MCUboot partitions -CONFIG_UPDATEABLE_IMAGE_NUMBER=2 - -# Store new images inside external flash -CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y - -# Enable flash simulator -CONFIG_PCD_APP=y -CONFIG_FLASH_SIMULATOR=y -CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y -CONFIG_FLASH_SIMULATOR_STATS=n - -# Configure QSPI for external flash -CONFIG_FLASH=y -CONFIG_FPROTECT=y -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay b/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay deleted file mode 100644 index c670799..0000000 --- a/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - - / { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/SWTL001/child_image/mcuboot/prj.conf b/samples/SWTL001/child_image/mcuboot/prj.conf deleted file mode 100644 index 78d7622..0000000 --- a/samples/SWTL001/child_image/mcuboot/prj.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" - -CONFIG_BOOT_UPGRADE_ONLY=n -CONFIG_RESET_ON_FATAL_ERROR=y - -CONFIG_LOG=n -CONFIG_PRINTK=n -CONFIG_CONSOLE_HANDLER=n -CONFIG_ASSERT=n -CONFIG_BOOT_BANNER=n -CONFIG_CONSOLE=n -CONFIG_SERIAL=n -CONFIG_UART_CONSOLE=n -CONFIG_USE_SEGGER_RTT=n -CONFIG_GPIO=n -CONFIG_NO_RUNTIME_CHECKS=y -CONFIG_SIZE_OPTIMIZATIONS=y diff --git a/samples/SWTL001/child_image/mcuboot/prj_release.conf b/samples/SWTL001/child_image/mcuboot/prj_release.conf deleted file mode 100644 index 78d7622..0000000 --- a/samples/SWTL001/child_image/mcuboot/prj_release.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" - -CONFIG_BOOT_UPGRADE_ONLY=n -CONFIG_RESET_ON_FATAL_ERROR=y - -CONFIG_LOG=n -CONFIG_PRINTK=n -CONFIG_CONSOLE_HANDLER=n -CONFIG_ASSERT=n -CONFIG_BOOT_BANNER=n -CONFIG_CONSOLE=n -CONFIG_SERIAL=n -CONFIG_UART_CONSOLE=n -CONFIG_USE_SEGGER_RTT=n -CONFIG_GPIO=n -CONFIG_NO_RUNTIME_CHECKS=y -CONFIG_SIZE_OPTIMIZATIONS=y diff --git a/samples/SWTL001/configuration/pm_static_no_dfu.yml b/samples/SWTL001/configuration/pm_static_no_dfu.yml deleted file mode 100644 index 658ce75..0000000 --- a/samples/SWTL001/configuration/pm_static_no_dfu.yml +++ /dev/null @@ -1,5 +0,0 @@ -mfg_storage: - address: 0xff000 - end_address: 0x100000 - region: flash_primary - size: 0x1000 diff --git a/samples/SWTL001/include/app.h b/samples/SWTL001/include/app.h index 077f3ca..6eff418 100644 --- a/samples/SWTL001/include/app.h +++ b/samples/SWTL001/include/app.h @@ -4,9 +4,14 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ +#ifndef SAMPLE_APP_H +#define SAMPLE_APP_H + /** * @brief Start Sidewalk end device application. * * @note This function should never return. */ void app_start(void); + +#endif /* SAMPLE_APP_H */ diff --git a/samples/SWTL001/pm_static.yml b/samples/SWTL001/pm_static.yml deleted file mode 100644 index 55dba59..0000000 --- a/samples/SWTL001/pm_static.yml +++ /dev/null @@ -1,10 +0,0 @@ -mcuboot: - address: 0x0 - end_address: 0x8000 - region: flash_primary - size: 0x8000 -mfg_storage: - address: 0xff000 - end_address: 0x100000 - region: flash_primary - size: 0x1000 diff --git a/samples/SWTL001/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/samples/SWTL001/pm_static_nrf52840dk_nrf52840.yml similarity index 100% rename from samples/SWTL001/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml rename to samples/SWTL001/pm_static_nrf52840dk_nrf52840.yml diff --git a/samples/lbm_sid_end_device/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/samples/SWTL001/pm_static_nrf52840dk_nrf52840_release.yml similarity index 100% rename from samples/lbm_sid_end_device/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml rename to samples/SWTL001/pm_static_nrf52840dk_nrf52840_release.yml diff --git a/samples/SWTL001/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/samples/SWTL001/pm_static_nrf5340dk_nrf5340_cpuapp.yml similarity index 100% rename from samples/SWTL001/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml rename to samples/SWTL001/pm_static_nrf5340dk_nrf5340_cpuapp.yml diff --git a/samples/lbm_sid_end_device/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/samples/SWTL001/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml similarity index 100% rename from samples/lbm_sid_end_device/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml rename to samples/SWTL001/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml diff --git a/samples/SWTL001/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml b/samples/SWTL001/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml new file mode 100644 index 0000000..2aae80f --- /dev/null +++ b/samples/SWTL001/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml @@ -0,0 +1,71 @@ +app: + address: 0xc800 + end_address: 0xc3000 + region: flash_primary + size: 0xb6800 +mcuboot: + address: 0x0 + end_address: 0xc000 + placement: + before: + - mcuboot_primary + region: flash_primary + size: 0xc000 +mcuboot_pad: + address: 0xc000 + end_address: 0xc800 + placement: + before: + - mcuboot_primary_app + region: flash_primary + size: 0x800 +mcuboot_primary: + address: 0xc000 + end_address: 0xc3000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + sharers: 0x1 + size: 0xb7000 + span: *id001 +mcuboot_primary_app: + address: 0xc800 + end_address: 0xc3000 + orig_span: &id002 + - app + region: flash_primary + size: 0xb6800 + span: *id002 +mcuboot_secondary: + address: 0xc3000 + end_address: 0x17a000 + placement: + after: + - mcuboot_primary + align: + start: 0x1000 + region: flash_primary + share_size: + - mcuboot_primary + size: 0xb7000 +mfg_storage: + address: 0x17c000 + end_address: 0x17d000 + region: flash_primary + size: 0x1000 +settings_storage: + address: 0x17a000 + end_address: 0x17c000 + placement: + align: + start: 0x1000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20000000 + end_address: 0x20040000 + region: sram_primary + size: 0x40000 diff --git a/samples/SWTL001/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml b/samples/SWTL001/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml new file mode 100644 index 0000000..2aae80f --- /dev/null +++ b/samples/SWTL001/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml @@ -0,0 +1,71 @@ +app: + address: 0xc800 + end_address: 0xc3000 + region: flash_primary + size: 0xb6800 +mcuboot: + address: 0x0 + end_address: 0xc000 + placement: + before: + - mcuboot_primary + region: flash_primary + size: 0xc000 +mcuboot_pad: + address: 0xc000 + end_address: 0xc800 + placement: + before: + - mcuboot_primary_app + region: flash_primary + size: 0x800 +mcuboot_primary: + address: 0xc000 + end_address: 0xc3000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + sharers: 0x1 + size: 0xb7000 + span: *id001 +mcuboot_primary_app: + address: 0xc800 + end_address: 0xc3000 + orig_span: &id002 + - app + region: flash_primary + size: 0xb6800 + span: *id002 +mcuboot_secondary: + address: 0xc3000 + end_address: 0x17a000 + placement: + after: + - mcuboot_primary + align: + start: 0x1000 + region: flash_primary + share_size: + - mcuboot_primary + size: 0xb7000 +mfg_storage: + address: 0x17c000 + end_address: 0x17d000 + region: flash_primary + size: 0x1000 +settings_storage: + address: 0x17a000 + end_address: 0x17c000 + placement: + align: + start: 0x1000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20000000 + end_address: 0x20040000 + region: sram_primary + size: 0x40000 diff --git a/samples/SWTL001/configuration/thingy53_nrf5340_cpuapp/pm_static_dfu.yml b/samples/SWTL001/pm_static_thingy53_nrf5340_cpuapp.yml similarity index 100% rename from samples/SWTL001/configuration/thingy53_nrf5340_cpuapp/pm_static_dfu.yml rename to samples/SWTL001/pm_static_thingy53_nrf5340_cpuapp.yml diff --git a/samples/SWTL001/prj_no_dfu.conf b/samples/SWTL001/prj_no_dfu.conf deleted file mode 100644 index 3f14d8c..0000000 --- a/samples/SWTL001/prj_no_dfu.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 2023 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Sidewalk -CONFIG_SIDEWALK=y -CONFIG_SIDEWALK_DFU=n -CONFIG_SMF=y - -# Log -CONFIG_LOG=y -CONFIG_LOG_PRINTK=y -CONFIG_LOG_BUFFER_SIZE=2048 -CONFIG_NVS_LOG_LEVEL_WRN=y - -# Bluetooth -CONFIG_BT_DEVICE_NAME="Nordic" - -# Debug -CONFIG_RESET_ON_FATAL_ERROR=n diff --git a/samples/SWTL001/sample.yaml b/samples/SWTL001/sample.yaml index a61c19d..e4635fc 100644 --- a/samples/SWTL001/sample.yaml +++ b/samples/SWTL001/sample.yaml @@ -1,96 +1,62 @@ sample: name: Sidewalk end device sample description: Sample implementing Amazon Sidewalk End Device +common: + sysbuild: true + build_only: true + platform_allow: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf54l15pdk/nrf54l15/cpuapp + integration_platforms: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf54l15pdk/nrf54l15/cpuapp tests: sample.sidewalk.hello: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_configs: - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp + - CONFIG_SIDEWALK_FILE_TRANSFER=y tags: Sidewalk hello sample.sidewalk.hello.release: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: - CONF_FILE=prj_release.conf + FILE_SUFFIX=release extra_configs: - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp - tags: Sidewalk hello - - sample.sidewalk.hello.no_dfu: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp - extra_args: - CONF_FILE=prj_no_dfu.conf - extra_configs: - - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk hello sample.sidewalk.hello.ble_only: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_configs: - CONFIG_SIDEWALK_SUBGHZ_SUPPORT=n - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk hello BLE sample.sidewalk.hello.ble_only.release: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: - CONF_FILE=prj_release.conf + FILE_SUFFIX=release extra_configs: - CONFIG_SIDEWALK_SUBGHZ_SUPPORT=n - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk hello BLE sample.sidewalk.demo: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: OVERLAY_CONFIG="overlay-demo.conf" extra_configs: - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk demo sample.sidewalk.demo.ble_only: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp thingy53_nrf5340_cpuapp + platform_allow: + - thingy53/nrf5340/cpuapp extra_args: OVERLAY_CONFIG="overlay-demo.conf" extra_configs: - CONFIG_SIDEWALK_SUBGHZ_SUPPORT=n integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp - - thingy53_nrf5340_cpuapp + - thingy53/nrf5340/cpuapp tags: Sidewalk demo BLE sample.sidewalk.dut: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: OVERLAY_CONFIG="overlay-dut.conf" - extra_configs: - - CONFIG_SIDEWALK_FILE_TRANSFER=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk cli diff --git a/samples/SWTL001/src/main.c b/samples/SWTL001/src/main.c index e050000..e7a910a 100644 --- a/samples/SWTL001/src/main.c +++ b/samples/SWTL001/src/main.c @@ -8,9 +8,6 @@ #include #include -#include -LOG_MODULE_REGISTER(main, CONFIG_SIDEWALK_LOG_LEVEL); - int main(void) { PRINT_SIDEWALK_VERSION(); diff --git a/samples/SWTL001/src/swtl001/app.c b/samples/SWTL001/src/swtl001/app.c index 0f182ac..5ce3112 100644 --- a/samples/SWTL001/src/swtl001/app.c +++ b/samples/SWTL001/src/swtl001/app.c @@ -71,3 +71,4 @@ void app_start(void) break; } } + diff --git a/samples/SWTL001/sysbuild/ipc_radio/prj.conf b/samples/SWTL001/sysbuild/ipc_radio/prj.conf new file mode 100644 index 0000000..654a36b --- /dev/null +++ b/samples/SWTL001/sysbuild/ipc_radio/prj.conf @@ -0,0 +1,35 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 + +# Bluetooth +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y +CONFIG_BT_CTLR_ASSERT_HANDLER=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_CENTRAL=n +CONFIG_BT_MAX_CONN=1 +CONFIG_BT_BUF_ACL_RX_SIZE=502 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 + +# IPC +CONFIG_IPC_SERVICE=y +CONFIG_MBOX=y + +# Debug +CONFIG_LOG=n +CONFIG_SERIAL=n +CONFIG_ASSERT=y +CONFIG_DEBUG_INFO=y +CONFIG_EXCEPTION_STACK_TRACE=y +CONFIG_RESET_ON_FATAL_ERROR=y + +# ipc_radio +CONFIG_IPC_RADIO_BT=y +CONFIG_IPC_RADIO_BT_HCI_IPC=y diff --git a/samples/SWTL001/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf b/samples/SWTL001/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf new file mode 100644 index 0000000..c333f7b --- /dev/null +++ b/samples/SWTL001/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2023 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Configure QSPI for external flash +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay b/samples/SWTL001/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay similarity index 77% rename from samples/lbm_sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay rename to samples/SWTL001/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay index 055f044..6ea6421 100644 --- a/samples/lbm_sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay +++ b/samples/SWTL001/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay @@ -4,8 +4,9 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ - / { +/ { chosen { + zephyr,code-partition = &boot_partition; nordic,pm-ext-flash = &mx25r64; }; }; diff --git a/samples/SWTL001/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/SWTL001/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 0000000..96cb33e --- /dev/null +++ b/samples/SWTL001/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1,28 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 + +# The following configurations are required to support simultaneous multi image update +CONFIG_PCD_APP=y +CONFIG_UPDATEABLE_IMAGE_NUMBER=2 + +CONFIG_BOOT_SWAP_USING_MOVE=n +# Multi-image updates do not support image swapping yet. +CONFIG_BOOT_UPGRADE_ONLY=y + +# The network core cannot access external flash directly. The flash simulator must be used to +# provide a memory region that is used to forward the new firmware to the network core. +CONFIG_FLASH_SIMULATOR=y +CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y +CONFIG_FLASH_SIMULATOR_STATS=n + +# Enable custom command to erase settings partition. +CONFIG_ENABLE_MGMT_PERUSER=y +CONFIG_ZCBOR=y +CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE=y diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay b/samples/SWTL001/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay similarity index 77% rename from samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay rename to samples/SWTL001/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay index 055f044..6ea6421 100644 --- a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/samples/SWTL001/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -4,8 +4,9 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ - / { +/ { chosen { + zephyr,code-partition = &boot_partition; nordic,pm-ext-flash = &mx25r64; }; }; diff --git a/samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf b/samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf new file mode 100644 index 0000000..16bd5b0 --- /dev/null +++ b/samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf @@ -0,0 +1,13 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +CONFIG_BOOT_MAX_IMG_SECTORS=256 +# Ensure that the qspi driver is disabled by default +CONFIG_NORDIC_QSPI_NOR=n + +# Workaroud: fprotect and watchdog feed +# are not supported in NCS v2.6.0 +CONFIG_FPROTECT=n +CONFIG_BOOT_WATCHDOG_FEED=n diff --git a/samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay b/samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay new file mode 100644 index 0000000..6220cb2 --- /dev/null +++ b/samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/* There is no aditional config needed for this version of PDK */ diff --git a/samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay b/samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay new file mode 100644 index 0000000..8edfb64 --- /dev/null +++ b/samples/SWTL001/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + +/* Application does not use cpuflpr core. Assign whole RRAM to cpuapp. */ +&cpuapp_rram { + reg = < 0x0 DT_SIZE_K(1524) >; +}; diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340_cpuapp.conf b/samples/SWTL001/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.conf similarity index 93% rename from samples/lbm_sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340_cpuapp.conf rename to samples/SWTL001/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.conf index a0db3d5..561529f 100644 --- a/samples/lbm_sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340_cpuapp.conf +++ b/samples/SWTL001/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.conf @@ -4,9 +4,6 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -# Increase main stack size -CONFIG_MAIN_STACK_SIZE=10240 - # Configure MCUboot features CONFIG_NRF53_MULTI_IMAGE_UPDATE=y CONFIG_BOOT_UPGRADE_ONLY=y diff --git a/samples/SWTL001/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay b/samples/SWTL001/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay similarity index 77% rename from samples/SWTL001/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay rename to samples/SWTL001/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay index 055f044..6ea6421 100644 --- a/samples/SWTL001/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay +++ b/samples/SWTL001/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay @@ -4,8 +4,9 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ - / { +/ { chosen { + zephyr,code-partition = &boot_partition; nordic,pm-ext-flash = &mx25r64; }; }; diff --git a/samples/SWTL001/sysbuild/mcuboot/prj.conf b/samples/SWTL001/sysbuild/mcuboot/prj.conf new file mode 100644 index 0000000..0a05853 --- /dev/null +++ b/samples/SWTL001/sysbuild/mcuboot/prj.conf @@ -0,0 +1,39 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +CONFIG_MAIN_STACK_SIZE=10240 + +CONFIG_BOOT_SWAP_SAVE_ENCTLV=n +CONFIG_BOOT_BOOTSTRAP=n +CONFIG_PM=n + +CONFIG_FLASH=y +CONFIG_FPROTECT=y + +CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" + +CONFIG_BOOT_MAX_IMG_SECTORS=256 + +# Use minimal C library instead of the Picolib +CONFIG_MINIMAL_LIBC=y + +# Disable logs +CONFIG_NCS_BOOT_BANNER=n +CONFIG_CONSOLE=n +CONFIG_SERIAL=n +CONFIG_UART_CONSOLE=n +CONFIG_USE_SEGGER_RTT=n +CONFIG_LOG=n +CONFIG_CONSOLE_HANDLER=n +CONFIG_BOOT_BANNER=n + +# Bootloader size optimization +CONFIG_RESET_ON_FATAL_ERROR=n +CONFIG_GPIO=n +CONFIG_TIMESLICING=n +CONFIG_MULTITHREADING=n +CONFIG_TICKLESS_KERNEL=n +CONFIG_TIMEOUT_64BIT=n +CONFIG_NRF_ENABLE_ICACHE=n diff --git a/samples/lbm_sid_end_device/CMakeLists.txt b/samples/lbm_sid_end_device/CMakeLists.txt index 8d853db..1c4847c 100644 --- a/samples/lbm_sid_end_device/CMakeLists.txt +++ b/samples/lbm_sid_end_device/CMakeLists.txt @@ -6,24 +6,6 @@ cmake_minimum_required(VERSION 3.20.0) -# Sidewalk version -include(bootloader_version.cmake) - -# Child images -set(hci_ipc_KCONFIG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/child_image/hci_ipc/Kconfig.root) -set(mcuboot_KCONFIG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/child_image/mcuboot/Kconfig.root) - -# Configurations -if(CONF_FILE) - get_filename_component(CONFIG_FILE_NAME ${CONF_FILE} NAME) -endif() - -if("${CONFIG_FILE_NAME}" STREQUAL "prj_no_dfu.conf") - set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/pm_static_no_dfu.yml) -else() - set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static_dfu.yml) -endif() - # Zephyr CMake project find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(sidewalk_sid_end_device) @@ -35,7 +17,10 @@ target_sources(app PRIVATE src/sidewalk.c ) -target_sources_ifdef(CONFIG_SIDEWALK_FILE_TRANSFER app PRIVATE src/file_transfer.c) +target_sources_ifdef(CONFIG_SIDEWALK_FILE_TRANSFER app PRIVATE + src/sbdt/file_transfer.c + src/sbdt/scratch_buffer.c +) if(CONFIG_SID_END_DEVICE_SENSOR_MONITORING) target_sources(app PRIVATE @@ -106,6 +91,7 @@ if(CONFIG_SID_END_DEVICE_CLI) src/cli/app_dut.c src/cli/app_shell.c ) + target_sources_ifdef(CONFIG_SIDEWALK_ON_DEV_CERT app PRIVATE src/cli/sid_on_dev_cert_cli.c) endif() if(CONFIG_SMTC_CLI) diff --git a/samples/lbm_sid_end_device/Kconfig b/samples/lbm_sid_end_device/Kconfig index 9b97458..b416aec 100644 --- a/samples/lbm_sid_end_device/Kconfig +++ b/samples/lbm_sid_end_device/Kconfig @@ -90,9 +90,35 @@ config SID_END_DEVICE_EVENT_HEAP_SIZE config SIDEWALK_FILE_TRANSFER select EXPERIMENTAL - bool "Add File transfer capability to the application" + bool "Enable Sidewalk file transfer" help - Include the callbacks necesary to handle file transfer + Add support for Sidewalk Bulk Data Transfer (SBDT) + in application. + +if SIDEWALK_FILE_TRANSFER + +config SIDEWALK_FILE_TRANSFER_HEAP_SIZE + int "Sidewalk file transfer heap size" + default 10240 + help + Heap size in bytes to be allocated + for Sidewalk Bulk Data Transfer (SBDT). + +config SIDEWALK_FILE_TRANSFER_DFU + bool "Sildewak file transfer and dfu" + default SIDEWALK_FILE_TRANSFER + imply SIDEWALK_DFU_IMG_UTILS + imply DFU_MULTI_IMAGE + imply DFU_TARGET + imply DFU_TARGET_MCUBOOT + imply STREAM_FLASH + imply STREAM_FLASH_ERASE + imply SIDEWALK_THREAD_QUEUE_TIMEOUT + help + Save recived data to flash. Expect CBOR manifest. + Autoatically reset device after file transfer. + +endif rsource "Kconfig.defconfig" diff --git a/samples/lbm_sid_end_device/Kconfig.sysbuild b/samples/lbm_sid_end_device/Kconfig.sysbuild new file mode 100644 index 0000000..404f972 --- /dev/null +++ b/samples/lbm_sid_end_device/Kconfig.sysbuild @@ -0,0 +1,54 @@ +# +# Copyright (c) 2023 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +config NRF_DEFAULT_IPC_RADIO + default y if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP + +choice BOOTLOADER + default BOOTLOADER_MCUBOOT +endchoice + +if BOOTLOADER_MCUBOOT + +config DFU_MULTI_IMAGE_PACKAGE_BUILD + default y + +config DFU_MULTI_IMAGE_PACKAGE_APP + default y + +if (BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP) + +config MCUBOOT_UPDATEABLE_IMAGES + default 2 + +choice MCUBOOT_MODE + default MCUBOOT_MODE_OVERWRITE_ONLY +endchoice + +choice BOOT_SIGNATURE_TYPE + default BOOT_SIGNATURE_TYPE_RSA +endchoice + +config SECURE_BOOT + default y + +config SECURE_BOOT_NETCORE + default y + +config NETCORE_APP_UPDATE + default y + +config DFU_MULTI_IMAGE_PACKAGE_NET + default y + +endif # BOOTLOADER_MCUBOOT + +endif # (BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP) + +config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY + default y if BOARD_NRF52840DK_NRF52840 || BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/lbm_sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.overlay b/samples/lbm_sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.overlay index 4395ed1..d0a7679 100644 --- a/samples/lbm_sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/samples/lbm_sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -20,6 +20,37 @@ }; /{ + state_notifier_gpios{ + compatible = "gpio-keys"; + state_notifier_error: error { + gpios = <&gpio1 0x8 0x0>; + label = "Application state error"; + }; + state_notifier_dfu: dfu { + gpios = <&gpio1 0x2 0x0>; + label = "Application state dfu"; + }; + state_notifier_sending: sending { + gpios = <&gpio1 0x4 0x0>; + label = "Application state sending"; + }; + state_notifier_receiving: receiving { + gpios = <&gpio1 0x3 0x0>; + label = "Application state receiving"; + }; + }; + + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + state-notifier-error = &state_notifier_error; + state-notifier-dfu = &state_notifier_dfu; + state-notifier-sending = &state_notifier_sending; + state-notifier-receiving = &state_notifier_receiving; + }; + semtech_sx1262_gpios{ compatible = "gpio-keys"; semtech_sx1262_cs: cs { diff --git a/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf new file mode 100644 index 0000000..d6a0780 --- /dev/null +++ b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Workaround: +# The nRF54L15 PDK (PCA10156) revisions v0.2.0 AA0-ES2, v0.2.0 AA0-ES3, +# and v0.2.1 AB0-ES5 have Buttons 3 and 4 connected to the GPIO port +# which does not support interrupts. +CONFIG_DK_LIBRARY_BUTTON_NO_ISR=y + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay new file mode 100644 index 0000000..2d0f58c --- /dev/null +++ b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + +&pinctrl { + spi00_default: spi00_default { + group1 { + psels = , + , + ; + }; + }; + + spi00_sleep: spi00_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + +sid_semtech: &spi00 { + compatible = "nordic,nrf-spim"; + status = "okay"; + pinctrl-0 = <&spi00_default>; + pinctrl-1 = <&spi00_sleep>; + pinctrl-names = "default", "sleep"; + clock-frequency = ; +}; + +/{ + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + }; + + semtech_sx1262_gpios{ + compatible = "gpio-keys"; + semtech_sx1262_cs: cs { + gpios = <&gpio2 0xa GPIO_PULL_UP>; + label = "semtech_sx1262 CS"; + }; + semtech_sx1262_reset_gpios: reset { + gpios = <&gpio1 0xb (GPIO_ACTIVE_LOW|GPIO_PULL_UP)>; + label = "semtech_sx1262 Reset"; + }; + semtech_sx1262_busy_gpios: busy { + gpios = <&gpio1 0xc 0x0>; + label = "semtech_sx1262 Busy"; + }; + semtech_sx1262_antenna_enable_gpios: antena_enable { + gpios = <&gpio2 0x7 0x0>; + label = "semtech_sx1262 Antena Enable"; + }; + semtech_sx1262_dio1_gpios: dio1 { + gpios = <&gpio1 0xa 0x0>; + label = "semtech_sx1262 DIO1"; + }; + radio_gnss_lna: gnss_lna { + gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; + label = "gnss antenna"; + }; + radio_led_sniff: led_sniff { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "yellow LED"; + }; + radio_led_tx: led_tx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "red tx LED"; + }; + radio_led_rx: led_rx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "green rx LED"; + }; + }; + +}; + +&gpiote20 { + status = "okay"; +}; + +&gpiote30 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; diff --git a/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf new file mode 100644 index 0000000..e99da54 --- /dev/null +++ b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay new file mode 100644 index 0000000..5a08ece --- /dev/null +++ b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + +/* Application does not use cpuflpr core. Assign whole RRAM to cpuapp. */ +&cpuapp_rram { + reg = < 0x0 DT_SIZE_K(1524) >; +}; + + &pinctrl { + spi21_default: spi21_default { + group1 { + psels = , + , + ; + }; + }; + + spi21_sleep: spi21_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + + sid_semtech: &spi21 { + compatible = "nordic,nrf-spim"; + status = "okay"; + pinctrl-0 = <&spi21_default>; + pinctrl-1 = <&spi21_sleep>; + pinctrl-names = "default", "sleep"; + clock-frequency = ; +}; + +/{ + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + }; + + semtech_sx1262_gpios{ + compatible = "gpio-keys"; + semtech_sx1262_cs: cs { + gpios = <&gpio2 0xa GPIO_PULL_UP>; + label = "semtech_sx1262 CS"; + }; + semtech_sx1262_reset_gpios: reset { + gpios = <&gpio0 0x2 (GPIO_ACTIVE_LOW|GPIO_PULL_UP)>; + label = "semtech_sx1262 Reset"; + }; + semtech_sx1262_busy_gpios: busy { + gpios = <&gpio0 0x0 0x0>; + label = "semtech_sx1262 Busy"; + }; + semtech_sx1262_antenna_enable_gpios: antena_enable { + gpios = <&gpio0 0x1 0x0>; + label = "semtech_sx1262 Antena Enable"; + }; + semtech_sx1262_dio1_gpios: dio1 { + gpios = <&gpio0 0x3 0x0>; + label = "semtech_sx1262 DIO1"; + }; + radio_gnss_lna: gnss_lna { + gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; + label = "gnss antenna"; + }; + radio_led_sniff: led_sniff { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "yellow LED"; + }; + radio_led_tx: led_tx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "red tx LED"; + }; + radio_led_rx: led_rx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "green rx LED"; + }; + }; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; diff --git a/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf new file mode 100644 index 0000000..d6a0780 --- /dev/null +++ b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Workaround: +# The nRF54L15 PDK (PCA10156) revisions v0.2.0 AA0-ES2, v0.2.0 AA0-ES3, +# and v0.2.1 AB0-ES5 have Buttons 3 and 4 connected to the GPIO port +# which does not support interrupts. +CONFIG_DK_LIBRARY_BUTTON_NO_ISR=y + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf new file mode 100644 index 0000000..e99da54 --- /dev/null +++ b/samples/lbm_sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/lbm_sid_end_device/child_image/hci_ipc/Kconfig.root b/samples/lbm_sid_end_device/child_image/hci_ipc/Kconfig.root deleted file mode 100644 index 60e8bd4..0000000 --- a/samples/lbm_sid_end_device/child_image/hci_ipc/Kconfig.root +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# The purpose of this file is to create a wrapper Kconfig file that will be set as -# hci_ipc_KCONFIG_ROOT and processed before any other Kconfig for hci_ipc child image. - -config HEAP_MEM_POOL_SIZE - default 8192 - -config MAIN_STACK_SIZE - default 2048 - -config SYSTEM_WORKQUEUE_STACK_SIZE - default 2048 - -config BT - default y - -config BT_HCI_RAW - default y - -config BT_MAX_CONN - default 1 - -config BT_PERIPHERAL - default y - -config BT_CENTRAL - default n - -config BT_BUF_ACL_RX_SIZE - default 502 - -config BT_BUF_ACL_TX_SIZE - default 251 - -config BT_CTLR_DATA_LENGTH_MAX - default 251 - -config BT_CTLR_ASSERT_HANDLER - default y - -config BT_HCI_RAW_RESERVE - default 1 - -# Workaround: Unable to allocate command buffer when using K_NO_WAIT since -# Host number of completed commands does not follow normal flow control. -config BT_BUF_CMD_TX_COUNT - default 10 - -config ASSERT - default y - -config DEBUG_INFO - default y - -config EXCEPTION_STACK_TRACE - default y - -config IPC_SERVICE - default y - -config MBOX - default y - -source "Kconfig.zephyr" diff --git a/samples/lbm_sid_end_device/child_image/hci_ipc/prj.conf b/samples/lbm_sid_end_device/child_image/hci_ipc/prj.conf deleted file mode 100644 index c89bda6..0000000 --- a/samples/lbm_sid_end_device/child_image/hci_ipc/prj.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_LOG=n -CONFIG_SERIAL=n -CONFIG_RESET_ON_FATAL_ERROR=n diff --git a/samples/lbm_sid_end_device/child_image/hci_ipc/prj_no_dfu.conf b/samples/lbm_sid_end_device/child_image/hci_ipc/prj_no_dfu.conf deleted file mode 100644 index c89bda6..0000000 --- a/samples/lbm_sid_end_device/child_image/hci_ipc/prj_no_dfu.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_LOG=n -CONFIG_SERIAL=n -CONFIG_RESET_ON_FATAL_ERROR=n diff --git a/samples/lbm_sid_end_device/child_image/hci_ipc/prj_release.conf b/samples/lbm_sid_end_device/child_image/hci_ipc/prj_release.conf deleted file mode 100644 index 86c0d92..0000000 --- a/samples/lbm_sid_end_device/child_image/hci_ipc/prj_release.conf +++ /dev/null @@ -1,9 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_LOG=n -CONFIG_SERIAL=n -CONFIG_UART_CONSOLE=n -CONFIG_RESET_ON_FATAL_ERROR=y diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/Kconfig.root b/samples/lbm_sid_end_device/child_image/mcuboot/Kconfig.root deleted file mode 100644 index d6ecb28..0000000 --- a/samples/lbm_sid_end_device/child_image/mcuboot/Kconfig.root +++ /dev/null @@ -1,127 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# The purpose of this file is to create a wrapper Kconfig file that will be set as -# mcuboot_KCONFIG_ROOT and processed before any other Kconfig for mcuboot child image. - - -config MAIN_STACK_SIZE - default 10240 - -config BOOT_SWAP_SAVE_ENCTLV - default n - -config BOOT_ENCRYPT_RSA - default n - -config BOOT_ENCRYPT_EC256 - default n - -config BOOT_ENCRYPT_X25519 - default n - -config BOOT_BOOTSTRAP - default n - -config PM - default n - -config FLASH - default y - -config FPROTECT - default y - -config NORDIC_QSPI_NOR - default y - -config NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE - default 4096 - -config NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE - default 16 - -config BOOT_MAX_IMG_SECTORS - default 256 - -config LOG - default n - -choice LIBC_IMPLEMENTATION - default MINIMAL_LIBC -endchoice - -config COMMON_LIBC_CALLOC - default y - -config COMMON_LIBC_MALLOC - default y - -config COMMON_LIBC_REALLOCARRAY - default y - -config NCS_SAMPLES_DEFAULTS - default n - -config PRINTK - default n - -config REBOOT - default n - -config NRF_RTC_TIMER - default y if SOC_SERIES_NRF53X - default n - -config CONSOLE - default n - -config CONSOLE_HANDLER - default n - -config GPIO - default n - -config KERNEL_MEM_POOL - default n - -config ASSERT - default n - -config BOOT_BANNER - default n - -config SERIAL - default n - -config UART_CONSOLE - default n - -config TIMESLICING - default n - -config USE_SEGGER_RTT - default n - -config RESET_ON_FATAL_ERROR - default n - -config SECURE_BOOT_DEBUG - default n - -config MULTITHREADING - default n - -config TICKLESS_KERNEL - default n - -config TIMEOUT_64BIT - default n - -config NRF_ENABLE_ICACHE - default n - -source "${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr/Kconfig" diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay b/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay deleted file mode 100644 index 69bf975..0000000 --- a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -/ { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay b/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay deleted file mode 100644 index 69bf975..0000000 --- a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -/ { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf deleted file mode 100644 index 3664dd3..0000000 --- a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Increase main stack size -CONFIG_MAIN_STACK_SIZE=10240 - -# Configure MCUboot features -CONFIG_NRF53_MULTI_IMAGE_UPDATE=y -CONFIG_BOOT_UPGRADE_ONLY=y -CONFIG_BOOT_MAX_IMG_SECTORS=256 -CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y - -# Allow for storing two images in MCUboot partitions -CONFIG_UPDATEABLE_IMAGE_NUMBER=2 - -# Store new images inside external flash -CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y - -# Enable flash simulator -CONFIG_PCD_APP=y -CONFIG_FLASH_SIMULATOR=y -CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y -CONFIG_FLASH_SIMULATOR_STATS=n - -# Configure QSPI for external flash -CONFIG_FLASH=y -CONFIG_FPROTECT=y -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf b/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf deleted file mode 100644 index 3664dd3..0000000 --- a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Increase main stack size -CONFIG_MAIN_STACK_SIZE=10240 - -# Configure MCUboot features -CONFIG_NRF53_MULTI_IMAGE_UPDATE=y -CONFIG_BOOT_UPGRADE_ONLY=y -CONFIG_BOOT_MAX_IMG_SECTORS=256 -CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y - -# Allow for storing two images in MCUboot partitions -CONFIG_UPDATEABLE_IMAGE_NUMBER=2 - -# Store new images inside external flash -CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y - -# Enable flash simulator -CONFIG_PCD_APP=y -CONFIG_FLASH_SIMULATOR=y -CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y -CONFIG_FLASH_SIMULATOR_STATS=n - -# Configure QSPI for external flash -CONFIG_FLASH=y -CONFIG_FPROTECT=y -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay b/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay deleted file mode 100644 index c670799..0000000 --- a/samples/lbm_sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - - / { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/prj.conf b/samples/lbm_sid_end_device/child_image/mcuboot/prj.conf deleted file mode 100644 index 78d7622..0000000 --- a/samples/lbm_sid_end_device/child_image/mcuboot/prj.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" - -CONFIG_BOOT_UPGRADE_ONLY=n -CONFIG_RESET_ON_FATAL_ERROR=y - -CONFIG_LOG=n -CONFIG_PRINTK=n -CONFIG_CONSOLE_HANDLER=n -CONFIG_ASSERT=n -CONFIG_BOOT_BANNER=n -CONFIG_CONSOLE=n -CONFIG_SERIAL=n -CONFIG_UART_CONSOLE=n -CONFIG_USE_SEGGER_RTT=n -CONFIG_GPIO=n -CONFIG_NO_RUNTIME_CHECKS=y -CONFIG_SIZE_OPTIMIZATIONS=y diff --git a/samples/lbm_sid_end_device/child_image/mcuboot/prj_release.conf b/samples/lbm_sid_end_device/child_image/mcuboot/prj_release.conf deleted file mode 100644 index 78d7622..0000000 --- a/samples/lbm_sid_end_device/child_image/mcuboot/prj_release.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" - -CONFIG_BOOT_UPGRADE_ONLY=n -CONFIG_RESET_ON_FATAL_ERROR=y - -CONFIG_LOG=n -CONFIG_PRINTK=n -CONFIG_CONSOLE_HANDLER=n -CONFIG_ASSERT=n -CONFIG_BOOT_BANNER=n -CONFIG_CONSOLE=n -CONFIG_SERIAL=n -CONFIG_UART_CONSOLE=n -CONFIG_USE_SEGGER_RTT=n -CONFIG_GPIO=n -CONFIG_NO_RUNTIME_CHECKS=y -CONFIG_SIZE_OPTIMIZATIONS=y diff --git a/samples/lbm_sid_end_device/configuration/pm_static_no_dfu.yml b/samples/lbm_sid_end_device/configuration/pm_static_no_dfu.yml deleted file mode 100644 index 658ce75..0000000 --- a/samples/lbm_sid_end_device/configuration/pm_static_no_dfu.yml +++ /dev/null @@ -1,5 +0,0 @@ -mfg_storage: - address: 0xff000 - end_address: 0x100000 - region: flash_primary - size: 0x1000 diff --git a/samples/lbm_sid_end_device/include/app.h b/samples/lbm_sid_end_device/include/app.h index 077f3ca..6eff418 100644 --- a/samples/lbm_sid_end_device/include/app.h +++ b/samples/lbm_sid_end_device/include/app.h @@ -4,9 +4,14 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ +#ifndef SAMPLE_APP_H +#define SAMPLE_APP_H + /** * @brief Start Sidewalk end device application. * * @note This function should never return. */ void app_start(void); + +#endif /* SAMPLE_APP_H */ diff --git a/samples/lbm_sid_end_device/include/file_transfer.h b/samples/lbm_sid_end_device/include/file_transfer.h deleted file mode 100644 index ad62fc4..0000000 --- a/samples/lbm_sid_end_device/include/file_transfer.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2024 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#include - -struct data_received_args { - struct sid_bulk_data_transfer_desc desc; - struct sid_bulk_data_transfer_buffer *buffer; - void *context; -}; - -void app_file_transfer_demo_init(struct sid_handle *handle); - -void app_file_transfer_demo_deinit(struct sid_handle *handle); diff --git a/samples/lbm_sid_end_device/include/sbdt/file_transfer.h b/samples/lbm_sid_end_device/include/sbdt/file_transfer.h new file mode 100644 index 0000000..c51eb1b --- /dev/null +++ b/samples/lbm_sid_end_device/include/sbdt/file_transfer.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#ifndef FILE_TRANSFER_H +#define FILE_TRANSFER_H + +#include + +/** + * @brief Initilize Sidewalk Bulk Data Transfer module. + * + * @param handle Sidewalk handle given by sid_init. + */ +void app_file_transfer_demo_init(struct sid_handle *handle); + +/** + * @brief Deinitilize Sidewalk Bulk Data Transfer module. + * + * @param handle Sidewalk handle given by sid_init. + */ +void app_file_transfer_demo_deinit(struct sid_handle *handle); + +#endif /* FILE_TRANSFER_H */ diff --git a/samples/lbm_sid_end_device/include/sbdt/scratch_buffer.h b/samples/lbm_sid_end_device/include/sbdt/scratch_buffer.h new file mode 100644 index 0000000..7de934e --- /dev/null +++ b/samples/lbm_sid_end_device/include/sbdt/scratch_buffer.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#ifndef SCRATCH_BUFFER_H +#define SCRATCH_BUFFER_H + +#include +#include + +/** + * @brief Init scratch buffer + * + * Inilizing module is neccessary to find files by id. + * + */ +void scratch_buffer_init(void); + +/** + * @brief Create scratch buffor assigned for file id. + * + * @param id file id + * @param size size of file buffer + * @return void* pointer to allocated memory. NULL on error. + */ +void *scratch_buffer_create(uint32_t id, size_t size); + +/** + * @brief Remove scratch buffer for file id. + * + * @param id file id + */ +void scratch_buffer_remove(uint32_t id); + +#endif /* SCRATCH_BUFFER_H */ diff --git a/samples/lbm_sid_end_device/include/sidewalk.h b/samples/lbm_sid_end_device/include/sidewalk.h index 2c30c09..82795d9 100644 --- a/samples/lbm_sid_end_device/include/sidewalk.h +++ b/samples/lbm_sid_end_device/include/sidewalk.h @@ -12,6 +12,9 @@ #include #include +#include +#include + #define LBM_STACK_ID 0 enum state { @@ -42,6 +45,7 @@ typedef enum { #ifdef NAV3_SEND /* */ SID_EVENT_NAV3_SEND, #endif /* !NAV3_SEND */ + /* */ SID_EVENT_REBOOT, /* */ SID_EVENT_LAST, } sidewalk_event_t; @@ -104,6 +108,7 @@ typedef struct sm_s { } sm_t; typedef struct { + sys_snode_t node; struct sid_msg msg; struct sid_msg_desc desc; } sidewalk_msg_t; @@ -114,10 +119,19 @@ typedef struct { size_t data_len; } sidewalk_option_t; +typedef struct { + uint32_t file_id; + size_t file_offset; + void *data; + size_t data_size; +} sidewalk_transfer_t; + void sidewalk_start(sidewalk_ctx_t *context); int sidewalk_event_send(sidewalk_event_t event, void *ctx); +sidewalk_msg_t *get_message_buffer(uint16_t message_id); + extern const struct smf_state sid_states[]; void app_event_lbm(void); #if defined(CONFIG_LBM_END_DEVICE) diff --git a/samples/lbm_sid_end_device/pm_static.yml b/samples/lbm_sid_end_device/pm_static.yml deleted file mode 100644 index 55dba59..0000000 --- a/samples/lbm_sid_end_device/pm_static.yml +++ /dev/null @@ -1,10 +0,0 @@ -mcuboot: - address: 0x0 - end_address: 0x8000 - region: flash_primary - size: 0x8000 -mfg_storage: - address: 0xff000 - end_address: 0x100000 - region: flash_primary - size: 0x1000 diff --git a/samples/sid_end_device/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/samples/lbm_sid_end_device/pm_static_nrf52840dk_nrf52840.yml similarity index 100% rename from samples/sid_end_device/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml rename to samples/lbm_sid_end_device/pm_static_nrf52840dk_nrf52840.yml diff --git a/samples/lbm_sid_end_device/pm_static_nrf52840dk_nrf52840_release.yml b/samples/lbm_sid_end_device/pm_static_nrf52840dk_nrf52840_release.yml new file mode 100644 index 0000000..10bf45a --- /dev/null +++ b/samples/lbm_sid_end_device/pm_static_nrf52840dk_nrf52840_release.yml @@ -0,0 +1,73 @@ +app: + address: 0x7200 + end_address: 0xfd000 + region: flash_primary + size: 0xf5e00 +external_flash: + address: 0xf6000 + end_address: 0x800000 + region: external_flash + size: 0x70a000 +mcuboot: + address: 0x0 + end_address: 0x7000 + region: flash_primary + size: 0x7000 +mcuboot_pad: + address: 0x7000 + end_address: 0x7200 + placement: + align: + start: 0x1000 + before: + - mcuboot_primary_app + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x7000 + end_address: 0xfd000 + orig_span: &id001 + - app + - mcuboot_pad + region: flash_primary + size: 0xf6000 + span: *id001 +mcuboot_primary_app: + address: 0x7200 + end_address: 0xfd000 + orig_span: &id002 + - app + region: flash_primary + size: 0xf5e00 + span: *id002 +mcuboot_secondary: + address: 0x0 + device: DT_CHOSEN(nordic_pm_ext_flash) + end_address: 0xf6000 + placement: + align: + start: 0x4 + region: external_flash + share_size: + - mcuboot_primary + size: 0xf6000 +mfg_storage: + address: 0xff000 + end_address: 0x100000 + region: flash_primary + size: 0x1000 +settings_storage: + address: 0xfd000 + end_address: 0xff000 + placement: + align: + start: 0x1000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20000000 + end_address: 0x20040000 + region: sram_primary + size: 0x40000 diff --git a/samples/sid_end_device/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/samples/lbm_sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp.yml similarity index 100% rename from samples/sid_end_device/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml rename to samples/lbm_sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp.yml diff --git a/samples/lbm_sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml b/samples/lbm_sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml new file mode 100644 index 0000000..5764ee5 --- /dev/null +++ b/samples/lbm_sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml @@ -0,0 +1,119 @@ +EMPTY_0: + address: 0xfe000 + end_address: 0xff000 + placement: + after: + - settings_storage + region: flash_primary + size: 0x1000 +app: + address: 0x8200 + end_address: 0xfc000 + region: flash_primary + size: 0xf3e00 +external_flash: + address: 0x134000 + end_address: 0x800000 + region: external_flash + size: 0x6cc000 +mcuboot: + address: 0x0 + end_address: 0x8000 + region: flash_primary + size: 0x8000 +mcuboot_pad: + address: 0x8000 + end_address: 0x8200 + placement: + align: + start: 0x4000 + before: + - mcuboot_primary_app + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x8000 + end_address: 0xfc000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + size: 0xf4000 + span: *id001 +mcuboot_primary_1: + address: 0x0 + device: nordic_ram_flash_controller + end_address: 0x40000 + region: ram_flash + size: 0x40000 +mcuboot_primary_app: + address: 0x8200 + end_address: 0xfc000 + orig_span: &id002 + - app + region: flash_primary + size: 0xf3e00 + span: *id002 +mcuboot_secondary: + address: 0x0 + device: DT_CHOSEN(nordic_pm_ext_flash) + end_address: 0xf4000 + placement: + align: + start: 0x4 + region: external_flash + share_size: + - mcuboot_primary + size: 0xf4000 +mcuboot_secondary_1: + address: 0xf4000 + device: DT_CHOSEN(nordic_pm_ext_flash) + end_address: 0x134000 + region: external_flash + size: 0x40000 +mfg_storage: + address: 0xff000 + end_address: 0x100000 + region: flash_primary + size: 0x1000 +otp: + address: 0xff8100 + end_address: 0xff83fc + region: otp + size: 0x2fc +pcd_sram: + address: 0x20000000 + end_address: 0x20002000 + placement: + after: + - start + region: sram_primary + size: 0x2000 +ram_flash: + address: 0x40000 + end_address: 0x40000 + region: ram_flash + size: 0x0 +rpmsg_nrf53_sram: + address: 0x20070000 + end_address: 0x20080000 + placement: + before: + - end + region: sram_primary + size: 0x10000 +settings_storage: + address: 0xfc000 + end_address: 0xfe000 + placement: + align: + start: 0x4000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20002000 + end_address: 0x20070000 + region: sram_primary + size: 0x6e000 diff --git a/samples/lbm_sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml b/samples/lbm_sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml new file mode 100644 index 0000000..2aae80f --- /dev/null +++ b/samples/lbm_sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml @@ -0,0 +1,71 @@ +app: + address: 0xc800 + end_address: 0xc3000 + region: flash_primary + size: 0xb6800 +mcuboot: + address: 0x0 + end_address: 0xc000 + placement: + before: + - mcuboot_primary + region: flash_primary + size: 0xc000 +mcuboot_pad: + address: 0xc000 + end_address: 0xc800 + placement: + before: + - mcuboot_primary_app + region: flash_primary + size: 0x800 +mcuboot_primary: + address: 0xc000 + end_address: 0xc3000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + sharers: 0x1 + size: 0xb7000 + span: *id001 +mcuboot_primary_app: + address: 0xc800 + end_address: 0xc3000 + orig_span: &id002 + - app + region: flash_primary + size: 0xb6800 + span: *id002 +mcuboot_secondary: + address: 0xc3000 + end_address: 0x17a000 + placement: + after: + - mcuboot_primary + align: + start: 0x1000 + region: flash_primary + share_size: + - mcuboot_primary + size: 0xb7000 +mfg_storage: + address: 0x17c000 + end_address: 0x17d000 + region: flash_primary + size: 0x1000 +settings_storage: + address: 0x17a000 + end_address: 0x17c000 + placement: + align: + start: 0x1000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20000000 + end_address: 0x20040000 + region: sram_primary + size: 0x40000 diff --git a/samples/lbm_sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml b/samples/lbm_sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml new file mode 100644 index 0000000..2aae80f --- /dev/null +++ b/samples/lbm_sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml @@ -0,0 +1,71 @@ +app: + address: 0xc800 + end_address: 0xc3000 + region: flash_primary + size: 0xb6800 +mcuboot: + address: 0x0 + end_address: 0xc000 + placement: + before: + - mcuboot_primary + region: flash_primary + size: 0xc000 +mcuboot_pad: + address: 0xc000 + end_address: 0xc800 + placement: + before: + - mcuboot_primary_app + region: flash_primary + size: 0x800 +mcuboot_primary: + address: 0xc000 + end_address: 0xc3000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + sharers: 0x1 + size: 0xb7000 + span: *id001 +mcuboot_primary_app: + address: 0xc800 + end_address: 0xc3000 + orig_span: &id002 + - app + region: flash_primary + size: 0xb6800 + span: *id002 +mcuboot_secondary: + address: 0xc3000 + end_address: 0x17a000 + placement: + after: + - mcuboot_primary + align: + start: 0x1000 + region: flash_primary + share_size: + - mcuboot_primary + size: 0xb7000 +mfg_storage: + address: 0x17c000 + end_address: 0x17d000 + region: flash_primary + size: 0x1000 +settings_storage: + address: 0x17a000 + end_address: 0x17c000 + placement: + align: + start: 0x1000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20000000 + end_address: 0x20040000 + region: sram_primary + size: 0x40000 diff --git a/samples/lbm_sid_end_device/configuration/thingy53_nrf5340_cpuapp/pm_static_dfu.yml b/samples/lbm_sid_end_device/pm_static_thingy53_nrf5340_cpuapp.yml similarity index 100% rename from samples/lbm_sid_end_device/configuration/thingy53_nrf5340_cpuapp/pm_static_dfu.yml rename to samples/lbm_sid_end_device/pm_static_thingy53_nrf5340_cpuapp.yml diff --git a/samples/lbm_sid_end_device/prj_no_dfu.conf b/samples/lbm_sid_end_device/prj_no_dfu.conf deleted file mode 100644 index 3f14d8c..0000000 --- a/samples/lbm_sid_end_device/prj_no_dfu.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 2023 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Sidewalk -CONFIG_SIDEWALK=y -CONFIG_SIDEWALK_DFU=n -CONFIG_SMF=y - -# Log -CONFIG_LOG=y -CONFIG_LOG_PRINTK=y -CONFIG_LOG_BUFFER_SIZE=2048 -CONFIG_NVS_LOG_LEVEL_WRN=y - -# Bluetooth -CONFIG_BT_DEVICE_NAME="Nordic" - -# Debug -CONFIG_RESET_ON_FATAL_ERROR=n diff --git a/samples/lbm_sid_end_device/sample.yaml b/samples/lbm_sid_end_device/sample.yaml index a61c19d..e4635fc 100644 --- a/samples/lbm_sid_end_device/sample.yaml +++ b/samples/lbm_sid_end_device/sample.yaml @@ -1,96 +1,62 @@ sample: name: Sidewalk end device sample description: Sample implementing Amazon Sidewalk End Device +common: + sysbuild: true + build_only: true + platform_allow: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf54l15pdk/nrf54l15/cpuapp + integration_platforms: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf54l15pdk/nrf54l15/cpuapp tests: sample.sidewalk.hello: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_configs: - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp + - CONFIG_SIDEWALK_FILE_TRANSFER=y tags: Sidewalk hello sample.sidewalk.hello.release: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: - CONF_FILE=prj_release.conf + FILE_SUFFIX=release extra_configs: - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp - tags: Sidewalk hello - - sample.sidewalk.hello.no_dfu: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp - extra_args: - CONF_FILE=prj_no_dfu.conf - extra_configs: - - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk hello sample.sidewalk.hello.ble_only: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_configs: - CONFIG_SIDEWALK_SUBGHZ_SUPPORT=n - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk hello BLE sample.sidewalk.hello.ble_only.release: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: - CONF_FILE=prj_release.conf + FILE_SUFFIX=release extra_configs: - CONFIG_SIDEWALK_SUBGHZ_SUPPORT=n - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk hello BLE sample.sidewalk.demo: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: OVERLAY_CONFIG="overlay-demo.conf" extra_configs: - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk demo sample.sidewalk.demo.ble_only: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp thingy53_nrf5340_cpuapp + platform_allow: + - thingy53/nrf5340/cpuapp extra_args: OVERLAY_CONFIG="overlay-demo.conf" extra_configs: - CONFIG_SIDEWALK_SUBGHZ_SUPPORT=n integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp - - thingy53_nrf5340_cpuapp + - thingy53/nrf5340/cpuapp tags: Sidewalk demo BLE sample.sidewalk.dut: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: OVERLAY_CONFIG="overlay-dut.conf" - extra_configs: - - CONFIG_SIDEWALK_FILE_TRANSFER=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk cli diff --git a/samples/lbm_sid_end_device/src/cli/app.c b/samples/lbm_sid_end_device/src/cli/app.c index 0dad5c5..97eef5e 100644 --- a/samples/lbm_sid_end_device/src/cli/app.c +++ b/samples/lbm_sid_end_device/src/cli/app.c @@ -11,8 +11,7 @@ #include #include #include -#include -#include +#include #include LOG_MODULE_REGISTER(app, CONFIG_SIDEWALK_LOG_LEVEL); @@ -40,6 +39,13 @@ static void on_sidewalk_msg_sent(const struct sid_msg_desc *msg_desc, void *cont LOG_INF("Message send success"); printk(JSON_NEW_LINE(JSON_OBJ(JSON_NAME( "on_msg_sent", JSON_OBJ(JSON_VAL_sid_msg_desc("sid_msg_desc", msg_desc, 0)))))); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc *msg_desc, @@ -50,6 +56,13 @@ static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc "on_send_error", JSON_OBJ(JSON_LIST_2(JSON_VAL_sid_error_t("error", error), JSON_VAL_sid_msg_desc("sid_msg_desc", msg_desc, 0))))))); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_factory_reset(void *context) diff --git a/samples/lbm_sid_end_device/src/cli/app_dut.c b/samples/lbm_sid_end_device/src/cli/app_dut.c index fbbe28e..9788694 100644 --- a/samples/lbm_sid_end_device/src/cli/app_dut.c +++ b/samples/lbm_sid_end_device/src/cli/app_dut.c @@ -4,13 +4,14 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ +#include "sid_error.h" #include #include #include #include #include #include -#include +#include LOG_MODULE_REGISTER(sid_cli, CONFIG_SIDEWALK_LOG_LEVEL); @@ -76,7 +77,7 @@ static void dut_option_get(sidewalk_option_t *p_option, struct sid_handle *handl case SID_OPTION_GET_LINK_POLICY_AUTO_CONNECT_PARAMS: { struct sid_link_auto_connect_params params = { 0 }; memcpy(¶ms.link_type, p_option->data, sizeof(uint32_t)); - sid_error_t e = sid_option(handle, opt, ¶ms, sizeof(params)); + sid_error_t e = sid_option(handle, opt, (void *)¶ms, sizeof(params)); LOG_INF("sid_option returned %d; AC Policy, link %d, enable %d priority %d timeout %d", e, params.link_type, params.enable, params.priority, params.connection_attempt_timeout_seconds); @@ -123,6 +124,9 @@ void app_dut_event_process(sidewalk_ctx_event_t event, sidewalk_ctx_t *sid) sid->config.link_mask = dut_ctx_get_uint32(event.ctx); sid_error_t e = sid_init(&sid->config, &sid->handle); LOG_INF("sid_init returned %d", e); + if (e != SID_ERROR_NONE) { + return; + } #ifdef CONFIG_SIDEWALK_FILE_TRANSFER app_file_transfer_demo_init(sid->handle); #endif @@ -157,13 +161,13 @@ void app_dut_event_process(sidewalk_ctx_event_t event, sidewalk_ctx_t *sid) case DUT_EVENT_GET_MTU: { uint32_t link_mask = dut_ctx_get_uint32(event.ctx); size_t mtu = 0; - sid_error_t e = sid_get_mtu(sid->handle, link_mask, &mtu); + sid_error_t e = sid_get_mtu(sid->handle, (enum sid_link_type)link_mask, &mtu); LOG_INF("sid_get_mtu returned %d, MTU: %d", e, mtu); } break; case DUT_EVENT_GET_TIME: { uint32_t format = dut_ctx_get_uint32(event.ctx); struct sid_timespec curr_time = { 0 }; - sid_error_t e = sid_get_time(sid->handle, format, &curr_time); + sid_error_t e = sid_get_time(sid->handle, (enum sid_time_format)format, &curr_time); LOG_INF("sid_get_time returned %d, SEC: %d NSEC: %d", e, curr_time.tv_sec, curr_time.tv_nsec); } break; diff --git a/samples/lbm_sid_end_device/src/cli/app_shell.c b/samples/lbm_sid_end_device/src/cli/app_shell.c index 5cffbc1..728dd31 100644 --- a/samples/lbm_sid_end_device/src/cli/app_shell.c +++ b/samples/lbm_sid_end_device/src/cli/app_shell.c @@ -227,7 +227,7 @@ static int cmd_sid_option(cli_event_t event, enum sid_option option, void *data, p_opt->data = NULL; } - int err = sidewalk_event_send(event, p_opt); + int err = sidewalk_event_send((sidewalk_event_t)event, p_opt); if (err) { if (p_opt->data) { sid_hal_free(p_opt->data); @@ -262,7 +262,7 @@ static int cmd_sid_simple_param(cli_event_t event, uint32_t *data) } memcpy(event_ctx, data, sizeof(uint32_t)); - int err = sidewalk_event_send(event, event_ctx); + int err = sidewalk_event_send((sidewalk_event_t)event, event_ctx); if (err) { sid_hal_free(event_ctx); return -ENOMSG; @@ -282,10 +282,12 @@ int cmd_sid_init(const struct shell *shell, int32_t argc, const char **argv) uint32_t link_type = 0; if (!IN_RANGE(connection_type, CLI_CMD_OPT_LINK_BLE, CLI_CMD_OPT_LINK_ANY)) { + shell_error(shell, "invalid value"); return -EINVAL; } if (!cli_parse_link_mask_opt(connection_type, &link_type)) { + shell_error(shell, "invalid value"); return -EINVAL; } cli_cfg.send_link_type = link_type; @@ -297,7 +299,7 @@ int cmd_sid_deinit(const struct shell *shell, int32_t argc, const char **argv) { CHECK_ARGUMENT_COUNT(argc, CMD_SID_DEINIT_ARG_REQUIRED, CMD_SID_DEINIT_ARG_OPTIONAL); - return sidewalk_event_send(DUT_EVENT_DEINIT, NULL); + return sidewalk_event_send((sidewalk_event_t)DUT_EVENT_DEINIT, NULL); } int cmd_sid_start(const struct shell *shell, int32_t argc, const char **argv) @@ -309,6 +311,7 @@ int cmd_sid_start(const struct shell *shell, int32_t argc, const char **argv) link_type = cli_cfg.send_link_type; } else { if (!cli_parse_link_mask_opt(atoi(argv[1]), &link_type)) { + shell_error(shell, "invalid value"); return -EINVAL; } } @@ -325,6 +328,7 @@ int cmd_sid_stop(const struct shell *shell, int32_t argc, const char **argv) link_type = cli_cfg.send_link_type; } else { if (!cli_parse_link_mask_opt(atoi(argv[1]), &link_type)) { + shell_error(shell, "invalid value"); return -EINVAL; } } @@ -419,6 +423,7 @@ int cmd_sid_send(const struct shell *shell, int32_t argc, const char **argv) } if (!cli_parse_link_mask_opt(atoi(argv[opt]), &desc.link_type)) { + shell_error(shell, "invalid value"); return -EINVAL; } continue; @@ -497,7 +502,7 @@ int cmd_sid_send(const struct shell *shell, int32_t argc, const char **argv) memcpy(&send->msg, &msg, sizeof(struct sid_msg)); memcpy(&send->desc, &desc, sizeof(struct sid_msg_desc)); - int err = sidewalk_event_send(SID_EVENT_SEND_MSG, send); + int err = sidewalk_event_send((sidewalk_event_t)SID_EVENT_SEND_MSG, send); if (err) { sid_hal_free(send->msg.data); sid_hal_free(send); @@ -512,7 +517,7 @@ int cmd_sid_factory_reset(const struct shell *shell, int32_t argc, const char ** CHECK_ARGUMENT_COUNT(argc, CMD_SID_FACTORY_RESET_ARG_REQUIRED, CMD_SID_FACTORY_RESET_ARG_OPTIONAL); - int err = sidewalk_event_send(SID_EVENT_FACTORY_RESET, NULL); + int err = sidewalk_event_send((sidewalk_event_t)SID_EVENT_FACTORY_RESET, NULL); if (err) { shell_error(shell, "event err %d", err); } @@ -537,6 +542,7 @@ int cmd_sid_get_mtu(const struct shell *shell, int32_t argc, const char **argv) link_mask = SID_LINK_TYPE_3; break; default: + shell_error(shell, "invalid value"); return -EINVAL; } @@ -584,6 +590,7 @@ int cmd_sid_option_lp_set(const struct shell *shell, int32_t argc, const char ** data_raw = strtol(argv[1], &end, 0); if (end == argv[1]) { + shell_error(shell, "invalid value"); return -EINVAL; } if (!IN_RANGE(data_raw, 0, UINT8_MAX)) { @@ -885,7 +892,10 @@ int cmd_sid_option_gc(const struct shell *shell, int32_t argc, const char **argv } memset(p_link_mask, 0x0, sizeof(*p_link_mask)); - cli_parse_link_mask_opt((uint8_t)link_type, p_link_mask); + if (!cli_parse_link_mask_opt((uint8_t)link_type, p_link_mask)) { + shell_error(shell, "Can not parse link mask"); + return -EINVAL; + } int err = cmd_sid_option_get_input_data(SID_OPTION_GET_LINK_POLICY_AUTO_CONNECT_PARAMS, p_link_mask, sizeof(uint32_t)); @@ -901,7 +911,9 @@ int cmd_sid_last_status(const struct shell *shell, int32_t argc, const char **ar CHECK_ARGUMENT_COUNT(argc, CMD_SID_LAST_STATUS_ARG_REQUIRED, CMD_SID_LAST_STATUS_ARG_OPTIONAL); - sidewalk_event_send(DUT_EVENT_GET_STATUS, NULL); + if (0 != sidewalk_event_send((sidewalk_event_t)DUT_EVENT_GET_STATUS, NULL)) { + shell_error(shell, "Failed to send Event"); + } return 0; } @@ -919,6 +931,7 @@ int cmd_sid_conn_request(const struct shell *shell, int32_t argc, const char **a conn_req = 0U; break; default: + shell_error(shell, "invalid value"); return -EINVAL; } @@ -930,6 +943,7 @@ int cmd_sid_get_time(const struct shell *shell, int32_t argc, const char **argv) CHECK_ARGUMENT_COUNT(argc, CMD_SID_GET_TIME_ARG_REQUIRED, CMD_SID_GET_TIME_ARG_OPTIONAL); if (argv[1][0] != '0') { + shell_error(shell, "invalid value"); return -EINVAL; } uint32_t time_type = SID_GET_GPS_TIME; @@ -970,6 +984,7 @@ int cmd_sid_set_send_link(const struct shell *shell, int32_t argc, const char ** break; } default: { + shell_error(shell, "invalid value"); return -EINVAL; } } diff --git a/samples/lbm_sid_end_device/src/cli/sid_on_dev_cert_cli.c b/samples/lbm_sid_end_device/src/cli/sid_on_dev_cert_cli.c new file mode 100644 index 0000000..e6d1df5 --- /dev/null +++ b/samples/lbm_sid_end_device/src/cli/sid_on_dev_cert_cli.c @@ -0,0 +1,467 @@ +/* + * Copyright (c) 2022 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include +#include + +#include +#include + +#include + +LOG_MODULE_REGISTER(sid_dev_cert_shell, CONFIG_SIDEWALK_LOG_LEVEL); + +#ifdef SYNTAX_ERR +#undef SYNTAX_ERR +#endif +#define SYNTAX_ERR "Syntax err \r\n" + +#define CERT_INIT_H "Initialization of On-Device Certificate Generation library" +#define CERT_DEINIT_H "Deinitialization of On-Device Certificate Generation Library" +#define CERT_SMSN_H "Generate Sidewalk Manufacturing Serial Number (SMSN)" +#define CERT_CSR_H "Generate Certificate Signing Request (CSR)" +#define CERT_CHAIN_H "Write Sidewalk Certificate Chain" +#define CERT_CHAIN_START_H "Start writing of Sidewalk Certificate Chain" +#define CERT_CHAIN_WRITE_H "Write data fragment to Sidewalk Certificate Chain" +#define CERT_CHAIN_COMMIT_H "Commit previously writed Sidewalk Certificate Chain" +#define CERT_APPKEY_H "Write application server ED25519 public key" +#define CERT_APPKEY_START_H "Start writing of app server ED25519 public key" +#define CERT_APPKEY_WRITE_H "Write data fragment to app server ED25519 public key" +#define CERT_APPKEY_COMMIT_H "Commit previously writed app server ED25519 public key" +#define CERT_STORE_H "Verify and store Sidewalk certificates" + +#define CERT_INIT_CMD "cert init" +#define CERT_DEINIT_CMD "cert deinit" +#define CERT_SMSN_CMD "cert smsn []" +#define CERT_CSR_CMD "cert csr " +#define CERT_CHAIN_START_CMD "cert chain start " +#define CERT_CHAIN_WRITE_CMD "cert chain write " +#define CERT_CHAIN_COMMIT_CMD "cert chain commit" +#define CERT_APPKEY_START_CMD "cert app_key start" +#define CERT_APPKEY_WRITE_CMD "cert app_key write " +#define CERT_APPKEY_COMMIT_CMD "cert app_key commit" +#define CERT_STORE_CMD "cert store" + +#define CERT_MSG_OK "{CERT OK}" +#define CERT_MSG_ERROR "{CERT ERROR %d}" +#define CERT_MSG_BASE64 "{CERT <%s>}" +#define CERT_MSG_BASE64_MTU "{CERT BASE64_MTU=%d}" +#define CERT_ED25519_STR "ed25519" +#define CERT_P256R1_STR "p256r1" +#define CERT_DEV_TYPE_SUFFIX "-PRODUCTION" + +#define CERT_BASE64_FRAGMENT_MAX_SIZE 32 + +static uint8_t cert_app_key[SID_ODC_ED25519_PUK_SIZE]; +static uint8_t cert_chain_buffer[SID_ODC_SCC_MAX_SIZE]; +static struct sid_on_dev_cert_chain_params cert_chain_params = { + .cert_chain = NULL, + .cert_chain_size = 0, +}; + +// Persistent state for receiving the encoded certificate chain in multiple fragments +static struct sid_base64_ctx cert_chain_base64_ctx = { + .next_out = NULL, + .avail_out = 0, + .total_out = 0, + .state = 0, +}; + +static struct sid_base64_ctx cert_app_key_base64_ctx = { + .next_out = NULL, + .avail_out = 0, + .total_out = 0, + .state = 0, +}; + +static sid_error_t sid_on_dev_cert_cli_print_base64(const struct shell *shell, const uint8_t *input, + size_t input_size) +{ + struct sid_base64_ctx ctx; + sid_base64_init(&ctx); + uint8_t out[CERT_BASE64_FRAGMENT_MAX_SIZE + 1]; // allow extra byte for null terminator + + ctx.next_in = input; + ctx.avail_in = input_size; + ctx.next_out = out; + ctx.avail_out = CERT_BASE64_FRAGMENT_MAX_SIZE; + + while (true) { + sid_error_t status = sid_base64_encode(&ctx, true); + if (status == SID_ERROR_NONE || status == SID_ERROR_BUFFER_OVERFLOW) { + // add a null terminator + *ctx.next_out = '\0'; + + shell_info(shell, CERT_MSG_BASE64, out); + + if (status == SID_ERROR_NONE) { + break; + } + // Reset the output buffer for the next line + ctx.next_out = out; + ctx.avail_out = CERT_BASE64_FRAGMENT_MAX_SIZE; + } else { + return SID_ERROR_GENERIC; + } + } + return SID_ERROR_NONE; +} + +static int sid_on_dev_cert_cli_init_cmd(const struct shell *shell, int32_t argc, const char **argv) +{ + if (argc == 1) { + sid_error_t ret = sid_on_dev_cert_init(); + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_BASE64_MTU, CERT_BASE64_FRAGMENT_MAX_SIZE); + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_INIT_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_deinit(const struct shell *shell, int32_t argc, const char **argv) +{ + if (argc == 1) { + sid_on_dev_cert_deinit(); + + shell_info(shell, CERT_MSG_OK); + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_DEINIT_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_smsn(const struct shell *shell, int32_t argc, const char **argv) +{ + // command format: cert smsn [] + if (argc >= 4 && argc <= 5) { + sid_error_t ret = SID_ERROR_NONE; + // Note on device-type. It gets transformed into "Amazon-id" which is -PRODUCTION + char *dev_type_production = + sid_hal_malloc(strlen(argv[1]) + strlen(CERT_DEV_TYPE_SUFFIX) + 1); + if (!dev_type_production) { + ret = SID_ERROR_OOM; + goto exit; + } + dev_type_production[0] = 0; + strcat(dev_type_production, argv[1]); + strcat(dev_type_production, CERT_DEV_TYPE_SUFFIX); + + const struct sid_on_dev_cert_info dev_info = { + .dev_type = dev_type_production, + .dsn = argv[2], + .apid = argv[3], + .board_id = argc == 5 ? argv[4] : NULL, + }; + + uint8_t smsn[SID_ODC_SMSN_SIZE]; + memset(smsn, 0xFF, SID_ODC_SMSN_SIZE); + if ((ret = sid_on_dev_cert_generate_smsn(&dev_info, smsn)) == SID_ERROR_NONE) { + ret = sid_on_dev_cert_cli_print_base64(shell, smsn, SID_ODC_SMSN_SIZE); + } + + sid_hal_free(dev_type_production); + exit: + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_SMSN_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_csr(const struct shell *shell, int32_t argc, const char **argv) +{ + if (argc == 2) { + sid_error_t ret = SID_ERROR_NONE; + uint8_t csr[SID_ODC_CSR_MAX_SIZE]; + size_t csr_size = SID_ODC_CSR_MAX_SIZE; + enum sid_on_dev_cert_algo_type algo; + + if (strcmp(argv[1], CERT_ED25519_STR) == 0) { + algo = SID_ODC_CRYPT_ALGO_ED25519; + } else if (strcmp(argv[1], CERT_P256R1_STR) == 0) { + algo = SID_ODC_CRYPT_ALGO_P256R1; + } else { + ret = SID_ERROR_INVALID_ARGS; + } + + if (ret == SID_ERROR_NONE && + (ret = sid_on_dev_cert_generate_csr(algo, csr, &csr_size)) == SID_ERROR_NONE && + (ret = sid_on_dev_cert_cli_print_base64(shell, csr, csr_size)) == + SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_CSR_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_chain_start(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 2) { + sid_error_t ret = SID_ERROR_NONE; + enum sid_on_dev_cert_algo_type algo; + + if (strcmp(argv[1], CERT_ED25519_STR) == 0) { + algo = SID_ODC_CRYPT_ALGO_ED25519; + } else if (strcmp(argv[1], CERT_P256R1_STR) == 0) { + algo = SID_ODC_CRYPT_ALGO_P256R1; + } else { + ret = SID_ERROR_INVALID_ARGS; + } + if (ret == SID_ERROR_NONE) { + sid_base64_init(&cert_chain_base64_ctx); + cert_chain_base64_ctx.next_out = cert_chain_buffer; + cert_chain_base64_ctx.avail_out = (algo == SID_ODC_CRYPT_ALGO_ED25519) ? + SID_ODC_ED25519_SCC_MAX_SIZE : + SID_ODC_P256R1_SCC_MAX_SIZE; + cert_chain_params.algo = algo; + cert_chain_params.cert_chain = cert_chain_buffer; + cert_chain_params.cert_chain_size = 0; + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_CHAIN_START_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_chain_write(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 2) { + sid_error_t ret = SID_ERROR_NONE; + size_t base64_fragment_len = strlen(argv[1]); + + if (base64_fragment_len >= 1 && + base64_fragment_len <= CERT_BASE64_FRAGMENT_MAX_SIZE) { + if (cert_chain_params.cert_chain) { + cert_chain_base64_ctx.next_in = (const uint8_t *)argv[1]; + cert_chain_base64_ctx.avail_in = base64_fragment_len; + ret = sid_base64_decode(&cert_chain_base64_ctx); + /* + * If we have a successful result, we should check: + * - the input buffer should be empty + * - if the output buffer is empty and there are 8 bits or more of temporary data, it is an error + */ + if (ret != SID_ERROR_NONE || cert_chain_base64_ctx.avail_in != 0 || + (cert_chain_base64_ctx.avail_out == 0 && + cert_chain_base64_ctx.temp_len >= 8)) { + // Clear chain pointer. This makes chain uninitialized. + cert_chain_params.cert_chain = NULL; + // Reset base64 context + sid_base64_init(&cert_chain_base64_ctx); + ret = SID_ERROR_INVALID_ARGS; + } + } else { + ret = SID_ERROR_UNINITIALIZED; + } + } else { + ret = SID_ERROR_PARAM_OUT_OF_RANGE; + } + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_CHAIN_WRITE_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_chain_commit(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 1) { + sid_error_t ret = SID_ERROR_NONE; + if (cert_chain_params.cert_chain) { + cert_chain_params.cert_chain_size = cert_chain_base64_ctx.total_out; + ret = sid_on_dev_cert_write_cert_chain(&cert_chain_params); + // Clear chain pointer. This makes chain uninitialized. + cert_chain_params.cert_chain = NULL; + // Reset base64 context + sid_base64_init(&cert_chain_base64_ctx); + } else { + ret = SID_ERROR_UNINITIALIZED; + } + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_CHAIN_COMMIT_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_app_key_start(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 1) { + sid_base64_init(&cert_app_key_base64_ctx); + cert_app_key_base64_ctx.next_out = cert_app_key; + cert_app_key_base64_ctx.avail_out = SID_ODC_ED25519_PUK_SIZE; + shell_info(shell, CERT_MSG_OK); + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_APPKEY_START_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_app_key_write(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 2) { + sid_error_t ret = SID_ERROR_NONE; + size_t base64_fragment_len = strlen(argv[1]); + + if (base64_fragment_len >= 1 && + base64_fragment_len <= CERT_BASE64_FRAGMENT_MAX_SIZE) { + if (cert_app_key_base64_ctx.next_out) { + cert_app_key_base64_ctx.next_in = (const uint8_t *)argv[1]; + cert_app_key_base64_ctx.avail_in = base64_fragment_len; + + ret = sid_base64_decode(&cert_app_key_base64_ctx); + /* + * If we have a successful result, we should check: + * - the input buffer should be empty + * - if the output buffer is empty and there are 8 bits or more of temporary data, it is an error + */ + if (ret != SID_ERROR_NONE || + cert_app_key_base64_ctx.avail_in != 0 || + (cert_app_key_base64_ctx.avail_out == 0 && + cert_app_key_base64_ctx.temp_len >= 8)) { + // Reset base64 context + sid_base64_init(&cert_app_key_base64_ctx); + ret = SID_ERROR_INVALID_ARGS; + } + } else { + ret = SID_ERROR_UNINITIALIZED; + } + } else { + ret = SID_ERROR_PARAM_OUT_OF_RANGE; + } + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_APPKEY_WRITE_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_app_key_commit(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 1) { + sid_error_t ret = SID_ERROR_NONE; + + if (cert_app_key_base64_ctx.total_out == SID_ODC_ED25519_PUK_SIZE && + cert_app_key_base64_ctx.avail_out == 0) { + ret = sid_on_dev_cert_write_app_server_key((uint8_t *)cert_app_key); + } else { + ret = SID_ERROR_UNINITIALIZED; + } + // Reset base64 context + sid_base64_init(&cert_app_key_base64_ctx); + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_APPKEY_COMMIT_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_store(const struct shell *shell, int32_t argc, const char **argv) +{ + if (argc == 1) { + sid_error_t ret = sid_on_dev_cert_verify_and_store(); + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_STORE_CMD); + } + return 0; +} + +SHELL_STATIC_SUBCMD_SET_CREATE( + sub_chain, + SHELL_CMD_ARG(start, NULL, CERT_CHAIN_START_H, sid_on_dev_cert_cli_chain_start, 2, 0), + SHELL_CMD_ARG(write, NULL, CERT_CHAIN_WRITE_H, sid_on_dev_cert_cli_chain_write, 2, 0), + SHELL_CMD_ARG(commit, NULL, CERT_APPKEY_COMMIT_H, sid_on_dev_cert_cli_chain_commit, 1, 0), + SHELL_SUBCMD_SET_END); + +SHELL_STATIC_SUBCMD_SET_CREATE( + sub_app_key, + SHELL_CMD_ARG(start, NULL, CERT_APPKEY_START_H, sid_on_dev_cert_cli_app_key_start, 1, 0), + SHELL_CMD_ARG(write, NULL, CERT_APPKEY_WRITE_H, sid_on_dev_cert_cli_app_key_write, 2, 0), + SHELL_CMD_ARG(commit, NULL, CERT_APPKEY_COMMIT_H, sid_on_dev_cert_cli_app_key_commit, 1, 0), + SHELL_SUBCMD_SET_END); + +SHELL_STATIC_SUBCMD_SET_CREATE( + sub_services, SHELL_CMD_ARG(init, NULL, CERT_INIT_H, sid_on_dev_cert_cli_init_cmd, 1, 0), + SHELL_CMD_ARG(deinit, NULL, CERT_DEINIT_H, sid_on_dev_cert_cli_deinit, 1, 0), + SHELL_CMD_ARG(smsn, NULL, CERT_SMSN_H, sid_on_dev_cert_cli_smsn, 4, 1), + SHELL_CMD_ARG(csr, NULL, CERT_CSR_H, sid_on_dev_cert_cli_csr, 2, 0), + SHELL_CMD_ARG(chain, &sub_chain, CERT_CHAIN_H, NULL, 1, 0), + SHELL_CMD_ARG(app_key, &sub_app_key, CERT_APPKEY_H, NULL, 1, 0), + SHELL_CMD_ARG(store, NULL, CERT_STORE_H, sid_on_dev_cert_cli_store, 1, 0), + SHELL_SUBCMD_SET_END); + +// command, subcommands, help, handler +SHELL_CMD_REGISTER(cert, &sub_services, "sidewalk testing CLI", NULL); diff --git a/samples/lbm_sid_end_device/src/hello/app.c b/samples/lbm_sid_end_device/src/hello/app.c index 424a679..e5f4d0b 100644 --- a/samples/lbm_sid_end_device/src/hello/app.c +++ b/samples/lbm_sid_end_device/src/hello/app.c @@ -11,30 +11,32 @@ #include #include #if defined(CONFIG_GPIO) -#include +#include #endif #if defined(CONFIG_LOG) -#include +#include #endif #include #include #include #include -#include -#include +#include +#ifdef CONFIG_RADIO_LR11XX #include // radio_dbg pin +#endif /* CONFIG_RADIO_LR11XX */ LOG_MODULE_REGISTER(app, CONFIG_SIDEWALK_LOG_LEVEL); static uint32_t persistent_link_mask; +#ifdef CONFIG_RADIO_LR11XX halo_drv_semtech_ctx_t *radio_ctx; +#endif /* CONFIG_RADIO_LR11XX */ static void on_sidewalk_event(bool in_isr, void *context) { int err = sidewalk_event_send(SID_EVENT_SIDEWALK, NULL); - //sid_pal_gpio_toggle(radio_ctx->config->gpios.led_sniff); if (err) { LOG_ERR("Send event err %d", err); }; @@ -94,6 +96,13 @@ static void on_sidewalk_msg_sent(const struct sid_msg_desc *msg_desc, void *cont "on_msg_sent", JSON_OBJ(JSON_VAL_sid_msg_desc("sid_msg_desc", msg_desc, 0)))))); application_state_sending(&global_state_notifier, false); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc *msg_desc, @@ -106,6 +115,14 @@ static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc JSON_VAL_sid_msg_desc("sid_msg_desc", msg_desc, 0))))))); application_state_sending(&global_state_notifier, false); + + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_factory_reset(void *context) @@ -131,7 +148,7 @@ static void on_sidewalk_status_changed(const struct sid_status *status, void *co } else { memcpy(new_status, status, sizeof(struct sid_status)); } - sidewalk_event_send(SID_EVENT_NEW_STATUS, new_status); + err = sidewalk_event_send(SID_EVENT_NEW_STATUS, new_status); switch (status->state) { case SID_STATE_READY: @@ -264,7 +281,9 @@ void app_start(void) .sub_ghz_link_config = app_get_sub_ghz_config(), }; +#ifdef CONFIG_RADIO_LR11XX radio_ctx = lr11xx_get_drv_ctx(); +#endif /* CONFIG_RADIO_LR11XX */ sidewalk_start(&sid_ctx); } diff --git a/samples/lbm_sid_end_device/src/lbm/app_lbm_sidewalk.c b/samples/lbm_sid_end_device/src/lbm/app_lbm_sidewalk.c index 4926b78..b816afd 100644 --- a/samples/lbm_sid_end_device/src/lbm/app_lbm_sidewalk.c +++ b/samples/lbm_sid_end_device/src/lbm/app_lbm_sidewalk.c @@ -9,12 +9,12 @@ //#include //#endif #if defined(CONFIG_GPIO) -#include +#include #endif #if defined(CONFIG_LOG) -#include +#include #endif -#include +#include #include LOG_MODULE_REGISTER(app_lbm_sid, CONFIG_SIDEWALK_LOG_LEVEL); diff --git a/samples/lbm_sid_end_device/src/lbm/app_nav3_lbm.c b/samples/lbm_sid_end_device/src/lbm/app_nav3_lbm.c index 294e48a..d180c37 100644 --- a/samples/lbm_sid_end_device/src/lbm/app_nav3_lbm.c +++ b/samples/lbm_sid_end_device/src/lbm/app_nav3_lbm.c @@ -4,10 +4,10 @@ #include #include #if defined(CONFIG_GPIO) -#include +#include #endif #if defined(CONFIG_LOG) -#include +#include #endif #include diff --git a/samples/lbm_sid_end_device/src/lbm/app_nav3_sidewalk.c b/samples/lbm_sid_end_device/src/lbm/app_nav3_sidewalk.c index 568b3d4..11cc95d 100644 --- a/samples/lbm_sid_end_device/src/lbm/app_nav3_sidewalk.c +++ b/samples/lbm_sid_end_device/src/lbm/app_nav3_sidewalk.c @@ -5,15 +5,14 @@ #include #include #if defined(CONFIG_GPIO) -#include +#include #endif #if defined(CONFIG_LOG) -#include +#include #endif #include -#include -#include +#include #include LOG_MODULE_REGISTER(app, CONFIG_SIDEWALK_LOG_LEVEL); diff --git a/samples/lbm_sid_end_device/src/lbm/main_geolocation_lbm.c b/samples/lbm_sid_end_device/src/lbm/main_geolocation_lbm.c index c71ec72..c2cff96 100644 --- a/samples/lbm_sid_end_device/src/lbm/main_geolocation_lbm.c +++ b/samples/lbm_sid_end_device/src/lbm/main_geolocation_lbm.c @@ -271,6 +271,8 @@ void state_nav3_run(void *o) break; case SID_EVENT_TOGGLE_LBM_SIDEWALK: break; + case SID_EVENT_REBOOT: + break; case SID_EVENT_LAST: break; } // ..switch (sm->event.id) diff --git a/samples/lbm_sid_end_device/src/lbm/main_geolocation_sidewalk.c b/samples/lbm_sid_end_device/src/lbm/main_geolocation_sidewalk.c index e432698..7bc63fd 100644 --- a/samples/lbm_sid_end_device/src/lbm/main_geolocation_sidewalk.c +++ b/samples/lbm_sid_end_device/src/lbm/main_geolocation_sidewalk.c @@ -575,6 +575,8 @@ void state_nav3_run(void *o) send_scan_result(sm->sid); break; #endif /* NAV3_SEND */ + case SID_EVENT_REBOOT: { + } break; case SID_EVENT_LAST: break; } // ..switch (sm->event.id) diff --git a/samples/lbm_sid_end_device/src/lbm/main_periodical_uplink.c b/samples/lbm_sid_end_device/src/lbm/main_periodical_uplink.c index cb695a0..7bb9e0f 100644 --- a/samples/lbm_sid_end_device/src/lbm/main_periodical_uplink.c +++ b/samples/lbm_sid_end_device/src/lbm/main_periodical_uplink.c @@ -343,6 +343,8 @@ void state_lbm_run(void *o) case SID_EVENT_TOGGLE_LBM_SIDEWALK: smf_set_state(SMF_CTX(sm), &sid_states[STATE_SIDEWALK]); break; + case SID_EVENT_REBOOT: + break; case SID_EVENT_LAST: break; } diff --git a/samples/lbm_sid_end_device/src/main.c b/samples/lbm_sid_end_device/src/main.c index e050000..e7a910a 100644 --- a/samples/lbm_sid_end_device/src/main.c +++ b/samples/lbm_sid_end_device/src/main.c @@ -8,9 +8,6 @@ #include #include -#include -LOG_MODULE_REGISTER(main, CONFIG_SIDEWALK_LOG_LEVEL); - int main(void) { PRINT_SIDEWALK_VERSION(); diff --git a/samples/lbm_sid_end_device/src/sensor_monitoring/app.c b/samples/lbm_sid_end_device/src/sensor_monitoring/app.c index 5817426..6a43a1d 100644 --- a/samples/lbm_sid_end_device/src/sensor_monitoring/app.c +++ b/samples/lbm_sid_end_device/src/sensor_monitoring/app.c @@ -71,6 +71,13 @@ static void on_sidewalk_msg_received(const struct sid_msg_desc *msg_desc, const static void on_sidewalk_msg_sent(const struct sid_msg_desc *msg_desc, void *context) { LOG_DBG("sent message(type: %d, id: %u)", (int)msg_desc->type, msg_desc->id); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc *msg_desc, @@ -78,6 +85,13 @@ static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc { LOG_ERR("Send message err %d", (int)error); LOG_DBG("Failed to send message(type: %d, id: %u)", (int)msg_desc->type, msg_desc->id); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_factory_reset(void *context) @@ -151,10 +165,23 @@ static void on_sidewalk_status_changed(const struct sid_status *status, void *co static void sidewalk_btn_handler(uint32_t event) { - int err = sidewalk_event_send((app_event_t)event, NULL); + int err = sidewalk_event_send((sidewalk_event_t)event, NULL); if (err) { LOG_ERR("Send event err %d", err); + return; }; + + if (SID_EVENT_NORDIC_DFU == event) { + static bool in_dfu; + if (in_dfu) { + in_dfu = false; + k_timer_start(¬ify_timer, K_MSEC(NOTIFY_TIMER_DURATION_MS), + K_MSEC(CONFIG_SID_END_DEVICE_NOTIFY_DATA_PERIOD_MS)); + } else { + in_dfu = true; + k_timer_stop(¬ify_timer); + } + } } static int app_buttons_init(void) diff --git a/samples/lbm_sid_end_device/src/sensor_monitoring/app_tx.c b/samples/lbm_sid_end_device/src/sensor_monitoring/app_tx.c index f1ee8f2..6773184 100644 --- a/samples/lbm_sid_end_device/src/sensor_monitoring/app_tx.c +++ b/samples/lbm_sid_end_device/src/sensor_monitoring/app_tx.c @@ -46,9 +46,10 @@ static void state_notify_data(void *o); static void button_timer_cb(struct k_timer *timer_id); static const struct smf_state app_states[] = { - [STATE_APP_INIT] = SMF_CREATE_STATE(NULL, state_init, NULL), - [STATE_APP_NOTIFY_CAPABILITY] = SMF_CREATE_STATE(NULL, state_notify_capability, NULL), - [STATE_APP_NOTIFY_DATA] = SMF_CREATE_STATE(NULL, state_notify_data, NULL), + [STATE_APP_INIT] = SMF_CREATE_STATE(NULL, state_init, NULL, NULL, NULL), + [STATE_APP_NOTIFY_CAPABILITY] = + SMF_CREATE_STATE(NULL, state_notify_capability, NULL, NULL, NULL), + [STATE_APP_NOTIFY_DATA] = SMF_CREATE_STATE(NULL, state_notify_data, NULL, NULL, NULL), }; static uint8_t __aligned(4) @@ -179,7 +180,7 @@ static void state_notify_capability(void *o) app_sm_t *sm = (app_sm_t *)o; switch (sm->event) { - case APP_EVENT_NOTIFY_SENSOR: + case APP_EVENT_NOTIFY_SENSOR: { // Prepare message struct sid_demo_capability_discovery cap = { .link_type = last_link_mask_get(), @@ -219,7 +220,7 @@ static void state_notify_capability(void *o) } LOG_INF("Capability send"); - break; + } break; case APP_EVENT_CAPABILITY_SUCCESS: smf_set_state(SMF_CTX(sm), &app_states[STATE_APP_NOTIFY_DATA]); break; @@ -243,7 +244,7 @@ static void state_notify_data(void *o) int err = 0; switch (sm->event) { - case APP_EVENT_NOTIFY_BUTTON: + case APP_EVENT_NOTIFY_BUTTON: { // Read button state uint8_t button_arr[APP_BUTTONS_MAX] = { 0 }; uint8_t num_buttons = 0; @@ -299,8 +300,8 @@ static void state_notify_data(void *o) app_btn_pending_flag_clear(); LOG_INF("Notify button send"); - break; - case APP_EVENT_NOTIFY_SENSOR: + } break; + case APP_EVENT_NOTIFY_SENSOR: { // Read sensor data int16_t temp = 0; err = app_sensor_temperature_get(&temp); @@ -346,8 +347,8 @@ static void state_notify_data(void *o) } LOG_INF("Notify sensor send"); - break; - case APP_EVENT_RESP_LED_ON: + } break; + case APP_EVENT_RESP_LED_ON: { // Read led status uint8_t led_on_arr[APP_BUTTONS_MAX] = { 0 }; uint8_t num_leds_on = 0; @@ -374,8 +375,8 @@ static void state_notify_data(void *o) } LOG_INF("Response LED ON send"); - break; - case APP_EVENT_RESP_LED_OFF: + } break; + case APP_EVENT_RESP_LED_OFF: { // Read led status uint8_t led_off_arr[APP_BUTTONS_MAX] = { 0 }; uint8_t num_leds_off = 0; @@ -401,7 +402,7 @@ static void state_notify_data(void *o) } LOG_INF("Response LED OFF send"); - break; + } break; case APP_EVENT_TIME_SYNC_FAIL: smf_set_state(SMF_CTX(sm), &app_states[STATE_APP_NOTIFY_CAPABILITY]); case APP_EVENT_TIME_SYNC_SUCCESS: @@ -431,7 +432,7 @@ void app_tx_task(void *dummy1, void *dummy2, void *dummy3) k_timer_start(&button_timer, K_MSEC(APP_NOTIFY_BUTTON_PERIOD_MS), K_MSEC(APP_NOTIFY_BUTTON_PERIOD_MS)); - k_msgq_init(&app_sm.msgq, app_msgq_buff, sizeof(app_event_t), + k_msgq_init(&app_sm.msgq, (char *)app_msgq_buff, sizeof(app_event_t), CONFIG_SID_END_DEVICE_TX_THREAD_QUEUE_SIZE); smf_set_initial(SMF_CTX(&app_sm), &app_states[STATE_APP_INIT]); diff --git a/samples/lbm_sid_end_device/src/sidewalk.c b/samples/lbm_sid_end_device/src/sidewalk.c index fcb7981..49bdb53 100644 --- a/samples/lbm_sid_end_device/src/sidewalk.c +++ b/samples/lbm_sid_end_device/src/sidewalk.c @@ -3,27 +3,38 @@ * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ +#include +#include +#include -#include -#include - +#include +#include #include -#include -#include -#include +#ifdef CONFIG_SIDEWALK_SUBGHZ_SUPPORT +#include +#endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER +#include +#include +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU +#include +#include +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ +#include // print hash only +#include // print hash only +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER */ #ifdef CONFIG_SID_END_DEVICE_CLI #include -#endif +#endif /* CONFIG_SID_END_DEVICE_CLI */ #ifdef CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK #include -#endif +#endif /* CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK */ + #include +#include +#include #include -#include -#ifdef CONFIG_SIDEWALK_SUBGHZ_SUPPORT -#include -#endif -#include +#include #include #ifdef CONFIG_SMTC_CLI @@ -46,10 +57,36 @@ LOG_MODULE_REGISTER(sidewalk_app, CONFIG_SIDEWALK_LOG_LEVEL); static struct k_thread sid_thread; K_THREAD_STACK_DEFINE(sid_thread_stack, CONFIG_SIDEWALK_THREAD_STACK_SIZE); -//extern uint32_t radio_dbg; +sys_slist_t pending_message_list = SYS_SLIST_STATIC_INIT(&pending_message_list); +K_MUTEX_DEFINE(pending_message_list_mutex); + +sidewalk_msg_t *get_message_buffer(uint16_t message_id) +{ + sidewalk_msg_t *pending_message; + sidewalk_msg_t *iterator; + int mutex_err = + k_mutex_lock(&pending_message_list_mutex, k_is_in_isr() ? K_NO_WAIT : K_FOREVER); + if (mutex_err != 0) { + LOG_ERR("Failed to lock mutex for message list"); + return NULL; + } + SYS_SLIST_FOR_EACH_CONTAINER_SAFE (&pending_message_list, pending_message, iterator, node) { + if (pending_message->desc.id == message_id) { + if (sys_slist_find_and_remove(&pending_message_list, + &pending_message->node) == false) { + LOG_ERR("Failed to remove pending message from list"); + }; + k_mutex_unlock(&pending_message_list_mutex); + return pending_message; + } + } + k_mutex_unlock(&pending_message_list_mutex); + return NULL; +} static void state_sidewalk_run(void *o); static void state_sidewalk_entry(void *o); +static void state_sidewalk_exit(void *o); static void state_dfu_entry(void *o); static void state_dfu_run(void *o); #ifdef CONFIG_SMTC_CLI @@ -58,15 +95,16 @@ static void state_smtc_run(void *o); #endif /* CONFIG_SMTC_CLI */ const struct smf_state sid_states[] = { - [STATE_SIDEWALK] = SMF_CREATE_STATE(state_sidewalk_entry, state_sidewalk_run, NULL), - [STATE_DFU] = SMF_CREATE_STATE(state_dfu_entry, state_dfu_run, NULL), + [STATE_SIDEWALK] = SMF_CREATE_STATE(state_sidewalk_entry, state_sidewalk_run, + state_sidewalk_exit, NULL, NULL), + [STATE_DFU] = SMF_CREATE_STATE(state_dfu_entry, state_dfu_run, NULL, NULL, NULL), #if defined(CONFIG_LBM_END_DEVICE) - [STATE_LBM] = SMF_CREATE_STATE(state_lbm_entry, state_lbm_run, NULL), + [STATE_LBM] = SMF_CREATE_STATE(state_lbm_entry, state_lbm_run, NULL, NULL, NULL), #elif defined(CONFIG_SID_END_DEVICE_NAV3) || defined(CONFIG_LBM_END_DEVICE_NAV3) - [STATE_NAV3] = SMF_CREATE_STATE(state_nav3_entry, state_nav3_run, NULL), + [STATE_NAV3] = SMF_CREATE_STATE(state_nav3_entry, state_nav3_run, NULL, NULL, NULL), #endif #ifdef CONFIG_SMTC_CLI - [STATE_SMTC] = SMF_CREATE_STATE(state_smtc_entry, state_smtc_run, NULL), + [STATE_SMTC] = SMF_CREATE_STATE(state_smtc_entry, state_smtc_run, NULL, NULL, NULL), #endif /* CONFIG_SMTC_CLI */ }; @@ -85,7 +123,7 @@ static void state_sidewalk_entry(void *o) (radio_lr11xx_device_config_t *)get_radio_cfg(), #else (radio_sx126x_device_config_t *)get_radio_cfg(), -#endif /* CONFIG_RADIO_LR11XX */ +#endif /* CONFIG_RADIO_LR11XX */ #endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ }; @@ -123,7 +161,6 @@ static void state_sidewalk_entry(void *o) (SID_LINK_TYPE_3 & sm->sid->config.link_mask) ? "LoRa" : (SID_LINK_TYPE_2 & sm->sid->config.link_mask) ? "FSK" : "BLE"); - e = sid_init(&sm->sid->config, &sm->sid->handle); if (e) { LOG_ERR("sid init err %d", (int)e); @@ -137,10 +174,7 @@ static void state_sidewalk_entry(void *o) } #endif /* CONFIG_SMTC_CLI */ -#ifdef CONFIG_SIDEWALK_FILE_TRANSFER - app_file_transfer_demo_init(sm->sid->handle); -#endif - e = sid_start(sm->sid->handle, sm->sid->config.link_mask); // state_sidewalk_entry() + e = sid_start(sm->sid->handle, sm->sid->config.link_mask); if (e) { LOG_ERR("sid start err %d", (int)e); } @@ -172,6 +206,16 @@ static void state_sidewalk_entry(void *o) #endif /* CONFIG_SID_END_DEVICE_AUTO_CONN_REQ */ #endif /* CONFIG_SIDEWALK_AUTO_START */ + +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU + int dfu_err = boot_write_img_confirmed(); + if (dfu_err) { + LOG_ERR("img confirm fail %d", dfu_err); + } +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER + app_file_transfer_demo_init(((sm_t *)o)->sid->handle); +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER */ } static void state_sidewalk_run(void *o) @@ -181,9 +225,7 @@ static void state_sidewalk_run(void *o) switch (sm->event.id) { case SID_EVENT_SIDEWALK: { - //sid_pal_gpio_write(radio_dbg, 0); e = sid_process(sm->sid->handle); - //sid_pal_gpio_write(radio_dbg, 1); if (e) { LOG_ERR("sid process err %d", (int)e); } @@ -240,7 +282,7 @@ static void state_sidewalk_run(void *o) #ifdef CONFIG_SIDEWALK_FILE_TRANSFER app_file_transfer_demo_init(sm->sid->handle); #endif - e = sid_start(sm->sid->handle, sm->sid->config.link_mask); // state_sidewalk_run() SID_EVENT_LINK_SWITCH + e = sid_start(sm->sid->handle, sm->sid->config.link_mask); if (e) { LOG_ERR("sid start err %d", (int)e); } @@ -303,8 +345,13 @@ static void state_sidewalk_run(void *o) LOG_ERR("sid send err %d", (int)e); } LOG_DBG("sid send (type: %d, id: %u)", (int)p_msg->desc.type, p_msg->desc.id); - sid_hal_free(p_msg->msg.data); - sid_hal_free(p_msg); + int mutex_err = k_mutex_lock(&pending_message_list_mutex, K_FOREVER); + if (mutex_err != 0) { + LOG_ERR("Failed to lock mutex for message list"); + break; + } + sys_slist_append(&pending_message_list, &p_msg->node); + k_mutex_unlock(&pending_message_list_mutex); } break; case SID_EVENT_CONNECT: { if (!(sm->sid->config.link_mask & SID_LINK_TYPE_1)) { @@ -318,17 +365,20 @@ static void state_sidewalk_run(void *o) } break; case SID_EVENT_FILE_TRANSFER: { #ifdef CONFIG_SIDEWALK_FILE_TRANSFER - struct data_received_args *args = (struct data_received_args *)sm->event.ctx; - if (!args) { + sidewalk_transfer_t *transfer = (sidewalk_transfer_t *)sm->event.ctx; + if (!transfer) { LOG_ERR("File transfer event data is NULL"); break; } - LOG_INF("Received file Id %d; buffer size %d; file offset %d", args->desc.file_id, - args->buffer->size, args->desc.file_offset); + + LOG_INF("Received file Id %d; buffer size %d; file offset %d", transfer->file_id, + transfer->data_size, transfer->file_offset); + + // print data hash uint8_t hash_out[32]; sid_pal_hash_params_t params = { .algo = SID_PAL_HASH_SHA256, - .data = args->buffer->data, - .data_size = args->buffer->size, + .data = transfer->data, + .data_size = transfer->data_size, .digest = hash_out, .digest_size = sizeof(hash_out) }; @@ -345,15 +395,46 @@ static void state_sidewalk_run(void *o) LOG_INF("SHA256: %s", hex_str); } - sid_error_t ret = sid_bulk_data_transfer_release_buffer( - sm->sid->handle, args->desc.file_id, args->buffer); - if (ret != SID_ERROR_NONE) { - LOG_ERR("sid_bulk_data_transfer_release_buffer returned %s", - SID_ERROR_T_STR(ret)); +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU + int err = nordic_dfu_img_write(transfer->file_offset, transfer->data, + transfer->data_size); + + if (err) { + LOG_ERR("Fail to write img %d", err); + err = nordic_dfu_img_cancel(); + if (err) { + LOG_ERR("Fail to complete dfu %d", err); + } + e = sid_bulk_data_transfer_cancel( + sm->sid->handle, transfer->file_id, + SID_BULK_DATA_TRANSFER_REJECT_REASON_FILE_TOO_BIG); + if (e != SID_ERROR_NONE) { + LOG_ERR("sbdt cancel ret %s", SID_ERROR_T_STR(e)); + } + + sid_hal_free(transfer); + break; + } +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ + const struct sid_bulk_data_transfer_buffer sbdt_buffer = { + .data = transfer->data, + .size = transfer->data_size, + }; + e = sid_bulk_data_transfer_release_buffer(sm->sid->handle, transfer->file_id, + &sbdt_buffer); + if (e != SID_ERROR_NONE) { + LOG_ERR("sbdt release ret %s", SID_ERROR_T_STR(e)); } - sid_hal_free(args); + + // free event context + sid_hal_free(transfer); #endif /* CONFIG_SIDEWALK_FILE_TRANSFER */ } break; + case SID_EVENT_REBOOT: { + LOG_INF("Rebooting..."); + LOG_PANIC(); + sys_reboot(SYS_REBOOT_WARM); + } break; case SID_EVENT_TOGGLE_LBM_SIDEWALK: e = sid_stop(sm->sid->handle, sm->sid->config.link_mask); if (e) { @@ -412,6 +493,25 @@ static void state_smtc_run(void *o) } #endif /* CONFIG_SMTC_CLI */ +static void state_sidewalk_exit(void *o) +{ + int mutex_err = k_mutex_lock(&pending_message_list_mutex, K_FOREVER); + if (mutex_err != 0) { + LOG_ERR("Failed to lock mutex for message list"); + return; + } + sys_snode_t *list_element = sys_slist_get(&pending_message_list); + + while (list_element != NULL) { + sidewalk_msg_t *message = SYS_SLIST_CONTAINER(list_element, message, node); + sid_hal_free(message->msg.data); + sid_hal_free(message); + + list_element = sys_slist_get(&pending_message_list); + } + k_mutex_unlock(&pending_message_list_mutex); +} + static void state_dfu_entry(void *o) { sm_t *sm = (sm_t *)o; @@ -452,6 +552,9 @@ static void state_dfu_run(void *o) case SID_EVENT_LINK_SWITCH: case SID_EVENT_SIDEWALK: case SID_EVENT_FILE_TRANSFER: + case SID_EVENT_REBOOT: + LOG_INF("Operation not supported in DFU mode"); + break; case SID_EVENT_TOGGLE_LBM_SIDEWALK: LOG_INF("Operation not supported in DFU mode"); break; @@ -475,7 +578,7 @@ static void sid_thread_entry(void *context, void *unused, void *unused2) k_msgq_init(&sid_sm.msgq, sid_msgq_buff, sizeof(sidewalk_ctx_event_t), CONFIG_SIDEWALK_THREAD_QUEUE_SIZE); -#if defined(CONFIG_SMTC_CLI) +#ifdef CONFIG_SMTC_CLI smf_set_initial(SMF_CTX(&sid_sm), &sid_states[STATE_SMTC]); #elif defined(CONFIG_LBM_END_DEVICE) smf_set_initial(SMF_CTX(&sid_sm), &sid_states[STATE_LBM]); @@ -502,11 +605,7 @@ static void sid_thread_entry(void *context, void *unused, void *unused2) break; } } else { - if (err == -ENOMSG) - LOG_ERR("msgq ENOMSG"); // returned without waiting - else - LOG_ERR("Sidewalk msgq err %d", err); - k_sleep(K_MSEC(100)); + LOG_ERR("Sidewalk msgq err %d", err); } } @@ -528,8 +627,17 @@ int sidewalk_event_send(sidewalk_event_t event, void *ctx) .ctx = ctx, }; - const int result = k_msgq_put(&sid_sm.msgq, (void *)&ctx_event, K_NO_WAIT); + k_timeout_t timeout = K_NO_WAIT; + +#ifdef CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT + if (!k_is_in_isr()) { + timeout = K_MSEC(CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT_VALUE); + } +#endif /* CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT */ + + const int result = k_msgq_put(&sid_sm.msgq, (void *)&ctx_event, timeout); LOG_DBG("sidewalk_event_send event = %d (%s), context = %p, k_msgq_put result %d", event, SIDEWALK_EVENT_T_STR(event), ctx, result); + return result; } diff --git a/samples/lbm_sid_end_device/sysbuild/ipc_radio/prj.conf b/samples/lbm_sid_end_device/sysbuild/ipc_radio/prj.conf new file mode 100644 index 0000000..654a36b --- /dev/null +++ b/samples/lbm_sid_end_device/sysbuild/ipc_radio/prj.conf @@ -0,0 +1,35 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 + +# Bluetooth +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y +CONFIG_BT_CTLR_ASSERT_HANDLER=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_CENTRAL=n +CONFIG_BT_MAX_CONN=1 +CONFIG_BT_BUF_ACL_RX_SIZE=502 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 + +# IPC +CONFIG_IPC_SERVICE=y +CONFIG_MBOX=y + +# Debug +CONFIG_LOG=n +CONFIG_SERIAL=n +CONFIG_ASSERT=y +CONFIG_DEBUG_INFO=y +CONFIG_EXCEPTION_STACK_TRACE=y +CONFIG_RESET_ON_FATAL_ERROR=y + +# ipc_radio +CONFIG_IPC_RADIO_BT=y +CONFIG_IPC_RADIO_BT_HCI_IPC=y diff --git a/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf new file mode 100644 index 0000000..c333f7b --- /dev/null +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2023 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Configure QSPI for external flash +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 0000000..6ea6421 --- /dev/null +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + chosen { + zephyr,code-partition = &boot_partition; + nordic,pm-ext-flash = &mx25r64; + }; +}; diff --git a/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 0000000..96cb33e --- /dev/null +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1,28 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 + +# The following configurations are required to support simultaneous multi image update +CONFIG_PCD_APP=y +CONFIG_UPDATEABLE_IMAGE_NUMBER=2 + +CONFIG_BOOT_SWAP_USING_MOVE=n +# Multi-image updates do not support image swapping yet. +CONFIG_BOOT_UPGRADE_ONLY=y + +# The network core cannot access external flash directly. The flash simulator must be used to +# provide a memory region that is used to forward the new firmware to the network core. +CONFIG_FLASH_SIMULATOR=y +CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y +CONFIG_FLASH_SIMULATOR_STATS=n + +# Enable custom command to erase settings partition. +CONFIG_ENABLE_MGMT_PERUSER=y +CONFIG_ZCBOR=y +CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE=y diff --git a/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay similarity index 77% rename from samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay rename to samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay index 055f044..6ea6421 100644 --- a/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -4,8 +4,9 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ - / { +/ { chosen { + zephyr,code-partition = &boot_partition; nordic,pm-ext-flash = &mx25r64; }; }; diff --git a/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf new file mode 100644 index 0000000..16bd5b0 --- /dev/null +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf @@ -0,0 +1,13 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +CONFIG_BOOT_MAX_IMG_SECTORS=256 +# Ensure that the qspi driver is disabled by default +CONFIG_NORDIC_QSPI_NOR=n + +# Workaroud: fprotect and watchdog feed +# are not supported in NCS v2.6.0 +CONFIG_FPROTECT=n +CONFIG_BOOT_WATCHDOG_FEED=n diff --git a/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay new file mode 100644 index 0000000..6220cb2 --- /dev/null +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/* There is no aditional config needed for this version of PDK */ diff --git a/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay new file mode 100644 index 0000000..8edfb64 --- /dev/null +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + +/* Application does not use cpuflpr core. Assign whole RRAM to cpuapp. */ +&cpuapp_rram { + reg = < 0x0 DT_SIZE_K(1524) >; +}; diff --git a/samples/sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340_cpuapp.conf b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.conf similarity index 93% rename from samples/sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340_cpuapp.conf rename to samples/lbm_sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.conf index a0db3d5..561529f 100644 --- a/samples/sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340_cpuapp.conf +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.conf @@ -4,9 +4,6 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -# Increase main stack size -CONFIG_MAIN_STACK_SIZE=10240 - # Configure MCUboot features CONFIG_NRF53_MULTI_IMAGE_UPDATE=y CONFIG_BOOT_UPGRADE_ONLY=y diff --git a/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay new file mode 100644 index 0000000..6ea6421 --- /dev/null +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + chosen { + zephyr,code-partition = &boot_partition; + nordic,pm-ext-flash = &mx25r64; + }; +}; diff --git a/samples/lbm_sid_end_device/sysbuild/mcuboot/prj.conf b/samples/lbm_sid_end_device/sysbuild/mcuboot/prj.conf new file mode 100644 index 0000000..0a05853 --- /dev/null +++ b/samples/lbm_sid_end_device/sysbuild/mcuboot/prj.conf @@ -0,0 +1,39 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +CONFIG_MAIN_STACK_SIZE=10240 + +CONFIG_BOOT_SWAP_SAVE_ENCTLV=n +CONFIG_BOOT_BOOTSTRAP=n +CONFIG_PM=n + +CONFIG_FLASH=y +CONFIG_FPROTECT=y + +CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" + +CONFIG_BOOT_MAX_IMG_SECTORS=256 + +# Use minimal C library instead of the Picolib +CONFIG_MINIMAL_LIBC=y + +# Disable logs +CONFIG_NCS_BOOT_BANNER=n +CONFIG_CONSOLE=n +CONFIG_SERIAL=n +CONFIG_UART_CONSOLE=n +CONFIG_USE_SEGGER_RTT=n +CONFIG_LOG=n +CONFIG_CONSOLE_HANDLER=n +CONFIG_BOOT_BANNER=n + +# Bootloader size optimization +CONFIG_RESET_ON_FATAL_ERROR=n +CONFIG_GPIO=n +CONFIG_TIMESLICING=n +CONFIG_MULTITHREADING=n +CONFIG_TICKLESS_KERNEL=n +CONFIG_TIMEOUT_64BIT=n +CONFIG_NRF_ENABLE_ICACHE=n diff --git a/samples/sid_end_device/CMakeLists.txt b/samples/sid_end_device/CMakeLists.txt index c0a6550..2e2c967 100644 --- a/samples/sid_end_device/CMakeLists.txt +++ b/samples/sid_end_device/CMakeLists.txt @@ -6,24 +6,6 @@ cmake_minimum_required(VERSION 3.20.0) -# Sidewalk version -include(bootloader_version.cmake) - -# Child images -set(hci_ipc_KCONFIG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/child_image/hci_ipc/Kconfig.root) -set(mcuboot_KCONFIG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/child_image/mcuboot/Kconfig.root) - -# Configurations -if(CONF_FILE) - get_filename_component(CONFIG_FILE_NAME ${CONF_FILE} NAME) -endif() - -if("${CONFIG_FILE_NAME}" STREQUAL "prj_no_dfu.conf") - set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/pm_static_no_dfu.yml) -else() - set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static_dfu.yml) -endif() - # Zephyr CMake project find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(sidewalk_sid_end_device) @@ -35,7 +17,10 @@ target_sources(app PRIVATE src/sidewalk.c ) -target_sources_ifdef(CONFIG_SIDEWALK_FILE_TRANSFER app PRIVATE src/file_transfer.c) +target_sources_ifdef(CONFIG_SIDEWALK_FILE_TRANSFER app PRIVATE + src/sbdt/file_transfer.c + src/sbdt/scratch_buffer.c +) if(CONFIG_SID_END_DEVICE_SENSOR_MONITORING) target_sources(app PRIVATE @@ -61,6 +46,7 @@ if(CONFIG_SID_END_DEVICE_CLI) src/cli/app_dut.c src/cli/app_shell.c ) + target_sources_ifdef(CONFIG_SIDEWALK_ON_DEV_CERT app PRIVATE src/cli/sid_on_dev_cert_cli.c) endif() if(CONFIG_SMTC_CLI) diff --git a/samples/sid_end_device/Kconfig b/samples/sid_end_device/Kconfig index 6bcff8e..9cdc196 100644 --- a/samples/sid_end_device/Kconfig +++ b/samples/sid_end_device/Kconfig @@ -45,10 +45,10 @@ config SID_END_DEVICE_CLI The interface commands are compatilbe with former dut sample. config SMTC_CLI - bool "enable semtech CLI" - imply SHELL - help - Enables semtech radio command line interface. + bool "enable semtech CLI" + imply SHELL + help + Enables semtech radio command line interface. config SID_END_DEVICE_AUTO_START default y @@ -71,9 +71,35 @@ config SID_END_DEVICE_EVENT_HEAP_SIZE config SIDEWALK_FILE_TRANSFER select EXPERIMENTAL - bool "Add File transfer capability to the application" + bool "Enable Sidewalk file transfer" help - Include the callbacks necesary to handle file transfer + Add support for Sidewalk Bulk Data Transfer (SBDT) + in application. + +if SIDEWALK_FILE_TRANSFER + +config SIDEWALK_FILE_TRANSFER_HEAP_SIZE + int "Sidewalk file transfer heap size" + default 10240 + help + Heap size in bytes to be allocated + for Sidewalk Bulk Data Transfer (SBDT). + +config SIDEWALK_FILE_TRANSFER_DFU + bool "Sildewak file transfer and dfu" + default SIDEWALK_FILE_TRANSFER + imply SIDEWALK_DFU_IMG_UTILS + imply DFU_MULTI_IMAGE + imply DFU_TARGET + imply DFU_TARGET_MCUBOOT + imply STREAM_FLASH + imply STREAM_FLASH_ERASE + imply SIDEWALK_THREAD_QUEUE_TIMEOUT + help + Save recived data to flash. Expect CBOR manifest. + Autoatically reset device after file transfer. + +endif rsource "Kconfig.defconfig" diff --git a/samples/sid_end_device/Kconfig.sysbuild b/samples/sid_end_device/Kconfig.sysbuild new file mode 100644 index 0000000..404f972 --- /dev/null +++ b/samples/sid_end_device/Kconfig.sysbuild @@ -0,0 +1,54 @@ +# +# Copyright (c) 2023 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +config NRF_DEFAULT_IPC_RADIO + default y if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP + +choice BOOTLOADER + default BOOTLOADER_MCUBOOT +endchoice + +if BOOTLOADER_MCUBOOT + +config DFU_MULTI_IMAGE_PACKAGE_BUILD + default y + +config DFU_MULTI_IMAGE_PACKAGE_APP + default y + +if (BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP) + +config MCUBOOT_UPDATEABLE_IMAGES + default 2 + +choice MCUBOOT_MODE + default MCUBOOT_MODE_OVERWRITE_ONLY +endchoice + +choice BOOT_SIGNATURE_TYPE + default BOOT_SIGNATURE_TYPE_RSA +endchoice + +config SECURE_BOOT + default y + +config SECURE_BOOT_NETCORE + default y + +config NETCORE_APP_UPDATE + default y + +config DFU_MULTI_IMAGE_PACKAGE_NET + default y + +endif # BOOTLOADER_MCUBOOT + +endif # (BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP) + +config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY + default y if BOARD_NRF52840DK_NRF52840 || BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/sid_end_device/VERSION b/samples/sid_end_device/VERSION new file mode 100644 index 0000000..808984a --- /dev/null +++ b/samples/sid_end_device/VERSION @@ -0,0 +1,5 @@ +VERSION_MAJOR = 2 +VERSION_MINOR = 6 +PATCHLEVEL = 99 +VERSION_TWEAK = 0 +EXTRAVERSION = diff --git a/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.conf deleted file mode 100644 index 1fd0180..0000000 --- a/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.conf +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Allow for storing two images in MCUboot partitions -CONFIG_UPDATEABLE_IMAGE_NUMBER=2 - -# Store new images inside external flash -CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y - -# Configure QSPI for external flash -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 - -CONFIG_DFU_MULTI_IMAGE=y -CONFIG_NRF53_ENFORCE_IMAGE_VERSION_EQUALITY=y diff --git a/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.overlay b/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.overlay index 4395ed1..d0a7679 100644 --- a/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -20,6 +20,37 @@ }; /{ + state_notifier_gpios{ + compatible = "gpio-keys"; + state_notifier_error: error { + gpios = <&gpio1 0x8 0x0>; + label = "Application state error"; + }; + state_notifier_dfu: dfu { + gpios = <&gpio1 0x2 0x0>; + label = "Application state dfu"; + }; + state_notifier_sending: sending { + gpios = <&gpio1 0x4 0x0>; + label = "Application state sending"; + }; + state_notifier_receiving: receiving { + gpios = <&gpio1 0x3 0x0>; + label = "Application state receiving"; + }; + }; + + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + state-notifier-error = &state_notifier_error; + state-notifier-dfu = &state_notifier_dfu; + state-notifier-sending = &state_notifier_sending; + state-notifier-receiving = &state_notifier_receiving; + }; + semtech_sx1262_gpios{ compatible = "gpio-keys"; semtech_sx1262_cs: cs { diff --git a/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp_release.conf b/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp_release.conf deleted file mode 100644 index 1fd0180..0000000 --- a/samples/sid_end_device/boards/nrf5340dk_nrf5340_cpuapp_release.conf +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Allow for storing two images in MCUboot partitions -CONFIG_UPDATEABLE_IMAGE_NUMBER=2 - -# Store new images inside external flash -CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y - -# Configure QSPI for external flash -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 - -CONFIG_DFU_MULTI_IMAGE=y -CONFIG_NRF53_ENFORCE_IMAGE_VERSION_EQUALITY=y diff --git a/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf new file mode 100644 index 0000000..d6a0780 --- /dev/null +++ b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.conf @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Workaround: +# The nRF54L15 PDK (PCA10156) revisions v0.2.0 AA0-ES2, v0.2.0 AA0-ES3, +# and v0.2.1 AB0-ES5 have Buttons 3 and 4 connected to the GPIO port +# which does not support interrupts. +CONFIG_DK_LIBRARY_BUTTON_NO_ISR=y + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay new file mode 100644 index 0000000..811a033 --- /dev/null +++ b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/* Application does not use cpuflpr core. Assign whole RRAM to cpuapp. */ +&cpuapp_rram { + reg = < 0x0 DT_SIZE_K(1524) >; +}; +&pinctrl { + spi00_default: spi00_default { + group1 { + psels = , + , + ; + }; + }; + + spi00_sleep: spi00_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + +sid_semtech: &spi00 { + compatible = "nordic,nrf-spim"; + status = "okay"; + pinctrl-0 = <&spi00_default>; + pinctrl-1 = <&spi00_sleep>; + pinctrl-names = "default", "sleep"; + clock-frequency = ; +}; + +/{ + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + }; + + semtech_sx1262_gpios{ + compatible = "gpio-keys"; + semtech_sx1262_cs: cs { + gpios = <&gpio2 0xa GPIO_PULL_UP>; + label = "semtech_sx1262 CS"; + }; + semtech_sx1262_reset_gpios: reset { + gpios = <&gpio1 0xb (GPIO_ACTIVE_LOW|GPIO_PULL_UP)>; + label = "semtech_sx1262 Reset"; + }; + semtech_sx1262_busy_gpios: busy { + gpios = <&gpio1 0xc 0x0>; + label = "semtech_sx1262 Busy"; + }; + semtech_sx1262_antenna_enable_gpios: antena_enable { + gpios = <&gpio2 0x7 0x0>; + label = "semtech_sx1262 Antena Enable"; + }; + semtech_sx1262_dio1_gpios: dio1 { + gpios = <&gpio1 0xa 0x0>; + label = "semtech_sx1262 DIO1"; + }; + radio_gnss_lna: gnss_lna { + gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; + label = "gnss antenna"; + }; + radio_led_sniff: led_sniff { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "yellow LED"; + }; + radio_led_tx: led_tx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "red tx LED"; + }; + radio_led_rx: led_rx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "green rx LED"; + }; + }; + +}; + +&gpiote20 { + status = "okay"; +}; + +&gpiote30 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; diff --git a/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf new file mode 100644 index 0000000..e99da54 --- /dev/null +++ b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay new file mode 100644 index 0000000..5a08ece --- /dev/null +++ b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + +/* Application does not use cpuflpr core. Assign whole RRAM to cpuapp. */ +&cpuapp_rram { + reg = < 0x0 DT_SIZE_K(1524) >; +}; + + &pinctrl { + spi21_default: spi21_default { + group1 { + psels = , + , + ; + }; + }; + + spi21_sleep: spi21_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + + sid_semtech: &spi21 { + compatible = "nordic,nrf-spim"; + status = "okay"; + pinctrl-0 = <&spi21_default>; + pinctrl-1 = <&spi21_sleep>; + pinctrl-names = "default", "sleep"; + clock-frequency = ; +}; + +/{ + aliases { + state-notifier-connected = &led0; + state-notifier-time-sync = &led1; + state-notifier-registered = &led2; + state-notifier-working = &led3; + }; + + semtech_sx1262_gpios{ + compatible = "gpio-keys"; + semtech_sx1262_cs: cs { + gpios = <&gpio2 0xa GPIO_PULL_UP>; + label = "semtech_sx1262 CS"; + }; + semtech_sx1262_reset_gpios: reset { + gpios = <&gpio0 0x2 (GPIO_ACTIVE_LOW|GPIO_PULL_UP)>; + label = "semtech_sx1262 Reset"; + }; + semtech_sx1262_busy_gpios: busy { + gpios = <&gpio0 0x0 0x0>; + label = "semtech_sx1262 Busy"; + }; + semtech_sx1262_antenna_enable_gpios: antena_enable { + gpios = <&gpio0 0x1 0x0>; + label = "semtech_sx1262 Antena Enable"; + }; + semtech_sx1262_dio1_gpios: dio1 { + gpios = <&gpio0 0x3 0x0>; + label = "semtech_sx1262 DIO1"; + }; + radio_gnss_lna: gnss_lna { + gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; + label = "gnss antenna"; + }; + radio_led_sniff: led_sniff { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "yellow LED"; + }; + radio_led_tx: led_tx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "red tx LED"; + }; + radio_led_rx: led_rx { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "green rx LED"; + }; + }; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; diff --git a/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf new file mode 100644 index 0000000..d6a0780 --- /dev/null +++ b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_2_1.conf @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Workaround: +# The nRF54L15 PDK (PCA10156) revisions v0.2.0 AA0-ES2, v0.2.0 AA0-ES3, +# and v0.2.1 AB0-ES5 have Buttons 3 and 4 connected to the GPIO port +# which does not support interrupts. +CONFIG_DK_LIBRARY_BUTTON_NO_ISR=y + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf new file mode 100644 index 0000000..e99da54 --- /dev/null +++ b/samples/sid_end_device/boards/nrf54l15pdk_nrf54l15_cpuapp_release_0_3_0.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_SOC_FLASH_NRF_TIMEOUT_MULTIPLIER=100 diff --git a/samples/sid_end_device/boards/thingy53_nrf5340_cpuapp_no_dfu.conf b/samples/sid_end_device/boards/thingy53_nrf5340_cpuapp_no_dfu.conf deleted file mode 100644 index e9fc49e..0000000 --- a/samples/sid_end_device/boards/thingy53_nrf5340_cpuapp_no_dfu.conf +++ /dev/null @@ -1,10 +0,0 @@ -# -# Copyright (c) 2023 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# -CONFIG_BOOTLOADER_MCUBOOT=n - -CONFIG_I2C=y -CONFIG_SENSOR=y -CONFIG_BME680=y diff --git a/samples/sid_end_device/child_image/hci_ipc/Kconfig.root b/samples/sid_end_device/child_image/hci_ipc/Kconfig.root deleted file mode 100644 index 60e8bd4..0000000 --- a/samples/sid_end_device/child_image/hci_ipc/Kconfig.root +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# The purpose of this file is to create a wrapper Kconfig file that will be set as -# hci_ipc_KCONFIG_ROOT and processed before any other Kconfig for hci_ipc child image. - -config HEAP_MEM_POOL_SIZE - default 8192 - -config MAIN_STACK_SIZE - default 2048 - -config SYSTEM_WORKQUEUE_STACK_SIZE - default 2048 - -config BT - default y - -config BT_HCI_RAW - default y - -config BT_MAX_CONN - default 1 - -config BT_PERIPHERAL - default y - -config BT_CENTRAL - default n - -config BT_BUF_ACL_RX_SIZE - default 502 - -config BT_BUF_ACL_TX_SIZE - default 251 - -config BT_CTLR_DATA_LENGTH_MAX - default 251 - -config BT_CTLR_ASSERT_HANDLER - default y - -config BT_HCI_RAW_RESERVE - default 1 - -# Workaround: Unable to allocate command buffer when using K_NO_WAIT since -# Host number of completed commands does not follow normal flow control. -config BT_BUF_CMD_TX_COUNT - default 10 - -config ASSERT - default y - -config DEBUG_INFO - default y - -config EXCEPTION_STACK_TRACE - default y - -config IPC_SERVICE - default y - -config MBOX - default y - -source "Kconfig.zephyr" diff --git a/samples/sid_end_device/child_image/hci_ipc/prj.conf b/samples/sid_end_device/child_image/hci_ipc/prj.conf deleted file mode 100644 index c89bda6..0000000 --- a/samples/sid_end_device/child_image/hci_ipc/prj.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_LOG=n -CONFIG_SERIAL=n -CONFIG_RESET_ON_FATAL_ERROR=n diff --git a/samples/sid_end_device/child_image/hci_ipc/prj_no_dfu.conf b/samples/sid_end_device/child_image/hci_ipc/prj_no_dfu.conf deleted file mode 100644 index c89bda6..0000000 --- a/samples/sid_end_device/child_image/hci_ipc/prj_no_dfu.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_LOG=n -CONFIG_SERIAL=n -CONFIG_RESET_ON_FATAL_ERROR=n diff --git a/samples/sid_end_device/child_image/hci_ipc/prj_release.conf b/samples/sid_end_device/child_image/hci_ipc/prj_release.conf deleted file mode 100644 index 86c0d92..0000000 --- a/samples/sid_end_device/child_image/hci_ipc/prj_release.conf +++ /dev/null @@ -1,9 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_LOG=n -CONFIG_SERIAL=n -CONFIG_UART_CONSOLE=n -CONFIG_RESET_ON_FATAL_ERROR=y diff --git a/samples/sid_end_device/child_image/mcuboot/Kconfig.root b/samples/sid_end_device/child_image/mcuboot/Kconfig.root deleted file mode 100644 index d6ecb28..0000000 --- a/samples/sid_end_device/child_image/mcuboot/Kconfig.root +++ /dev/null @@ -1,127 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# The purpose of this file is to create a wrapper Kconfig file that will be set as -# mcuboot_KCONFIG_ROOT and processed before any other Kconfig for mcuboot child image. - - -config MAIN_STACK_SIZE - default 10240 - -config BOOT_SWAP_SAVE_ENCTLV - default n - -config BOOT_ENCRYPT_RSA - default n - -config BOOT_ENCRYPT_EC256 - default n - -config BOOT_ENCRYPT_X25519 - default n - -config BOOT_BOOTSTRAP - default n - -config PM - default n - -config FLASH - default y - -config FPROTECT - default y - -config NORDIC_QSPI_NOR - default y - -config NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE - default 4096 - -config NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE - default 16 - -config BOOT_MAX_IMG_SECTORS - default 256 - -config LOG - default n - -choice LIBC_IMPLEMENTATION - default MINIMAL_LIBC -endchoice - -config COMMON_LIBC_CALLOC - default y - -config COMMON_LIBC_MALLOC - default y - -config COMMON_LIBC_REALLOCARRAY - default y - -config NCS_SAMPLES_DEFAULTS - default n - -config PRINTK - default n - -config REBOOT - default n - -config NRF_RTC_TIMER - default y if SOC_SERIES_NRF53X - default n - -config CONSOLE - default n - -config CONSOLE_HANDLER - default n - -config GPIO - default n - -config KERNEL_MEM_POOL - default n - -config ASSERT - default n - -config BOOT_BANNER - default n - -config SERIAL - default n - -config UART_CONSOLE - default n - -config TIMESLICING - default n - -config USE_SEGGER_RTT - default n - -config RESET_ON_FATAL_ERROR - default n - -config SECURE_BOOT_DEBUG - default n - -config MULTITHREADING - default n - -config TICKLESS_KERNEL - default n - -config TIMEOUT_64BIT - default n - -config NRF_ENABLE_ICACHE - default n - -source "${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr/Kconfig" diff --git a/samples/sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay b/samples/sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay deleted file mode 100644 index 69bf975..0000000 --- a/samples/sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -/ { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay b/samples/sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay deleted file mode 100644 index 69bf975..0000000 --- a/samples/sid_end_device/child_image/mcuboot/boards/nrf52840dk_nrf52840_release.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -/ { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf deleted file mode 100644 index 3664dd3..0000000 --- a/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Increase main stack size -CONFIG_MAIN_STACK_SIZE=10240 - -# Configure MCUboot features -CONFIG_NRF53_MULTI_IMAGE_UPDATE=y -CONFIG_BOOT_UPGRADE_ONLY=y -CONFIG_BOOT_MAX_IMG_SECTORS=256 -CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y - -# Allow for storing two images in MCUboot partitions -CONFIG_UPDATEABLE_IMAGE_NUMBER=2 - -# Store new images inside external flash -CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y - -# Enable flash simulator -CONFIG_PCD_APP=y -CONFIG_FLASH_SIMULATOR=y -CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y -CONFIG_FLASH_SIMULATOR_STATS=n - -# Configure QSPI for external flash -CONFIG_FLASH=y -CONFIG_FPROTECT=y -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf b/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf deleted file mode 100644 index 3664dd3..0000000 --- a/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.conf +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Increase main stack size -CONFIG_MAIN_STACK_SIZE=10240 - -# Configure MCUboot features -CONFIG_NRF53_MULTI_IMAGE_UPDATE=y -CONFIG_BOOT_UPGRADE_ONLY=y -CONFIG_BOOT_MAX_IMG_SECTORS=256 -CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y - -# Allow for storing two images in MCUboot partitions -CONFIG_UPDATEABLE_IMAGE_NUMBER=2 - -# Store new images inside external flash -CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y - -# Enable flash simulator -CONFIG_PCD_APP=y -CONFIG_FLASH_SIMULATOR=y -CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y -CONFIG_FLASH_SIMULATOR_STATS=n - -# Configure QSPI for external flash -CONFIG_FLASH=y -CONFIG_FPROTECT=y -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay b/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay deleted file mode 100644 index c670799..0000000 --- a/samples/sid_end_device/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_release.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - - / { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay b/samples/sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay deleted file mode 100644 index 055f044..0000000 --- a/samples/sid_end_device/child_image/mcuboot/boards/thingy53_nrf5340dk_nrf5340_cpuapp.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2023 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - - / { - chosen { - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/sid_end_device/child_image/mcuboot/prj.conf b/samples/sid_end_device/child_image/mcuboot/prj.conf deleted file mode 100644 index 78d7622..0000000 --- a/samples/sid_end_device/child_image/mcuboot/prj.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" - -CONFIG_BOOT_UPGRADE_ONLY=n -CONFIG_RESET_ON_FATAL_ERROR=y - -CONFIG_LOG=n -CONFIG_PRINTK=n -CONFIG_CONSOLE_HANDLER=n -CONFIG_ASSERT=n -CONFIG_BOOT_BANNER=n -CONFIG_CONSOLE=n -CONFIG_SERIAL=n -CONFIG_UART_CONSOLE=n -CONFIG_USE_SEGGER_RTT=n -CONFIG_GPIO=n -CONFIG_NO_RUNTIME_CHECKS=y -CONFIG_SIZE_OPTIMIZATIONS=y diff --git a/samples/sid_end_device/child_image/mcuboot/prj_release.conf b/samples/sid_end_device/child_image/mcuboot/prj_release.conf deleted file mode 100644 index 78d7622..0000000 --- a/samples/sid_end_device/child_image/mcuboot/prj_release.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" - -CONFIG_BOOT_UPGRADE_ONLY=n -CONFIG_RESET_ON_FATAL_ERROR=y - -CONFIG_LOG=n -CONFIG_PRINTK=n -CONFIG_CONSOLE_HANDLER=n -CONFIG_ASSERT=n -CONFIG_BOOT_BANNER=n -CONFIG_CONSOLE=n -CONFIG_SERIAL=n -CONFIG_UART_CONSOLE=n -CONFIG_USE_SEGGER_RTT=n -CONFIG_GPIO=n -CONFIG_NO_RUNTIME_CHECKS=y -CONFIG_SIZE_OPTIMIZATIONS=y diff --git a/samples/sid_end_device/configuration/pm_static_no_dfu.yml b/samples/sid_end_device/configuration/pm_static_no_dfu.yml deleted file mode 100644 index 658ce75..0000000 --- a/samples/sid_end_device/configuration/pm_static_no_dfu.yml +++ /dev/null @@ -1,5 +0,0 @@ -mfg_storage: - address: 0xff000 - end_address: 0x100000 - region: flash_primary - size: 0x1000 diff --git a/samples/sid_end_device/include/app.h b/samples/sid_end_device/include/app.h index 077f3ca..6eff418 100644 --- a/samples/sid_end_device/include/app.h +++ b/samples/sid_end_device/include/app.h @@ -4,9 +4,14 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ +#ifndef SAMPLE_APP_H +#define SAMPLE_APP_H + /** * @brief Start Sidewalk end device application. * * @note This function should never return. */ void app_start(void); + +#endif /* SAMPLE_APP_H */ diff --git a/samples/sid_end_device/include/file_transfer.h b/samples/sid_end_device/include/file_transfer.h deleted file mode 100644 index ad62fc4..0000000 --- a/samples/sid_end_device/include/file_transfer.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2024 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#include - -struct data_received_args { - struct sid_bulk_data_transfer_desc desc; - struct sid_bulk_data_transfer_buffer *buffer; - void *context; -}; - -void app_file_transfer_demo_init(struct sid_handle *handle); - -void app_file_transfer_demo_deinit(struct sid_handle *handle); diff --git a/samples/sid_end_device/include/sbdt/file_transfer.h b/samples/sid_end_device/include/sbdt/file_transfer.h new file mode 100644 index 0000000..c51eb1b --- /dev/null +++ b/samples/sid_end_device/include/sbdt/file_transfer.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#ifndef FILE_TRANSFER_H +#define FILE_TRANSFER_H + +#include + +/** + * @brief Initilize Sidewalk Bulk Data Transfer module. + * + * @param handle Sidewalk handle given by sid_init. + */ +void app_file_transfer_demo_init(struct sid_handle *handle); + +/** + * @brief Deinitilize Sidewalk Bulk Data Transfer module. + * + * @param handle Sidewalk handle given by sid_init. + */ +void app_file_transfer_demo_deinit(struct sid_handle *handle); + +#endif /* FILE_TRANSFER_H */ diff --git a/samples/sid_end_device/include/sbdt/scratch_buffer.h b/samples/sid_end_device/include/sbdt/scratch_buffer.h new file mode 100644 index 0000000..7de934e --- /dev/null +++ b/samples/sid_end_device/include/sbdt/scratch_buffer.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#ifndef SCRATCH_BUFFER_H +#define SCRATCH_BUFFER_H + +#include +#include + +/** + * @brief Init scratch buffer + * + * Inilizing module is neccessary to find files by id. + * + */ +void scratch_buffer_init(void); + +/** + * @brief Create scratch buffor assigned for file id. + * + * @param id file id + * @param size size of file buffer + * @return void* pointer to allocated memory. NULL on error. + */ +void *scratch_buffer_create(uint32_t id, size_t size); + +/** + * @brief Remove scratch buffer for file id. + * + * @param id file id + */ +void scratch_buffer_remove(uint32_t id); + +#endif /* SCRATCH_BUFFER_H */ diff --git a/samples/sid_end_device/include/sidewalk.h b/samples/sid_end_device/include/sidewalk.h index 35e1307..e66e37e 100644 --- a/samples/sid_end_device/include/sidewalk.h +++ b/samples/sid_end_device/include/sidewalk.h @@ -8,6 +8,9 @@ #include +#include +#include + typedef enum { SID_EVENT_SIDEWALK, SID_EVENT_FACTORY_RESET, @@ -17,6 +20,7 @@ typedef enum { SID_EVENT_LINK_SWITCH, SID_EVENT_NORDIC_DFU, SID_EVENT_FILE_TRANSFER, + SID_EVENT_REBOOT, SID_EVENT_LAST, } sidewalk_event_t; @@ -32,6 +36,7 @@ typedef struct { } sidewalk_ctx_t; typedef struct { + sys_snode_t node; struct sid_msg msg; struct sid_msg_desc desc; } sidewalk_msg_t; @@ -42,8 +47,17 @@ typedef struct { size_t data_len; } sidewalk_option_t; +typedef struct { + uint32_t file_id; + size_t file_offset; + void *data; + size_t data_size; +} sidewalk_transfer_t; + void sidewalk_start(sidewalk_ctx_t *context); int sidewalk_event_send(sidewalk_event_t event, void *ctx); +sidewalk_msg_t *get_message_buffer(uint16_t message_id); + #endif /* SIDEWALK_APP_H */ diff --git a/samples/sid_end_device/overlay-dut.conf b/samples/sid_end_device/overlay-dut.conf index a499386..38ab735 100644 --- a/samples/sid_end_device/overlay-dut.conf +++ b/samples/sid_end_device/overlay-dut.conf @@ -14,6 +14,9 @@ CONFIG_SIDEWALK_BLE_ADAPTER_LOG_LEVEL_DBG=y CONFIG_SID_END_DEVICE_AUTO_START=n CONFIG_SID_END_DEVICE_ECHO_MSGS=n +CONFIG_SIDEWALK_FILE_TRANSFER=y +CONFIG_SIDEWALK_FILE_TRANSFER_DFU=n + # smtc: #CONFIG_SIDEWALK_LINK_MASK_FSK=y # causes DUAL_LINK_SUPPORT=0 then non-working "sid init 3" #CONFIG_SIDEWALK_LINK_MASK_LORA=y diff --git a/samples/sid_end_device/pm_static.yml b/samples/sid_end_device/pm_static.yml deleted file mode 100644 index 55dba59..0000000 --- a/samples/sid_end_device/pm_static.yml +++ /dev/null @@ -1,10 +0,0 @@ -mcuboot: - address: 0x0 - end_address: 0x8000 - region: flash_primary - size: 0x8000 -mfg_storage: - address: 0xff000 - end_address: 0x100000 - region: flash_primary - size: 0x1000 diff --git a/samples/sid_end_device/pm_static_nrf52840dk_nrf52840.yml b/samples/sid_end_device/pm_static_nrf52840dk_nrf52840.yml new file mode 100644 index 0000000..10bf45a --- /dev/null +++ b/samples/sid_end_device/pm_static_nrf52840dk_nrf52840.yml @@ -0,0 +1,73 @@ +app: + address: 0x7200 + end_address: 0xfd000 + region: flash_primary + size: 0xf5e00 +external_flash: + address: 0xf6000 + end_address: 0x800000 + region: external_flash + size: 0x70a000 +mcuboot: + address: 0x0 + end_address: 0x7000 + region: flash_primary + size: 0x7000 +mcuboot_pad: + address: 0x7000 + end_address: 0x7200 + placement: + align: + start: 0x1000 + before: + - mcuboot_primary_app + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x7000 + end_address: 0xfd000 + orig_span: &id001 + - app + - mcuboot_pad + region: flash_primary + size: 0xf6000 + span: *id001 +mcuboot_primary_app: + address: 0x7200 + end_address: 0xfd000 + orig_span: &id002 + - app + region: flash_primary + size: 0xf5e00 + span: *id002 +mcuboot_secondary: + address: 0x0 + device: DT_CHOSEN(nordic_pm_ext_flash) + end_address: 0xf6000 + placement: + align: + start: 0x4 + region: external_flash + share_size: + - mcuboot_primary + size: 0xf6000 +mfg_storage: + address: 0xff000 + end_address: 0x100000 + region: flash_primary + size: 0x1000 +settings_storage: + address: 0xfd000 + end_address: 0xff000 + placement: + align: + start: 0x1000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20000000 + end_address: 0x20040000 + region: sram_primary + size: 0x40000 diff --git a/samples/sid_end_device/pm_static_nrf52840dk_nrf52840_release.yml b/samples/sid_end_device/pm_static_nrf52840dk_nrf52840_release.yml new file mode 100644 index 0000000..10bf45a --- /dev/null +++ b/samples/sid_end_device/pm_static_nrf52840dk_nrf52840_release.yml @@ -0,0 +1,73 @@ +app: + address: 0x7200 + end_address: 0xfd000 + region: flash_primary + size: 0xf5e00 +external_flash: + address: 0xf6000 + end_address: 0x800000 + region: external_flash + size: 0x70a000 +mcuboot: + address: 0x0 + end_address: 0x7000 + region: flash_primary + size: 0x7000 +mcuboot_pad: + address: 0x7000 + end_address: 0x7200 + placement: + align: + start: 0x1000 + before: + - mcuboot_primary_app + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x7000 + end_address: 0xfd000 + orig_span: &id001 + - app + - mcuboot_pad + region: flash_primary + size: 0xf6000 + span: *id001 +mcuboot_primary_app: + address: 0x7200 + end_address: 0xfd000 + orig_span: &id002 + - app + region: flash_primary + size: 0xf5e00 + span: *id002 +mcuboot_secondary: + address: 0x0 + device: DT_CHOSEN(nordic_pm_ext_flash) + end_address: 0xf6000 + placement: + align: + start: 0x4 + region: external_flash + share_size: + - mcuboot_primary + size: 0xf6000 +mfg_storage: + address: 0xff000 + end_address: 0x100000 + region: flash_primary + size: 0x1000 +settings_storage: + address: 0xfd000 + end_address: 0xff000 + placement: + align: + start: 0x1000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20000000 + end_address: 0x20040000 + region: sram_primary + size: 0x40000 diff --git a/samples/sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp.yml b/samples/sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp.yml new file mode 100644 index 0000000..5764ee5 --- /dev/null +++ b/samples/sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp.yml @@ -0,0 +1,119 @@ +EMPTY_0: + address: 0xfe000 + end_address: 0xff000 + placement: + after: + - settings_storage + region: flash_primary + size: 0x1000 +app: + address: 0x8200 + end_address: 0xfc000 + region: flash_primary + size: 0xf3e00 +external_flash: + address: 0x134000 + end_address: 0x800000 + region: external_flash + size: 0x6cc000 +mcuboot: + address: 0x0 + end_address: 0x8000 + region: flash_primary + size: 0x8000 +mcuboot_pad: + address: 0x8000 + end_address: 0x8200 + placement: + align: + start: 0x4000 + before: + - mcuboot_primary_app + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x8000 + end_address: 0xfc000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + size: 0xf4000 + span: *id001 +mcuboot_primary_1: + address: 0x0 + device: nordic_ram_flash_controller + end_address: 0x40000 + region: ram_flash + size: 0x40000 +mcuboot_primary_app: + address: 0x8200 + end_address: 0xfc000 + orig_span: &id002 + - app + region: flash_primary + size: 0xf3e00 + span: *id002 +mcuboot_secondary: + address: 0x0 + device: DT_CHOSEN(nordic_pm_ext_flash) + end_address: 0xf4000 + placement: + align: + start: 0x4 + region: external_flash + share_size: + - mcuboot_primary + size: 0xf4000 +mcuboot_secondary_1: + address: 0xf4000 + device: DT_CHOSEN(nordic_pm_ext_flash) + end_address: 0x134000 + region: external_flash + size: 0x40000 +mfg_storage: + address: 0xff000 + end_address: 0x100000 + region: flash_primary + size: 0x1000 +otp: + address: 0xff8100 + end_address: 0xff83fc + region: otp + size: 0x2fc +pcd_sram: + address: 0x20000000 + end_address: 0x20002000 + placement: + after: + - start + region: sram_primary + size: 0x2000 +ram_flash: + address: 0x40000 + end_address: 0x40000 + region: ram_flash + size: 0x0 +rpmsg_nrf53_sram: + address: 0x20070000 + end_address: 0x20080000 + placement: + before: + - end + region: sram_primary + size: 0x10000 +settings_storage: + address: 0xfc000 + end_address: 0xfe000 + placement: + align: + start: 0x4000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20002000 + end_address: 0x20070000 + region: sram_primary + size: 0x6e000 diff --git a/samples/sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml b/samples/sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml new file mode 100644 index 0000000..5764ee5 --- /dev/null +++ b/samples/sid_end_device/pm_static_nrf5340dk_nrf5340_cpuapp_release.yml @@ -0,0 +1,119 @@ +EMPTY_0: + address: 0xfe000 + end_address: 0xff000 + placement: + after: + - settings_storage + region: flash_primary + size: 0x1000 +app: + address: 0x8200 + end_address: 0xfc000 + region: flash_primary + size: 0xf3e00 +external_flash: + address: 0x134000 + end_address: 0x800000 + region: external_flash + size: 0x6cc000 +mcuboot: + address: 0x0 + end_address: 0x8000 + region: flash_primary + size: 0x8000 +mcuboot_pad: + address: 0x8000 + end_address: 0x8200 + placement: + align: + start: 0x4000 + before: + - mcuboot_primary_app + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x8000 + end_address: 0xfc000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + size: 0xf4000 + span: *id001 +mcuboot_primary_1: + address: 0x0 + device: nordic_ram_flash_controller + end_address: 0x40000 + region: ram_flash + size: 0x40000 +mcuboot_primary_app: + address: 0x8200 + end_address: 0xfc000 + orig_span: &id002 + - app + region: flash_primary + size: 0xf3e00 + span: *id002 +mcuboot_secondary: + address: 0x0 + device: DT_CHOSEN(nordic_pm_ext_flash) + end_address: 0xf4000 + placement: + align: + start: 0x4 + region: external_flash + share_size: + - mcuboot_primary + size: 0xf4000 +mcuboot_secondary_1: + address: 0xf4000 + device: DT_CHOSEN(nordic_pm_ext_flash) + end_address: 0x134000 + region: external_flash + size: 0x40000 +mfg_storage: + address: 0xff000 + end_address: 0x100000 + region: flash_primary + size: 0x1000 +otp: + address: 0xff8100 + end_address: 0xff83fc + region: otp + size: 0x2fc +pcd_sram: + address: 0x20000000 + end_address: 0x20002000 + placement: + after: + - start + region: sram_primary + size: 0x2000 +ram_flash: + address: 0x40000 + end_address: 0x40000 + region: ram_flash + size: 0x0 +rpmsg_nrf53_sram: + address: 0x20070000 + end_address: 0x20080000 + placement: + before: + - end + region: sram_primary + size: 0x10000 +settings_storage: + address: 0xfc000 + end_address: 0xfe000 + placement: + align: + start: 0x4000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20002000 + end_address: 0x20070000 + region: sram_primary + size: 0x6e000 diff --git a/samples/sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml b/samples/sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml new file mode 100644 index 0000000..2aae80f --- /dev/null +++ b/samples/sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp.yml @@ -0,0 +1,71 @@ +app: + address: 0xc800 + end_address: 0xc3000 + region: flash_primary + size: 0xb6800 +mcuboot: + address: 0x0 + end_address: 0xc000 + placement: + before: + - mcuboot_primary + region: flash_primary + size: 0xc000 +mcuboot_pad: + address: 0xc000 + end_address: 0xc800 + placement: + before: + - mcuboot_primary_app + region: flash_primary + size: 0x800 +mcuboot_primary: + address: 0xc000 + end_address: 0xc3000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + sharers: 0x1 + size: 0xb7000 + span: *id001 +mcuboot_primary_app: + address: 0xc800 + end_address: 0xc3000 + orig_span: &id002 + - app + region: flash_primary + size: 0xb6800 + span: *id002 +mcuboot_secondary: + address: 0xc3000 + end_address: 0x17a000 + placement: + after: + - mcuboot_primary + align: + start: 0x1000 + region: flash_primary + share_size: + - mcuboot_primary + size: 0xb7000 +mfg_storage: + address: 0x17c000 + end_address: 0x17d000 + region: flash_primary + size: 0x1000 +settings_storage: + address: 0x17a000 + end_address: 0x17c000 + placement: + align: + start: 0x1000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20000000 + end_address: 0x20040000 + region: sram_primary + size: 0x40000 diff --git a/samples/sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml b/samples/sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml new file mode 100644 index 0000000..2aae80f --- /dev/null +++ b/samples/sid_end_device/pm_static_nrf54l15pdk_nrf54l15_cpuapp_release.yml @@ -0,0 +1,71 @@ +app: + address: 0xc800 + end_address: 0xc3000 + region: flash_primary + size: 0xb6800 +mcuboot: + address: 0x0 + end_address: 0xc000 + placement: + before: + - mcuboot_primary + region: flash_primary + size: 0xc000 +mcuboot_pad: + address: 0xc000 + end_address: 0xc800 + placement: + before: + - mcuboot_primary_app + region: flash_primary + size: 0x800 +mcuboot_primary: + address: 0xc000 + end_address: 0xc3000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + sharers: 0x1 + size: 0xb7000 + span: *id001 +mcuboot_primary_app: + address: 0xc800 + end_address: 0xc3000 + orig_span: &id002 + - app + region: flash_primary + size: 0xb6800 + span: *id002 +mcuboot_secondary: + address: 0xc3000 + end_address: 0x17a000 + placement: + after: + - mcuboot_primary + align: + start: 0x1000 + region: flash_primary + share_size: + - mcuboot_primary + size: 0xb7000 +mfg_storage: + address: 0x17c000 + end_address: 0x17d000 + region: flash_primary + size: 0x1000 +settings_storage: + address: 0x17a000 + end_address: 0x17c000 + placement: + align: + start: 0x1000 + before: + - end + region: flash_primary + size: 0x2000 +sram_primary: + address: 0x20000000 + end_address: 0x20040000 + region: sram_primary + size: 0x40000 diff --git a/samples/sid_end_device/configuration/thingy53_nrf5340_cpuapp/pm_static_dfu.yml b/samples/sid_end_device/pm_static_thingy53_nrf5340_cpuapp.yml similarity index 100% rename from samples/sid_end_device/configuration/thingy53_nrf5340_cpuapp/pm_static_dfu.yml rename to samples/sid_end_device/pm_static_thingy53_nrf5340_cpuapp.yml diff --git a/samples/sid_end_device/prj_no_dfu.conf b/samples/sid_end_device/prj_no_dfu.conf deleted file mode 100644 index 3f14d8c..0000000 --- a/samples/sid_end_device/prj_no_dfu.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 2023 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Sidewalk -CONFIG_SIDEWALK=y -CONFIG_SIDEWALK_DFU=n -CONFIG_SMF=y - -# Log -CONFIG_LOG=y -CONFIG_LOG_PRINTK=y -CONFIG_LOG_BUFFER_SIZE=2048 -CONFIG_NVS_LOG_LEVEL_WRN=y - -# Bluetooth -CONFIG_BT_DEVICE_NAME="Nordic" - -# Debug -CONFIG_RESET_ON_FATAL_ERROR=n diff --git a/samples/sid_end_device/sample.yaml b/samples/sid_end_device/sample.yaml index a61c19d..e4635fc 100644 --- a/samples/sid_end_device/sample.yaml +++ b/samples/sid_end_device/sample.yaml @@ -1,96 +1,62 @@ sample: name: Sidewalk end device sample description: Sample implementing Amazon Sidewalk End Device +common: + sysbuild: true + build_only: true + platform_allow: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf54l15pdk/nrf54l15/cpuapp + integration_platforms: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf54l15pdk/nrf54l15/cpuapp tests: sample.sidewalk.hello: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_configs: - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp + - CONFIG_SIDEWALK_FILE_TRANSFER=y tags: Sidewalk hello sample.sidewalk.hello.release: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: - CONF_FILE=prj_release.conf + FILE_SUFFIX=release extra_configs: - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp - tags: Sidewalk hello - - sample.sidewalk.hello.no_dfu: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp - extra_args: - CONF_FILE=prj_no_dfu.conf - extra_configs: - - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk hello sample.sidewalk.hello.ble_only: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_configs: - CONFIG_SIDEWALK_SUBGHZ_SUPPORT=n - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk hello BLE sample.sidewalk.hello.ble_only.release: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: - CONF_FILE=prj_release.conf + FILE_SUFFIX=release extra_configs: - CONFIG_SIDEWALK_SUBGHZ_SUPPORT=n - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk hello BLE sample.sidewalk.demo: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: OVERLAY_CONFIG="overlay-demo.conf" extra_configs: - CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk demo sample.sidewalk.demo.ble_only: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp thingy53_nrf5340_cpuapp + platform_allow: + - thingy53/nrf5340/cpuapp extra_args: OVERLAY_CONFIG="overlay-demo.conf" extra_configs: - CONFIG_SIDEWALK_SUBGHZ_SUPPORT=n integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp - - thingy53_nrf5340_cpuapp + - thingy53/nrf5340/cpuapp tags: Sidewalk demo BLE sample.sidewalk.dut: - build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp extra_args: OVERLAY_CONFIG="overlay-dut.conf" - extra_configs: - - CONFIG_SIDEWALK_FILE_TRANSFER=y - integration_platforms: - - nrf52840dk_nrf52840 - - nrf5340dk_nrf5340_cpuapp tags: Sidewalk cli diff --git a/samples/sid_end_device/src/cli/app.c b/samples/sid_end_device/src/cli/app.c index 0dad5c5..97eef5e 100644 --- a/samples/sid_end_device/src/cli/app.c +++ b/samples/sid_end_device/src/cli/app.c @@ -11,8 +11,7 @@ #include #include #include -#include -#include +#include #include LOG_MODULE_REGISTER(app, CONFIG_SIDEWALK_LOG_LEVEL); @@ -40,6 +39,13 @@ static void on_sidewalk_msg_sent(const struct sid_msg_desc *msg_desc, void *cont LOG_INF("Message send success"); printk(JSON_NEW_LINE(JSON_OBJ(JSON_NAME( "on_msg_sent", JSON_OBJ(JSON_VAL_sid_msg_desc("sid_msg_desc", msg_desc, 0)))))); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc *msg_desc, @@ -50,6 +56,13 @@ static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc "on_send_error", JSON_OBJ(JSON_LIST_2(JSON_VAL_sid_error_t("error", error), JSON_VAL_sid_msg_desc("sid_msg_desc", msg_desc, 0))))))); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_factory_reset(void *context) diff --git a/samples/sid_end_device/src/cli/app_dut.c b/samples/sid_end_device/src/cli/app_dut.c index fbbe28e..9788694 100644 --- a/samples/sid_end_device/src/cli/app_dut.c +++ b/samples/sid_end_device/src/cli/app_dut.c @@ -4,13 +4,14 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ +#include "sid_error.h" #include #include #include #include #include #include -#include +#include LOG_MODULE_REGISTER(sid_cli, CONFIG_SIDEWALK_LOG_LEVEL); @@ -76,7 +77,7 @@ static void dut_option_get(sidewalk_option_t *p_option, struct sid_handle *handl case SID_OPTION_GET_LINK_POLICY_AUTO_CONNECT_PARAMS: { struct sid_link_auto_connect_params params = { 0 }; memcpy(¶ms.link_type, p_option->data, sizeof(uint32_t)); - sid_error_t e = sid_option(handle, opt, ¶ms, sizeof(params)); + sid_error_t e = sid_option(handle, opt, (void *)¶ms, sizeof(params)); LOG_INF("sid_option returned %d; AC Policy, link %d, enable %d priority %d timeout %d", e, params.link_type, params.enable, params.priority, params.connection_attempt_timeout_seconds); @@ -123,6 +124,9 @@ void app_dut_event_process(sidewalk_ctx_event_t event, sidewalk_ctx_t *sid) sid->config.link_mask = dut_ctx_get_uint32(event.ctx); sid_error_t e = sid_init(&sid->config, &sid->handle); LOG_INF("sid_init returned %d", e); + if (e != SID_ERROR_NONE) { + return; + } #ifdef CONFIG_SIDEWALK_FILE_TRANSFER app_file_transfer_demo_init(sid->handle); #endif @@ -157,13 +161,13 @@ void app_dut_event_process(sidewalk_ctx_event_t event, sidewalk_ctx_t *sid) case DUT_EVENT_GET_MTU: { uint32_t link_mask = dut_ctx_get_uint32(event.ctx); size_t mtu = 0; - sid_error_t e = sid_get_mtu(sid->handle, link_mask, &mtu); + sid_error_t e = sid_get_mtu(sid->handle, (enum sid_link_type)link_mask, &mtu); LOG_INF("sid_get_mtu returned %d, MTU: %d", e, mtu); } break; case DUT_EVENT_GET_TIME: { uint32_t format = dut_ctx_get_uint32(event.ctx); struct sid_timespec curr_time = { 0 }; - sid_error_t e = sid_get_time(sid->handle, format, &curr_time); + sid_error_t e = sid_get_time(sid->handle, (enum sid_time_format)format, &curr_time); LOG_INF("sid_get_time returned %d, SEC: %d NSEC: %d", e, curr_time.tv_sec, curr_time.tv_nsec); } break; diff --git a/samples/sid_end_device/src/cli/app_shell.c b/samples/sid_end_device/src/cli/app_shell.c index 5cffbc1..728dd31 100644 --- a/samples/sid_end_device/src/cli/app_shell.c +++ b/samples/sid_end_device/src/cli/app_shell.c @@ -227,7 +227,7 @@ static int cmd_sid_option(cli_event_t event, enum sid_option option, void *data, p_opt->data = NULL; } - int err = sidewalk_event_send(event, p_opt); + int err = sidewalk_event_send((sidewalk_event_t)event, p_opt); if (err) { if (p_opt->data) { sid_hal_free(p_opt->data); @@ -262,7 +262,7 @@ static int cmd_sid_simple_param(cli_event_t event, uint32_t *data) } memcpy(event_ctx, data, sizeof(uint32_t)); - int err = sidewalk_event_send(event, event_ctx); + int err = sidewalk_event_send((sidewalk_event_t)event, event_ctx); if (err) { sid_hal_free(event_ctx); return -ENOMSG; @@ -282,10 +282,12 @@ int cmd_sid_init(const struct shell *shell, int32_t argc, const char **argv) uint32_t link_type = 0; if (!IN_RANGE(connection_type, CLI_CMD_OPT_LINK_BLE, CLI_CMD_OPT_LINK_ANY)) { + shell_error(shell, "invalid value"); return -EINVAL; } if (!cli_parse_link_mask_opt(connection_type, &link_type)) { + shell_error(shell, "invalid value"); return -EINVAL; } cli_cfg.send_link_type = link_type; @@ -297,7 +299,7 @@ int cmd_sid_deinit(const struct shell *shell, int32_t argc, const char **argv) { CHECK_ARGUMENT_COUNT(argc, CMD_SID_DEINIT_ARG_REQUIRED, CMD_SID_DEINIT_ARG_OPTIONAL); - return sidewalk_event_send(DUT_EVENT_DEINIT, NULL); + return sidewalk_event_send((sidewalk_event_t)DUT_EVENT_DEINIT, NULL); } int cmd_sid_start(const struct shell *shell, int32_t argc, const char **argv) @@ -309,6 +311,7 @@ int cmd_sid_start(const struct shell *shell, int32_t argc, const char **argv) link_type = cli_cfg.send_link_type; } else { if (!cli_parse_link_mask_opt(atoi(argv[1]), &link_type)) { + shell_error(shell, "invalid value"); return -EINVAL; } } @@ -325,6 +328,7 @@ int cmd_sid_stop(const struct shell *shell, int32_t argc, const char **argv) link_type = cli_cfg.send_link_type; } else { if (!cli_parse_link_mask_opt(atoi(argv[1]), &link_type)) { + shell_error(shell, "invalid value"); return -EINVAL; } } @@ -419,6 +423,7 @@ int cmd_sid_send(const struct shell *shell, int32_t argc, const char **argv) } if (!cli_parse_link_mask_opt(atoi(argv[opt]), &desc.link_type)) { + shell_error(shell, "invalid value"); return -EINVAL; } continue; @@ -497,7 +502,7 @@ int cmd_sid_send(const struct shell *shell, int32_t argc, const char **argv) memcpy(&send->msg, &msg, sizeof(struct sid_msg)); memcpy(&send->desc, &desc, sizeof(struct sid_msg_desc)); - int err = sidewalk_event_send(SID_EVENT_SEND_MSG, send); + int err = sidewalk_event_send((sidewalk_event_t)SID_EVENT_SEND_MSG, send); if (err) { sid_hal_free(send->msg.data); sid_hal_free(send); @@ -512,7 +517,7 @@ int cmd_sid_factory_reset(const struct shell *shell, int32_t argc, const char ** CHECK_ARGUMENT_COUNT(argc, CMD_SID_FACTORY_RESET_ARG_REQUIRED, CMD_SID_FACTORY_RESET_ARG_OPTIONAL); - int err = sidewalk_event_send(SID_EVENT_FACTORY_RESET, NULL); + int err = sidewalk_event_send((sidewalk_event_t)SID_EVENT_FACTORY_RESET, NULL); if (err) { shell_error(shell, "event err %d", err); } @@ -537,6 +542,7 @@ int cmd_sid_get_mtu(const struct shell *shell, int32_t argc, const char **argv) link_mask = SID_LINK_TYPE_3; break; default: + shell_error(shell, "invalid value"); return -EINVAL; } @@ -584,6 +590,7 @@ int cmd_sid_option_lp_set(const struct shell *shell, int32_t argc, const char ** data_raw = strtol(argv[1], &end, 0); if (end == argv[1]) { + shell_error(shell, "invalid value"); return -EINVAL; } if (!IN_RANGE(data_raw, 0, UINT8_MAX)) { @@ -885,7 +892,10 @@ int cmd_sid_option_gc(const struct shell *shell, int32_t argc, const char **argv } memset(p_link_mask, 0x0, sizeof(*p_link_mask)); - cli_parse_link_mask_opt((uint8_t)link_type, p_link_mask); + if (!cli_parse_link_mask_opt((uint8_t)link_type, p_link_mask)) { + shell_error(shell, "Can not parse link mask"); + return -EINVAL; + } int err = cmd_sid_option_get_input_data(SID_OPTION_GET_LINK_POLICY_AUTO_CONNECT_PARAMS, p_link_mask, sizeof(uint32_t)); @@ -901,7 +911,9 @@ int cmd_sid_last_status(const struct shell *shell, int32_t argc, const char **ar CHECK_ARGUMENT_COUNT(argc, CMD_SID_LAST_STATUS_ARG_REQUIRED, CMD_SID_LAST_STATUS_ARG_OPTIONAL); - sidewalk_event_send(DUT_EVENT_GET_STATUS, NULL); + if (0 != sidewalk_event_send((sidewalk_event_t)DUT_EVENT_GET_STATUS, NULL)) { + shell_error(shell, "Failed to send Event"); + } return 0; } @@ -919,6 +931,7 @@ int cmd_sid_conn_request(const struct shell *shell, int32_t argc, const char **a conn_req = 0U; break; default: + shell_error(shell, "invalid value"); return -EINVAL; } @@ -930,6 +943,7 @@ int cmd_sid_get_time(const struct shell *shell, int32_t argc, const char **argv) CHECK_ARGUMENT_COUNT(argc, CMD_SID_GET_TIME_ARG_REQUIRED, CMD_SID_GET_TIME_ARG_OPTIONAL); if (argv[1][0] != '0') { + shell_error(shell, "invalid value"); return -EINVAL; } uint32_t time_type = SID_GET_GPS_TIME; @@ -970,6 +984,7 @@ int cmd_sid_set_send_link(const struct shell *shell, int32_t argc, const char ** break; } default: { + shell_error(shell, "invalid value"); return -EINVAL; } } diff --git a/samples/sid_end_device/src/cli/sid_on_dev_cert_cli.c b/samples/sid_end_device/src/cli/sid_on_dev_cert_cli.c new file mode 100644 index 0000000..e6d1df5 --- /dev/null +++ b/samples/sid_end_device/src/cli/sid_on_dev_cert_cli.c @@ -0,0 +1,467 @@ +/* + * Copyright (c) 2022 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include +#include + +#include +#include + +#include + +LOG_MODULE_REGISTER(sid_dev_cert_shell, CONFIG_SIDEWALK_LOG_LEVEL); + +#ifdef SYNTAX_ERR +#undef SYNTAX_ERR +#endif +#define SYNTAX_ERR "Syntax err \r\n" + +#define CERT_INIT_H "Initialization of On-Device Certificate Generation library" +#define CERT_DEINIT_H "Deinitialization of On-Device Certificate Generation Library" +#define CERT_SMSN_H "Generate Sidewalk Manufacturing Serial Number (SMSN)" +#define CERT_CSR_H "Generate Certificate Signing Request (CSR)" +#define CERT_CHAIN_H "Write Sidewalk Certificate Chain" +#define CERT_CHAIN_START_H "Start writing of Sidewalk Certificate Chain" +#define CERT_CHAIN_WRITE_H "Write data fragment to Sidewalk Certificate Chain" +#define CERT_CHAIN_COMMIT_H "Commit previously writed Sidewalk Certificate Chain" +#define CERT_APPKEY_H "Write application server ED25519 public key" +#define CERT_APPKEY_START_H "Start writing of app server ED25519 public key" +#define CERT_APPKEY_WRITE_H "Write data fragment to app server ED25519 public key" +#define CERT_APPKEY_COMMIT_H "Commit previously writed app server ED25519 public key" +#define CERT_STORE_H "Verify and store Sidewalk certificates" + +#define CERT_INIT_CMD "cert init" +#define CERT_DEINIT_CMD "cert deinit" +#define CERT_SMSN_CMD "cert smsn []" +#define CERT_CSR_CMD "cert csr " +#define CERT_CHAIN_START_CMD "cert chain start " +#define CERT_CHAIN_WRITE_CMD "cert chain write " +#define CERT_CHAIN_COMMIT_CMD "cert chain commit" +#define CERT_APPKEY_START_CMD "cert app_key start" +#define CERT_APPKEY_WRITE_CMD "cert app_key write " +#define CERT_APPKEY_COMMIT_CMD "cert app_key commit" +#define CERT_STORE_CMD "cert store" + +#define CERT_MSG_OK "{CERT OK}" +#define CERT_MSG_ERROR "{CERT ERROR %d}" +#define CERT_MSG_BASE64 "{CERT <%s>}" +#define CERT_MSG_BASE64_MTU "{CERT BASE64_MTU=%d}" +#define CERT_ED25519_STR "ed25519" +#define CERT_P256R1_STR "p256r1" +#define CERT_DEV_TYPE_SUFFIX "-PRODUCTION" + +#define CERT_BASE64_FRAGMENT_MAX_SIZE 32 + +static uint8_t cert_app_key[SID_ODC_ED25519_PUK_SIZE]; +static uint8_t cert_chain_buffer[SID_ODC_SCC_MAX_SIZE]; +static struct sid_on_dev_cert_chain_params cert_chain_params = { + .cert_chain = NULL, + .cert_chain_size = 0, +}; + +// Persistent state for receiving the encoded certificate chain in multiple fragments +static struct sid_base64_ctx cert_chain_base64_ctx = { + .next_out = NULL, + .avail_out = 0, + .total_out = 0, + .state = 0, +}; + +static struct sid_base64_ctx cert_app_key_base64_ctx = { + .next_out = NULL, + .avail_out = 0, + .total_out = 0, + .state = 0, +}; + +static sid_error_t sid_on_dev_cert_cli_print_base64(const struct shell *shell, const uint8_t *input, + size_t input_size) +{ + struct sid_base64_ctx ctx; + sid_base64_init(&ctx); + uint8_t out[CERT_BASE64_FRAGMENT_MAX_SIZE + 1]; // allow extra byte for null terminator + + ctx.next_in = input; + ctx.avail_in = input_size; + ctx.next_out = out; + ctx.avail_out = CERT_BASE64_FRAGMENT_MAX_SIZE; + + while (true) { + sid_error_t status = sid_base64_encode(&ctx, true); + if (status == SID_ERROR_NONE || status == SID_ERROR_BUFFER_OVERFLOW) { + // add a null terminator + *ctx.next_out = '\0'; + + shell_info(shell, CERT_MSG_BASE64, out); + + if (status == SID_ERROR_NONE) { + break; + } + // Reset the output buffer for the next line + ctx.next_out = out; + ctx.avail_out = CERT_BASE64_FRAGMENT_MAX_SIZE; + } else { + return SID_ERROR_GENERIC; + } + } + return SID_ERROR_NONE; +} + +static int sid_on_dev_cert_cli_init_cmd(const struct shell *shell, int32_t argc, const char **argv) +{ + if (argc == 1) { + sid_error_t ret = sid_on_dev_cert_init(); + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_BASE64_MTU, CERT_BASE64_FRAGMENT_MAX_SIZE); + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_INIT_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_deinit(const struct shell *shell, int32_t argc, const char **argv) +{ + if (argc == 1) { + sid_on_dev_cert_deinit(); + + shell_info(shell, CERT_MSG_OK); + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_DEINIT_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_smsn(const struct shell *shell, int32_t argc, const char **argv) +{ + // command format: cert smsn [] + if (argc >= 4 && argc <= 5) { + sid_error_t ret = SID_ERROR_NONE; + // Note on device-type. It gets transformed into "Amazon-id" which is -PRODUCTION + char *dev_type_production = + sid_hal_malloc(strlen(argv[1]) + strlen(CERT_DEV_TYPE_SUFFIX) + 1); + if (!dev_type_production) { + ret = SID_ERROR_OOM; + goto exit; + } + dev_type_production[0] = 0; + strcat(dev_type_production, argv[1]); + strcat(dev_type_production, CERT_DEV_TYPE_SUFFIX); + + const struct sid_on_dev_cert_info dev_info = { + .dev_type = dev_type_production, + .dsn = argv[2], + .apid = argv[3], + .board_id = argc == 5 ? argv[4] : NULL, + }; + + uint8_t smsn[SID_ODC_SMSN_SIZE]; + memset(smsn, 0xFF, SID_ODC_SMSN_SIZE); + if ((ret = sid_on_dev_cert_generate_smsn(&dev_info, smsn)) == SID_ERROR_NONE) { + ret = sid_on_dev_cert_cli_print_base64(shell, smsn, SID_ODC_SMSN_SIZE); + } + + sid_hal_free(dev_type_production); + exit: + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_SMSN_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_csr(const struct shell *shell, int32_t argc, const char **argv) +{ + if (argc == 2) { + sid_error_t ret = SID_ERROR_NONE; + uint8_t csr[SID_ODC_CSR_MAX_SIZE]; + size_t csr_size = SID_ODC_CSR_MAX_SIZE; + enum sid_on_dev_cert_algo_type algo; + + if (strcmp(argv[1], CERT_ED25519_STR) == 0) { + algo = SID_ODC_CRYPT_ALGO_ED25519; + } else if (strcmp(argv[1], CERT_P256R1_STR) == 0) { + algo = SID_ODC_CRYPT_ALGO_P256R1; + } else { + ret = SID_ERROR_INVALID_ARGS; + } + + if (ret == SID_ERROR_NONE && + (ret = sid_on_dev_cert_generate_csr(algo, csr, &csr_size)) == SID_ERROR_NONE && + (ret = sid_on_dev_cert_cli_print_base64(shell, csr, csr_size)) == + SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_CSR_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_chain_start(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 2) { + sid_error_t ret = SID_ERROR_NONE; + enum sid_on_dev_cert_algo_type algo; + + if (strcmp(argv[1], CERT_ED25519_STR) == 0) { + algo = SID_ODC_CRYPT_ALGO_ED25519; + } else if (strcmp(argv[1], CERT_P256R1_STR) == 0) { + algo = SID_ODC_CRYPT_ALGO_P256R1; + } else { + ret = SID_ERROR_INVALID_ARGS; + } + if (ret == SID_ERROR_NONE) { + sid_base64_init(&cert_chain_base64_ctx); + cert_chain_base64_ctx.next_out = cert_chain_buffer; + cert_chain_base64_ctx.avail_out = (algo == SID_ODC_CRYPT_ALGO_ED25519) ? + SID_ODC_ED25519_SCC_MAX_SIZE : + SID_ODC_P256R1_SCC_MAX_SIZE; + cert_chain_params.algo = algo; + cert_chain_params.cert_chain = cert_chain_buffer; + cert_chain_params.cert_chain_size = 0; + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_CHAIN_START_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_chain_write(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 2) { + sid_error_t ret = SID_ERROR_NONE; + size_t base64_fragment_len = strlen(argv[1]); + + if (base64_fragment_len >= 1 && + base64_fragment_len <= CERT_BASE64_FRAGMENT_MAX_SIZE) { + if (cert_chain_params.cert_chain) { + cert_chain_base64_ctx.next_in = (const uint8_t *)argv[1]; + cert_chain_base64_ctx.avail_in = base64_fragment_len; + ret = sid_base64_decode(&cert_chain_base64_ctx); + /* + * If we have a successful result, we should check: + * - the input buffer should be empty + * - if the output buffer is empty and there are 8 bits or more of temporary data, it is an error + */ + if (ret != SID_ERROR_NONE || cert_chain_base64_ctx.avail_in != 0 || + (cert_chain_base64_ctx.avail_out == 0 && + cert_chain_base64_ctx.temp_len >= 8)) { + // Clear chain pointer. This makes chain uninitialized. + cert_chain_params.cert_chain = NULL; + // Reset base64 context + sid_base64_init(&cert_chain_base64_ctx); + ret = SID_ERROR_INVALID_ARGS; + } + } else { + ret = SID_ERROR_UNINITIALIZED; + } + } else { + ret = SID_ERROR_PARAM_OUT_OF_RANGE; + } + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_CHAIN_WRITE_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_chain_commit(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 1) { + sid_error_t ret = SID_ERROR_NONE; + if (cert_chain_params.cert_chain) { + cert_chain_params.cert_chain_size = cert_chain_base64_ctx.total_out; + ret = sid_on_dev_cert_write_cert_chain(&cert_chain_params); + // Clear chain pointer. This makes chain uninitialized. + cert_chain_params.cert_chain = NULL; + // Reset base64 context + sid_base64_init(&cert_chain_base64_ctx); + } else { + ret = SID_ERROR_UNINITIALIZED; + } + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_CHAIN_COMMIT_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_app_key_start(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 1) { + sid_base64_init(&cert_app_key_base64_ctx); + cert_app_key_base64_ctx.next_out = cert_app_key; + cert_app_key_base64_ctx.avail_out = SID_ODC_ED25519_PUK_SIZE; + shell_info(shell, CERT_MSG_OK); + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_APPKEY_START_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_app_key_write(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 2) { + sid_error_t ret = SID_ERROR_NONE; + size_t base64_fragment_len = strlen(argv[1]); + + if (base64_fragment_len >= 1 && + base64_fragment_len <= CERT_BASE64_FRAGMENT_MAX_SIZE) { + if (cert_app_key_base64_ctx.next_out) { + cert_app_key_base64_ctx.next_in = (const uint8_t *)argv[1]; + cert_app_key_base64_ctx.avail_in = base64_fragment_len; + + ret = sid_base64_decode(&cert_app_key_base64_ctx); + /* + * If we have a successful result, we should check: + * - the input buffer should be empty + * - if the output buffer is empty and there are 8 bits or more of temporary data, it is an error + */ + if (ret != SID_ERROR_NONE || + cert_app_key_base64_ctx.avail_in != 0 || + (cert_app_key_base64_ctx.avail_out == 0 && + cert_app_key_base64_ctx.temp_len >= 8)) { + // Reset base64 context + sid_base64_init(&cert_app_key_base64_ctx); + ret = SID_ERROR_INVALID_ARGS; + } + } else { + ret = SID_ERROR_UNINITIALIZED; + } + } else { + ret = SID_ERROR_PARAM_OUT_OF_RANGE; + } + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_APPKEY_WRITE_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_app_key_commit(const struct shell *shell, int32_t argc, + const char **argv) +{ + if (argc == 1) { + sid_error_t ret = SID_ERROR_NONE; + + if (cert_app_key_base64_ctx.total_out == SID_ODC_ED25519_PUK_SIZE && + cert_app_key_base64_ctx.avail_out == 0) { + ret = sid_on_dev_cert_write_app_server_key((uint8_t *)cert_app_key); + } else { + ret = SID_ERROR_UNINITIALIZED; + } + // Reset base64 context + sid_base64_init(&cert_app_key_base64_ctx); + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_APPKEY_COMMIT_CMD); + } + return 0; +} + +static int sid_on_dev_cert_cli_store(const struct shell *shell, int32_t argc, const char **argv) +{ + if (argc == 1) { + sid_error_t ret = sid_on_dev_cert_verify_and_store(); + + if (ret == SID_ERROR_NONE) { + shell_info(shell, CERT_MSG_OK); + } else { + shell_info(shell, CERT_MSG_ERROR, ret); + } + + } else { + shell_error(shell, SYNTAX_ERR); + shell_warn(shell, CERT_STORE_CMD); + } + return 0; +} + +SHELL_STATIC_SUBCMD_SET_CREATE( + sub_chain, + SHELL_CMD_ARG(start, NULL, CERT_CHAIN_START_H, sid_on_dev_cert_cli_chain_start, 2, 0), + SHELL_CMD_ARG(write, NULL, CERT_CHAIN_WRITE_H, sid_on_dev_cert_cli_chain_write, 2, 0), + SHELL_CMD_ARG(commit, NULL, CERT_APPKEY_COMMIT_H, sid_on_dev_cert_cli_chain_commit, 1, 0), + SHELL_SUBCMD_SET_END); + +SHELL_STATIC_SUBCMD_SET_CREATE( + sub_app_key, + SHELL_CMD_ARG(start, NULL, CERT_APPKEY_START_H, sid_on_dev_cert_cli_app_key_start, 1, 0), + SHELL_CMD_ARG(write, NULL, CERT_APPKEY_WRITE_H, sid_on_dev_cert_cli_app_key_write, 2, 0), + SHELL_CMD_ARG(commit, NULL, CERT_APPKEY_COMMIT_H, sid_on_dev_cert_cli_app_key_commit, 1, 0), + SHELL_SUBCMD_SET_END); + +SHELL_STATIC_SUBCMD_SET_CREATE( + sub_services, SHELL_CMD_ARG(init, NULL, CERT_INIT_H, sid_on_dev_cert_cli_init_cmd, 1, 0), + SHELL_CMD_ARG(deinit, NULL, CERT_DEINIT_H, sid_on_dev_cert_cli_deinit, 1, 0), + SHELL_CMD_ARG(smsn, NULL, CERT_SMSN_H, sid_on_dev_cert_cli_smsn, 4, 1), + SHELL_CMD_ARG(csr, NULL, CERT_CSR_H, sid_on_dev_cert_cli_csr, 2, 0), + SHELL_CMD_ARG(chain, &sub_chain, CERT_CHAIN_H, NULL, 1, 0), + SHELL_CMD_ARG(app_key, &sub_app_key, CERT_APPKEY_H, NULL, 1, 0), + SHELL_CMD_ARG(store, NULL, CERT_STORE_H, sid_on_dev_cert_cli_store, 1, 0), + SHELL_SUBCMD_SET_END); + +// command, subcommands, help, handler +SHELL_CMD_REGISTER(cert, &sub_services, "sidewalk testing CLI", NULL); diff --git a/samples/sid_end_device/src/file_transfer.c b/samples/sid_end_device/src/file_transfer.c deleted file mode 100644 index c4b2178..0000000 --- a/samples/sid_end_device/src/file_transfer.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2023 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -LOG_MODULE_REGISTER(file_transfer, CONFIG_SIDEWALK_LOG_LEVEL); - -#define PARALEL_TRANSFER_MAX 3 - -struct buffer_repo_element { - uint32_t file_id; - void *memory_slab_for_transfer; -}; - -static struct buffer_repo_element buffer_repo[PARALEL_TRANSFER_MAX]; - -static void on_transfer_request(const struct sid_bulk_data_transfer_request *const transfer_request, - struct sid_bulk_data_transfer_response *const transfer_response, - void *context) -{ - printk(JSON_NEW_LINE(JSON_OBJ( - JSON_NAME("on_transfer_request", JSON_OBJ(JSON_VAL_sid_bulk_data_transfer_request( - "transfer_request", transfer_request)))))); - LOG_HEXDUMP_INF(transfer_request->file_descriptor, transfer_request->file_descriptor_size, - "file_descriptor"); - size_t repo_index = UINT_MAX; - for (size_t i = 0; i < PARALEL_TRANSFER_MAX; i++) { - if (buffer_repo[i].memory_slab_for_transfer == NULL) { - repo_index = i; - break; - } - } - if (repo_index > PARALEL_TRANSFER_MAX) { - LOG_ERR("Failed to find slot for transfer"); - transfer_response->status = SID_BULK_DATA_TRANSFER_ACTION_REJECT; - transfer_response->reject_reason = SID_BULK_DATA_TRANSFER_REJECT_REASON_GENERIC; - return; - } - void *ptr = sid_hal_malloc(transfer_request->minimum_scratch_buffer_size); - if (ptr == NULL) { - LOG_ERR("Failed to alloc memory"); - transfer_response->status = SID_BULK_DATA_TRANSFER_ACTION_REJECT; - transfer_response->reject_reason = SID_BULK_DATA_TRANSFER_REJECT_REASON_NO_SPACE; - return; - } - memset(ptr, 0x0, sizeof(transfer_request->minimum_scratch_buffer_size)); - - // accept all requests if only we have avaliable memory for scratch buffer - buffer_repo[repo_index].memory_slab_for_transfer = ptr; - buffer_repo[repo_index].file_id = transfer_request->file_id; - transfer_response->status = SID_BULK_DATA_TRANSFER_ACTION_ACCEPT; - transfer_response->reject_reason = SID_BULK_DATA_TRANSFER_REJECT_REASON_NONE; - transfer_response->scratch_buffer = ptr; - transfer_response->scratch_buffer_size = transfer_request->minimum_scratch_buffer_size; -} - -static void on_data_received(const struct sid_bulk_data_transfer_desc *const desc, - const struct sid_bulk_data_transfer_buffer *const buffer, - void *context) -{ - printk(JSON_NEW_LINE(JSON_OBJ( - JSON_LIST_2(JSON_NAME("on_data_received", - JSON_OBJ(JSON_VAL_sid_bulk_data_transfer_desc("desc", desc))), - JSON_NAME("data_size", JSON_INT(buffer->size)))))); - - struct data_received_args *args = - (struct data_received_args *)sid_hal_malloc(sizeof(struct data_received_args)); - if (!args) { - LOG_ERR("Failed to allocate memory for received data descriptor"); - return; - } - memset(args, 0x0, sizeof(*args)); - args->desc = *desc; - args->buffer = (struct sid_bulk_data_transfer_buffer *)buffer; - args->context = context; - int err = sidewalk_event_send(SID_EVENT_FILE_TRANSFER, args); - if (err) { - sid_hal_free(args); - } -} - -static void on_finalize_request(uint32_t file_id, void *context) -{ - printk(JSON_NEW_LINE(JSON_OBJ(JSON_NAME( - "on_finalize_request", JSON_OBJ(JSON_NAME("file_id", JSON_INT(file_id))))))); - - // Illustrative API indicating verification of file - // validate received file - - // always report success - sid_error_t ret = sid_bulk_data_transfer_finalize( - (struct sid_handle *)context, file_id, SID_BULK_DATA_TRANSFER_FINAL_STATUS_SUCCESS); - if (ret != SID_ERROR_NONE) { - LOG_ERR("sid_bulk_data_transfer_finalize returned %s", SID_ERROR_T_STR(ret)); - } -} - -static void on_cancel_request(uint32_t file_id, void *context) -{ - printk(JSON_NEW_LINE(JSON_OBJ(JSON_NAME( - "on_cancel_request", JSON_OBJ(JSON_NAME("file_id", JSON_INT(file_id))))))); -} - -static void on_error(uint32_t file_id, void *context) -{ - printk(JSON_NEW_LINE(JSON_OBJ( - JSON_NAME("on_error", JSON_OBJ(JSON_NAME("file_id", JSON_INT(file_id))))))); -} - -static void on_release_scratch_buffer(uint32_t file_id, void *context) -{ - printk(JSON_NEW_LINE(JSON_OBJ(JSON_NAME( - "on_release_scratch_buffer", JSON_OBJ(JSON_NAME("file_id", JSON_INT(file_id))))))); - - for (size_t i = 0; i < PARALEL_TRANSFER_MAX; i++) { - if (buffer_repo[i].file_id == file_id) { - sid_hal_free(buffer_repo[i].memory_slab_for_transfer); - - buffer_repo[i].memory_slab_for_transfer = NULL; - buffer_repo[i].file_id = UINT32_MAX; - return; - } - } - LOG_ERR("failed to find file_id to be freed"); -} - -static struct sid_bulk_data_transfer_event_callbacks ft_callbacks = { - .context = NULL, - .on_transfer_request = on_transfer_request, - .on_data_received = on_data_received, - .on_finalize_request = on_finalize_request, - .on_cancel_request = on_cancel_request, - .on_error = on_error, - .on_release_scratch_buffer = on_release_scratch_buffer -}; - -void app_file_transfer_demo_init(struct sid_handle *handle) -{ - ft_callbacks.context = (void *)handle; - - sid_error_t err = sid_bulk_data_transfer_init( - &(struct sid_bulk_data_transfer_config){ .callbacks = &ft_callbacks }, handle); - if (err != SID_ERROR_NONE) { - LOG_ERR("sid_bulk_data_transfer_init returned %s", SID_ERROR_T_STR(err)); - } -} - -void app_file_transfer_demo_deinit(struct sid_handle *handle) -{ - sid_error_t err = sid_bulk_data_transfer_deinit(handle); - if (err != SID_ERROR_NONE) { - LOG_ERR("sid_bulk_data_transfer_deinit returned %s", SID_ERROR_T_STR(err)); - } -} diff --git a/samples/sid_end_device/src/hello/app.c b/samples/sid_end_device/src/hello/app.c index 6cac668..e5f4d0b 100644 --- a/samples/sid_end_device/src/hello/app.c +++ b/samples/sid_end_device/src/hello/app.c @@ -11,18 +11,17 @@ #include #include #if defined(CONFIG_GPIO) -#include +#include #endif #if defined(CONFIG_LOG) -#include +#include #endif #include #include #include #include -#include -#include +#include #ifdef CONFIG_RADIO_LR11XX #include // radio_dbg pin #endif /* CONFIG_RADIO_LR11XX */ @@ -38,7 +37,6 @@ halo_drv_semtech_ctx_t *radio_ctx; static void on_sidewalk_event(bool in_isr, void *context) { int err = sidewalk_event_send(SID_EVENT_SIDEWALK, NULL); - //sid_pal_gpio_toggle(radio_ctx->config->gpios.led_sniff); if (err) { LOG_ERR("Send event err %d", err); }; @@ -98,6 +96,13 @@ static void on_sidewalk_msg_sent(const struct sid_msg_desc *msg_desc, void *cont "on_msg_sent", JSON_OBJ(JSON_VAL_sid_msg_desc("sid_msg_desc", msg_desc, 0)))))); application_state_sending(&global_state_notifier, false); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc *msg_desc, @@ -110,6 +115,14 @@ static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc JSON_VAL_sid_msg_desc("sid_msg_desc", msg_desc, 0))))))); application_state_sending(&global_state_notifier, false); + + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_factory_reset(void *context) @@ -135,7 +148,7 @@ static void on_sidewalk_status_changed(const struct sid_status *status, void *co } else { memcpy(new_status, status, sizeof(struct sid_status)); } - sidewalk_event_send(SID_EVENT_NEW_STATUS, new_status); + err = sidewalk_event_send(SID_EVENT_NEW_STATUS, new_status); switch (status->state) { case SID_STATE_READY: diff --git a/samples/sid_end_device/src/main.c b/samples/sid_end_device/src/main.c index e050000..e7a910a 100644 --- a/samples/sid_end_device/src/main.c +++ b/samples/sid_end_device/src/main.c @@ -8,9 +8,6 @@ #include #include -#include -LOG_MODULE_REGISTER(main, CONFIG_SIDEWALK_LOG_LEVEL); - int main(void) { PRINT_SIDEWALK_VERSION(); diff --git a/samples/lbm_sid_end_device/src/file_transfer.c b/samples/sid_end_device/src/sbdt/file_transfer.c similarity index 59% rename from samples/lbm_sid_end_device/src/file_transfer.c rename to samples/sid_end_device/src/sbdt/file_transfer.c index c4b2178..db3d42e 100644 --- a/samples/lbm_sid_end_device/src/file_transfer.c +++ b/samples/sid_end_device/src/sbdt/file_transfer.c @@ -4,30 +4,22 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ -#include -#include -#include +#include +#include +#include #include -#include +#include +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU +#include +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ +#include #include +#include #include -#include -#include - -#include LOG_MODULE_REGISTER(file_transfer, CONFIG_SIDEWALK_LOG_LEVEL); -#define PARALEL_TRANSFER_MAX 3 - -struct buffer_repo_element { - uint32_t file_id; - void *memory_slab_for_transfer; -}; - -static struct buffer_repo_element buffer_repo[PARALEL_TRANSFER_MAX]; - static void on_transfer_request(const struct sid_bulk_data_transfer_request *const transfer_request, struct sid_bulk_data_transfer_response *const transfer_response, void *context) @@ -37,34 +29,30 @@ static void on_transfer_request(const struct sid_bulk_data_transfer_request *con "transfer_request", transfer_request)))))); LOG_HEXDUMP_INF(transfer_request->file_descriptor, transfer_request->file_descriptor_size, "file_descriptor"); - size_t repo_index = UINT_MAX; - for (size_t i = 0; i < PARALEL_TRANSFER_MAX; i++) { - if (buffer_repo[i].memory_slab_for_transfer == NULL) { - repo_index = i; - break; - } - } - if (repo_index > PARALEL_TRANSFER_MAX) { - LOG_ERR("Failed to find slot for transfer"); + +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU + int dfu_err = nordic_dfu_img_init(); + if (dfu_err) { + LOG_ERR("dfu img init fail %d", dfu_err); transfer_response->status = SID_BULK_DATA_TRANSFER_ACTION_REJECT; transfer_response->reject_reason = SID_BULK_DATA_TRANSFER_REJECT_REASON_GENERIC; + transfer_response->scratch_buffer_size = 0; return; } - void *ptr = sid_hal_malloc(transfer_request->minimum_scratch_buffer_size); - if (ptr == NULL) { - LOG_ERR("Failed to alloc memory"); +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ + + transfer_response->scratch_buffer = scratch_buffer_create( + transfer_request->file_id, transfer_request->minimum_scratch_buffer_size); + + if (!transfer_response->scratch_buffer) { transfer_response->status = SID_BULK_DATA_TRANSFER_ACTION_REJECT; transfer_response->reject_reason = SID_BULK_DATA_TRANSFER_REJECT_REASON_NO_SPACE; + transfer_response->scratch_buffer_size = 0; return; } - memset(ptr, 0x0, sizeof(transfer_request->minimum_scratch_buffer_size)); - // accept all requests if only we have avaliable memory for scratch buffer - buffer_repo[repo_index].memory_slab_for_transfer = ptr; - buffer_repo[repo_index].file_id = transfer_request->file_id; transfer_response->status = SID_BULK_DATA_TRANSFER_ACTION_ACCEPT; transfer_response->reject_reason = SID_BULK_DATA_TRANSFER_REJECT_REASON_NONE; - transfer_response->scratch_buffer = ptr; transfer_response->scratch_buffer_size = transfer_request->minimum_scratch_buffer_size; } @@ -77,19 +65,35 @@ static void on_data_received(const struct sid_bulk_data_transfer_desc *const des JSON_OBJ(JSON_VAL_sid_bulk_data_transfer_desc("desc", desc))), JSON_NAME("data_size", JSON_INT(buffer->size)))))); - struct data_received_args *args = - (struct data_received_args *)sid_hal_malloc(sizeof(struct data_received_args)); - if (!args) { - LOG_ERR("Failed to allocate memory for received data descriptor"); + sidewalk_transfer_t *transfer = + (sidewalk_transfer_t *)sid_hal_malloc(sizeof(sidewalk_transfer_t)); + if (!transfer) { + LOG_ERR("Fail transfer alloc"); return; } - memset(args, 0x0, sizeof(*args)); - args->desc = *desc; - args->buffer = (struct sid_bulk_data_transfer_buffer *)buffer; - args->context = context; - int err = sidewalk_event_send(SID_EVENT_FILE_TRANSFER, args); + transfer->file_id = desc->file_id; + transfer->file_offset = desc->file_offset; + transfer->data = buffer->data; + transfer->data_size = buffer->size; + + int err = sidewalk_event_send(SID_EVENT_FILE_TRANSFER, transfer); if (err) { - sid_hal_free(args); + LOG_ERR("Event transfer err %d", err); + LOG_INF("Cancelig file transfer"); +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU + err = nordic_dfu_img_cancel(); + if (err) { + LOG_ERR("Fail to complete dfu %d", err); + } +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ + sid_error_t ret = + sid_bulk_data_transfer_cancel((struct sid_handle *)context, + transfer->file_id, + SID_BULK_DATA_TRANSFER_REJECT_REASON_GENERIC); + if (ret != SID_ERROR_NONE) { + LOG_ERR("Fail to cancel sbdt %d", ret); + } + sid_hal_free(transfer); } } @@ -98,27 +102,52 @@ static void on_finalize_request(uint32_t file_id, void *context) printk(JSON_NEW_LINE(JSON_OBJ(JSON_NAME( "on_finalize_request", JSON_OBJ(JSON_NAME("file_id", JSON_INT(file_id))))))); - // Illustrative API indicating verification of file - // validate received file - - // always report success + // report transfer success sid_error_t ret = sid_bulk_data_transfer_finalize( (struct sid_handle *)context, file_id, SID_BULK_DATA_TRANSFER_FINAL_STATUS_SUCCESS); if (ret != SID_ERROR_NONE) { LOG_ERR("sid_bulk_data_transfer_finalize returned %s", SID_ERROR_T_STR(ret)); } + +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU + // request upgrade and reboot + int err = 0; + err = nordic_dfu_img_finalize(); + if (err) { + LOG_ERR("dfu image finalize fail %d", err); + } + + err = sidewalk_event_send(SID_EVENT_REBOOT, NULL); + if (err) { + LOG_ERR("reboot event send ret %d", err); + } +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ } static void on_cancel_request(uint32_t file_id, void *context) { printk(JSON_NEW_LINE(JSON_OBJ(JSON_NAME( "on_cancel_request", JSON_OBJ(JSON_NAME("file_id", JSON_INT(file_id))))))); + +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU + int err = nordic_dfu_img_cancel(); + if (err) { + LOG_ERR("Fail to complete dfu %d", err); + } +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ } static void on_error(uint32_t file_id, void *context) { printk(JSON_NEW_LINE(JSON_OBJ( JSON_NAME("on_error", JSON_OBJ(JSON_NAME("file_id", JSON_INT(file_id))))))); + +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU + int err = nordic_dfu_img_cancel(); + if (err) { + LOG_ERR("Fail to complete dfu %d", err); + } +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ } static void on_release_scratch_buffer(uint32_t file_id, void *context) @@ -126,16 +155,7 @@ static void on_release_scratch_buffer(uint32_t file_id, void *context) printk(JSON_NEW_LINE(JSON_OBJ(JSON_NAME( "on_release_scratch_buffer", JSON_OBJ(JSON_NAME("file_id", JSON_INT(file_id))))))); - for (size_t i = 0; i < PARALEL_TRANSFER_MAX; i++) { - if (buffer_repo[i].file_id == file_id) { - sid_hal_free(buffer_repo[i].memory_slab_for_transfer); - - buffer_repo[i].memory_slab_for_transfer = NULL; - buffer_repo[i].file_id = UINT32_MAX; - return; - } - } - LOG_ERR("failed to find file_id to be freed"); + scratch_buffer_remove(file_id); } static struct sid_bulk_data_transfer_event_callbacks ft_callbacks = { @@ -150,12 +170,13 @@ static struct sid_bulk_data_transfer_event_callbacks ft_callbacks = { void app_file_transfer_demo_init(struct sid_handle *handle) { - ft_callbacks.context = (void *)handle; + scratch_buffer_init(); - sid_error_t err = sid_bulk_data_transfer_init( + ft_callbacks.context = (void *)handle; + sid_error_t ret = sid_bulk_data_transfer_init( &(struct sid_bulk_data_transfer_config){ .callbacks = &ft_callbacks }, handle); - if (err != SID_ERROR_NONE) { - LOG_ERR("sid_bulk_data_transfer_init returned %s", SID_ERROR_T_STR(err)); + if (ret != SID_ERROR_NONE) { + LOG_ERR("sid_bulk_data_transfer_init returned %s", SID_ERROR_T_STR(ret)); } } diff --git a/samples/sid_end_device/src/sbdt/scratch_buffer.c b/samples/sid_end_device/src/sbdt/scratch_buffer.c new file mode 100644 index 0000000..4a61ce8 --- /dev/null +++ b/samples/sid_end_device/src/sbdt/scratch_buffer.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include +#include +#include + +LOG_MODULE_REGISTER(scratch_buffer); + +#define SCRATCH_FILE_ID_UNUSED UINT32_MAX +#define SCRATCH_BUFFERS_MAX (3) + +typedef struct { + uint32_t id; + void *buffer; +} file_ctx_t; + +static file_ctx_t files[SCRATCH_BUFFERS_MAX]; + +void scratch_buffer_init(void) +{ + for (uint8_t i = 0; i < SCRATCH_BUFFERS_MAX; i++) { + files[i].id = SCRATCH_FILE_ID_UNUSED; + } +} + +void *scratch_buffer_create(uint32_t file_id, size_t size) +{ + file_ctx_t *p_file = NULL; + for (uint8_t i = 0; i < SCRATCH_BUFFERS_MAX; i++) { + if (!p_file && files[i].id == SCRATCH_FILE_ID_UNUSED) { + p_file = &files[i]; + } + if(files[i].id == file_id){ + LOG_ERR("buffer already assigned to file (id %d)", file_id); + return NULL; + } + } + + if (!p_file) { + LOG_ERR("too many buffers (max %d)", SCRATCH_BUFFERS_MAX); + return NULL; + } + + p_file->id = file_id; + + p_file->buffer = sid_hal_malloc(size); + if (!p_file->buffer) { + LOG_ERR("buffor alloc fail (size %d)", size); + return NULL; + } + + memset(p_file->buffer, 0x0, size); + + return p_file->buffer; +} + +void scratch_buffer_remove(uint32_t file_id) +{ + file_ctx_t *p_file = NULL; + for (uint8_t i = 0; i < SCRATCH_BUFFERS_MAX; i++) { + if (files[i].id == file_id) { + p_file = &files[i]; + break; + } + } + + if (!p_file) { + LOG_ERR("buffer not found for file (id %d)", file_id); + return; + } + + p_file->id = SCRATCH_FILE_ID_UNUSED; + if (p_file->buffer) { + sid_hal_free(p_file->buffer); + p_file->buffer = NULL; + } +} diff --git a/samples/sid_end_device/src/sensor_monitoring/app.c b/samples/sid_end_device/src/sensor_monitoring/app.c index 5817426..6a43a1d 100644 --- a/samples/sid_end_device/src/sensor_monitoring/app.c +++ b/samples/sid_end_device/src/sensor_monitoring/app.c @@ -71,6 +71,13 @@ static void on_sidewalk_msg_received(const struct sid_msg_desc *msg_desc, const static void on_sidewalk_msg_sent(const struct sid_msg_desc *msg_desc, void *context) { LOG_DBG("sent message(type: %d, id: %u)", (int)msg_desc->type, msg_desc->id); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc *msg_desc, @@ -78,6 +85,13 @@ static void on_sidewalk_send_error(sid_error_t error, const struct sid_msg_desc { LOG_ERR("Send message err %d", (int)error); LOG_DBG("Failed to send message(type: %d, id: %u)", (int)msg_desc->type, msg_desc->id); + sidewalk_msg_t *message = get_message_buffer(msg_desc->id); + if (message == NULL) { + LOG_ERR("failed to find message buffer to clean"); + return; + } + sid_hal_free(message->msg.data); + sid_hal_free(message); } static void on_sidewalk_factory_reset(void *context) @@ -151,10 +165,23 @@ static void on_sidewalk_status_changed(const struct sid_status *status, void *co static void sidewalk_btn_handler(uint32_t event) { - int err = sidewalk_event_send((app_event_t)event, NULL); + int err = sidewalk_event_send((sidewalk_event_t)event, NULL); if (err) { LOG_ERR("Send event err %d", err); + return; }; + + if (SID_EVENT_NORDIC_DFU == event) { + static bool in_dfu; + if (in_dfu) { + in_dfu = false; + k_timer_start(¬ify_timer, K_MSEC(NOTIFY_TIMER_DURATION_MS), + K_MSEC(CONFIG_SID_END_DEVICE_NOTIFY_DATA_PERIOD_MS)); + } else { + in_dfu = true; + k_timer_stop(¬ify_timer); + } + } } static int app_buttons_init(void) diff --git a/samples/sid_end_device/src/sensor_monitoring/app_tx.c b/samples/sid_end_device/src/sensor_monitoring/app_tx.c index f1ee8f2..6773184 100644 --- a/samples/sid_end_device/src/sensor_monitoring/app_tx.c +++ b/samples/sid_end_device/src/sensor_monitoring/app_tx.c @@ -46,9 +46,10 @@ static void state_notify_data(void *o); static void button_timer_cb(struct k_timer *timer_id); static const struct smf_state app_states[] = { - [STATE_APP_INIT] = SMF_CREATE_STATE(NULL, state_init, NULL), - [STATE_APP_NOTIFY_CAPABILITY] = SMF_CREATE_STATE(NULL, state_notify_capability, NULL), - [STATE_APP_NOTIFY_DATA] = SMF_CREATE_STATE(NULL, state_notify_data, NULL), + [STATE_APP_INIT] = SMF_CREATE_STATE(NULL, state_init, NULL, NULL, NULL), + [STATE_APP_NOTIFY_CAPABILITY] = + SMF_CREATE_STATE(NULL, state_notify_capability, NULL, NULL, NULL), + [STATE_APP_NOTIFY_DATA] = SMF_CREATE_STATE(NULL, state_notify_data, NULL, NULL, NULL), }; static uint8_t __aligned(4) @@ -179,7 +180,7 @@ static void state_notify_capability(void *o) app_sm_t *sm = (app_sm_t *)o; switch (sm->event) { - case APP_EVENT_NOTIFY_SENSOR: + case APP_EVENT_NOTIFY_SENSOR: { // Prepare message struct sid_demo_capability_discovery cap = { .link_type = last_link_mask_get(), @@ -219,7 +220,7 @@ static void state_notify_capability(void *o) } LOG_INF("Capability send"); - break; + } break; case APP_EVENT_CAPABILITY_SUCCESS: smf_set_state(SMF_CTX(sm), &app_states[STATE_APP_NOTIFY_DATA]); break; @@ -243,7 +244,7 @@ static void state_notify_data(void *o) int err = 0; switch (sm->event) { - case APP_EVENT_NOTIFY_BUTTON: + case APP_EVENT_NOTIFY_BUTTON: { // Read button state uint8_t button_arr[APP_BUTTONS_MAX] = { 0 }; uint8_t num_buttons = 0; @@ -299,8 +300,8 @@ static void state_notify_data(void *o) app_btn_pending_flag_clear(); LOG_INF("Notify button send"); - break; - case APP_EVENT_NOTIFY_SENSOR: + } break; + case APP_EVENT_NOTIFY_SENSOR: { // Read sensor data int16_t temp = 0; err = app_sensor_temperature_get(&temp); @@ -346,8 +347,8 @@ static void state_notify_data(void *o) } LOG_INF("Notify sensor send"); - break; - case APP_EVENT_RESP_LED_ON: + } break; + case APP_EVENT_RESP_LED_ON: { // Read led status uint8_t led_on_arr[APP_BUTTONS_MAX] = { 0 }; uint8_t num_leds_on = 0; @@ -374,8 +375,8 @@ static void state_notify_data(void *o) } LOG_INF("Response LED ON send"); - break; - case APP_EVENT_RESP_LED_OFF: + } break; + case APP_EVENT_RESP_LED_OFF: { // Read led status uint8_t led_off_arr[APP_BUTTONS_MAX] = { 0 }; uint8_t num_leds_off = 0; @@ -401,7 +402,7 @@ static void state_notify_data(void *o) } LOG_INF("Response LED OFF send"); - break; + } break; case APP_EVENT_TIME_SYNC_FAIL: smf_set_state(SMF_CTX(sm), &app_states[STATE_APP_NOTIFY_CAPABILITY]); case APP_EVENT_TIME_SYNC_SUCCESS: @@ -431,7 +432,7 @@ void app_tx_task(void *dummy1, void *dummy2, void *dummy3) k_timer_start(&button_timer, K_MSEC(APP_NOTIFY_BUTTON_PERIOD_MS), K_MSEC(APP_NOTIFY_BUTTON_PERIOD_MS)); - k_msgq_init(&app_sm.msgq, app_msgq_buff, sizeof(app_event_t), + k_msgq_init(&app_sm.msgq, (char *)app_msgq_buff, sizeof(app_event_t), CONFIG_SID_END_DEVICE_TX_THREAD_QUEUE_SIZE); smf_set_initial(SMF_CTX(&app_sm), &app_states[STATE_APP_INIT]); diff --git a/samples/sid_end_device/src/sidewalk.c b/samples/sid_end_device/src/sidewalk.c index bf9fde0..2dc8c79 100644 --- a/samples/sid_end_device/src/sidewalk.c +++ b/samples/sid_end_device/src/sidewalk.c @@ -3,34 +3,43 @@ * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ +#include +#include +#include -#include -#include +#ifdef CONFIG_SMTC_CLI +#include +extern volatile int csuso; +#endif /* CONFIG_SMTC_CLI */ +#include +#include #include -#include -#include -#include +#ifdef CONFIG_SIDEWALK_SUBGHZ_SUPPORT +#include +#endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER +#include +#include +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU +#include +#include +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ +#include // print hash only +#include // print hash only +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER */ #ifdef CONFIG_SID_END_DEVICE_CLI #include -#endif +#endif /* CONFIG_SID_END_DEVICE_CLI */ #ifdef CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK #include -#endif +#endif /* CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK */ + #include #include +#include #include -#include -#ifdef CONFIG_SIDEWALK_SUBGHZ_SUPPORT -#include -#endif -#include - -#include -#ifdef CONFIG_SMTC_CLI -#include -extern volatile int csuso; -#endif /* CONFIG_SMTC_CLI */ +#include #ifdef CONFIG_SIDEWALK_LINK_MASK_BLE #define DEFAULT_LM (uint32_t)(SID_LINK_TYPE_1) @@ -47,7 +56,32 @@ LOG_MODULE_REGISTER(sidewalk_app, CONFIG_SIDEWALK_LOG_LEVEL); static struct k_thread sid_thread; K_THREAD_STACK_DEFINE(sid_thread_stack, CONFIG_SIDEWALK_THREAD_STACK_SIZE); -//extern uint32_t radio_dbg; +sys_slist_t pending_message_list = SYS_SLIST_STATIC_INIT(&pending_message_list); +K_MUTEX_DEFINE(pending_message_list_mutex); + +sidewalk_msg_t *get_message_buffer(uint16_t message_id) +{ + sidewalk_msg_t *pending_message; + sidewalk_msg_t *iterator; + int mutex_err = + k_mutex_lock(&pending_message_list_mutex, k_is_in_isr() ? K_NO_WAIT : K_FOREVER); + if (mutex_err != 0) { + LOG_ERR("Failed to lock mutex for message list"); + return NULL; + } + SYS_SLIST_FOR_EACH_CONTAINER_SAFE (&pending_message_list, pending_message, iterator, node) { + if (pending_message->desc.id == message_id) { + if (sys_slist_find_and_remove(&pending_message_list, + &pending_message->node) == false) { + LOG_ERR("Failed to remove pending message from list"); + }; + k_mutex_unlock(&pending_message_list_mutex); + return pending_message; + } + } + k_mutex_unlock(&pending_message_list_mutex); + return NULL; +} typedef struct sm_s { struct smf_ctx ctx; @@ -64,6 +98,7 @@ enum state { static void state_sidewalk_run(void *o); static void state_sidewalk_entry(void *o); +static void state_sidewalk_exit(void *o); static void state_dfu_entry(void *o); static void state_dfu_run(void *o); #ifdef CONFIG_SMTC_CLI @@ -72,10 +107,11 @@ static void state_smtc_run(void *o); #endif /* CONFIG_SMTC_CLI */ static const struct smf_state sid_states[] = { - [STATE_SIDEWALK] = SMF_CREATE_STATE(state_sidewalk_entry, state_sidewalk_run, NULL), - [STATE_DFU] = SMF_CREATE_STATE(state_dfu_entry, state_dfu_run, NULL), + [STATE_SIDEWALK] = SMF_CREATE_STATE(state_sidewalk_entry, state_sidewalk_run, + state_sidewalk_exit, NULL, NULL), + [STATE_DFU] = SMF_CREATE_STATE(state_dfu_entry, state_dfu_run, NULL, NULL, NULL), #ifdef CONFIG_SMTC_CLI - [STATE_SMTC] = SMF_CREATE_STATE(state_smtc_entry, state_smtc_run, NULL), + [STATE_SMTC] = SMF_CREATE_STATE(state_smtc_entry, state_smtc_run, NULL, NULL, NULL), #endif /* CONFIG_SMTC_CLI */ }; @@ -94,7 +130,7 @@ static void state_sidewalk_entry(void *o) (radio_lr11xx_device_config_t *)get_radio_cfg(), #else (radio_sx126x_device_config_t *)get_radio_cfg(), -#endif /* CONFIG_RADIO_LR11XX */ +#endif /* CONFIG_RADIO_LR11XX */ #endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ }; @@ -132,7 +168,6 @@ static void state_sidewalk_entry(void *o) (SID_LINK_TYPE_3 & sm->sid->config.link_mask) ? "LoRa" : (SID_LINK_TYPE_2 & sm->sid->config.link_mask) ? "FSK" : "BLE"); - e = sid_init(&sm->sid->config, &sm->sid->handle); if (e) { LOG_ERR("sid init err %d", (int)e); @@ -146,10 +181,7 @@ static void state_sidewalk_entry(void *o) } #endif /* CONFIG_SMTC_CLI */ -#ifdef CONFIG_SIDEWALK_FILE_TRANSFER - app_file_transfer_demo_init(sm->sid->handle); -#endif - e = sid_start(sm->sid->handle, sm->sid->config.link_mask); // state_sidewalk_entry() + e = sid_start(sm->sid->handle, sm->sid->config.link_mask); if (e) { LOG_ERR("sid start err %d", (int)e); } @@ -181,6 +213,16 @@ static void state_sidewalk_entry(void *o) #endif /* CONFIG_SID_END_DEVICE_AUTO_CONN_REQ */ #endif /* CONFIG_SIDEWALK_AUTO_START */ + +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU + int dfu_err = boot_write_img_confirmed(); + if (dfu_err) { + LOG_ERR("img confirm fail %d", dfu_err); + } +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER + app_file_transfer_demo_init(((sm_t *)o)->sid->handle); +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER */ } static void state_sidewalk_run(void *o) @@ -190,9 +232,7 @@ static void state_sidewalk_run(void *o) switch (sm->event.id) { case SID_EVENT_SIDEWALK: { - //sid_pal_gpio_write(radio_dbg, 0); e = sid_process(sm->sid->handle); - //sid_pal_gpio_write(radio_dbg, 1); if (e) { LOG_ERR("sid process err %d", (int)e); } @@ -249,7 +289,7 @@ static void state_sidewalk_run(void *o) #ifdef CONFIG_SIDEWALK_FILE_TRANSFER app_file_transfer_demo_init(sm->sid->handle); #endif - e = sid_start(sm->sid->handle, sm->sid->config.link_mask); // state_sidewalk_run() SID_EVENT_LINK_SWITCH + e = sid_start(sm->sid->handle, sm->sid->config.link_mask); if (e) { LOG_ERR("sid start err %d", (int)e); } @@ -312,8 +352,13 @@ static void state_sidewalk_run(void *o) LOG_ERR("sid send err %d", (int)e); } LOG_DBG("sid send (type: %d, id: %u)", (int)p_msg->desc.type, p_msg->desc.id); - sid_hal_free(p_msg->msg.data); - sid_hal_free(p_msg); + int mutex_err = k_mutex_lock(&pending_message_list_mutex, K_FOREVER); + if (mutex_err != 0) { + LOG_ERR("Failed to lock mutex for message list"); + break; + } + sys_slist_append(&pending_message_list, &p_msg->node); + k_mutex_unlock(&pending_message_list_mutex); } break; case SID_EVENT_CONNECT: { if (!(sm->sid->config.link_mask & SID_LINK_TYPE_1)) { @@ -327,17 +372,20 @@ static void state_sidewalk_run(void *o) } break; case SID_EVENT_FILE_TRANSFER: { #ifdef CONFIG_SIDEWALK_FILE_TRANSFER - struct data_received_args *args = (struct data_received_args *)sm->event.ctx; - if (!args) { + sidewalk_transfer_t *transfer = (sidewalk_transfer_t *)sm->event.ctx; + if (!transfer) { LOG_ERR("File transfer event data is NULL"); break; } - LOG_INF("Received file Id %d; buffer size %d; file offset %d", args->desc.file_id, - args->buffer->size, args->desc.file_offset); + + LOG_INF("Received file Id %d; buffer size %d; file offset %d", transfer->file_id, + transfer->data_size, transfer->file_offset); + + // print data hash uint8_t hash_out[32]; sid_pal_hash_params_t params = { .algo = SID_PAL_HASH_SHA256, - .data = args->buffer->data, - .data_size = args->buffer->size, + .data = transfer->data, + .data_size = transfer->data_size, .digest = hash_out, .digest_size = sizeof(hash_out) }; @@ -354,15 +402,46 @@ static void state_sidewalk_run(void *o) LOG_INF("SHA256: %s", hex_str); } - sid_error_t ret = sid_bulk_data_transfer_release_buffer( - sm->sid->handle, args->desc.file_id, args->buffer); - if (ret != SID_ERROR_NONE) { - LOG_ERR("sid_bulk_data_transfer_release_buffer returned %s", - SID_ERROR_T_STR(ret)); +#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU + int err = nordic_dfu_img_write(transfer->file_offset, transfer->data, + transfer->data_size); + + if (err) { + LOG_ERR("Fail to write img %d", err); + err = nordic_dfu_img_cancel(); + if (err) { + LOG_ERR("Fail to complete dfu %d", err); + } + e = sid_bulk_data_transfer_cancel( + sm->sid->handle, transfer->file_id, + SID_BULK_DATA_TRANSFER_REJECT_REASON_FILE_TOO_BIG); + if (e != SID_ERROR_NONE) { + LOG_ERR("sbdt cancel ret %s", SID_ERROR_T_STR(e)); + } + + sid_hal_free(transfer); + break; } - sid_hal_free(args); +#endif /* CONFIG_SIDEWALK_FILE_TRANSFER_DFU */ + const struct sid_bulk_data_transfer_buffer sbdt_buffer = { + .data = transfer->data, + .size = transfer->data_size, + }; + e = sid_bulk_data_transfer_release_buffer(sm->sid->handle, transfer->file_id, + &sbdt_buffer); + if (e != SID_ERROR_NONE) { + LOG_ERR("sbdt release ret %s", SID_ERROR_T_STR(e)); + } + + // free event context + sid_hal_free(transfer); #endif /* CONFIG_SIDEWALK_FILE_TRANSFER */ } break; + case SID_EVENT_REBOOT: { + LOG_INF("Rebooting..."); + LOG_PANIC(); + sys_reboot(SYS_REBOOT_WARM); + } break; case SID_EVENT_LAST: break; } @@ -399,6 +478,25 @@ static void state_smtc_run(void *o) } #endif /* CONFIG_SMTC_CLI */ +static void state_sidewalk_exit(void *o) +{ + int mutex_err = k_mutex_lock(&pending_message_list_mutex, K_FOREVER); + if (mutex_err != 0) { + LOG_ERR("Failed to lock mutex for message list"); + return; + } + sys_snode_t *list_element = sys_slist_get(&pending_message_list); + + while (list_element != NULL) { + sidewalk_msg_t *message = SYS_SLIST_CONTAINER(list_element, message, node); + sid_hal_free(message->msg.data); + sid_hal_free(message); + + list_element = sys_slist_get(&pending_message_list); + } + k_mutex_unlock(&pending_message_list_mutex); +} + static void state_dfu_entry(void *o) { sm_t *sm = (sm_t *)o; @@ -437,6 +535,7 @@ static void state_dfu_run(void *o) case SID_EVENT_LINK_SWITCH: case SID_EVENT_SIDEWALK: case SID_EVENT_FILE_TRANSFER: + case SID_EVENT_REBOOT: LOG_INF("Operation not supported in DFU mode"); break; case SID_EVENT_LAST: @@ -489,8 +588,17 @@ int sidewalk_event_send(sidewalk_event_t event, void *ctx) .ctx = ctx, }; - const int result = k_msgq_put(&sid_sm.msgq, (void *)&ctx_event, K_NO_WAIT); + k_timeout_t timeout = K_NO_WAIT; + +#ifdef CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT + if (!k_is_in_isr()) { + timeout = K_MSEC(CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT_VALUE); + } +#endif /* CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT */ + + const int result = k_msgq_put(&sid_sm.msgq, (void *)&ctx_event, timeout); LOG_DBG("sidewalk_event_send event = %d (%s), context = %p, k_msgq_put result %d", event, SIDEWALK_EVENT_T_STR(event), ctx, result); + return result; } diff --git a/samples/sid_end_device/sysbuild/ipc_radio/prj.conf b/samples/sid_end_device/sysbuild/ipc_radio/prj.conf new file mode 100644 index 0000000..654a36b --- /dev/null +++ b/samples/sid_end_device/sysbuild/ipc_radio/prj.conf @@ -0,0 +1,35 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 + +# Bluetooth +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y +CONFIG_BT_CTLR_ASSERT_HANDLER=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_CENTRAL=n +CONFIG_BT_MAX_CONN=1 +CONFIG_BT_BUF_ACL_RX_SIZE=502 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 + +# IPC +CONFIG_IPC_SERVICE=y +CONFIG_MBOX=y + +# Debug +CONFIG_LOG=n +CONFIG_SERIAL=n +CONFIG_ASSERT=y +CONFIG_DEBUG_INFO=y +CONFIG_EXCEPTION_STACK_TRACE=y +CONFIG_RESET_ON_FATAL_ERROR=y + +# ipc_radio +CONFIG_IPC_RADIO_BT=y +CONFIG_IPC_RADIO_BT_HCI_IPC=y diff --git a/samples/sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf new file mode 100644 index 0000000..c333f7b --- /dev/null +++ b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2023 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Configure QSPI for external flash +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/samples/sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 0000000..6ea6421 --- /dev/null +++ b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + chosen { + zephyr,code-partition = &boot_partition; + nordic,pm-ext-flash = &mx25r64; + }; +}; diff --git a/samples/sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 0000000..96cb33e --- /dev/null +++ b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1,28 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 + +# The following configurations are required to support simultaneous multi image update +CONFIG_PCD_APP=y +CONFIG_UPDATEABLE_IMAGE_NUMBER=2 + +CONFIG_BOOT_SWAP_USING_MOVE=n +# Multi-image updates do not support image swapping yet. +CONFIG_BOOT_UPGRADE_ONLY=y + +# The network core cannot access external flash directly. The flash simulator must be used to +# provide a memory region that is used to forward the new firmware to the network core. +CONFIG_FLASH_SIMULATOR=y +CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y +CONFIG_FLASH_SIMULATOR_STATS=n + +# Enable custom command to erase settings partition. +CONFIG_ENABLE_MGMT_PERUSER=y +CONFIG_ZCBOR=y +CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE=y diff --git a/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay similarity index 77% rename from samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay rename to samples/sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay index 055f044..6ea6421 100644 --- a/samples/SWTL001/child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -4,8 +4,9 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ - / { +/ { chosen { + zephyr,code-partition = &boot_partition; nordic,pm-ext-flash = &mx25r64; }; }; diff --git a/samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf new file mode 100644 index 0000000..16bd5b0 --- /dev/null +++ b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp.conf @@ -0,0 +1,13 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +CONFIG_BOOT_MAX_IMG_SECTORS=256 +# Ensure that the qspi driver is disabled by default +CONFIG_NORDIC_QSPI_NOR=n + +# Workaroud: fprotect and watchdog feed +# are not supported in NCS v2.6.0 +CONFIG_FPROTECT=n +CONFIG_BOOT_WATCHDOG_FEED=n diff --git a/samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay new file mode 100644 index 0000000..6220cb2 --- /dev/null +++ b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_2_1.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/* There is no aditional config needed for this version of PDK */ diff --git a/samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay new file mode 100644 index 0000000..8edfb64 --- /dev/null +++ b/samples/sid_end_device/sysbuild/mcuboot/boards/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + +/* Application does not use cpuflpr core. Assign whole RRAM to cpuapp. */ +&cpuapp_rram { + reg = < 0x0 DT_SIZE_K(1524) >; +}; diff --git a/samples/SWTL001/child_image/mcuboot/boards/thingy53_nrf5340_cpuapp.conf b/samples/sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.conf similarity index 93% rename from samples/SWTL001/child_image/mcuboot/boards/thingy53_nrf5340_cpuapp.conf rename to samples/sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.conf index a0db3d5..561529f 100644 --- a/samples/SWTL001/child_image/mcuboot/boards/thingy53_nrf5340_cpuapp.conf +++ b/samples/sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.conf @@ -4,9 +4,6 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -# Increase main stack size -CONFIG_MAIN_STACK_SIZE=10240 - # Configure MCUboot features CONFIG_NRF53_MULTI_IMAGE_UPDATE=y CONFIG_BOOT_UPGRADE_ONLY=y diff --git a/samples/sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay b/samples/sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay new file mode 100644 index 0000000..6ea6421 --- /dev/null +++ b/samples/sid_end_device/sysbuild/mcuboot/boards/thingy53_nrf5340_cpuapp.overlay @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + chosen { + zephyr,code-partition = &boot_partition; + nordic,pm-ext-flash = &mx25r64; + }; +}; diff --git a/samples/sid_end_device/sysbuild/mcuboot/prj.conf b/samples/sid_end_device/sysbuild/mcuboot/prj.conf new file mode 100644 index 0000000..0a05853 --- /dev/null +++ b/samples/sid_end_device/sysbuild/mcuboot/prj.conf @@ -0,0 +1,39 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +CONFIG_MAIN_STACK_SIZE=10240 + +CONFIG_BOOT_SWAP_SAVE_ENCTLV=n +CONFIG_BOOT_BOOTSTRAP=n +CONFIG_PM=n + +CONFIG_FLASH=y +CONFIG_FPROTECT=y + +CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" + +CONFIG_BOOT_MAX_IMG_SECTORS=256 + +# Use minimal C library instead of the Picolib +CONFIG_MINIMAL_LIBC=y + +# Disable logs +CONFIG_NCS_BOOT_BANNER=n +CONFIG_CONSOLE=n +CONFIG_SERIAL=n +CONFIG_UART_CONSOLE=n +CONFIG_USE_SEGGER_RTT=n +CONFIG_LOG=n +CONFIG_CONSOLE_HANDLER=n +CONFIG_BOOT_BANNER=n + +# Bootloader size optimization +CONFIG_RESET_ON_FATAL_ERROR=n +CONFIG_GPIO=n +CONFIG_TIMESLICING=n +CONFIG_MULTITHREADING=n +CONFIG_TICKLESS_KERNEL=n +CONFIG_TIMEOUT_64BIT=n +CONFIG_NRF_ENABLE_ICACHE=n diff --git a/v261_nRF52840_sidewalk_lr11xx.diff b/v261_nRF52840_sidewalk_lr11xx.diff deleted file mode 100644 index 972f19d..0000000 --- a/v261_nRF52840_sidewalk_lr11xx.diff +++ /dev/null @@ -1,106 +0,0 @@ -diff -urN '--exclude=.git' '--exclude=build' '--exclude=.github' '--exclude=version.conf' sidewalk/Kconfig.dependencies sidewalk_with_lr/Kconfig.dependencies ---- sidewalk/Kconfig.dependencies 2024-05-23 13:53:14.017676539 -0700 -+++ sidewalk_with_lr/Kconfig.dependencies 2024-05-23 13:52:39.704938865 -0700 -@@ -172,7 +172,7 @@ - - config SIDEWALK_GPIO_MAX - int -- default 6 if SIDEWALK_SUBGHZ_SUPPORT -+ default 12 if SIDEWALK_SUBGHZ_SUPPORT - default 0 - help - Maximum number of GPIO assigned for use with Sidewalk GPIO API -diff -urN '--exclude=.git' '--exclude=build' '--exclude=.github' '--exclude=version.conf' sidewalk/subsys/config/common/CMakeLists.txt sidewalk_with_lr/subsys/config/common/CMakeLists.txt ---- sidewalk/subsys/config/common/CMakeLists.txt 2024-05-23 13:53:14.045677140 -0700 -+++ sidewalk_with_lr/subsys/config/common/CMakeLists.txt 2024-05-23 10:14:18.792084848 -0700 -@@ -8,6 +8,8 @@ - - zephyr_library_sources_ifdef(CONFIG_SIDEWALK src/app_ble_config.c) - --zephyr_library_sources_ifdef(CONFIG_SIDEWALK_SUBGHZ_SUPPORT src/app_subGHz_config.c) -+if(NOT CONFIG_RADIO_LR11XX) -+ zephyr_library_sources_ifdef(CONFIG_SIDEWALK_SUBGHZ_SUPPORT src/app_subGHz_config.c) -+endif() - zephyr_library_sources_ifndef(CONFIG_SIDEWALK_SUBGHZ_SUPPORT src/app_subGHz_config_empty.c) - -diff -urN '--exclude=.git' '--exclude=build' '--exclude=.github' '--exclude=version.conf' sidewalk/subsys/config/common/include/app_subGHz_config.h sidewalk_with_lr/subsys/config/common/include/app_subGHz_config.h ---- sidewalk/subsys/config/common/include/app_subGHz_config.h 2024-05-23 13:53:14.045677140 -0700 -+++ sidewalk_with_lr/subsys/config/common/include/app_subGHz_config.h 2024-05-23 09:39:15.946953949 -0700 -@@ -16,11 +16,19 @@ - #ifndef APP_900_CONFIG_H - #define APP_900_CONFIG_H - -+#if defined(CONFIG_RADIO_LR11XX) -+#include -+#else - #include -+#endif - #include - #include - --const radio_sx126x_device_config_t* get_radio_cfg(void); -+#if defined(CONFIG_RADIO_LR11XX) -+const radio_lr11xx_device_config_t *get_radio_cfg(void); -+#else -+const radio_sx126x_device_config_t *get_radio_cfg(void); -+#endif - const sid_pal_mfg_store_region_t* get_mfg_cfg(void); - struct sid_sub_ghz_links_config* app_get_sub_ghz_config(void); - #endif -diff -urN '--exclude=.git' '--exclude=build' '--exclude=.github' '--exclude=version.conf' sidewalk/subsys/sal/common/sid_pal_ifc/sid_pal_platform_init_types.h sidewalk_with_lr/subsys/sal/common/sid_pal_ifc/sid_pal_platform_init_types.h ---- sidewalk/subsys/sal/common/sid_pal_ifc/sid_pal_platform_init_types.h 2024-05-23 13:53:14.045677140 -0700 -+++ sidewalk_with_lr/subsys/sal/common/sid_pal_ifc/sid_pal_platform_init_types.h 2024-05-23 10:23:45.460148547 -0700 -@@ -17,14 +17,22 @@ - #define SID_PAL_PLATFORM_INIT_TYPES_H - - #if defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) -+#if defined(CONFIG_RADIO_LR11XX) -+#include -+#else - #include --#endif -+#endif /* CONFIG_RADIO_LR11XX */ -+#endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ - - typedef struct { - //place holder for platform specific init parameters - #if defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) -+#if defined(CONFIG_RADIO_LR11XX) -+ radio_lr11xx_device_config_t * radio_cfg; -+#else - radio_sx126x_device_config_t * radio_cfg; --#endif -+#endif /* CONFIG_RADIO_LR11XX */ -+#endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ - } platform_specific_init_parameters_t; - - #endif -diff -urN '--exclude=.git' '--exclude=build' '--exclude=.github' '--exclude=version.conf' sidewalk/subsys/sal/sid_pal/src/sid_common.c sidewalk_with_lr/subsys/sal/sid_pal/src/sid_common.c ---- sidewalk/subsys/sal/sid_pal/src/sid_common.c 2024-05-23 13:53:14.049677227 -0700 -+++ sidewalk_with_lr/subsys/sal/sid_pal/src/sid_common.c 2024-05-23 10:20:59.916632544 -0700 -@@ -12,8 +12,12 @@ - #endif /* defined(CONFIG_SOC_SERIES_NRF53X) && defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) */ - - #if defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) -+#if defined(CONFIG_RADIO_LR11XX) -+#include -+#else - #include --#endif -+#endif /* CONFIG_RADIO_LR11XX */ -+#endif /* CONFIG_SIDEWALK_SUBGHZ_SUPPORT */ - - #include - #include -@@ -31,7 +35,11 @@ - return SID_ERROR_INCOMPATIBLE_PARAMS; - } - #if defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) -+#if defined(CONFIG_RADIO_LR11XX) -+ set_radio_lr11xx_device_config(platform_init_parameters->radio_cfg); -+#else - set_radio_sx126x_device_config(platform_init_parameters->radio_cfg); -+#endif - #if defined(CONFIG_SOC_SERIES_NRF53X) - (void)bt_enable(NULL); - (void)bt_disable(); diff --git a/v270_sidewalk_lr11xx.diff b/v270_sidewalk_lr11xx.diff new file mode 100644 index 0000000..b791137 --- /dev/null +++ b/v270_sidewalk_lr11xx.diff @@ -0,0 +1,89 @@ +diff -urN '--exclude=.git' '--exclude=build' '--exclude=.github' sidewalk/subsys/config/common/CMakeLists.txt lr_sidewalk/subsys/config/common/CMakeLists.txt +--- sidewalk/subsys/config/common/CMakeLists.txt 2024-07-09 14:02:55.256569753 -0700 ++++ lr_sidewalk/subsys/config/common/CMakeLists.txt 2024-07-08 14:18:06.339408639 -0700 +@@ -8,6 +8,8 @@ + + zephyr_library_sources_ifdef(CONFIG_SIDEWALK src/app_ble_config.c) + +-zephyr_library_sources_ifdef(CONFIG_SIDEWALK_SUBGHZ_SUPPORT src/app_subGHz_config.c) ++if(NOT DEFINED CONFIG_RADIO_LR11XX) ++ zephyr_library_sources_ifdef(CONFIG_SIDEWALK_SUBGHZ_SUPPORT src/app_subGHz_config.c) ++endif() + zephyr_library_sources_ifndef(CONFIG_SIDEWALK_SUBGHZ_SUPPORT src/app_subGHz_config_empty.c) + +diff -urN '--exclude=.git' '--exclude=build' '--exclude=.github' sidewalk/subsys/config/common/include/app_subGHz_config.h lr_sidewalk/subsys/config/common/include/app_subGHz_config.h +--- sidewalk/subsys/config/common/include/app_subGHz_config.h 2024-07-09 14:02:55.256569753 -0700 ++++ lr_sidewalk/subsys/config/common/include/app_subGHz_config.h 2024-07-08 14:16:00.309593858 -0700 +@@ -16,11 +16,16 @@ + #ifndef APP_900_CONFIG_H + #define APP_900_CONFIG_H + +-#include + #include + #include +- ++#ifdef CONFIG_RADIO_LR11XX ++#include ++const radio_lr11xx_device_config_t* get_radio_cfg(void); ++#else ++#include + const radio_sx126x_device_config_t* get_radio_cfg(void); ++#endif ++ + const sid_pal_mfg_store_region_t* get_mfg_cfg(void); + struct sid_sub_ghz_links_config* app_get_sub_ghz_config(void); + #endif +diff -urN '--exclude=.git' '--exclude=build' '--exclude=.github' sidewalk/subsys/sal/common/sid_pal_ifc/sid_pal_platform_init_types.h lr_sidewalk/subsys/sal/common/sid_pal_ifc/sid_pal_platform_init_types.h +--- sidewalk/subsys/sal/common/sid_pal_ifc/sid_pal_platform_init_types.h 2024-07-09 14:02:55.256569753 -0700 ++++ lr_sidewalk/subsys/sal/common/sid_pal_ifc/sid_pal_platform_init_types.h 2024-07-08 14:24:11.326089757 -0700 +@@ -17,13 +17,21 @@ + #define SID_PAL_PLATFORM_INIT_TYPES_H + + #if defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) +-#include ++ #if defined(CONFIG_RADIO_LR11XX) ++ #include ++ #else ++ #include ++ #endif + #endif + + typedef struct { + //place holder for platform specific init parameters + #if defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) ++ #if defined(CONFIG_RADIO_LR11XX) ++ radio_lr11xx_device_config_t * radio_cfg; ++ #else + radio_sx126x_device_config_t * radio_cfg; ++ #endif + #endif + } platform_specific_init_parameters_t; + +diff -urN '--exclude=.git' '--exclude=build' '--exclude=.github' sidewalk/subsys/sal/sid_pal/src/sid_common.c lr_sidewalk/subsys/sal/sid_pal/src/sid_common.c +--- sidewalk/subsys/sal/sid_pal/src/sid_common.c 2024-07-09 14:02:55.256569753 -0700 ++++ lr_sidewalk/subsys/sal/sid_pal/src/sid_common.c 2024-07-08 14:20:32.697876640 -0700 +@@ -12,7 +12,11 @@ + #endif /* defined(CONFIG_SOC_SERIES_NRF53X) && defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) */ + + #if defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) +-#include ++ #if defined(CONFIG_RADIO_LR11XX) ++ #include ++ #else ++ #include ++ #endif + #endif + + #include +@@ -31,7 +35,11 @@ + return SID_ERROR_INCOMPATIBLE_PARAMS; + } + #if defined(CONFIG_SIDEWALK_SUBGHZ_SUPPORT) ++ #if defined(CONFIG_RADIO_LR11XX) ++ set_radio_lr11xx_device_config(platform_init_parameters->radio_cfg); ++ #else + set_radio_sx126x_device_config(platform_init_parameters->radio_cfg); ++ #endif + #if defined(CONFIG_SOC_SERIES_NRF53X) + (void)bt_enable(NULL); + (void)bt_disable(); diff --git a/west.yml b/west.yml index d78e68d..e7f0f37 100644 --- a/west.yml +++ b/west.yml @@ -15,12 +15,12 @@ manifest: - name: nrf remote: ncs repo-path: sdk-nrf - revision: v2.6.1 + revision: v2.7.0 import: true - name: sidewalk remote: ncs repo-path: sdk-sidewalk - revision: v2.6.1 + revision: v2.7.0 - name: lbm431 remote: lora-net repo-path: SWSD006