C:/Espressif/tools/riscv32-esp-elf/esp-15.2.0_20251204/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/15.2.0/../../../../riscv32-esp-elf/bin/ld.exe: esp-idf/lvgl__lvgl/liblvgl__lvgl.a(lv_fs_fatfs.c.obj): in function `fs_dir_read':
C:/ESP-IDF Projects/Latest-version-V6-compatible/Waveshare/Test_fatfs/managed_components/lvgl__lvgl/src/libs/fsdrv/lv_fs_fatfs.c:278:(.text.fs_dir_read.part.0.constprop.0+0x48): undefined reference to `f_readdir'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The failure appears to be in this section the loop starts at line 268:
do {
res = f_readdir(dir_p, &fno);
if(res != FR_OK) return LV_FS_RES_UNKNOWN;
if(fno.fname[0] == 0) break; /* End of the directory */
if(fno.fattrib & AM_DIR) {
lv_snprintf(fn, fn_len, "/%s", fno.fname);
}
else lv_strlcpy(fn, fno.fname, fn_len);
} while(lv_strcmp(fn, "/.") == 0 || lv_strcmp(fn, "/..") == 0);
return LV_FS_RES_OK;
}
Thank you for your reply, This is the config generated code for fatfs:
# FAT Filesystem support
#
# default:
CONFIG_FATFS_VOLUME_COUNT=2
# default:
# CONFIG_FATFS_LFN_NONE is not set
# default:
CONFIG_FATFS_LFN_HEAP=y
# default:
# CONFIG_FATFS_LFN_STACK is not set
# default:
# CONFIG_FATFS_SECTOR_512 is not set
# default:
CONFIG_FATFS_SECTOR_4096=y
# default:
# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set
# default:
CONFIG_FATFS_CODEPAGE_437=y
# default:
# CONFIG_FATFS_CODEPAGE_720 is not set
# default:
# CONFIG_FATFS_CODEPAGE_737 is not set
# default:
# CONFIG_FATFS_CODEPAGE_771 is not set
# default:
# CONFIG_FATFS_CODEPAGE_775 is not set
# default:
# CONFIG_FATFS_CODEPAGE_850 is not set
# default:
# CONFIG_FATFS_CODEPAGE_852 is not set
# default:
# CONFIG_FATFS_CODEPAGE_855 is not set
# default:
# CONFIG_FATFS_CODEPAGE_857 is not set
# default:
# CONFIG_FATFS_CODEPAGE_860 is not set
# default:
# CONFIG_FATFS_CODEPAGE_861 is not set
# default:
# CONFIG_FATFS_CODEPAGE_862 is not set
# default:
# CONFIG_FATFS_CODEPAGE_863 is not set
# default:
# CONFIG_FATFS_CODEPAGE_864 is not set
# default:
# CONFIG_FATFS_CODEPAGE_865 is not set
# default:
# CONFIG_FATFS_CODEPAGE_866 is not set
# default:
# CONFIG_FATFS_CODEPAGE_869 is not set
# default:
# CONFIG_FATFS_CODEPAGE_932 is not set
# default:
# CONFIG_FATFS_CODEPAGE_936 is not set
# default:
# CONFIG_FATFS_CODEPAGE_949 is not set
# default:
# CONFIG_FATFS_CODEPAGE_950 is not set
# default:
CONFIG_FATFS_CODEPAGE=437
# default:
CONFIG_FATFS_MAX_LFN=255
# default:
CONFIG_FATFS_API_ENCODING_ANSI_OEM=y
# default:
# CONFIG_FATFS_API_ENCODING_UTF_8 is not set
# default:
CONFIG_FATFS_FS_LOCK=0
# default:
CONFIG_FATFS_TIMEOUT_MS=10000
# default:
CONFIG_FATFS_PER_FILE_CACHE=y
# default:
CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y
# default:
# CONFIG_FATFS_USE_FASTSEEK is not set
# default:
CONFIG_FATFS_USE_STRFUNC_NONE=y
# default:
# CONFIG_FATFS_USE_STRFUNC_WITHOUT_CRLF_CONV is not set
# default:
# CONFIG_FATFS_USE_STRFUNC_WITH_CRLF_CONV is not set
# default:
CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0
# default:
# CONFIG_FATFS_IMMEDIATE_FSYNC is not set
# default:
# CONFIG_FATFS_USE_LABEL is not set
# default:
CONFIG_FATFS_LINK_LOCK=y
# default:
CONFIG_FATFS_USE_DYN_BUFFERS=y
#
# File system free space calculation behavior
#
# default:
CONFIG_FATFS_DONT_TRUST_FREE_CLUSTER_CNT=0
# default:
CONFIG_FATFS_DONT_TRUST_LAST_ALLOC=0
# end of File system free space calculation behavior
# end of FAT Filesystem support
By default .CONFIG_FATFS_LFN_HEAP=y I will try setting it explicitly.
SDK Config editor shows:
Thank you for the much needed offer of help. My first task is to completely uninstall ESP-IDF and VS-CODE. Much of what I did was came from Copilot. A lot of its instructions were just plain wrong and I was foolish enough not to keep a proper record of everything it did to my environment. I will reinstall and check that the projects I wrote without the help of AI still work and then start an new project using ESP32-P4 nano, lvlg and setup USB OTG to access the SD card via the connection to my PC USB using a seperate core (the Waveshare ESP32P4 nano has a single USB OTG port). Once that works OK I will add the fatfs code. On my original attempt I got the filesystem to work but it conflicted with lvgl; I was trying to to get fs to run on the second core and let lvgl run on the first core. It was at that point the I got ‘help’ from Copilot