This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BOOTLOADER_DFU_GPREGRET_MASK

Hi,

I am using NRF52840.

After upgrading to SDK 17, I found that the chuo stays in boot mode because this new condition (I highlighted it in the code below):

  if (NRF_BL_DFU_ENTER_METHOD_GPREGRET/* &&
((nrf_power_gpregret_get() & BOOTLOADER_DFU_GPREGRET_MASK) == BOOTLOADER_DFU_GPREGRET)
&& (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);
}

For the time begin, i simply commented it out. 

What is the intention of this mask and how should it be used?

Thanks,

Alon Barak

Software Engineer

Qcore medical

Parents
  • Hi,

    The GPREGRET register is used for triggering DFU, and it was always the intention that the higher 5 bits are set to a magic value to signal that the lower 3 bits are used for signalling DFU related information. The same goes for GPREGRET2. That way, if the higher 5 bits are NOT set to the magic value, the register can be used by the application for other purposes.

    The intended behaviour can be deduced from the comments in nrf_bootloader_info.h:

    #define BOOTLOADER_DFU_GPREGRET_MASK            (0xF8)      /**< Mask for GPGPREGRET bits used for the magic pattern written to GPREGRET register to signal between main app and DFU. */
    #define BOOTLOADER_DFU_GPREGRET                 (0xB0)      /**< Magic pattern written to GPREGRET register to signal between main app and DFU. The 3 lower bits are assumed to be used for signalling purposes.*/
    #define BOOTLOADER_DFU_START_BIT_MASK           (0x01)      /**< Bit mask to signal from main application to enter DFU mode using a buttonless service. */
    
    #define BOOTLOADER_DFU_GPREGRET2_MASK           (0xF8)      /**< Mask for GPGPREGRET2 bits used for the magic pattern written to GPREGRET2 register to signal between main app and DFU. */
    #define BOOTLOADER_DFU_GPREGRET2                (0xA8)      /**< Magic pattern written to GPREGRET2 register to signal between main app and DFU. The 3 lower bits are assumed to be used for signalling purposes.*/
    #define BOOTLOADER_DFU_SKIP_CRC_BIT_MASK        (0x01)      /**< Bit mask to signal from main application that CRC-check is not needed for image verification. */

    However, in previous versions of the SDK, the 5 higher bits were not properly checked for the magic value, and bit patterns that should not have triggered DFU did so anyway.

    As long as you do not use GPREGRET for other purposes than DFU, removing the check should be totally fine.

    Unfortunately the new check was not implemented in all locations, ref. the discussion in Bug in how bootloader treats GPREGRET, which may be the reason why it is possible to trigger DFU but not completely clean up the GPREGRET register afterwards. The missing checks have previously been reported internally.

    Regards,
    Terje

Reply
  • Hi,

    The GPREGRET register is used for triggering DFU, and it was always the intention that the higher 5 bits are set to a magic value to signal that the lower 3 bits are used for signalling DFU related information. The same goes for GPREGRET2. That way, if the higher 5 bits are NOT set to the magic value, the register can be used by the application for other purposes.

    The intended behaviour can be deduced from the comments in nrf_bootloader_info.h:

    #define BOOTLOADER_DFU_GPREGRET_MASK            (0xF8)      /**< Mask for GPGPREGRET bits used for the magic pattern written to GPREGRET register to signal between main app and DFU. */
    #define BOOTLOADER_DFU_GPREGRET                 (0xB0)      /**< Magic pattern written to GPREGRET register to signal between main app and DFU. The 3 lower bits are assumed to be used for signalling purposes.*/
    #define BOOTLOADER_DFU_START_BIT_MASK           (0x01)      /**< Bit mask to signal from main application to enter DFU mode using a buttonless service. */
    
    #define BOOTLOADER_DFU_GPREGRET2_MASK           (0xF8)      /**< Mask for GPGPREGRET2 bits used for the magic pattern written to GPREGRET2 register to signal between main app and DFU. */
    #define BOOTLOADER_DFU_GPREGRET2                (0xA8)      /**< Magic pattern written to GPREGRET2 register to signal between main app and DFU. The 3 lower bits are assumed to be used for signalling purposes.*/
    #define BOOTLOADER_DFU_SKIP_CRC_BIT_MASK        (0x01)      /**< Bit mask to signal from main application that CRC-check is not needed for image verification. */

    However, in previous versions of the SDK, the 5 higher bits were not properly checked for the magic value, and bit patterns that should not have triggered DFU did so anyway.

    As long as you do not use GPREGRET for other purposes than DFU, removing the check should be totally fine.

    Unfortunately the new check was not implemented in all locations, ref. the discussion in Bug in how bootloader treats GPREGRET, which may be the reason why it is possible to trigger DFU but not completely clean up the GPREGRET register afterwards. The missing checks have previously been reported internally.

    Regards,
    Terje

Children
No Data
Related