This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

sd130 and sdk12.1.0 ble bootloader problem

I'm sorry. I closed this question and can't reopen. I need more answer. If I solve all problem I'll close this question.

As you mentioned I'll try HW version modification. And I'll add the result.


Hello,

I have some problem in DFU. I ask this again. I did as below.

  1. private key generation nrfutil keys generate c:\vault\priv.pem

  2. public key generation in code format nrfutil keys display --key pk --format hex c:\vault\priv.pem nrfutil keys display --key pk --format code c:\vault\priv.pem nrfutil keys display --key pk --format code c:\vault\priv.pem --out_file dfu_public_key.c

  3. experimental_ble_app_buttonless_dfu project compile and package file make nrfutil pkg generate --hw-version 1 --sd-req 0x87 --application-version 4 --application nrf51422_xxac.hex --key-file key.pem app_dfu_package.zip

  4. bootloader_secure compile with dfu_public_key.c(made in process 2) and bootloader setting file make nrfutil settings generate --family NRF51--application nrf51422_xxac.hex --application-version 3 --bootloader-version 2 --bl-settings-version 1 settings.hex

  5. merge bootloader and settings hex file mergehex -m nrf51422_xxac_s130 settings.hex -o output_file.hex

  6. SD130 / output_file.hex program into PCA10028 Board after erase all

  7. I try DFU in android phone. I can see DfuTarg. But, It fails to DFU app_dfu_package.zip(made in process 3).

What’s wrong? I don’t know.

**I want DFU process as below.

  1. my application run when power on
  2. bootloader enter(using buttonless_dfu projecs - Already I merged with my application.) after some key input (This key is in my custom board.)
  3. upload my new F/W using bootloader_secure in android phone.
  4. my new application run again after DFU done.**

I need your help eagerly.

  • Thanks, I saw the DFU works after doing as you mentioned(set the --hw-version to 51 and not 1).

    Now, How should I modify buttonless_dfu projecs If I want to do as below?

    1. my application run when power on
    2. bootloader enter(using buttonless_dfu projecs , Already I merged with my application.) after some key input (This key is in my custom board.)

    int main(void)

    {

    uint32_t err_code;
    
    UART_TX_HIGH;
    
    lfclk_config();								// clock init
    nrf_delay_ms(5);
    
    twi_master_init();							// eeprom init
    TWI_400K;									// twi frequency
    
    // dfu check
    if(checkDfu())								// check eeprom and enter into DFU mode
    	goto DFU;
    	.
    	.
    	.
    // ******* main loop start ******* //
    while (1)
    {
    	.
    	.
    	.
    }
    

    DFU:

    startDfu();
    

    }

    // It's the same as buttonless_dfu main function

    void startDfu(void)

    {

    uint32_t err_code;
    bool erase_bonds;
    
    // Initialize.
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);
    
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    
    peer_manager_init(erase_bonds);
    if (erase_bonds == true)
    {
    	NRF_LOG_DEBUG("Bonds erased!\r\n");
    }
    
    gap_params_init();
    advertising_init();
    
    services_init();
    NRF_LOG_DEBUG("Services are initialized\r\n");
    
    conn_params_init();
    NRF_LOG_DEBUG("conn params are initialized\r\n");
    
    // Start execution.
    application_timers_start();
    NRF_LOG_DEBUG("app timers are started\r\n");
    
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    NRF_LOG_DEBUG("advertising is started\r\n");
    
    // loop
    for( ; ; )
    {
    	if(NRF_LOG_PROCESS() == false)
    	{
    		power_manage();
    	}
    }
    

    }

    1. upload my new F/W using bootloader_secure in android phone.
    2. my new application run again after DFU done.

    To do this, I tried to modify DFU control point. But, it didn't work. I am trying to solve this problem. I'm sorry but it's better to have your help.

  • Hello, I tried some

    • In the bootloader_secure project I removed the init_softdevice check in ble_stack_init().

    //if (init_softdevice)

    //{

    err_code = sd_mbr_command(&com);
    APP_ERROR_CHECK(err_code);
    

    //}

    • In the buttonless_dfu project I inserted code related with jump to bootloader.

    int main(void)

    {

    uint32_t err_code;
    bool     erase_bonds;
    
    NRF_POWER->GPREGRET = 0xb1;		// BOOTLOADER_DFU_START;
    NVIC_SystemReset();
    

    . .

    }

    And

    1. SD130/bootloader programming into PCA10028 board

    2. Buttoness_dfu f/w package file upload in android phone

    In this procedure -2, I guess buttoness_dfu runs(jump to bootloader again) after upload done.

    So, I think I can upload the new F/W again.

    Sure, I saw 1st upload.

    But, bootloader doesn’t run after 1st upload.

    These are related with what I want to realize as I explained in the above comments.

    If it’s wrong How can I realize?

  • Hi air, there is a bug in the buttonless examples so if you have tried to write to the DFU control, but the device is not jumping to bootloader mode then you have add the write permission to the control point characteristic as described in this answer.

    If you want to switch to bootloader with a button press then you have to call the enter_bootloader() function in ble_dfu.c once you get an interrupt from the button pin. Or you can simply do

    s_dfu_settings.enter_buttonless_dfu = true;
    
    (void)nrf_dfu_settings_write(flash_callback);
    
    sd_nvic_SystemReset();
    
  • Thank you very much!

    Now, it's possible to enter bootloader mode and DFU using my custom key.

    But,there's one thing to be solved.

    I want to run the application(not bootloader) when the 1st power on after SD / application / bootloader programmed into the board.

    I'm trying to modify this.

    If you know this would you give me a tip?

    Always thanks.

  • Hi Air, you have to create a bootloader settings page with nrfutil to set the valid app flag using the follwing command

    nrfutil settings generate --family NRF52 --application <name of application hex file>.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 bootloader_settings.hex
    

    After creating the bootloader_settings.hex file you have to merge it with the combined bootoader, application and softdevice hex file, and then flash it to your device.

Related