1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-26 20:22:17 +00:00

Some more USB fixes.

This commit is contained in:
Pablo Curiel 2020-05-09 09:49:02 -04:00
parent 1f05a39560
commit 47297daf3a
2 changed files with 9 additions and 11 deletions

View file

@ -149,7 +149,7 @@ static int read_thread_func(void *arg)
return -1; return -1;
} }
u8 *buf = usbAllocatePageAlignedBuffer(TEST_BUF_SIZE); u8 *buf = malloc(TEST_BUF_SIZE);
if (!buf) if (!buf)
{ {
shared_data->read_error = true; shared_data->read_error = true;
@ -296,7 +296,7 @@ int main(int argc, char *argv[])
.id_offset = 0 .id_offset = 0
}; };
buf = malloc(TEST_BUF_SIZE); buf = usbAllocatePageAlignedBuffer(TEST_BUF_SIZE);
if (!buf) if (!buf)
{ {
consolePrint("buf failed\n"); consolePrint("buf failed\n");

View file

@ -28,6 +28,8 @@
#define USB_CMD_HEADER_MAGIC 0x4E584454 /* "NXDT" */ #define USB_CMD_HEADER_MAGIC 0x4E584454 /* "NXDT" */
#define USB_SESSION_START_TIMEOUT 10 /* 10 seconds */
#define USB_TRANSFER_ALIGNMENT 0x1000 /* 4 KiB */ #define USB_TRANSFER_ALIGNMENT 0x1000 /* 4 KiB */
#define USB_TRANSFER_TIMEOUT 5 /* 5 seconds */ #define USB_TRANSFER_TIMEOUT 5 /* 5 seconds */
@ -188,15 +190,10 @@ bool usbStartSession(void)
time_t start = time(NULL); time_t start = time(NULL);
time_t now = start; time_t now = start;
while((now - start) < USB_TRANSFER_TIMEOUT) while((now - start) < USB_SESSION_START_TIMEOUT)
{ {
if (usbIsHostAvailable()) ret = g_usbSessionStarted = (usbIsHostAvailable() && _usbStartSession());
{ if (ret) break;
/* Once the console has been connected to a host device, there's no need to keep running this loop */
/* usbTransferData() implements its own timeout */
ret = g_usbSessionStarted = _usbStartSession();
break;
}
utilsSleep(1); utilsSleep(1);
now = time(NULL); now = time(NULL);
@ -950,6 +947,7 @@ static bool usbTransferData(void *buf, u64 size, UsbDsEndpoint *endpoint)
if (R_FAILED(rc)) if (R_FAILED(rc))
{ {
LOGFILE("USB transfer timed out! (0x%08X)", rc); LOGFILE("USB transfer timed out! (0x%08X)", rc);
usbDsEndpoint_Cancel(endpoint);
return false; return false;
} }
@ -963,7 +961,7 @@ static bool usbTransferData(void *buf, u64 size, UsbDsEndpoint *endpoint)
rc = usbDsParseReportData(&report_data, urb_id, NULL, &transferred_size); rc = usbDsParseReportData(&report_data, urb_id, NULL, &transferred_size);
if (R_FAILED(rc)) if (R_FAILED(rc))
{ {
LOGFILE("usbDsEndpoint_GetReportData failed! (0x%08X)", rc); LOGFILE("usbDsParseReportData failed! (0x%08X)", rc);
return false; return false;
} }