Skip to content

Commit fb18a2a

Browse files
Xu Yangnxpfrankli
authored andcommitted
Add -force-ctrl option for HID backup transfer
In case the normal HID interrupt transfer fails, the HID can use control ep to transfer data as a backup. Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
1 parent b186f50 commit fb18a2a

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

libuuu/libuuu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,6 @@ enum class bmap_mode {
174174
/*Get .bmap handling mode*/
175175
EXT bmap_mode uuu_get_bmap_mode();
176176
EXT int uuu_set_bmap_mode(bmap_mode mode);
177+
EXT void uuu_set_force_hid_use_ctrl_ep(bool force);
177178

178179
#endif

libuuu/trans.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ extern "C"
4343

4444
using namespace std;
4545

46+
static bool g_force_hid_use_ctrl_ep = false;
47+
48+
void uuu_set_force_hid_use_ctrl_ep(bool force)
49+
{
50+
g_force_hid_use_ctrl_ep = force;
51+
}
52+
4653
TransBase::~TransBase()
4754
{
4855
}
@@ -171,7 +178,7 @@ int HIDTrans::write_simple(void *buff, size_t size)
171178
uint8_t *p = (uint8_t *)buff;
172179
int actual_size;
173180

174-
if (m_outEP)
181+
if (m_outEP && !g_force_hid_use_ctrl_ep)
175182
{
176183
ret = libusb_interrupt_transfer(
177184
(libusb_device_handle *)m_devhandle,

uuu/uuu.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ void print_help(bool detail = false)
188188
" -dry Dry run mode, check if script or cmd correct \n"
189189
" -bmap Try using .bmap files even if flash commands do not specify them\n"
190190
" -no-bmap Ignore .bmap files even if flash commands specify them\n"
191+
" -force-ctrl Force HID transfer use control endpoint\n"
191192
" -m <usbpath> Only monitor these paths.\n"
192193
" -m 1:2 -m 1:3\n\n"
193194
" -ms <serial_no> Monitor the serial number prefix of the device using 'serial_no'.\n"
@@ -1041,6 +1042,10 @@ int main(int argc, char **argv)
10411042
{
10421043
uuu_set_bmap_mode(bmap_mode::Ignore);
10431044
}
1045+
else if (s == "-force-ctrl")
1046+
{
1047+
uuu_set_force_hid_use_ctrl_ep(true);
1048+
}
10441049
else if (s == "-e")
10451050
{
10461051
#ifndef WIN32

0 commit comments

Comments
 (0)