flash_read fails, memcpy succeeds

I have used Partition Manager to insert a non-secure static partition at the start of Flash.

The problem is that reading addresses within this partition using the zephyr flash api "flash_read" fails for addresses below 0x80000.
flash_erase and flash_write works fine.

For reading I can see that "flash_nrf_read" in soc_flash_nrf.c does some checking to see if the address is less than PM_APP_ADDRESS. If it is greater, it does a memcpy if not it calls soc_secure_mem_read. The result is -22, which is EINVAL.

Using memcpy directly for reading seems to work fine.

pm_static.yml looks like this:

nonsecure_storage:
  address: 0x00
  size: 0x80000

I have the following Flash partitions:

  flash_primary (0x100000 - 1024kB): 
+--------------------------------------------+
| 0x0: nonsecure_storage (0x80000 - 512kB)   |
+---0x80000: tfm_secure (0x8000 - 32kB)------+
| 0x80000: tfm (0x8000 - 32kB)               |
+---0x88000: tfm_nonsecure (0x78000 - 480kB)-+
| 0x88000: app (0x78000 - 480kB)             |
+--------------------------------------------+

Related