Serial over USB driver on STM32, cable unplug detecting

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Serial over USB driver on STM32, cable unplug detecting

Post by Giovanni »

Usually a backport is allowed if the updated is localized in a single module and does not break compatibility too much. The USB driver is very different now so I have to make some verifications first.

For new projects I recommend using 2.5.x for development, it is stable enough, and wait 2.6.x for deployment. 2.4.x and 2.2.x are legacy.

Giovanni
User avatar
Prof. Dr. YoMan
Posts: 57
Joined: Thu May 24, 2012 11:00 am
Been thanked: 1 time

Re: Serial over USB driver on STM32, cable unplug detecting

Post by Prof. Dr. YoMan »

Ok. Trunk or 2.5.x for development?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Serial over USB driver on STM32, cable unplug detecting

Post by Giovanni »

Trunk is good enough most of time, if I am going to break something usually I post it in the development forum.

Giovanni
User avatar
Prof. Dr. YoMan
Posts: 57
Joined: Thu May 24, 2012 11:00 am
Been thanked: 1 time

Re: Serial over USB driver on STM32, cable unplug detecting

Post by Prof. Dr. YoMan »

:) I switch the question around: Do I miss a lot, if I am on 2.5.x and not trunk?

And then: Back on topic. Thanks for the break.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Serial over USB driver on STM32, cable unplug detecting

Post by Giovanni »

You do miss a lot, just read the readme in the trunk version, all differences are listed there. The trunk is always the most up to date and includes all fixes for known bugs.

Giovanni
User avatar
Prof. Dr. YoMan
Posts: 57
Joined: Thu May 24, 2012 11:00 am
Been thanked: 1 time

Re: Serial over USB driver on STM32, cable unplug detecting

Post by Prof. Dr. YoMan »

Which git mirror should I use?

Homepage: https://github.com/mabl/ChibiOS
This? https://github.com/ChibiOS-Upstream/ChibiOS-RT
That? https://github.com/ChibiOS/ChibiOS-RT-Community

Is made sure that the git-hashes do not change in the feature, because I want to use one of them as module in my projects.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Serial over USB driver on STM32, cable unplug detecting

Post by Giovanni »

Hi,

The official repository is the subversion one on the SourceForge page. The GIT mirror listed in the homepage is the mirror.

The other two... I simply didn't understand what are they for.

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Serial over USB driver on STM32, cable unplug detecting

Post by alexblack »

Hi.
I tested new STM32F429 MCU and found that in usb driver there is no USB_EVENT_SUSPEND detection which I used for usb cable unplug detectiong. Is there any reason fo this?
I pathed the driver and all works now:

Code: Select all

Index: usb_lld.c
===================================================================
--- usb_lld.c   (revision 6883)
+++ usb_lld.c   (working copy)
@@ -616,6 +616,11 @@
     _usb_isr_invoke_event_cb(usbp, USB_EVENT_RESET);
   }
 
+  /* USB bus SUSPEND condition handling.*/
+  if (sts & GINTSTS_USBSUSP) {
+    _usb_isr_invoke_event_cb(usbp, USB_EVENT_SUSPEND);
+  }
+   
   /* Enumeration done.*/
   if (sts & GINTSTS_ENUMDNE) {
     (void)otgp->DSTS;
@@ -915,10 +920,10 @@
     otgp->DOEPMSK  = 0;
     otgp->DAINTMSK = 0;
     if (usbp->config->sof_cb == NULL)
-      otgp->GINTMSK  = GINTMSK_ENUMDNEM | GINTMSK_USBRSTM /*| GINTMSK_USBSUSPM |
+      otgp->GINTMSK  = GINTMSK_ENUMDNEM | GINTMSK_USBRSTM | GINTMSK_USBSUSPM /*|
                        GINTMSK_ESUSPM  |*/;
     else
-      otgp->GINTMSK  = GINTMSK_ENUMDNEM | GINTMSK_USBRSTM /*| GINTMSK_USBSUSPM |
+      otgp->GINTMSK  = GINTMSK_ENUMDNEM | GINTMSK_USBRSTM | GINTMSK_USBSUSPM /*|
                        GINTMSK_ESUSPM */ | GINTMSK_SOFM;
     otgp->GINTSTS  = 0xFFFFFFFF;         /* Clears all pending IRQs, if any. */
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Serial over USB driver on STM32, cable unplug detecting

Post by Giovanni »

Hi,

The problem is the other way, 2.4.x is unable to detect that #SV10 error, 2.6.x has a state checker.

The lock is required because an higher priority interrupt could preempt chVTSetI() in the middle corrupting the timers list.

The lock-unlock protocol ensures that there cannot be race conditions related to kernel calls.

Giovanni
GSE
Posts: 3
Joined: Fri May 29, 2015 10:04 am

Re: Serial over USB driver on STM32, cable unplug detecting

Post by GSE »

In current version of 2.6.x, STM32 usb_lld.c usb event USB_EVENT_SUSPEND no handling more. How to realize USB cable unplug event in this case? 5V monitoring not so clean way. Why this event handling removed?
Post Reply