Peer manager fails with NRF_ERROR_STORAGE_FULL

I'm having problems getting the peer manager to work in a project forked from the ble_app_template on my nRF52-DK (using pca10040e, S112), complaining it can't initialize it's flash storage. But it doesn't even work using one of the examples (unmodified), ble_app_cscs for example. It was working at some point when I first tried, but it stopped eventually. I also tried erasing the chip using --eraseall or --chiperase as suggested in other threads, without success. Programming the chip also fails (times out) sometimes, maybe that's related.

The log is spammed with these messages:

<error> peer_manager_pds: Could not initialize flash storage. fds_init() returned 0xB.
<error> peer_manager: pm_init failed because pds_init() returned NRF_ERROR_STORAGE_FULL.
<error> app: Fatal error
<warning> app: System reset
<error> peer_manager_pds: Could not initialize flash storage. fds_init() returned 0xB.
<error> peer_manager: pm_init failed because pds_init() returned NRF_ERROR_STORAGE_FULL.
<error> app: Fatal error
<warning> app: System reset

Debugging shows the following:

  • pm_init() calls pds_init()
  • pds_init() calls fds_register() successfully, then fds_init()
  • fds_init() calls pages_init()
  • in pages_init() page_identify() is called for all pages, which returns FDS_PAGE_UNDEFINED
  • page_is_erased() returns false as *p_page_addr = 0x5f46524e (or anything else but 0xffffffff)
  • total_pages_available is 0 eventually and pages_init() returns NO_PAGES
  • fds_init() fails with FDS_ERR_NO_PAGES and pds_init() return NRF_ERROR_STORAGE_FULL

Using pca10040 ans S132 on the ble_app_cscs example doesn't lead to this error though, only pca10040e/S112.

I'm using nRF5_SDK_15.3.0_59ac345 with arm-none-eabi-gcc 8.3.0 and nrfjprog version 9.8.1/JLinkARM.dll version 6.44a on Linux (Arch).

Anything I'm missing? I'm just getting started with nRF52 development.

Edit 1: Since it might be related, attached is the log from nrfjprog when flashing fails.

log.log