Hi, I am using nrf51822 CDAB version chip which has 128kb of flash memory, my code is built on ble_hrs I am trying to save my app_trace logs i.e., redirecting my printf to the below function which will save the data on to my flash. After adding this piece of code my device starts resetting. Any other way of logging data into flash would be appreciated.
/*
* Global variables
*/
static pstorage_handle_t m_storage_handle;
char m_buff[DATA_BLOCK_SIZE] __attribute__ ((aligned(4)));
extern uint8_t m_device_name[MAX_DEVICE_BUFFER_LENGTH];
extern uint8_t m_accel_threshold;
uint8_t block_no = 1;
/**@brief store logs into flash memory
*
* @All the printf logs can be redirected to flash.
*/
int flash_printf(const char *format, ...)
{
char str[64];
va_list args;
pstorage_handle_t handle;
va_start(args, format);
sprintf(str, format, args);
va_end(args);
pstorage_block_identifier_get(&m_storage_handle, block_no, &handle);
uint32_t err_code = pstorage_update(&handle, (uint8_t *)str, DATA_BLOCK_SIZE, 0);
APP_ERROR_CHECK(err_code);
block_no++;
}
Thanks and Regards, Faizan