Hi,
After upgrading to NCS v2.7.0, I got some intermittent issues about OTA DFU process.
Firmware description:
- Our firmware, developed on nRF52840 with NCS v2.7.0 running on our custom PCB, acts as a Peripheral, waiting to be connected and paired by a Central (mobile app).
Issue detail:
- Using Device Manager app, sometimes the pairing at firmware is lost, sometimes not.
- When the pairing is lost, other settings (saved by `settings_save_one()`) also are.
- When pairing is persisted, sometimes the Central device, which had paired with this firmware, failed to reconnect due to error
BT_SECURITY_ERR_UNSPECIFIED (9) returned in `on_security_changed()` callback; sometimes it just works.I have captured comparison of the uart printout between these 2 cases and compares in the attached `persisted vs lost.png`. I also attach their full log files: pairing `persisted.jl` and `pairing lost.jl` for your reference.
- Using our mobile app: is "app settings" at firmware kept or deleted by function call in app?
- On iOS:
- is it correct to use this function `reset()` in DefaultManager to complete the DFU/OTA process? Is this function equivalent to `Confirm` and `Send Reset Command` in Device Manager app? If not, how should I complete the DFU/OTA process without erasing app settings at firmware?
- By using `reset()` function, is "app settings" erased?
- On Android: we build setting with `eraseAppSetting(false)`. However, pairing is still lost some times.
- On iOS:
Source code attached: dfu_bluetooth.h, dfu_bluetooth.c, prj.conf
- dfu_bluetooth is initialized in `main()` when `dfu_mode` is true
... int main() { ... if (dfu_mode) { init_bluetooth_dfu(); } ... }
- Is there anything wrong with our implementation at firmware, described above, causing pairing lost? Or pairing, whether persisted or erased, is decided by app's function call?
- Why is firmware after OTA so intermittent: sometimes it can keep pairing info, sometimes it can keep but failed to connect by its peer (which had paired with it before); sometimes not?
- Although pairing info is intermittent, latest firmware is always updated.
What is the pattern of this pairing-lost event? I'm so confused.
Best regards,
<wrn> main: *******NOUS ECG BLE 3.2-debug3 build time: Nov 4 2024 11:56:36********DFU********* <wrn> main: NAND write Address:0x00000003 <wrn> main: NAND mode:0 <wrn> main: Packet_num :45 <inf> peri_led: peri_led init!! <inf> bt_sdc_hci_driver: SoftDevice Controller build revision: d6 da c7 ae 08 db 72 6f 2a a3 26 49 2a 4d a8 b3 |......ro *.&I*M.. 98 0e 07 7f |.... <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002) <inf> bt_hci_core: HW Variant: nRF52x (0x0002) <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 214.51162 Build 1926957230 <inf> bt_hci_core: No ID address. App must call settings_load() <inf> bt_hci_core: Identity: D6:B5:40:32:16:53 (random) <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x11fb, manufacturer 0x0059 <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x11fb <inf> dfu_bluetooth: DFU adv started with err: 0 <inf> dfu_bluetooth: Bluetooth DFU initialized <inf> bas: BAS Notifications enabled <inf> ecg_bluetooth: Basic Command Notification enabled <inf> ecg_bluetooth: DAT ECG Notification enabled <inf> ecg_bluetooth: DAT System Notification enabled <wrn> bt_l2cap: Ignoring data for unknown channel ID 0x003a <inf> mcuboot_util: Image index: 0, Swap type: none <inf> mcuboot_util: Image index: 0, Swap type: none <err> qspi_nor: pm_device_runtime_put failed: -16 <inf> mcuboot_util: Image index: 0, Swap type: none <inf> mcuboot_util: Image index: 0, Swap type: none <inf> mcuboot_util: Image index: 0, Swap type: perm D: lfclk: Clock started D: RDSR 40 QE 1 need 1: no-change *** Booting My Application v2.1.0-dev-daf2946a0f07 *** *** Using nRF Connect SDK v2.7.0-5cb85570ca43 *** *** Using Zephyr OS v3.6.99-100befc70c74 *** I: Starting bootloader I: Primary image: magic=good, swap_type=0x3, copy_done=0x1, image_ok=0x1 I: Secondary image: magic=good, swap_type=0x3, copy_done=0x3, image_ok=0x1 I: Boot source: none I: Image index: 0, Swap type: perm I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3 I: Secondary image: magic=good, swap_type=0x3, copy_done=0x3, image_ok=0x1 I: Boot source: none I: Starting swap using move algorithm. D: erasing trailer; fa_id=14 D: initializing status; fa_id=14 D: writing swap_info; fa_id=14 off=0xd9fd8 (0xfcfd8), swap_type=0x3 image_num=0x0 D: writing image_ok; fa_id=14 off=0xd9fe8 (0xfcfe8) D: writing swap_size; fa_id=14 off=0xd9fd0 (0xfcfd0) D: writing magic; fa_id=14 off=0xd9ff0 (0xfcff0) D: erasing trailer; fa_id=2 D: writing swap status; fa_id=14 off=0xd93d0 (0xfc3d0) D: writing swap status; fa_id=14 off=0xd93d4 (0xfc3d4) D: writing swap status; fa_id=14 off=0xd93d8 (0xfc3d8) D: writing swap status; fa_id=14 off=0xd93dc (0xfc3dc) D: writing swap status; fa_id=14 off=0xd93e0 (0xfc3e0) D: writing swap status; fa_id=14 off=0xd93e4 (0xfc3e4) D: writing swap status; fa_id=14 off=0xd93e8 (0xfc3e8) D: writing swap status; fa_id=14 off=0xd93ec (0xfc3ec) D: writing swap status; fa_id=14 off=0xd93f0 (0xfc3f0) D: writing swap status; fa_id=14 off=0xd93f4 (0xfc3f4) D: writing swap status; fa_id=14 off=0xd93f8 (0xfc3f8) D: writing swap status; fa_id=14 off=0xd93fc (0xfc3fc) D: writing swap status; fa_id=14 off=0xd9400 (0xfc400) D: writing swap status; fa_id=14 off=0xd9404 (0xfc404) D: writing swap status; fa_id=14 off=0xd9408 (0xfc408) D: writing swap status; fa_id=14 off=0xd940c (0xfc40c) D: writing swap status; fa_id=14 off=0xd9410 (0xfc410) D: writing swap status; fa_id=14 off=0xd9414 (0xfc414) D: writing swap status; fa_id=14 off=0xd9418 (0xfc418) D: writing swap status; fa_id=14 off=0xd941c (0xfc41c) D: writing swap status; fa_id=14 off=0xd9420 (0xfc420) D: writing swap status; fa_id=14 off=0xd9424 (0xfc424) D: writing swap status; fa_id=14 off=0xd9428 (0xfc428) D: writing swap status; fa_id=14 off=0xd942c (0xfc42c) D: writing swap status; fa_id=14 off=0xd9430 (0xfc430) D: writing swap status; fa_id=14 off=0xd9434 (0xfc434) D: writing swap status; fa_id=14 off=0xd9438 (0xfc438) D: writing swap status; fa_id=14 off=0xd943c (0xfc43c) D: writing swap status; fa_id=14 off=0xd9440 (0xfc440) D: writing swap status; fa_id=14 off=0xd9444 (0xfc444) D: writing swap status; fa_id=14 off=0xd9448 (0xfc448) D: writing swap status; fa_id=14 off=0xd944c (0xfc44c) D: writing swap status; fa_id=14 off=0xd9450 (0xfc450) D: writing swap status; fa_id=14 off=0xd9454 (0xfc454) D: writing swap status; fa_id=14 off=0xd9458 (0xfc458) D: writing swap status; fa_id=14 off=0xd945c (0xfc45c) D: writing swap status; fa_id=14 off=0xd9460 (0xfc460) D: writing swap status; fa_id=14 off=0xd9464 (0xfc464) D: writing swap status; fa_id=14 off=0xd9468 (0xfc468) D: writing swap status; fa_id=14 off=0xd946c (0xfc46c) D: writing swap status; fa_id=14 off=0xd9470 (0xfc470) D: writing swap status; fa_id=14 off=0xd9474 (0xfc474) D: writing swap status; fa_id=14 off=0xd9478 (0xfc478) D: writing swap status; fa_id=14 off=0xd947c (0xfc47c) D: writing swap status; fa_id=14 off=0xd9480 (0xfc480) D: writing swap status; fa_id=14 off=0xd9484 (0xfc484) D: writing swap status; fa_id=14 off=0xd9488 (0xfc488) D: writing swap status; fa_id=14 off=0xd948c (0xfc48c) D: writing swap status; fa_id=14 off=0xd9490 (0xfc490) D: writing swap status; fa_id=14 off=0xd9494 (0xfc494) D: writing swap status; fa_id=14 off=0xd9498 (0xfc498) D: writing swap status; fa_id=14 off=0xd949c (0xfc49c) D: writing swap status; fa_id=14 off=0xd94a0 (0xfc4a0) D: writing swap status; fa_id=14 off=0xd94a4 (0xfc4a4) D: writing swap status; fa_id=14 off=0xd94a8 (0xfc4a8) D: writing swap status; fa_id=14 off=0xd94ac (0xfc4ac) D: writing swap status; fa_id=14 off=0xd94b0 (0xfc4b0) D: writing swap status; fa_id=14 off=0xd94b4 (0xfc4b4) D: writing swap status; fa_id=14 off=0xd94b8 (0xfc4b8) D: writing swap status; fa_id=14 off=0xd94bc (0xfc4bc) D: writing swap status; fa_id=14 off=0xd94c0 (0xfc4c0) D: writing swap status; fa_id=14 off=0xd94c4 (0xfc4c4) D: writing swap status; fa_id=14 off=0xd94c8 (0xfc4c8) D: writing swap status; fa_id=14 off=0xd94cc (0xfc4cc) D: writing swap status; fa_id=14 off=0xd94d0 (0xfc4d0) D: writing swap status; fa_id=14 off=0xd94d4 (0xfc4d4) D: writing swap status; fa_id=14 off=0xd94d8 (0xfc4d8) D: writing swap status; fa_id=14 off=0xd94dc (0xfc4dc) D: writing swap status; fa_id=14 off=0xd94e0 (0xfc4e0) D: writing swap status; fa_id=14 off=0xd94e4 (0xfc4e4) D: writing swap status; fa_id=14 off=0xd94e8 (0xfc4e8) D: writing swap status; fa_id=14 off=0xd94ec (0xfc4ec) D: writing swap status; fa_id=14 off=0xd94f0 (0xfc4f0) D: writing swap status; fa_id=14 off=0xd94f4 (0xfc4f4) D: writing swap status; fa_id=14 off=0xd94f8 (0xfc4f8) D: writing swap status; fa_id=14 off=0xd94fc (0xfc4fc) D: writing swap status; fa_id=14 off=0xd97d0 (0xfc7d0) D: writing swap status; fa_id=14 off=0xd97d4 (0xfc7d4) D: writing swap status; fa_id=14 off=0xd97d8 (0xfc7d8) D: writing swap status; fa_id=14 off=0xd97dc (0xfc7dc) D: writing swap status; fa_id=14 off=0xd97e0 (0xfc7e0) D: writing swap status; fa_id=14 off=0xd97e4 (0xfc7e4) D: writing swap status; fa_id=14 off=0xd97e8 (0xfc7e8) D: writing swap status; fa_id=14 off=0xd97ec (0xfc7ec) D: writing swap status; fa_id=14 off=0xd97f0 (0xfc7f0) D: writing swap status; fa_id=14 off=0xd97f4 (0xfc7f4) D: writing swap status; fa_id=14 off=0xd97f8 (0xfc7f8) D: writing swap status; fa_id=14 off=0xd97fc (0xfc7fc) D: writing swap status; fa_id=14 off=0xd9800 (0xfc800) D: writing swap status; fa_id=14 off=0xd9804 (0xfc804) D: writing swap status; fa_id=14 off=0xd9808 (0xfc808) D: writing swap status; fa_id=14 off=0xd980c (0xfc80c) D: writing swap status; fa_id=14 off=0xd9810 (0xfc810) D: writing swap status; fa_id=14 off=0xd9814 (0xfc814) D: writing swap status; fa_id=14 off=0xd9818 (0xfc818) D: writing swap status; fa_id=14 off=0xd981c (0xfc81c) D: writing swap status; fa_id=14 off=0xd9820 (0xfc820) D: writing swap status; fa_id=14 off=0xd9824 (0xfc824) D: writing swap status; fa_id=14 off=0xd9828 (0xfc828) D: writing swap status; fa_id=14 off=0xd982c (0xfc82c) D: writing swap status; fa_id=14 off=0xd9830 (0xfc830) D: writing swap status; fa_id=14 off=0xd9834 (0xfc834) D: writing swap status; fa_id=14 off=0xd9838 (0xfc838) D: writing swap status; fa_id=14 off=0xd983c (0xfc83c) D: writing swap status; fa_id=14 off=0xd9840 (0xfc840) D: writing swap status; fa_id=14 off=0xd9844 (0xfc844) D: writing swap status; fa_id=14 off=0xd9848 (0xfc848) D: writing swap status; fa_id=14 off=0xd984c (0xfc84c) D: writing swap status; fa_id=14 off=0xd9850 (0xfc850) D: writing swap status; fa_id=14 off=0xd9854 (0xfc854) D: writing swap status; fa_id=14 off=0xd9858 (0xfc858) D: writing swap status; fa_id=14 off=0xd985c (0xfc85c) D: writing swap status; fa_id=14 off=0xd9860 (0xfc860) D: writing swap status; fa_id=14 off=0xd9864 (0xfc864) D: writing swap status; fa_id=14 off=0xd9868 (0xfc868) D: writing swap status; fa_id=14 off=0xd986c (0xfc86c) D: writing swap status; fa_id=14 off=0xd9870 (0xfc870) D: writing swap status; fa_id=14 off=0xd9874 (0xfc874) D: writing swap status; fa_id=14 off=0xd9878 (0xfc878) D: writing swap status; fa_id=14 off=0xd987c (0xfc87c) D: writing swap status; fa_id=14 off=0xd9880 (0xfc880) D: writing swap status; fa_id=14 off=0xd9884 (0xfc884) D: writing swap status; fa_id=14 off=0xd9888 (0xfc888) D: writing swap status; fa_id=14 off=0xd988c (0xfc88c) D: writing swap status; fa_id=14 off=0xd9890 (0xfc890) D: writing swap status; fa_id=14 off=0xd9894 (0xfc894) D: writing swap status; fa_id=14 off=0xd9898 (0xfc898) D: writing swap status; fa_id=14 off=0xd989c (0xfc89c) D: writing swap status; fa_id=14 off=0xd98a0 (0xfc8a0) D: writing swap status; fa_id=14 off=0xd98a4 (0xfc8a4) D: writing swap status; fa_id=14 off=0xd98a8 (0xfc8a8) D: writing swap status; fa_id=14 off=0xd98ac (0xfc8ac) D: writing swap status; fa_id=14 off=0xd98b0 (0xfc8b0) D: writing swap status; fa_id=14 off=0xd98b4 (0xfc8b4) D: writing swap status; fa_id=14 off=0xd98b8 (0xfc8b8) D: writing swap status; fa_id=14 off=0xd98bc (0xfc8bc) D: writing swap status; fa_id=14 off=0xd98c0 (0xfc8c0) D: writing swap status; fa_id=14 off=0xd98c4 (0xfc8c4) D: writing swap status; fa_id=14 off=0xd98c8 (0xfc8c8) D: writing swap status; fa_id=14 off=0xd98cc (0xfc8cc) D: writing swap status; fa_id=14 off=0xd98d0 (0xfc8d0) D: writing swap status; fa_id=14 off=0xd98d4 (0xfc8d4) D: writing swap status; fa_id=14 off=0xd98d8 (0xfc8d8) D: writing swap status; fa_id=14 off=0xd98dc (0xfc8dc) D: writing swap status; fa_id=14 off=0xd98e0 (0xfc8e0) D: writing swap status; fa_id=14 off=0xd98e4 (0xfc8e4) D: writing swap status; fa_id=14 off=0xd98e8 (0xfc8e8) D: writing swap status; fa_id=14 off=0xd98ec (0xfc8ec) D: writing swap status; fa_id=14 off=0xd98f0 (0xfc8f0) D: writing swap status; fa_id=14 off=0xd98f4 (0xfc8f4) D: writing swap status; fa_id=14 off=0xd98f8 (0xfc8f8) D: writing swap status; fa_id=14 off=0xd98fc (0xfc8fc) D: writing swap status; fa_id=14 off=0xd9900 (0xfc900) D: writing swap status; fa_id=14 off=0xd9904 (0xfc904) D: writing swap status; fa_id=14 off=0xd9908 (0xfc908) D: writing swap status; fa_id=14 off=0xd990c (0xfc90c) D: writing swap status; fa_id=14 off=0xd9910 (0xfc910) D: writing swap status; fa_id=14 off=0xd9914 (0xfc914) D: writing swap status; fa_id=14 off=0xd9918 (0xfc918) D: writing swap status; fa_id=14 off=0xd991c (0xfc91c) D: writing swap status; fa_id=14 off=0xd9920 (0xfc920) D: writing swap status; fa_id=14 off=0xd9924 (0xfc924) D: writing swap status; fa_id=14 off=0xd9928 (0xfc928) D: writing swap status; fa_id=14 off=0xd992c (0xfc92c) D: writing swap status; fa_id=14 off=0xd9930 (0xfc930) D: writing swap status; fa_id=14 off=0xd9934 (0xfc934) D: writing swap status; fa_id=14 off=0xd9938 (0xfc938) D: writing swap status; fa_id=14 off=0xd993c (0xfc93c) D: writing swap status; fa_id=14 off=0xd9940 (0xfc940) D: writing swap status; fa_id=14 off=0xd9944 (0xfc944) D: writing swap status; fa_id=14 off=0xd9948 (0xfc948) D: writing swap status; fa_id=14 off=0xd994c (0xfc94c) D: writing swap status; fa_id=14 off=0xd9950 (0xfc950) D: writing swap status; fa_id=14 off=0xd9954 (0xfc954) D: writing swap status; fa_id=14 off=0xd9958 (0xfc958) D: writing swap status; fa_id=14 off=0xd995c (0xfc95c) D: writing swap status; fa_id=14 off=0xd9960 (0xfc960) D: writing swap status; fa_id=14 off=0xd9964 (0xfc964) D: writing swap status; fa_id=14 off=0xd9968 (0xfc968) D: writing swap status; fa_id=14 off=0xd996c (0xfc96c) D: writing swap status; fa_id=14 off=0xd9970 (0xfc970) D: writing swap status; fa_id=14 off=0xd9974 (0xfc974) D: writing swap status; fa_id=14 off=0xd9978 (0xfc978) D: writing swap status; fa_id=14 off=0xd997c (0xfc97c) D: writing swap status; fa_id=14 off=0xd9980 (0xfc980) D: writing swap status; fa_id=14 off=0xd9984 (0xfc984) D: writing swap status; fa_id=14 off=0xd9988 (0xfc988) D: writing swap status; fa_id=14 off=0xd998c (0xfc98c) D: writing swap status; fa_id=14 off=0xd9990 (0xfc990) D: writing swap status; fa_id=14 off=0xd9994 (0xfc994) D: writing swap status; fa_id=14 off=0xd9998 (0xfc998) D: writing swap status; fa_id=14 off=0xd999c (0xfc99c) D: writing swap status; fa_id=14 off=0xd99a0 (0xfc9a0) D: writing swap status; fa_id=14 off=0xd99a4 (0xfc9a4) D: writing swap status; fa_id=14 off=0xd99a8 (0xfc9a8) D: writing swap status; fa_id=14 off=0xd99ac (0xfc9ac) D: writing swap status; fa_id=14 off=0xd99b0 (0xfc9b0) D: writing swap status; fa_id=14 off=0xd99b4 (0xfc9b4) D: writing swap status; fa_id=14 off=0xd99b8 (0xfc9b8) D: writing swap status; fa_id=14 off=0xd99bc (0xfc9bc) D: writing swap status; fa_id=14 off=0xd99c0 (0xfc9c0) D: writing swap status; fa_id=14 off=0xd99c4 (0xfc9c4) D: writing swap status; fa_id=14 off=0xd99c8 (0xfc9c8) D: writing swap status; fa_id=14 off=0xd99cc (0xfc9cc) D: writing swap status; fa_id=14 off=0xd99d0 (0xfc9d0) D: writing swap status; fa_id=14 off=0xd99d4 (0xfc9d4) D: writing swap status; fa_id=14 off=0xd99d8 (0xfc9d8) D: writing swap status; fa_id=14 off=0xd99dc (0xfc9dc) D: writing swap status; fa_id=14 off=0xd99e0 (0xfc9e0) D: writing swap status; fa_id=14 off=0xd99e4 (0xfc9e4) D: writing swap status; fa_id=14 off=0xd99e8 (0xfc9e8) D: writing swap status; fa_id=14 off=0xd99ec (0xfc9ec) D: writing swap status; fa_id=14 off=0xd99f0 (0xfc9f0) D: writing swap status; fa_id=14 off=0xd99f4 (0xfc9f4) D: writing swap status; fa_id=14 off=0xd99f8 (0xfc9f8) D: writing swap status; fa_id=14 off=0xd99fc (0xfc9fc) D: writing swap status; fa_id=14 off=0xd9a00 (0xfca00) D: writing swap status; fa_id=14 off=0xd9a04 (0xfca04) D: writing swap status; fa_id=14 off=0xd9a08 (0xfca08) D: writing swap status; fa_id=14 off=0xd9a0c (0xfca0c) D: writing swap status; fa_id=14 off=0xd9a10 (0xfca10) D: writing swap status; fa_id=14 off=0xd9a14 (0xfca14) D: writing swap status; fa_id=14 off=0xd9a18 (0xfca18) D: writing swap status; fa_id=14 off=0xd9a1c (0xfca1c) D: writing swap status; fa_id=14 off=0xd9a20 (0xfca20) D: writing swap status; fa_id=14 off=0xd9a24 (0xfca24) D: writing swap status; fa_id=14 off=0xd9a28 (0xfca28) D: writing swap status; fa_id=14 off=0xd9a2c (0xfca2c) D: writing copy_done; fa_id=14 off=0xd9fe0 (0xfcfe0) I: Bootloader chainload address offset: 0x23000 I: Jumping to the first image slot*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 *** *** Using Zephyr OS v3.6.99-100befc70c74 *** Memory test passed Device peripherals test passed <inf> fs_nvs: 2 Sectors of 4096 bytes <inf> fs_nvs: alloc wra: 0, fe8 <inf> fs_nvs: data wra: 0, 0 <inf> uart: Loaded 0 timesync pkt <wrn> main: *******NOUS ECG BLE 3.2-debug build time: Nov 3 2024 09:20:20********NORMAL********* <wrn> main: NAND write Address:0x00000000 <wrn> main: NAND mode:0 <wrn> main: Packet_num :1 <inf> peri_led: peri_led init!! <inf> bt_sdc_hci_driver: SoftDevice Controller build revision: d6 da c7 ae 08 db 72 6f 2a a3 26 49 2a 4d a8 b3 |......ro *.&I*M.. 98 0e 07 7f |.... <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002) <inf> bt_hci_core: HW Variant: nRF52x (0x0002) <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 214.51162 Build 1926957230 <inf> bt_hci_core: No ID address. App must call settings_load() <inf> ecg_bluetooth: Bluetooth initialized! <inf> bt_hci_core: Identity: D6:B5:40:32:16:53 (random) <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x11fb, manufacturer 0x0059 <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x11fb <inf> util: Total 1 identities loaded <wrn> util: <Default addr> str: D6:B5:40:32:16:53 (random) <wrn> util: <bonded addr> str: FF:FF:FF:FF:FF:FF (public) <inf> ecg_bluetooth: actual tx_pwr of ADV: 0 <wrn> util: <ECG> BLE adv stopped with err: 0 <wrn> ecg_bluetooth: ECG adv started with name: NousECG 1653! <inf> peri_button: Set up button at gpio@50000000 pin 29 successfully <inf> peri_usb: Set up usb-c detector at gpio@50000000 pin 3 <inf> peri_usb: USB detected:0 <inf> ADS1x9x: ADS SPI, IO init done
<wrn> main: *******NOUS ECG BLE 3.2-debug build time: Nov 3 2024 09:20:20********DFU********* <wrn> main: NAND write Address:0x00000003 <wrn> main: NAND mode:0 <wrn> main: Packet_num :45 <inf> peri_led: peri_led init!! <inf> bt_sdc_hci_driver: SoftDevice Controller build revision: d6 da c7 ae 08 db 72 6f 2a a3 26 49 2a 4d a8 b3 |......ro *.&I*M.. 98 0e 07 7f |.... <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002) <inf> bt_hci_core: HW Variant: nRF52x (0x0002) <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 214.51162 Build 1926957230 <inf> bt_hci_core: No ID address. App must call settings_load() <inf> bt_hci_core: Identity: D6:B5:40:32:16:53 (random) <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x11fb, manufacturer 0x0059 <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x11fb <inf> dfu_bluetooth: DFU adv started with err: 0 <inf> dfu_bluetooth: Bluetooth DFU initialized <inf> bas: BAS Notifications enabled <inf> ecg_bluetooth: Basic Command Notification enabled <inf> ecg_bluetooth: DAT ECG Notification enabled <inf> ecg_bluetooth: DAT System Notification enabled <wrn> bt_l2cap: Ignoring data for unknown channel ID 0x003a <inf> mcuboot_util: Image index: 0, Swap type: none <inf> mcuboot_util: Image index: 0, Swap type: none <err> qspi_nor: pm_device_runtime_put failed: -16 <inf> mcuboot_util: Image index: 0, Swap type: none <inf> mcuboot_util: Image index: 0, Swap type: none <inf> mcuboot_util: Image index: 0, Swap type: perm D: lfclk: Clock started D: RDSR 40 QE 1 need 1: no-change *** Booting My Application v2.1.0-dev-daf2946a0f07 *** *** Using nRF Connect SDK v2.7.0-5cb85570ca43 *** *** Using Zephyr OS v3.6.99-100befc70c74 *** I: Starting bootloader I: Primary image: magic=good, swap_type=0x3, copy_done=0x1, image_ok=0x1 I: Secondary image: magic=good, swap_type=0x3, copy_done=0x3, image_ok=0x1 I: Boot source: none I: Image index: 0, Swap type: perm I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3 I: Secondary image: magic=good, swap_type=0x3, copy_done=0x3, image_ok=0x1 I: Boot source: none I: Starting swap using move algorithm. D: erasing trailer; fa_id=14 D: initializing status; fa_id=14 D: writing swap_info; fa_id=14 off=0xd9fd8 (0xfcfd8), swap_type=0x3 image_num=0x0 D: writing image_ok; fa_id=14 off=0xd9fe8 (0xfcfe8) D: writing swap_size; fa_id=14 off=0xd9fd0 (0xfcfd0) D: writing magic; fa_id=14 off=0xd9ff0 (0xfcff0) D: erasing trailer; fa_id=2 D: writing swap status; fa_id=14 off=0xd93d0 (0xfc3d0) D: writing swap status; fa_id=14 off=0xd93d4 (0xfc3d4) D: writing swap status; fa_id=14 off=0xd93d8 (0xfc3d8) D: writing swap status; fa_id=14 off=0xd93dc (0xfc3dc) D: writing swap status; fa_id=14 off=0xd93e0 (0xfc3e0) D: writing swap status; fa_id=14 off=0xd93e4 (0xfc3e4) D: writing swap status; fa_id=14 off=0xd93e8 (0xfc3e8) D: writing swap status; fa_id=14 off=0xd93ec (0xfc3ec) D: writing swap status; fa_id=14 off=0xd93f0 (0xfc3f0) D: writing swap status; fa_id=14 off=0xd93f4 (0xfc3f4) D: writing swap status; fa_id=14 off=0xd93f8 (0xfc3f8) D: writing swap status; fa_id=14 off=0xd93fc (0xfc3fc) D: writing swap status; fa_id=14 off=0xd9400 (0xfc400) D: writing swap status; fa_id=14 off=0xd9404 (0xfc404) D: writing swap status; fa_id=14 off=0xd9408 (0xfc408) D: writing swap status; fa_id=14 off=0xd940c (0xfc40c) D: writing swap status; fa_id=14 off=0xd9410 (0xfc410) D: writing swap status; fa_id=14 off=0xd9414 (0xfc414) D: writing swap status; fa_id=14 off=0xd9418 (0xfc418) D: writing swap status; fa_id=14 off=0xd941c (0xfc41c) D: writing swap status; fa_id=14 off=0xd9420 (0xfc420) D: writing swap status; fa_id=14 off=0xd9424 (0xfc424) D: writing swap status; fa_id=14 off=0xd9428 (0xfc428) D: writing swap status; fa_id=14 off=0xd942c (0xfc42c) D: writing swap status; fa_id=14 off=0xd9430 (0xfc430) D: writing swap status; fa_id=14 off=0xd9434 (0xfc434) D: writing swap status; fa_id=14 off=0xd9438 (0xfc438) D: writing swap status; fa_id=14 off=0xd943c (0xfc43c) D: writing swap status; fa_id=14 off=0xd9440 (0xfc440) D: writing swap status; fa_id=14 off=0xd9444 (0xfc444) D: writing swap status; fa_id=14 off=0xd9448 (0xfc448) D: writing swap status; fa_id=14 off=0xd944c (0xfc44c) D: writing swap status; fa_id=14 off=0xd9450 (0xfc450) D: writing swap status; fa_id=14 off=0xd9454 (0xfc454) D: writing swap status; fa_id=14 off=0xd9458 (0xfc458) D: writing swap status; fa_id=14 off=0xd945c (0xfc45c) D: writing swap status; fa_id=14 off=0xd9460 (0xfc460) D: writing swap status; fa_id=14 off=0xd9464 (0xfc464) D: writing swap status; fa_id=14 off=0xd9468 (0xfc468) D: writing swap status; fa_id=14 off=0xd946c (0xfc46c) D: writing swap status; fa_id=14 off=0xd9470 (0xfc470) D: writing swap status; fa_id=14 off=0xd9474 (0xfc474) D: writing swap status; fa_id=14 off=0xd9478 (0xfc478) D: writing swap status; fa_id=14 off=0xd947c (0xfc47c) D: writing swap status; fa_id=14 off=0xd9480 (0xfc480) D: writing swap status; fa_id=14 off=0xd9484 (0xfc484) D: writing swap status; fa_id=14 off=0xd9488 (0xfc488) D: writing swap status; fa_id=14 off=0xd948c (0xfc48c) D: writing swap status; fa_id=14 off=0xd9490 (0xfc490) D: writing swap status; fa_id=14 off=0xd9494 (0xfc494) D: writing swap status; fa_id=14 off=0xd9498 (0xfc498) D: writing swap status; fa_id=14 off=0xd949c (0xfc49c) D: writing swap status; fa_id=14 off=0xd94a0 (0xfc4a0) D: writing swap status; fa_id=14 off=0xd94a4 (0xfc4a4) D: writing swap status; fa_id=14 off=0xd94a8 (0xfc4a8) D: writing swap status; fa_id=14 off=0xd94ac (0xfc4ac) D: writing swap status; fa_id=14 off=0xd94b0 (0xfc4b0) D: writing swap status; fa_id=14 off=0xd94b4 (0xfc4b4) D: writing swap status; fa_id=14 off=0xd94b8 (0xfc4b8) D: writing swap status; fa_id=14 off=0xd94bc (0xfc4bc) D: writing swap status; fa_id=14 off=0xd94c0 (0xfc4c0) D: writing swap status; fa_id=14 off=0xd94c4 (0xfc4c4) D: writing swap status; fa_id=14 off=0xd94c8 (0xfc4c8) D: writing swap status; fa_id=14 off=0xd94cc (0xfc4cc) D: writing swap status; fa_id=14 off=0xd94d0 (0xfc4d0) D: writing swap status; fa_id=14 off=0xd94d4 (0xfc4d4) D: writing swap status; fa_id=14 off=0xd94d8 (0xfc4d8) D: writing swap status; fa_id=14 off=0xd94dc (0xfc4dc) D: writing swap status; fa_id=14 off=0xd94e0 (0xfc4e0) D: writing swap status; fa_id=14 off=0xd94e4 (0xfc4e4) D: writing swap status; fa_id=14 off=0xd94e8 (0xfc4e8) D: writing swap status; fa_id=14 off=0xd94ec (0xfc4ec) D: writing swap status; fa_id=14 off=0xd94f0 (0xfc4f0) D: writing swap status; fa_id=14 off=0xd94f4 (0xfc4f4) D: writing swap status; fa_id=14 off=0xd94f8 (0xfc4f8) D: writing swap status; fa_id=14 off=0xd94fc (0xfc4fc) D: writing swap status; fa_id=14 off=0xd97d0 (0xfc7d0) D: writing swap status; fa_id=14 off=0xd97d4 (0xfc7d4) D: writing swap status; fa_id=14 off=0xd97d8 (0xfc7d8) D: writing swap status; fa_id=14 off=0xd97dc (0xfc7dc) D: writing swap status; fa_id=14 off=0xd97e0 (0xfc7e0) D: writing swap status; fa_id=14 off=0xd97e4 (0xfc7e4) D: writing swap status; fa_id=14 off=0xd97e8 (0xfc7e8) D: writing swap status; fa_id=14 off=0xd97ec (0xfc7ec) D: writing swap status; fa_id=14 off=0xd97f0 (0xfc7f0) D: writing swap status; fa_id=14 off=0xd97f4 (0xfc7f4) D: writing swap status; fa_id=14 off=0xd97f8 (0xfc7f8) D: writing swap status; fa_id=14 off=0xd97fc (0xfc7fc) D: writing swap status; fa_id=14 off=0xd9800 (0xfc800) D: writing swap status; fa_id=14 off=0xd9804 (0xfc804) D: writing swap status; fa_id=14 off=0xd9808 (0xfc808) D: writing swap status; fa_id=14 off=0xd980c (0xfc80c) D: writing swap status; fa_id=14 off=0xd9810 (0xfc810) D: writing swap status; fa_id=14 off=0xd9814 (0xfc814) D: writing swap status; fa_id=14 off=0xd9818 (0xfc818) D: writing swap status; fa_id=14 off=0xd981c (0xfc81c) D: writing swap status; fa_id=14 off=0xd9820 (0xfc820) D: writing swap status; fa_id=14 off=0xd9824 (0xfc824) D: writing swap status; fa_id=14 off=0xd9828 (0xfc828) D: writing swap status; fa_id=14 off=0xd982c (0xfc82c) D: writing swap status; fa_id=14 off=0xd9830 (0xfc830) D: writing swap status; fa_id=14 off=0xd9834 (0xfc834) D: writing swap status; fa_id=14 off=0xd9838 (0xfc838) D: writing swap status; fa_id=14 off=0xd983c (0xfc83c) D: writing swap status; fa_id=14 off=0xd9840 (0xfc840) D: writing swap status; fa_id=14 off=0xd9844 (0xfc844) D: writing swap status; fa_id=14 off=0xd9848 (0xfc848) D: writing swap status; fa_id=14 off=0xd984c (0xfc84c) D: writing swap status; fa_id=14 off=0xd9850 (0xfc850) D: writing swap status; fa_id=14 off=0xd9854 (0xfc854) D: writing swap status; fa_id=14 off=0xd9858 (0xfc858) D: writing swap status; fa_id=14 off=0xd985c (0xfc85c) D: writing swap status; fa_id=14 off=0xd9860 (0xfc860) D: writing swap status; fa_id=14 off=0xd9864 (0xfc864) D: writing swap status; fa_id=14 off=0xd9868 (0xfc868) D: writing swap status; fa_id=14 off=0xd986c (0xfc86c) D: writing swap status; fa_id=14 off=0xd9870 (0xfc870) D: writing swap status; fa_id=14 off=0xd9874 (0xfc874) D: writing swap status; fa_id=14 off=0xd9878 (0xfc878) D: writing swap status; fa_id=14 off=0xd987c (0xfc87c) D: writing swap status; fa_id=14 off=0xd9880 (0xfc880) D: writing swap status; fa_id=14 off=0xd9884 (0xfc884) D: writing swap status; fa_id=14 off=0xd9888 (0xfc888) D: writing swap status; fa_id=14 off=0xd988c (0xfc88c) D: writing swap status; fa_id=14 off=0xd9890 (0xfc890) D: writing swap status; fa_id=14 off=0xd9894 (0xfc894) D: writing swap status; fa_id=14 off=0xd9898 (0xfc898) D: writing swap status; fa_id=14 off=0xd989c (0xfc89c) D: writing swap status; fa_id=14 off=0xd98a0 (0xfc8a0) D: writing swap status; fa_id=14 off=0xd98a4 (0xfc8a4) D: writing swap status; fa_id=14 off=0xd98a8 (0xfc8a8) D: writing swap status; fa_id=14 off=0xd98ac (0xfc8ac) D: writing swap status; fa_id=14 off=0xd98b0 (0xfc8b0) D: writing swap status; fa_id=14 off=0xd98b4 (0xfc8b4) D: writing swap status; fa_id=14 off=0xd98b8 (0xfc8b8) D: writing swap status; fa_id=14 off=0xd98bc (0xfc8bc) D: writing swap status; fa_id=14 off=0xd98c0 (0xfc8c0) D: writing swap status; fa_id=14 off=0xd98c4 (0xfc8c4) D: writing swap status; fa_id=14 off=0xd98c8 (0xfc8c8) D: writing swap status; fa_id=14 off=0xd98cc (0xfc8cc) D: writing swap status; fa_id=14 off=0xd98d0 (0xfc8d0) D: writing swap status; fa_id=14 off=0xd98d4 (0xfc8d4) D: writing swap status; fa_id=14 off=0xd98d8 (0xfc8d8) D: writing swap status; fa_id=14 off=0xd98dc (0xfc8dc) D: writing swap status; fa_id=14 off=0xd98e0 (0xfc8e0) D: writing swap status; fa_id=14 off=0xd98e4 (0xfc8e4) D: writing swap status; fa_id=14 off=0xd98e8 (0xfc8e8) D: writing swap status; fa_id=14 off=0xd98ec (0xfc8ec) D: writing swap status; fa_id=14 off=0xd98f0 (0xfc8f0) D: writing swap status; fa_id=14 off=0xd98f4 (0xfc8f4) D: writing swap status; fa_id=14 off=0xd98f8 (0xfc8f8) D: writing swap status; fa_id=14 off=0xd98fc (0xfc8fc) D: writing swap status; fa_id=14 off=0xd9900 (0xfc900) D: writing swap status; fa_id=14 off=0xd9904 (0xfc904) D: writing swap status; fa_id=14 off=0xd9908 (0xfc908) D: writing swap status; fa_id=14 off=0xd990c (0xfc90c) D: writing swap status; fa_id=14 off=0xd9910 (0xfc910) D: writing swap status; fa_id=14 off=0xd9914 (0xfc914) D: writing swap status; fa_id=14 off=0xd9918 (0xfc918) D: writing swap status; fa_id=14 off=0xd991c (0xfc91c) D: writing swap status; fa_id=14 off=0xd9920 (0xfc920) D: writing swap status; fa_id=14 off=0xd9924 (0xfc924) D: writing swap status; fa_id=14 off=0xd9928 (0xfc928) D: writing swap status; fa_id=14 off=0xd992c (0xfc92c) D: writing swap status; fa_id=14 off=0xd9930 (0xfc930) D: writing swap status; fa_id=14 off=0xd9934 (0xfc934) D: writing swap status; fa_id=14 off=0xd9938 (0xfc938) D: writing swap status; fa_id=14 off=0xd993c (0xfc93c) D: writing swap status; fa_id=14 off=0xd9940 (0xfc940) D: writing swap status; fa_id=14 off=0xd9944 (0xfc944) D: writing swap status; fa_id=14 off=0xd9948 (0xfc948) D: writing swap status; fa_id=14 off=0xd994c (0xfc94c) D: writing swap status; fa_id=14 off=0xd9950 (0xfc950) D: writing swap status; fa_id=14 off=0xd9954 (0xfc954) D: writing swap status; fa_id=14 off=0xd9958 (0xfc958) D: writing swap status; fa_id=14 off=0xd995c (0xfc95c) D: writing swap status; fa_id=14 off=0xd9960 (0xfc960) D: writing swap status; fa_id=14 off=0xd9964 (0xfc964) D: writing swap status; fa_id=14 off=0xd9968 (0xfc968) D: writing swap status; fa_id=14 off=0xd996c (0xfc96c) D: writing swap status; fa_id=14 off=0xd9970 (0xfc970) D: writing swap status; fa_id=14 off=0xd9974 (0xfc974) D: writing swap status; fa_id=14 off=0xd9978 (0xfc978) D: writing swap status; fa_id=14 off=0xd997c (0xfc97c) D: writing swap status; fa_id=14 off=0xd9980 (0xfc980) D: writing swap status; fa_id=14 off=0xd9984 (0xfc984) D: writing swap status; fa_id=14 off=0xd9988 (0xfc988) D: writing swap status; fa_id=14 off=0xd998c (0xfc98c) D: writing swap status; fa_id=14 off=0xd9990 (0xfc990) D: writing swap status; fa_id=14 off=0xd9994 (0xfc994) D: writing swap status; fa_id=14 off=0xd9998 (0xfc998) D: writing swap status; fa_id=14 off=0xd999c (0xfc99c) D: writing swap status; fa_id=14 off=0xd99a0 (0xfc9a0) D: writing swap status; fa_id=14 off=0xd99a4 (0xfc9a4) D: writing swap status; fa_id=14 off=0xd99a8 (0xfc9a8) D: writing swap status; fa_id=14 off=0xd99ac (0xfc9ac) D: writing swap status; fa_id=14 off=0xd99b0 (0xfc9b0) D: writing swap status; fa_id=14 off=0xd99b4 (0xfc9b4) D: writing swap status; fa_id=14 off=0xd99b8 (0xfc9b8) D: writing swap status; fa_id=14 off=0xd99bc (0xfc9bc) D: writing swap status; fa_id=14 off=0xd99c0 (0xfc9c0) D: writing swap status; fa_id=14 off=0xd99c4 (0xfc9c4) D: writing swap status; fa_id=14 off=0xd99c8 (0xfc9c8) D: writing swap status; fa_id=14 off=0xd99cc (0xfc9cc) D: writing swap status; fa_id=14 off=0xd99d0 (0xfc9d0) D: writing swap status; fa_id=14 off=0xd99d4 (0xfc9d4) D: writing swap status; fa_id=14 off=0xd99d8 (0xfc9d8) D: writing swap status; fa_id=14 off=0xd99dc (0xfc9dc) D: writing swap status; fa_id=14 off=0xd99e0 (0xfc9e0) D: writing swap status; fa_id=14 off=0xd99e4 (0xfc9e4) D: writing swap status; fa_id=14 off=0xd99e8 (0xfc9e8) D: writing swap status; fa_id=14 off=0xd99ec (0xfc9ec) D: writing swap status; fa_id=14 off=0xd99f0 (0xfc9f0) D: writing swap status; fa_id=14 off=0xd99f4 (0xfc9f4) D: writing swap status; fa_id=14 off=0xd99f8 (0xfc9f8) D: writing swap status; fa_id=14 off=0xd99fc (0xfc9fc) D: writing swap status; fa_id=14 off=0xd9a00 (0xfca00) D: writing swap status; fa_id=14 off=0xd9a04 (0xfca04) D: writing swap status; fa_id=14 off=0xd9a08 (0xfca08) D: writing swap status; fa_id=14 off=0xd9a0c (0xfca0c) D: writing swap status; fa_id=14 off=0xd9a10 (0xfca10) D: writing swap status; fa_id=14 off=0xd9a14 (0xfca14) D: writing swap status; fa_id=14 off=0xd9a18 (0xfca18) D: writing swap status; fa_id=14 off=0xd9a1c (0xfca1c) D: writing swap status; fa_id=14 off=0xd9a20 (0xfca20) D: writing swap status; fa_id=14 off=0xd9a24 (0xfca24) D: writing swap status; fa_id=14 off=0xd9a28 (0xfca28) D: writing swap status; fa_id=14 off=0xd9a2c (0xfca2c) D: writing copy_done; fa_id=14 off=0xd9fe0 (0xfcfe0) I: Bootloader chainload address offset: 0x23000 I: Jumping to the first image slot*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 *** *** Using Zephyr OS v3.6.99-100befc70c74 *** Memory test passed Device peripherals test passed <inf> fs_nvs: 2 Sectors of 4096 bytes <inf> fs_nvs: alloc wra: 0, e20 <inf> fs_nvs: data wra: 0, c7c <inf> main: immediate load: OK. <inf> main: immediate load: OK. <inf> main: immediate load: OK. <inf> main: immediate load: OK. <inf> main: immediate load: OK. <inf> uart: Loaded 5 timesync pkt <wrn> main: *******NOUS ECG BLE 3.2-debug3 build time: Nov 4 2024 11:56:36********NORMAL********* <wrn> main: NAND write Address:0x00000003 <wrn> main: NAND mode:0 <wrn> main: Packet_num :45 <inf> peri_led: peri_led init!! <inf> bt_sdc_hci_driver: SoftDevice Controller build revision: d6 da c7 ae 08 db 72 6f 2a a3 26 49 2a 4d a8 b3 |......ro *.&I*M.. 98 0e 07 7f |.... <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002) <inf> bt_hci_core: HW Variant: nRF52x (0x0002) <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 214.51162 Build 1926957230 <inf> bt_hci_core: No ID address. App must call settings_load() <inf> ecg_bluetooth: Bluetooth initialized! <inf> bt_hci_core: Identity: D6:B5:40:32:16:53 (random) <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x11fb, manufacturer 0x0059 <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x11fb <inf> util: Total 1 identities loaded <wrn> util: <Default addr> str: D6:B5:40:32:16:53 (random) <wrn> util: <bonded addr> str: A0:FB:C5:0E:55:35 (public) <inf> ecg_bluetooth: actual tx_pwr of ADV: 0 <inf> ecg_bluetooth: whitelist err: 0 <wrn> util: <ECG> BLE adv stopped with err: 0 <wrn> ecg_bluetooth: ECG adv started with name: NousECG 1653! <inf> peri_button: Set up button at gpio@50000000 pin 29 successfully <inf> peri_usb: Set up usb-c detector at gpio@50000000 pin 3 <inf> peri_usb: USB detected:0 <inf> ADS1x9x: ADS SPI, IO init done
#include "dfu_bluetooth.h" #include <zephyr/bluetooth/bluetooth.h> #include <zephyr/sys/reboot.h> #include <zephyr/mgmt/mcumgr/mgmt/mgmt.h> #include <zephyr/mgmt/mcumgr/mgmt/callbacks.h> #include <zephyr/dfu/mcuboot.h> #include <zephyr/logging/log.h> #include <zephyr/settings/settings.h> #include "peri_led.h" LOG_MODULE_REGISTER(dfu_bluetooth, 4); static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA(BT_DATA_NAME_COMPLETE, "ECG_DFU", 7), }; static const struct bt_data sd[] = { BT_DATA_BYTES(BT_DATA_UUID128_ALL, 0x84, 0xaa, 0x60, 0x74, 0x52, 0x8a, 0x8b, 0x86, 0xd3, 0x4c, 0xb7, 0x1d, 0x1d, 0xdc, 0x53, 0x8d), }; static void led_timer_cb(struct k_timer *timer_id); K_TIMER_DEFINE(led_timer, led_timer_cb, NULL); static void led_timer_cb(struct k_timer *timer_id) { ARG_UNUSED(timer_id); led_toggle(); k_timer_start(&led_timer, K_MSEC(500), Z_TIMEOUT_NO_WAIT); } void dfu_enter() { int dfu_mode = 1; settings_save_one("dfu", &dfu_mode, sizeof(dfu_mode)); settings_save(); LOG_INF("Reboot to enter DFU mode"); k_sleep(K_MSEC(500)); sys_reboot(SYS_REBOOT_COLD); } struct k_work_delayable dfu_not_started_handler; static enum mgmt_cb_return dfu_mode_cb(uint32_t event, enum mgmt_cb_return prev_status, int32_t *rc, uint16_t *group, bool *abort_more, void *data, size_t data_size) { switch (event) { case MGMT_EVT_OP_IMG_MGMT_DFU_STARTED: LOG_INF("DFU Started"); k_work_reschedule(&dfu_not_started_handler, K_MINUTES(5)); break; case MGMT_EVT_OP_IMG_MGMT_DFU_STOPPED: LOG_INF("DFU Stopped"); sys_reboot(SYS_REBOOT_COLD); break; case MGMT_EVT_OP_IMG_MGMT_DFU_PENDING: LOG_INF("DFU Pending"); break; case MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED: LOG_INF("DFU Confirmed"); break; default: LOG_ERR("Unknown event %d", event); break; } return MGMT_ERR_EOK; } static struct mgmt_callback dfu_mode_mgmt_cb = { .callback = dfu_mode_cb, .event_id = MGMT_EVT_OP_IMG_MGMT_DFU_STARTED | MGMT_EVT_OP_IMG_MGMT_DFU_STOPPED | MGMT_EVT_OP_IMG_MGMT_DFU_PENDING | MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, }; static void exit_dfu_mode(struct k_work *work) { LOG_WRN("DFU did not start or could not complete. Reset to exit dfu mode"); k_sleep(K_MSEC(1000)); sys_reboot(SYS_REBOOT_COLD); } void init_dfu_bluetooth() { // LED initialization moved to @ref peri_led int err = bt_enable(NULL); if (err) { LOG_ERR("Bluetooth init failed (err %d)\n", err); return; } mgmt_callback_register(&dfu_mode_mgmt_cb); settings_load(); err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd)); LOG_INF("DFU adv started with err: %d", err); k_work_init_delayable(&dfu_not_started_handler, exit_dfu_mode); k_work_reschedule(&dfu_not_started_handler, K_MINUTES(5)); k_timer_start(&led_timer, K_MSEC(500), Z_TIMEOUT_NO_WAIT); LOG_INF("Bluetooth DFU initialized\n"); } void dfu_check_boot_image() { if (boot_is_img_confirmed()) { return; } int ret = boot_write_img_confirmed(); if (ret) { LOG_ERR("Couldn't confirm image: %d", ret); } else { LOG_INF("Marked image as OK"); } }