Skip to content

Instantly share code, notes, and snippets.

@fanoush
Created September 21, 2020 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fanoush/da2194ffce6c8d8ee44424cbaf768145 to your computer and use it in GitHub Desktop.
Save fanoush/da2194ffce6c8d8ee44424cbaf768145 to your computer and use it in GitHub Desktop.
diff --git a/targetlibs/nrf5x_12/components/libraries/bootloader/dfu/nrf_dfu_utils.c b/targetlibs/nrf5x_12/components/libraries/bootloader/dfu/nrf_dfu_utils.c
index 6da88aa9..5ba66f3d 100644
--- a/targetlibs/nrf5x_12/components/libraries/bootloader/dfu/nrf_dfu_utils.c
+++ b/targetlibs/nrf5x_12/components/libraries/bootloader/dfu/nrf_dfu_utils.c
@@ -461,10 +461,11 @@ uint32_t nrf_dfu_continue(uint32_t * p_enter_dfu_mode)
bool nrf_dfu_app_is_valid(void)
{
NRF_LOG_INFO("Enter nrf_dfu_app_is_valid\r\n");
- if (s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_VALID_APP &&
+ if (s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_VALID_APP ^M
//* VALID_APP FIX START *//
- s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_INVALID) // meh. Allows us to work without bootloader_settings
+ // && s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_INVALID // meh. Allows us to work without bootloader_settings^M
//* VALID_APP FIX END *//
+ )^M
{
// Bank 0 has no valid app. Nothing to boot
NRF_LOG_INFO("Return false in valid app check\r\n");
diff --git a/targets/nrf5x_dfu/main.c b/targets/nrf5x_dfu/main.c
index 21018459..11c91836 100644
--- a/targets/nrf5x_dfu/main.c
+++ b/targets/nrf5x_dfu/main.c
@@ -90,7 +90,9 @@ bool nrf_dfu_enter_check(void) {
// dfu_enter_check must be modified to add the __WEAK keyword
bool dfu_enter_check(void) {
#endif
+
bool dfu_start = get_btn1_state();
+ if (NRF_POWER->GPREGRET == 1) { NRF_POWER->GPREGRET=0; return true; }
#ifdef BUTTONPRESS_TO_REBOOT_BOOTLOADER
// if DFU looks invalid, go straight to bootloader
if (s_dfu_settings.bank_0.bank_code == NRF_DFU_BANK_INVALID) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment