添加tmpfs文件系统为根目录

修改挂载路径
添加数据处理资源
This commit is contained in:
sc committed 2025-11-21 02:31:43 +08:00
1 parent 879bd943a4
commit 1c13877a10
8 files changed
+16 -27

No files matched your search

+3 -15
View File
@@ -14,11 +14,11 @@
#include "DB_SQLite.h"
#include "sqlite3.h"
#define DB_NAME "/SC828.db"
#define DB_NAME "/sddisk/SC828.db"
int db_HelperInit;
rt_mq_t db_mq = RT_NULL; //
#define DBG_TAG "db_sql"
#define DBG_TAG "dat_sql"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
@@ -190,18 +190,6 @@ void db_sqlite_init_full(void)
if (access(DB_NAME, F_OK) != 0)
{
// 先测试文件系统是否可写
LOG_E("[SD] Test File System...");
int test_fd = open("/db_test.tmp", O_CREAT | O_WRONLY, 0);
if (test_fd < 0) {
LOG_E("[DB] ERROR: Root filesystem not writable! errno=%d", errno);
return;
}
write(test_fd, "test", 4);
close(test_fd);
unlink("/db_test.tmp");
LOG_D("[SD] File system available.");
// 创建新数据库
if (sqlite3_open(DB_NAME, &g_db) != SQLITE_OK)
{
@@ -458,6 +446,6 @@ void thread_DB_SQLite(void)
}
else
{
LOG_D("Failed to create led thread!\n");
LOG_D("Failed to create SQLite thread!\n");
}
}
+4 -4
View File
@@ -10,7 +10,6 @@
#include <rtthread.h>
#include "dfs_fs.h"
#define DBG_TAG "mount_fs"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
@@ -25,9 +24,10 @@ void sd_mount(void *parameter)
{
if (rt_device_find("sd") != RT_NULL)
{
if (dfs_mount("sd", "/", "elm", 0, NULL) == RT_EOK)
mkdir("/sddisk", 0777);
if (dfs_mount("sd", "/sddisk", "elm", 0, NULL) == RT_EOK)
{
LOG_I("SD card mounted to '/' successfully");
LOG_I("SD card mounted to '/sddisk' successfully");
// 挂载成功,释放信号量
if (mount_sem != RT_NULL)
{
@@ -46,7 +46,7 @@ void sd_mount(void *parameter)
}
// 避免空转,延时 100ms 再试
rt_thread_mdelay(500);
rt_thread_mdelay(100);
retry++;
}
}
+5 -1
View File
@@ -9,8 +9,11 @@
*/
#include <rtthread.h>
#include <dfs_posix.h>
#include "RUN_LED.h"
#include "DB_SQLite.h"
#include "DATA_comm.h"
#include "DATA_uart.h"
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
@@ -22,7 +25,8 @@ int main(void)
{
rt_sem_take(mount_sem, rt_tick_from_millisecond(5000)); // 等待挂载完成,最多等待 5 秒
thread_DB_SQLite();
data_comm_init();
//start_uart_thread();
thread_RUN_LED();//运行指示灯线程
return RT_EOK;
}