Adding USB stack to existing MQX application

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

Adding USB stack to existing MQX application

1,329 Views
jose_asensio
Contributor III

Hello everyone.

I have a MQX application and I want to add a CDC device to it. I am not using PE.

I had a look at USB related documentation like Freescale KSDK USB Stack Developing New Application User’s Guide

but I am not sure if that document is all what I need to get some USB code compiling.

I tried adding usb_descriptor.c and usb_descriptor.h files and all USB include paths to my project but I'm getting a lot of errors.

Any suggestion?

Regards

Jose

0 Kudos
10 Replies

851 Views
jose_asensio
Contributor III

I created a new MQX project using KSDK project generator and added usb files from project:

C:\Freescale\KSDK_1.3.0\examples\twrk60d100m\demo_apps\usb\device\cdc\virtual_com\mqx\kds

I have exactly the same problem. I does not compile.

Please find it enclosed

0 Kudos

851 Views
jose_asensio
Contributor III

Hi David. Thanks for your response.

I think now I have a better picture of MQX.

I edited the post title because I found out that I am using MQX for SDK and not classic MQX.

My project was setup using KSDK project generator tool.

All my include paths are under KSDK 1.3 folder or KDS folder, as shown:

${PROJECT_KSDK_PATH}/platform/osa/inc

"${PROJECT_KSDK_PATH}/rtos"

"C:\Freescale\KDS_v3\Toolchain\lib\gcc\arm-none-eabi\4.8.4\include"

"C:\Freescale\KDS_v3\Toolchain\lib\gcc\arm-none-eabi\4.8.4\include-fixed"

"C:\Freescale\KDS_v3\Toolchain\arm-none-eabi\include"

"C:\Freescale\KSDK_1.3.0\middleware\filesystem\mfs\source\include"

"C:\Freescale\KSDK_1.3.0\middleware\filesystem\mfs\lib\twrk60d100m.kds\debug\mfs"

../../board

../../

${PROJECT_KSDK_PATH}/platform/utilities/inc

../../port/mqx

../../port

${PROJECT_KSDK_PATH}/platform/utilities/src

"${PROJECT_KSDK_PATH}/platform/utilities/inc"

${PROJECT_KSDK_PATH}/platform/CMSIS/Include

${PROJECT_KSDK_PATH}/platform/devices/MK20D10/include

${PROJECT_KSDK_PATH}/platform/devices

${PROJECT_KSDK_PATH}/platform/devices/MK20D10/startup

${PROJECT_KSDK_PATH}/platform/hal/inc

${PROJECT_KSDK_PATH}/platform/drivers/inc

C:/Freescale/KSDK_1.3.0/usb/adapter/sources

C:/Freescale/KSDK_1.3.0/usb/adapter/sources/sdk

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/include/MK60D10

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/include

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/audio

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/cdc

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/common

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/composite

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/hid

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/include

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/include/config

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/msd

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/phdc

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/classes/video

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/controller/khci

C:/Freescale/KSDK_1.3.0/usb/usb_core/device/sources/controller

C:/Freescale/KSDK_1.3.0/usb/usb_core/hal

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/include/MK60D10

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/include

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/sources/classes/audio

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/sources/classes/cdc

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/sources/classes/hid

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/sources/classes/hub

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/sources/classes/msd

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/sources/classes/phdc

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/sources/controller/khci

C:/Freescale/KSDK_1.3.0/usb/usb_core/host/sources/controller

C:/Freescale/KSDK_1.3.0/usb/usb_core/include

C:/Freescale/KSDK_1.3.0/usb/usb_core/otg/sources/driver/khci

C:/Freescale/KSDK_1.3.0/usb/usb_core/otg/sources/driver/max3353/sdk

C:/Freescale/KSDK_1.3.0/usb/usb_core/otg/include

C:/Freescale/KSDK_1.3.0/usb/usb_core/otg/sources/otg

${PROJECT_KSDK_PATH}/platform/system/inc

${PROJECT_KSDK_PATH}/platform/drivers/src/adc16

${PROJECT_KSDK_PATH}/platform/drivers/src/cmp

${PROJECT_KSDK_PATH}/platform/drivers/src/cmt

${PROJECT_KSDK_PATH}/platform/drivers/src/crc

${PROJECT_KSDK_PATH}/platform/drivers/src/dac

${PROJECT_KSDK_PATH}/platform/drivers/src/dspi

${PROJECT_KSDK_PATH}/platform/drivers/src/edma

