2023-09-09 12:58:57 +08:00
|
|
|
|
#include "u_log.h"
|
2023-09-24 01:26:07 +08:00
|
|
|
|
#include "ns_cli.h"
|
|
|
|
|
|
#include "u_rpc_svr.h"
|
|
|
|
|
|
#include "u_prot.h"
|
|
|
|
|
|
#include "fs_rpc.h"
|
|
|
|
|
|
#include <ff.h>
|
2023-09-21 21:44:17 +08:00
|
|
|
|
#include <stdio.h>
|
2023-09-24 01:26:07 +08:00
|
|
|
|
#include <assert.h>
|
2023-09-09 12:58:57 +08:00
|
|
|
|
static FATFS fs;
|
|
|
|
|
|
static BYTE buff[512];
|
|
|
|
|
|
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-09-09 12:58:57 +08:00
|
|
|
|
FRESULT res = f_mount(&fs, "0:", 1);
|
2023-09-22 00:14:27 +08:00
|
|
|
|
|
2023-09-09 12:58:57 +08:00
|
|
|
|
if (res != FR_OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
res = f_mkfs("0:", &defopt, buff, 512); // 第三个参数可以设置成NULL,默认使用heap memory
|
|
|
|
|
|
if (res != FR_OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
printf("f_mkfs err.\n");
|
|
|
|
|
|
while (1)
|
|
|
|
|
|
;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
res = f_mount(&fs, "0:", 1);
|
|
|
|
|
|
if (res != FR_OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
printf("f_mount err.\n");
|
|
|
|
|
|
while (1)
|
|
|
|
|
|
;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
printf("mount success\n");
|
2023-09-24 01:26:07 +08:00
|
|
|
|
obj_handler_t ipc_hd;
|
|
|
|
|
|
int ret = rpc_creaite_bind_ipc(THREAD_MAIN, NULL, &ipc_hd);
|
|
|
|
|
|
assert(ret >= 0);
|
|
|
|
|
|
ns_register("fs", ipc_hd);
|
|
|
|
|
|
|
|
|
|
|
|
fs_svr_init(ipc_hd);
|
|
|
|
|
|
fs_svr_loop();
|
2023-09-08 21:39:02 +08:00
|
|
|
|
while (1)
|
|
|
|
|
|
;
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|