Giter Site home page Giter Site logo

eclipse-threadx / usbx Goto Github PK

View Code? Open in Web Editor NEW
149.0 149.0 88.0 7.65 MB

Eclipse ThreadX - USBX is a high-performance USB host, device, and on-the-go (OTG) embedded stack, that is fully integrated with Eclipse ThreadX RTOS

Home Page: https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/usbx/index.md

License: MIT License

CMake 0.57% C 99.40% Shell 0.03%
eclipse-threadx embedded iot mcu microcontroller rtos usb usb-hid usb-host

usbx's People

Contributors

ayedm1 avatar bo-ms avatar ericwolz avatar goldscott avatar liydu avatar philmea avatar pprovost avatar tiejunms avatar wickste avatar xiaocq2001 avatar yuxin-azrtos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

usbx's Issues

USB cannot send data after sending some data

I ported threadX and USBX on stm32f105rbt6. When I try to send some data through IN breakpoint, I can no longer send data but can accept data. The error of sending data is ux_device_class_hid_event_array_tail. Why is this?

USBX Host : Multiple CDC device instances

Hello,

Is it possible to connect more than one CDC device to USBX host stack? Or two independent USB CDC devices or a single device with two CDC interfaces. First one is detected correctly, but not sure how to implement the second interface that has been enumerated and properly configured.

Multi storage media creation

In the ux_host_class_storage_device_initialize.c file, after defining the UX_HOST_CLASS_STORAGE_NO_FILEX macro, when creating storage_media, traversing ux_host_class_media will create multiple storage_media!,
which should break at line 209.

#if defined(UX_HOST_CLASS_STORAGE_NO_FILEX)

        /* Find a free media slot for inserted media.  */
        storage_media =  (UX_HOST_CLASS_STORAGE_MEDIA *) class_inst -> ux_host_class_media;
        for (inst_index = 0; inst_index < UX_HOST_CLASS_STORAGE_MAX_MEDIA;
            storage_media ++, inst_index++)
        {

            /* Skip used storage media slots.  */
            if (storage_media -> ux_host_class_storage_media_storage != UX_NULL)
                continue;

            /* Use this free storage media slot.  */
            storage_media -> ux_host_class_storage_media_storage = storage;

            /* Save media information.  */
            storage_media -> ux_host_class_storage_media_lun = (UCHAR)storage -> ux_host_class_storage_lun;
            storage_media -> ux_host_class_storage_media_sector_size = (USHORT)storage -> ux_host_class_storage_sector_size;
            storage_media -> ux_host_class_storage_media_number_sectors = storage -> ux_host_class_storage_last_sector_number + 1;

            /* Invoke callback for media insertion.  */
            if (_ux_system_host -> ux_system_host_change_function != UX_NULL)
            {

                /* Call system change function.  */
                _ux_system_host ->  ux_system_host_change_function(UX_STORAGE_MEDIA_INSERTION,
                                    storage -> ux_host_class_storage_class, (VOID *) storage_media);
            }
        }
#endif

Are CDRW drives supported for writing/reading files?

I've noticed various places in the code that say CDRW drives aren't supported but I've also seen in the same code actions being taken if the current device is a CDRW. Confusing to say the least.

If they aren't supported, what actions specifically would need to be taken to support them?

I'm assuming that I can potentially write and read raw sectors onto a CDRW right now with USBX? Is that correct? However, because of the formatting, FileX doesn't support actually reading or writing files. If so, then I would think all that I would have to do is write or find a filesystem library that supports the common CDRW formats like UDF 2.01. Is that correct?

Is it possible to cancel the CDC notification endpoint?

Hello,
I try to use ThreadX+USBX in my project. My USB needs CDC and HID, but my MCU only has 4 endpoints (including EP0), so there are only 3 endpoints available for me to use. CDC occupies 3 endpoints, which makes the endpoints not enough to be used. I tried to block the notification endpoint of CDC and assign it to HID. It is possible to run ThreadX+USBX (CDC+HID) alone, but when I add other components The system will crash. I tried ThreadX+USBX (HID only) to add other components and it works normally. The problem lies in the CDC. How can I solve it?

USBX 6.1.4

Hello,

In order to get USB devices working with release 6.1.3 for i.MXRT1060, I have to build USBX library with UX_HCD_EHCI_SPLIT_TRANSFER_ENABLE

If I use UX_HCD_EHCI_SPLIT_TRANSFER_ENABLE, 6.1.4 fails building the USBX lib.

