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

BLE doesn't enter into DFU/OTA mode.

Dear Team,

Greetings !!!

Device - nRF52832
Softdevice - s132_nrf52_6.0.0
IDE - segger embedded studio
Bootloader - secure bootloader

In our current application, We are using hardware watchdog timer which timeout is 2 sec. It means we are sending continuous pulses to watch dog timer using app timer. If watch dog timer does not get pulses for 2 seconds then it will reset the device. It works perfectly for our application without DFU/OTA.

I have followed the DFU procedure as per nordic application note and it works perfectly without hardware watchdog timer. The problem causes with Hardware WDT.

First, i download the secure bootloader in our device and browse the .zip file then application is successfully updated into the device. The problem occured when i tried to jump into secure bootloader from application, it does not jump into boot loader and device get reset. In short, i could not enter into the DFU mode further.

Your quick reply would be highly appreciated.

Thanks

Parents
  • Hi Prajapati, 

    since you are using S132 v6.0.0, can i assume that you are using SDK v15.0.0?

    have followed the DFU procedure as per nordic application note and it works perfectly without hardware watchdog timer. The problem causes with Hardware WDT.

    First, i download the secure bootloader in our device and browse the .zip file then application is successfully updated into the device. The problem occured when i tried to jump into secure bootloader from application, it does not jump into boot loader and device get reset. In short, i could not enter into the DFU mode further.

    It is important to note that the jump from the application to the bootloader is done by writting a specific value to the GPREGRET register, then performing a soft reset and then examining the  GPREGRET register in the bootloader code, which will always execute before the application. The WDT is __not__ reset through a soft reset so it will still be running in the BL when jumping from the application. 

    The bootloader in SDK v15.x.x should detect whether the WDT is running or not and start a timer that reloads the WDT at an interval lower that the timeout interval. 

    However, it could be that a 2 second WDT timeout is to short for the bootloader to exmine the WDT registers and start the timer. Hence, my suggestion would be to either increase the WDT timeout interval and see if that helps or reload the WDT immediatly upon entering the bootloader to give it time to start the timer. 

    Best regards

    Bjørn

  • Thanks for your quick reply,

    The problem is that WDT enable pin is not controlled by the nRF52832. It is enabled by the external supply so it will be ON for all time.


    I disabled the "CONFIG_GPIO_AS_PINRESET" in bootloader code and i succeed to do DFU. But if i tried to go into bootloader from the application then my device resets every time and can not enter into bootloader.

    Then i disabled the same macro in both firmwares then everything works fine. But the problem is that my device does not reset  by WDT as RESET pin is disconnected.

    I have also tried to change the RESET pin number in bootloader code but can't get any success.

    Can you suggest me any fruitful approach regarding the RESET pin to solve this issue?

    Its very urgent to solve this.
    Please give your answer ASAP
    Your quick reply would be highly appreciated!!!

    Thanks

  • Prajapati said:
    The problem is that WDT enable pin is not controlled by the nRF52832. It is enabled by the external supply so it will be ON for all time.

     Have you configured a GPIO on the nRF52832 to turn on the WDT if it is high? 

    Prajapati said:
    Then i disabled the same macro in both firmwares then everything works fine. But the problem is that my device does not reset  by WDT as RESET pin is disconnected.

    Yes, the CONFIG_GPIO_AS_PINRESET preprocessor definition must be removed in both application and bootloader if you do not want to use pin 21 as the reset pin. The WDT should reset the nRF52832 when it times out regardless if the RESET pin is enabled or not. Note that the bootloader will feed the WDT automatically,search for nrf_bootloader_wdt_feed() in the bootloader project, but there should be an inactivity timeout that causes the bootloader to jump to the application if no central starts the DFU procedure. 

    The timeout value of this timer can be adjusted by changing NRF_BL_DFU_INACTIVITY_TIMEOUT_MS in sdk_config.h in the bootloader.

    Prajapati said:
    I have also tried to change the RESET pin number in bootloader code but can't get any success.

     It is only pin 21 that has the RESET functionality routed to it, so this is the only pin that can be used as a reset pin. Trying to set other pins at the reset pin will have no effect. 

     Best regards

    Bjørn

  • I want to use pin21 as reset in my application code. I also want to disable or change the reset pin in bootloader code. So when my device enter into bootloader code device will not reset even though the WDT timeout happened. When my device will enter into application code i will reconfigure pin21 as reset pin.

    The above scenario is possible or not?
     
    How to reconfigure the pin 21 as reset pin in main code? 

