2011-08-15 04:32 AM
Hi,
I'm trying to implement USB mass storage and mass storage bootloader on STM32F103RBT but ... I have a problem with the adapted the code from STM32_USB-FS-Device_Lib_V3.3.0 Mass_Storage example. The ISTR_RESET interrupt is received (MASS_Reset() gets called) when I connect the USB cable to a host PC but no other USB interrupts take place. I think that the code is correctly implemented: - Peripiheral clock is enabled and Interrupts are enabled - USB clock initialised to 1.5 of system clock of 72Mhz (checked that sys clock is 72Mhz) The startup code calls the following routines: MAL_Config(); Set_USBClock(); //USB clock setup USB_Interrupts_Config(); /NVIC setup USB_Init(); Has anyone implemented USB mass storage successfully? What interrupts would you expect to receive after ISTR_RESET? Thanks.2011-08-15 03:19 PM
Problem: Receiving only USB_ISTR Reset message and no other USB interrupts
Resolution: Add a 1.5K pull-up to D+2011-08-16 05:33 AM
2011-08-16 07:24 AM
Maybe, your debug output disturbs the firmware from responding to the host in time. Switch off all the debug output, temporarily.
Host expects that the device responds to control transfers in time. The minimum timeout is 50 ms. If your debug output delays the device response, it causes timeout on the host side. As you are starting from ST example, the USB stack should work :) For MSC-BOT (Mass-Storage Class, Bulk-Only Transport), the timeout of bulk IN/OUT endpoints is much longer (around 5 sec) than Control transfer. You may add the debug output to the bulk IN/OUT process, but not for the control transfer process. Tsuneo2011-08-16 11:52 AM
***** MAL_GetStatus() then gets called every few seconds
2011-08-16 02:03 PM
Your trace shows that the bulk OUT (and IN?) endpoint (EP) doesn't respond to host. And then, the host tries to reset the bulk pipe using Clear_Feature(ENDPOINT_HALT) request - ie. Mass_Storage_ClearFeature() is called on the device side, repeatedly.
Did you change the bulk EP address? The address of the bulk IN/OUT endpoints are specified by the endpoint descriptors. STM32_USB-FS-Device_Lib_V3.3.0\Project\Mass_Storage\src\usb_desc.c const uint8_t MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] = { ... /* 18 */ 0x07, /*Endpoint descriptor length = 7*/ 0x05, /*Endpoint descriptor type */ 0x81, /*Endpoint address (IN, address 1) */ <------------ 0x02, /*Bulk endpoint type */ 0x40, /*Maximum packet size (64 bytes) */ 0x00, 0x00, /*Polling interval in milliseconds */ /* 25 */ 0x07, /*Endpoint descriptor length = 7 */ 0x05, /*Endpoint descriptor type */ 0x02, /*Endpoint address (OUT, address 2) */ <------------ 0x02, /*Bulk endpoint type */ 0x40, /*Maximum packet size (64 bytes) */ 0x00, 0x00 /*Polling interval in milliseconds*/ These bulk endpoints are enabled at MASS_Reset(). The EP addresses, ENDP1_TXADDR and ENDP2_RXADDR, are registered to the EPs, here. STM32_USB-FS-Device_Lib_V3.3.0\Project\Mass_Storage\src\usb_prop.c void MASS_Reset() { ... #else ... /* Initialize Endpoint 1 */ SetEPType(ENDP1, EP_BULK); SetEPTxAddr(ENDP1, ENDP1_TXADDR); <------------ SetEPTxStatus(ENDP1, EP_TX_NAK); SetEPRxStatus(ENDP1, EP_RX_DIS); /* Initialize Endpoint 2 */ SetEPType(ENDP2, EP_BULK); SetEPRxAddr(ENDP2, ENDP2_RXADDR); <------------ SetEPRxCount(ENDP2, Device_Property.MaxPacketSize); SetEPRxStatus(ENDP2, EP_RX_VALID); SetEPTxStatus(ENDP2, EP_TX_DIS); Tsuneo2011-08-17 04:12 AM
2011-08-17 02:39 PM