-
-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blink an LED until USB is enumerated #1566
Comments
@esden @dragonmux I'm keen to work on this as a first issue, if no objections from you |
Certainly, please do! Our mental plan for this was to start by poking in the SysTick handler and accessing the USB stack state to see if a connection has been established in whatever way we can without modifying libopencm3 if possible. |
No objections. :) If you end up modifying locm3 for this, please submit your changes up stream: https://github.com/libopencm3/libopencm3 and to our fork: https://github.com/blackmagic-debug/libopencm3 |
That is a useful feature. Since there already are two usb_set_config callbacks (for serial and for DFU), I used I started by appending the top-most super-loop with a gpio_toggle+timeout reload on timeout expiry (for non-hosted). Using morse for this looked too fishy. I needed another all-platform universal way to blink the idle LED from boot until PoC, tested on blackpill-f411ce (+uhubctl or a power bank): diff --git a/src/main.c b/src/main.c
index 496cfd02..b528ec2d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,6 +32,9 @@
#ifdef ENABLE_RTT
#include "rtt.h"
#endif
+#if PC_HOSTED == 0
+#include "usb.h"
+#endif
/* This has to be aligned so the remote protocol can re-use it without causing Problems */
static char pbuf[GDB_PACKET_BUFFER_SIZE + 1U] __attribute__((aligned(8)));
@@ -77,6 +80,16 @@ int main(int argc, char **argv)
(void)argc;
(void)argv;
platform_init();
+
+ platform_timeout_s nousb_blinky;
+ platform_timeout_set(&nousb_blinky, 1000U);
+
+ while (!usb_get_config()) {
+ if (platform_timeout_is_expired(&nousb_blinky)) {
+ gpio_toggle(LED_PORT, LED_IDLE_RUN);
+ platform_timeout_set(&nousb_blinky, 1000U);
+ }
+ }
#endif
while (true) {
|
@ALTracer your patch above is almost identical to the PoC I had as well. Below is what my thought process was after the PoC:
I understand your point about the morse subsystem being non-reentrant. I too am concerned about this. The lack of a scheduler and associated synchronisation primitives makes this tricky. I think a concept of message priorities could also help. Perhaps these are other issues that could be raised and assessed on their merit. |
Closing as fixed by #1616 which implemented this feature. |
If we blink an LED until USB becomes enumerated it is clear that there is a USB connectivity issue. A common user problem is the use of charge only USB cables, that lack data lines.
It probably makes most sense to blink the RED led, possibly using the morse subsystem?
The text was updated successfully, but these errors were encountered: