2013-11-01 01:51 AM
Hi,
Can anyone give me some help/advice on how to go about implementing Chan's FAT FS? I'm using MikroC Pro for ARM as my toolchain so things are going to be little bit different from most of the toolchains used on here, but principles should still be the same. Do I need to edit any of his functions, what ones do I need to call from my own code etc?2013-11-01 03:55 AM
Hi
The code is well documented and it tells you where you have to provide code. The FAT FS software provides the functions for fopen etc to read/write to FAT32 partitioned memory cards. You have to provide the low level driver to access the memory card. If I remember correctly, the driver layer is POSIX compliant. The driver has to provide read, write and control functions with absolute addressing in the memory card.2013-11-01 04:09 AM
One modifies the access functions in DISKIO.C to conform with the drive(s) and hardware abstractions thereof.
2013-11-11 06:05 AM
Hi,
I was using Chan´s FATFS and this diskio https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Attachments/27480/diskio.c and everythinkg was working ok.2014-01-20 03:49 AM
Hi again,
I'm now using FatFS and it's all working well apart from one issue I currently have. I have one function which mounts my volume, and another which creates and writes my file. My file creation function looks like this, but when I examine the file on my pc, it contains the bytes 0x00,0x00,0x3f,0x Any idea why the first two bytes are being overwritten as 0x00?void WRITE_FILE(void){
uint16_t bytesWritten;
uint8_t data[]={0x00,0x54,0x3f,0x12};
f_open(&file, ''Test.ddd'', FA_CREATE_ALWAYS | FA_WRITE);
f_write(&file,data,sizeof(data), (void *)&bytesWritten);
f_close(&file);
}
2014-01-20 06:03 AM
In disk_write() output the parameters passed, and the first 8 bytes of the sector. If you see your full data pattern here, then the problem is with your SDIO code.
2014-01-20 06:05 AM
Hi
I am not 100% certain but it could be due to memory alignment. ''uint8_t data[]={0x00,0x54,0x3f,0x12};
''
can be aligned to any byte boundary.
''(void *)&bytesWritten)
''
is forcing the address onto a 32bit boundary.
2014-01-20 09:11 AM
Clive: I'm using the USB code provided by STM for the firmware update so it's unlikely to be anything on that side of the fat stuff. I'll take a look a the parameters being passed tomorrow though and let you know if they show anything.
Sung: If that were the case, how would I go about fixing it?2014-01-20 09:33 AM
Hi
''Sung: If that were the case, how would I go about fixing it?'' ''uint8_t data[]={0x00,0x54,0x3f,0x12};
''
With this trivial case - the compiler can put the data anywhere it likes.
The compiler has packed the code in as efficiently as possible.
http://en.wikipedia.org/wiki/Data_structure_alignment
You will probably not have an issue with RAM.
You can create a buffer of type int (or any other variable type that is aligned to 4bytes)
then cast a uint8_t pointer onto that buffer.