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

Passing data from bootloader to app via GPREGRET

Problem: I use a button with a pull-up to wake up the device (nrf52832) from power_off, but by the time the bootloader verifies the application and jumps, the button may have been already released, and the application can't detect that the button is what woke up the device.

Since the bootloader is fast enough to capture that button press, I'd like to pass a "the button was down when I woke up" flag from the bootloader to the application using GPREGRET, like so:

if(button_was_down){
    	uint32_t temp = NRF_POWER->GPREGRET2;
    	temp |= 0x80000000;
    	NRF_POWER->GPREGRET2 = temp;//set the MSB
    }

This code executes before nrf_bootloader_init(). However, the application always reads GPREGRET2 as 0x00000000:

printf("gpregret2: %lx\r\n", NRF_POWER->GPREGRET2);

produces this output:

gpregret2: 0

Am I somehow using the GPREGRET incorrectly? I did notice that nrf_dfu clears out GPREGRET, which is why I'm trying to use GPREGRET2.

As an aside, why does the bootloader take so long to run, anyway?

Parents Reply Children
No Data
Related