Squashed 'third_party/pico-sdk/lib/tinyusb/' content from commit 868948f67c

Change-Id: I5d33c2566dd597be9d4b1c30d4b3723c5ef4a265
git-subtree-dir: third_party/pico-sdk/lib/tinyusb
git-subtree-split: 868948f67c90fa7c2553cdcd604b52862cf55720
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/tools/build_board.py b/tools/build_board.py
new file mode 100644
index 0000000..9397c75
--- /dev/null
+++ b/tools/build_board.py
@@ -0,0 +1,125 @@
+import os
+import glob
+import sys
+import subprocess
+import time
+
+SUCCEEDED = "\033[32msucceeded\033[0m"
+FAILED = "\033[31mfailed\033[0m"
+SKIPPED = "\033[33mskipped\033[0m"
+
+success_count = 0
+fail_count = 0
+skip_count = 0
+exit_status = 0
+
+total_time = time.monotonic()
+
+build_format = '| {:29} | {:30} | {:18} | {:7} | {:6} | {:6} |'
+build_separator = '-' * 106
+
+def filter_with_input(mylist):
+    if len(sys.argv) > 1:
+        input_args = list(set(mylist).intersection(sys.argv))
+        if len(input_args) > 0:
+            mylist[:] = input_args
+
+# If examples are not specified in arguments, build all
+all_examples = []
+for entry in os.scandir("examples/device"):
+    if entry.is_dir():
+        all_examples.append("device/" + entry.name)
+for entry in os.scandir("examples/host"):
+    if entry.is_dir():
+        all_examples.append("host/" + entry.name)
+filter_with_input(all_examples)
+all_examples.sort()
+
+# If boards are not specified in arguments, build all
+all_boards = []
+for entry in os.scandir("hw/bsp"):
+    if entry.is_dir() and os.path.exists(entry.path + "/board.mk"):
+        all_boards.append(entry.name)
+filter_with_input(all_boards)
+all_boards.sort()
+
+def build_board(example, board):
+    global success_count, fail_count, skip_count, exit_status
+    start_time = time.monotonic()
+    flash_size = "-"
+    sram_size = "-"
+
+    # Check if board is skipped
+    if skip_example(example, board):
+        success = SKIPPED
+        skip_count += 1
+        print(build_format.format(example, board, success, '-', flash_size, sram_size))
+    else:
+        subprocess.run("make -C examples/{} BOARD={} clean".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        build_result = subprocess.run("make -j -C examples/{} BOARD={} all".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+        if build_result.returncode == 0:
+            success = SUCCEEDED
+            success_count += 1
+            (flash_size, sram_size) = build_size(example, board)
+        else:
+            exit_status = build_result.returncode
+            success = FAILED
+            fail_count += 1
+
+        build_duration = time.monotonic() - start_time
+        print(build_format.format(example, board, success, "{:.2f}s".format(build_duration), flash_size, sram_size))
+
+        if build_result.returncode != 0:
+            print(build_result.stdout.decode("utf-8"))
+
+def build_size(example, board):
+    #elf_file = 'examples/device/{}/_build/{}/{}-firmware.elf'.format(example, board, board)
+    elf_file = 'examples/{}/_build/{}/*.elf'.format(example, board)
+    size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8")
+    size_list = size_output.split('\n')[1].split('\t')
+    flash_size = int(size_list[0])
+    sram_size = int(size_list[1]) + int(size_list[2])
+    return (flash_size, sram_size)
+
+def skip_example(example, board):
+    ex_dir = 'examples/' + example
+    board_mk = 'hw/bsp/{}/board.mk'.format(board)
+    with open(board_mk) as mk:
+        mk_contents = mk.read()
+
+        # Skip all OPT_MCU_NONE these are WIP port
+        if '-DCFG_TUSB_MCU=OPT_MCU_NONE' in mk_contents:
+            return 1
+
+        # Skip if CFG_TUSB_MCU in board.mk to match skip file
+        for skip_file in glob.iglob(ex_dir + '/.skip.MCU_*'):
+            mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2]
+            if mcu_cflag in mk_contents:
+                return 1
+
+        # Build only list, if exists only these MCU are built
+        only_list = list(glob.iglob(ex_dir + '/.only.MCU_*'))
+        if len(only_list) > 0:
+            for only_file in only_list:
+                mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2]
+                if mcu_cflag in mk_contents:
+                    return 0
+            return 1
+
+    return 0
+
+print(build_separator)
+print(build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
+
+for example in all_examples:
+    print(build_separator)
+    for board in all_boards:
+        build_board(example, board)
+
+total_time = time.monotonic() - total_time
+print(build_separator)
+print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, total_time))
+print(build_separator)
+
+sys.exit(exit_status)
diff --git a/tools/build_esp32sx.py b/tools/build_esp32sx.py
new file mode 100644
index 0000000..91953f0
--- /dev/null
+++ b/tools/build_esp32sx.py
@@ -0,0 +1,102 @@
+import os
+import glob
+import sys
+import subprocess
+import time
+
+SUCCEEDED = "\033[32msucceeded\033[0m"
+FAILED = "\033[31mfailed\033[0m"
+SKIPPED = "\033[33mskipped\033[0m"
+
+success_count = 0
+fail_count = 0
+skip_count = 0
+exit_status = 0
+
+total_time = time.monotonic()
+
+build_format = '| {:23} | {:30} | {:18} | {:7} | {:6} | {:6} |'
+build_separator = '-' * 100
+
+def filter_with_input(mylist):
+    if len(sys.argv) > 1:
+        input_args = list(set(mylist).intersection(sys.argv))
+        if len(input_args) > 0:
+            mylist[:] = input_args
+
+# Build all examples if not specified
+all_examples = []
+for entry in os.scandir("examples/device"):
+    # Only includes example with CMakeLists.txt for esp32s, and skip board_test to speed up ci
+    if entry.is_dir() and os.path.exists(entry.path + "/sdkconfig.defaults") and entry.name != 'board_test':
+        all_examples.append(entry.name)
+filter_with_input(all_examples)
+all_examples.sort()
+
+# Build all boards if not specified
+all_boards = []
+for entry in os.scandir("hw/bsp/esp32s2/boards"):
+    if entry.is_dir():
+        all_boards.append(entry.name)
+for entry in os.scandir("hw/bsp/esp32s3/boards"):
+    if entry.is_dir():
+        all_boards.append(entry.name)
+filter_with_input(all_boards)
+all_boards.sort()
+
+def build_board(example, board):
+    global success_count, fail_count, skip_count, exit_status
+    start_time = time.monotonic()
+    flash_size = "-"
+    sram_size = "-"
+
+    # Check if board is skipped
+    if skip_example(example, board):
+        success = SKIPPED
+        skip_count += 1
+        print(build_format.format(example, board, success, '-', flash_size, sram_size))
+    else:
+        subprocess.run("make -C examples/device/{} BOARD={} clean".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        build_result = subprocess.run("make -j -C examples/device/{} BOARD={} all".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+        if build_result.returncode == 0:
+            success = SUCCEEDED
+            success_count += 1
+            (flash_size, sram_size) = build_size(example, board)
+        else:
+            exit_status = build_result.returncode
+            success = FAILED
+            fail_count += 1
+
+        build_duration = time.monotonic() - start_time
+        print(build_format.format(example, board, success, "{:.2f}s".format(build_duration), flash_size, sram_size))
+
+        if build_result.returncode != 0:
+            print(build_result.stdout.decode("utf-8"))
+
+def build_size(example, board):
+    #elf_file = 'examples/device/{}/_build/{}/{}-firmware.elf'.format(example, board, board)
+    elf_file = 'examples/device/{}/_build/{}/*.elf'.format(example, board)
+    size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8")
+    size_list = size_output.split('\n')[1].split('\t')
+    flash_size = int(size_list[0])
+    sram_size = int(size_list[1]) + int(size_list[2])
+    return (flash_size, sram_size)
+
+def skip_example(example, board):
+    return 0
+
+print(build_separator)
+print(build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
+print(build_separator)
+
+for example in all_examples:
+    for board in all_boards:
+        build_board(example, board)
+
+total_time = time.monotonic() - total_time
+print(build_separator)
+print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, total_time))
+print(build_separator)
+
+sys.exit(exit_status)
diff --git a/tools/build_family.py b/tools/build_family.py
new file mode 100644
index 0000000..4195c25
--- /dev/null
+++ b/tools/build_family.py
@@ -0,0 +1,151 @@
+import os
+import glob
+import sys
+import subprocess
+import time
+
+SUCCEEDED = "\033[32msucceeded\033[0m"
+FAILED = "\033[31mfailed\033[0m"
+SKIPPED = "\033[33mskipped\033[0m"
+
+success_count = 0
+fail_count = 0
+skip_count = 0
+exit_status = 0
+
+total_time = time.monotonic()
+
+build_format = '| {:29} | {:30} | {:18} | {:7} | {:6} | {:6} |'
+build_separator = '-' * 106
+
+def filter_with_input(mylist):
+    if len(sys.argv) > 1:
+        input_args = list(set(mylist).intersection(sys.argv))
+        if len(input_args) > 0:
+            mylist[:] = input_args
+
+# If examples are not specified in arguments, build all
+all_examples = []
+for entry in os.scandir("examples/device"):
+    if entry.is_dir():
+        all_examples.append("device/" + entry.name)
+for entry in os.scandir("examples/host"):
+    if entry.is_dir():
+        all_examples.append("host/" + entry.name)
+filter_with_input(all_examples)
+all_examples.sort()
+
+# If family are not specified in arguments, build all
+all_families = []
+for entry in os.scandir("hw/bsp"):
+    if entry.is_dir() and os.path.isdir(entry.path + "/boards") and entry.name != "esp32s2" and entry.name != "esp32s3":
+        all_families.append(entry.name)
+            
+filter_with_input(all_families)
+all_families.sort()
+
+def build_family(example, family):
+    all_boards = []
+    for entry in os.scandir("hw/bsp/{}/boards".format(family)):
+        if entry.is_dir():
+            all_boards.append(entry.name)
+    filter_with_input(all_boards)
+    all_boards.sort()
+    
+    for board in all_boards:
+        build_board(example, board)
+    
+def build_board(example, board):
+    global success_count, fail_count, skip_count, exit_status
+    start_time = time.monotonic()
+    flash_size = "-"
+    sram_size = "-"
+
+    # Check if board is skipped
+    if skip_example(example, board):
+        success = SKIPPED
+        skip_count += 1
+        print(build_format.format(example, board, success, '-', flash_size, sram_size))
+    else:   
+        #subprocess.run("make -C examples/{} BOARD={} clean".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        build_result = subprocess.run("make -j -C examples/{} BOARD={} all".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+        if build_result.returncode == 0:
+            success = SUCCEEDED
+            success_count += 1
+            (flash_size, sram_size) = build_size(example, board)
+            subprocess.run("make -j -C examples/{} BOARD={} copy-artifact".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        else:
+            exit_status = build_result.returncode
+            success = FAILED
+            fail_count += 1
+
+        build_duration = time.monotonic() - start_time
+        print(build_format.format(example, board, success, "{:.2f}s".format(build_duration), flash_size, sram_size))
+
+        if build_result.returncode != 0:
+            print(build_result.stdout.decode("utf-8"))
+
+def build_size(example, board):
+    #elf_file = 'examples/device/{}/_build/{}/{}-firmware.elf'.format(example, board, board)
+    elf_file = 'examples/{}/_build/{}/*.elf'.format(example, board)
+    size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8")
+    size_list = size_output.split('\n')[1].split('\t')
+    flash_size = int(size_list[0])
+    sram_size = int(size_list[1]) + int(size_list[2])
+    return (flash_size, sram_size)
+
+def skip_example(example, board):
+    ex_dir = 'examples/' + example
+    
+    # Check if example is skipped by family or board directory
+    skip_file = ".skip." + example.replace('/', '.');
+    if os.path.isfile("hw/bsp/{}/{}".format(family, skip_file)) or os.path.isfile("hw/bsp/{}/boards/{}/{}".format(family, board, skip_file)):
+        return 1
+
+    # Otherwise check if mcu is excluded by example directory
+
+    # family CMake
+    family_mk = 'hw/bsp/{}/family.cmake'.format(family)
+
+    # family.mk
+    if not os.path.exists(family_mk):
+        family_mk = 'hw/bsp/{}/family.mk'.format(family)
+
+    with open(family_mk) as mk:
+        mk_contents = mk.read()
+
+        # Skip all OPT_MCU_NONE these are WIP port
+        if 'CFG_TUSB_MCU=OPT_MCU_NONE' in mk_contents:
+            return 1
+
+        # Skip if CFG_TUSB_MCU in family.mk to match skip file
+        for skip_file in glob.iglob(ex_dir + '/.skip.MCU_*'):
+            mcu_cflag = 'CFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2]
+            if mcu_cflag in mk_contents:
+                return 1
+
+        # Build only list, if exists only these MCU are built
+        only_list = list(glob.iglob(ex_dir + '/.only.MCU_*'))
+        if len(only_list) > 0:
+            for only_file in only_list:
+                mcu_cflag = 'CFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2]
+                if mcu_cflag in mk_contents:
+                    return 0
+            return 1
+    return 0
+
+print(build_separator)
+print(build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
+
+for example in all_examples:
+    print(build_separator)
+    for family in all_families:
+        build_family(example, family)
+
+total_time = time.monotonic() - total_time
+print(build_separator)
+print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, total_time))
+print(build_separator)
+
+sys.exit(exit_status)
diff --git a/tools/iar_gen.py b/tools/iar_gen.py
new file mode 100644
index 0000000..73c8b29
--- /dev/null
+++ b/tools/iar_gen.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python3
+
+import os
+import xml.dom.minidom as XML
+
+# Read base configuration
+base = ""
+with open("iar_template.ipcf") as f:
+    base = f.read()
+
+# Enumerate all device/host examples
+dir_1 = os.listdir("../examples")
+for dir_2 in dir_1:
+    if os.path.isdir("../examples/{}".format(dir_2)):
+        print(dir_2)
+        examples = os.listdir("../examples/{}".format(dir_2))
+        for example in examples:
+            if os.path.isdir("../examples/{}/{}".format(dir_2, example)):
+                print("../examples/{}/{}".format(dir_2, example))
+                conf = XML.parseString(base)
+                files = conf.getElementsByTagName("files")[0]
+                inc   = conf.getElementsByTagName("includePath")[0]
+                # Add bsp inc
+                path = conf.createElement('path')
+                path_txt = conf.createTextNode("$TUSB_DIR$/hw")
+                path.appendChild(path_txt)
+                inc.appendChild(path)
+                # Add board.c/.h
+                grp = conf.createElement('group')
+                grp.setAttribute("name", "bsp")
+                path = conf.createElement('path')
+                path_txt = conf.createTextNode("$TUSB_DIR$/hw/bsp/board.c")
+                path.appendChild(path_txt)
+                grp.appendChild(path)
+                files.appendChild(grp)
+                # Add example's .c/.h
+                grp = conf.createElement('group')
+                grp.setAttribute("name", "example")
+                for file in os.listdir("../examples/{}/{}/src".format(dir_2, example)):
+                    if file.endswith(".c") or file.endswith(".h"):
+                        path = conf.createElement('path')
+                        path.setAttribute("copyTo", "$PROJ_DIR$/{}".format(file))
+                        path_txt = conf.createTextNode("$TUSB_DIR$/examples/{0}/{1}/src/{2}".format(dir_2, example, file))
+                        path.appendChild(path_txt)
+                        grp.appendChild(path)
+                files.appendChild(grp)
+                cfg_str = conf.toprettyxml()
+                cfg_str = '\n'.join([s for s in cfg_str.splitlines() if s.strip()])
+                #print(cfg_str)
+                with open("../examples/{0}/{1}/iar_{1}.ipcf".format(dir_2, example), 'w') as f:
+                    f.write(cfg_str)
diff --git a/tools/iar_template.ipcf b/tools/iar_template.ipcf
new file mode 100644
index 0000000..ba54fe0
--- /dev/null
+++ b/tools/iar_template.ipcf
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<iarProjectConnection name="tinyusb" oneShot="true">
+
+	<includePath>
+		<path>$TUSB_DIR$/src</path>
+        <path>$TUSB_DIR$/lib/SEGGER_RTT/RTT</path>
+        <path>$PROJ_DIR$</path>
+	</includePath>
+	<files>
+		<group name="src/device">
+			<path>$TUSB_DIR$/src/device/usbd.c</path>
+			<path>$TUSB_DIR$/src/device/usbd_control.c</path>
+		</group>
+		<group name="src/common">
+			<path>$TUSB_DIR$/src/common/tusb_fifo.c</path>
+		</group>
+		<group name="src/class/audio">
+			<path>$TUSB_DIR$/src/class/audio/audio_device.c</path>
+		</group>
+		<group name="src/class/bth">
+			<path>$TUSB_DIR$/src/class/bth/bth_device.c</path>
+		</group>
+		<group name="src/class/cdc">
+			<path>$TUSB_DIR$/src/class/cdc/cdc_device.c</path>
+			<path>$TUSB_DIR$/src/class/cdc/cdc_host.c</path>
+			<path>$TUSB_DIR$/src/class/cdc/cdc_rndis_host.c</path>
+		</group>
+		<group name="src/class/dfu">
+			<path>$TUSB_DIR$/src/class/dfu/dfu_device.c</path>
+			<path>$TUSB_DIR$/src/class/dfu/dfu_rt_device.c</path>
+		</group>
+		<group name="src/class/hid">
+			<path>$TUSB_DIR$/src/class/hid/hid_device.c</path>
+			<path>$TUSB_DIR$/src/class/hid/hid_host.c</path>
+		</group>
+		<group name="src/class/midi">
+			<path>$TUSB_DIR$/src/class/midi/midi_device.c</path>
+		</group>
+		<group name="src/class/msc">
+			<path>$TUSB_DIR$/src/class/msc/msc_device.c</path>
+			<path>$TUSB_DIR$/src/class/msc/msc_host.c</path>
+		</group>
+		<group name="src/class/net">
+			<path>$TUSB_DIR$/src/class/net/ecm_rndis_device.c</path>
+			<path>$TUSB_DIR$/src/class/net/ncm_device.c</path>
+		</group>
+		<group name="src/class/usbtmc">
+			<path>$TUSB_DIR$/src/class/usbtmc/usbtmc_device.c</path>
+		</group>
+		<group name="src/class/vendor">
+			<path>$TUSB_DIR$/src/class/vendor/vendor_device.c</path>
+			<path>$TUSB_DIR$/src/class/vendor/vendor_host.c</path>
+		</group>
+        <group name="src">
+            <path>$TUSB_DIR$/src/tusb.c</path>
+        </group>
+		<group name="src/host">
+			<path>$TUSB_DIR$/src/host/hub.c</path>
+			<path>$TUSB_DIR$/src/host/usbh.c</path>
+			<path>$TUSB_DIR$/src/host/usbh_control.c</path>
+		</group>
+		<group name="src/portable/synopsys/dwc2">
+			<path>$TUSB_DIR$/src/portable/synopsys/dwc2/dcd_dwc2.c</path>
+		</group>
+		<group name="src/portable/dialog/da146xx">
+			<path>$TUSB_DIR$/src/portable/dialog/da146xx/dcd_da146xx.c</path>
+		</group>
+		<group name="src/portable/ehci">
+			<path>$TUSB_DIR$/src/portable/ehci/ehci.c</path>
+		</group>
+		<group name="src/portable/espressif/esp32sx">
+			<path>$TUSB_DIR$/src/portable/espressif/esp32sx/dcd_esp32sx.c</path>
+		</group>
+		<group name="src/portable/mentor/musb">
+			<path>$TUSB_DIR$/src/portable/mentor/musb/dcd_musb.c</path>
+		</group>
+		<group name="src/portable/microchip/samd">
+			<path>$TUSB_DIR$/src/portable/microchip/samd/dcd_samd.c</path>
+		</group>
+		<group name="src/portable/microchip/samg">
+			<path>$TUSB_DIR$/src/portable/microchip/samg/dcd_samg.c</path>
+		</group>
+		<group name="src/portable/microchip/samx7x">
+			<path>$TUSB_DIR$/src/portable/microchip/samx7x/dcd_samx7x.c</path>
+		</group>
+		<group name="src/portable/mindmotion/mm32">
+			<path>$TUSB_DIR$/src/portable/mindmotion/mm32/dcd_mm32f327x_otg.c</path>
+		</group>
+		<group name="src/portable/nordic/nrf5x">
+			<path>$TUSB_DIR$/src/portable/nordic/nrf5x/dcd_nrf5x.c</path>
+		</group>
+		<group name="src/portable/nuvoton/nuc120">
+			<path>$TUSB_DIR$/src/portable/nuvoton/nuc120/dcd_nuc120.c</path>
+		</group>
+		<group name="src/portable/nuvoton/nuc121">
+			<path>$TUSB_DIR$/src/portable/nuvoton/nuc121/dcd_nuc121.c</path>
+		</group>
+		<group name="src/portable/nuvoton/nuc505">
+			<path>$TUSB_DIR$/src/portable/nuvoton/nuc505/dcd_nuc505.c</path>
+		</group>
+		<group name="src/portable/nxp/khci">
+			<path>$TUSB_DIR$/src/portable/nxp/khci/dcd_khci.c</path>
+		</group>
+		<group name="src/portable/nxp/lpc17_40">
+			<path>$TUSB_DIR$/src/portable/nxp/lpc17_40/dcd_lpc17_40.c</path>
+			<path>$TUSB_DIR$/src/portable/nxp/lpc17_40/hcd_lpc17_40.c</path>
+		</group>
+		<group name="src/portable/nxp/lpc_ip3511">
+			<path>$TUSB_DIR$/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c</path>
+		</group>
+		<group name="src/portable/nxp/transdimension">
+			<path>$TUSB_DIR$/src/portable/nxp/transdimension/dcd_transdimension.c</path>
+			<path>$TUSB_DIR$/src/portable/nxp/transdimension/hcd_transdimension.c</path>
+		</group>
+		<group name="src/portable/ohci">
+			<path>$TUSB_DIR$/src/portable/ohci/ohci.c</path>
+		</group>
+		<group name="src/portable/raspberrypi/rp2040">
+			<path>$TUSB_DIR$/src/portable/raspberrypi/rp2040/dcd_rp2040.c</path>
+			<path>$TUSB_DIR$/src/portable/raspberrypi/rp2040/hcd_rp2040.c</path>
+			<path>$TUSB_DIR$/src/portable/raspberrypi/rp2040/rp2040_usb.c</path>
+		</group>
+		<group name="src/portable/renesas/usba">
+			<path>$TUSB_DIR$/src/portable/renesas/usba/dcd_usba.c</path>
+		</group>
+		<group name="src/portable/sony/cxd56">
+			<path>$TUSB_DIR$/src/portable/sony/cxd56/dcd_cxd56.c</path>
+		</group>
+		<group name="src/portable/st/stm32_fsdev">
+			<path>$TUSB_DIR$/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c</path>
+		</group>
+		<group name="src/portable/ti/msp430x5xx">
+			<path>$TUSB_DIR$/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c</path>
+		</group>
+		<group name="src/portable/valentyusb/eptri">
+			<path>$TUSB_DIR$/src/portable/valentyusb/eptri/dcd_eptri.c</path>
+		</group>
+        <group name="lib/SEGGER_RTT">
+			<path>$TUSB_DIR$/lib/SEGGER_RTT/RTT/SEGGER_RTT.c</path>
+            <path>$TUSB_DIR$/lib/SEGGER_RTT/RTT/SEGGER_RTT_printf.c</path>
+            <path>$TUSB_DIR$/lib/SEGGER_RTT/Syscalls/SEGGER_RTT_Syscalls_IAR.c</path>
+		</group>
+    </files>
+    
+</iarProjectConnection>
diff --git a/tools/top.mk b/tools/top.mk
new file mode 100644
index 0000000..84523a5
--- /dev/null
+++ b/tools/top.mk
@@ -0,0 +1,30 @@
+ifneq ($(lastword a b),b)
+$(error This Makefile require make 3.81 or newer)
+endif
+
+# Detect whether shell style is windows or not
+# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069
+ifeq '$(findstring ;,$(PATH))' ';'
+CMDEXE := 1
+endif
+
+# Set TOP to be the path to get from the current directory (where make was
+# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns
+# the name of this makefile relative to where make was invoked.
+
+THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
+TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE))
+
+ifeq ($(CMDEXE),1)
+TOP := $(subst \,/,$(shell for %%i in ( $(TOP) ) do echo %%~fi))
+else
+TOP := $(shell realpath $(TOP))
+endif
+#$(info Top directory is $(TOP))
+
+ifeq ($(CMDEXE),1)
+CURRENT_PATH := $(subst $(TOP)/,,$(subst \,/,$(shell echo %CD%)))
+else
+CURRENT_PATH := $(shell realpath --relative-to=$(TOP) `pwd`)
+endif
+#$(info Path from top is $(CURRENT_PATH))
diff --git a/tools/uf2 b/tools/uf2
new file mode 160000
index 0000000..1961540
--- /dev/null
+++ b/tools/uf2
@@ -0,0 +1 @@
+Subproject commit 19615407727073e36d81bf239c52108ba92e7660
diff --git a/tools/usb_drivers/tinyusb_win_usbser.inf b/tools/usb_drivers/tinyusb_win_usbser.inf
new file mode 100644
index 0000000..e7f7a9b
--- /dev/null
+++ b/tools/usb_drivers/tinyusb_win_usbser.inf
@@ -0,0 +1,108 @@
+;************************************************************
+; Windows USB CDC ACM Setup File
+; Copyright (c) 2000 Microsoft Corporation
+
+
+[Version]
+Signature="$Windows NT$"
+Class=Ports
+ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
+Provider=%MFGNAME%
+LayoutFile=layout.inf
+CatalogFile=%MFGFILENAME%.cat
+DriverVer=11/15/2007,5.1.2600.0
+DriverPackageDisplayName=%DESCRIPTION%
+
+[Manufacturer]
+%MFGNAME%=DeviceList, NTamd64
+
+[DestinationDirs]
+DefaultDestDir=12
+
+
+;------------------------------------------------------------------------------
+;  Windows 2000/XP/Vista-32bit Sections
+;------------------------------------------------------------------------------
+
+[DriverInstall.nt]
+include=mdmcpq.inf
+CopyFiles=DriverCopyFiles.nt
+AddReg=DriverInstall.nt.AddReg
+
+[DriverCopyFiles.nt]
+usbser.sys,,,0x20
+
+[DriverInstall.nt.AddReg]
+HKR,,DevLoader,,*ntkern
+HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
+
+[DriverInstall.nt.Services]
+AddService=usbser, 0x00000002, DriverService.nt
+
+[DriverService.nt]
+DisplayName=%SERVICE%
+ServiceType=1
+StartType=3
+ErrorControl=1
+ServiceBinary=%12%\%DRIVERFILENAME%.sys
+
+;------------------------------------------------------------------------------
+;  Vista-64bit Sections
+;------------------------------------------------------------------------------
+
+[DriverInstall.NTamd64]
+include=mdmcpq.inf
+CopyFiles=DriverCopyFiles.NTamd64
+AddReg=DriverInstall.NTamd64.AddReg
+
+[DriverCopyFiles.NTamd64]
+%DRIVERFILENAME%.sys,,,0x20
+
+[DriverInstall.NTamd64.AddReg]
+HKR,,DevLoader,,*ntkern
+HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
+
+[DriverInstall.NTamd64.Services]
+AddService=usbser, 0x00000002, DriverService.NTamd64
+
+[DriverService.NTamd64]
+DisplayName=%SERVICE%
+ServiceType=1
+StartType=3
+ErrorControl=1
+ServiceBinary=%12%\%DRIVERFILENAME%.sys
+
+
+;------------------------------------------------------------------------------
+;  Vendor and Product ID Definitions
+;------------------------------------------------------------------------------
+; When developing your USB device, the VID and PID used in the PC side
+; application program and the firmware on the microcontroller must match.
+; Modify the below line to use your VID and PID.  Use the format as shown below.
+; Note: One INF file can be used for multiple devices with different VID and PIDs.
+; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
+;------------------------------------------------------------------------------
+[SourceDisksFiles]
+[SourceDisksNames]
+[DeviceList]
+
+%DESCRIPTION%=DriverInstall, USB\VID_CAFE&PID_4001&MI_00, USB\VID_CAFE&PID_4003&MI_00, USB\VID_CAFE&PID_4005&MI_00, USB\VID_CAFE&PID_4007&MI_00, USB\VID_CAFE&PID_4009&MI_00, USB\VID_CAFE&PID_400b&MI_00, USB\VID_CAFE&PID_400d&MI_00, USB\VID_CAFE&PID_400f&MI_00, USB\VID_CAFE&PID_4011&MI_00, USB\VID_CAFE&PID_4013&MI_00, USB\VID_CAFE&PID_4015&MI_00, USB\VID_CAFE&PID_4017&MI_00, USB\VID_CAFE&PID_4019&MI_00, USB\VID_CAFE&PID_401b&MI_00, USB\VID_CAFE&PID_401d&MI_00, USB\VID_CAFE&PID_401f&MI_00, USB\VID_CAFE&PID_4021&MI_00, USB\VID_CAFE&PID_4023&MI_00, USB\VID_CAFE&PID_4025&MI_00, USB\VID_CAFE&PID_4027&MI_00, USB\VID_CAFE&PID_4029&MI_00, USB\VID_CAFE&PID_402b&MI_00, USB\VID_CAFE&PID_402d&MI_00, USB\VID_CAFE&PID_402f&MI_00, USB\VID_CAFE&PID_4031&MI_00, USB\VID_CAFE&PID_4033&MI_00, USB\VID_CAFE&PID_4035&MI_00, USB\VID_CAFE&PID_4037&MI_00, USB\VID_CAFE&PID_4039&MI_00, USB\VID_CAFE&PID_403b&MI_00, USB\VID_CAFE&PID_403d&MI_00, USB\VID_CAFE&PID_403f&MI_00
+
+
+[DeviceList.NTamd64]
+%DESCRIPTION%=DriverInstall, USB\VID_CAFE&PID_4001&MI_00, USB\VID_CAFE&PID_4003&MI_00, USB\VID_CAFE&PID_4005&MI_00, USB\VID_CAFE&PID_4007&MI_00, USB\VID_CAFE&PID_4009&MI_00, USB\VID_CAFE&PID_400b&MI_00, USB\VID_CAFE&PID_400d&MI_00, USB\VID_CAFE&PID_400f&MI_00, USB\VID_CAFE&PID_4011&MI_00, USB\VID_CAFE&PID_4013&MI_00, USB\VID_CAFE&PID_4015&MI_00, USB\VID_CAFE&PID_4017&MI_00, USB\VID_CAFE&PID_4019&MI_00, USB\VID_CAFE&PID_401b&MI_00, USB\VID_CAFE&PID_401d&MI_00, USB\VID_CAFE&PID_401f&MI_00, USB\VID_CAFE&PID_4021&MI_00, USB\VID_CAFE&PID_4023&MI_00, USB\VID_CAFE&PID_4025&MI_00, USB\VID_CAFE&PID_4027&MI_00, USB\VID_CAFE&PID_4029&MI_00, USB\VID_CAFE&PID_402b&MI_00, USB\VID_CAFE&PID_402d&MI_00, USB\VID_CAFE&PID_402f&MI_00, USB\VID_CAFE&PID_4031&MI_00, USB\VID_CAFE&PID_4033&MI_00, USB\VID_CAFE&PID_4035&MI_00, USB\VID_CAFE&PID_4037&MI_00, USB\VID_CAFE&PID_4039&MI_00, USB\VID_CAFE&PID_403b&MI_00, USB\VID_CAFE&PID_403d&MI_00, USB\VID_CAFE&PID_403f&MI_00
+
+;------------------------------------------------------------------------------
+;  String Definitions
+;------------------------------------------------------------------------------
+;Modify these strings to customize your device
+;------------------------------------------------------------------------------
+[Strings]
+MFGFILENAME="tinyusb_usbser"
+DRIVERFILENAME ="usbser"
+MFGNAME="tinyusb.org"
+INSTDISK="tinyusb CDC Driver"
+DESCRIPTION="tinyusb Serial"
+SERVICE="USB RS-232 Emulation Driver"
\ No newline at end of file