-
Notifications
You must be signed in to change notification settings - Fork 7.5k
drivers: usb: USB device driver for Kinetis USBFSOTG Controller #542
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
drivers: usb: USB device driver for Kinetis USBFSOTG Controller #542
Conversation
@fvincenzo @MaureenHelm When the MPU is switched on (default on), the USBFSOTG controller signals the DMA error because it, Bus Master 4, can not access the SRAM (BD table and the buffer are located there). As I see, I can insert a new region into nxp_mpu_regions.c and/or add BM4 Flags to MPU_REGION_xxxxx, is it correct so far? see 678c39b |
6b0d207
to
cbf8ad2
Compare
cbf8ad2
to
7e0bc69
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.
Thanks @jfischer-phytec-iot. This looks pretty good. I wasn't able to get the cdc sample to work on frdm_k64f though; it got stuck waiting for DTR.
@fvincenzo @MaureenHelm When the MPU is switched on (default on), the USBFSOTG controller signals the DMA error because it, Bus Master 4, can not access the SRAM (BD table and the buffer are located there). As I see, I can insert a new region into nxp_mpu_regions.c and/or add BM4 Flags to MPU_REGION_xxxxx, is it correct so far? see 678c39b
Let's add the flags to MPU_REGION_xxxx (as you've already done) to be consistent with ethernet.
drivers/usb/device/usb_kinetis.c
Outdated
|
||
static inline void kinetis_usb_init_clock(void) | ||
{ | ||
/* TODO: refactor or use ext/mcux sdk */ |
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.
Yes, please. Should also move to soc.c since the SIM is soc-specific.
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.
Done, I wanted to make the clock source configurable, but the IRC48 did not work for me, so for the first the PLL is the only possible clock source.
7e0bc69
to
3b73bdc
Compare
usb 9-1: SerialNumber: 00.01 | ||
cdc_acm 9-1:1.0: ttyACM1: USB ACM device | ||
|
||
The app prints on serial output, used for the console: |
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.
Does the sample app read from and write to the minicom terminal?
|
||
Wait for DTR | ||
|
||
Open a serial port emulator, for example minicom |
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.
Don't you need to open minicom BEFORE you run the sample app (where does "Wait for DTR" mentioned above appear?)
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.
no, the sample waits for DTR, it appears after the minicom opens the device provided by the Zephyr.
Overview | ||
******** | ||
|
||
Sample app for USB CDC ACM driver. The received data is echoed back |
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.
This sample app demonstrates use of a USB Communication Device Class (CDC) Abstract Control Model (ACM) driver provided by the Zephyr project. Received data is echoed back to the serial port provided by this driver.
Building and Running | ||
******************** | ||
|
||
Plug the board into a host device, for example, a PC running Linux. |
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.
You don't say how to build (and flash) the sample app.
Characters read: | ||
|
||
The characters entered in serial port emulator will be echoed back. | ||
You may need to stop modemmanager, if it is trying to access the |
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.
You should mention this issue earlier in the steps -- before plugging the board to your host system I suspect.
|
||
USB CDC ACM Sample Application | ||
#################################### | ||
|
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.
Does this sample app only work on specific boards? If so, you should list them here.
************ | ||
|
||
This project requires an USB device driver, | ||
which is available for the :ref:`arduino_101` and :ref:`frdm_k64f` boards. |
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.
Is this the list of supported boards then?
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.
yes, but, I've just seen that the default board for this sample is quark_se_c1000_devboard.
******************** | ||
|
||
Plug the board into a host device, for example, a PC running Linux. | ||
The board will be detected as a CDC ACM device. |
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.
(as shown by the Linux dmesg
command):
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.
suggested edits and clarifications
dadd93e
to
d8c63e1
Compare
d8c63e1
to
1c75f65
Compare
1c75f65
to
892928f
Compare
rebased on master, tested with CDC ACM and DFU, usable but still WIP (leds and blocking while must be removed) |
@jfischer-phytec-iot since still wip, added that to subject, also used github markup for the todo list. (might need a bit of cleaning up) |
892928f
to
d1c16e8
Compare
9c0da27
to
0e7857b
Compare
0e7857b
to
069b6e0
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.
LGTM, tested CDC ACM and ECM functionality on FRDM-K64F
@nashif ping |
@jfischer-phytec-iot pong. @MaureenHelm have you looked at this? I assume it is ready to be re-reviewed/tested now. |
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.
LGTM, but I'd like to get someone from my USB team to also take a look.
I tested CDC on frdm_k64f and it works fine. Do the other samples work too?
dts/arm/nxp/nxp_k6x.dtsi
Outdated
@@ -366,6 +366,16 @@ | |||
label = "ADC_1"; | |||
status = "disabled"; | |||
}; | |||
|
|||
usbd: usbd@0x40027000 { |
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.
Remove the 0x from the address. You'll also need to update the fixups accordingly
dts/arm/nxp/nxp_kw2xd.dtsi
Outdated
@@ -301,6 +301,15 @@ | |||
status = "disabled"; | |||
}; | |||
|
|||
usbd: usbd@0x40027000 { |
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.
Remove the 0x from the address. You'll also need to update the fixups accordingly
Yes, this is my reference driver for usb development (netusb related samples need CONFIG_ETH_MCUX to be disabled). |
069b6e0
to
a8ea9e7
Compare
a8ea9e7
to
c4718e4
Compare
@jfischer-phytec-iot I'm sorry for the delay, but I got some feedback from our USB team. Here's what they said:
|
@MaureenHelm thanks for review
yes, it's an issue, but I do not have an elegant solution right now. It probably belongs in something like a power domain driver but I do not want to touch it now.
If it is not possible to receive a setup token then a token was received and the TXSUSPENDTOKENBUSY is set until the stack(cooperative thread) calls the function usb_dc_ep_read. Currently, there is no way to signal the state of setup Stage to the driver. I will keep it in mind.
Yes, It can be improved, the buffer have not be copied again, but it not only affect the kinetis driver, I see it as a future enhancement to the USB stack.
It will be set to false at the end of usb_dc_detach.
Yes, it's not so nice, but the usb stack does not support multiple controller case either.
I will check it.
I will look at it.
I will check it. |
ffb095b
to
29db57f
Compare
@nashif @MaureenHelm @finikorg
Linux kernel output:
|
Add yaml file for Kinetis USBD support. Signed-off-by: Johann Fischer <[email protected]>
Add DT and fixup files to configure USB device driver on Kinetis SoC K64F and KW24D512. Signed-off-by: Johann Fischer <[email protected]>
Set bus master 4 to write and read access which allows the USBFSOTG controller read/write access to the memory. Signed-off-by: Johann Fischer <[email protected]>
Add usb device driver for Kinetis USBFSOTG Controller. Signed-off-by: Johann Fischer <[email protected]>
Enable USB device driver for K64F and KW2xD512 SoC Signed-off-by: Johann Fischer <[email protected]>
Enable sanitycheck for FRDM-K64F and USB-KW24D512 boards Signed-off-by: Johann Fischer <[email protected]>
Exclude usb_kw24d512 from wpanusb sample until the the sample has been reworked and is more generic. Signed-off-by: Johann Fischer <[email protected]>
This patch fixes some bugs found during testing with testusb from linux kernel. An unresolved issue is that the stack is not fast enough to stall (if necessary) the control endpoint during Setup Stage. This might require a API change so that the usb device stack can explicit allow the driver to resume token processing. Signed-off-by: Johann Fischer <[email protected]>
29db57f
to
895ad80
Compare
USB device driver for Kinetis USBFSOTG Controller
I had a driver for Kinetis USBFSOTG controller left over here, so I adapted it for zephyr, it is still WIP/RFC. Tested with FRDM-K64F board. The LEDs/gpio code will be removed, it is only for tracing.
TODO:
, currently 64 byte buffers are used by default-> see 259e568.