Clean KSDK 2.x project, how do you add USB?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Clean KSDK 2.x project, how do you add USB?

Jump to solution
1,200 Views
chriskeeser
Contributor III

I'm trying to add USB to a clean KDS 3.2 KSDK 2.x project.  I found this related post : How to add USB Middleware on my KDS+KSDK Project but the described steps are incomplete and so far I have been unable to even successfully compile the project.

I copied the files from the middleware folders and example project into my project and added them as include paths for the compiler:

C:\Freescale\SDK_2.2_MK22FN512xxx12\middleware\usb_1.6.3/device

C:\Freescale\SDK_2.2_MK22FN512xxx12\middleware\usb_1.6.3/includes

C:\Freescale\SDK_2.2_MK22FN512xxx12\middleware\usb_1.6.3/osa

C:\Freescale\SDK_2.2_MK22FN512xxx12\boards\frdmk22f\usb_examples\usb_device_composite_cdc_msc_lite/bm

I removed the 'kds' folder from the example 'bm' directory after the copy to prevent any confusion with the kds project files.

I need the project to be stand-alone (cannot link files in the KSDK 2.x directory) since the entire (complete) project must be included in version control.

In summary, what are the steps to add the USB middleware to a clean KSDK 2.x project in KDS 3.2?

1 Solution
909 Views
visakhanc
Contributor III

Hi,

Here are the steps to copy a usb device example to a new KSDK 2.x project and build it:

1. Delete main.c from source folder of the new project

2. Copy application files from bm folder (boards\frdmk22f\usb_examples\usb_device_composite_cdc_msc_lite\bm)  to source folder. After this the source folder will be like:

      source.PNG

3. Delete all files in board folder and copy these files them from bm folder into board folder

    pastedImage_8.png

4. Copy usb driver folders(from middleware\usb_1.6.3) to a new folder usb

   pastedImage_10.png

5. Add include directories to settings

   pastedImage_12.png

6. Change this in linker file (MK22FN512xxx12_flash.ld):

linker_usb.PNG

7. Add these preprocessor definitions:

pastedImage_13.png

pastedImage_14.png

8. Add this option to linker settings:

   -Xlinker --defsym=__usb_ram_size__=0x800

pastedImage_19.png

Now the new project is ready for build and you have the usb example project as a standalone project. 

Regards

View solution in original post

5 Replies
909 Views
marek-trmac
NXP Employee
NXP Employee

Hi Chris,

KDS New Project Wizard allow to create standalone projects from SDK 2.x examples:

  • File - New - Kinetis SDK 2.x Project
  • Enter project name and select SDK 2.x root folder
  • Select Boards - {board} - Examples - usb_examples - {example}
  • Hit Finish

Before starting this wizard, please ensure you have the latest version from KDS Update site.

Regards

Marek

Regards,
Marek
0 Kudos
909 Views
chriskeeser
Contributor III

Thanks Marek, but this solution does not do what I need.  While this solution does allow you to create a new clean project with USB from an example, it does not describe how to bring USB into an existing clean project.  Therefore, I am unable to specify which driver set I want to import (none / minimal / complete) and I am not able to specify a c++ project from the beginning of creating the project.

0 Kudos
910 Views
visakhanc
Contributor III

Hi,

Here are the steps to copy a usb device example to a new KSDK 2.x project and build it:

1. Delete main.c from source folder of the new project

2. Copy application files from bm folder (boards\frdmk22f\usb_examples\usb_device_composite_cdc_msc_lite\bm)  to source folder. After this the source folder will be like:

      source.PNG

3. Delete all files in board folder and copy these files them from bm folder into board folder

    pastedImage_8.png

4. Copy usb driver folders(from middleware\usb_1.6.3) to a new folder usb

   pastedImage_10.png

5. Add include directories to settings

   pastedImage_12.png

6. Change this in linker file (MK22FN512xxx12_flash.ld):

linker_usb.PNG

7. Add these preprocessor definitions:

pastedImage_13.png

pastedImage_14.png

8. Add this option to linker settings:

   -Xlinker --defsym=__usb_ram_size__=0x800

pastedImage_19.png

Now the new project is ready for build and you have the usb example project as a standalone project. 

Regards

909 Views
chriskeeser
Contributor III

Thank you.  These steps worked properly and allowed me to bring in the middleware into my existing project.  Thank you for taking the time to write up the very clear instructions.

As a related question, do you know what the '-Xlinker --defsym=__usb_ram_size=0x800' linker option does?  I was unable to find that symbol in the linker script or anywhere in the project.

0 Kudos
909 Views
visakhanc
Contributor III

Nice to know it helped you! The linker option '-Xlinker --defsym=__usb_ram_size=0x800' was found in the project settings of that usb example. I also didn't find the use of it. I think some other usb examples may be using it.

0 Kudos