nRF5 SDK v15.3.0
Modules | Functions
Validation

Modules

 DFU validation configuration
 

Functions

void nrf_dfu_validation_init (void)
 Function for module initialization. More...
 
nrf_dfu_result_t nrf_dfu_validation_init_cmd_create (uint32_t size)
 Function called on reception of init command creation request. More...
 
nrf_dfu_result_t nrf_dfu_validation_init_cmd_append (uint8_t const *p_data, uint32_t length)
 Function called on reception of fragment of init command. More...
 
void nrf_dfu_validation_init_cmd_status_get (uint32_t *p_offset, uint32_t *p_crc, uint32_t *p_max_size)
 Function for getting init command status. More...
 
bool nrf_dfu_validation_init_cmd_present (void)
 Function for inquiring whether a valid init command has been received. More...
 
nrf_dfu_result_t nrf_dfu_validation_init_cmd_execute (uint32_t *p_dst_data_addr, uint32_t *p_data_len)
 Function for validating init command and retrieving the address and length of the firmware. More...
 
nrf_dfu_result_t nrf_dfu_validation_prevalidate (void)
 Function for validating the init command. More...
 
bool nrf_dfu_validation_boot_validate (boot_validation_t const *p_validation, uint32_t data_addr, uint32_t data_len)
 Function for validating the firmware for booting. More...
 
nrf_dfu_result_t nrf_dfu_validation_post_data_execute (uint32_t data_addr, uint32_t data_len)
 Function for postvalidating the update after all data is received. More...
 
nrf_dfu_result_t nrf_dfu_validation_activation_prepare (uint32_t data_addr, uint32_t data_len)
 Function for preparing the update for activation. More...
 
nrf_dfu_result_t nrf_dfu_validation_post_external_app_execute (dfu_init_command_t const *p_init, bool is_trusted)
 Function to execute on a validated external app. More...
 
bool nrf_dfu_validation_valid_external_app (void)
 Function to check if there is a valid external app in Bank 1. More...
 

Detailed Description

Function Documentation

nrf_dfu_result_t nrf_dfu_validation_activation_prepare ( uint32_t  data_addr,
uint32_t  data_len 
)

Function for preparing the update for activation.

This function is called after a reset, after all data is received. This function also runs nrf_dfu_validation_post_data_execute internally. If this succeeds, the update is activated by the activation machinery in the bootloader the next time it runs.

Note
The caller must have permissions to edit the relevant entries in the settings.
Parameters
[in]data_addrStart address of the received data.
[in]data_lenLength of the received data.
Returns
Operation result. See nrf_dfu_result_t
bool nrf_dfu_validation_boot_validate ( boot_validation_t const *  p_validation,
uint32_t  data_addr,
uint32_t  data_len 
)

Function for validating the firmware for booting.

Parameters
[in]p_validationValidation parameters.
[in]data_addrStart address of the firmware.
[in]data_lenLength of the firmware.
Returns
Whether the firmware is valid for booting.
void nrf_dfu_validation_init ( void  )

Function for module initialization.

Function checks if there is a valid init packet in DFU settings written in flash.

nrf_dfu_result_t nrf_dfu_validation_init_cmd_append ( uint8_t const *  p_data,
uint32_t  length 
)

Function called on reception of fragment of init command.

Parameters
[in]p_dataInit command fragment.
[in]lengthInit command fragment size.
Returns
Operation result. See nrf_dfu_result_t
nrf_dfu_result_t nrf_dfu_validation_init_cmd_create ( uint32_t  size)

Function called on reception of init command creation request.

Parameters
[in]sizeSize of incoming init packet.
Returns
Operation result. See nrf_dfu_result_t
nrf_dfu_result_t nrf_dfu_validation_init_cmd_execute ( uint32_t *  p_dst_data_addr,
uint32_t *  p_data_len 
)

Function for validating init command and retrieving the address and length of the firmware.

If init command is successfully validated Bank 1 details are written to out parameters.

Until nrf_dfu_validation_init_cmd_create is called, this function can be called again after the first time without side effects to retrieve address and length.

Parameters
[out]p_dst_data_addrStart address of received data, if validation is successful.
[out]p_data_lenExpected length of received data, if validation is successful.
Returns
Operation result. See nrf_dfu_result_t
bool nrf_dfu_validation_init_cmd_present ( void  )

Function for inquiring whether a valid init command has been received.

Returns
true if there is a valid init command. This can be true at boot time if the device was reset during a DFU operation.
void nrf_dfu_validation_init_cmd_status_get ( uint32_t *  p_offset,
uint32_t *  p_crc,
uint32_t *  p_max_size 
)

Function for getting init command status.

Parameters
[out]p_offsetCurrent offset.
[out]p_crcCurrent CRC.
[out]p_max_sizeMaximum size of init command.
nrf_dfu_result_t nrf_dfu_validation_post_data_execute ( uint32_t  data_addr,
uint32_t  data_len 
)

Function for postvalidating the update after all data is received.

Parameters
[in]data_addrStart address of the received data.
[in]data_lenLength of the received data.
Returns
Operation result. See nrf_dfu_result_t.
nrf_dfu_result_t nrf_dfu_validation_post_external_app_execute ( dfu_init_command_t const *  p_init,
bool  is_trusted 
)

Function to execute on a validated external app.

This function is called once all data is received with the parameter is_boot set to false. The function is called during bootup with the parameter set to true.

Note
This function requires that NRF_DFU_SUPPORTS_EXTERNAL_APP is set to 1. It is up to the user to implement this function.
Warning
Parameter is_trusted must be used to ensure that no loss of security of process can happen. This parameter should only be set if the function is called after a root-of-trust reset on the device.

Parameter is_trusted can be used for the following:

  • Ensuring that an external application is run only once (after root-of-trust).
  • Ensuring that a bank flag or any other flash access can only happen after root-of-trust.
  • Ensuring that the device reaches the correct state after a power failure on the device.
Parameters
[in]p_initInit command for the firmware upgrade.
[in]is_trustedMust be set to true if this is called after root-of-trust boot. Must be set to false if this is called from DFU mode or background DFU operation.
Returns
Operation result. see nrf_dfu_result_t.
nrf_dfu_result_t nrf_dfu_validation_prevalidate ( void  )

Function for validating the init command.

Returns
Operation result. See nrf_dfu_result_t.
bool nrf_dfu_validation_valid_external_app ( void  )

Function to check if there is a valid external app in Bank 1.

Returns
True if valid external app, otherwise false.

Documentation feedback | Developer Zone | Subscribe | Updated