cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4-DIscovery FAT example wrong

chief
Associate II
Posted on April 07, 2015 at 12:52

In example:

if(f_open(&MyFile, ''STM32.TXT'', FA_CREATE_ALWAYS | FA_WRITE) != FR_OK) 

Keil output:

 error:  &sharp167: argument of type ''char *'' is incompatible with parameter of type ''const TCHAR *''

        if(f_open(&MyFile, ''STM32.TXT'', FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)

#whiskey-tango-foxtrot
5 REPLIES 5
Amel NASRI
ST Employee
Posted on April 07, 2015 at 18:21

Which STM32CubeF4 package & µVision versions are you using?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

chief
Associate II
Posted on April 08, 2015 at 08:14

STM32CubeMX Software V4.7.0 / 20 March 2015

STM32CubeF4 Firmware Package V1.5.0 /13-March-2015

µVision V5.0.0 Tool Version Numbers: Toolchain: MDK-ARM Standard Version: 5.0.0 C Compiler: Armcc.exe V5.05 update 1 (build 106) Assembler: Armasm.exe V5.05 update 1 (build 106) Linker/Locator: ArmLink.exe V5.05 update 1 (build 106) Library Manager: ArmAr.exe V5.05 update 1 (build 106) Hex Converter: FromElf.exe V5.05 update 1 (build 106) CPU DLL: SARMCM3.DLL V5.0.0 Dialog DLL: DCM.DLL V1.1.0 Target DLL: STLink\ST-LINKIII-KEIL_SWO.dll V2.0.0_KEIL Dialog DLL: TCM.DLL V1.4.0 And some fun thnigs - autogenerated code for SDIO mode ''SD 1 bit'' have HardFault, then i try to use f_open My example:

FATFS FileSystem;
uint8_t DiskPath[4];
FIL LogFile;
if(retSD==0)
{
printf(''Link MicroSD Driver:\t[OK]
'');
if(f_mount(&FileSystem, (TCHAR const*)DiskPath, 0) != FR_OK)
{
printf(''Mount file system:\t[FAIL]
'');
}
else
{
printf(''Mount file system:\t[OK]
'');
if(f_open(&LogFile,(TCHAR *) ''log.txt'',FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
printf(''Opening file:\t[FAIL]
'');
}
else
{
printf(''Opening file:\t\t[OK]
'');
uint32_t byteswritten;
if(f_write(&LogFile,''Hello world'',sizeof(''Hello world''),(void *)&byteswritten) != FR_OK)
{
printf(''Writing:\t\t[FAIL]'');
}
else
{
printf(''Writing:\t\t[OK]'');
printf(''Writed %d bytes
'',byteswritten);
if(f_close(&LogFile) != FR_OK)
{
printf(''Close file:\t\t[FAIL]'');
}
else
{
printf(''Close file:\t\t[OK]'');
}
}
}
}
}
else
{
printf(''Link MicroSD Driver:\t[FAIL]
'');
}

As i know - in file ff.c (f_open function) at string №2446 res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); after thet string pointer to hsd->Instance will be modifed (hsd->Instance must bee 0x12C00, but after this function it have value 0xA) Tested at STM32F4Dicrovery with DM-STF4BB extation board (microSD holder and etc.)
chief
Associate II
Posted on April 08, 2015 at 10:41

LOL, wtf

this code change hsd->Instance

 0x080037F0 E92D4FF7  PUSH          {r0-r2,r4-r11,lr}

how?

Posted on April 08, 2015 at 17:59

Make sure you have an adequate stack allocation.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chief
Associate II
Posted on April 09, 2015 at 07:39

Where i can seen it?