1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #17656 from benpicco/vfs_default-test

vfs_default: add compile test and add default mount for more boards
This commit is contained in:
benpicco 2022-03-29 13:47:08 +02:00 committed by GitHub
commit 9ca3dd5d4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 198 additions and 17 deletions

View File

@ -13,3 +13,9 @@ endif
ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_spi_nor
endif
# default to using littlefs2 on the external flash
ifneq (,$(filter vfs_default,$(USEMODULE)))
USEPKG += littlefs2
USEMODULE += mtd
endif

View File

@ -52,4 +52,9 @@ static mtd_spi_nor_t weact_nor_dev = {
};
mtd_dev_t *mtd0 = (mtd_dev_t *)&weact_nor_dev;
#ifdef MODULE_VFS_DEFAULT
#include "vfs_default.h"
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(weact_nor_dev), VFS_DEFAULT_NVM(0), 0);
#endif
#endif /* MODULE_MTD */

View File

@ -9,4 +9,10 @@ ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_spi_nor
endif
# default to using littlefs2 on the external flash
ifneq (,$(filter vfs_default,$(USEMODULE)))
USEPKG += littlefs2
USEMODULE += mtd
endif
USEMODULE += boards_common_iotlab

View File

@ -52,4 +52,9 @@ static mtd_spi_nor_t mtd_nor_dev = {
};
mtd_dev_t *mtd0 = (mtd_dev_t *)&mtd_nor_dev;
#ifdef MODULE_VFS_DEFAULT
#include "vfs_default.h"
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(mtd_nor_dev), VFS_DEFAULT_NVM(0), 0);
#endif
#endif /* MODULE_MTD */

View File

@ -7,3 +7,9 @@ endif
ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_mci
endif
# default to using FAT on the SD card
ifneq (,$(filter vfs_default,$(USEMODULE)))
USEMODULE += fatfs_vfs
USEMODULE += mtd
endif

View File

@ -31,6 +31,11 @@ static mtd_dev_t _mtd_mci = { .driver = &mtd_mci_driver };
mtd_dev_t *mtd0 = &_mtd_mci;
#endif
#ifdef MODULE_VFS_DEFAULT
#include "vfs_default.h"
VFS_AUTO_MOUNT(fatfs, { .dev = &_mtd_mci }, VFS_DEFAULT_SD(0), 0);
#endif
void led_init(void)
{
/* LEDs */

View File

@ -12,3 +12,9 @@ endif
ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_mci
endif
# default to using FAT on the SD card
ifneq (,$(filter vfs_default,$(USEMODULE)))
USEMODULE += fatfs_vfs
USEMODULE += mtd
endif

View File

@ -27,11 +27,14 @@
#include "board.h"
#include "cpu.h"
#include "mtd.h"
#include "periph/init.h"
#include "stdio_base.h"
#ifdef MODULE_MTD_MCI
extern const mtd_desc_t mtd_mci_driver;
static mtd_dev_t _mtd_mci = { .driver = &mtd_mci_driver };
mtd_dev_t *mtd0 = &_mtd_mci;
#endif
#ifdef MODULE_VFS_DEFAULT
#include "vfs_default.h"
VFS_AUTO_MOUNT(fatfs, { .dev = &_mtd_mci }, VFS_DEFAULT_SD(0), 0);
#endif

View File

@ -35,7 +35,7 @@ mtd_dev_t *mtd0 = &mtd0_dev.base;
#endif
#ifdef MODULE_VFS
#include "vfs.h"
#include "vfs_default.h"
/*
* On `native` we define auto-mounts for every file system.
@ -47,27 +47,19 @@ mtd_dev_t *mtd0 = &mtd0_dev.base;
/* littlefs support */
#if defined(MODULE_LITTLEFS)
#include "fs/littlefs_fs.h"
VFS_AUTO_MOUNT(littlefs, VFS_MTD(mtd0_dev), "/nvm", 0);
VFS_AUTO_MOUNT(littlefs, VFS_MTD(mtd0_dev), VFS_DEFAULT_NVM(0), 0);
/* littlefs2 support */
#elif defined(MODULE_LITTLEFS2)
#include "fs/littlefs2_fs.h"
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(mtd0_dev), "/nvm", 0);
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(mtd0_dev), VFS_DEFAULT_NVM(0), 0);
/* spiffs support */
#elif defined(MODULE_SPIFFS)
#include "fs/spiffs_fs.h"
VFS_AUTO_MOUNT(spiffs, VFS_MTD(mtd0_dev), "/nvm", 0);
VFS_AUTO_MOUNT(spiffs, VFS_MTD(mtd0_dev), VFS_DEFAULT_NVM(0), 0);
/* FAT support */
#elif defined(MODULE_FATFS_VFS)
#include "fs/fatfs.h"
VFS_AUTO_MOUNT(fatfs, VFS_MTD(mtd0_dev), "/nvm", 0);
VFS_AUTO_MOUNT(fatfs, VFS_MTD(mtd0_dev), VFS_DEFAULT_NVM(0), 0);
#endif
#endif /* MODULE_VFS */

