-
Notifications
You must be signed in to change notification settings - Fork 143
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
[ext] Add TinyUSB module and port for STM32 and SAM #478
Conversation
I got a little over-exited and accidentally modularized the entire tinyusb source code. I have a hunch that I can generate the descriptors automatically that way for multiple classes in one device. Or maybe I've drunk too much tea… (The original repo was a ~30MB download, so I made a partial clone for ~300kB). |
Very cool, this is much less hacky than my PR :D Re the modularization thing - I did look through the linker output of the example in my PR and it seems like the linker did quite a good job of kicking out all the unused stuff. The binary size was about 9.5-10kB which might serve as a good benchmark for this effort (I don't find 10kB for a hello world example "tiny" at all so any improvements are highly welcome!) |
The aggressive modularization is mostly to cut down compile time, by just compiling less files ;-P This is the only reason we can compile the HAL for all 2000+ devices in the CI within a reasonable time (<10mins per family). The linker is pretty good at garbage collection, and I've stripped the linkerscript down to the bare minimum of sections. BUT we don't use LTO, even though it might be a good idea to look into this. |
8e7a2cf
to
a375039
Compare
I couldn't get this to work in hardware, I'm not sure why though… I'll have to verify all clock sources and double check the hardware connections… The tinyusb debug printf hasn't printed any errors, not sure if it is supposed to… |
Is this completely merged with #477 now? If yes, then I can retest it on my SAM device to help you narrow down the issue. Unfortunately tinyusb doesn't seem to output anything useful on serial until it starts to work... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for merging this!
This comment has been minimized.
This comment has been minimized.
Tested it on a fresh clone of your branch, but it fails in the exact same way: The USB port appears, I can Perhaps this is a macOS problem? Or maybe I'm using the wrong command to open the serial port? |
My branch shows the exact same system information, so perhaps it's a macOS 10.14 problem? What OS are you testing this on? |
No, the issue is simply that |
The Arduino hack works too, but I don't have the UF2 bootloader on my device, I have the original Bossa bootloader and no idea how to jump into double tap mode here… |
So the bootloader on my board is this one: https://github.com/arduino/ArduinoCore-samd/tree/master/bootloaders/zero And the address is the same, but the magic is different |
Latest commit works reliably for me.
This is a better bootloader which works reliably: https://github.com/microsoft/uf2-samdx1 I guess we should make the magic constant an lbuild option given that the SAM bootloader developers couldn't agree on a single one... |
Ok, I'll look into the STM32 side next weekend.
Pfff, lame, let's simply™ scan the bootloader binary image to determine the right magic constant ;-P |
STM32 Blue Pill CDC example is working after fixing the interrupt filtering code. |
I've implemented auto-generation of USB descriptors, at least for the device type. I've tested USB sucessfully on STM32F1, STM32F3, STM32F4 both fsdev and synosys hardware. However, I've noticed a couple of limitations.
So you're limited to only two device classes in general. Unfortunately error reporting in TinyUSB is terrible, since their I'll try with STM32F7 next, which has a HS Synopsys device and more resources and report back. |
+1 for improving debuggability, this is by far the biggest con of tinyusb (maybe apart from that it is written in C). |
cb7b807
to
ae3c1eb
Compare
94455d3
to
1057811
Compare
This is now feature complete, I still need to fix the CI though. I didn't add the arduino serial hack to the library nor to the BSP, since the bootloader magic numbers are different. You can add it to your application for now. I tested this in HW in all the boards I could find with the USB port. |
d3a1a26
to
7cd766d
Compare
I have STM32F401/411 Mini boards, however I don't have a USB-C to USB-A converter (it's in the mail), so I didn't implement BSP support for that. Perhaps @rleh can add it later? |
89d457f
to
0883d0e
Compare
TinyUSB had an example for this board, so I added it to the BSP, but didn't test it. |
0aa6286
to
3a2862c
Compare
I've tested the example on Mini-F401 and Mini-F411 boards: Serial and Mass storage both work! |
3a2862c
to
6f0f303
Compare
@henrikssn Please review and test on your hardware. |
6f0f303
to
029f7e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍 👍 👍 👍 👍
Just wanted to say that this is really exciting. Finally USB support in modm! |
029f7e5
to
1e35ecf
Compare
1e35ecf
to
622028a
Compare
This adds a stripped-down TinyUSB submodule, and lbuildifies it as a follow-up for #477.
tusb_config.h
generatortinyusb_get_serial()
Limitations:
cc @henrikssn @strongly-typed