${PROJECT_KSDK_PATH}/platform/drivers/src/enet

${PROJECT_KSDK_PATH}/platform/drivers/src/ewm

${PROJECT_KSDK_PATH}/platform/drivers/src/flexbus

${PROJECT_KSDK_PATH}/platform/drivers/src/flexcan

${PROJECT_KSDK_PATH}/platform/drivers/src/ftm

${PROJECT_KSDK_PATH}/platform/drivers/src/gpio

${PROJECT_KSDK_PATH}/platform/drivers/src/i2c

${PROJECT_KSDK_PATH}/platform/drivers/src/lptmr

${PROJECT_KSDK_PATH}/platform/drivers/src/mpu

${PROJECT_KSDK_PATH}/platform/drivers/src/pdb

${PROJECT_KSDK_PATH}/platform/drivers/src/pit

${PROJECT_KSDK_PATH}/platform/drivers/src/rnga

${PROJECT_KSDK_PATH}/platform/drivers/src/rtc

${PROJECT_KSDK_PATH}/platform/drivers/src/sai

${PROJECT_KSDK_PATH}/platform/drivers/src/sdhc

${PROJECT_KSDK_PATH}/platform/drivers/src/tsi

${PROJECT_KSDK_PATH}/platform/drivers/src/uart

${PROJECT_KSDK_PATH}/platform/drivers/src/vref

${PROJECT_KSDK_PATH}/platform/drivers/src/wdog

${PROJECT_KSDK_PATH}/platform/drivers/src/smartcard

${PROJECT_KSDK_PATH}/platform/drivers/src/smartcard/interface

${PROJECT_KSDK_PATH}/rtos/mqx/lib/twrk60d100m.kds/debug

${PROJECT_KSDK_PATH}/rtos/mqx/lib/twrk60d100m.kds/debug/config

${PROJECT_KSDK_PATH}/rtos/mqx/lib/twrk60d100m.kds/debug/mqx

${PROJECT_KSDK_PATH}/rtos/mqx/lib/twrk60d100m.kds/debug/mqx_stdlib

${PROJECT_KSDK_PATH}/rtos/mqx/config/mcu/MK60D10

${PROJECT_KSDK_PATH}/rtos/mqx/config/board/twrk60d100m

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/bsp

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/psp/cortex_m

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/psp/cortex_m/compiler/gcc_arm

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/psp/cortex_m/core/M4

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/psp/cortex_m/cpu

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/include

${PROJECT_KSDK_PATH}/rtos/mqx/config/common

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/nio

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_dummy

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_mem

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_null

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_pipe

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_serial

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_tfs

