Teensy 3.1 / MK20DX256VLH7 support

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

Moderator: utzig

utzig
Posts: 355
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby utzig » Fri Jan 23, 2015 9:14 pm

RedoX wrote:That's really cool. If you have a Git/Svn repository with your changes for the USB driver, I would be okay to have a look and see if I can help.


If I did that now I would make you cry or maybe LOL! Seriously though, I expected to be finishing probably by next Wednesday. If I have not commited it by then, please feel free to ping me and I will add a github repo with this so that we can work on it together.

RedoX wrote:Here's a new patch to add support for the Teensy3.1 to ChibiOS. This time, there is way less duplication. The only hack that I kept is for the PLL initialization to get 72MHz for the Teensy3.1. There must be a cleaner way to implement it, but for now, it works with my Teensy3.1... Please, have a look and tell me what you think about it.


It's still kinda big patch. I'll review it after the USB driver is done. I think there's lots of ways for we to make code even more reusable between different uC lines.

RedoX wrote:Any reason why st_lld and pal_lld are not in LLD/ ? They look the same for K20x and KL2x...
Also, I think there is a clean way to move serial_lld to LLD/ even if KL2x uses this UARTLP_Typedef for UART0 instead of the UART_Typedef. I don't have any board to test so I won't do it for now... but the KL25 Freedom is cheap so I might order one next time I need some parts. I think the spi_lld could also be moved to LLD/ since the KL2x family also has support for DMA.


The reason is that it was made with one specific model in mind and never tested on the others! My bad, I'll fix it in the near future. Thanks for the suggestions.

Cheers,
Fabio Utzig

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

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby RedoX » Fri Jan 23, 2015 9:40 pm

Okay thanks,

Good luck with the USB driver.

I think the reason the patch is so big is because it includes the demo folder for Teensy3.1 and the definition header for K20x7 and the memory setup for MK20DX256, which are separate static files... Well, Don't bother too much with the patch, I just forked the Github repo to be able to work on my stuff and still be able to merge the upstream changes easily.

BTW, the K20x/ext_lld driver didn't compile and channels could ntot be disable. Quick fix, in ext_lld_channel_disable() replace:

Code: Select all

port->PCR[pin] |= PORTx_PCRn_IRQC(PCR_IRQC_DISABLED);

by

Code: Select all

  port->PCR[pin] = port->PCR[pin] & (~PORTx_PCRn_IRQC_MASK);


Cheers

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

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby RedoX » Tue Feb 03, 2015 11:28 am

utzig wrote:If I did that now I would make you cry or maybe LOL! Seriously though, I expected to be finishing probably by next Wednesday. If I have not commited it by then, please feel free to ping me and I will add a github repo with this so that we can work on it together.


Hi Fabio,

How is the USB driver going ? On my side, I have almost everything I wanted, except this one; If that's okay with you, I would be happy to (try to) help you on the USB driver. Teensys are not the best boards to debug code, but I should get a FRDM-KL25Z by the end of the week.

Cheers

utzig
Posts: 355
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby utzig » Wed Feb 04, 2015 1:30 am

Hi,

For now I would prefer to continue on my own. I finally took a full day to hack on this. At the current stage it's not working but I'm getting the data from host (GET DESCRIPTOR) and sending the response although it's getting on the host malformed. I know I'm still missing some things which I'm working on, so to get this to a stage where at least basic functionality is there may not be far away. What is surprising is how hard it has been to wrap my head around the ChibiOS USB driver model. Not that hard to implement but hard to get it all...

Anyway, if you have some extremely high requirement to have USB working soon, I would suggest using your own driver. The only problem would be that you would not be able to use the serial_usb but most Kinetis/Teensy usb drivers I've seen already have CDC in them. Also if your board will only arrive by the end of the week, this driver might be working, but this time I don't want to sound too confident that it will!

As soon as my driver is acceptable I may commit it and a demo to trunk (without adding to platform.mk) so that anyone can inspect/review.

Cheers,
Fabio Utzig

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

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby Giovanni » Wed Feb 04, 2015 9:31 am

utzig wrote:What is surprising is how hard it has been to wrap my head around the ChibiOS USB driver model. Not that hard to implement but hard to get it all...


And you are not the only one... I wish to find ways to make it simpler.

I could remove the queues-related APIs but without those the CDC implementation becomes ridiculously complex so complexity just moves elsewhere.

Giovanni

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

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby RedoX » Wed Feb 04, 2015 10:08 am

Hi Fabio,

That's good news. I understand and will waiting for the first release, to do some beta test.

Right now I am stuck on reconfiguring the EEPROM partition on the Teensy3.1. Warning: If you use the eeprom, you will probably not be able to reconfigure it (change the size), due to the design of the bootloader (on the Mini54).

Thanks and good luck with the driver !

Cheers

TomV
Posts: 1
Joined: Sat Mar 07, 2015 3:38 pm

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby TomV » Mon Mar 09, 2015 5:34 pm

Hi Fabio,

any progress in usb driver?
I need one for Kinetis K22 so I'm offering help/testing.

Tom

utzig
Posts: 355
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby utzig » Mon Mar 09, 2015 10:29 pm

Hi,

Sorry but I didn't really work on the USB driver those last weeks. I relocated to another state in my country and I'm still looking for a definitive place to live because right now I'm living on a hostel (since last week). It should take maybe two more weeks to get everything setup and then I'll get back to the USB work.

Cheers,
Fabio Utzig

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

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby ohanssen » Fri Apr 10, 2015 9:32 am

Hi and thanks for the good work on ChibiOS and Teensy. I am using RedoX's repository and it works well upto a point. I use the serial driver SD1 and it works fine, BUT when I try to use the other two serial ports (SD2 and SD3) the whole thing crashes as soon as I try to read from or write to the serial port.

I have configured the pins as follows (for SD3):

Code: Select all

   palSetPadMode(IOPORT4, PORTD_TEENSY_PIN7, PAL_MODE_ALTERNATIVE_3);
   palSetPadMode(IOPORT4, PORTD_TEENSY_PIN8, PAL_MODE_ALTERNATIVE_3);

Except for different addresses for the UART modules, the driver code seems to be identical, so I cannot see why it fails. Anyone got the second or the third serial port on a Teensy 3.1 working? Am I missing something?

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

Re: Teensy 3.1 / MK20DX256VLH7 support

Postby RedoX » Fri Apr 10, 2015 10:02 am

Hi,

I don't think I tried that, but it should work... Can you provide the code you are using so we can have a look and maybe find what's wrong ? Also, make sure you defined the KINETIS_HAS_SERIALx and KINETIS_SERIALx_IRQ_VECTOR with the correct values for the serial port you are trying to use. I had the same issue when I first tried to use the Teensy3 port on a Teensy3.1

I will have a closer look at this when I have some spare time.

The code is almost the same for KL2x and K20x (and also for K20x5 and K20x7) and they will be merged as soon as we find a clean way to do it.


Return to “Kinetis Support”

Who is online

Users browsing this forum: No registered users and 1 guest