Update tinyusb library to compatible with 1.2.0 (#303)

* more Adafruit_TinyUSB include

* add metro m0 m4 with tinyusb to ci

* correct fqbn

* support ci with tinyusb variant

bump zeroDMA and fix warnings with USBHost library example

* install missing libraries

* more libraries

* update tinyusb library to 1.2.0

increase version to 1.7.3
This commit is contained in:
Ha Thach 2021-06-25 21:08:33 +07:00 committed by GitHub
parent 4e51791226
commit 203746757a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 34 additions and 113 deletions

View file

@ -19,6 +19,8 @@ jobs:
- 'pyportal_m4'
- 'pyportal_m4_titano'
- 'feather_m4_can'
- 'metro_m0:usbstack=tinyusb'
- 'metro_m4:speed=120,usbstack=tinyusb'
runs-on: ubuntu-latest
@ -30,14 +32,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'true'
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive
- name: Install Arduino CLI and Tools
run: |
# make all our directories we need for files and libraries
@ -52,7 +49,6 @@ jobs:
env:
BSP_URL: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
BSP_PATH: .arduino15/packages/adafruit/hardware/samd
LIB_DEPS: FlashStorage SD
run: |
arduino-cli config init
arduino-cli core update-index
@ -63,7 +59,7 @@ jobs:
BSP_VERSION=`eval ls $HOME/$BSP_PATH`
rm -r $HOME/$BSP_PATH/*
ln -s $GITHUB_WORKSPACE $HOME/$BSP_PATH/$BSP_VERSION
arduino-cli lib install $LIB_DEPS
arduino-cli lib install "Adafruit NeoPixel" "Adafruit seesaw Library" "Adafruit SPIFlash" "FlashStorage" "MIDI Library" "SD" "SdFat - Adafruit Fork"
- name: Build examples
run: python3 extras/build_all.py ${{ matrix.board }}

View file

@ -1,93 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018, hathach for Adafruit
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _TUSB_CONFIG_H_
#define _TUSB_CONFIG_H_
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------
// COMMON CONFIGURATION
//--------------------------------------------------------------------
#ifdef __SAMD51__
#define CFG_TUSB_MCU OPT_MCU_SAMD51
#else
#define CFG_TUSB_MCU OPT_MCU_SAMD21
#endif
#ifdef USE_TINYUSB
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
#else
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE
#endif
#define CFG_TUSB_OS OPT_OS_NONE
#define CFG_TUSB_DEBUG 0
#if CFG_TUSB_DEBUG
#define tu_printf serial1_printf
extern int serial1_printf(const char *__restrict __format, ...);
#endif
#define CFG_TUSB_MEM_SECTION
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
//--------------------------------------------------------------------
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
#define CFG_TUD_ENDOINT0_SIZE 64
//------------- CLASS -------------//
#define CFG_TUD_CDC 1
#define CFG_TUD_MSC 1
#define CFG_TUD_HID 1
#define CFG_TUD_MIDI 1
#define CFG_TUD_VENDOR 1
// CDC FIFO size of TX and RX
#define CFG_TUD_CDC_RX_BUFSIZE 256
#define CFG_TUD_CDC_TX_BUFSIZE 256
// MSC Buffer size of Device Mass storage
#define CFG_TUD_MSC_BUFSIZE 512
// HID buffer size Should be sufficient to hold ID (if any) + Data
#define CFG_TUD_HID_BUFSIZE 64
// MIDI FIFO size of TX and RX
#define CFG_TUD_MIDI_RX_BUFSIZE 128
#define CFG_TUD_MIDI_TX_BUFSIZE 128
// Vendor FIFO size of TX and RX
#define CFG_TUD_VENDOR_RX_BUFSIZE 64
#define CFG_TUD_VENDOR_TX_BUFSIZE 64
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_CONFIG_H_ */

View file

@ -15,12 +15,13 @@ success_count = 0
fail_count = 0
skip_count = 0
build_format = '| {:20} | {:35} | {:18} | {:6} |'
build_separator = '-' * 83
build_format = '| {:25} | {:35} | {:18} | {:6} |'
build_separator = '-' * 88
FQBN_PREFIX='adafruit:samd:adafruit_'
default_boards = [ 'metro_m0', 'metro_m4', 'circuitplayground_m0', 'feather_m4_can' ]
#default_boards = [ 'metro_m0', 'metro_m4', 'circuitplayground_m0', 'feather_m4_can', 'metro_m0:usbstack=tinyusb', 'metro_m4:speed=120,usbstack=tinyusb' ]
default_boards = [ 'metro_m0', 'metro_m0:usbstack=tinyusb' ]
build_boards = []
# build all variants if input not existed
@ -37,7 +38,7 @@ def build_examples(variant):
print('\n')
print(build_separator)
print('| {:^79} |'.format('Board ' + variant))
print('| {:^84} |'.format('Board ' + variant))
print(build_separator)
print(build_format.format('Library', 'Example', '\033[39mResult\033[0m', 'Time'))
print(build_separator)
@ -45,10 +46,6 @@ def build_examples(variant):
fqbn = "{}{}".format(FQBN_PREFIX, variant)
for sketch in all_examples:
# TODO skip TinyUSB library examples for now
if "libraries/Adafruit_TinyUSB_Arduino" in sketch:
continue
start_time = time.monotonic()
# Skip if contains: ".board.test.skip" or ".all.test.skip"
@ -60,6 +57,14 @@ def build_examples(variant):
elif glob.glob(sketchdir+"/.*.test.only") and not os.path.exists(sketchdir + '/.' + variant + '.test.only'):
success = SKIPPED
skip_count += 1
elif 'usbstack=tinyusb' not in variant and "libraries/Adafruit_TinyUSB_Arduino" in sketch:
# skip non-tinyusb variant for tinyusb examples
success = SKIPPED
skip_count += 1
elif 'usbstack=tinyusb' in variant and "libraries/USBHost" in sketch:
# skip -tinyusb variant for USBHost examples
success = SKIPPED
skip_count += 1
else:
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=PIPE, stderr=PIPE)

