This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

pstorage triggering 'Error while identifying Cortex M core'

I'm attempting to implement a buffer in flash using the persistent storage module but have hit a bit of a wall. When I manually set the block size to something less than the minimum I get a NRF_ERROR_INVALID_PARAM error back from this function but my code otherwise runs perfectly. The moment I increase the block size to something that's valid, nRFgo Studio flashes up an "Error while identifying Cortex M core" window as soon as I flash the chip. I've included the code below.

Thanks for your help!

I'm using an NRF51822 with SoftDevice v6.0.0 on a custom board.

Here are the definitions for BLE_BUFFER_SIZE and reading_t

#define BLE_BUFFER_SIZE 10

typedef struct {
	timestamp_t     timestamp;
	uint16_t        type;
	uint32_t        value;
} reading_t;


// Initialise buffer. Returns NRF_SUCCESS if buffer is initialised,
// an error code otherwise.
uint32_t flash_buffer_init(void) {
	uint32_t				err_code, i;
	uint8_t					zeros[sizeof(reading_t)];
	pstorage_module_param_t	param;
	pstorage_handle_t		dest_block;

	// Make the zeros array zeros
	memset(zeros, 0, sizeof(reading_t));

	// Initialise the buffer
	flash_buffer.size = BLE_BUFFER_SIZE;
	flash_buffer.start = 0;
	flash_buffer.count = 0;

	// This is what we're requesting from flash.
	// Basically, we're putting the buffer in it.

	// The block size has to be a multiple of the word
	// length (32 bits) and between the maximum and
	// minimum block size
	param.block_size =	MAX((CEIL_DIV(sizeof(reading_t),
			sizeof(uint32_t))*sizeof(uint32_t)),
			PSTORAGE_MIN_BLOCK_SIZE);
	param.block_count = flash_buffer.size;
	param.cb =			flash_buffer_pstorage_cb_handler;

	// Register with the flash module
	if ((err_code = pstorage_register(&param,
			&flash_buffer.buffer_handle)) != NRF_SUCCESS)
		return err_code;

	// Do an initial write of zero to every single block. This is so
	// that later we can use 'update' for writes.
	for(i=0; i<BLE_BUFFER_SIZE;i++)
	{
		// Get the block identifier
		if ((err_code = pstorage_block_identifier_get(
				&flash_buffer.buffer_handle, i, &dest_block)) !=
				NRF_SUCCESS)
			return err_code;

		// Write zeros to the block
		if ((err_code = pstorage_store(&dest_block, zeros,
				sizeof(reading_t), 0)) != NRF_SUCCESS)
			return err_code;
	}

	return NRF_SUCCESS;
}
Parents
  • If I put some delay code early on in my main function the 'Error while Identifying Cortex M Core' message doesn't come up. Perhaps this message is a sign the device is resetting too rapidly.

    My code is still crashing, though :P

Reply
  • If I put some delay code early on in my main function the 'Error while Identifying Cortex M Core' message doesn't come up. Perhaps this message is a sign the device is resetting too rapidly.

    My code is still crashing, though :P

Children
No Data
Related