2023-12-02 00:27:57 +08:00
|
|
|
|
#include "cons_cli.h"
|
2023-09-24 01:26:07 +08:00
|
|
|
|
#include "fs_rpc.h"
|
2025-02-13 13:28:16 +08:00
|
|
|
|
#include "ns_cli.h"
|
|
|
|
|
|
#include "u_env.h"
|
|
|
|
|
|
#include "u_hd_man.h"
|
|
|
|
|
|
#include "u_log.h"
|
|
|
|
|
|
#include "u_prot.h"
|
|
|
|
|
|
#include "u_rpc_svr.h"
|
|
|
|
|
|
#include <assert.h>
|
2023-09-24 01:26:07 +08:00
|
|
|
|
#include <ff.h>
|
2023-09-21 21:44:17 +08:00
|
|
|
|
#include <stdio.h>
|
2023-10-03 17:46:02 +08:00
|
|
|
|
#include <stdlib.h>
|
2025-02-13 13:28:16 +08:00
|
|
|
|
#include "u_hd_man.h"
|
2025-01-03 18:29:25 +08:00
|
|
|
|
#include <u_fast_ipc.h>
|
2025-02-13 13:28:16 +08:00
|
|
|
|
|
2025-01-03 18:29:25 +08:00
|
|
|
|
#define STACK_COM_ITME_SIZE (2048)
|
|
|
|
|
|
ATTR_ALIGN(8)
|
|
|
|
|
|
uint8_t stack_coms[STACK_COM_ITME_SIZE];
|
|
|
|
|
|
uint8_t msg_buf_coms[MSG_BUG_LEN];
|
2025-02-13 13:28:16 +08:00
|
|
|
|
static obj_handler_t com_th_obj;
|
|
|
|
|
|
|
2025-01-03 18:29:25 +08:00
|
|
|
|
void fast_ipc_init(void)
|
|
|
|
|
|
{
|
2025-02-13 13:28:16 +08:00
|
|
|
|
com_th_obj = handler_alloc();
|
|
|
|
|
|
assert(com_th_obj != HANDLER_INVALID);
|
|
|
|
|
|
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
|
2025-01-03 18:29:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-09 12:58:57 +08:00
|
|
|
|
static FATFS fs;
|
|
|
|
|
|
static MKFS_PARM defopt = {FM_ANY, 0, 0, 0};
|
2023-09-07 23:47:34 +08:00
|
|
|
|
|
2023-09-08 21:39:02 +08:00
|
|
|
|
int main(int args, char *argv[])
|
|
|
|
|
|
{
|
2023-12-02 22:02:56 +08:00
|
|
|
|
obj_handler_t hd;
|
|
|
|
|
|
int ret;
|
2025-01-03 18:29:25 +08:00
|
|
|
|
fast_ipc_init();
|
2023-12-02 22:02:56 +08:00
|
|
|
|
|
|
|
|
|
|
ret = rpc_meta_init(THREAD_MAIN, &hd);
|
2023-10-02 00:22:13 +08:00
|
|
|
|
assert(ret >= 0);
|
2023-12-02 22:02:56 +08:00
|
|
|
|
fs_svr_init();
|
2025-02-25 23:59:56 +08:00
|
|
|
|
ns_register("/mnt", hd, 0);
|
2023-10-02 00:22:13 +08:00
|
|
|
|
|
2023-09-09 12:58:57 +08:00
|
|
|
|
FRESULT res = f_mount(&fs, "0:", 1);
|
2023-09-22 00:14:27 +08:00
|
|
|
|
|
2025-02-13 13:28:16 +08:00
|
|
|
|
if (res != FR_OK) {
|
2023-10-03 17:46:02 +08:00
|
|
|
|
assert(sizeof(fs.win) >= FF_MAX_SS);
|
|
|
|
|
|
res = f_mkfs("0:", &defopt, (void *)(fs.win), FF_MAX_SS); // 第三个参数可以设置成NULL,默认使用heap memory
|
2025-02-13 13:28:16 +08:00
|
|
|
|
if (res != FR_OK) {
|
2023-12-02 00:27:57 +08:00
|
|
|
|
cons_write_str("f_mkfs err.\n");
|
2023-10-03 17:46:02 +08:00
|
|
|
|
exit(-1);
|
2025-02-13 13:28:16 +08:00
|
|
|
|
} else {
|
2023-09-09 12:58:57 +08:00
|
|
|
|
res = f_mount(&fs, "0:", 1);
|
2025-02-13 13:28:16 +08:00
|
|
|
|
if (res != FR_OK) {
|
2023-12-02 00:27:57 +08:00
|
|
|
|
cons_write_str("f_mount err.\n");
|
2023-10-03 17:46:02 +08:00
|
|
|
|
exit(-1);
|
2023-09-09 12:58:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-09 23:11:55 +08:00
|
|
|
|
cons_write_str("fatfs mount success\n");
|
2023-09-24 01:26:07 +08:00
|
|
|
|
|
|
|
|
|
|
fs_svr_loop();
|
2023-10-03 17:46:02 +08:00
|
|
|
|
return 0;
|
2023-09-08 21:39:02 +08:00
|
|
|
|
}
|