@ -1 +1 @@
Subproject commit 8f4bc1f438c9d89a9080438b2e36291c527b4e0e
Subproject commit a5f8ea0686bbd844fb36e4a27cf6aa127f3f9711

@ -1 +1 @@
Subproject commit 1472d1f5d06a84f0458eca35839a8540583530a0
Subproject commit 655916e504e24ec92a46dd17c057ead9e2fe402d

View file

@ -37,6 +37,12 @@ static I2SDevice_SAMD21G18x i2sd(*I2S);
#include "I2S.h"
#ifdef USE_TINYUSB
// For Serial when selecting TinyUSB
#include <Adafruit_TinyUSB.h>
#endif
int I2SClass::_beginCount = 0;
I2SClass::I2SClass(uint8_t deviceIndex, uint8_t clockGenerator, uint8_t sdPin, uint8_t sckPin, uint8_t fsPin) :

View file

@ -21,6 +21,11 @@
#include <Arduino.h>
#include <Servo.h>
#ifdef USE_TINYUSB
// For Serial when selecting TinyUSB
#include <Adafruit_TinyUSB.h>
#endif
#if defined(__SAMD51__)
// Different prescalers depending on FCPU (avoid overflowing 16-bit counter)
#if(F_CPU > 200000000)

View file

@ -216,6 +216,7 @@ byte getconfdescr( byte addr, byte conf )
uint16_t total_length;
// FIXME -- no check of return code from usb.getConfDescr()
rcode = usb.getConfDescr( addr, 0, 4, conf, buf ); //get total length
(void) rcode;
LOBYTE( total_length ) = buf[ 2 ];
HIBYTE( total_length ) = buf[ 3 ];
if( total_length > sizeof(buf)) { //check if total length is larger than buffer
@ -224,6 +225,7 @@ byte getconfdescr( byte addr, byte conf )
}
// FIXME -- no check of return code from usb.getConfDescr()
rcode = usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor
(void) rcode;
while( buf_ptr < buf + total_length ) { //parsing descriptors
descr_length = *( buf_ptr );
descr_type = *( buf_ptr + 1 );

View file

@ -20,7 +20,7 @@
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
version=1.7.2
version=1.7.3
# Compile variables
# -----------------