AC52 系列虚拟u盘使用说明文档
📎 原始文档:https://www.kdocs.cn/l/ccZmua9Tpqcb AC52 系列虚拟u盘使用说明文档
目录
TOC \o "1-3" \h \u HYPERLINK \l "_Toc131273148" 一、功能描述 PAGEREF _Toc131273148 \h 2
HYPERLINK \l "_Toc131273149" 二、软硬件测试环境 PAGEREF _Toc131273149 \h 2
HYPERLINK \l "_Toc131273150" 三、虚拟u盘环境配置 PAGEREF _Toc131273150 \h 2
一、功能描述
该功能可以使得AC52系列外挂的flash某一内存区域挂载上FAT文件系统,并且通过usb实现了虚拟U盘的功能。
二、软硬件测试环境
测试软件环境:V1.1.6 SDK。
测试硬件环境:5211开发板+8M的华邦flash。
三、虚拟u盘环境配置
板级文件配置参考:
注意正确选择文件系统挂载地址,挂载容量。
usb模式配置:
请在app_main函数加入测试逻辑:
- /*
- * 应用程序主函数
- */
- void app_main()
- {
- // if (!fdir_exist("mnt/spiflash")) {
- //// mount("spiflash", "mnt/spiflash", "sdfile", 0, NULL);
- // }
- mount_sd_to_fs(SDX_DEV);
- err = upgrade_detect(SDX_DEV);
- if (!err) {
- return;
- }
- // 接电脑进盘符模式
- os_time_dly(200);
- set_usb_mass_storage();
- return;
- char buf[101]={0};
- int l_cnt = 3;
- struct imount *mt;
- #define FLASH_ROOT_PATH "storage/extflash"
- #if 0//挂载文件系统
- do{
- os_time_dly(100);
- if (!fdir_exist(FLASH_ROOT_PATH)) {
- puts("fdir_exist == 0!\n");
- mt = mount("extflash", FLASH_ROOT_PATH, "flashfs", 0, NULL);
- if (!mt) {
- puts("mount flashfs fail\n");
- int err0 = f_format("extflash","flashfs", 0);
- printf("f_format err_code:%d\n", err0);
- }
- else {
- puts("mount flashfs suss\n");
- if (!fdir_exist(FLASH_ROOT_PATH)){
- puts("mount suss but fdir no exist!!\n");
- }
- break;
- }
- }else{
- break;
- }
- }while(l_cnt--);
- #endif // 0
- #if 0
- FILE* fp= fopen(FLASH_ROOT_PATH"/C/readme.txt", "w+");//"mnt/spiflash/
- if(fp){
- puts("fopen ok\n");
- fwrite(fp, "hello world!", 10);
- fclose(fp);
- }else{
- puts("fopen err\n");
- }
- #else
- //总是挂载失败请注意:检查jl_isd.bin超板级所设置的extflash大小和地址,每次烧录后将原来的文件系统给擦除了
- mt = mount("extflash", FLASH_ROOT_PATH, "flashfs", 0, NULL);
- if (!mt) {
- puts("mount flashfs fail\n");
- return;
- }
- FILE* fp= fopen(FLASH_ROOT_PATH"/C/readme.txt", "r");//"mnt/spiflash/
- if(fp){
- puts("fopen ok\n");
- fread(fp, buf, 100);
- printf("buf %s\n", buf);
- fclose(fp);
- }else{
- puts("fopen err\n");
- }
- #endif // 0
- return;
- }
杰理科技
2023年04月01日