Error[Pe136]: struct "UX_EHCI_ED_STRUCT" (declared at line 370 \usbx\common\usbx_host_controllers\src\ux_hcd_ehci_least_traffic_list_get.c 135
ux_hcd_ehci.h") has no field "ux_ehci_ed_microframe_ssplit_count"

There are 12 error (same issue)

stm32 控制器中断服务函数中使用了 _ux_utility_memory_allocate 是否有内存隐患?

stm32H7做 host 接了一个鼠标通过栈回溯了一次中断事件

-- OTG_FS_IRQHandler
   -> usbx\common\usbx_stm32_host_controllers\ux_hcd_stm32_interrupt_handler.c:81 (_ux_hcd_stm32_interrupt_handler)
      -> stm32h7xx_hal_hcd.c:579 (HAL_HCD_IRQHandler)
         -> stm32h7xx_hal_hcd.c:1238 (HCD_HC_IN_IRQHandler)
             -> usbx\common\usbx_stm32_host_controllers\ux_hcd_stm32_callback.c:304 (HAL_HCD_HC_NotifyURBChange_Callback)
                -> usbx\common\usbx_host_classes\src\ux_host_class_hid_transfer_request_completed.c:263
                   -> usbx\common\core\src\ux_host_stack_transfer_request.c:208
                      -> usbx\common\usbx_host_classes\src\ux_host_class_hid_transfer_request_completed.c:173
                         -> usbx\common\core\src\ux_utility_memory_allocate.c:199
                            -> \usbx\common\core\src\ux_utility_mutex_on.c:79
VOID  *_ux_utility_memory_allocate(ULONG memory_alignment, ULONG memory_cache_flag,
                                   ULONG memory_size_requested)
{

UX_MEMORY_BLOCK     *memory_block;
UX_MEMORY_BLOCK     *new_memory_block;
UX_MEMORY_BLOCK     *leftover_memory_block;
ULONG               memory_for_alignment;
ULONG               memory_removed_from_pool;
ULONG               leftover;
UCHAR               *memory_buffer;
ALIGN_TYPE          int_memory_buffer;


    /* Get the mutex as this is a critical section.  */
    _ux_utility_mutex_on(&_ux_system -> ux_system_mutex);

_txe_mutex_get中:

.......................

    /* Determine if everything is okay.  */
    if (status == TX_SUCCESS)
    {

        /* Check for interrupt call.  */
        if (TX_THREAD_GET_SYSTEM_STATE() != ((ULONG) 0))
        {
    
            /* Now, make sure the call is from an interrupt and not initialization.  */
            if (TX_THREAD_GET_SYSTEM_STATE() < TX_INITIALIZE_IN_PROGRESS)
            {
        
                /* Yes, invalid caller of this function, return appropriate error code.  */
                status =  TX_CALLER_ERROR;
            }
        }
    }

    /* Determine if everything is okay.  */
    if (status == TX_SUCCESS)
    {

        /* Call actual get mutex function.  */
        status =  _tx_mutex_get(mutex_ptr, wait_option);
    }

    /* Return completion status.  */
    return(status);

可以看到在中断中触发了一次 ux_utility_memory_allocate,这个 mutex由于是在中断中, 所以必然会返回 TX_CALLER_ERROR,而调用处并没有对于_ux_utility_mutex_on的结果有任何判断,结尾处的 _ux_utility_mutex_off 同样如此,这个做法对于内存而言是否有安全隐患?

How about a callback when new event is received in receiver thread

First of all thank you vey much for adding support for optional OUT endpoint.

The current code structure calls for another thread to poll the ux_device_class_hid_receiver_event_get() function in order to be notified when new events are received data on the OUT endpoint.
How about adding a callback function, which can be part of the UX_DEVICE_CLASS_HID_RECEIVER structure, that will be called when the _ux_device_class_hid_receiver_thread determines that a new event was received. This will eliminate another polling thread and the system will be more event driven as well.

I certainly might have interpreted the new code incorrectly and would appreciate it if there are other ways than a polling thread to get notified of new received events.

USBX HOST HID类导致内存踩踏风险

USBX HID 设备问题现象:

以鼠标举例, 假设第一个插入的鼠标为1号鼠标, 第二个插入的为2号鼠标,2个鼠标都插入后,将2号鼠标拔出,此时1号鼠标也将不能使用。


更严重的影响:发生内存踩踏

2号鼠标被拔出后,它所使用的内存将被释放,此时1号鼠标动作虽然使用api获取的属性值(x/y坐标、按键值、滚轮值)没有改变,当实际原因是1号鼠标的属性值被更新到2号鼠标原先属性值所在的内存中去了。1号鼠标仍在操作原本已经被释放的2号鼠标的内存。


LOG分析:

鼠标插入:

从LOG上可以看出插入一号鼠标后 一号鼠标的 mouse_instance = 0x2116D830 接着插入2号鼠标 mouse_instance = 0x21174140

从下面这2条LOG可以看出 他们所属的hid客户端是同一个,也就是调用ux_host_class_hid_client_register(_ux_system_host_class_hid_client_mouse_name, ux_host_class_hid_mouse_entry)注册鼠标客户端时malloc的一片内存。

鼠标枚举LOG _ux_host_class_hid_mouse_activate

源码:

从这个.c的源码中也能看出,这里 hid_client -> ux_host_class_hid_client_local_instance = (VOID *) mouse_instance;的操作会覆盖原本的这个值, 即使这个鼠标枚举失败了 hid_client -> ux_host_class_hid_client_local_instance也没有恢复操作,1号原本可以使用的对象就直接丢失了。(这里就不分析这个情况了,看代码就能理解了)

    /* Get some memory for both the HID class instance of this client
       and for the callback.  */
    mouse_instance =  (UX_HOST_CLASS_HID_MOUSE *) _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_HOST_CLASS_HID_MOUSE));
    
    if(mouse_instance == UX_NULL)
        return(UX_MEMORY_INSUFFICIENT);

    /* Attach the mouse instance to the client instance.  */
    hid_client -> ux_host_class_hid_client_local_instance =  (VOID *) mouse_instance;
    LOG_D("f{%s} hid_client = 0x%X  mouse_instance = 0x%X", __FUNCTION__, hid_client, mouse_instance);
    
    /* Save the HID instance in the client instance.  */
    mouse_instance -> ux_host_class_hid_mouse_hid =  hid;

LOG:

D/NO_TAG: f{_ux_host_class_hid_mouse_activate} hid_client = 0x21163370  mouse_instance = 0x2116D830
...
...
D/NO_TAG: f{_ux_host_class_hid_mouse_activate} hid_client = 0x21163370  mouse_instance = 0x21174140

2号鼠标拔出:

从LOG中可以很清楚的看到2号鼠标已经被协议栈移除 free hid_client = 0x21163370 instance 0x21174140并且已经释放了0x21174140这个地址的内存。

源码:

    /* Get the HID client pointer.  */
    hid_client =  hid -> ux_host_class_hid_client;

    /* If trace is enabled, insert this event into the trace buffer.  */
    UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_HID_MOUSE_DEACTIVATE, hid, hid_client -> ux_host_class_hid_client_local_instance, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
    
    /* Now free the instance memory.  */
    LOG_D("f{%s} free hid_client = 0x%X  instance 0x%X", __FUNCTION__, hid_client, hid_client->ux_host_class_hid_client_local_instance);
    _ux_utility_memory_free(hid_client -> ux_host_class_hid_client_local_instance);

LOG:

I/NO_TAG: port2: ohci_register_port_status = 0x100
I/NO_TAG: f{_ux_host_stack_rh_change_process} line 119
I/NO_TAG: f{_ux_host_stack_rh_change_process} line 172
D/NO_TAG: f{_ux_host_stack_device_remove} device = 0x2115E408
D/NO_TAG: f{_ux_host_stack_device_remove} class_instance = 0x21171E20
D/NO_TAG: f{_ux_host_class_hid_mouse_deactivate} free hid_client = 0x21163370  instance 0x21174140
W/app_usbx_host: ux_host_event_callback event 0x4  Current_class = 0x2115DFE0  Current_instance = 0x21163370
W/app_usbx_host: HID Client Unplugged
W/app_usbx_host: ux_host_event_callback event 0x2  Current_class = 0x2115DFE0  Current_instance = 0x21171E20
I/app_usbx_host: mouse = 0x2116D830
I/app_usbx_host: Check the HID_client if this is a HID mouse device.
W/app_usbx_host: USB Device Removal
D/NO_TAG: f{_ux_host_stack_device_remove} class_instance = 0x211747B0
D/mouse: Pos_x = 11 Pos_y= 0
W/app_usbx_host: ux_host_event_callback event 0x2  Current_class = 0x2115DFE0  Current_instance = 0x211747B0
W/app_usbx_host: ux_host_event_callback event 0x82  Current_class = 0x0  Current_instance = 0x2115E408

