I like gdb, I can see thread free memory now.
Code: Select all
Breakpoint 1, sWriteToFile (_this=0x2000087c, logLevel=Error, fmt=0x8030a84 "SD Card mounted", ap=...) at Log/file_logger.c:184
184 FileLogWriter *flw = (FileLogWriter*) _this;
(gdb) n
186 __CHECK_AND_ROLLBACK(flw);
(gdb)
191 FRESULT err = 0;
(gdb)
192 if(!_this || ( err = wf_open(&(flw->fp), thread_file_log, FA_WRITE | FA_OPEN_ALWAYS) != FR_OK ) )
(gdb)
208 uint8_t nb = 0;
(gdb)
210 rtcGetTimeTm(&RTCD1, &timp);
(gdb) p flw
$21 = (FileLogWriter *) 0x2000087c
(gdb) n
214 err = wf_write(&(flw->fp), "[TEST][TEST]", 12, &nb);//, sGetLogPrefix(logLevel), asctime(&timp));
(gdb) p flw->fp
$22 = {fs = 0x200091d0, id = 1, flag = 18 '\022', pad1 = 0 '\000', fptr = 0, fsize = 9, sclust = 7, clust = 0, dsect = 0, dir_sect = 23536,
dir_ptr = 0x20009224 "PLSEE LOG ", buf = '\000' <repeats 511 times>}
(gdb) n
216 err = wf_write(&(flw->fp), "\n", 1, &nb);
(gdb) p flw->fp
$23 = {fs = 0x55555555, id = 21845, flag = 85 'U', pad1 = 85 'U', fptr = 1431655765, fsize = 1431655765, sclust = 1431655765, clust = 1431655765, dsect = 1431655765,
dir_sect = 1431655765, dir_ptr = 0x55555555 "", buf = 'U' <repeats 512 times>}
(gdb) p/x wa_logger_daemon
$24 = {0x2000846420008388, 0x20009b4c00000041, 0x20009d3820008464, 0x2000945c00000000, 0x14010001, 0x2000943c00000000, 0x2000944020009440, 0x120009bb4, 0x4100000000,
0x55555555ffffffff, 0x5555555555555555 <repeats 213 times>, 0x802463155555555, 0x5555555500000000, 0x5555555555555555, 0x5555555555555555, 0x8000f2555555555,
0xa006e9855555555, 0x2000941055555555, 0x8002c2f00000000, 0x802463100000000, 0x5555555500000000, 0x5555555555555555, 0x5555555555555555, 0x8000f2555555555,
0xa006e9855555555, 0x2000941055555555, 0x8002c2f00000000, 0x20006e9800000000, 0x2000941000000000, 0x80234c920009bb8, 0xc20009c0a, 0x10000000800045e,
0x20006e9800000000, 0x0, 0x8002c3355555555, 0x21000000080246c2, 0x8030a8420009c50, 0x2000087c04555555, 0x2300000000, 0x1700000020, 0x60000000b, 0x200000064,
0xffffffff00000000, 0x20000000000c5555, 0x80249ad00000008, 0x20009c50000001f4, 0x400a13c08030a84, 0x20007edc, 0x802459f08024471, 0x8030a8420009410, 0x20009c50,
0x408024555, 0x20007f3400000001, 0x55555555, 0x0, 0x2000940800000200, 0x820009410, 0x2000940c00000000, 0x420009410, 0x200091cc00000000, 0x220009410,
0x200091c800000000, 0x120009410, 0x400000000, 0x800048f20009410, 0x80010b920009410}
(gdb) p chUnusedStack(wa_logger_daemon,sizeof(wa_logger_daemon))
$25 = 1786
(gdb) p flw
$26 = (FileLogWriter *) 0x20000000
(gdb)
So, now, I can write one time, the second call hangs. I lost a pointer ! I think the probleme is now outside the fatfs. I just correct one thing before a f_stat call : don't forget to memset the FILINFO struct to 0, elsewhere, a lfsize is unitilised and used.