2016-09-03 03:26 AM
I have a trouble when I reach the f_open command, it always return FR_DISK_ERR.
Here is my code which generated fromSTM32CubeMX :
#include ''stm32f4xx_hal.h''
#include ''fatfs.h''
#include ''usb_host.h''
/* USER CODE BEGIN Includes */
#include ''stdio.h''
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
FATFS fs;
FIL MyFile;
FRESULT fres;
extern ApplicationTypeDef Appli_state;
char path[100];
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
void Error_Handler(void);
static void MX_GPIO_Init(void);
void MX_USB_HOST_Process(void);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_FATFS_Init();
MX_USB_HOST_Init();
/* USER CODE BEGIN 2 */
MX_USB_HOST_Process();
if(retUSBH != 0){
Error_Handler();
}
if(fres = f_mount(&fs, (TCHAR const*) USBH_Path, 0) != FR_OK)
{
Error_Handler();
}
if(f_open(&MyFile, ''STMTXT'', FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
Error_Handler();
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
MX_USB_HOST_Process();
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
It always get stuck at f_open, so it looping in Error_Handler(). Can someone help me ?
Thank you very much
#f_open
2016-09-03 06:33 AM
You'd need to review how the DISKIO layer within FatFs is interfacing with the USB MSC, and understand why the USB side isn't working or passing back errors.
Try some different USB sticks, the low cost ones might have timing issues.2016-09-03 06:45 PM
I already tried my USB with the repository example and it works well, i already modify the repository example and it works great with my USB. The problem was if i want to add an additional repository, i found some difficulties to add peripheral because my IAR always return Error[Li005] if i build my project. So, I want to build fresh project using Cube.
Any idea ?2016-09-08 04:56 AM
Hi Tama.bounta,
Try to do like the following implimentation example
char SDPath[4];
f_mount(&SDFatFs, (TCHAR const*)SDPath, 0)
I recommend that you take a look to the ''FatFs_uSD'' example in
package at this path: STM32Cube_FW_F7_V1.4.0\Projects\STM32F769I_EVAL\Applications\FatFs\FatFs_uSD
-Hannibal-