File tree Expand file tree Collapse file tree 3 files changed +36
-7
lines changed
samples/subsys/mgmt/updatehub/src Expand file tree Collapse file tree 3 files changed +36
-7
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2018-2020 O.S.Systems
2
+ * Copyright (c) 2018-2023 O.S.Systems
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
10
10
#include <zephyr/net/net_event.h>
11
11
#include <zephyr/net/net_conn_mgr.h>
12
12
#include <zephyr/net/wifi_mgmt.h>
13
- #include <zephyr/dfu/mcuboot.h>
14
13
15
14
#if defined(CONFIG_UPDATEHUB_DTLS )
16
15
#include <zephyr/net/tls_credentials.h>
@@ -45,7 +44,7 @@ void start_updatehub(void)
45
44
switch (updatehub_update ()) {
46
45
case UPDATEHUB_OK :
47
46
ret = 0 ;
48
- sys_reboot ( SYS_REBOOT_WARM );
47
+ updatehub_reboot ( );
49
48
break ;
50
49
51
50
default :
@@ -110,7 +109,7 @@ void main(void)
110
109
111
110
/* The image of application needed be confirmed */
112
111
LOG_INF ("Confirming the boot image" );
113
- ret = boot_write_img_confirmed ();
112
+ ret = updatehub_confirm ();
114
113
if (ret < 0 ) {
115
114
LOG_ERR ("Error to confirm the image" );
116
115
}
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2018 O.S.Systems
2
+ * Copyright (c) 2018-2023 O.S.Systems
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
@@ -69,6 +69,23 @@ enum updatehub_response updatehub_probe(void);
69
69
*/
70
70
enum updatehub_response updatehub_update (void );
71
71
72
+ /**
73
+ * @brief Confirm that image is running as expected.
74
+ *
75
+ * @details Must be used before the UpdateHub probe. It should be one of first
76
+ * actions after reboot.
77
+ *
78
+ * @return Return 0 if success otherwise a negative @errorno value.
79
+ */
80
+ int updatehub_confirm (void );
81
+
82
+ /**
83
+ * @brief Request system to reboot.
84
+ *
85
+ * @return Return 0 if success otherwise a negative @errorno value.
86
+ */
87
+ int updatehub_reboot (void );
88
+
72
89
/**
73
90
* @}
74
91
*/
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ LOG_MODULE_REGISTER(updatehub, CONFIG_UPDATEHUB_LOG_LEVEL);
19
19
#include <zephyr/drivers/flash.h>
20
20
#include <zephyr/sys/reboot.h>
21
21
#include <zephyr/data/json.h>
22
+ #include <zephyr/dfu/mcuboot.h>
22
23
#include <zephyr/storage/flash_map.h>
23
24
24
25
#include "include/updatehub.h"
@@ -762,6 +763,18 @@ static void probe_cb(char *metadata, size_t metadata_size)
762
763
LOG_INF ("Probe metadata received" );
763
764
}
764
765
766
+ int updatehub_confirm (void )
767
+ {
768
+ return boot_write_img_confirmed ();
769
+ }
770
+
771
+ int updatehub_reboot (void )
772
+ {
773
+ sys_reboot (SYS_REBOOT_WARM );
774
+
775
+ return 0 ;
776
+ }
777
+
765
778
enum updatehub_response updatehub_probe (void )
766
779
{
767
780
struct probe request ;
@@ -985,14 +998,14 @@ static void autohandler(struct k_work *work)
985
998
"confirmed image." );
986
999
987
1000
LOG_PANIC ();
988
- sys_reboot ( SYS_REBOOT_WARM );
1001
+ updatehub_reboot ( );
989
1002
break ;
990
1003
991
1004
case UPDATEHUB_HAS_UPDATE :
992
1005
switch (updatehub_update ()) {
993
1006
case UPDATEHUB_OK :
994
1007
LOG_PANIC ();
995
- sys_reboot ( SYS_REBOOT_WARM );
1008
+ updatehub_reboot ( );
996
1009
break ;
997
1010
998
1011
default :
You can’t perform that action at this time.
0 commit comments