From 65711de870ba4ef178d08f9f02fb76c69306aa67 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 18 Dec 2019 15:18:05 +0700 Subject: [PATCH 1/4] added coverity badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f7556cf..3f7e7ecd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![tinyUSB_240x100](https://user-images.githubusercontent.com/249515/62646655-f9393200-b978-11e9-9c53-484862f15503.png) -[![Build Status](https://travis-ci.org/hathach/tinyusb.svg?branch=master)](https://travis-ci.org/hathach/tinyusb) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) +[![Build Status](https://travis-ci.org/hathach/tinyusb.svg?branch=master)](https://travis-ci.org/hathach/tinyusb) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)[![Coverity](https://img.shields.io/coverity/scan/458.svg)](https://scan.coverity.com/projects/tinyusb) TinyUSB is an open-source cross-platform USB Host/Device stack for embedded system, designed to be memory-safe with no dynamic allocation and thread-safe with all interrupt events are deferred then handled in the non-ISR task function. From a1e55e57a4b012742e0f571723e86d1bcdc91186 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 20 Dec 2019 17:09:42 +0700 Subject: [PATCH 2/4] clean warnings --- src/device/usbd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/device/usbd.h b/src/device/usbd.h index 9d39af13..e685686a 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -212,7 +212,7 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re // Interface number, string index, protocol, report descriptor len, EP In address, size & polling interval #define TUD_HID_DESCRIPTOR(_itfnum, _stridx, _boot_protocol, _report_desc_len, _epin, _epsize, _ep_interval) \ /* Interface */\ - 9, TUSB_DESC_INTERFACE, _itfnum, 0, 1, TUSB_CLASS_HID, (_boot_protocol) ? HID_SUBCLASS_BOOT : 0, _boot_protocol, _stridx,\ + 9, TUSB_DESC_INTERFACE, _itfnum, 0, 1, TUSB_CLASS_HID, (uint8_t)((_boot_protocol) ? HID_SUBCLASS_BOOT : 0), _boot_protocol, _stridx,\ /* HID descriptor */\ 9, HID_DESC_TYPE_HID, U16_TO_U8S_LE(0x0111), 0, 1, HID_DESC_TYPE_REPORT, U16_TO_U8S_LE(_report_desc_len),\ /* Endpoint In */\ @@ -225,7 +225,7 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re // Interface number, string index, protocol, report descriptor len, EP OUT & IN address, size & polling interval #define TUD_HID_INOUT_DESCRIPTOR(_itfnum, _stridx, _boot_protocol, _report_desc_len, _epout, _epin, _epsize, _ep_interval) \ /* Interface */\ - 9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_HID, (_boot_protocol) ? HID_SUBCLASS_BOOT : 0, _boot_protocol, _stridx,\ + 9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_HID, (uint8_t)((_boot_protocol) ? HID_SUBCLASS_BOOT : 0), _boot_protocol, _stridx,\ /* HID descriptor */\ 9, HID_DESC_TYPE_HID, U16_TO_U8S_LE(0x0111), 0, 1, HID_DESC_TYPE_REPORT, U16_TO_U8S_LE(_report_desc_len),\ /* Endpoint Out */\ From a1c94067f778dc6f055c132ca18c870a107910be Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 23 Dec 2019 19:48:52 +0700 Subject: [PATCH 3/4] add driver 99-tinyusb.rules for ubuntu, rename window usbser inf --- tools/usb_drivers/99-tinyusb.rules | 18 ++++++++++++++++++ .../tinyusb_win_usbser.inf} | 0 2 files changed, 18 insertions(+) create mode 100644 tools/usb_drivers/99-tinyusb.rules rename tools/{windows_cdc_driver/tusb_usbser.inf => usb_drivers/tinyusb_win_usbser.inf} (100%) diff --git a/tools/usb_drivers/99-tinyusb.rules b/tools/usb_drivers/99-tinyusb.rules new file mode 100644 index 00000000..334159f9 --- /dev/null +++ b/tools/usb_drivers/99-tinyusb.rules @@ -0,0 +1,18 @@ +# Copy this file to the location of your distribution's udev rules, for example on Ubuntu: +# sudo cp 99-tinyusb.rules /etc/udev/rules.d/ +# Then reload udev configuration by executing: +# sudo udevadm control --reload-rules +# sudo udevadm trigger + +# Check SUBSYSTEM +SUBSYSTEMS=="hidraw", KERNEL=="hidraw*", MODE="0666", GROUP="dialout" + +# Rule applies to all TinyUSB example +ATTRS{idVendor}=="cafe", MODE="0666", GROUP="dialout" + +# Rule to blacklist TinyUSB example from being manipulated by ModemManager. +SUBSYSTEMS=="usb", ATTRS{idVendor}=="cafe", ENV{ID_MM_DEVICE_IGNORE}="1" + +# Xplained Pro SamG55 Device +SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE="0666", GROUP="users", ENV{ID_MM_DEVICE_IGNORE}="1" +SUBSYSTEMS=="tty", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE="0666", GROUP="users", ENV{ID_MM_DEVICE_IGNORE}="1" diff --git a/tools/windows_cdc_driver/tusb_usbser.inf b/tools/usb_drivers/tinyusb_win_usbser.inf similarity index 100% rename from tools/windows_cdc_driver/tusb_usbser.inf rename to tools/usb_drivers/tinyusb_win_usbser.inf From 605129eb6600ffb50ea2d239e0ad78a9636df8e1 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 24 Dec 2019 21:24:43 +0700 Subject: [PATCH 4/4] invoke scsi complete callback before queue for csw status there is racing issue with samd + qspi flash testing with arduino otherwise. --- src/class/msc/msc_device.c | 18 +++++++++++++----- src/tusb_option.h | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 93167bc6..bef5d599 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -39,7 +39,8 @@ enum { MSC_STAGE_CMD = 0, MSC_STAGE_DATA, - MSC_STAGE_STATUS + MSC_STAGE_STATUS, + MSC_STAGE_STATUS_SENT }; typedef struct @@ -569,7 +570,11 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t break; case MSC_STAGE_STATUS: - // Wait for the command status wrapper complete event + // processed immediately after this switch, supposedly to be empty + break; + + case MSC_STAGE_STATUS_SENT: + // Wait for the Status phase to complete if( (ep_addr == p_msc->ep_in) && (xferred_bytes == sizeof(msc_csw_t)) ) { TU_LOG2(" SCSI Status: %u\n", p_csw->status); @@ -598,9 +603,6 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t } else { - // Send SCSI Status - TU_ASSERT(usbd_edpt_xfer(rhport, p_msc->ep_in , (uint8_t*) &p_msc->csw, sizeof(msc_csw_t))); - // Invoke complete callback if defined switch(p_cbw->command[0]) { @@ -616,6 +618,12 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t if ( tud_msc_scsi_complete_cb ) tud_msc_scsi_complete_cb(p_cbw->lun, p_cbw->command); break; } + + // Move to Status Sent stage + p_msc->stage = MSC_STAGE_STATUS_SENT; + + // Send SCSI Status + TU_ASSERT(usbd_edpt_xfer(rhport, p_msc->ep_in , (uint8_t*) &p_msc->csw, sizeof(msc_csw_t))); } } diff --git a/src/tusb_option.h b/src/tusb_option.h index 6766da07..266687ff 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -36,7 +36,7 @@ * \ref CFG_TUSB_MCU must be defined to one of these * @{ */ -#define OPT_MCU_NONE 0 +#define OPT_MCU_NONE 0 // LPC #define OPT_MCU_LPC11UXX 1 ///< NXP LPC11Uxx