OK I'm sure I'm doing something stupid, but this is driving me nuts.
I have a perfectly working app on an STM32L432 when USB is connected and working. There's also an LED which flashes briefly every 5 seconds to show activity - it runs in the main loop. There are two other threads which cover reading from USB and one that also writes to USB.
As soon as I unplug from USB, everything stops - the LED doesn't flash any more. Plug it back in and everything resumes fine. Note THE PROCESSOR DOESN'T reset - it's definitely just suspended and resumed.
I'm not using CRS so there should be no dependency on the USB clocks. I'm checking in the read and write routines for the USB being 'ACTIVE' and I've even added a flag of my own that is 'off' when the USB_SUSPEND event is triggered, to make sure none of my read/write routines are paused on that. But even if they were, the main thread would surely be unaffected if one of the other threads stalled!
Any ideas because I'm utterly fed up with this stuff - it seems as if the USB SUSPEND is causing the whole processor to be suspended, but I can't see anything in the ChibiOS code to do that, nor of course is there anything in my code either........
USB on STM32L432 Driving Me NUTS!
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: USB on STM32L432 Driving Me NUTS!
Hi,
If the LED is no more flashing probably the system is halted.
Do you have debug options enabled in chconf.h? if so, what is the state after the CPU stops? please inspect the halt message (if any) and do a stack trace.
Giovanni
If the LED is no more flashing probably the system is halted.
Do you have debug options enabled in chconf.h? if so, what is the state after the CPU stops? please inspect the halt message (if any) and do a stack trace.
Giovanni
Re: USB on STM32L432 Driving Me NUTS!
I can't debug it that way unfortunately - Blackmagic Probe no longer seems to work with the L4 series, tried loads of different versions and none of them work for me any more. Still great for the F0 and F3 but L4 is totally broken in terms of BMP.
And it can't be a halt with a ChibiOS debug assert as that would need a reset to restart things whereas as per my note, just plugging in USB causes everything to resume.
Any ideas what could cause a processor suspend on USB without any code? I'm going through all the data sheets to find out what's going on but so far nothing - in fact the USB section of the data sheet specifically says that you need code to stop the clocks / go into low power mode so I just don't see what's causing that pause......
I also wondered if it could be thread priorities ie one thread getting 'stuck' in the USB routines and then blocking the other threads, so I set them all to the same priority and enabled pre-emption / round-robin for same-priority threads; still no good.
And it can't be a halt with a ChibiOS debug assert as that would need a reset to restart things whereas as per my note, just plugging in USB causes everything to resume.
Any ideas what could cause a processor suspend on USB without any code? I'm going through all the data sheets to find out what's going on but so far nothing - in fact the USB section of the data sheet specifically says that you need code to stop the clocks / go into low power mode so I just don't see what's causing that pause......
I also wondered if it could be thread priorities ie one thread getting 'stuck' in the USB routines and then blocking the other threads, so I set them all to the same priority and enabled pre-emption / round-robin for same-priority threads; still no good.
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: USB on STM32L432 Driving Me NUTS!
Without knowing where it is stuck it is hard to tell, in addition, I don't know your code, this seems to not happen in normal demos and L432 uses the same driver used by all other devices.
I recommend getting a working debugger.
Giovanni
I recommend getting a working debugger.
Giovanni
Re: USB on STM32L432 Driving Me NUTS!
If I disable the thread that reads from USB and I immediately return from the thread that writes to USB everything works.
So there's something in either of those routines that blocks everything - all threads just stop. I'm going to narrow it down now to whether it's read or write then I'll share the ChibiOS calls I make in those routines as there's clearly something in one of the ChibiOS calls that's causing this to suspend all threads, which surely should never happen?
So there's something in either of those routines that blocks everything - all threads just stop. I'm going to narrow it down now to whether it's read or write then I'll share the ChibiOS calls I make in those routines as there's clearly something in one of the ChibiOS calls that's causing this to suspend all threads, which surely should never happen?
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: USB on STM32L432 Driving Me NUTS!
There is nothing that can suspend all other threads except a thread looping indefinitely at higher priority.
Giovanni
Giovanni
- alex31
- Posts: 374
- Joined: Fri May 25, 2012 10:23 am
- Location: toulouse, france
- Has thanked: 38 times
- Been thanked: 61 times
- Contact:
Re: USB on STM32L432 Driving Me NUTS!
Hi,
Hum, i have no problem using BMP with L4, I even reflash stlink probe on nucleol432 board with BMP with no problems.
I have at this time 6 students working on nucleol432 board flashed with black magic probe.
If you want, i have a doc describing how to replace stlink by BMP on nucleo (in french).
Alexandre
avrhack wrote:I can't debug it that way unfortunately - Blackmagic Probe no longer seems to work with the L4 series, tried loads of different versions and none of them work for me any more. Still great for the F0 and F3 but L4 is totally broken in terms of BMP.
Hum, i have no problem using BMP with L4, I even reflash stlink probe on nucleol432 board with BMP with no problems.
I have at this time 6 students working on nucleol432 board flashed with black magic probe.
If you want, i have a doc describing how to replace stlink by BMP on nucleo (in french).
Alexandre
Re: USB on STM32L432 Driving Me NUTS!
Giovanni wrote:There is nothing that can suspend all other threads except a thread looping indefinitely at higher priority.
Giovanni
Well the issue was a suspended thread causing all others to stop - even though they were all the same priority and I had set up pre-emptive scheduling round robin specifically to avoid that.
Unlikely to be a ChibiOS bug as that's a key part of the OS so surely someone else would have found it already; must be something in my configuration that is stopping pre-emptive scheduling for same-priority threads. My bet is that it's a locking issue somewhere in a critical zone......
Re: USB on STM32L432 Driving Me NUTS!
alex31 wrote:Hi,avrhack wrote:I can't debug it that way unfortunately - Blackmagic Probe no longer seems to work with the L4 series, tried loads of different versions and none of them work for me any more. Still great for the F0 and F3 but L4 is totally broken in terms of BMP.
Hum, i have no problem using BMP with L4, I even reflash stlink probe on nucleol432 board with BMP with no problems.
I have at this time 6 students working on nucleol432 board flashed with black magic probe.
If you want, i have a doc describing how to replace stlink by BMP on nucleo (in french).
Alexandre
Thanks Alexandre - my French is from schooldays so might just get by
However I wonder whether there's some issue with hardware. My BMP is a home-built v1 that I designed a PCB for myself and made a couple of modifications, rather than a 'real' one. That said, it has worked perfectly for me for F0, F1, F2, F3 and F4 series but not L4 which doesn't make any sense.
I guess I'll go and buy a real BMP and see if that works better - you can never have too many of them!
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: USB on STM32L432 Driving Me NUTS!
Round robin is not supported in tick-less mode, if you need it then make sure to set the delta to zero and tick frequency to 1000.
In general it is not a good idea to rely on RR, the "granularity" is low.
Giovanni
In general it is not a good idea to rely on RR, the "granularity" is low.
Giovanni
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 35 guests