Skip to content

Commit 142b339

Browse files
committed
boot: introduce MCUBOOT_CPU_IDLE() for support low power single thread
Introduced MCUBOOT_CPU_IDLE() macro. If a port supports single thread or is bare-metal then might be need to switch to idle mode explicitly form MCUboot code. The call allows to enable lower power consumption while waiting for incoming transmission in serial recovery etc. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
1 parent d5e9902 commit 142b339

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

boot/cypress/MCUBootApp/config/mcuboot_config/mcuboot_config.h

+7
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,11 @@
152152
#define NUM_ECC_BYTES (256 / 8)
153153
#endif /* ENC_IMG */
154154

155+
/*
156+
* No direct idle call implemented
157+
*/
158+
#define MCUBOOT_CPU_IDLE() \
159+
do { \
160+
} while (0)
161+
155162
#endif /* MCUBOOT_CONFIG_H */

boot/mbed/include/mcuboot_config/mcuboot_config.h

+6
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,11 @@
7979
do { \
8080
} while (0)
8181

82+
/*
83+
* No direct idle call implemented
84+
*/
85+
#define MCUBOOT_CPU_IDLE() \
86+
do { \
87+
} while (0)
8288

8389
#endif /* __MCUBOOT_CONFIG_H__ */

boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h

+7
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,11 @@
101101
#define MCUBOOT_WATCHDOG_FEED() do {} while (0)
102102
#endif
103103

104+
/*
105+
* No direct idle call implemented
106+
*/
107+
#define MCUBOOT_CPU_IDLE() \
108+
do { \
109+
} while (0)
110+
104111
#endif /* __MCUBOOT_CONFIG_H__ */

boot/zephyr/include/mcuboot_config/mcuboot_config.h

+5
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,9 @@
205205

206206
#endif /* CONFIG_BOOT_WATCHDOG_FEED */
207207

208+
#define MCUBOOT_CPU_IDLE() \
209+
if (!IS_ENABLED(CONFIG_MULTITHREADING)) { \
210+
k_cpu_idle(); \
211+
}
212+
208213
#endif /* __MCUBOOT_CONFIG_H__ */

samples/mcuboot_config/mcuboot_config.template.h

+10
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,14 @@
146146
* do { do watchdog feeding here! } while (0)
147147
*/
148148

149+
/* If a OS ports support single thread mode or is bare-metal then:
150+
* This macro implements call that switches CPU to an idle state, from which
151+
* the CPU may be woken up by, for example, UART transmission event.
152+
*
153+
* Otherwise this macro should be no-op.
154+
*/
155+
#define MCUBOOT_CPU_IDLE() \
156+
do { \
157+
} while (0)
158+
149159
#endif /* __MCUBOOT_CONFIG_H__ */

0 commit comments

Comments
 (0)