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?
Solved! Go to Solution.
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:
3. Delete all files in board folder and copy these files them from bm folder into board folder
4. Copy usb driver folders(from middleware\usb_1.6.3) to a new folder usb
5. Add include directories to settings
6. Change this in linker file (MK22FN512xxx12_flash.ld):
7. Add these preprocessor definitions:
8. Add this option to linker settings:
-Xlinker --defsym=__usb_ram_size__=0x800
Now the new project is ready for build and you have the usb example project as a standalone project.
Regards
Hi Chris,
KDS New Project Wizard allow to create standalone projects from SDK 2.x examples:
Before starting this wizard, please ensure you have the latest version from KDS Update site.
Regards
Marek
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.
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:
3. Delete all files in board folder and copy these files them from bm folder into board folder
4. Copy usb driver folders(from middleware\usb_1.6.3) to a new folder usb
5. Add include directories to settings
6. Change this in linker file (MK22FN512xxx12_flash.ld):
7. Add these preprocessor definitions:
8. Add this option to linker settings:
-Xlinker --defsym=__usb_ram_size__=0x800
Now the new project is ready for build and you have the usb example project as a standalone project.
Regards
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.
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.