Skip to content

Commit 1d301c3

Browse files
committed
更新软件版本。去掉一些调试信息。
1 parent 56d17a7 commit 1d301c3

10 files changed

+70
-49
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
*.a
33
/build/
44
/CMakeFiles/
5+
/out/
6+
/.vscode/
7+
/.vs/

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
cmake_minimum_required(VERSION 3.0.0)
2-
project(mkfatfs VERSION 0.1.0)
2+
project(mkfatfs VERSION 2.0.1)
33

4-
# # specify the C++ standard
5-
# set(CMAKE_CXX_STANDARD 11)
6-
# set(CMAKE_CXX_STANDARD_REQUIRED True)
4+
# specify the C++ standard
5+
set(CMAKE_CXX_STANDARD 11)
6+
set(CMAKE_CXX_STANDARD_REQUIRED True)
77

88
configure_file(Config.h.in Config.h)
99

filesystem/diskio/diskio_RAM.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ esp_err_t ff_diskio_register_RAM_partition(BYTE pdrv, RAM_handle_t RAM_handle, e
122122
esp_err_t ff_diskio_unregister_RAM_partition(BYTE pdrv, RAM_handle_t RAM_handle)
123123
{
124124
// delete part[pdrv];
125+
return ESP_OK;
125126
}
126127

127128
BYTE ff_diskio_get_pdrv_RAM(RAM_handle_t RAM_handle)

pack_fat.cpp

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
235235
{
236236
if (strcmp(findData.name, ".") == 0 || strcmp(findData.name, "..") == 0)
237237
continue;
238-
239-
std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl;
240-
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;
238+
if (g_debugLevel > 0) {
239+
std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl;
240+
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;
241+
}
241242
emulate_vfs_mkdir(dir_full_path_d.c_str(), 1);
242243
parkFilesToRamFS(dir_full_path_s.c_str(), dir_full_path_d.c_str());
243244
}
@@ -252,7 +253,9 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
252253
}
253254
break;
254255
}
255-
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;
256+
if (g_debugLevel > 0) {
257+
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;
258+
}
256259
}
257260

258261
} while (_findnext(handle, &findData) == 0);
@@ -273,10 +276,11 @@ bool Pack_fat::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
273276

274277
if (ent->d_name[0] == '.') // Ignore dir itself.
275278
continue;
279+
if (g_debugLevel > 0) {
280+
std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl;
281+
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;
282+
}
276283

277-
std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl;
278-
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;
279-
280284
struct stat path_stat;
281285
stat (dir_full_path_s.c_str(), &path_stat);
282286

@@ -333,7 +337,7 @@ int Pack_fat::unparkFileFromRamFS(const char* path_src, const char* path_des)
333337

334338
size_t size = emulate_esp_vfs_lseek(f_src, 0, SEEK_END);
335339
emulate_esp_vfs_lseek(f_src, 0, SEEK_SET);
336-
std::cout << "file size: " << size << std::endl;
340+
337341
if (g_debugLevel > 0) {
338342
std::cout << "file size: " << size << std::endl;
339343
}
@@ -375,26 +379,36 @@ bool Pack_fat::unparkFilesFromRamFS(const char* dirSrc, const char* dirDes)
375379
{
376380
continue;
377381
}
378-
379-
std::cout << "ent->d_name: "<< ent->d_name << std::endl;
382+
if (g_debugLevel > 0) {
383+
std::cout << "ent->d_name: "<< ent->d_name << std::endl;
384+
}
385+
380386
dir_full_path_s = dir_RAM_fs + "/" + ent->d_name;
381387
#if defined(_WIN32)
382388
dir_full_path_d = dir_pc + "\\" + ent->d_name;
383389
#else
384390
dir_full_path_d = dir_pc + "/" + ent->d_name;
385391
#endif
386-
std::cout << "RAM dir: "<< dir_full_path_s.c_str() << std::endl;
392+
393+
if (g_debugLevel > 0) {
394+
std::cout << "RAM dir: "<< dir_full_path_s.c_str() << std::endl;
395+
}
396+
387397
struct stat path_stat;
388398
emulate_esp_vfs_stat (dir_full_path_s.c_str(), &path_stat); //get file info.
389-
std::cout << "file mode: "<< path_stat.st_mode << std::endl;
399+
if (g_debugLevel > 0) {
400+
std::cout << "file mode: "<< path_stat.st_mode << std::endl;
401+
}
390402

