diff --git a/.gitignore b/.gitignore index 7e7bdfa..96bb9e8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *.a /build/ /CMakeFiles/ +/out/ +/.vscode/ +/.vs/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 657fe79..33eb0fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.0.0) -project(mkfatfs VERSION 0.1.0) +project(mkfatfs VERSION 2.0.1) -# # specify the C++ standard -# set(CMAKE_CXX_STANDARD 11) -# set(CMAKE_CXX_STANDARD_REQUIRED True) +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) configure_file(Config.h.in Config.h) diff --git a/filesystem/diskio/diskio_RAM.cpp b/filesystem/diskio/diskio_RAM.cpp index 029409e..e160aaf 100644 --- a/filesystem/diskio/diskio_RAM.cpp +++ b/filesystem/diskio/diskio_RAM.cpp @@ -122,6 +122,7 @@ esp_err_t ff_diskio_register_RAM_partition(BYTE pdrv, RAM_handle_t RAM_handle, e esp_err_t ff_diskio_unregister_RAM_partition(BYTE pdrv, RAM_handle_t RAM_handle) { // delete part[pdrv]; + return ESP_OK; } BYTE ff_diskio_get_pdrv_RAM(RAM_handle_t RAM_handle) diff --git a/pack_fat.cpp b/pack_fat.cpp index 834ca3c..88083ff 100644 --- a/pack_fat.cpp +++ b/pack_fat.cpp @@ -235,9 +235,10 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes) { if (strcmp(findData.name, ".") == 0 || strcmp(findData.name, "..") == 0) continue; - - std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl; - std::cout << "Sub dir: "<< findData.name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; + if (g_debugLevel > 0) { + std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl; + std::cout << "Sub dir: "<< findData.name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; + } emulate_vfs_mkdir(dir_full_path_d.c_str(), 1); parkFilesToRamFS(dir_full_path_s.c_str(), dir_full_path_d.c_str()); } @@ -252,7 +253,9 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes) } break; } - std::cout << "Pack file, dir_full_path_s: " << dir_full_path_s.c_str() << "dir_full_path_d: "<< dir_full_path_d.c_str() << " file name: "<< findData.name << std::endl; + if (g_debugLevel > 0) { + std::cout << "Pack file, dir_full_path_s: " << dir_full_path_s.c_str() << "dir_full_path_d: "<< dir_full_path_d.c_str() << " file name: "<< findData.name << std::endl; + } } } while (_findnext(handle, &findData) == 0); @@ -273,10 +276,11 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes) if (ent->d_name[0] == '.') // Ignore dir itself. continue; + if (g_debugLevel > 0) { + std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl; + std::cout << "Sub dir: "<< ent->d_name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; + } - std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl; - std::cout << "Sub dir: "<< ent->d_name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; - struct stat path_stat; stat (dir_full_path_s.c_str(), &path_stat); @@ -333,7 +337,7 @@ int Pack_fat::unparkFileFromRamFS(const char* path_src, const char* path_des) size_t size = emulate_esp_vfs_lseek(f_src, 0, SEEK_END); emulate_esp_vfs_lseek(f_src, 0, SEEK_SET); - std::cout << "file size: " << size << std::endl; + if (g_debugLevel > 0) { std::cout << "file size: " << size << std::endl; } @@ -375,18 +379,26 @@ bool Pack_fat::unparkFilesFromRamFS(const char* dirSrc, const char* dirDes) { continue; } - - std::cout << "ent->d_name: "<< ent->d_name << std::endl; + if (g_debugLevel > 0) { + std::cout << "ent->d_name: "<< ent->d_name << std::endl; + } + dir_full_path_s = dir_RAM_fs + "/" + ent->d_name; #if defined(_WIN32) dir_full_path_d = dir_pc + "\\" + ent->d_name; #else dir_full_path_d = dir_pc + "/" + ent->d_name; #endif - std::cout << "RAM dir: "<< dir_full_path_s.c_str() << std::endl; + + if (g_debugLevel > 0) { + std::cout << "RAM dir: "<< dir_full_path_s.c_str() << std::endl; + } + struct stat path_stat; emulate_esp_vfs_stat (dir_full_path_s.c_str(), &path_stat); //get file info. - std::cout << "file mode: "<< path_stat.st_mode << std::endl; + if (g_debugLevel > 0) { + std::cout << "file mode: "<< path_stat.st_mode << std::endl; + } #if defined(_WIN32) if (S_ISDIR(path_stat.st_mode)) @@ -394,7 +406,9 @@ bool Pack_fat::unparkFilesFromRamFS(const char* dirSrc, const char* dirDes) if (path_stat.st_mode & 0x4000) #endif { - std::cout << "Sub dir: "<< ent->d_name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; + if (g_debugLevel > 0) { + std::cout << "Sub dir: "<< ent->d_name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; + } dirCreate(dir_full_path_d.c_str()); if (unparkFilesFromRamFS(dir_full_path_s.c_str(), dir_full_path_d.c_str()) != 0) { @@ -408,7 +422,6 @@ bool Pack_fat::unparkFilesFromRamFS(const char* dirSrc, const char* dirDes) #endif { // Add File to image. - std::cerr << "unpark file......!" << std::endl; if (unparkFileFromRamFS(dir_full_path_s.c_str(), dir_full_path_d.c_str()) != 0) { std::cerr << "error unpark file!" << std::endl; error = true; @@ -464,7 +477,10 @@ int Pack_fat::actionPack(std::string s_dirName, std::string s_imageName, int s_i } // 6. copy all data in g_flashmem to *.bin file. - std::cout << "g_flashmem[0]: " << g_flashmem[0] << "size: " << g_flashmem.size() << std::endl; + if (g_debugLevel > 0) { + std::cout << "g_flashmem[0]: " << g_flashmem[0] << "size: " << g_flashmem.size() << std::endl; + } + fwrite(&g_flashmem[0], 4, g_flashmem.size()/4, fdres); //write all data in RAM fatfs to *.bin. fclose(fdres); diff --git a/pack_littlefs.cpp b/pack_littlefs.cpp index d08a35e..9804d49 100644 --- a/pack_littlefs.cpp +++ b/pack_littlefs.cpp @@ -268,9 +268,10 @@ bool Pack_littlefs::parkFilesToRamFS(const char* dirSrc, const char* dirDes) { if (strcmp(findData.name, ".") == 0 || strcmp(findData.name, "..") == 0) continue; - - std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl; - std::cout << "Sub dir: "<< findData.name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; + if (g_debugLevel > 0) { + std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl; + std::cout << "Sub dir: "<< findData.name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; + } lfs2_mkdir(&s_fs, dir_full_path_d.c_str()); // Ignore error, we'll catch later if it's fatal parkFilesToRamFS(dir_full_path_s.c_str(), dir_full_path_d.c_str()); } @@ -284,7 +285,9 @@ bool Pack_littlefs::parkFilesToRamFS(const char* dirSrc, const char* dirDes) } break; } - std::cout << "Pack file, dir_full_path_s: " << dir_full_path_s.c_str() << "dir_full_path_d: "<< dir_full_path_d.c_str() << " file name: "<< findData.name << std::endl; + if (g_debugLevel > 0) { + std::cout << "Pack file, dir_full_path_s: " << dir_full_path_s.c_str() << "dir_full_path_d: "<< dir_full_path_d.c_str() << " file name: "<< findData.name << std::endl; + } } } while (_findnext(handle, &findData) == 0); @@ -306,10 +309,10 @@ bool Pack_littlefs::parkFilesToRamFS(const char* dirSrc, const char* dirDes) if (ent->d_name[0] == '.') // Ignore dir itself. continue; - - std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl; - std::cout << "Sub dir: "<< ent->d_name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; - + if (g_debugLevel > 0) { + std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl; + std::cout << "Sub dir: "<< ent->d_name << " full dir_full_path_s: "<< dir_full_path_s.c_str() << " full dir_full_path_d: "<< dir_full_path_d.c_str() << "\n" << std::endl; + } struct stat path_stat; stat (dir_full_path_s.c_str(), &path_stat); @@ -405,7 +408,9 @@ bool Pack_littlefs::unparkFilesFromRamFS(const char* dirSrc, std::string dirDes) // Check if directory exists. If it does not then try to create it with permissions 755. if (! dirExists(dirDes.c_str())) { - std::cout << "Directory " << dirDes << " does not exists. Try to create it." << std::endl; + if (g_debugLevel > 0) { + std::cout << "Directory " << dirDes << " does not exists. Try to create it." << std::endl; + } // Try to create directory on pc. if (! dirCreate(dirDes.c_str())) { @@ -425,24 +430,29 @@ bool Pack_littlefs::unparkFilesFromRamFS(const char* dirSrc, std::string dirDes) // Check if content is a file. if ((int)(ent.type) == LFS2_TYPE_REG) { + std::string name = (const char*)(ent.name); std::string dirDesFilePath = dirDes + name; // Unpack file to destination directory. if (! unparkFileFromRamFS(dirSrc, &ent, dirDesFilePath.c_str()) ) { - std::cout << "Can not unpack " << ent.name << "!" << std::endl; + if (g_debugLevel > 0) { + std::cout << "Can not unpack " << ent.name << "!" << std::endl; + } return false; } // Output stuff. - std::cout - << dirSrc - << ent.name - << '\t' - << " > " << dirDesFilePath - << '\t' - << "size: " << ent.size << " Bytes" - << std::endl; + if (g_debugLevel > 0) { + std::cout + << dirSrc + << ent.name + << '\t' + << " > " << dirDesFilePath + << '\t' + << "size: " << ent.size << " Bytes" + << std::endl; + } } else if (ent.type == LFS2_TYPE_DIR) { char newPath[PATH_MAX]; if (dirSrc[0]) { @@ -491,7 +501,9 @@ int Pack_littlefs::actionPack(std::string s_dirName, std::string s_imageName, in } // 6. copy all data in g_flashmem to *.bin file. - std::cout << "g_flashmem[0]: " << g_flashmem[0] << "size: " << g_flashmem.size() << std::endl; + if (g_debugLevel > 0) { + std::cout << "g_flashmem[0]: " << g_flashmem[0] << "size: " << g_flashmem.size() << std::endl; + } fwrite(&g_flashmem[0], 4, g_flashmem.size()/4, fdres); //write all data in RAM littlefsfs to *.bin. fclose(fdres); diff --git a/release/mkfatfs_v1.0.0 b/release/mkfatfs_v1.0.0 deleted file mode 100644 index d775d51..0000000 Binary files a/release/mkfatfs_v1.0.0 and /dev/null differ diff --git a/release/mkfatfs_v1.0.0.exe b/release/mkfatfs_v1.0.0.exe deleted file mode 100644 index 00d2070..0000000 Binary files a/release/mkfatfs_v1.0.0.exe and /dev/null differ diff --git a/release/mkfatfs_v2.0.0 b/release/mkfatfs_v2.0.0 deleted file mode 100644 index a6b86a3..0000000 Binary files a/release/mkfatfs_v2.0.0 and /dev/null differ diff --git a/release/mkfatfs_v2.0.0.exe b/release/mkfatfs_v2.0.0.exe deleted file mode 100644 index e6eb606..0000000 Binary files a/release/mkfatfs_v2.0.0.exe and /dev/null differ diff --git a/sdkconfig.h.xx b/sdkconfig.h.xx deleted file mode 100644 index 4b130dd..0000000 --- a/sdkconfig.h.xx +++ /dev/null @@ -1,11 +0,0 @@ - -#define CONFIG_WL_SECTOR_SIZE 4096 -#define CONFIG_WL_SECTOR_MODE - -#define CONFIG_FATFS_CODEPAGE 437 - -#define CONFIG_FATFS_LFN_HEAP 1 -//#define CONFIG_FATFS_LFN_STACK 1 -#define CONFIG_FATFS_MAX_LFN 127 - -//#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1