{"id":325,"date":"2017-11-23T21:06:18","date_gmt":"2017-11-23T20:06:18","guid":{"rendered":"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=325"},"modified":"2017-12-31T19:47:10","modified_gmt":"2017-12-31T18:47:10","slug":"21-usb_msc_host-library-stm32f429","status":"publish","type":"page","link":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=325","title":{"rendered":"21-USB_MSC_HOST-Library (STM32F429)"},"content":{"rendered":"<p><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-previous\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=323\" title=\"20-SPI_L3GD20-Library (STM32F429)\"><span class=\"meta-nav\">\u2190<\/span> 20-SPI_L3GD20-Library (STM32F429)<\/a><\/div><\/div><!-- #nav-below --><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-next\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=327\" title=\"22-Graphic-DMA2D-Library (STM32F429)\">22-Graphic-DMA2D-Library (STM32F429) <span class=\"meta-nav\">&rarr;<\/span><\/a><\/div><\/div><!-- #nav-below --><\/p>\n<p>Mit dieser Library k\u00f6nnen normale USB-Sticks am USB-OTG-Port vom Discovery-Modul betrieben werden. Per FATFS-Library (die USB-Version) kann dann mit Filefunktionen darauf zugegriffen werden.<\/p>\n<p>Die Librarys sind 100% kompatibel zur STM32F407 Version, aus dem Grund<br \/>\nf\u00fcr Details zur FATFS-Lib : <a title=\"13-FATFS_SDIO-Library (STM32F4)\" href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=523\">LINK<\/a><br \/>\nf\u00fcr Detail zur USB-MSC-Host-Lib : <a title=\"32-USB_MSC_HOST-Library (STM32F4)\" href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=383\">LINK<\/a><\/p>\n<p>Hinweis : ich hab hier zwei USB-Sticks ausprobiert. Einmal ein 8GB-Stick von SanDisk. Mit diesem kommt es aber zu einem Fehler -&gt; \u201cDEVICE_NOT_SUPPORTED\u201d. Mit dem zweiten Stick, einem 4GB Intenso kommt kein Fehler und das schreiben und lesen funktioniert ohne Probleme.<\/p>\n<p>Es wird ein USB-Adapter mit Micro-USB-Stecker ben\u00f6tigt. (gibts bei EBay oder Amazon)<\/p>\n<p><em><strong>Hinweis<\/strong>\u00a0: weil f\u00fcr USB eine Clock-Frq von 48MHz zwingend notwendig ist und diese Frq mit einer Sysclock von 180MHz nicht einstellbar ist, wurde f\u00fcr diese Library der Sysclock auf 168MHz runtergesetzt !!<\/em><\/p>\n<p><strong>Benutzte Pins :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">PB13  -> USB_OTG_VBUS\r\nPB12  -> USB_OTG_ID\r\nPB14  -> USB_OTG_DM\r\nPB15  -> USB_OTG_DP\r\nPC4   -> USB_VBUS_Enable<\/pre>\n<p><strong>Enumerationen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">typedef enum {\r\n  USB_MSC_HOST_NO_INIT =0,   \/\/ USB-Schnittstelle noch nicht initialisiert\r\n  USB_MSC_DEV_DETACHED,      \/\/ kein Device angeschlossen\r\n  USB_MSC_SPEED_ERROR,       \/\/ USB-Speed wird nicht unterst\u00fctzt\r\n  USB_MSC_DEV_NOT_SUPPORTED, \/\/ Device wird nicht unters\u00fctzt\r\n  USB_MSC_DEV_WRITE_PROTECT, \/\/ Device ist schreibgesch\u00fctzt\r\n  USB_MSC_OVER_CURRENT,      \/\/ \u00dcberstrom erkannt\r\n  USB_MSC_DEV_CONNECTED      \/\/ Device verbunden und bereit\r\n}USB_MSC_HOST_STATUS_t;<\/pre>\n<p><strong>Funktionen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">void UB_USB_MSC_HOST_Init(void);                 \/\/ zum init des USB-Host\r\nUSB_MSC_HOST_STATUS_t UB_USB_MSC_HOST_Do(void);  \/\/ zum check vom Device-Status<\/pre>\n<p><strong>Beispiel :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">\/\/--------------------------------------------------------------\r\n\/\/ File     : main.c\r\n\/\/ Datum    : 08.11.2013\r\n\/\/ Version  : 1.0\r\n\/\/ Autor    : UB\r\n\/\/ EMail    : mc-4u(@)t-online.de\r\n\/\/ Web      : www.mikrocontroller-4u.de\r\n\/\/ CPU      : STM32F429\r\n\/\/ IDE      : CooCox CoIDE 1.7.4\r\n\/\/ GCC      : 4.7 2012q4\r\n\/\/ Module   : CMSIS_BOOT, M4_CMSIS_CORE\r\n\/\/ Funktion : Demo der USB-MSC-Host-Library\r\n\/\/ Hinweis  : Diese zwei Files muessen auf 8MHz stehen\r\n\/\/              \"cmsis_boot\/stm32f4xx.h\"\r\n\/\/              \"cmsis_boot\/system_stm32f4xx.c\"\r\n\/\/ In Configuration diese Define hinzuf\u00fcgen :\r\n\/\/ \"STM32F429_439xx\" , \"__ASSEMBLY__\" , \"USE_STDPERIPH_DRIVER\"\r\n\/\/--------------------------------------------------------------\r\n\r\n#include \"main.h\"\r\n#include \"stm32_ub_led.h\"\r\n#include \"stm32_ub_usb_msc_host.h\"\r\n\r\nint main(void)\r\n{\r\n  FIL myFile;   \/\/ Filehandler\r\n  uint8_t write_ok=0;\r\n\r\n  SystemInit(); \/\/ Quarz Einstellungen aktivieren\r\n\r\n  \/\/ Init der LEDs\r\n  UB_Led_Init();\r\n\r\n  \/\/ Init vom USB-OTG-Port als MSC-HOST\r\n  \/\/ (zum lesen\/schreiben auf einen USB-Stick)\r\n  UB_USB_MSC_HOST_Init();\r\n\r\n  while(1)\r\n  {\r\n    \/\/ pollen vom USB-Status\r\n    if(UB_USB_MSC_HOST_Do()==USB_MSC_DEV_CONNECTED) {\r\n      \/\/ wenn USB-Stick erkannt wurde\r\n      UB_Led_On(LED_GREEN);\r\n\r\n      \/\/ wenn File noch nicht geschrieben wurde\r\n      if(write_ok==0) {\r\n       \twrite_ok=1;\r\n       \tUB_Led_On(LED_RED);\r\n       \t\/\/ Media mounten\r\n       \tif(UB_Fatfs_Mount(USB_0)==FATFS_OK) {\r\n          \/\/ File zum schreiben im root neu anlegen\r\n          if(UB_Fatfs_OpenFile(&amp;myFile, \"USB_File.txt\", F_WR_CLEAR)==FATFS_OK) {\r\n            \/\/ ein paar Textzeilen in das File schreiben\r\n            UB_Fatfs_WriteString(&amp;myFile,\"Test der WriteString-Funktion (STM32F429)\");\r\n            UB_Fatfs_WriteString(&amp;myFile,\"hier Zeile zwei\");\r\n            UB_Fatfs_WriteString(&amp;myFile,\"ENDE\");\r\n            \/\/ File schliessen\r\n            UB_Fatfs_CloseFile(&amp;myFile);\r\n          }\r\n          \/\/ Media unmounten\r\n          UB_Fatfs_UnMount(USB_0);\r\n        }\r\n        UB_Led_Off(LED_RED);\r\n      }\r\n    }\r\n    else {\r\n      \/\/ wenn kein USB-Stick vorhanden\r\n      UB_Led_Off(LED_GREEN);\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p>Hier die Library zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2013\/11\/fatfs_usb_f429_v100.zip\">fatfs_usb_f429_v100<\/a><\/p>\n<p><a href=\"wp-content\/uploads\/2013\/11\/usb_msc_host_f429_v100.zip\">usb_msc_host_f429_v100<\/a><\/p>\n<p>Hier der komplette CooCox-Projektordner zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2013\/11\/Demo_F429_21.zip\">Demo_F429_21<\/a><\/p>\n<hr \/>\n<h3 id=\"comments-title\">20 Antworten auf <em>21-USB_MSC_HOST-Library (STM32F429)<\/em><\/h3>\n<ol class=\"commentlist\">\n<li id=\"li-comment-1699\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-1699\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">13. Mai 2014 um 07:03<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Ich verstehe nicht warum genau immer nur einmal geschrieben wird.<br \/>\nZiehe ich den USB Stick ab und stecke ihn wieder ein, wird wieder ein Datensatz geschrieben.<\/p>\n<p>int main(void)<br \/>\n{<br \/>\nFIL myFile; \/\/ Filehandler<br \/>\nfloat temp;<br \/>\nErrorStatus check;<br \/>\nchar buf[20];<br \/>\nuint8_t i;<\/p>\n<p>SystemInit(); \/\/ Quarz Einstellungen aktivieren<\/p>\n<p>\/\/ Init der LEDs<br \/>\nUB_Led_Init();<\/p>\n<p>\/\/ Init vom USB-OTG-Port als MSC-HOST<br \/>\n\/\/ (zum lesen\/schreiben auf einen USB-Stick)<br \/>\nUB_USB_MSC_HOST_Init();<\/p>\n<p>while(1)<br \/>\n{<\/p>\n<p>check=UB_DS18XX_Init();<br \/>\nif(UB_USB_MSC_HOST_Do()==USB_MSC_DEV_CONNECTED) { if(check==SUCCESS) {<br \/>\nDelay(500000);<br \/>\ntemp=UB_DS1822B20_ReadTemp(\u201c2828C8D205000026\u2033);<br \/>\nUB_DS18XX_TempToStr(temp,buf);<\/p>\n<p>UB_Led_On(LED_GREEN);<br \/>\nUB_Led_On(LED_RED);<\/p>\n<p>if(UB_Fatfs_Mount(USB_0)==FATFS_OK) {<br \/>\n\/\/ File zum schreiben im root anf\u00fcgen<br \/>\nif(UB_Fatfs_OpenFile(&amp;myFile, \u201cEierlog.txt\u201d, F_WR)==FATFS_OK) {<br \/>\nUB_Fatfs_WriteString(&amp;myFile,buf);<br \/>\nUB_Fatfs_CloseFile(&amp;myFile);<br \/>\n}<br \/>\nUB_Fatfs_UnMount(USB_0);<br \/>\n}<br \/>\nUB_Led_Off(LED_RED);<\/p>\n<p>for (i = 0; i &lt; 10; ++i) {<br \/>\nDelay(500000);<br \/>\n}<\/p>\n<p>}<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-1701\" class=\"comment odd alt thread-odd thread-alt depth-1\">\n<div id=\"comment-1701\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">13. Mai 2014 um 10:46<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Es ist definitiv so, dass<\/p>\n<p>if(UB_Fatfs_Mount(USB_0)==FATFS_OK) {<\/p>\n<p>nicht mehr wahr ist bis der Stick entfernt und wieder angesteckt wurde.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1705\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-1705\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">13. Mai 2014 um 19:29<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Die Funktion \u201cUB_USB_MSC_HOST_Do()\u201d darf nicht durch eine Pause verlangsamt werden. Du musst das ganze anders schreiben (ohne die Pause). Benutze einfach einen \u201cWartecounter\u201d\u2026so in der ART<\/p>\n<pre lang=\"c\" line=\"1\">uint32_t cnt1=0;\r\n\r\nwhile(1) {\r\n  UB_USB_MSC_HOST_DO();\r\n  cnt1++;\r\n  if(cnt1&gt;500000) {\r\n   \/\/ pause ist um\r\n    cnt1=0;\r\n    UB_DS1822B20_ReadTemp();\r\n    (...)\r\n  }\r\n}\r\n<\/pre>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-1706\" class=\"comment odd alt thread-even depth-1\">\n<div id=\"comment-1706\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">13. Mai 2014 um 20:17<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Danke, haut hin, war einfach da ich sowieso die RTC auch benutze.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-2054\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-2054\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/90c9e15cb118a9e9f69c0f697f2942b0?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Lurch<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">19. August 2014 um 21:53<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>While experimenting with ths Demo, I found this typo.<\/p>\n<p>In file ub_lib\\usb_msc_host_lolevel\\usbh_usr.c line 57:<br \/>\nUSB_MSC_HOST_STATUS=USB_MSC_DEV_DETACHED;<br \/>\nshould be:<br \/>\nUSB_MSC_HOST_STATUS=USB_MSC_DEV_CONNECTED;<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-2332\" class=\"comment odd alt thread-even depth-1\">\n<div id=\"comment-2332\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/733659f5799b217cb7eac6d2088ee55a?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Alexander N<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">14. Oktober 2014 um 14:31<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>When I am trying to use this demo with stm32f429-disco and 512MB Flash, if(UB_USB_MSC_HOST_Do()==USB_MSC_DEV_CONNECTED) do not satisfyed.<\/p>\n<p>In debugger process stops here<\/p>\n<p>case HOST_CTRL_XFER:<br \/>\n\/* process control transfer state machine *\/<br \/>\nUSBH_HandleControl(pdev, phost);<br \/>\nbreak;<\/p>\n<p>In this USBH_HandleControl(pdev, phost) procedure, URB_Status = URB_IDLE, phost-&gt;Control.status = CTRL_SETUP_WAIT.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2338\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-2338\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">14. Oktober 2014 um 20:00<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>please try the compiled HEX-File from the path \u201cstm32f429\/debug\/bin\u201d<br \/>\nwhat IDE do you use? What changes do you made? The project under CoIDE is tested many times.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2339\" class=\"comment odd alt depth-3\">\n<div id=\"comment-2339\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/733659f5799b217cb7eac6d2088ee55a?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Alexander N<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">15. Oktober 2014 um 07:14<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>When I programm MCU with HEX it works.<\/p>\n<p>I use Atollic TRUE Studio. I made only few corrections in #include parts to compile project.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2341\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-4\">\n<div id=\"comment-2341\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">15. Oktober 2014 um 08:49<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>do you use the right \u201ccmsis\u201d library : the one for the stm32f429 not for the stm32f407. Is your systemclock at 168MHz (not 180MHz) and the PLL for USB at 48MHz. Other values than 48MHz and USB is not working !<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2342\" class=\"comment odd alt depth-5\">\n<div id=\"comment-2342\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/733659f5799b217cb7eac6d2088ee55a?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Alexander N<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">15. Oktober 2014 um 09:10<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Thank you, now it works <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_smile.gif\" alt=\":)\" \/><br \/>\nThe problem was a wrong system clock.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-2560\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-2560\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/733659f5799b217cb7eac6d2088ee55a?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Alexander N<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">27. November 2014 um 12:43<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>I am trying to change this demo for working with OTG Full Speed on custom board with STMF429IIT6. USB schematics of this board almost the same as in STMF429I-DISCO. I initialize GPIO pins according PCB and change all other parts of initialization to work with USB_FS. Unfortunately, I found that program stuck in this cycle:<\/p>\n<p>if(HCD_IsDeviceConnected(&amp;USB_OTG_Core) &amp;&amp; (USB_MSC_HOST_STATUS==USB_MSC_DEV_CONNECTED))<br \/>\n{<br \/>\ndo<br \/>\n{<br \/>\nstatus = USBH_MSC_Read10(&amp;USB_OTG_Core, buff, sector, 512*count);<br \/>\nUSBH_MSC_HandleBOTXfer(&amp;USB_OTG_Core ,&amp;USB_Host);<\/p>\n<p>if(!HCD_IsDeviceConnected(&amp;USB_OTG_Core))<br \/>\n{<br \/>\nstatus=USBH_MSC_FAIL;<br \/>\n}<br \/>\n}<br \/>\nwhile(status == USBH_MSC_BUSY );<br \/>\n}<br \/>\nIn debugger USBH_MSC_BOTXferParam.CmdStateMachine = CMD_WAIT_STATUS; status = USBH_MSC_BUSY .<\/p>\n<p>I tried different USB flash drives but this didn\u2019t make any effect. USB drive LED constantly blinking when program is executing.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2564\" class=\"comment odd alt depth-2\">\n<div id=\"comment-2564\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/733659f5799b217cb7eac6d2088ee55a?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Alexander N<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">27. November 2014 um 15:47<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>In other words, I can\u2019t perform f_getfree in UB_Fatfs_Mount fuction<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2566\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-3\">\n<div id=\"comment-2566\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">27. November 2014 um 20:15<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>check your clock settings\u2026USB clock must be 48MHz and enabled. and the lib is USB FullSpeed if you want USB High-Speed you need an external PHY !!<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-2744\" class=\"comment odd alt depth-2\">\n<div id=\"comment-2744\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b8d4b8dfe091faf10f48e3384c1438fc?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Thomas m<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">17. Dezember 2014 um 15:50<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hello Alexander,<\/p>\n<p>I have the same configuration than you and encountered the same problem. Could you please tell me if you found a solution and what was the source of the problem ?<\/p>\n<p>Best regards<br \/>\nThomas<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-2761\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-2761\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dd736dc2e44876cc9e0d373a58b58e37?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Afik89<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">22. Dezember 2014 um 20:28<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>i have the same problems on stm32f429 and stm32f407 discovery boards, when i try to read more than 512 bytes or try to read some several times, USBH_MSC_Read10 gets in infinite loop. find solution, i think it\u2019s not good, but work \u2013 call UB_USB_MSC_HOST_Do not infinite loop:<\/p>\n<p>\/*Init USB HOST*\/<br \/>\nUB_USB_MSC_HOST_Init ( );<br \/>\nwhile ( UB_USB_MSC_HOST_Do ( ) != USB_MSC_DEV_CONNECTED );<\/p>\n<p>\/****<\/p>\n<p>your code<\/p>\n<p>****\/<\/p>\n<p>And i use FreeRTOS so have to change USB interapt to:<\/p>\n<p>void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev)<br \/>\n{<\/p>\n<p>NVIC_InitTypeDef NVIC_InitStructure;<br \/>\n\/* Enable USB Interrupt *\/<br \/>\nNVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);<\/p>\n<p>NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn;<br \/>\nNVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4;<br \/>\nNVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;<br \/>\nNVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;<br \/>\nNVIC_Init(&amp;NVIC_InitStructure);<br \/>\n}<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-3368\" class=\"comment odd alt thread-odd thread-alt depth-1\">\n<div id=\"comment-3368\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/1ea0e89405c60e478dc8138cb7b7ffd8?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Jc<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">29. Juni 2015 um 14:24<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Many thanks for this library! Works fine for my Kingston 8GB.<\/p>\n<p>With this library i can run an image from inside the USB-Sticks?<br \/>\nUsing your graphics library, it would be possible?<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-3372\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-3372\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">29. Juni 2015 um 18:45<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>there is a lib to load images (*img, *jpg. *bmp) from a fatfs system.<br \/>\nbut only for f407-disco.<br \/>\nnot sure if it works without modifications at the f429-disco<br \/>\ntry it out and write again if you need help<br \/>\n<a href=\"index9a32.html?page_id=870\" rel=\"nofollow\">http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=870<\/a><\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-4218\" class=\"comment odd alt thread-even depth-1\">\n<div id=\"comment-4218\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/a18fc4cde8cc659c5390789458e6fb71?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Shawn<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">8. Oktober 2015 um 00:06<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hello,<\/p>\n<p>I am using EWARM and I am finding a problem using this code in my program. I have 5 errors showing the same<\/p>\n<p>Error[Li006]: duplicate definitions for \u201cUSB_MSC_HOST_STATUS\u201d; in \u201cxxxxx<\/p>\n<p>Did anyone confront this problem?<\/p>\n<p>Thanks<br \/>\nShawn<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-4224\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-4224\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">11. Oktober 2015 um 12:51<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>try to move the line :<br \/>\n<code><br \/>\n\"USB_MSC_HOST_STATUS_t USB_MSC_HOST_STATUS;<br \/>\n<\/code><br \/>\nfrom the file \u201cstm32_ub_usb_msc_host.h\u201d<br \/>\nto the file \u201cstm32_ub_usb_msc_host.c\u201d<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-4549\" class=\"comment odd alt thread-odd thread-alt depth-1\">\n<div id=\"comment-4549\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/5db14fc61285f3acbcdf427f1950cda2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Thomas T<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">28. Januar 2016 um 18:35<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hallo,<\/p>\n<p>das Thema ist zwar schon etwas \u00e4lter, aber ich habe das Problem wie einige vor mir.<br \/>\nIch habe das Projekt: Demo_F429_21 runtergeladen und wenn ich einen USB Stick einstecke. Leuchten beide LEDs, aber er h\u00e4ngt fest in:<br \/>\nDatei: stm32_ub_usbdisk.c<br \/>\nFunktion: int USB_disk_read(BYTE *buff, DWORD sector, BYTE count)<br \/>\nEr kommt nicht mehr aus der do-while Schleife heraus.<\/p>\n<p>Gibt es dazu eine L\u00f6sung?<\/p>\n<p>Danke schonmal<br \/>\nThomas<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Mit dieser Library k\u00f6nnen normale USB-Sticks am USB-OTG-Port vom Discovery-Modul betrieben werden. Per FATFS-Library (die USB-Version) kann dann mit Filefunktionen darauf zugegriffen werden. Die Librarys sind 100% kompatibel zur STM32F407 Version, aus dem Grund f\u00fcr Details zur FATFS-Lib : LINK &hellip; <a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=325\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":160,"menu_order":21,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[129],"tags":[9,158,102,95,186],"class_list":["post-325","page","type-page","status-publish","hentry","category-stm32f429","tag-library","tag-msc","tag-stm32f429","tag-usb","tag-usb-stick"],"_links":{"self":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=325"}],"version-history":[{"count":5,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/325\/revisions"}],"predecessor-version":[{"id":1802,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/325\/revisions\/1802"}],"up":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/160"}],"wp:attachment":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}