Teensy 3.1 / MK20DX256VLH7 support

ChibiOS public support forum for topics related to the Freescale Kinetis family of micro-controllers.

Moderator: utzig

jstruebel
Posts: 19
Joined: Sat Oct 17, 2015 5:59 am
Has thanked: 2 times
Been thanked: 3 times
Contact:

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby jstruebel » Sun Oct 18, 2015 6:07 pm

First of all I want to say thank you to RedoX and flabbergast for porting the USB to the KINETIS. It looks like you've put a lot of effort into it.

However, I'm trying to get it up and running on a Freescale FRDM-K20D50M board and I'm having trouble attaching to the virtual COM port with TeraTerm. I started by copying over the KL25Z testhal and modifying it for the K20 MCU with the RT-FREEDOM-K20D50M demo and TEENSY3 testhal projects. When I plug in the USB I get the debug output over the serial port which I think means it is attaching, and I have a new ChTsy CDC COM port, but when I try to connect to that COM port with TeraTerm it just sits there forever saying it's connecting and periodically I get some debug messages on the serial port. Is this something any of you have seen and do you have any suggestions for where to look? Do you have any sort of decoder for the debug messages on the serial port or do I just need to look through the USB driver code to figure out what is going on?

Any help is greatly appreciated.

Thanks,
Jonathan

flabbergast
Posts: 71
Joined: Sat Aug 22, 2015 1:22 pm

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby flabbergast » Sun Oct 18, 2015 10:10 pm

Getting the debug messages pretty much means that the USB driver does interact with your PC. AFAIK there's no decoder, if you really want to figure out what's exactly going on, you need to search through the code in usb_lld.c.

I think if you start from the Teensy3/usb_serial demo, it should be just a matter of changing the board in the Makefile and the LED on/off statements - they have the same MCU (the only other notable differences are onboard crystal frequencies and LEDs). That code does work for me on a Teensy 3.0 (using both mine and RedoX's tree - just make sure that you have all the CH_DBG options disables in chconf.h with RedoX's tree). Unfortunately I don't have a FRDM-K20D50M board to test.

I've had a problem like this (when I was playing with STM32F042 though), and in my case the problem turned out to be that the I didn't have enough MCU memory for the "shell" that's supposed to run on the MCU side (it allocates memory dynamically) - and that's unlikely to be a problem for you...

User avatar
RedoX
Posts: 16
Joined: Tue Jan 20, 2015 4:36 pm

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby RedoX » Tue Oct 20, 2015 10:18 pm

Hi flabbergast,

Nice job on cleaning up the KINETIS port ! It does look great (better than mine actually). I still have no time to work on that but I keep an eye on your development and it's really cool to see all that stuff.

I plan on getting a TeensyLC (and also a 3.2, but that's less interesting) in the next weeks and try with ChibiOS then...

Keep up the good work !

Best regards,
RedoX

flabbergast
Posts: 71
Joined: Sat Aug 22, 2015 1:22 pm

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby flabbergast » Wed Oct 21, 2015 9:09 am

Thanks for the kind words! All the actual code is yours ;)

(I haven't touched the K20x things much yet - I have a Teensy 3.2 on the way, so hopefully I can do some testing with K20x7 soon as well.)

jstruebel
Posts: 19
Joined: Sat Oct 17, 2015 5:59 am
Has thanked: 2 times
Been thanked: 3 times
Contact:

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby jstruebel » Thu Oct 29, 2015 5:46 am

I'm still unable to get the USB_SERIAL to work with my setup. After trying several things including installing the latest GNU ARM tools, I went ahead and got a Freedom-KL25Z to test with. Unfortunately I get the same results, it is recognized by windows as a COM port, but when I try to open it with TeraTerm, no luck. It just sits there trying to connect. I'm running Windows Vista 32-bit and TeraTerm v4.84. I'm thinking that there is something about the way the virtual serial port is being implemented that doesn't work well with my setup. What are you all using to connect up with the USB_SERIAL project?

Thanks,
Jonathan

flabbergast
Posts: 71
Joined: Sat Aug 22, 2015 1:22 pm

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby flabbergast » Thu Oct 29, 2015 1:57 pm

I don't use windows for development (or otherwise), but I gave it a go in a virtual machine. Windows 7 32bit, FRDM KL26Z, with the USB Serial demo from my kinetis branch, TeraTerm. Worked without problems (by which I mean: plugged in; W7 complained about non-existence of a driver, so I "installed" the chtsy.inf file from the USB Serial source folder, after which the demo was recognised as a serial port; connected via TeraTerm; changed the baud rate to 115200 - after which I got the expected response from the "chibi shell" running on the KL26Z). So unfortunately I can't really help you...

User avatar
Giovanni
Site Admin
Posts: 11386
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 430 times
Been thanked: 363 times
Contact:

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby Giovanni » Thu Oct 29, 2015 3:57 pm

Note that Serial-USB does not handle all EP0 CDC messages, if the communication program sends an unhandled message the endpoints are stalled. This could be a cause.

The solution would be to place a breakpoint in the Serial-USB messages handler and verify what it is being sent, then handle the extra messages.

This can be done in two wais:
- Write a new handler that calls the existing handler and adds new messages.
- Add new messages to the existing handler improving Serial-USB.

Giovanni

ohanssen
Posts: 5
Joined: Thu Mar 05, 2015 10:56 pm

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby ohanssen » Sat Oct 31, 2015 1:11 pm

A small typo in gpt_lld.c ?
Line 311 (in flabbergast kinetis branch):

#if KINETIS_GPT_USE_PIT3
if (&GPTD4 == gptp) {
nvicDisableVector(PITChannel4_IRQn);
}
#endif

It seems like the correct PITChannel is 3, not 4?

flabbergast
Posts: 71
Joined: Sat Aug 22, 2015 1:22 pm

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby flabbergast » Sun Nov 01, 2015 9:24 am

Yep, thanks! I fixed it in my branch, but utzig might want to do it in the official svn as well ... :)

jstruebel
Posts: 19
Joined: Sat Oct 17, 2015 5:59 am
Has thanked: 2 times
Been thanked: 3 times
Contact:

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby jstruebel » Fri Nov 06, 2015 5:46 am

I was able to do some more debugging tonight using USBPcap/Wireshark and comparing the ChibiOS Serial-USB to the Freescale Kinetis SDK reference. It appears to be hanging at one point in the connection when TeraTerm is trying to connect. I see a 30sec gap and it restarts the sequence of USB messages. Possibly this is the stall that Giovanni was referring to, but as you'll see below, that particular message seems to have a handler. I'll do some more debugging this weekend to see if I can figure out why it hangs at that particular spot. Any suggestions or tips are much appreciated.

The USB messages are:
GET LINE CODING Request
GET LINE CODING Response
GET LINE CODING Request
GET LINE CODING Response
GET LINE CODING Request
GET LINE CODING Response
SET LINE CODING Request
SET LINE CODING Response
GET LINE CODING Request
GET LINE CODING Response
SET CONTROL LINE STATE Request
SET LINE CODING Request <-- This is where it hangs and I don't see the following messages.
30sec later it repeats from the top to this point.
SET LINE CODING Response
GET LINE CODING Request
GET LINE CODING Response


Return to “Kinetis Support”

Who is online

Users browsing this forum: No registered users and 1 guest