2号鼠标拔出后移动1号鼠标:

从下面日志可以看到 mouse_instance = 0x21174140这个地址正是已经被释放了的2号鼠标所拥有的 0x21174140 而不是1号本身的 0x2116D830
源码中野可以看到,他下面直接对这个地址里的属性值做了修改,此时就发生了内存踩踏

源码:

VOID  _ux_host_class_hid_mouse_callback(UX_HOST_CLASS_HID_REPORT_CALLBACK* callback)
{

UX_HOST_CLASS_HID_CLIENT    *hid_client;
UX_HOST_CLASS_HID_MOUSE     *mouse_instance;

    /* Get the HID client instance that issued the callback.  */
    hid_client =  callback -> ux_host_class_hid_report_callback_client;
    
    /* Get the mouse local instance */
    mouse_instance =  (UX_HOST_CLASS_HID_MOUSE *) hid_client -> ux_host_class_hid_client_local_instance;
    
    LOG_D("f{%s}, mouse_instance  0x%X  usage 0x%X  value 0x%X", __FUNCTION__, mouse_instance, callback->ux_host_class_hid_report_callback_usage,
        callback->ux_host_class_hid_report_callback_value);
    /* Analyze the usage we have received.  */
    switch (callback -> ux_host_class_hid_report_callback_usage)
    {


        /* X/Y Axis movement.  */
        case    UX_HOST_CLASS_HID_MOUSE_AXIS_X      :
    
            /* Add the deplacement to the position.  */
            mouse_instance -> ux_host_class_hid_mouse_x_position += (SCHAR) callback -> ux_host_class_hid_report_callback_value;
    
            break;

LOG:

D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90002  value 0x1
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10030  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0xC0238  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90002  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10030  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0xC0238  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90002  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10030  value 0x1
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0xC0238  value 0x0

hid客户端注册 ux_host_class_hid_client_register

    /* From the class container, we get the client pointer which has the list of
       HID clients. If the pointer is NULL, the client list was not assigned.  */
    if (class -> ux_host_class_client == UX_NULL)
    {

        /* Allocate memory for the class client.
         * Allocate size overflow static checked outside the function.
         */
        class -> ux_host_class_client =  _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY,
                                            sizeof(UX_HOST_CLASS_HID_CLIENT)*UX_HOST_CLASS_HID_MAX_CLIENTS);
    
        /* Check for successful allocation.  */
        if (class -> ux_host_class_client == UX_NULL)
            return(UX_MEMORY_INSUFFICIENT);
    }

完整日志:

W/app_usbx_host: hid_client addr 0x211633C8
I/app_usbx_host: keyboard = 0x21169C70
I/app_usbx_host: Check the HID_client if this is a HID keyboard device.
D/app_usbx_host: HID_Keyboard_Device
D/app_usbx_host: PID: 0xc53f
D/app_usbx_host: VID: 0x46d
D/app_usbx_host: USB HID Host Keyboard App...
D/app_usbx_host: keyboard is ready...

D/NO_TAG: f{_ux_host_class_hid_client_search} item_global_usage_page  = 0x1   item_local_usage = 0x2
I/NO_TAG: f{_ux_host_class_hid_client_search} status = 0x0
I/NO_TAG: f{_ux_host_class_hid_client_search} activate ux_host_class_hid_client_mouse
D/NO_TAG: f{_ux_host_class_hid_mouse_activate} hid_client = 0x21163370  mouse_instance = 0x2116D830
I/NO_TAG: f{_ux_host_class_hid_mouse_activate} line 168  mouse_callback = 0x802A3DD8
W/app_usbx_host: ux_host_event_callback event 0x3  Current_class = 0x2115DFE0  Current_instance = 0x21163370
W/app_usbx_host: HID Client Plugged
W/app_usbx_host: ux_host_event_callback event 0x1  Current_class = 0x2115DFE0  Current_instance = 0x2116B540
W/app_usbx_host: hid_client addr 0x21163370
I/app_usbx_host: mouse = 0x2116D830
I/app_usbx_host: Check the HID_client if this is a HID mouse device.
D/app_usbx_host: HID_Mouse_Device
D/app_usbx_host: PID: 0xc53f
D/app_usbx_host: VID: 0x46d
D/app_usbx_host: USB HID Host Mouse App...
D/app_usbx_host: Mouse is ready...

D/NO_TAG: f{_ux_host_class_hid_client_search} item_global_usage_page  = 0xFF00   item_local_usage = 0x1
I/NO_TAG: f{_ux_host_class_hid_client_search} status = 0x57
I/NO_TAG: f{_ux_host_class_hid_client_search} status = 0x57
E/app_usbx_host: ux_host_error_callback  level 2,  context 7,  error_code 0x7B
W/app_usbx_host: ux_host_event_callback event 0x1  Current_class = 0x2115DFE0  Current_instance = 0x2116E540
W/app_usbx_host: hid_client addr 0x0
W/NO_TAG: _ux_host_stack_new_device_create [288]: status = 0
W/NO_TAG: _ux_host_stack_new_device_create 295 status = 0
W/app_usbx_host: ux_host_event_callback event 0x81  Current_class = 0x0  Current_instance = 0x2115E150
I/NO_TAG: port_index 2  ux_hcd_root_hub_signal 0

D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90002  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x10030  value 0x1
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0xC0238  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90002  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x10030  value 0x9
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x2116D830  usage 0xC0238  value 0x0
D/mouse: Pos_x = 11 Pos_y= 0

I/NO_TAG: port_index 0  ux_hcd_root_hub_signal 0
I/NO_TAG: port_index 1  ux_hcd_root_hub_signal 0
I/NO_TAG: port_index 2  ux_hcd_root_hub_signal 2
I/NO_TAG: port2: ohci_register_port_status = 0x101
I/NO_TAG: f{_ux_host_stack_rh_change_process} line 119
I/NO_TAG: f{_ux_host_stack_rh_change_process} line 128
I/NO_TAG: f{_ux_host_stack_rh_change_process} line 133
I/NO_TAG: ohci_port_enable  2
I/NO_TAG: port2: ohci_register_port_status = 0x103
D/NO_TAG: f{_ux_host_stack_new_device_create} new device = 0x2115E408

W/NO_TAG: Get the configuration descriptor
D/NO_TAG: vid = 0x46D  pid = 0xC084  class = 0x0 subclass = 0x0
W/NO_TAG: _ux_host_stack_new_device_create [282]: status = 57
D/NO_TAG: f{_ux_host_class_hid_client_search} item_global_usage_page  = 0x1   item_local_usage = 0x2
I/NO_TAG: f{_ux_host_class_hid_client_search} status = 0x0
I/NO_TAG: f{_ux_host_class_hid_client_search} activate ux_host_class_hid_client_mouse
D/NO_TAG: f{_ux_host_class_hid_mouse_activate} hid_client = 0x21163370  mouse_instance = 0x21174140
I/NO_TAG: f{_ux_host_class_hid_mouse_activate} line 168  mouse_callback = 0x802A3DD8
W/app_usbx_host: ux_host_event_callback event 0x3  Current_class = 0x2115DFE0  Current_instance = 0x21163370
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90002  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10030  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0xC0238  value 0x0
W/app_usbx_host: HID Client Plugged
W/app_usbx_host: ux_host_event_callback event 0x1  Current_class = 0x2115DFE0  Current_instance = 0x21171E20
W/app_usbx_host: hid_client addr 0x21163370
I/app_usbx_host: mouse = 0x21174140
I/app_usbx_host: Check the HID_client if this is a HID mouse device.
D/app_usbx_host: HID_Mouse_Device
D/app_usbx_host: PID: 0xc084
D/app_usbx_host: VID: 0x46d
D/app_usbx_host: USB HID Host Mouse App...
D/app_usbx_host: Mouse is ready...

D/mouse: Pos_x = 0 Pos_y= 0
D/NO_TAG: f{_ux_host_class_hid_client_search} item_global_usage_page  = 0x1   item_local_usage = 0x6
I/NO_TAG: f{_ux_host_class_hid_client_search} status = 0x57
I/NO_TAG: f{_ux_host_class_hid_client_search} status = 0x0
I/NO_TAG: f{_ux_host_class_hid_client_search} activate ux_host_class_hid_client_keyboard
I/NO_TAG: f{_ux_host_class_hid_keyboard_activate} hid = 0x211747B0
I/NO_TAG: f{_ux_host_class_hid_keyboard_activate} activate ux_host_class_hid_client_keyboard
I/NO_TAG: f{_ux_host_class_hid_keyboard_activate} hid_client = 0x211633C8   keyboard_instance = 0x21177CB0
W/app_usbx_host: ux_host_event_callback event 0x1  Current_class = 0x2115DFE0  Current_instance = 0x211747B0
W/app_usbx_host: hid_client addr 0x0
W/NO_TAG: _ux_host_stack_new_device_create [288]: status = 0
W/NO_TAG: _ux_host_stack_new_device_create 295 status = 0
W/app_usbx_host: ux_host_event_callback event 0x81  Current_class = 0x0  Current_instance = 0x2115E408
I/NO_TAG: port_index 0  ux_hcd_root_hub_signal 0
I/NO_TAG: port_index 1  ux_hcd_root_hub_signal 0
I/NO_TAG: port_index 2  ux_hcd_root_hub_signal 1
I/NO_TAG: port2: ohci_register_port_status = 0x103
I/NO_TAG: f{_ux_host_stack_rh_change_process} line 119
I/NO_TAG: f{_ux_host_stack_rh_change_process} line 128

D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90002  value 0x1
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10030  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0xC0238  value 0x0
D/mouse: Right Button Pressed
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90002  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10030  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0xC0238  value 0x0

I/NO_TAG: port_index 0  ux_hcd_root_hub_signal 0
I/NO_TAG: port_index 1  ux_hcd_root_hub_signal 0
I/NO_TAG: port_index 2  ux_hcd_root_hub_signal 1
I/NO_TAG: port2: ohci_register_port_status = 0x100
I/NO_TAG: f{_ux_host_stack_rh_change_process} line 119
I/NO_TAG: f{_ux_host_stack_rh_change_process} line 172
D/NO_TAG: f{_ux_host_stack_device_remove} device = 0x2115E408
D/NO_TAG: f{_ux_host_stack_device_remove} class_instance = 0x21171E20
D/NO_TAG: f{_ux_host_class_hid_mouse_deactivate} free hid_client = 0x21163370  instance 0x21174140
W/app_usbx_host: ux_host_event_callback event 0x4  Current_class = 0x2115DFE0  Current_instance = 0x21163370
W/app_usbx_host: HID Client Unplugged
W/app_usbx_host: ux_host_event_callback event 0x2  Current_class = 0x2115DFE0  Current_instance = 0x21171E20
I/app_usbx_host: mouse = 0x2116D830
I/app_usbx_host: Check the HID_client if this is a HID mouse device.
W/app_usbx_host: USB Device Removal
D/NO_TAG: f{_ux_host_stack_device_remove} class_instance = 0x211747B0
D/mouse: Pos_x = 11 Pos_y= 0
W/app_usbx_host: ux_host_event_callback event 0x2  Current_class = 0x2115DFE0  Current_instance = 0x211747B0
W/app_usbx_host: ux_host_event_callback event 0x82  Current_class = 0x0  Current_instance = 0x2115E408

D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90002  value 0x1
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10030  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0xC0238  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90002  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10030  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0xC0238  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90001  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90002  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90003  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90004  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90005  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90006  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90007  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90008  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90009  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000A  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000B  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000C  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000D  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000E  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x9000F  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x90010  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10030  value 0x1
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10031  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0x10038  value 0x0
D/NO_TAG: f{_ux_host_class_hid_mouse_callback}, mouse_instance  0x21174140  usage 0xC0238  value 0x0


HID IN data transmission frequency is only about 10 times per second

I used ThreadX and USBX STM32 in the project as USB HID devices to connect to the computer. My program collects sensor data every millisecond and calls the ux_device_class_hid_event_set() function to send to the host computer, but the host computer can only receive about 10 per second The data, why is there such a situation, ux_device_class_hid_event_set is also set to 1ms in the endpoint descriptor

About cdc-acm support in standalone mode

Hi there, I'm new to usbx and recently noticed that usbx added standalone mode support in the latest v6.1.10_rel release, so I wrote some codes to initialize standalone usbx device stack as cdc-acm class.

But when I tried to build the firmware, the compiler warned undefined references to _ux_device_class_cdc_acm_read and _ux_device_class_cdc_acm_write functions.

Then I saw the implementation of these two function were all isolated by UX_DEVICE_STANDALONE and UX_DEVICE_STANDALONE macros.

My question is, are these functions deprecated in standalone mode, or just are lacked with support temporarily ?
If these two functions can't be used for now, is there something instead?

And where can I go for further details like these problems, I will be glad to have a migration guide.

Great thanks for your help

Example of device MSD+CDC

I have an embedded device that I currently run a USB slave MSD on to access the internal filesystem. I would also like to have a serial communication so that I can use teraterm to talk and see output from this device on that same port. I know USBX supports both of these functionalities (I've tried both and they work), but I'm not skilled enough to develop a composite descriptor for this use case as it gets complicated when you have multiple interfaces with IADs (I think mixed in). It also seems that USBX only supports one device "port" at once, so I cannot just use two USB ports for this function.

Is there any way someone could show what a composite descriptor would look like for a USB device that has MSD and CDC? And if possible how this can be initialized on the USBx stack side?

Recommendations for reducing USBx host stack size.

Hi,
I downloaded sample code from : https://github.com/azure-rtos/samples for STM32.
In this one “sample_usbx_host_mass_storage” uses stack memory of 64KB:

#define USBX_MEMORY_SIZE            (64 * 1024)
ux_system_initialize(memory_pointer, USBX_MEMORY_SIZE, UX_NULL, 0);

I tried to test this with our hardware and I was able to get this working with 48KB.
But any reduction is stack memory below that generates “UX_MEMORY_INSUFFICIENT” error.

USBx documentation mentions this < https://docs.microsoft.com/en-us/azure/rtos/usbx/usbx-host-stack-2 >

Target Considerations

USBX requires between 24 KBytes and 64 KBytes of Read Only Memory (ROM) on the target in host mode. The amount of memory required is dependent on the type of controller used and the USB classes linked to USBX. Another 32 KBytes of the target's Random Access Memory (RAM) are required for USBX global data structures and memory pool. This memory pool can also be adjusted depending on the expected number of devices on the USB and the type of USB controller. The USBX device side requires roughly 10-12 K of ROM depending on the type of device controller. The RAM memory usage depends on the type of class emulated by the device.

I tried to test this with our hardware and I was able to get this working with minimum stack of 48KB.
But any reduction is stack memory below that generates “UX_MEMORY_INSUFFICIENT” error.

We only want to connect one USB device to a host at a time. And I understand that I can adjust parameters in "ux_port.h" to improve this code size. ( Though I had not much success ).

My Questions :

Q 1: Is there any list of steps/options/recommendation/link time define switch to try to reduce stack size of USBx ?

Q2: And is 32KB minimum stack required for USBx mode and is it possible to go below that ? if we only want to connect one device to a host let say mass storage device.

Regards,
Parth

usbx_device_controllers

Hello, may I have the usbx_host_controllers source code in the usbx\common folder, but there is no usbx_device_controllers file. Why?

HID IN data transmission frequency is only about 10 times per second

I used ThreadX and USBX STM32 in the project as USB HID devices to connect to the computer. My program collects sensor data every millisecond and calls the ux_device_class_hid_event_set() function to send to the host computer, but the host computer can only receive about 10 per second The data, why is there such a situation, ux_device_class_hid_event_set is also set to 1ms in the endpoint descriptor

USBX Are there plans to support 64-bit compilers?

As you can see, if you use a 64-bit compiler, the compiled structure address offset will be inconsistent with the OHCI specification, and it will require 8 DWords


/* Define OHCI ED structure.  */

typedef struct UX_OHCI_ED_STRUCT
{

    ULONG           ux_ohci_ed_dw0;
    struct UX_OHCI_TD_STRUCT               
                    *ux_ohci_ed_tail_td;
    struct UX_OHCI_TD_STRUCT               
                    *ux_ohci_ed_head_td;
    struct UX_OHCI_ED_STRUCT               
                    *ux_ohci_ed_next_ed;
    struct UX_OHCI_ED_STRUCT               
                    *ux_ohci_ed_previous_ed;
    ULONG           ux_ohci_ed_status;
    struct UX_ENDPOINT_STRUCT          
                    *ux_ohci_ed_endpoint;
    ULONG           ux_ohci_ed_frame;
} UX_OHCI_ED;


/* Define OHCI TD structure.  */

typedef struct UX_OHCI_TD_STRUCT
{                                                
    ULONG           ux_ohci_td_dw0;
    UCHAR *         ux_ohci_td_cbp;
    struct UX_OHCI_TD_STRUCT              
                    *ux_ohci_td_next_td;
    UCHAR *         ux_ohci_td_be;
    ULONG           ux_ohci_td_reserved_1[4];
    struct UX_TRANSFER_STRUCT          
                    *ux_ohci_td_transfer_request;
    struct UX_OHCI_TD_STRUCT              
                    *ux_ohci_td_next_td_transfer_request;
    struct UX_OHCI_ED_STRUCT              
                    *ux_ohci_td_ed;
    ULONG           ux_ohci_td_length;
    ULONG           ux_ohci_td_status;
    ULONG           ux_ohci_td_reserved_2[3];
} UX_OHCI_TD;

image

image

Provide sample code for video host class

Hi,
Can you please provide sample code for USB video host class , if possible ?
I can see there are good examples on RTOS/samples , but they do not include example for video class.

duplicate line in : usbx/common/core/src/ux_host_stack_class_device_scan.c

It might not be big issue but there is duplicate line in : usbx/common/core/src/ux_host_stack_class_device_scan.c

    /* Perform the command initialization.  */
    class_command.ux_host_class_command_request      =   UX_HOST_CLASS_COMMAND_QUERY;
    class_command.ux_host_class_command_container    =   (VOID *) device;
    class_command.ux_host_class_command_vid          =   device -> ux_device_descriptor.idVendor;
    class_command.ux_host_class_command_pid          =   device -> ux_device_descriptor.idProduct;
    class_command.ux_host_class_command_class        =   device -> ux_device_descriptor.bDeviceClass;
    class_command.ux_host_class_command_subclass     =   device -> ux_device_descriptor.bDeviceSubClass;
    class_command.ux_host_class_command_subclass     =   device -> ux_device_descriptor.bDeviceSubClass;
    class_command.ux_host_class_command_protocol     =   device -> ux_device_descriptor.bDeviceProtocol;
    class_command.ux_host_class_command_iad_class    =   0;
    class_command.ux_host_class_command_iad_subclass =   0;
    class_command.ux_host_class_command_iad_protocol =   0;

usbx on renesas rx mcu

Hi,
I am updating usbx from v5.9 to v6.1.6 on a Rx63 mcu. Currently i am using the "USBX host rx Controller" but is it possible to change it to ohci/ehci host controller? Because i can see in your latest release that you does not include rx controller files anymore. I have tried changing it to ehci but it doesn't seem to work.

Azure RTOS USBX audio class 2.0

Hi All,

I’m Currently working on an USBx audio application with an stm32H743i. I have some point for support & enhancement .

I found a mistake when registering audio class in MS website https://docs.microsoft.com/fr-fr/azure/rtos/usbx/usbx-device-stack-supplemental-2#usb-device-audio-class

image

Support.

issue
I can’t enumerate my audio2.0 device.

Enhance
In “ux_device_class_audio20_control_process.c” file it’s possible to set WRES in applicative side by user when host request FU_VOLUME_CONTROL?

image

For feature unit control selectors macros in “ux_device_class_audio20.h” it is possible to change it like Audio device Class Specification.

For Example change UX_DEVICE_CLASS_AUDIO20_FU_MUTE_CONTROL 0x01 to 0x03

image

Screenshot from audio20 spec sheet 59

image

Regards,
Mohamed

HID IN data transmission frequency is only about 10 times per second

I used ThreadX and USBX STM32 in the project as USB HID devices to connect to the computer. My program collects sensor data every millisecond and calls the ux_device_class_hid_event_set() function to send to the host computer, but the host computer can only receive about 10 per second The data, why is there such a situation, ux_device_class_hid_event_set is also set to 1ms in the endpoint descriptor

USB hub issues with MXRT1064EVK

Both the NXP SDK and USBX have issues with many USB hubs on the MXRT platform. After lots of investigation, I was able to at least somewhat get the NXP SDK examples to consistently enumerate and communicate with all devices on a hub by increasing the hub port reset delay. However, the NXP USB drivers tend to have other issues that makes me not want to use them compared to USBX.

I've tested USBX with USB hubs to connect a mouse and keyboard to a single port without luck so far. USBX always enumerates the hub but fails to enumerate any devices on the hub. I get a USBX error callback due to a transaction not getting a response that is triggered by the stack trying to set an address of a device on the hub after that device's port has been reset.

I am unfortunately unable to provide much more information than this as I do not have access to a USB protocol analyzer at the moment.

USB HID class : Composite device does not pass compliance tests.

Hi,
I made a composite device that include multiple HID devices.
It is recognized by Windows and works. However it does not pass HID Tests with the USB2CV test tool.

  • HID Class Descriptor Test
  • HID Class GET/SET Idle Test
  • HID Class Report Descriptor Test

The tests uses GET_DESCRIPTOR with wIndex parameter to get HID descriptors.
However current code does not use the parameter, therefore it does not return a HID descriptor except the first one.

I think that It should support request_index parameter as follows:

ux_device_class_hid_descriptor_send.c.patch.txt

UVC

Is it possible with the help of this stack to implement interaction with Webcamera through UVC ? If so, how?

Multiple transaction in single microframe for interrupt endpoints

Hi,

I am using STM32 mass storage HOST example from : https://github.com/azure-rtos/sample

I was going through code ( in STM32 mass storage HOST example ) and in :
UINT _ux_hcd_stm32_td_schedule(UX_HCD_STM32 *hcd_stm32, UX_HCD_STM32_ED *ed)

I seen this line :
number_packets = (td -> ux_stm32_td_length + endpoint -> ux_endpoint_descriptor.wMaxPacketSize - 1) / endpoint -> ux_endpoint_descriptor.wMaxPacketSize;

Now if you see carefully then this line will always return 1 irrespective of ux_endpoint_descriptor.wMaxPacketSize.

In my opinion it should be :

max_packet_size  = endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_PACKET_SIZE_MASK;
number_packets =  (td -> ux_stm32_td_length + max_packet_size - 1) / max_packet_size;

Not sure fully , but let me know your thoughts on this.
Also I wanted to know does USBx code supports multiple transaction in single microframe for interrupt endpoints ?

and also multiple transaction in single microframe for isochronous endpoints ? I simply tried to search "UX_HCD_STM32_OTG_FS_HCTSIZ_DPID_MDATA" but was not able to find it ?

Update usbx/common/usbx_host_classes/inc/ux_host_class_video.h as per latest UVC 1.5 specification.

Hi,

It seems header file for video host class is not matching UVC 1.5 specification < https://www.usb.org/document-library/video-class-v15-document-set >.
for example ux_host_class_video.h mentions:

/* Define Video Class specific VS . */

#define UX_HOST_CLASS_VIDEO_VS_UNDEFINED                                                    0x00
#define UX_HOST_CLASS_VIDEO_VS_INPUT_HEADER                                                 0x01
#define UX_HOST_CLASS_VIDEO_VS_OUTPUT_HEADER                                                0x02
#define UX_HOST_CLASS_VIDEO_VS_STILL_IMAGE_FRAME                                            0x03
#define UX_HOST_CLASS_VIDEO_VS_FORMAT_UNCOMPRESSED                                          0x04
#define UX_HOST_CLASS_VIDEO_VS_FRAME_UNCOMPRESSED                                           0x05
#define UX_HOST_CLASS_VIDEO_VS_FORMAT_MJPEG                                                 0x06
#define UX_HOST_CLASS_VIDEO_VS_FRAME_MJPEG                                                  0x07
#define UX_HOST_CLASS_VIDEO_VS_FORMAT_MPEG2TS                                               0x0A
#define UX_HOST_CLASS_VIDEO_VS_FORMAT_DV                                                    0x0C
#define UX_HOST_CLASS_VIDEO_VS_COLORFORMAT                                                  0x0D
#define UX_HOST_CLASS_VIDEO_VS_FORMAT_FRAME_BASED                                           0x10
#define UX_HOST_CLASS_VIDEO_VS_FRAME_FRAME_BASED                                            0x11
#define UX_HOST_CLASS_VIDEO_VS_FORMAT_STREAM_BASED                                          0x12

But there are other subtypes as well on page 172 , UVC 1.5 specification < https://www.usb.org/document-library/video-class-v15-document-set >.
Ideally following should be added :

#define UX_HOST_CLASS_VIDEO_VS_FORMAT_H264                                          0x13
#define UX_HOST_CLASS_VIDEO_VS__FRAME_H264                                          0x14
#define UX_HOST_CLASS_VIDEO_VS_FORMAT_H264_SIMULCAST                                0x15
#define UX_HOST_CLASS_VIDEO_VS_FORMAT_VP8                                          0x16
#define UX_HOST_CLASS_VIDEO_VS_FRAME_VP8                                           0x17
#define UX_HOST_CLASS_VIDEO_VS_FORMAT_VP8_SIMULCAST                                0x18

This is just an example entire file need an update.

is it possible to read device isochronous endpoints using host interrupt endpoints?

We are developing an example where device continuously stream data through an isochronous IN endpoint. Now my question was as interrupt and isochronous have lot of similarities :

  1. Max 1024 packets in USB HS
  2. both are for bandwidth guarantee.
  3. Host can poll device every micro frame.

can I use my host interrupt endpoint to configure is to read from device's isochronous endpoints ?

device isochronous endpoints is following :

===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x05 -> Isochronous Transfer Type, Synchronization Type = Asynchronous, Usage Type = Data Endpoint
wMaxPacketSize: 0x0180 = 1 transactions per microframe, 0x180 max bytes
bInterval: 0x01

I understand there is NACK/ACK token in the interrupt endpoints , but let say if device ignores this NACK/ACK token can I still communicate with device using my interrupt endpoints ?

STM32 F105 cannot use USBX CDC ACM normally

I have successfully ported ThreadX and USBX to STM32F105, and USBX HID can work normally. When I try to use USBX CDC ACM, the problem occurs. There is VCOM virtualized by STM32 in the device manager of windows, but when I try to use this serial port STM32 will freeze and stop running during communication. Why is there such a problem? I do the same operation on STM32 H7 and there is no problem

Differences between STM32F1 and STM32H7 series MCUs using USBX

I have successfully run the ThreadX+USBX program on the STM32H7 chip. The USB composite device (CDC ACM+HID) is used, so I tried to implement the same function on STM32F105RBT6, but I ran into trouble, running USB on F105 The composite device can run normally at the beginning, but after 40s, the USB will be disconnected and reconnected, and the USB will not be recognized. If I use HID or CDC alone, everything works fine . I learned that H7 has 9 endpoints and F1 has only 4 USB endpoints. Will it? Is USB working abnormally because of the number of endpoints?

Does USBX MSC support SPI FLASH?

I have tried to use the SD card as a storage device on the USBX MSC, and then I wrote a program to read the external Nor FLASH through SPI, but when I used the USB MSC with the Nor Flash driver, the problem appeared. On windows Storage devices did not appear as expected. What are the possible reasons for the above phenomenon?

Device storage hot-plugging issue and files not updating in realtime.

Hi!

I have a few issues with USBX's device storage class that I need some help resolving.

First and most importantly:
If I connect my MCU board to my computer via USB to access the device storage filesystem I have set up through filex + usbx everything works fine. However, If I try to unplug the USB and plug it back in, sometimes the device fails to attach to windows properly. The windows error code is code 10 (this device cannot start). I haven't experimented enough to say anymore, but it seems It definitely breaks by around the 4th hotplug. Is there anything specifically I should be doing to support hotplugging the device storage class?

Secondly:
Even if I flush my filesystem through filex, I can never see real-time changes in files that the MCU is writing to. (even if I also close those files and flush in between writes). However, rebooting my board or replugging in the USB will make the files update. I would be perfectly fine with the last solution, however, the first problem regarding hotplugging is making that solution pretty unusable.

And a third bonus question:
On the custom board I'm working on, we only have one USB port that can act as a OTG device. In this case, we are using that port to access the board's filesystem from a PC using USBX. However, we have been thinking it would be nice to also be able to access serial output through CDC over that USB. But, as far as I can tell, there isn't a way to do that. Is there any way to effectively hub CDC and device storage over the one OTG port?

Extra info:

I'm giving USBX around 128k of uncached memory which I think should be plenty. I'm implementing media status and media flush but they are just returning UX_SUCCESS. Is this a problem? The board I'm working on is a derivative of the 1064 EVK board from NXP.

The rest of my USBX init code I'll paste below.

		UINT status =
			_ux_device_stack_initialize(usbfs_device_framework_high_speed, sizeof(usbfs_device_framework_high_speed), usbfs_device_framework_full_speed, sizeof(usbfs_device_framework_full_speed),
										usbfs_string_framework, sizeof(usbfs_string_framework), usbfs_language_id_framework, sizeof(usbfs_language_id_framework), nullptr);

		if (status != UX_SUCCESS)
			return false;

		/* Store the number of LUN in this device storage instance. */
		usbfs_storage_parameter.ux_slave_class_storage_parameter_number_lun = 1;

		/* Initialize the storage class parameters for reading/writing to the Flash
		 * Disk. */
		usbfs_storage_parameter.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_last_lba = USBFS_LAST_BLOCK_INDEX;
		usbfs_storage_parameter.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_block_length = USBFS_BLOCK_SIZE; // needs to be 512, not sure if this needs to match
																																	  // filessytem
		usbfs_storage_parameter.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_type = 0;
		usbfs_storage_parameter.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_removable_flag = 0x80;
		usbfs_storage_parameter.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_read = usbfs_media_read;
		usbfs_storage_parameter.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_write = usbfs_media_write;
		usbfs_storage_parameter.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_status = usbfs_media_status;
		usbfs_storage_parameter.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_flush = usbfs_media_flush;

		/* Initilize the device storage class. The class is connected with interface
		 * 0 on configuration 1. */
		status = _ux_device_stack_class_register(_ux_system_slave_class_storage_name, _ux_device_class_storage_entry, 1, 0, (VOID *)&usbfs_storage_parameter);

		if (status != UX_SUCCESS)
			return false;

		_ux_dcd_mcimx6_initialize(usb_device_base());

		/* Init the USB interrupt. */
		usb_device_interrupt_setup(USB_DEVICE_INTERRUPT_PRIORITY);

USB host stack sizes need to be large.

Hi,

It seems the default stack size for UsbX in the gnu port file is too small for even my basic application of USB mouse and keyboard. I believe it is set to 2048 by default. 8192 seems to do the trick for me. However, I can probably get away with something in the middle.

When the stack size is too small I always get a hard fault in the UX function that searches for a free memory block called by the ux allocate function. This occurs when I plug in a device for a second time. IE: plug in a device, unplug the device, and plug it back in. 100% hardfault using that scenario with the default stack size on USBx v6.1.7. I know it is a stack corruption as the local variables get corrupted and simply upping the stack size fixes the issue. This issues happens nomatter how many devices are used. It happens constantly with just a basic mouse after the second plug in.

It's not really a bug, but it seems something has changed recently, from the older versions, that are requiring a larger stack size. This is more so a note to others that might run into a similar issue.

I'm on the ARM platform using an MXRT1064

A question about using msc class

Excuse me everybody, i have a question that I don't know which API to use to read and write the MSc class. Is the dpump class used for reading and writing.I don't know yet. thanks

wrong "packet_size" calculation for ISO/INT endpoint

Wrong calculation if wMaxPacketSize has multi transfer per microframe

In file "ux_host_stack_new_endpoint_create.c" line 157

/* Number transaction over 2 additional is not allowed. */ n_tran = endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_NUMBER_OF_TRANSACTIONS_MASK; if (n_tran >= UX_MAX_NUMBER_OF_TRANSACTIONS_MASK) { _ux_utility_memory_free(endpoint); return(UX_DESCRIPTOR_CORRUPTED); }

and at line no 185 which will cause packet_size to be a very large value

packet_size *= (n_tran + 1);

It should be

/* Number transaction over 2 additional is not allowed. */ n_tran = ((endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_NUMBER_OF_TRANSACTIONS_MASK) >> UX_MAX_NUMBER_OF_TRANSACTIONS_SHIFT); if (n_tran > 2) { _ux_utility_memory_free(endpoint); return(UX_DESCRIPTOR_CORRUPTED); }

_ux_hcd_ohci_asynchronous_endpoint_create 中 ‘head_ed’ 需要用虚拟地址去访问 ux_ohci_ed_previous_ed

head_ed =  (UX_OHCI_ED *) _ux_hcd_ohci_register_read(hcd_ohci, OHCI_HC_BULK_HEAD_ED);

    if (head_ed != UX_NULL)
        head_ed -> ux_ohci_ed_previous_ed =  ed;

head_ed 被直接从寄存器中读出的是物理地址,如果地址不是 1 : 1 映射关系,这个操作将会错误访问地址

修改为:

  if (head_ed != UX_NULL)
    {
        head_ed = _ux_utility_virtual_address(head_ed);
        head_ed->ux_ohci_ed_previous_ed = ed;
    }

OHCI controller for full speed usb host

Hello,
I'm trying to get the example available running at full speed instead of high-speed. The example is the usbx_host_hid_keyboard for the LPC5528.
The keyboard enumerates correctly, but it doesn't respond to any key inputs. The only changes I saw were necessary in board_setup.c/.h which sets up the appropriate USB0, clocks, and interrupts.

I added the ohci drivers in the project. However when calling _ux_host_class_hid_keyboard_key_get, I do not get any information.

Are there any other changes required for full-speed to work?

I'd like to add that these changes are fine, for host_mass_storage example. I can switch between high speed and full speed without a problem.

Various ux_host_class_xxx.h files missing extern "C"

Atleast a few of these host class files like ux_host_class_hub.h, host_class_hid.h, host_class_hid_mouse.h, keyboard.h, etc... are all missing the standard #ifdef __cplusplus extern "C".

It's easy enough for me to edit in my project, but it would be nice if USBX played well with C++ out of the box as it mostly does.

_ux_host_class_hid_transfer_request_completed 中的内存浪费

_ux_host_class_hid_transfer_request_completed.c 中处理接收数据时,为什么申请的大小为item的数量而不是实际需要的大小?

对于下面这个设备来说, item的数量是264个, 但实际需要处理的数据只有8个, 在32位上需要的内存也仅只有 (8+6) << 3, 比这里的264<<3,所需要的内存要小很多
image

image

Incorrect trace values

These 2 both have a value of 855.
#define UX_TRACE_DEVICE_STACK_CONFIGURATION_GET (UX_TRACE_DEVICE_STACK_EVENTS_BASE + 5) /* I1 = configuration value /
#define UX_TRACE_DEVICE_STACK_CONFIGURATION_SET (UX_TRACE_DEVICE_STACK_EVENTS_BASE + 5) /
I1 = configuration value */

Within TraceX, 856 shows as Event: ux_trace_device_stack_configuration_set (856). The actual event was UX_TRACE_DEVICE_STACK_CONNECT, so I think UX_TRACE_DEVICE_STACK_CONFIGURATION_SET and below are all off by 1.

Does USBX support multiple device type switching?

The processor used in my project is STM32F105RBT6. I transplanted ThreadX and USBX for development. I want to know if USBX supports multiple device type switching. For example, USB is a normal USB device when it is working normally. When firmware update is required, enter USB DFU mode?

Not getting deactivate callback when USB is removed in usbx_device_mass_storage on IMXRT1060-EVK

Hi,

I have modified usbx_device_mass_storage sdk example for IMXRT060-EVK to include the activate and deactivate callback as shown below:

storage_parameter.ux_slave_class_storage_instance_activate =
    demo_thread_media_activate;
storage_parameter.ux_slave_class_storage_instance_deactivate =
    demo_thread_media_deactivate;

As of now I am just printing inside these callbacks as shown below:
VOID demo_thread_media_activate(VOID *storage)
{
PRINTF("demo_thread_media_activate.....\r\n");
}
VOID demo_thread_media_deactivate(VOID *storage)
{
PRINTF("demo_thread_media_deactivate.....\r\n");
}

I do receive the activate callback when I plug in USB but do not get deactivate callback when plugging out the USB but gets both deactivate and activate callback prints after I plugin USB post plugging out .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.