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

dm_init() returning NRF_ERROR_INVALID_ADDR

Every once and a while a compile will result in dm_init() returning NRF_ERROR_INVALID_ADDR. Looking at device_manager_peripheral.c:dm_init(), it looks like this error is coming from one of the pstorage routines that checks address alignment.

Using nm on a failed compile looking for non-32 bit aligned m_* symbols shows: 2000242e b m_bond_table.10242 20002842 b m_peer_table.10251

bond_context_t is made up of uint8_t and uint16_t, so it is aligned to uint16_t. Most of the time it is 4 byte aligned, but that is only dumb luck.

So it looks like the device manager needs to force alignment for anything it is trying to put in flash, at least for gcc users.

I added attribute aligned to m_peer_table and m_bond_table, so hopefully that will fix the problem. But I'm not sure if I caught all the structs that interact with pstorage in the device manager.

Related