mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 16:47:35 +08:00
AirBrainH743: reformat littlefs if required
This commit is contained in:
@@ -45,6 +45,8 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/board.h>
|
||||
@@ -188,7 +190,26 @@ __EXPORT int board_app_initialize(uintptr_t arg)
|
||||
syslog(LOG_INFO, "[boot] W25N MTD registered at /dev/mtd0\n");
|
||||
|
||||
#ifdef CONFIG_FS_LITTLEFS
|
||||
ret = nx_mount("/dev/mtd0", "/fs/microsd", "littlefs", 0, "autoformat");
|
||||
ret = nx_mount("/dev/mtd0", "/fs/microsd", "littlefs", 0, NULL);
|
||||
|
||||
if (ret == 0) {
|
||||
/* Verify the filesystem is usable by creating a test file */
|
||||
int fd = open("/fs/microsd/.mount_test", O_CREAT | O_WRONLY | O_TRUNC);
|
||||
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
unlink("/fs/microsd/.mount_test");
|
||||
|
||||
} else {
|
||||
syslog(LOG_WARNING, "[boot] littlefs mounted but not usable, reformatting\n");
|
||||
nx_umount2("/fs/microsd", 0);
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
ret = nx_mount("/dev/mtd0", "/fs/microsd", "littlefs", 0, "forceformat");
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
syslog(LOG_ERR, "[boot] FAILED to mount littlefs: %d\n", ret);
|
||||
|
||||
Reference in New Issue
Block a user