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

Having Trouble with Single Bank DFU (NRF51822)

I'm having trouble making a single bank dfu mode with 128k NRF51822 chip.

Here's the problem;

  • Works fine when everything(SoftDevice, Application, Bootloader) is all uploaded. The Application is launched as expected.
  • I used the Nordic Master Control app to upload a new Application to the chip. Upload works fine (using Single Bank DFU boot loader).
  • After the upload process finishes, the bootloader should launch the new Application BUT it seems to stop at the bootloader.
  • If I remove the battery and put it again, the boot loader launches the application as expected and works fine.

This is the main() function of the boot loader. Did some debugging and I think that 'bootloader_app_start(DFU_BANK_0_REGION_START);' doesn't starts as expected.

It would be really thankful if anyone could tell me what I did wrong. Thanks.

    int main(void)
{
   uint32_t err_code;
   //bool     bootloader_is_pushed = false;
      bool     dfu_start = false;
   bool     app_reset = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_START);
       
   leds_init();

   APP_ERROR_CHECK_BOOL(​*((uint32_t *​)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
   APP_ERROR_CHECK_BOOL(NRF_FICR->CODEPAGESIZE == CODE_PAGE_SIZE);

    
   // Initialize.
   timers_init();
   gpiote_init();
   buttons_init();
   ble_stack_init(!app_reset);
   scheduler_init();

        dfu_start  = app_reset;
   dfu_start |= ((nrf_gpio_pin_read(BOOTLOADER_BUTTON_PIN) == 0) ? true: false);

   if (dfu_start || (!bootloader_app_is_valid(DFU_BANK_0_REGION_START)))
   {
       //nrf_gpio_pin_set(LED_2);

       // Initiate an update of the firmware.
       err_code = bootloader_dfu_start();
       APP_ERROR_CHECK(err_code);

       //nrf_gpio_pin_clear(LED_2);
            
            //NRF_POWER->GPREGRET = 0xFF;
   }

    
   if (bootloader_app_is_valid(DFU_BANK_0_REGION_START))
   {
       leds_off();
          
       // Select a bank region to use as application region.
       // @note: Only applications running from DFU_BANK_0_REGION_START is supported.
       bootloader_app_start(DFU_BANK_0_REGION_START);
       
   }

   nrf_gpio_pin_clear(LED_0);
   //nrf_gpio_pin_clear(LED_1);
   //nrf_gpio_pin_clear(LED_2);
   //nrf_gpio_pin_clear(LED_7);
   
   NVIC_SystemReset();
}
Parents
  • Hi, what SDK is this bootloader based on? If your are using one of the newer ones (e.g., version 10.0.0) you only need to replace dfu_dual_bank.c with dfu_single_bank.c, set dfu_types.h->BOOTLOADER_REGION_START = 0x1c000 and recompile with the following memory layout (for xxAB):

    image description

    With the behavior you describe it sounds like the bootloader is not reaching the NVIC_SystemReset(); call in main.c as it should when the application image has been uploaded. I would suggest to try the approach above and see whether you get the same result or not

Reply
  • Hi, what SDK is this bootloader based on? If your are using one of the newer ones (e.g., version 10.0.0) you only need to replace dfu_dual_bank.c with dfu_single_bank.c, set dfu_types.h->BOOTLOADER_REGION_START = 0x1c000 and recompile with the following memory layout (for xxAB):

    image description

    With the behavior you describe it sounds like the bootloader is not reaching the NVIC_SystemReset(); call in main.c as it should when the application image has been uploaded. I would suggest to try the approach above and see whether you get the same result or not

Children
No Data
Related