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

How to switch to bootloader when OTA?

Hi,

I'm using nRF5_SDK_12.2.0_f012efa and s132_nrf52_3.0.0_softdevice. We want to do the OTA on it. However, I found that there is no DFU service in the HRS example.If I want to switch to the bootloader in the application like HRS example in nRF5_SDK_11, so that it can easily swith to bootloader using APP instead of using button. what example could I refer to? Could you give me some advice? Thanks.

Best regards, Alice

Parents
  • Hi Alice, Please find the example in \examples\ble_peripheral\experimental_ble_app_buttonless_dfu\ instead.

    Note that you would need to add the write properties as described here.

  • Hi Hung, now I can use nRF Connect in IOS to write the characteristic(write 0x01 value) to make it switch to bootloader. I do it as follow, in the ble_dfu_evt_handler function, I will write the GPREGRET register: case BLE_DFU_EVT_ENTERING_BOOTLOADER: sd_power_gpregret_set(0,0xB1); NVIC_SystemReset(); printf("Device is entering bootloader mode!\r\n"); break; Then in the bootloader, I will check the GPREGRET register in nrf_dfu_enter_check() function:

    __WEAK bool nrf_dfu_enter_check(void)
    

    {

    	if(NRF_POWER->GPREGRET==0x01)	
    	{	
    		NRF_POWER->GPREGRET =0x00;		
    		return true;
    	}
    
    if (nrf_gpio_pin_read(BOOTLOADER_BUTTON) == 0)
    {
        return true;
    }
    
    if (s_dfu_settings.enter_buttonless_dfu == 1)
    {
        s_dfu_settings.enter_buttonless_dfu = 0;
        (void)nrf_dfu_settings_write(NULL);
        return true;
    }
    return false;
    

    }

    After that, it will switch to bootloader and then update the fireware. However, the DFU app in the nRF Toolbox cann't make it switch to bootloader. If I want to use it to make it switch to bootloader, what should I do? Could I use the APP to do OTA?

Reply
  • Hi Hung, now I can use nRF Connect in IOS to write the characteristic(write 0x01 value) to make it switch to bootloader. I do it as follow, in the ble_dfu_evt_handler function, I will write the GPREGRET register: case BLE_DFU_EVT_ENTERING_BOOTLOADER: sd_power_gpregret_set(0,0xB1); NVIC_SystemReset(); printf("Device is entering bootloader mode!\r\n"); break; Then in the bootloader, I will check the GPREGRET register in nrf_dfu_enter_check() function:

    __WEAK bool nrf_dfu_enter_check(void)
    

    {

    	if(NRF_POWER->GPREGRET==0x01)	
    	{	
    		NRF_POWER->GPREGRET =0x00;		
    		return true;
    	}
    
    if (nrf_gpio_pin_read(BOOTLOADER_BUTTON) == 0)
    {
        return true;
    }
    
    if (s_dfu_settings.enter_buttonless_dfu == 1)
    {
        s_dfu_settings.enter_buttonless_dfu = 0;
        (void)nrf_dfu_settings_write(NULL);
        return true;
    }
    return false;
    

    }

    After that, it will switch to bootloader and then update the fireware. However, the DFU app in the nRF Toolbox cann't make it switch to bootloader. If I want to use it to make it switch to bootloader, what should I do? Could I use the APP to do OTA?

Children
No Data
Related