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

Write to flash with softdevice and mesh S113

Hi,

I try to write some data into the flash memory, but I always get a hardfault when I try to use the write function provided from the examples:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
uint32_t nrf_flash_write(uint32_t * p_dst, const uint32_t* p_src, uint32_t size)
{
if (!IS_WORD_ALIGNED(p_dst) || !IS_WORD_ALIGNED(p_src))
{
return NRF_ERROR_INVALID_ADDR;
}
if (size == 0 || !IS_WORD_ALIGNED(size))
{
return NRF_ERROR_INVALID_LENGTH;
}
#if !defined(HOST)
size /= WORD_SIZE;
/* Turn on flash write enable and wait until the NVMC is ready: */
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
wait_for_ready();
while (size--)
{
if (*p_src != FLASH_BLANK_WORD)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

No I think this is because of the softdevice, that is stopped for an amount of time. There is also a mesh_flah.c available, but I don't see any functions for writing to the flash. What I actually need is some functionality, such that I can write a uint8_t array with specific length to the flash and then read it again.