From 5b91c54936db14c6d972fccd01732cae9cf5e8df Mon Sep 17 00:00:00 2001 From: CTCaer Date: Tue, 5 May 2020 19:21:07 +0300 Subject: [PATCH] fatfs: Backport some fixes --- bootloader/libs/fatfs/ff.c | 5 ++++- nyx/Makefile | 2 +- nyx/nyx_gui/libs/fatfs/ff.c | 5 ++++- nyx/nyx_gui/libs/lv_conf.h | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bootloader/libs/fatfs/ff.c b/bootloader/libs/fatfs/ff.c index 6c1ef8c..732e31b 100644 --- a/bootloader/libs/fatfs/ff.c +++ b/bootloader/libs/fatfs/ff.c @@ -5630,7 +5630,7 @@ FRESULT f_mkfs ( UINT len /* Size of working buffer [byte] */ ) { - const UINT n_fats = 1; /* Number of FATs for FAT/FAT32 volume (1 or 2) */ + const UINT n_fats = 2; /* Number of FATs for FAT/FAT32 volume (1 or 2) */ const UINT n_rootdir = 512; /* Number of root directory entries for FAT volume */ static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT volume (4Ks unit) */ static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128Ks unit) */ @@ -5918,6 +5918,9 @@ FRESULT f_mkfs ( if (fmt == FS_FAT32) { /* FAT32: Move FAT base */ sz_rsv += n; b_fat += n; } else { /* FAT: Expand FAT size */ + if (n % n_fats) { /* Adjust fractional error if needed */ + n--; sz_rsv++; b_fat++; + } sz_fat += n / n_fats; } diff --git a/nyx/Makefile b/nyx/Makefile index a41dcfd..476532a 100644 --- a/nyx/Makefile +++ b/nyx/Makefile @@ -63,7 +63,7 @@ OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \ lv_hal_disp.o lv_hal_indev.o lv_hal_tick.o \ interui_20.o interui_30.o ubuntu_mono.o hekate_symbol_20.o hekate_symbol_30.o hekate_symbol_120.o lv_font_builtin.o \ lv_anim.o lv_area.o lv_circ.o lv_color.o lv_font.o lv_ll.o lv_math.o lv_mem.o lv_task.o lv_txt.o lv_gc.o \ - lv_bar.o lv_btn.o lv_btnm.o lv_cb.o lv_cont.o lv_ddlist.o lv_img.o lv_kb.o lv_label.o lv_line.o lv_list.o lv_lmeter.o lv_mbox.o \ + lv_bar.o lv_btn.o lv_btnm.o lv_cb.o lv_cont.o lv_ddlist.o lv_img.o lv_label.o lv_line.o lv_list.o lv_lmeter.o lv_mbox.o \ lv_page.o lv_roller.o lv_slider.o lv_sw.o lv_tabview.o lv_ta.o lv_win.o lv_log.o lv_imgbtn.o \ lv_theme.o lv_theme_hekate.o \ ) diff --git a/nyx/nyx_gui/libs/fatfs/ff.c b/nyx/nyx_gui/libs/fatfs/ff.c index 96ed8f1..c48c036 100644 --- a/nyx/nyx_gui/libs/fatfs/ff.c +++ b/nyx/nyx_gui/libs/fatfs/ff.c @@ -5842,7 +5842,7 @@ FRESULT f_mkfs ( UINT len /* Size of working buffer [byte] */ ) { - const UINT n_fats = 1; /* Number of FATs for FAT/FAT32 volume (1 or 2) */ + const UINT n_fats = 2; /* Number of FATs for FAT/FAT32 volume (1 or 2) */ const UINT n_rootdir = 512; /* Number of root directory entries for FAT volume */ static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT volume (4Ks unit) */ static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128Ks unit) */ @@ -6130,6 +6130,9 @@ FRESULT f_mkfs ( if (fmt == FS_FAT32) { /* FAT32: Move FAT base */ sz_rsv += n; b_fat += n; } else { /* FAT: Expand FAT size */ + if (n % n_fats) { /* Adjust fractional error if needed */ + n--; sz_rsv++; b_fat++; + } sz_fat += n / n_fats; } diff --git a/nyx/nyx_gui/libs/lv_conf.h b/nyx/nyx_gui/libs/lv_conf.h index 95425a0..797d1f9 100644 --- a/nyx/nyx_gui/libs/lv_conf.h +++ b/nyx/nyx_gui/libs/lv_conf.h @@ -336,7 +336,7 @@ #define USE_LV_BTNM 1 /*Keyboard (dependencies: lv_btnm)*/ -#define USE_LV_KB 1 +#define USE_LV_KB 0 /*Check box (dependencies: lv_btn, lv_label)*/ #define USE_LV_CB 1