Hello all,
I have been struggling for some days with the USB drivers on both a
custom board based on SAML21, and on a SAMR34-Xplained board (for the
latter, I'm using pr/samr34_support from
https://github.com/dylad/RIOT.git).
Enabling USB was trivial: according to the datasheets, the hardware
configuration is the very same used by board samr21-xpro.
My problem is that the host-provided USB address is not accepted at
all, and thus even examples/usbus_minimal is failing.
I've tried to add extensive debug points, but the code assigning the
address is never triggered (only on RESET, with address 0).
Debugging conversation with Wireshark shows me that a SET_ADDRESS
command is indeed send by host, but the immediate answer is a "broken
pipe" error - possibly directly generated by the L21 CPU (I have no
clue).
Does anyone have an advice about how to pinpoint the problem, and
solve it? Any help will be greatly appreciated, I've been working on
this for a few days already but got nowhere.
Hello Antonio,
I was able to run the usbus_minimal app some time ago on SAML21-XPRO.
Since you are using #11250 already, I suggest you to add #10075 and adapt it for SAMR34 to have 48MHz clock support (which is needed by USB IP). This should be pretty straightforward.
You should have a working USB after this.
If you encounter more issues, I can try to help you after the RIOT summit.
Cheers,
Dylan
Hello Antonio,
I was able to run the usbus_minimal app some time ago on SAML21-XPRO.
Hello Dylan,
thanks for reassuring me - then I must be doing something silly somewhere.
Since you are using #11250 already, I suggest you to add #10075 and adapt it for SAMR34 to have 48MHz clock support (which is needed by USB IP). This should be pretty straightforward.
You should have a working USB after this.
Yestrday afternoon I had a "doh" moment when I realized that L21 is
initialized at 16MHz - this is exactly what's needed, then.
If you encounter more issues, I can try to help you after the RIOT summit.
Thanks a lot for your support - hopefully your tip will be enough.
I'll report back in any case.
I have followed your advice and tested #10075: USB works, but serial
output is garbled - I guess UART would also need adjusting when
changing the main clock.
Enabling 48MHz DFLL on a different clock generator without messing
with main CPU clock does work correctly, though, so I went for it. I
added the clock code in sam0_common/periph/usbdev.c, and used DFLL in
USB Clock Recovery mode (DFLL locks on 1kHz SOF USB signals) instead
of XOSC32.
Haven't created a pull request since I don't know if my approach is
conforming with RIOT code, but here is my final result: