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

Flashing custom nRF52 (Bootloader, SoftDevice, Application)

Good morning,

Is it always required to use Segger J-Link in order to flash Bootloader, Softdevice and Application to a new device?

Could you summarize the different possibilities we have to flash any of these parts?

Furthermore, and regarding the nRF52840: is it possible to use the USB port to flash the device?

Best regards.

Parents Reply Children
  • Hi Vidar,

    I have implemented DFU in the same way the 'Buttonless_dfu' is implement. My doubt is related to the 'app_shutdown_handler'. Shoult I have to modify it? Now it is in the following way:

    static bool app_shutdown_handler(nrf_pwr_mgmt_evt_t event)
    {
        switch (event)
        {
            case NRF_PWR_MGMT_EVT_PREPARE_DFU:
                NRF_LOG_INFO("Power management wants to reset to DFU mode.");
                // YOUR_JOB: Get ready to reset into DFU mode
                //
                // If you aren't finished with any ongoing tasks, return "false" to
                // signal to the system that reset is impossible at this stage.
                //
                // Here is an example using a variable to delay resetting the device.
                //
                // if (!m_ready_for_reset)
                // {
                //      return false;
                // }
                // else
                //{
                //
                //    // Device ready to enter
                //    uint32_t err_code;
                //    err_code = sd_softdevice_disable();
                //    APP_ERROR_CHECK(err_code);
                //    err_code = app_timer_stop_all();
                //    APP_ERROR_CHECK(err_code);
                //}
                break;
    
            default:
                // YOUR_JOB: Implement any of the other events available from the power management module:
                //      -NRF_PWR_MGMT_EVT_PREPARE_SYSOFF
                //      -NRF_PWR_MGMT_EVT_PREPARE_WAKEUP
                //      -NRF_PWR_MGMT_EVT_PREPARE_RESET
                return true;
        }
    
        NRF_LOG_INFO("Power management allowed to reset to DFU mode.");
        return true;
    }

    Apart of this, for DFU I have APP_ADV_INTERVAL set to 80 and APP_ADV_DURATION to 200 (same values as in my application).And in my application, advertising is done every 10s.  Should this values cause any problem?

    Best regards,

    Dani.

  • Some more information: When I'm using nRF Connect desktop application, it seems that Bootloader do not enter until this 1-minute wait: once DFU is started application continues working normally (nRFConnect, says 'Initializing' -DFU) during this 1-minute. After that time, application is updated succesfully.

    On the other hand, when I use Android application, it seems the Bootloader enters just after DFU  button is pushed (application is not working): but then, application remains in 'Connecting...' for about 1-minute. After that time, application seems to be updated and it starts running again (Reset is carried out).

  • Try to change the app_shutdown_handler() implementation so it always return true on NRF_PWR_MGMT_EVT_PREPARE_DFU, then try again with nRF connect for desktop and see if it still takes a minute to get into DFU mode. 

  • The same: around 1 minute. In fact, according the code I have specified above, this function was already returning true.

    Furthermore: In my application (when connected) a characteristic sends notifications once every 250ms. With nRF connect (Desktop), if this notifications are enabled, DFU initializing time is practically halved. If notifications are not enabled, time for DFU initialization is around 1m

  • Dani said:
    In fact, according the code I have specified above, this function was already returning true

    When is the m_ready_for_reset flag set?

Related