I have another little problem. I work on a file logger and I can't open a file, I just completed the InsertHandler for ttsting purpose :
Code: Select all
static void InsertHandler(eventid_t id) {
FRESULT err;
(void)id;
/*
* On insertion SDC initialization and FS mount.
*/
if (sdcConnect(&SDCD1))
return;
err = f_mount(0, &SDC_FS);
if (err != FR_OK) {
sdcDisconnect(&SDCD1);
return;
}
FIL fp;
if ( f_open(&fp, "0:/test.log", FA_READ | FA_WRITE | FA_OPEN_ALWAYS) == FR_OK )
{
uint8_t nb = 0;
struct tm timp;
rtcGetTimeTm(&RTCD1, &timp);
f_printf(&fp, "[TEST][%s]", asctime(&timp));
f_write(&fp, "\n", 1, &nb);
f_close(&fp);
}
f_mount(0,0);
fs_ready = TRUE;
}
The f_open function freeze.
Code: Select all
chk_mounted (path=0x200004c0, rfs=0x200004d8, chk_wp=18 '\022') at ../ChibiOS_2.5.1/ext/fatfs/src/ff.c:2019
2019 const TCHAR *p = *path;
(gdb) n
2023 vol = p[0] - '0'; /* Is there a drive number? */
(gdb)
2024 if (vol <= 9 && p[1] == ':') { /* Found a drive number, get and strip it */
(gdb)
2025 p += 2; *path = p; /* Return pointer to the path name */
(gdb)
2035 if (vol >= _VOLUMES) /* Is the drive number valid? */
(gdb)
2037 *rfs = fs = FatFs[vol]; /* Return pointer to the corresponding file system object */
(gdb)
2038 if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */
(gdb) p fs
$1 = (FATFS *) 0x2000bea8
(gdb) p *fs
$2 = {fs_type = 0 '\000', drv = 0 '\000', csize = 0 '\000', n_fats = 0 '\000', wflag = 0 '\000', fsi_flag = 0 '\000', id = 0, n_rootdir = 0, sobj = 0x200073cc,
last_clust = 0, free_clust = 0, fsi_sector = 0, n_fatent = 0, fsize = 0, fatbase = 0, dirbase = 0, database = 0, winsect = 0, win = '\000' <repeats 511 times>}
(gdb) n
2040 ENTER_FF(fs); /* Lock file system */
(gdb)
2042 if (fs->fs_type) { /* If the logical drive has been mounted */
(gdb)
2054 fs->fs_type = 0; /* Clear the file system object */
(gdb) n
2055 fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */
(gdb)
2056 stat = disk_initialize(fs->drv); /* Initialize low level disk I/O layer */
The fs_type attribute should not be 0, may be the mount function fail ?
Without my writing test, the f_getfree function works. Do I miss something ?
I use a sandisk sdhc 4go.
Board : Olimex stm32h407
ChibiOS 2.5.1