${PROJECT_KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_tty

I hope this helps for you to understand better.

Regards

Jose

0 Kudos

850 Views
DavidS
NXP Employee
NXP Employee

Hi Jose,

Sorry for delay.

Where I am confused is as follows:  Why are you mixing and matching USB stacks?

MQX4.2 has USB stack integrated with it.  Trying to take the USB stack from KSDK is not something we currently support so it is hard to give help.

Sorry if I am not understanding this correctly.

Regards,

David

0 Kudos

850 Views
jose_asensio
Contributor III

I am still stuck with this.

Any suggestions?

Thanks so much

0 Kudos

850 Views
jose_asensio
Contributor III

This is a copy of my project:

Dropbox - copy-point-green.zip

In my machine the project is located at C:\projects\kds_workspace\

Thanks

0 Kudos

850 Views
jose_asensio
Contributor III

Hi David.

Following indications of your last post, I added some includes paths, and I got it compiling, but there are a few things I do not understand very well.

As I explained, I set up a project based on MQX 4.2 in which I use these libraries:

"C:\Freescale\KSDK_1.3.0\usb\usb_core\device\lib\mqx\kds\MK60D10\debug\libusbd_mqx.a"

${PROJECT_KSDK_PATH}/lib/ksdk_mqx_lib/kds/K60D10/debug/libksdk_platform_mqx.a

${PROJECT_KSDK_PATH}/rtos/mqx/lib/twrk60d100m.kds/debug/mqx/lib_mqx.a

${PROJECT_KSDK_PATH}/rtos/mqx/lib/twrk60d100m.kds/debug/mqx_stdlib/lib_mqx_stdlib.a

The example project you did mention seems to be using different stuff and when I debug my app something weird happens when calling USB_Class_CDC_Init function. This is my function call:

g_app_handle = USB_Class_CDC_Init(&cdc_config);

The function prorotype is defined in header file C:\Freescale\Freescale_MQX_4_2\lib\twrk60d100m.kds\debug\usb\usb_cdc.h

There is an implementation matching that function prototype in C:\Freescale\Freescale_MQX_4_2\usb\device\source\classes\cdc\usb_cdc.c:

uint32_t USB_Class_CDC_Init (CDC_CONFIG_STRUCT_PTR cdc_config_ptr)

But in this case the function invoked and the function executed are not the same, as de function executing has different input parameters and seems to be the one implemented in C:\Freescale\KSDK_1.3.0\usb\usb_core\device\sources\classes\cdc\usb_cdc.c:

usb_status USB_Class_CDC_Init (uint8_t controller_id, cdc_config_struct_t * cdc_config_ptr, cdc_handle_t * cdc_handle_ptr)

I tried to use exactly the same configuration parameters as in the example project: includes, libraries an so...but things became worse.

I found another example project located at:

C:\Freescale\KSDK_1.3.0\examples\twrk60d100m\demo_apps\usb\device\cdc\virtual_com\mqx\kds

I am using it as a reference now. In this project, function call to USB_Class_CDC_Init matches with implementation in

C:\Freescale\KSDK_1.3.0\usb\usb_core\device\sources\classes\cdc\usb_cdc.c

The point is that I still have problems to compile my app:

expected declaration specifiers or '...' before '*' token point-green_MK60DN512VMD10  line 42 C/C++ Problem
expected declaration specifiers or '...' before '*' token point-green_MK60DN512VMD10  line 42 C/C++ Problem
expected declaration specifiers or '...' before '*' token point-green_MK60DN512VMD10  line 42 C/C++ Problem
make: *** [sources/main.o] Error 1 point-green_MK60DN512VMD10    C/C++ Problem
make: Target 'all' not remade because of errors. point-green_MK60DN512VMD10    C/C++ Problem
recipe for target 'sources/main.o' failed subdir.mk /point-green_MK60DN512VMD10/debug/sources line 18 C/C++ Problem

0 Kudos

850 Views
DavidS
NXP Employee
NXP Employee

Hi Jose,

You might want to compare your project to the cdc_vcom_twrk60d100m project Properties.

There are Cross ARM C Compiler Preprocessor Defined symbols:

_AEABI_LC_CTYPE=C

__STRICT_ANSI__=1

_DEBUG=1

There are Cross ARM C Compiler Includes paths:

${ProjDirPath}/../../..

${ProjDirPath}/../../../../../../../../lib/twrk60d100m.kds/debug/bsp/Generated_Code

${ProjDirPath}/../../../../../../../../lib/twrk60d100m.kds/debug

${ProjDirPath}/../../../../../../../../lib/twrk60d100m.kds/debug/bsp

${ProjDirPath}/../../../../../../../../lib/twrk60d100m.kds/debug/psp

${ProjDirPath}/../../../../../../../../lib/twrk60d100m.kds/debug/usb

${eclipse_home}../toolchain/lib/gcc/arm-none-eabi/4.8.4/include

${eclipse_home}../toolchain/lib/gcc/arm-none-eabi/4.8.4/include-fixed

${eclipse_home}../toolchain/arm-none-eabi/include

There are Cross ARM C Linker Miscellaneous Other objects paths:

${ProjDirPath}/../../../../../../../../lib/twrk60d100m.kds/debug/bsp/bsp.a

${ProjDirPath}/../../../../../../../../lib/twrk60d100m.kds/debug/psp/psp.a

${ProjDirPath}/../../../../../../../../lib/twrk60d100m.kds/debug/usb/usbd.a

${eclipse_home}../toolchain/lib/gcc/arm-none-eabi/4.8.4/armv7e-m/libgcc.a

${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/libc.a

${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/libsupc++.a

${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/libm.a

${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/libnosys.a

Regards,

David

0 Kudos

850 Views
jose_asensio
Contributor III

This is what I am getting

compile.jpg

0 Kudos

850 Views
jose_asensio
Contributor III

Hi David.

Yes...I imported it into the workspace and it compiles with no errors

0 Kudos

850 Views
DavidS
NXP Employee
NXP Employee

Hi Jose,

Have you tried using the following USB CDC example in MQX4.2?

C:\Freescale\Freescale_MQX_4_2\usb\device\examples\cdc\virtual_com\build\kds

Regards,

David

0 Kudos