How can I jump to the bootloader from the application without anything BLE related. Possibly through a botton?
I'm on the newest SDK v11.
How can I jump to the bootloader from the application without anything BLE related. Possibly through a botton?
I'm on the newest SDK v11.
In order to jump to the bootloader , you have to add this define in your application project
#define BOOTLOADER_DFU_START 0xB1
and call the following functions when the button is pressed:
if (button_is_pressed)
{
// Write to the the GPREGRET REGISTER and reset the chip
//You can use the sd_-functions
err_code = sd_power_gpregret_set(BOOTLOADER_DFU_START);
APP_ERROR_CHECK(err_code);
sd_nvic_SystemReset();
//OR set the register directly and then call NVIC_SystemReset();
NRF_POWER->GPREGRET = BOOTLOADER_DFU_START;
NVIC_SystemReset();
}
In the bootloader you have to remove the init_softdevice check in ble_stack_init(), i.e.
//if (init_softdevice)
//{
err_code = sd_mbr_command(&com);
APP_ERROR_CHECK(err_code);
//}
-Bjørn
In order to jump to the bootloader , you have to add this define in your application project
#define BOOTLOADER_DFU_START 0xB1
and call the following functions when the button is pressed:
if (button_is_pressed)
{
// Write to the the GPREGRET REGISTER and reset the chip
//You can use the sd_-functions
err_code = sd_power_gpregret_set(BOOTLOADER_DFU_START);
APP_ERROR_CHECK(err_code);
sd_nvic_SystemReset();
//OR set the register directly and then call NVIC_SystemReset();
NRF_POWER->GPREGRET = BOOTLOADER_DFU_START;
NVIC_SystemReset();
}
In the bootloader you have to remove the init_softdevice check in ble_stack_init(), i.e.
//if (init_softdevice)
//{
err_code = sd_mbr_command(&com);
APP_ERROR_CHECK(err_code);
//}
-Bjørn
Are there any restrictions on how many times you can read/write to this register? Or what you set it as? After setting it does it always have to be followed by a reset? What if you want to communicate different reasons why a reset occurred using this register? Can you set it to values of your choice?
Is there documentation on how to use the GPREGRET register?
No, you can write to the GPREGRET (General purpose retention register) at any time and set it to any value. No, writing to the GPREGRET register does not have to be followed by a reset. Since the register is retained during a reset, you can set it to a certain value indicating the reason for the reset and then check it after the device has reset. We do not have any documentation on how to use GPREGRET register.
What would happen if I set the GPREGRET and turn off the device? Will the GPREGRET still retain the data when the device starts up again?
No, the GPREGRET register will not be retained during a Power-on-Reset. Pleas refer section 12.1.19 Reset behavior in the nRF51 Reference Manual, found here.