USB Host (HVAC demo) fail

cancel
Showing results for 
Search instead for 
Did you mean: 

USB Host (HVAC demo) fail

613 Views
arnogir
Senior Contributor II

Hello everybody.

I'm using a board with a K70FN1M0VMJ15 an USB port connected to the µC pin USB0DM/DP.

I'm using the exemple given in C:\Freescale\Freescale_MQX_4_1\demo\hvac

I only extract the USB file (USB_Files.cpp/hpp, USB_Classes.cpp/hpp, USB_Task.cpp/hpp) and create a main.cpp like following:

TASK_TEMPLATE_STRUCT MQX_template_list[] = {

/*  Task number, Entry point, Stack, Pri, String, Auto? */

  { USB_TASK,     USB_task,        2200L,   8L,      "USB",      MQX_AUTO_START_TASK,    0,      0           },

   {MAIN_TASK  ,Main_task  ,   1000, 4,"main"   , MQX_AUTO_START_TASK, 0, 0}, };

/*TASK*----------------------------------------------------------------- * * Function Name  : Main_task * Comments       : *    This task initializes MFS and starts SHELL. * *END------------------------------------------------------------------*/

void Main_task(uint_32 initial_data) {

for (;;) {

    _time_delay(10000);   } }

But this example do not wok find every time.

1- I declare only the USB_TASK (no main task) with Stack = 2200 and Prio = 8 (Like in example):

Unable to open USB device

Error while uninstalling filesystem.

Error while uninstalling partition manager.

USB device removed.

2- I declare only the USB_TASK (no main task) with Stack = 2200 and Prio = 9:

Unable to open USB device

Error while uninstalling filesystem.

Error while uninstalling partition manager.

USB device removed.

3- I declare only the USB_TASK (no main task) with Stack = 3000 and Prio = 9:  (WORK FINE !!!!!!)

************************************************************************

Vendor Information: Intenso Mass Storage Device

Product Identification: Rainbow Line 

Product Revision Level: 8.07

************************************************************************

Installing MFS over partition...

USB device installed to c:

4- I declare only the USB_TASK (no main task) with Stack = 4000 and Prio = 9:  (Not work with a larger stack size!!!

Unable to open USB device

Error while uninstalling filesystem.

Error while uninstalling partition manager.

USB device removed.

5- I declare the USB_TASK + The  Maintask with Stack = 3000 and Prio = 9:  (Not work with an other task which do nothing!

Unable to open USB device

Error while uninstalling filesystem.

Error while uninstalling partition manager.

USB device removed.

To resume, the USB work fine and install a partition on my USB key, ONLY when I have ONE task (USB) with STackSize = 3000 and task Prio = 9.

In all other case, USB not work.

When USB not work, it is the call back awaiting after calling usb_mass_ufi_inquiry which is never received (Screenshot in attached file)

Do you have an Idea?

Thank

0 Kudos
7 Replies

274 Views
arnogir
Senior Contributor II

Hi

If I comment the following define in the file

C:\Freescale\Freescale_MQX_4_1\usb\host\source\host\khci\khci.h:

:

/* Allow workaround for bug in the peripheral when unaligned buffer @4B address is used */ //debug AG #define KHCICFG_4BYTE_ALIGN_FIX

All work correctly.

Is somebody can explain me why? And what is the effect to comment this line? It seems to me it is a patch workaround??

274 Views
arnogir
Senior Contributor II

Hi,

So, nobody know why this patch must be commented in my case?

If a patch was created, it was to correct a problem, so if I comment this patch, what problem can occurs?

Thanks.

0 Kudos

274 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Arno,

Seems there is some code issue in MQX_template_list[], which should have a zero entry in the end. Please kindly refer to the following for details.

Untitled.png

BTW, I didn't see any "USB_Files.cpp/hpp, USB_Classes.cpp/hpp, USB_Task.cpp/hpp" in the folder, just "USB_Files.c/h, USB_Classes.c/h, USB_Task.c/h", are these source files written by yourself? Please kindly help to clarify. Thanks for your patience!


Have a great day,
Kan

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

0 Kudos

274 Views
arnogir
Senior Contributor II

Hi,

I extract souce code from the exemple: Freescale_MQX_4_1\demo\hvac\ . Yes  It is a mistake from me, file are .c and .h. (not cpp/hpp)

I also made a mistake on copying code here. In my TASK_TEMPLATE_STRUCT MQX_template_list[] I realy have the last line "{0, 0,0 ....}"

0 Kudos

274 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Arno,

I am trying to reproduce your issue, but based on the TWR-K70F120M, I found even for the failed case that you listed, the USB task can work sometimes, and the successful case is very random, everytime it failed, the BTOERR bit was got set, I am not sure if that is the same situation you met, would you please help to clarify?

Untitled.png


Have a great day,
Kan

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

0 Kudos

274 Views
arnogir
Senior Contributor II

Hi

Sorry for the late,

After many try, I can't to reproduce the problem now! It is very strange,

But When I was debug step by step when problem occurs, there was a very strange Address mix in the following code:

static void _usb_device_usbfs_service_tk_dne_intr

#if defined(KHCICFG_4BYTE_ALIGN_FIX) if (!xd_ptr->INTERNAL_DMA_ALIGN) { src = (uint8_t *)LONG_LE_TO_HOST(BD_ADDR_RX(ep_num, state_ptr->EP_INFO[ep_num].rx_buf_odd)); dst = xd_ptr->G.WSTARTADDRESS + xd_ptr->G.WSOFAR; if(src != dst) { USB_mem_copy(src, dst, len); } } #endif

0 Kudos

274 Views
Garabo
NXP TechSupport
NXP TechSupport

Hi Arno,

We are checking this workaround commented in the code. Let us do more research and we will come back with an answer.

Best Regards,

Garabo

0 Kudos