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

Uploading App using Keil uVision on preloaded SD+DFU BL?

Hi

I have sd+dfu uploaded and can download app through dfu with no issues. But if I make any change to the app and try to upload app using Keil uVision then nrf52832 not jump to app. it stays at dfu. Is there any way to upload app through keil uVision on preinstalled SD+DFU BL or it has be OTA all the time?

Thanks

Parents
  • Hi,

    The bootloader will check the CRC of the application and compare with the CRC stored in bootloader settings. If the CRC is incorrect, it will enter DFU mode instead of starting the application.

    When you modify the application and program it via Keil (or any other method other than DFU for that matter), the CRC in the bootloader settings is not updated, and the bootloader will not start the application. There are a few ways to handle this:

    • The obvious option is to program the application via DFU, since this causes the bootloader to update the CRC. This works, but is a bit time consuming, so I understand why you want to avoid it.
    • You can also generate a new bootloader settings page using nrfutil and program it when you program the application. That way the new CRC match the new application.
    • The simplest (and best in my opinion) approach is to modify the bootloader so that it does not check application CRC on startup. This makes much sense during development. You can do this easily by commenting out the CRC check in dfu_enter_check() in nrf_bootloader.c.
  • Hi Einar,

                I am using bootloader sdk-v12 and dfu_enter_check() is not in nrf_bootloader.c. Can you point me for disabling CRC on sdk v12? Thanks

     

  • Hi,

    For SDK 12 this is handled by the nrf_dfu_app_is_valid() function in nrf_dfu_util.c. Just comment out everything related to CRC checking, like this (from 12.3):

    bool nrf_dfu_app_is_valid(void)
    {
        NRF_LOG_INFO("Enter nrf_dfu_app_is_valid\r\n");
        if (s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_VALID_APP)
        {
           // Bank 0 has no valid app. Nothing to boot
           NRF_LOG_INFO("Return false in valid app check\r\n");
           return false;
        }
    
        // If CRC == 0, this means CRC check is skipped.
        // if (s_dfu_settings.bank_0.image_crc != 0)
        // {
        //     uint32_t crc = crc32_compute((uint8_t*) CODE_REGION_1_START,
        //                                  s_dfu_settings.bank_0.image_size,
        //                                  NULL);
    
        //     if (crc != s_dfu_settings.bank_0.image_crc)
        //     {
        //         // CRC does not match with what is stored.
        //         NRF_LOG_INFO("Return false in CRC\r\n");
        //         return  false;
        //     }
        // }
    
        NRF_LOG_INFO("Return true. App was valid\r\n");
        return true;
    }

Reply
  • Hi,

    For SDK 12 this is handled by the nrf_dfu_app_is_valid() function in nrf_dfu_util.c. Just comment out everything related to CRC checking, like this (from 12.3):

    bool nrf_dfu_app_is_valid(void)
    {
        NRF_LOG_INFO("Enter nrf_dfu_app_is_valid\r\n");
        if (s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_VALID_APP)
        {
           // Bank 0 has no valid app. Nothing to boot
           NRF_LOG_INFO("Return false in valid app check\r\n");
           return false;
        }
    
        // If CRC == 0, this means CRC check is skipped.
        // if (s_dfu_settings.bank_0.image_crc != 0)
        // {
        //     uint32_t crc = crc32_compute((uint8_t*) CODE_REGION_1_START,
        //                                  s_dfu_settings.bank_0.image_size,
        //                                  NULL);
    
        //     if (crc != s_dfu_settings.bank_0.image_crc)
        //     {
        //         // CRC does not match with what is stored.
        //         NRF_LOG_INFO("Return false in CRC\r\n");
        //         return  false;
        //     }
        // }
    
        NRF_LOG_INFO("Return true. App was valid\r\n");
        return true;
    }

Children
Related