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

Added support for the NXP K64 series #2168

Merged
merged 9 commits into from
Feb 23, 2024
Merged

Added support for the NXP K64 series #2168

merged 9 commits into from
Feb 23, 2024

Conversation

emb4fun
Copy link
Contributor

@emb4fun emb4fun commented Jul 23, 2023

Here I am working with a FRDM-K64F board and try to get the TinyUSB up and running.
It takes some time, but I could found the problem why it is not working at first.

In case of the K64 the USB clock will be set with e.g.

CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcIrc48M, 48000000U);

This function will set inside some registers which are needed for the USB clock recovery:

if (kCLOCK_UsbSrcIrc48M == src)
{
    USB0->CLK_RECOVER_IRC_EN = 0x03U;
    USB0->CLK_RECOVER_CTRL |= USB_CLK_RECOVER_CTRL_CLOCK_RECOVER_EN_MASK;
}

Unfortunately this registers will be reset by the dcd_init function where a USB reset is performed.
This PR fix the problem in case of a K64 series. With this changes the device will be enumerated.
I am still in the progress of testing.

Best regards,
Michael

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

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

thank you very much for your PR. I have rename the option from OPT_MCU_KINETIS_K64 to simply OPT_MCU_KINETIS_K since it seems to be the name of family of those m4f.

I have tried to add kinetis_k to bsp with teensy_35 board to test with this PR. Unfortunately teensy 3.5 is not able to blink led with board_test example. It is probably due to clock config. I push the changes anyway, will try to find an k64f board later to test with. Menanwhile please be patient.

Update: I haved ordered frdm-k64f board for testing out this PR, it may take 3-4 weeks before it got delivered. Please be patient, thanks.

@karlp
Copy link

karlp commented Feb 19, 2024

I've got another tree with frdmk-64 support as well. I'll compare the two and comment.

@karlp
Copy link

karlp commented Feb 19, 2024

Why did you need the freertosconfig.h file? That seems unnecessary to have another copy of it? (and freertos demos work fine for me without it)

I'm still clearing our work with internal management, so it's not (very) publically shared yet unfortunately.

@hathach
Copy link
Owner

hathach commented Feb 23, 2024

Why did you need the freertosconfig.h file? That seems unnecessary to have another copy of it? (and freertos demos work fine for me without it)

I'm still clearing our work with internal management, so it's not (very) publically shared yet unfortunately.

It is part of my new approach, previously there is 1 freertos (per example) for all ports. However, that makes it difficult to compile with IAR since freeRTOSConfig.h is included by IAR assembler which is very primitive and cannot support complicated include like gcc assembler. SO I have moved freeRTOSconfig.h to each bsp, it kind of make sense as well, since each hardware would have different freertosconfig.

Currently only cmake make use of the new config (make still use the example's one), but eventually, when all bsp has its own config, I will remove the example's config later.

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

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

thank you, I have tested this with my frdm k64f board, working well. The save/restore crystal-less configuration is required, otherwise setting will be reset. There is no harm to restore these value when not using crystal-less mode

@hathach hathach merged commit 21de824 into hathach:master Feb 23, 2024
49 checks passed
@karlp
Copy link

karlp commented Feb 23, 2024

well, my only other concern is that not all the kinetis parts have those crystalless config registers, so we're going to be writing into registers that don't always exist.

@hathach
Copy link
Owner

hathach commented Feb 24, 2024

I will pull out to test with my kl25z board, I think it shouldn't have any effect. In my experience, these registers exist anyway, it is just readonly. If it is an issue, We can actually check the IRC_EN bit before restoring value, but I guess it is not really needed.

@hathach
Copy link
Owner

hathach commented Feb 24, 2024

PS: it cause out-of-memory issue on KL25Z, PR is on the way to fix this :) #2489

@karlp
Copy link

karlp commented Mar 4, 2024

I'm back from holidays, and this asserts (vApplicationStackOverflowHook 43: ASSERT FAILED ) when a hub is plugged in, with the examples/host/cdc_msc_hid_freertos example.

My local version (didn't get to a PR) works fine. I can't see what the difference would be (yet) but I'm obviously goin to have to find out :) Did this example work for you at all?

Related to the FreeRTOSConfig files, the newly added file is not even used at present. At least in the host/cdc_msc_hid_freertos. I added #error calls, and it's still using the standard one from the example. (however, the diff is minimal, and it shouldn't be changing stack sizes as far as I can tell)

@karlp
Copy link

karlp commented Mar 4, 2024

You also removed the pinmuxing, are you sure this actually works with uarts after those changes? Well, the uart still works, with LOGGER=uart, so I guess mcux is doing pinmuxing automatically....

@hathach
Copy link
Owner

hathach commented Mar 13, 2024

You also removed the pinmuxing, are you sure this actually works with uarts after those changes? Well, the uart still works, with LOGGER=uart, so I guess mcux is doing pinmuxing automatically....

pin muxing is done by boards/pin_mux.c which I use mcupinconfig to generate.

Related to the FreeRTOSConfig files, the newly added file is not even used at present. At least in the host/cdc_msc_hid_freertos. I added #error calls, and it's still using the standard one from the example. (however, the diff is minimal, and it shouldn't be changing stack sizes as far as I can tell)

yeah, I think I only tested with the cmake version, I will test with make later and adjust the heapsize when testing with the board again. Planning to do full migration but couldn't manage the time.

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