Skip to content

Commit

Permalink
更新软件版本。去掉一些调试信息。
Browse files Browse the repository at this point in the history
  • Loading branch information
diskman88 committed Aug 17, 2020
1 parent 56d17a7 commit 1d301c3
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*.a
/build/
/CMakeFiles/
/out/
/.vscode/
/.vs/
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
1 change: 1 addition & 0 deletions filesystem/diskio/diskio_RAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
46 changes: 31 additions & 15 deletions pack_fat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -375,26 +379,36 @@ 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))
#else
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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
50 changes: 31 additions & 19 deletions pack_littlefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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())) {
Expand All @@ -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]) {
Expand Down Expand Up @@ -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);

Expand Down
Binary file removed release/mkfatfs_v1.0.0
Binary file not shown.
Binary file removed release/mkfatfs_v1.0.0.exe
Binary file not shown.
Binary file removed release/mkfatfs_v2.0.0
Binary file not shown.
Binary file removed release/mkfatfs_v2.0.0.exe
Binary file not shown.
11 changes: 0 additions & 11 deletions sdkconfig.h.xx

This file was deleted.

0 comments on commit 1d301c3

Please sign in to comment.