How to use safe SoC flash memory in smp_svr example?

smp_svr example mounts littleFS file system in SoC flash for OTA DFU function. Can I use that file system to save my variables? When I use fs_open() function there is an error: fs: invalid file name!! 

#define STORAGE_PARTITION_LABEL	storage_partition
#define STORAGE_PARTITION_ID	FIXED_PARTITION_ID(STORAGE_PARTITION_LABEL)

/* Define an example stats group; approximates seconds since boot. */
STATS_SECT_START(smp_svr_stats)
STATS_SECT_ENTRY(ticks)
STATS_SECT_END;

/* Assign a name to the `ticks` stat. */
STATS_NAME_START(smp_svr_stats)
STATS_NAME(smp_svr_stats, ticks)
STATS_NAME_END(smp_svr_stats);

/* Define an instance of the stats group. */
STATS_SECT_DECL(smp_svr_stats) smp_svr_stats;

#ifdef CONFIG_MCUMGR_GRP_FS
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
static struct fs_mount_t littlefs_mnt = {
	.type = FS_LITTLEFS,
	.fs_data = &cstorage,
	.storage_dev = (void *)STORAGE_PARTITION_ID,
	.mnt_point = "/lfs1"
};
#endif

int main(void)
{
	
	struct fs_file_t file;
	uint8_t f_Name[] = "vars.dat";
	uint8_t test_Bytes[] = {0x01,0x02,0x03,0x04};
	

	NRF_POWER->DCDCEN = false;
	NRF_UICR->NFCPINS = 0;  // NFC pins as GPIOs

	LOG_LEVEL_SET(LOG_LEVEL_INF);
	int rc = STATS_INIT_AND_REG(smp_svr_stats, STATS_SIZE_32,
				    "smp_svr_stats");

	if (rc < 0) {
		LOG_ERR("Error initializing stats system [%d]", rc);
	}
    
	rc = fs_mount(&littlefs_mnt);
	if (rc < 0) {
		LOG_ERR("Error mounting littlefs [%d]", rc);
	}
fs_file_t_init(&file);


rc = fs_open(&file, f_Name, FS_O_CREATE|FS_O_RDWR);
	if (rc < 0) {
		LOG_ERR("Error of opening file [%d]", rc);
	} else {
		LOG_INF("File opened ok!");
	}
ssize_t rf = fs_write(&file, test_Bytes, 4);
rc = fs_close(&file);
	if (rc < 0) {
		LOG_ERR("Error of closing file [%d]", rc);
	}

#ifdef CONFIG_MCUMGR_TRANSPORT_BT
	start_smp_bluetooth_adverts();
#endif

	while (1) {
		k_sleep(K_MSEC(1000));
		STATS_INC(smp_svr_stats, ticks);
	}
	return 0;
}

Related