This has been noted a couple of times but your treatment of bit fields is just wrong in the bootloader. It not only disagrees with the documentation but it's so flawed that it interferes with valid gpregret operations and consistent upgrade techniques. Can you please please look into this? I'm including my recommended changes here. I think you could argue the first two, although not convincingly. The third is just wrong - it's not checking the bit fields correctly.
Thank you,
Mark
diff --git a/components/libraries/bootloader/nrf_bootloader.c b/components/libraries/bootloader/nrf_bootloader.c
index 19bdc9c9..4d2e59ed 100644
--- a/components/libraries/bootloader/nrf_bootloader.c
+++ b/components/libraries/bootloader/nrf_bootloader.c
@@ -246,7 +246,7 @@ static bool crc_on_valid_app_required(void)
((nrf_power_gpregret2_get() & BOOTLOADER_DFU_GPREGRET2_MASK) == BOOTLOADER_DFU_GPREGRET2)
&& (nrf_power_gpregret2_get() & BOOTLOADER_DFU_SKIP_CRC_BIT_MASK))
{
- nrf_power_gpregret2_set(nrf_power_gpregret2_get() & ~BOOTLOADER_DFU_SKIP_CRC);
+ nrf_power_gpregret2_set(nrf_power_gpregret2_get() & ~BOOTLOADER_DFU_SKIP_CRC_BIT_MASK);
ret = false;
}
else
@@ -332,7 +332,7 @@ static void dfu_enter_flags_clear(void)
&& (nrf_power_gpregret_get() & BOOTLOADER_DFU_START_BIT_MASK))
{
// Clear DFU mark in GPREGRET register.
- nrf_power_gpregret_set(nrf_power_gpregret_get() & ~BOOTLOADER_DFU_START);
+ nrf_power_gpregret_set(nrf_power_gpregret_get() & ~BOOTLOADER_DFU_START_BIT_MASK);
}
if (NRF_BL_DFU_ENTER_METHOD_BUTTONLESS &&
@@ -370,7 +370,8 @@ static bool dfu_enter_check(void)
}
if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &&
- (nrf_power_gpregret_get() & BOOTLOADER_DFU_START))
+ ((nrf_power_gpregret_get() & BOOTLOADER_DFU_GPREGRET_MASK) == BOOTLOADER_DFU_GPREGRET)
+ && (nrf_power_gpregret_get() & BOOTLOADER_DFU_START_BIT_MASK))
{
NRF_LOG_DEBUG("DFU mode requested via GPREGRET.");
return true;