Page 1 of 2

USB_CDC on STM32F2 without VBUS

Posted: Sun Sep 16, 2012 8:46 pm
by docens
Hello,

I have a custom made board based on STM32F207. I am examining ChibiOS as a possible platform and am very satisfied with the results until now. I have a working Serial driver, ICU and SDIO driver with fatfs for SD card handling. Next step would be to utilize the serial over USB driver for OTG_FS, but I have no success here. First I've tried to adapt the STM32F4 USB_CDC testhal code, but I had a building problem in stm32f2xx.h where the definition of the RCC_AHB2RSTR_OTGFSRST was missing. I have seen that you had a fix here recently (I use the trunk of the git repository now), but I could not get the point in that. I have temporarily changed it like this:

Code: Select all

 #define  RCC_AHB1RSTR_DMA1RST                ((uint32_t)0x00200000)
 #define  RCC_AHB1RSTR_DMA2RST                ((uint32_t)0x00400000)
 #define  RCC_AHB1RSTR_ETHMACRST              ((uint32_t)0x02000000)
-#define  RCC_AHB1RSTR_OTGHRST                ((uint32_t)0x10000000)
+#define  RCC_AHB1RSTR_OTGHSRST               ((uint32_t)0x10000000)
 
 /********************  Bit definition for RCC_AHB2RSTR register  **************/
 #define  RCC_AHB2RSTR_DCMIRST                ((uint32_t)0x00000001)
 #define  RCC_AHB2RSTR_CRYPRST                ((uint32_t)0x00000010)
 #define  RCC_AHB2RSTR_HSAHRST                ((uint32_t)0x00000020)
 #define  RCC_AHB2RSTR_RNGRST                 ((uint32_t)0x00000040)
-/* CHIBIOS FIX *
-/*#define  RCC_AHB1RSTR_OTGHRST                ((uint32_t)0x10000000)*/
-#define  RCC_AHB1RSTR_OTGHSRST                ((uint32_t)0x10000000)
+#define  RCC_AHB2RSTR_OTGFSRST               ((uint32_t)0x00000080)


After this it compiles, but my host linux cannot attach the device, I have the following messages with dmesg:
[96431.565905] usb 1-1.3: device not accepting address 55, error -110
[96431.566142] hub 1-1:1.0: unable to enumerate USB device on port 3

I assume that probably I have a hardware related problem here:
I have only the DM and DP pins of the USB connector connected, nor ID and VBUS. As far as I have seen in the OTGv1 driver it uses forced peripheral mode, so the ID pin does not matter, but I have not found the NOVBUSSENS bit definition in there. I am affraid, this is needed for operation without VBUS connected (the PA9 PIN is used for a different function), and also I don't exactly know if I have to trigger somehow the start of the communication instead of VBUS...
Do you have any experience with USB_CDC on F2? Do you plan to support NOVBUSSENS in the near future?

Thanks,

Csaba

Re: USB_CDC on STM32F2 without VBUS

Posted: Mon Sep 17, 2012 8:08 am
by Giovanni
Hi,

I added the constant GCCFG_NOVBUSSENS to the header file, you can add it to the line 890 in usb_lld.c, if it works for you I will add an option to the driver.

Code: Select all

    otgp->GCCFG = GCCFG_NOVBUSSENS | GCCFG_VBUSASEN | GCCFG_VBUSBSEN | GCCFG_PWRDWN;


Giovanni

Re: USB_CDC on STM32F2 without VBUS

Posted: Mon Sep 17, 2012 9:54 pm
by docens
Hi Giovanni,

Thank you very much for your fast and effective answer. Regarding NOVBUSSENS this is exactly what I needed. Today I had limited time to test it, just throwing it in and building it did not help, the connection was not established at all, I had the same message at the host side.

I have to double check my code, probably I can spot some problem there and also dig a little bit deeper to the ST USB documentation to see if I have to trigger anything else instead of VBUS to push the USB PHY until it generates the USBRST interrupt where the OTGv1 driver starts to work as far as I have seen.

I will let you know if I have any progress here.

Also please check the issue with the stm32f2xx.h that I have mentioned in my original post, as at it's present state OTGv1 does not build.

Again, I am very impressed by your project from both codebase and support side.

Csaba

Re: USB_CDC on STM32F2 without VBUS

Posted: Tue Sep 18, 2012 11:35 am
by rubenswerk
Do not forget to put an external pullup to tha data line. The OTG_FS has an internal pullup, but this one only works if VBUS is connected to 5v.
Bye, RuWe

Re: USB_CDC on STM32F2 without VBUS

Posted: Wed Sep 19, 2012 1:41 pm
by Giovanni
Hi,

I committed the fix to the header, please let me know if there are other problems.

Giovanni

Re: USB_CDC on STM32F2 without VBUS

Posted: Wed Sep 19, 2012 9:15 pm
by tuxscreen
@ rubenswerk

We did the same... we "forgot" to connect VBUS on our board, and we just had to patch the Flags in the driver, to get it working...

How do I check, if I will have a problem in the future?

(We power the board externally (12Vin with several power lines to 3.3 and 1.8V) USB is just connected to the USB datalines of the FS port

BR
Marc

Re: USB_CDC on STM32F2 without VBUS

Posted: Fri Oct 19, 2012 9:31 pm
by docens
Hi Giovanni,

I was busy with other topics until now, but now I'm back to the USB issue and it is not solved yet. The problem remains the same: the USB connection is not established. Now I use the testhal/STM32F4xx/USB_CDC sample project with only minimal modifications to adapt to my custom STM32F2XX board, and I use the GCCFG_NOVBUSSENS constant as you advised. I also have an external pull up resistor on the D+ line. I have checked, that the USB_EVENT_RESET is fired as I connect the USB cable, but no other events occur.

Unfortunately the ST docs are quite short on NOVBUSSENS, so I am a little bit puzzled how to progress.

Csaba

Re: USB_CDC on STM32F2 without VBUS

Posted: Sat Oct 20, 2012 7:44 am
by Giovanni
Adding that flag worked for Marc so it must be something else in your case, being a custom board I would check a) settings in boardh b) possible HW problems.

Giovanni

Re: USB_CDC on STM32F2 without VBUS

Posted: Sat Dec 21, 2013 4:34 pm
by lilvinz
I am using a custom made hardware without vbus pin connected in device mode and had to add GCCFG_NOVBUSSENS to get it running as well. It would be nice to have this supported "officially" at the mcuconf.h file.

Cheers,

Vinz

Re: USB_CDC on STM32F2 without VBUS

Posted: Sun Dec 22, 2013 6:25 pm
by lilvinz
Also if i understand the GPL exception correctly, a modification of this file would force the whole project code GPL so a commercial project choosing the GPL+exception licensing option would not be able to use USB without vsense pin.
@Giovanni: It would be nice to clarify this point for me.

Thanks a lot and best regards,

Vinz