View File

@ -4,4 +4,10 @@ ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_spi_nor
endif
# default to using littlefs2 on the external flash
ifneq (,$(filter vfs_default,$(USEMODULE)))
USEPKG += littlefs2
USEMODULE += mtd
endif
include $(RIOTBOARD)/common/nrf52xxxdk/Makefile.dep

View File

@ -54,4 +54,8 @@ static mtd_spi_nor_t nrf52840dk_nor_dev = {
mtd_dev_t *mtd0 = (mtd_dev_t *)&nrf52840dk_nor_dev;
#ifdef MODULE_VFS_DEFAULT
#include "vfs_default.h"
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(nrf52840dk_nor_dev), VFS_DEFAULT_NVM(0), 0);
#endif
#endif

View File

@ -63,7 +63,7 @@ static mtd_at24cxxx_t at24mac_dev = {
mtd_dev_t *mtd1 = (mtd_dev_t *)&at24mac_dev;
#ifdef MODULE_VFS_DEFAULT
#include "fs/littlefs2_fs.h"
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(same54_nor_dev), "/nvm", 0);
#include "vfs_default.h"
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(same54_nor_dev), VFS_DEFAULT_NVM(0), 0);
#endif
#endif /* MODULE_MTD */

75
sys/include/vfs_default.h Normal file
View File

@ -0,0 +1,75 @@
/*
* Copyright (C) 2022 ML!PA Consulting GmbH
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup sys_vfs
* @brief VFS default mount points
*
* @{
* @file
* @brief VFS layer default definitions & mount points
*
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
*/
#ifndef VFS_DEFAULT_H
#define VFS_DEFAULT_H
#include "board.h"
#include "vfs.h"
#if IS_USED(MODULE_FATFS_VFS)
#include "fs/fatfs.h"
#endif
#if IS_USED(MODULE_LITTLEFS)
#include "fs/littlefs_fs.h"
#endif
#if IS_USED(MODULE_LITTLEFS2)
#include "fs/littlefs2_fs.h"
#endif
#if IS_USED(MODULE_SPIFFS)
#include "fs/spiffs_fs.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Default mount point for removable storage
*/
#ifndef VFS_DEFAULT_SD
#define VFS_DEFAULT_SD(n) "/sd" # n
#endif
/**
* @brief Default mount point for non-removable storage
*/
#ifndef VFS_DEFAULT_NVM
#define VFS_DEFAULT_NVM(n) "/nvm" # n
#endif
/**
* @brief Default data directory
* This can be written to by applications
*/
#ifndef VFS_DEFAULT_DATA
#if IS_USED(MODULE_MTD_MCI) || IS_USED(MODULE_MTD_SDCARD)
#define VFS_DEFAULT_DATA VFS_DEFAULT_SD(0)
#else
#define VFS_DEFAULT_DATA VFS_DEFAULT_NVM(0)
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* VFS_DEFAULT_H */
/** @} */

View File

@ -0,0 +1,9 @@
include ../Makefile.tests_common
USEMODULE += vfs_default
USEMODULE += vfs_auto_format
USEMODULE += shell
USEMODULE += shell_commands
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1,11 @@
BOARD_INSUFFICIENT_MEMORY := \
arduino-leonardo \
arduino-nano \
atmega328p-xplained-mini \
arduino-duemilanove \
arduino-uno \
atmega328p \
stm32f030f4-demo \
samd10-xmini \
nucleo-l011k4 \
#

42
tests/vfs_default/main.c Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2022 ML!PA Consulting GmbH
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Test application for vfs_default
*
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
* @}
*/
#include <stdio.h>
#include "shell.h"
#include "shell_commands.h"
#include "vfs_default.h"
int main(void)
{
vfs_DIR mount = {0};
/* list mounted file systems */
puts("mount points:");
while (vfs_iterate_mount_dirs(&mount)) {
printf("\t%s\n", mount.mp->mount_point);
}
printf("\ndata dir: %s\n", VFS_DEFAULT_DATA);
/* start the shell */
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}