DFU utilities

nRF5 SDK v15.0.0

Macros

#define ALIGN_TO_PAGE (val) ALIGN_NUM (( CODE_PAGE_SIZE ), (val))

Functions

uint32_t nrf_dfu_bank0_start_addr (void)
Function for getting the start address of bank 0. More...
uint32_t nrf_dfu_bank1_start_addr (void)
Function for getting the start address of bank 1. More...
uint32_t nrf_dfu_app_start_address (void)
Function for getting the start address of the app. More...
uint32_t nrf_dfu_softdevice_start_address (void)
Function for getting the start address of the SoftDevice. More...
bool nrf_dfu_app_is_valid (bool do_crc)
Function for checking if the main application is valid. More...
uint32_t nrf_dfu_cache_prepare (uint32_t required_size, bool single_bank, bool keep_app, bool keep_softdevice)
Function for finding and preparing a place in flash in which to store a DFU update. More...
void nrf_dfu_softdevice_invalidate (void)
Function for making sure a SoftDevice is not recognized as such anymore. More...
void nrf_dfu_bank_invalidate ( nrf_dfu_bank_t *const p_bank)
Function for making sure a bank is not copied or booted. More...

Detailed Description

Macro Definition Documentation

#define ALIGN_TO_PAGE ( val ) ALIGN_NUM (( CODE_PAGE_SIZE ), (val))

Round up val to the next page boundary

Function Documentation

bool nrf_dfu_app_is_valid ( bool do_crc )

Function for checking if the main application is valid.

This function checks if there is a valid application located at Bank 0.

Parameters
[in] do_crc Perform CRC check on application.
Return values
true If a valid application has been detected.
false If there is no valid application.
uint32_t nrf_dfu_app_start_address ( void )

Function for getting the start address of the app.

Returns
The start address of the bootable app.
uint32_t nrf_dfu_bank0_start_addr ( void )

Function for getting the start address of bank 0.

Note
Bank 0 starts after the SoftDevice if a SoftDevice is present.
Returns
The start address of bank 0.
uint32_t nrf_dfu_bank1_start_addr ( void )

Function for getting the start address of bank 1.

Returns
The start address of bank 1.
void nrf_dfu_bank_invalidate ( nrf_dfu_bank_t *const p_bank )

Function for making sure a bank is not copied or booted.

This also sets the size of the bank to 0.

Parameters
[in] p_bank Pointer to the bank to be invalidated.
uint32_t nrf_dfu_cache_prepare ( uint32_t required_size ,
bool single_bank ,
bool keep_app ,
bool keep_softdevice
)

Function for finding and preparing a place in flash in which to store a DFU update.

This function checks the size requirements and selects a location for placing the cache of the DFU images. The function tries to find enough space after the existing firmwares. If there is not enough space, the present application is deleted. If there is still not enough space, the SoftDevice is deleted. If single_bank is true, the default behavior is to immediately delete the app and SoftDevice as necessary to place the new firmware at its intended location. If the intended location cannot be made available, or if the update is a bootloader update, the update will be a dual bank update, and nothing will be deleted by this function except when needed for size. If keep_app is true, the app is never deleted by this function. Likewise if keep_softdevice is true, the SoftDevice is never deleted by this function. If the new firmware cannot fit within the constraints, nothing is deleted and the function fails.

Parameters
[in] required_size Requirements for the size of the new image.
[in] single_bank Whether to put the firmware directly where it's meant to go. keep_app and keep_softdevice take precedence over this.
[in] keep_app True to ensure the app is not deleted by this function. This effectively enforces dual bank update.
[out] keep_softdevice True to ensure the SoftDevice is not deleted by this function.
Return values
NRF_SUCCESS If a cache location was found for the DFU process.
NRF_ERROR_NO_MEM If there is not enough space available to receive the update. Nothing has been deleted.
void nrf_dfu_softdevice_invalidate ( void )

Function for making sure a SoftDevice is not recognized as such anymore.

It works by overwriting the magic number of the SoftDevice with 0s. The magic number is used throughout the bootloader to detect whether a SoftDevice is present.

Warning
This function should only be called when both banks are already invalid. because the (implicit) position of the banks will shift when the SoftDevice is invalidated.
uint32_t nrf_dfu_softdevice_start_address ( void )

Function for getting the start address of the SoftDevice.

Returns
The start address of the SoftDevivce.