summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-05-19 13:32:49 +0700
committerhathach <[email protected]>2023-05-19 13:32:49 +0700
commit5dae5e12928ba789cd7e248edd9fa91376902925 (patch)
tree19c1585bd7f6c6da0124bef4749d3c3261e54460
parentf26a93908ef9dcde6818c9b271727ed6c77e87d8 (diff)
ehci fix dcache clean when control endpoint failed
-rw-r--r--hw/bsp/imxrt/family.cmake6
-rw-r--r--src/host/usbh.c3
-rw-r--r--src/portable/ehci/ehci.c10
-rw-r--r--src/tusb.c2
4 files changed, 12 insertions, 9 deletions
diff --git a/hw/bsp/imxrt/family.cmake b/hw/bsp/imxrt/family.cmake
index 4628abc34..a475b4721 100644
--- a/hw/bsp/imxrt/family.cmake
+++ b/hw/bsp/imxrt/family.cmake
@@ -57,12 +57,16 @@ if (NOT TARGET ${BOARD_TARGET})
)
update_board(${BOARD_TARGET})
+ if (NOT DEFINED LD_FILE_${TOOLCHAIN})
+ set(LD_FILE_gcc ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld)
+ endif ()
+
if (TOOLCHAIN STREQUAL "gcc")
target_sources(${BOARD_TARGET} PUBLIC
${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S
)
target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld"
+ "LINKER:--script=${LD_FILE_gcc}"
"LINKER:-Map=$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map"
# nanolib
--specs=nosys.specs
diff --git a/src/host/usbh.c b/src/host/usbh.c
index c56ff9459..7b265c742 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -440,7 +440,7 @@ void tuh_task_ext(uint32_t timeout_ms, bool in_isr)
uint8_t const epnum = tu_edpt_number(ep_addr);
uint8_t const ep_dir = tu_edpt_dir(ep_addr);
- TU_LOG_USBH("on EP %02X with %u bytes %s\r\n", ep_addr, (unsigned int) event.xfer_complete.len,
+ TU_LOG_USBH("on EP %02X with %u bytes: %s\r\n", ep_addr, (unsigned int) event.xfer_complete.len,
tu_str_xfer_result[event.xfer_complete.result]);
if (event.dev_addr == 0)
@@ -1255,6 +1255,7 @@ static void process_enumeration(tuh_xfer_t* xfer)
{
failed_count++;
osal_task_delay(ATTEMPT_DELAY_MS); // delay a bit
+ TU_LOG1("Enumeration attempt %u\r\n", failed_count);
TU_ASSERT(tuh_control_xfer(xfer), );
}else
{
diff --git a/src/portable/ehci/ehci.c b/src/portable/ehci/ehci.c
index cc825d549..10e2db7b5 100644
--- a/src/portable/ehci/ehci.c
+++ b/src/portable/ehci/ehci.c
@@ -577,7 +577,7 @@ void qhd_xfer_complete_isr(ehci_qhd_t * qhd) {
uint32_t const xferred_bytes = qtd->expected_bytes - qtd->total_bytes;
// invalidate dcache if IN transfer
- if (dir == 1 && qhd->attached_buffer != 0) {
+ if (dir == 1 && qhd->attached_buffer != 0 && xferred_bytes > 0) {
hcd_dcache_invalidate((void*) qhd->attached_buffer, xferred_bytes);
}
@@ -660,7 +660,7 @@ void qhd_xfer_error_isr(ehci_qhd_t * qhd)
if (qtd_overlay->halted) {
xfer_result_t xfer_result;
- if (qtd_overlay->err_count == 0 || qtd_overlay->buffer_err || qtd_overlay->babble_err || qtd_overlay->xact_err) {
+ if (qtd_overlay->xact_err || qtd_overlay->err_count == 0 || qtd_overlay->buffer_err || qtd_overlay->babble_err) {
// Error count = 0 often occurs when device disconnected, or other bus-related error
xfer_result = XFER_RESULT_FAILED;
}else {
@@ -671,7 +671,6 @@ void qhd_xfer_error_isr(ehci_qhd_t * qhd)
// if (XFER_RESULT_FAILED == xfer_result ) {
// TU_LOG1(" QHD xfer err count: %d\n", qtd_overlay->err_count);
// TU_BREAKPOINT(); // TODO skip unplugged device
-// while(1){}
// }
ehci_qtd_t * volatile qtd = (ehci_qtd_t * volatile) qhd->attached_qtd;
@@ -683,7 +682,7 @@ void qhd_xfer_error_isr(ehci_qhd_t * qhd)
uint32_t const xferred_bytes = qtd->expected_bytes - qtd->total_bytes;
// invalidate dcache if IN transfer
- if (dir == 1 && qhd->attached_buffer != 0) {
+ if (dir == 1 && qhd->attached_buffer != 0 && xferred_bytes > 0) {
hcd_dcache_invalidate((void*) qhd->attached_buffer, xferred_bytes);
}
@@ -698,8 +697,7 @@ void qhd_xfer_error_isr(ehci_qhd_t * qhd)
qhd->qtd_overlay.alternate.terminate = 1;
qhd->qtd_overlay.halted = 0;
- ehci_qtd_t *p_setup = qtd_control(qhd->dev_addr);
- p_setup->used = 0;
+ hcd_dcache_clean(qhd, sizeof(ehci_qhd_t));
}
// notify usbh
diff --git a/src/tusb.c b/src/tusb.c
index 7327db685..465b608b0 100644
--- a/src/tusb.c
+++ b/src/tusb.c
@@ -440,7 +440,7 @@ char const* const tu_str_std_request[] =
};
char const* const tu_str_xfer_result[] = {
- "OK", "Failed", "Stalled", "Timeout"
+ "OK", "FAILED", "STALLED", "TIMEOUT"
};
#endif