Skip to content
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

Draft: Add support for NXP Kinetis K28FA #2462

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pmiettinen
Copy link

@pmiettinen pmiettinen commented Feb 8, 2024

This is an attempt to add support for NXP Kinetis K28FA. Effort is mostly based on the existing ports for kinetis_k32l2, mimxrt1170_evkb and the frdmk28fa_dev_composite_cdc_vcom_cdc_vcom_bm example in NXP MCUXpresso.

Unsure if the ci_hs driver is applicable here as is.

Current state of the port

Build OK:

tinyusb$ make -C examples/device/cdc_dual_ports/ BOARD=frdm_k28fa15 LOG=2 all
...
CREATE _build/frdm_k28fa15/cdc_dual_ports.hex

   text    data     bss     dec     hex filename
  26436     152   10260   36848    8ff0 _build/frdm_k28fa15/cdc_dual_ports.elf

make: Leaving directory '/home/pasi/git/tinyusb/examples/device/cdc_dual_ports'

Board boots up but doesn't seem to receive the setup message:

USBD init on controller 0
sizeof(usbd_device_t) = 51
sizeof(tu_fifo_t) = 12
sizeof(tu_edpt_stream_t) = 24
CDC init
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed

Error messages on the Windows 11 host:

Windows has stopped this device because it has reported problems. (Code 43)

A request for the USB device descriptor failed.
Device settings for USB\VID_0000&PID_0002\6&28495545&0&2 were not migrated from previous OS installation due to partial or ambiguous device match.

Last Device Instance Id: USB\VID_045E&PID_07B2\9&1b254b8a&0&2
Class Guid: {36fc9e60-c465-11cf-8056-444553540000}
Location Path: 
Migration Rank: 0xF000FFFFFFFFF120
Present: false
Status: 0xC0000719

Porting guide suggests that this scenario indicates there's something wrong with the USB setup. This is possible but I am running out of ideas what to check. I took the clock config from the working MCUXpresso example and have been also otherwise comparing the projects but have not been able to find the relevant difference. Any tips what to check next? As a disclaimer, I have not worked with tinyusb earlier so I am likely to miss some obvious items too.

@@ -0,0 +1,35 @@
UF2_FAMILY_ID = 0x7f83e793
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be put here?

@pmiettinen pmiettinen changed the title Draft: Add support NXP Kinetis K28FA Draft: Add support for NXP Kinetis K28FA Feb 8, 2024
@pmiettinen pmiettinen marked this pull request as draft February 8, 2024 19:08
@pmiettinen
Copy link
Author

Some extra info.

This is what I see with the working NXP example:

image

With my tinyusb port I see nothing in the wireshark.

@pmiettinen
Copy link
Author

Looks like the dcd_reg->ENDPTSETUPSTAT is missed in dcd_int_handler because int_status & INTR_USB is not set at the same time.

@hathach
Copy link
Owner

hathach commented Feb 22, 2024

yeah, it should be ci_hs, try to compile with LOG=2 and checkout its output with either UART or segger rtt (LOGGER=RTT)

@pmiettinen
Copy link
Author

yeah, it should be ci_hs, try to compile with LOG=2 and checkout its output with either UART or segger rtt (LOGGER=RTT)

If I didn't totally misunderstand, this is what I've already done? Please check the PR description. Additionally, I have observed the dcd_int_handler behavior in debugger and saw ENDPTSETUPSTAT going unhandled in the current logic.

@hathach
Copy link
Owner

hathach commented Feb 24, 2024

yeah, it should be ci_hs, try to compile with LOG=2 and checkout its output with either UART or segger rtt (LOGGER=RTT)

If I didn't totally misunderstand, this is what I've already done? Please check the PR description. Additionally, I have observed the dcd_int_handler behavior in debugger and saw ENDPTSETUPSTAT going unhandled in the current logic.

sorry my bad, look like it could be an clock/setup issue, each MCU will have slightly different clock setup. Unfortunately I don't have any K28 to test with. I will try to see if I could find a reasonable Kinets with hs usb from ebay. It may take a while though.

@pmiettinen
Copy link
Author

By the way. I am seeing the same behavior on NXP MIMXRT1160-EVK secondary processor (M4). The primary core or M7 is working as expected. Just in case you have access to these boards more easily.

@hathach
Copy link
Owner

hathach commented Mar 13, 2024

By the way. I am seeing the same behavior on NXP MIMXRT1160-EVK secondary processor (M4). The primary core or M7 is working as expected. Just in case you have access to these boards more easily.

Oh, I don't have rt1160 but got 1170. Let me try to see if I could make a quick switch from m7 to m4 to compile with. However, they can be two different issues with different clock/pin configuration since these MCUs are totally different.

@pmiettinen
Copy link
Author

By the way. I am seeing the same behavior on NXP MIMXRT1160-EVK secondary processor (M4). The primary core or M7 is working as expected. Just in case you have access to these boards more easily.

Oh, I don't have rt1160 but got 1170. Let me try to see if I could make a quick switch from m7 to m4 to compile with. However, they can be two different issues with different clock/pin configuration since these MCUs are totally different.

1170 should be fine. As a background, I did the M4 experiment in MCUXpresso. I took some M4 example as a base and then followed the tinyUSB porting guide replacing the NXP USB stack.

@hathach
Copy link
Owner

hathach commented Apr 6, 2024

Just ordered an frdm k66f from ebay to test out this pr. Couldn't find a k28, but I guess it would be much more similar than rt1170. It will take a month or so for it to be delivered to my desk so please be patient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants