cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745: USB MSC stuck at configASSERT

FabianEbs
Associate II

Hello

I have created a project for a STM32H745I_Disco board in TouchGFX, imported it to STM32CubeIDE and enabled:

  • USB_OTG_FS -- Host_Only and VBUS sensing
  • USB_HOST_M7 -- Mass Storage Host Class + Platform settings for enable Pin
  • FATFS_M7 -- USB Disk, USE_LFN on, MAX_SS to 4096
  • USART2 -- for debugging, asynchronous and 9600 Baudrate 

After this, I generated the code. I had to manually add the usb files (STM32_USB_Host_Lib, USB_HOST, FATFS) to the project for it to compile successfully.

Now i want to write to a flash drive connected to the USB_FS port, using the default fatfs functions. All I did in the code is use f_mount, f_open, f_write and f_close for my flash drive, in usb_host.c in USBH_UserProcess under the HOST_USER_CLASS_ACTIVE case, like this:

 

 

  case HOST_USER_CLASS_ACTIVE:
  Appli_state = APPLICATION_READY;

  FIL file;
  FRESULT res;
  char data[] = "Hello, World!";
  UINT bytesWritten;

  // Attempt to mount the file system
  if (f_mount(&USBHFatFS, (TCHAR const*)USBHPath, 0) != FR_OK) {
      printf("Mount failed!\n");
      return;
  }

  // Attempt to open the file
  printf("Attempting to open the file...\n");
  res = f_open(&file, "test.txt", FA_CREATE_ALWAYS | FA_WRITE);
  if (res != FR_OK) {
      printf("File open failed with error: %d\n", res);
      return; // Exit if opening the file fails
  }
  printf("File opened successfully!\n");

  // Attempt to write to the file
  printf("Preparing to write data to the file...\n");
  res = f_write(&file, data, sizeof(data) - 1, &bytesWritten);
  if (res != FR_OK) {
      printf("Write operation failed with error: %d\n", res);
  } else {
      printf("File written successfully! Bytes written: %u\n", bytesWritten);
  }

  // Attempt to close the file
  res = f_close(&file);
  if (res != FR_OK) {
      printf("File close failed with error: %d\n", res);
  } else {
      printf("File closed successfully!\n");
  }
  break;

 

When debugging, the code is stuck in tasks.c at line 3157:  configASSERT( pxUnblockedTCB ); so is it some problem with RTOS scheduling?

When removing parts of my code, f_mount only works fine. Starting from f_open, the code gets stuck.

I have attached my .ioc file, but I really just adjusted the parts mentioned above.

 

What am I doing wrong here?

0 REPLIES 0