I've added the SPOTAR profile to my custom project and made sure the advertising data contains the correct values for the device to be detected in the SUOTA apps. When booting from EEPROM, trying to upload new firmware via SUOTA crashes my device. I've tried debugging in Keil by uploading the image that is normally stored in Bank 1 in the eeprom and when I try to send new firmware from the SUOTA app to my device, it crashes with a hardfault at this line: spota_state.status_ind_func( SPOTAR_START ); I'm not sure where to go from here to debug.
The entire function is here:
void app_spotar_start(void)
{
//app_force_active_mode();
spota_state。status_ind_func (SPOTAR_START);
if( SPOTAR_IS_FOR_PATCH( spota_state.mem_dev ) )
{
spotar_send_status_update_req((uint8_t) SPOTAR_SRV_STARTED);
}
else
{
spotar_send_status_update_req((uint8_t) SPOTAR_IMG_STARTED);
}
// Initialise indexes
spota_state。spota_pd_idx = 0;
spota_state。suota_block_idx = 0;
spota_state。suota_img_idx = 0;
spota_state。new_patch_len = 0;
spota_state。crc_clac = 0;
spota_state。crc_clac = 0;
}
The device seems to work just fine otherwise. All of my other services and peripherals work correctly.
Hi JBaczuk,
Seems like when accessing the callback function of that handler during the spotar indication it results in an invalid pointer value, you can check if the value passed in the pointer of the struct is indeed the pointer of the function you want to call when the SPOTAR_START event occurs. Do you invoke the app_spotar_init() in the app_init_func() so that the callback pointer is initialized with the app_spotar_status ?
Thanks MT_dialog
I have not invoked app_spotar_init(), how do I do this? It is looking for a pointer to a function, but what function pointer should I pass in and how?
Hi JBaczuk,
The app_spotar_init() function is called in the app_init_func() function and the callback function is passed as a parameter at the initialization. Normally this function should be called in the app_init_func() since you have defined the BLE_SPOTA_RECEIVER since you have enabled the SUOTA service. The default app_spotar_status() function doesn't do anything in the 580/581 but in the 583 chip it enables the internal flash. Make sure that the app_spotar_status() is implemented in your project. Please have a look at the SUOTA implementation in the proximity reporter project.
Thanks MT_dialog
Thank you that seems to have fixed it. I added the function app_spotar_status( const uint8_t spotar_event){...} to the app_project_proj.c file and then inside my app_init_func(void) function I added: app_spotar_init(app_spotar_status);