391403
#if defined(_WIN32)
392404
if (S_ISDIR(path_stat.st_mode))
393405
#else
394406
if (path_stat.st_mode & 0x4000)
395407
#endif
396408
{
397-
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;
409+
if (g_debugLevel > 0) {
410+
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;
411+
}
398412
dirCreate(dir_full_path_d.c_str());
399413
if (unparkFilesFromRamFS(dir_full_path_s.c_str(), dir_full_path_d.c_str()) != 0)
400414
{
@@ -408,7 +422,6 @@ bool Pack_fat::unparkFilesFromRamFS(const char* dirSrc, const char* dirDes)
408422
#endif
409423
{
410424
// Add File to image.
411-
std::cerr << "unpark file......!" << std::endl;
412425
if (unparkFileFromRamFS(dir_full_path_s.c_str(), dir_full_path_d.c_str()) != 0) {
413426
std::cerr << "error unpark file!" << std::endl;
414427
error = true;
@@ -464,7 +477,10 @@ int Pack_fat::actionPack(std::string s_dirName, std::string s_imageName, int s_i
464477
}
465478

466479
// 6. copy all data in g_flashmem to *.bin file.
467-
std::cout << "g_flashmem[0]: " << g_flashmem[0] << "size: " << g_flashmem.size() << std::endl;
480+
if (g_debugLevel > 0) {
481+
std::cout << "g_flashmem[0]: " << g_flashmem[0] << "size: " << g_flashmem.size() << std::endl;
482+
}
483+
468484
fwrite(&g_flashmem[0], 4, g_flashmem.size()/4, fdres); //write all data in RAM fatfs to *.bin.
469485
fclose(fdres);
470486

pack_littlefs.cpp

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,10 @@ bool Pack_littlefs::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
268268
{
269269
if (strcmp(findData.name, ".") == 0 || strcmp(findData.name, "..") == 0)
270270
continue;
271-
272-
std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl;
273-
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;
271+
if (g_debugLevel > 0) {
272+
std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl;
273+
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;
274+
}
274275
lfs2_mkdir(&s_fs, dir_full_path_d.c_str()); // Ignore error, we'll catch later if it's fatal
275276
parkFilesToRamFS(dir_full_path_s.c_str(), dir_full_path_d.c_str());
276277
}
@@ -284,7 +285,9 @@ bool Pack_littlefs::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
284285
}
285286
break;
286287
}
287-
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;
288+
if (g_debugLevel > 0) {
289+
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;
290+
}
288291
}
289292

290293
} while (_findnext(handle, &findData) == 0);
@@ -306,10 +309,10 @@ bool Pack_littlefs::parkFilesToRamFS(const char* dirSrc, const char* dirDes)
306309

307310
if (ent->d_name[0] == '.') // Ignore dir itself.
308311
continue;
309-
310-
std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl;
311-
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;
312-
312+
if (g_debugLevel > 0) {
313+
std::cout << "\n" << "dir_RAM_fs: "<< dir_RAM_fs.c_str() << " dir_pc: "<< dir_pc.c_str() << std::endl;
314+
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;
315+
}
313316
struct stat path_stat;
314317
stat (dir_full_path_s.c_str(), &path_stat);
315318

@@ -405,7 +408,9 @@ bool Pack_littlefs::unparkFilesFromRamFS(const char* dirSrc, std::string dirDes)
405408
// Check if directory exists. If it does not then try to create it with permissions 755.
406409
if (! dirExists(dirDes.c_str()))
407410
{
408-
std::cout << "Directory " << dirDes << " does not exists. Try to create it." << std::endl;
411+
if (g_debugLevel > 0) {
412+
std::cout << "Directory " << dirDes << " does not exists. Try to create it." << std::endl;
413+
}
409414

410415
// Try to create directory on pc.
411416
if (! dirCreate(dirDes.c_str())) {
@@ -425,24 +430,29 @@ bool Pack_littlefs::unparkFilesFromRamFS(const char* dirSrc, std::string dirDes)
425430

426431
// Check if content is a file.
427432
if ((int)(ent.type) == LFS2_TYPE_REG) {
433+
428434
std::string name = (const char*)(ent.name);
429435
std::string dirDesFilePath = dirDes + name;
430436

431437
// Unpack file to destination directory.
432438
if (! unparkFileFromRamFS(dirSrc, &ent, dirDesFilePath.c_str()) ) {
433-
std::cout << "Can not unpack " << ent.name << "!" << std::endl;
439+
if (g_debugLevel > 0) {
440+
std::cout << "Can not unpack " << ent.name << "!" << std::endl;
441+
}
434442
return false;
435443
}
436444

437445
// Output stuff.
438-
std::cout
439-
<< dirSrc
440-
<< ent.name
441-
<< '\t'
442-
<< " > " << dirDesFilePath
443-
<< '\t'
444-
<< "size: " << ent.size << " Bytes"
445-
<< std::endl;
446+
if (g_debugLevel > 0) {
447+
std::cout
448+
<< dirSrc
449+
<< ent.name
450+
<< '\t'
451+
<< " > " << dirDesFilePath
452+
<< '\t'
453+
<< "size: " << ent.size << " Bytes"
454+
<< std::endl;
455+
}
446456
} else if (ent.type == LFS2_TYPE_DIR) {
447457
char newPath[PATH_MAX];
448458
if (dirSrc[0]) {
@@ -491,7 +501,9 @@ int Pack_littlefs::actionPack(std::string s_dirName, std::string s_imageName, in
491501
}
492502

493503
// 6. copy all data in g_flashmem to *.bin file.
494-
std::cout << "g_flashmem[0]: " << g_flashmem[0] << "size: " << g_flashmem.size() << std::endl;
504+
if (g_debugLevel > 0) {
505+
std::cout << "g_flashmem[0]: " << g_flashmem[0] << "size: " << g_flashmem.size() << std::endl;
506+
}
495507
fwrite(&g_flashmem[0], 4, g_flashmem.size()/4, fdres); //write all data in RAM littlefsfs to *.bin.
496508
fclose(fdres);
497509

release/mkfatfs_v1.0.0

-239 KB
Binary file not shown.

release/mkfatfs_v1.0.0.exe

-334 KB
Binary file not shown.

release/mkfatfs_v2.0.0

-476 KB
Binary file not shown.

release/mkfatfs_v2.0.0.exe

-1.57 MB
Binary file not shown.

sdkconfig.h.xx

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)