Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
双系统
一个flash能否挂两个系统
发布于 2021-03-19 13:42:51 浏览:1199
订阅该版
我将flash分成了两部分,分别为A和B,现在在device中能够把A和B定义为两种设备,能否把A和B挂载成两种系统,怎么操作?
查看更多
Papalymo
2021-03-19
请勿打扰
参考 ART-PI 代码: ``` /* * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2018-12-13 balanceTWK add sdcard port file * 2019-06-11 WillianChan Add SD card hot plug detection */ #include
#ifdef BSP_USING_FS #if DFS_FILESYSTEMS_MAX < 4 #error "Please define DFS_FILESYSTEMS_MAX more than 4" #endif #if DFS_FILESYSTEM_TYPES_MAX < 4 #error "Please define DFS_FILESYSTEM_TYPES_MAX more than 4" #endif #ifdef BSP_USING_SPI_FLASH_FS #include "fal.h" #endif #include
#include "dfs_romfs.h" #include "drv_sdio.h" #define DBG_TAG "app.filesystem" #define DBG_LVL DBG_INFO #include
static const struct romfs_dirent _romfs_root[] = { {ROMFS_DIRENT_DIR, "flash1", RT_NULL, 0}, {ROMFS_DIRENT_DIR, "flash2", RT_NULL, 0}, {ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0}}; const struct romfs_dirent romfs_root = { ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root) / sizeof(_romfs_root[0])}; #ifdef BSP_USING_SDCARD_FS /* SD Card hot plug detection pin */ #define SD_CHECK_PIN GET_PIN(D, 5) static void _sdcard_mount(void) { rt_device_t device; device = rt_device_find("sd0"); if (device == NULL) { mmcsd_wait_cd_changed(0); sdcard_change(); mmcsd_wait_cd_changed(RT_WAITING_FOREVER); device = rt_device_find("sd0"); } if (device != RT_NULL) { if (dfs_mount("sd0", "/sdcard", "elm", 0, 0) == RT_EOK) { LOG_I("sd card mount to '/sdcard'"); } else { LOG_W("sd card mount to '/sdcard' failed!"); } } } static void _sdcard_unmount(void) { rt_thread_mdelay(200); dfs_unmount("/sdcard"); LOG_I("Unmount \"/sdcard\""); mmcsd_wait_cd_changed(0); sdcard_change(); mmcsd_wait_cd_changed(RT_WAITING_FOREVER); } static void sd_mount(void *parameter) { rt_uint8_t re_sd_check_pin = 1; rt_thread_mdelay(200); if (rt_pin_read(SD_CHECK_PIN)) { _sdcard_mount(); } while (1) { rt_thread_mdelay(200); if (!re_sd_check_pin && (re_sd_check_pin = rt_pin_read(SD_CHECK_PIN)) != 0) { _sdcard_mount(); } if (re_sd_check_pin && (re_sd_check_pin = rt_pin_read(SD_CHECK_PIN)) == 0) { _sdcard_unmount(); } } } #endif /* BSP_USING_SDCARD_FS */ #ifdef BSP_USING_FASTFS_FOMAT extern int lpm_init(void); #endif int mount_init(void) { #ifdef RT_USING_DFS_ROMFS if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) != 0) { LOG_E("rom mount to '/' failed!"); } #endif #ifdef BSP_USING_SPI_FLASH_FS struct rt_device *flash1_dev = RT_NULL; struct rt_device *flash2_dev = RT_NULL; #ifndef RT_USING_WIFI fal_init(); #endif flash1_dev = fal_mtd_nor_device_create("filesystem"); if (flash1_dev) { //mount filesystem if (dfs_mount(flash1_dev->parent.name, "/flash1", "elm", 0, 0) != 0) { LOG_W("mount to '/flash1' failed! try to mkfs %s", flash1_dev->parent.name); dfs_mkfs("lfs", flash1_dev->parent.name); if (dfs_mount(flash1_dev->parent.name, "/flash1", "lfs", 0, 0) == 0) { LOG_I("mount to '/flash1' success!"); } } else { LOG_I("mount to '/flash1' success!"); } } flash2_dev = fal_mtd_nor_device_create("easyflash"); if (flash2_dev) { //mount filesystem if (dfs_mount(flash2_dev->parent.name, "/flash2", "elm", 0, 0) != 0) { LOG_W("mount to '/flash2' failed! try to mkfs %s", flash2_dev->parent.name); dfs_mkfs("lfs", flash2_dev->parent.name); if (dfs_mount(flash2_dev->parent.name, "/flash2", "lfs", 0, 0) == 0) { LOG_I("mount to '/flash2' success!"); } } else { LOG_I("mount to '/flash2' success!"); } } #endif #ifdef BSP_USING_SDCARD_FS rt_thread_t tid; rt_pin_mode(SD_CHECK_PIN, PIN_MODE_INPUT_PULLUP); tid = rt_thread_create("sd_mount", sd_mount, RT_NULL, 2048, RT_THREAD_PRIORITY_MAX - 2, 20); if (tid != RT_NULL) { rt_thread_startup(tid); } else { LOG_E("create sd_mount thread err!"); } #endif return RT_EOK; } INIT_APP_EXPORT(mount_init); #endif /* BSP_USING_FS */ \ | / - RT - Thread Operating System / | \ 4.0.3 build Mar 19 2021 2006 - 2020 Copyright by rt-thread team [I/SDIO] SD card capacity 123008 KB. [I/SDIO] switching card to high speed failed! [I/SFUD] Find a Winbond flash chip. Size is 16777216 bytes. [I/SFUD] norflash0 flash device is initialize success. [I/SFUD] Probe SPI flash norflash0 by SPI device spi10 success. [D/FAL] (fal_flash_init:63) Flash device | norflash0 | addr: 0x00000000 | len: 0x01000000 | blk_size: 0x00001000 |initialized finish. [I/FAL] ==================== FAL partition table ==================== [I/FAL] | name | flash_dev | offset | length | [I/FAL] ------------------------------------------------------------- [I/FAL] | wifi_image | norflash0 | 0x00000000 | 0x00080000 | [I/FAL] | bt_image | norflash0 | 0x00080000 | 0x00080000 | [I/FAL] | download | norflash0 | 0x00100000 | 0x00200000 | [I/FAL] | easyflash | norflash0 | 0x00300000 | 0x00100000 | [I/FAL] | filesystem | norflash0 | 0x00400000 | 0x00c00000 | [I/FAL] ============================================================= [I/FAL] RT-Thread Flash Abstraction Layer (V0.5.0) initialize success. [I/FAL] The FAL MTD NOR device (filesystem) created successfully The sector size of device is greater than the sector size of FAT. [W/app.filesystem] mount to '/flash1' failed! try to mkfs filesyst msh />[I/app.filesystem] mount to '/flash1' success! [I/FAL] The FAL MTD NOR device (easyflash) created successfully The sector size of device is greater than the sector size of FAT. [W/app.filesystem] mount to '/flash2' failed! try to mkfs easyflas [I/app.filesystem] sd card mount to '/sdcard' msh /> msh />ls Directory /: flash1
flash2
sdcard
```
4
个回答
默认排序
按发布时间排序
HeFeng123
2021-03-19
这家伙很懒,什么也没写!
多谢flashman2002,多谢yangjie,多谢Thread_Liu.我也挂载成功了,一个为elm,一个rom。 代码分享如下: rt_sfud_flash_probe(SPI_FLASH_NAME, SPI_FLASH_USING_SPIBUS_NAME "0"); fal_init(); fal_blk_device_create("para"); if(dfs_mount("para", "/", "elm", 0, 0) == 0) { rt_kprintf("para fatfs filesystem mount is successful\r\n"); } else { dfs_mkfs("elm", "para"); dfs_mount("para", "/", "elm", 0, 0); rt_kprintf("para fatfs filesystem mount again!"); } mkdir("data", 0x777); fal_blk_device_create("data"); dfs_mount("data", "/data", "rom", 0, &(romfs_root));
flashman2002
2021-03-19
这家伙很懒,什么也没写!
你是指挂载2种不同的文件系统吗?可以的,你使用FAL分成不同的区partition后可以使用不同的文件系统初始化后挂载的。
yangjie
认证专家
2021-03-19
hello
可以参考这个示例: https://github.com/RT-Thread/IoT_Board/tree/master/examples/15_component_fs_flash
撰写答案
登录
注册新账号
关注者
0
被浏览
1.2k
关于作者
HeFeng123
这家伙很懒,什么也没写!
提问
16
回答
19
被采纳
2
关注TA
发私信
相关问题
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
freemodbus主机在freertos的适配,参考rtthread例程
2
开源共生 商业共赢 | RT-Thread 2024开发者大会议程正式发布!
3
【24嵌入式设计大赛】基于RT-Thread星火一号的智慧家居系统
4
RT-Thread EtherKit开源以太网硬件正式发布
5
还在担心bsp不好维护吗?快使用yml管理主线bsp
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
I2C_IIC
WIZnet_W5500
UART
ota在线升级
PWM
cubemx
freemodbus
flash
packages_软件包
BSP
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
中断
Debug
编译报错
msh
SFUD
rt_mq_消息队列_msg_queue
keil_MDK
ulog
MicroPython
C++_cpp
本月问答贡献
a1012112796
20
个答案
3
次被采纳
张世争
12
个答案
3
次被采纳
踩姑娘的小蘑菇
7
个答案
3
次被采纳
用户名由3_15位
13
个答案
2
次被采纳
rv666
9
个答案
2
次被采纳
本月文章贡献
程序员阿伟
9
篇文章
2
次点赞
hhart
3
篇文章
4
次点赞
RTT_逍遥
1
篇文章
8
次点赞
大龄码农
1
篇文章
5
次点赞
ThinkCode
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部