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

Bootloader - Where are packets saved for DFU?

Hi,

I would like to know, where the packets are written into the flash for the mesh DFU example.

In nrf_mesh_dfu.c is a function nrf_mesh_dfu_cmd_send:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
uint32_t nrf_mesh_dfu_cmd_send(bl_cmd_t* p_cmd)
{
if (m_cmd_handler == NULL)
{
__LOG(LOG_SRC_DFU, LOG_LEVEL_ERROR, "ERROR: No CMD handler!\n");
return NRF_ERROR_NOT_SUPPORTED;
}
if (p_cmd == NULL)
{
return NRF_ERROR_NULL;
}
/* Suspend flash operations for the duration of the command to avoid
premature flash-events disturbing the flow */
mesh_flash_set_suspended(true);
uint32_t error_code = m_cmd_handler(p_cmd); /* Bootloader */
mesh_flash_set_suspended(false);
//__LOG(LOG_SRC_DFU, LOG_LEVEL_INFO, "[NRF_MESH_DFU] nrf_mesh_dfu_cmd_send\n");
return error_code;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

It calls a handler, which was allocated at the end of the RAM:

Fullscreen
1
2
3
4
5
6
error_code = dfu_cmd_handler_set(*((bl_if_cmd_handler_t*) (DEVICE_DATA_RAM_END_GET() - sizeof(bl_if_cmd_handler_t)))); /* Puts the command handler at the end of the RAM */
if (error_code != NRF_SUCCESS)
{
m_transfer_state.state = NRF_MESH_DFU_STATE_INITIALIZED;
return NRF_ERROR_NOT_SUPPORTED;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

An this command handler (Bootloader?) gets now commands for BLE transmits or RX packets etc, but I don't see where the commands are actually handled?

Further I don't see where the received packets are stored. There is somehow a listener registered:

Fullscreen
1
2
3
4
5
AD_LISTENER(m_dfu_ad_listener) = {
.ad_type = AD_TYPE_DFU,
.adv_packet_type = ADL_WILDCARD_ADV_TYPE,
.handler = ad_data_in,
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And this listener somehow accesses the flash.

What I finally try to do is to store the DFU normally in the flash without flashing it or distributing it in the mesh. After I received the whole update, I want to start distributing

it in the mesh and update it at the end for myself, but I don't know where to access the individual packets out of the flash, since I don't see the storing mechanism behind.