USB Host Problems - Ux_host_class_instance_unknown

Hello,

I'm having some troubles integrating an USB thread to a bigger application.

I'm using SSP1.2.0 and a custom board based on the S7G2

I manage to get USB running by itself (the example application that creates a "counter" text in the USB) but I don't manage to make it work in a bigger application. This bigger application contains several threads with several features (UART communication, SD Card, touchscreen...).

When I try to run the USB application it detects that the USB has been inserted (usb_host_plug_event_notification), but prior to that, it doesn't manage to instance the media. I've debugged the application and the problem seems to be in the ux_system_host_storage_fx_media_get function inside common_data.c. Here we can find the following code:

/** Get the USBX Host Mass Storage Class. */
ux_host_stack_class_get (_ux_system_host_class_storage_name, &p_host_class);

/** Get the pointer to a media attached to the class container for USB Host Mass Storage. */
p_storage_media_local = (UX_HOST_CLASS_STORAGE_MEDIA *) p_host_class->ux_host_class_media;

/** Get the pointer to a FileX Media Control Block. */

for (index = 0; index < UX_HOST_CLASS_STORAGE_MAX_MEDIA; index++)
{
p_fx_media_local = &p_storage_media_local->ux_host_class_storage_media;
if (p_fx_media_local->fx_media_driver_info != instance)
{
/* None of FileX Media Control Blocks matched to this USBX Host Mass Storage Instance. */
p_storage_media_local++;
}
else
{
/* Found a FileX Media Control Block used for this USBX Host Mass Storage Instance. */
break;
}
}
if (UX_HOST_CLASS_STORAGE_MAX_MEDIA == index)
{
error = UX_HOST_CLASS_INSTANCE_UNKNOWN;
}
else
{
*p_storage_media = p_storage_media_local;
*p_fx_media = p_fx_media_local;
}

 

I think there's some problem with ux_host_stack_class_get because the value for p_host_class->ux_host_class_media is set to -113, and it ends up returning UX_HOST_CLASS_INSTANCE_UNKNOWN.

Any idea about how to solve this?

Regards,

isaenz

  • Hello isaenz,

    did you use a media device with FAT12/16/32 file system in both cases? FileX supports only 12-, 16-, and 32-bit FAT formats.

    Best regards,
    anper
  • In reply to anper:

    Hello ,

    yes, I used the very same device with both applications.

    Regards,
    isaenz.
  • In reply to isaenz:

    Hello isaenz,

    did you replicate all the necessary properties of the FileX and USBX modules to be same as in the USBX Host Class Mass Storage Module Guide - Application Project?

    Could you also check if all the Pins are configured correctly?

    Comparing all the properties one by one could help to find a mistake in configuration (if there is one).

    Best regards,
    anper

  • In reply to anper:

    Hello  

    Yes, I have that same configuration (even priorities and pool sizes). The pin configuration I'd say it's correct because I'm using the same pinconfig file in my two applications (the one that works and the one that doesn't) and I also enable the USB in the same way (our device has one pin that has to be set high).

    I was wondering if it might be something related to having two threads that use FileX: USB and SD Card. Is there any objection with that? That's the only thing I can think about....

    Or maybe I have to declare some variables as static, just in case other threads are affecting? 

    Regards,

    isaenz.

  • In reply to isaenz:

    Hello isaenz,

    as far as I know there should not be any problem with FileX being used for USB Mass Storage and for Block Media simultaneously.

    It may be worth checking if any other thread does not take too much processor time causing USB thread not working properly. Please look in the "RTOS Resources" view to see if there is any thread that stands out amongst others by having significantly higher number of run counts ("RunCount" column).
    menu bar > Renesas Views > Partner OS > RTOS Resources > Thread tab

    In the USBX Host Class Mass Storage Module Guide Application Project there is Priority 16 set in the properties of the USB Thread. If you use the same value in your project, please try increasing this priority (setting smaller number, e.g. 3). Try also setting a lower priority (bigger number) for other threads.

    Finaly, you could try remove your additional threads from the project, one by one, and see if at some stage the USB Mass Storage start to work properly. This would give you a clue which thread is causing the USB problem.

    Best regards,
    anper

  • In reply to anper:

    Hello  

    I'm not sure I'm using the RTOS Resources right. I've placed a breakpoint after the ux_system_host_storage_fx_media_get function in case something goes wrong (__BKPT(0) if the result is not UX_SUCCESS) and the code stops there. But I don't see anything in the RTOS Resources:

    Regards,

    isaenz.

  • In reply to isaenz:

    Hello isaenz,

    the "RTOS Resources" View > Thread tab should look like that (in case of two threads):

    Usually the "RTOS Resources" View becomes populated with data after the application is suspended two times (by a breakpoint or simply by pressing the Suspend button in the Toolbar).

    There are following issues described in:
    e2 studio 5.3.1.002 Release Notes > 4.20 RTOS Resources view occasionally not displaying data
    e2 studio 5.4.0.023 Release Notes > 5.18 Enabling BSD sockets in ThreadX source corrupts data in RTOS Resources view and Debug view
    which may cause the "RTOS Resources" View to work incorrectly. Does any of them apply in your case?

    Best regards,
    anper

  • In reply to anper:

    Hello  

    I'm using 5.3.1.002 version of the e2studio, so I've tried your suggestions and the RTOS Resources does not show the data, and this is the result:

    I don't know if I understand completely these results:

    - the gx[10] and the ux[8] (which relate to FrwHmi thread[3] and FrwUSB thread[4]) are the threads that have the highest run counts.

    I've run also the USB application on its own, and these are the results:

    The runCounts is similar to the complete case.

     

    I've tried to assign a lower priority to the guix thread, but the result remains quite the same.

    Any idea?

     

    Regards,

    isaenz.

  • In reply to isaenz:

    Hi isaenz,

    As Anper suggested before, could you disable auto start of other threads and enable them one by one to see when this issue appears again? This will help us to narrow possible reasons.

    Regards,
    adboc