NRF9160 LittleFS build non-secure target

(replica as the previous post was archived by accident...)

Hi,

I'm trying to incorporate LittleFS into our development. We are relying on services provided by TF-M. 

To recreate: build /zephyr/samples/fs/littleFS and set target nrf9160dk_nrf9160_ns

It works perfectly fine when I don't select the non-secure target. 

It fails to mount. I suspect that the fs is accessing a part of flash that has been configured for secure access only. The "memcpy(data, (void *)addrlen);" triggers a security fault and the device locks up. (zephyr/drivers/flash/soc_flash_nrf.c:163)

Any way to configure regions of the flash so it wont trigger the security exception? Should the FS be moved to a different location on flash? Is there a way to see what regions on the flash are reserved for the trusted execution environment? 

First part of the example works and it detects the flash area: "Area 5 at 0xfa000 on NRF_FLASH_DRV_NAME for 24576 bytes" 

It is pretty clear that it has been handled when using SPM as the spm_request_read(data, addr, len); is invoked in some cases. 

Cheers! 
static int flash_nrf_read(const struct device *dev, off_t addr,
			    void *data, size_t len)
{
	if (is_regular_addr_valid(addr, len)) {
		addr += DT_REG_ADDR(SOC_NV_FLASH_NODE);
	} else if (!is_uicr_addr_valid(addr, len)) {
		LOG_ERR("invalid address: 0x%08lx:%zu",
				(unsigned long)addr, len);
		return -EINVAL;
	}

	if (!len) {
		return 0;
	}

#if CONFIG_ARM_NONSECURE_FIRMWARE && CONFIG_SPM && USE_PARTITION_MANAGER \
	&& CONFIG_SPM_SECURE_SERVICES
	if (addr < PM_APP_ADDRESS) {
		return spm_request_read(data, addr, len);
	}
#endif

	memcpy(data, (void *)addr, len);

	return 0;
}
Parents Reply Children
No Data
Related