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
  • you need J-Link to flash bootloader. The Softdevice and the application can be flashed OTA

  • As mentioned, you need to program the chip with a bootloader first in order to enable FW update over USB,etc. Different options for programming the chips in production are summarized in this guide: http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.gs/dita/gs/prod_test_prog.html?cp=1_0_6  

  • Good morning,

    I have suceeded in programming both softdevice and application with J-Flash tool by Segger and ARM flasher. It is perfectly working-

    Now, I want to also include bootloader in order to have BLE-DFU implemented. I have created private_key following steps detailed in DFU_Step_by_step. I have merged bootloader, softdevice and application with J-Flash tool but device is not working. I suppose that it is a problem related with addresses. Is there any explanation showing which addresses to consider for all of this three parts in what regards the nRF52840 device?

    Furthermore, is it required to create the zip file using this?:

    nrfutil pkg generate --hw-version 52 --application-version 1 --application nrf52832_xxaa.hex --sd-req 0x98 --key-file private.key app_dfu_package.zip

    I suppose this is only required when carrying out a BLE-DFU operation, right? 

    Apart of this: in my application I have some preserved data: I have set FDS_VIRTUAL_PAGES to 5 and preserved data is working without Bootloader. Do I have to consider something new with this preserved data when including bootloader? Is re-adressing carried out automatically?

    All the best,

    Dani

  • Hi again,

    I have already found this: I had to create the bootloader setting.

    Now, the application starts working but, when it has to start advertising, it seems to be hung!!!! do you know which can be the reason?

    So,

    - How can I debug my application when bootloader is present?

    - What about preserved data? Have I to consider extra settings when bootloader is present?

    Best regards,

    Dani.

  • Hi Dani,

    Yes, the settings page is needed to tell the bootloader that you have a valid application, it will fall back to DFU mode otherwise. As for debugging the app, you can do that after you've loaded the settings page. Just make sure to disable boot validation option in the settings page to allow the bootloader to boot the app even if it has been modified. 

    Dani said:
    What about preserved data? Have I to consider extra settings when bootloader is present

     FDS automatically detects the presence of the bootloader and places the data below the bootloader instead of placing it at the end of flash, see Memory layout. Also, the NRF_DFU_APP_DATA_AREA_SIZE flag inside the bootloader must correspond to the number of FDS pages allocated by the app to ensure app data is preserved data through DFU. The default is usually 3 pages. 

    Best regards,

    Vidar

  • Hi Vidar,

    Thank you again for your answers.

    Which settings page are you referring to in your last answer?

    Should the 'NRF_DFU_APP_DATA_AREA_SIZE ' parameter also be modified in the 'nrf_dfu_types.h' file when including this file (DFU service) into the application?

    I'm working with Keil...

    Best regards,

    Dani.

  • Hi Dani,

    I was referring to the bootloader settings page. The NRF_DFU_APP_DATA_AREA_SIZE flag is only used by the bootloader. 

    Best regards,

    Vidar

Reply Children
  • Hi Vidar,

    And what about the settings page that is needed to be modified for debugging?

    Where is it? Which settings page are you referring to?

    Best regards,

    Dani

  • I have already found this: I had to create the bootloader setting.

    I'm referring to bootloader settings page that I assume you've created with nrfutil. Nrfutil has an option (as shown in screenshot) to disable boot validation of the app. 

  • Hi Vidar,

    I have succeeded in implementing Buttonless DFU into my prototype and it is working with nRF connect by Nordic: I have created the zip file containing my application and I was able to update the application via DFU using this tool.

    The problem is that it takes more than one minute with DFU in 'initializing' state --> please look at the first screenshot showing this situation. After this minute, it starts transferring the file, and once the file is completely transferred, my device is reseted and new application starts working. So,

    - Why is it taking such a long time initializing? 

    - Is it related to application size (zip file size is 131KB)?

    When DFU procedure is working, what does it mean? Is it refering to BLE transfer or to the new application transfer inside device memory?

    Best regards,

    Dani.

  • Hi Dani,

    It should only take a few seconds to pre-validate the update and get started on the transfer. Maybe the buttonless implementation is not transferring execution to the bootloader right away and thus delaying the transfer start? Or do you see the same if you start DFU when the device is already in bootloader DFU mode?

  • 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.

Related