硬汉嵌入式论坛

 找回密码
 立即注册
查看: 1142|回复: 2
收起左侧

[ThreadX全家桶] USBX HOST HID类设计缺陷导致内存踩踏风险

[复制链接]

4

主题

30

回帖

42

积分

新手上路

积分
42
发表于 2022-2-19 18:41:55 | 显示全部楼层 |阅读模式
本帖最后由 miss-you 于 2022-2-19 18:46 编辑

论坛排版不支持md文件可以直接下载文件看

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
​
​

usbx.md

34.9 KB, 下载次数: 3

评分

参与人数 1金币 +100 收起 理由
eric2013 + 100 很给力!

查看全部评分

回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106913
QQ
发表于 2022-2-19 20:56:41 | 显示全部楼层
非常好的帖子,后面整下,让论坛支持下markdown
回复

使用道具 举报

1

主题

10

回帖

13

积分

新手上路

积分
13
发表于 2023-9-14 14:51:07 | 显示全部楼层
楼主有试过USBX的Custom HID数据收发嘛?求助
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-9 20:21 , Processed in 0.165374 second(s), 29 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表