Replies: 1 comment
-
You need to reformat the code between a ``` at the top and ``` at the bottom. Also, don't do things like touch the UICR, this is not correct, there are Kconfig options to set these values |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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!! Sorry, I don't know, how to make readable code here...
`#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)
{
//fs_dir_t_init(&dir);
fs_file_t_init(&file);
rc = fs_statvfs(&littlefs_mnt.mnt_point, &sbuf);
if (rc < 0) {
printk("FAIL: statvfs: %d\n", rc);
return;
}
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!");
}
rc = fs_seek(&file, 0, FS_SEEK_SET);
if (rc < 0) {
LOG_ERR("FAIL: seek %s: %d", f_Name, rc);
}
ssize_t rf = fs_write(&file, test_Bytes, 4);
if (rf < 0) {
LOG_ERR("Error of writing file [%d]", rf);
} else {
LOG_INF("File written ok! [%d]", rf);
}
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
}
`
Beta Was this translation helpful? Give feedback.
All reactions