2020-08-11 09:10 PM
I tested 3 pendrives, 4GB (Samsung?), 16GB and 32GB (SanDisk Cruzer Blade).
Two worked on the STM32F407VG.
SD card adapter also doesn't work, 8GB (Kingston), 2GB (Generic), 16GB (Sandisk Ultra).
SanDisk Cruzer Blade 16GB don't work.
Using USB host with STM32CubeIDE 1.3 (Version 1.4 does not work with ST-Link V2 :expressionless_face:)
In case anyone has problems with this, I leave it registered that it can be common.
All devices run on Windows 10 x64 and Android 10 (Smartphone).
2020-08-19 10:46 AM
Thanks,
I tried to make your example work with the F407, but it didn't work, the uC was unable to open the file "2019/jan/1/pendrive.txt".
So I adapted it with parts of another sample code, and it worked, the F407 was able to read and write all the devices, both pendrive and SD card with adapter.
Unfortunately my project that has several peripherals (RTC DS3231, ACC MPU6050, LCD ILI9341, USB HID, USB MSC) cannot work with the changes I found. I think I will have to create a new project with IDE 1.4.2 and build the project again.
At least now I know that the IDE works with USB Host MSC.
Thank you.
2020-08-19 10:51 AM
Note: ST-Link still does not work on Windows (STM32CubeIDE 1.4.2), I am using Linux Xubuntu now, I think it is much faster to compile.
2020-08-19 10:02 PM
pendrive.txt file is written to your usb disk after flashing code to controller
you have to eject usb disk and plug it to your controller
you wil able to see pendrive.txt file in your usb disk
2020-08-19 11:22 PM
"The controller was unable to create the file" Thanks
2020-08-20 01:50 AM
this is working example
try it with simple pendrive.txt in root folder like
"pendrive.txt"
2020-08-20 08:29 PM
I was able to configure the debug messages (level 3) and noticed that the SD card only works if the microcontroller boots with the SD card connected. If the microcontroller boots and then connects the SD card, then it doesn't work. But this does not happen with a USB stick. With pendrive, it works in both cases.
If the microcontroller boots with the Pendrive connected:
USB Device Connected
USB Device Reset Completed
PID: 4200h
VID: 13feh
Address (#1) assigned.
Manufacturer :
Product : USB DISK 2.0
Serial Number : 7F004191A203B205
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Switching to Interface (#0)
Class : 8h
SubClass : 6h
Protocol : 50h
MSC class started.
Number of supported LUN: 1
LUN #0:
Inquiry Vendor :
Inquiry Product : USB DISK 2.0
Inquiry Version : PMAP
MSC Device ready
MSC Device capacity : 3449028096 Bytes
Block number : 15124991
Block Size : 512
f_mount(&USBDISKFatFs, (TCHAR const*)USBDISKPath, 0) == FR_OK
(byteswritten != 0) && (res == FR_OK)
f_open(&MyFile, 'Even.TXT', FA_READ) == FR_OK
(bytesread != 0) && (res == FR_OK)
(bytesread == byteswritten
If the microcontroller boots and then connects the Pendrive:
USB Device Connected
USB Device Reset Completed
PID: 4200h
VID: 13feh
Address (#1) assigned.
Manufacturer :
Product : USB DISK 2.0
Serial Number : 7F004191A203B205
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Switching to Interface (#0)
Class : 8h
SubClass : 6h
Protocol : 50h
MSC class started.
Number of supported LUN: 1
LUN #0:
Inquiry Vendor :
Inquiry Product : USB DISK 2.0
Inquiry Version : PMAP
MSC Device ready
MSC Device capacity : 3449028096 Bytes
Block number : 15124991
Block Size : 512
f_mount(&USBDISKFatFs, (TCHAR const*)USBDISKPath, 0) == FR_OK
(byteswritten != 0) && (res == FR_OK)
f_open(&MyFile, 'Even.TXT', FA_READ) == FR_OK
(bytesread != 0) && (res == FR_OK)
(bytesread == byteswritten
If the microcontroller boots with the SD card connected:
USB Device Connected
USB Device Reset Completed
PID: 125ch
VID: 14cdh
Address (#1) assigned.
Manufacturer : Generic
Product : Mass Storage Device
Serial Number : 125C20100726
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Switching to Interface (#0)
Class : 8h
SubClass : 6h
Protocol : 50h
MSC class started.
Number of supported LUN: 1
LUN #0:
Inquiry Vendor : Mass
Inquiry Product : Storage Device
Inquiry Version :
MSC Device ready
MSC Device capacity : 3527409152 Bytes
Block number : 15278079
Block Size : 512
f_mount(&USBDISKFatFs, (TCHAR const*)USBDISKPath, 0) == FR_OK
(byteswritten != 0) && (res == FR_OK)
f_open(&MyFile, 'Even.TXT', FA_READ) == FR_OK
(bytesread != 0) && (res == FR_OK)
(bytesread == byteswritten
If the microcontroller boots and then connects the SD card:
USB Device Connected
USB Device Reset Completed
2020-08-20 08:33 PM
2020-08-21 04:25 AM
Are you trying to work both usb mass storage device (sd card data shown as drive in computer ) and usb disk (pen drive ) at same time ?
2020-08-21 10:58 AM
No, I just assembled the code with the two ports to test, I am using only one port at a time to test. I'm testing with an adapter of this type:
2020-08-21 11:02 AM