Reply
  • I want to use pin21 as reset in my application code. I also want to disable or change the reset pin in bootloader code. So when my device enter into bootloader code device will not reset even though the WDT timeout happened. When my device will enter into application code i will reconfigure pin21 as reset pin.

    The above scenario is possible or not?
     
    How to reconfigure the pin 21 as reset pin in main code? 

Children
  • It is possible, but is a very risky approach as you will have to erase the UICR registers in order to re-configure the reset pin. 

    The UICR registers hold the start address for the bootloader which is used by the MBR on boot to jump to the bootloaders vector table. So this means that you will have to readback the UICR registers, modify the PSELRESET register values, erase the UICR registers and then write all the UICR registeres back.  So if there is a power failure during this procedure, specifically during the part where the UICR values are written back to the registers, then you potentially of bricking the device if the write does not complete successfully as the MBR will then jump to the address in the bootloader start address register if its not 0xFFFFFFFF.

    My recommendation would be to not do this and have the reset pin enabled on pin 21 in both bootloader and application. 

    Best regards

    Bjørn

  • Thanks for the quick response
    Is there any approach i can follow?

    currently i am trying to add a Timer to reset the external bootloader at 1 sec through GPIO(high pulse).

    This is what i have done in my application code, and works perfectly.

    But trying out this in bootloader code switched off the BLE advt.

    let me know how can i modify the bootloader code to achieve the above desired effect.

  • The code below should read back the UICR registers and I have marked the section where you should modify the values. Again, apply this at your own risk. 

        // Storage buffers and variables to hold the UICR register content
        static uint32_t uicr_buffer[59]    = {0x00000000};
        static uint32_t pselreset_0        = 0x00000000;
        static uint32_t pselreset_1        = 0x00000000;
        static uint32_t approtect          = 0x00000000;
        static uint32_t nfcpins            = 0x00000000;
        
        CRITICAL_REGION_ENTER();
      
        // Read and buffer UICR register content prior to erase
        uint32_t uicr_address = 0x10001014;
    
        for(int i = 0; i<sizeof(uicr_buffer); i++)
        {
            uicr_buffer[i] = *(uint32_t *)uicr_address; 
            while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
            // Set UICR address to the next register
            uicr_address += 0x04;
        }
      
        pselreset_0 = NRF_UICR->PSELRESET[0];
        pselreset_1 = NRF_UICR->PSELRESET[1];
        approtect   = NRF_UICR->APPROTECT;
        nfcpins     = NRF_UICR->NFCPINS;
        
        //Modify UICR values here
        
       
        // Enable Erase mode
        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos; //0x02; 
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
        
        // Erase the UICR registers
        NRF_NVMC->ERASEUICR = NVMC_ERASEUICR_ERASEUICR_Erase << NVMC_ERASEUICR_ERASEUICR_Pos; //0x00000001;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
       
        // Enable WRITE mode
        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; //0x01;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    
        // Write the modified UICR content back to the UICR registers 
        uicr_address = 0x10001014;
        for(int j = 0; j<sizeof(uicr_buffer); j++)
        {
            // Skip writing to registers that were 0xFFFFFFFF before the UICR register were erased. 
            if(uicr_buffer[j] != 0xFFFFFFFF)
            {
                *(uint32_t *)uicr_address = uicr_buffer[j];
                // Wait untill the NVMC peripheral has finished writting to the UICR register
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}                
            }
            // Set UICR address to the next register
            uicr_address += 0x04;  
        }
    
        NRF_UICR->PSELRESET[0]  = pselreset_0;
        NRF_UICR->PSELRESET[1]  = pselreset_1;
        NRF_UICR->APPROTECT     = approtect;
        NRF_UICR->NFCPINS       = nfcpins;
    
        CRITICAL_REGION_EXIT();

     

    Prajapati said:

    currently i am trying to add a Timer to reset the external bootloader at 1 sec through GPIO(high pulse).

    This is what i have done in my application code, and works perfectly.

    But trying out this in bootloader code switched off the BLE advt.

     So the bootloader should set a GPIO high after one second to reset an external chip?

Related