cancel
Showing results for 
Search instead for 
Did you mean: 

USB host on STM32L475 board with FATFS

ZZY
Associate II

Hi! Hope everyone are doing well! I currently encounter a problem and can't solve it. I want to write some pieces of data into a file in a usb-disk and now the Appli_state is constantly idle even I connect the USB-Disk already.

This is a test demo code from main.c and set up for USB related port. Thanks so much for  your support!

ZZY_0-1700078072221.png

ZZY_0-1700078428443.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Principal III

Question: can you read ? or read things ?

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

5 REPLIES 5
AScha.3
Principal III

Hi, just : what IS working here ?  

i just suggest: dont write, at first try to read (existing file) and proof, its working. 

write or format mkfs just could destroy the device... so dont do this. if mount - open- read - working fine, then you can do some write.

If you feel a post has answered your question, please click "Accept as Solution".

Hi,

Question is that the state is always idle and can’t do the open, write things 

AScha.3
Principal III

Question: can you read ? or read things ?

If you feel a post has answered your question, please click "Accept as Solution".

I can use now use f_mount and it works. But when I try f_open it returns FR_NO_FILESYSTEM. How can I solve it?

AScha.3
Principal III

probably you use mount with parameter 0 = delayed mount. (so you see the error at first read/open )

try : 

fresult = f_mount(&SDfs, (TCHAR const*)SDPath, 1); // SD card mount now !

if no mount success, you have a hardware problem or low level access not working.

look at (set breakpoint ...)

 

static void USBH_UserProcess...  (USBH_HandleTypeDef *phost, uint8_t id)
{
  /* USER CODE BEGIN CALL_BACK_2 */
  switch(id)
  {
  case HOST_USER_SELECT_CONFIGURATION:
  break;

  case HOST_USER_DISCONNECTION:
  Appli_state = APPLICATION_DISCONNECT;
  break;

  case HOST_USER_CLASS_ACTIVE:
  Appli_state = APPLICATION_READY;
  break;

  case HOST_USER_CONNECTION:
  Appli_state = APPLICATION_START;
  break;

 

-- is _ready or _start recognized ? then debug _mount , to see, whats the problem.

If you feel a post has answered your question, please click "Accept as Solution".