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

Bug in hal_device_reset()

Hi,

It seems to be a bug in hal_device_reset() when using S132.

void hal_device_reset(uint8_t gpregret_value)
{
#if defined(SOFTDEVICE_PRESENT)
    (void) sd_power_reset_reason_clr(RESET_REASON_MASK); /* avoid wrongful state-readout on reboot */
#if defined(S130) || defined(S110)
    (void) sd_power_gpregret_set(gpregret_value);
#elif defined(S132)
    (void) sd_power_gpregret_set(gpregret_value, RESET_REASON_MASK);
#endif
    (void) sd_nvic_SystemReset();
#else
    NRF_POWER->RESETREAS = RESET_REASON_MASK; /* avoid wrongful state-readout on reboot */
    NRF_POWER->GPREGRET = gpregret_value;
    NVIC_SystemReset();
#endif
    NRF_MESH_ASSERT(false);
}

On line 8 above the function sd_power_gpregret_set() is called with the wrong arguments. The first arguments should be either 0 or 1 to select between GPREGRET and GPREGRET2, the second argument should be the bits to set.

So instead of setting GPREGRET to gpregret_value, either one of the two registers or none at all is set to RESET_REASON_MASK (0xFFFFFFFF).

This bug seem to exist in v3.0.0 back to v1.0.0.

Changing line 8 to (void) sd_power_gpregret_set(0, gpregret_value); solves the problem and the correct value is written to the register.

Thanks.

Parents
  • Hi.

    The developer does not want to change the implementation at this stage, but he suggest changing the documentation to the following in a future release:

    For S110/S130 SoftDevice this API will set the indicated bits of the GPREGRET register. For S132 SoftDevice, this API will set the indicated bits of the GPREGRET0 register.

    Thanks for the input.

    Best regards,

    Andreas

Reply
  • Hi.

    The developer does not want to change the implementation at this stage, but he suggest changing the documentation to the following in a future release:

    For S110/S130 SoftDevice this API will set the indicated bits of the GPREGRET register. For S132 SoftDevice, this API will set the indicated bits of the GPREGRET0 register.

    Thanks for the input.

    Best regards,

    Andreas

Children
No Data
Related