USB HID Demo on FRDM-K66F

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

USB HID Demo on FRDM-K66F

Jump to solution
1,512 Views
a8Chcx
Contributor V

Hi,

 

I am testing USB HID Generic demo(BM version) and works fine..

Then, I am using Wizard 2.x in KDS 3.2.0 to generate my own project by choosing "include all driver", no RTOS option.

After that, I copied required USB stack and files from demo project, compile it, link it to generate *.elf fine. All work fine.

But, when I download it to my FRDM-K66F and run it, I got the error code==0x02(USB Busy) when I call USB_DeviceClassInit(CONTROLLER_ID, &g_UsbDeviceHidConfigList, &g_UsbDeviceHidGeneric.deviceHandle)). I check CONTROLLER_ID is 2.

Looks like it can't allocate memory for my USB handle...

Can anyone tell me where the problem can be, related to environment setting, like OS?

 

Thanks,

 

Christie

 

Labels (1)
0 Kudos
1 Solution
980 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Christie Su

Yes, the problem is in the linker file. There is a part in the linker file that assigned ram size for usb to initialized this in the .bss section:

USB_RAM_GAP = DEFINED(__usb_ram_size__) ? __usb_ram_size__ : 0x00;‍‍‍

So if you have defined symbol __usb_ram_size__ it will use it in USB_RAM_GAP, but if not, it will assigned 0x00. If you check linker settings in the example code, you can see that they defined the symbol with the flag "defsym"

pastedImage_2.png

But you don't have this linker flag in your settings, so linker file assigned 0x00 to USB_RAM_GAP, and when USB_DeviceClassInit try to allocate memory for usb, it doesn't have size in the .bss section.

You have two options, you could add this flag in your linker flags settings "-Xlinker -defsym=__usb_ram_size__=0x800", or you could change the linker file:

USB_RAM_GAP = DEFINED(__usb_ram_size__) ? __usb_ram_size__ : 0x800;‍‍‍

(Note: this is how it is defined in the earlier KSDK 2.0 release)

I made this change in your project and it works now, so give it a try and tell me if it works.
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
8 Replies
980 Views
ashesman
Contributor III

I also burnt quite some time on this problem...  Shame to have the USB library require project specific settings...

980 Views
a8Chcx
Contributor V

Sorry error code==0x01 when call the USB_DeviceClassInit function...

0 Kudos
980 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Christie Su

How is the status of you issue?

So If I understand correctly you get kStatus_USB_Error in USB_DeviceClassInit? CONTROLLER_ID as 2 is normal if you are using High speed drivers in your device configuration, so I don't believe that this generate you an error.

I made the same process that you do (generate my own project by choosing "include all driver"), I compile it and run it and I don't get any error code in the USB_DeviceClassInit function, could you share your project to see if I could find the error that you get?

Best Regards

Jorge Alcala

0 Kudos
980 Views
a8Chcx
Contributor V

Hi Jorge,

I played with some settings in KDS 3.2.0 and can't find where the problem is? Please see my attached project...

Here are what I did:

1) If I use the demo project, it works fine.

2) If I generate my own project with KSDK 2.0 with USB 1.0.0 in it. Then I copied USB 1.0.0 stack and required files in demo project. It works fine...

Please try my attached project to see if I made something wrong?

Please let me know the result...

Thanks,

Christie

0 Kudos
980 Views
a8Chcx
Contributor V

Hi Jorge,

I am using the latest KSDK 2.0 with Wizard 2.x to generate my own project(NO OS, all drives). Then I copied lwip_2.0.0 and required files from httpsrv demo. It works fine. Then I copied USB 1.0.0 and required files for USB HID. All these required files for USB HID are working. Then, I loaded to FRDM-K66F and USB not working again. But my http server still working...

Then, I tried earlier KSDK 2.0 with Wizard 2.X to build USB HID and works fine. Then I copied lwip_2.0.0 and required files from httpsrv demo. UBB HID and httpsrv server both are working.

To me, it looks like that the latest KSDK built from your web is different from what I built before, or there is different KDS setting?

Please let me know if you have any solution because I am thinking what the combination to use to build my final project?

Thanks,

Christie

0 Kudos
980 Views
a8Chcx
Contributor V

Hi Jorge,

Any update on the issue? Can you duplicate the problem?

Thanks,

Christie

0 Kudos
981 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Christie Su

Yes, the problem is in the linker file. There is a part in the linker file that assigned ram size for usb to initialized this in the .bss section:

USB_RAM_GAP = DEFINED(__usb_ram_size__) ? __usb_ram_size__ : 0x00;‍‍‍

So if you have defined symbol __usb_ram_size__ it will use it in USB_RAM_GAP, but if not, it will assigned 0x00. If you check linker settings in the example code, you can see that they defined the symbol with the flag "defsym"

pastedImage_2.png

But you don't have this linker flag in your settings, so linker file assigned 0x00 to USB_RAM_GAP, and when USB_DeviceClassInit try to allocate memory for usb, it doesn't have size in the .bss section.

You have two options, you could add this flag in your linker flags settings "-Xlinker -defsym=__usb_ram_size__=0x800", or you could change the linker file:

USB_RAM_GAP = DEFINED(__usb_ram_size__) ? __usb_ram_size__ : 0x800;‍‍‍

(Note: this is how it is defined in the earlier KSDK 2.0 release)

I made this change in your project and it works now, so give it a try and tell me if it works.
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
980 Views
a8Chcx
Contributor V

Hi Jorge,

It works after I change it in link file...

Thank you very much for your help!

Regards,

Christie

0 Kudos