diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
commit | 4fd287655a72b9aea14cdac715ad5b90ed082ed2 (patch) | |
tree | 65d393bc0e699dd12d05b29ba568e04cea666207 /circuitpython/lib/tinyusb/tools | |
parent | 0150f70ce9c39e9e6dd878766c0620c85e47bed0 (diff) |
add circuitpython code
Diffstat (limited to 'circuitpython/lib/tinyusb/tools')
-rw-r--r-- | circuitpython/lib/tinyusb/tools/build_board.py | 100 | ||||
-rw-r--r-- | circuitpython/lib/tinyusb/tools/build_esp32sx.py | 101 | ||||
-rw-r--r-- | circuitpython/lib/tinyusb/tools/build_family.py | 113 | ||||
-rw-r--r-- | circuitpython/lib/tinyusb/tools/build_utils.py | 61 | ||||
-rw-r--r-- | circuitpython/lib/tinyusb/tools/iar_gen.py | 51 | ||||
-rw-r--r-- | circuitpython/lib/tinyusb/tools/iar_template.ipcf | 145 | ||||
-rw-r--r-- | circuitpython/lib/tinyusb/tools/mksunxi.py | 48 | ||||
-rw-r--r-- | circuitpython/lib/tinyusb/tools/top.mk | 30 | ||||
-rw-r--r-- | circuitpython/lib/tinyusb/tools/usb_drivers/tinyusb_win_usbser.inf | 108 |
9 files changed, 757 insertions, 0 deletions
diff --git a/circuitpython/lib/tinyusb/tools/build_board.py b/circuitpython/lib/tinyusb/tools/build_board.py new file mode 100644 index 0000000..b2a80c6 --- /dev/null +++ b/circuitpython/lib/tinyusb/tools/build_board.py @@ -0,0 +1,100 @@ +import os +import glob +import sys +import subprocess +import time + +import build_utils + +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 build_utils.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) + +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/circuitpython/lib/tinyusb/tools/build_esp32sx.py b/circuitpython/lib/tinyusb/tools/build_esp32sx.py new file mode 100644 index 0000000..2947a0a --- /dev/null +++ b/circuitpython/lib/tinyusb/tools/build_esp32sx.py @@ -0,0 +1,101 @@ +import os +import glob +import sys +import subprocess +import time + +import build_utils + +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 build_utils.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) + +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/circuitpython/lib/tinyusb/tools/build_family.py b/circuitpython/lib/tinyusb/tools/build_family.py new file mode 100644 index 0000000..4094d07 --- /dev/null +++ b/circuitpython/lib/tinyusb/tools/build_family.py @@ -0,0 +1,113 @@ +import os +import glob +import sys +import subprocess +import time + +import build_utils + +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 not in ("esp32s2", "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 build_utils.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) + +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/circuitpython/lib/tinyusb/tools/build_utils.py b/circuitpython/lib/tinyusb/tools/build_utils.py new file mode 100644 index 0000000..299fffa --- /dev/null +++ b/circuitpython/lib/tinyusb/tools/build_utils.py @@ -0,0 +1,61 @@ +import pathlib + +def skip_example(example, board): + ex_dir = pathlib.Path('examples/') / example + bsp = pathlib.Path("hw/bsp") + + board_dir = list(bsp.glob("*/boards/" + board)) + if not board_dir: + # Skip unknown boards + return True + + board_dir = list(board_dir)[0] + + family_dir = board_dir.parent.parent + family = family_dir.name + + # family CMake + family_mk = family_dir / "family.cmake" + + # family.mk + if not family_mk.exists(): + family_mk = family_dir / "family.mk" + + mk_contents = family_mk.read_text() + + # Find the mcu + if "CFG_TUSB_MCU=OPT_MCU_" not in mk_contents: + board_mk = board_dir / "board.cmake" + if not board_mk.exists(): + board_mk = board_dir / "board.mk" + + mk_contents = board_mk.read_text() + + for token in mk_contents.split(): + if "CFG_TUSB_MCU=OPT_MCU_" in token: + # Strip " because cmake files has them. + token = token.strip("\"") + _, opt_mcu = token.split("=") + mcu = opt_mcu[len("OPT_MCU_"):] + + # Skip all OPT_MCU_NONE these are WIP port + if mcu == "NONE": + return True + + skip_file = ex_dir / "skip.txt" + only_file = ex_dir / "only.txt" + + if skip_file.exists() and only_file.exists(): + raise RuntimeError("Only have a skip or only file. Not both.") + elif skip_file.exists(): + skips = skip_file.read_text().split() + return ("mcu:" + mcu in skips or + "board:" + board in skips or + "family:" + family in skips) + elif only_file.exists(): + onlys = only_file.read_text().split() + return not ("mcu:" + mcu in onlys or + "board:" + board in onlys or + "family:" + family in onlys) + + return False diff --git a/circuitpython/lib/tinyusb/tools/iar_gen.py b/circuitpython/lib/tinyusb/tools/iar_gen.py new file mode 100644 index 0000000..73c8b29 --- /dev/null +++ b/circuitpython/lib/tinyusb/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/circuitpython/lib/tinyusb/tools/iar_template.ipcf b/circuitpython/lib/tinyusb/tools/iar_template.ipcf new file mode 100644 index 0000000..ba54fe0 --- /dev/null +++ b/circuitpython/lib/tinyusb/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/circuitpython/lib/tinyusb/tools/mksunxi.py b/circuitpython/lib/tinyusb/tools/mksunxi.py new file mode 100644 index 0000000..04786f4 --- /dev/null +++ b/circuitpython/lib/tinyusb/tools/mksunxi.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +import sys +import struct + +def align(num, alignment): + if num % alignment != 0: + num += (alignment - num % alignment) + return num + + +def process_file(input, output): + with open(input, 'rb') as fin: + content = bytearray(fin.read()) + + align_value = 512 + padded_length = align(len(content), align_value) + # pad file to actual length + content += b'\x00' * (padded_length - len(content)) + + struct_format = '<L8sLL' + (instruction, magic, checksum, length) = struct.unpack_from(struct_format, content) + + if magic != b'eGON.BT0': + print("Magic is invalid:", magic) + return 2 + + checksum = 0x5F0A6C39 + length = align(length, align_value) + + struct.pack_into(struct_format, content, 0, instruction, magic, checksum, length) + + checksum = 0 + for i in range(0, length, 4): + (n, ) = struct.unpack_from('<L', content, i) + checksum += n + checksum %= 4294967296 + + struct.pack_into(struct_format, content, 0, instruction, magic, checksum, length) + + with open(output, 'wb') as fout: + fout.write(content) + return 0 + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: mksunxi.py input.bin output.bin") + exit(1) + exit(process_file(sys.argv[1], sys.argv[2]))
\ No newline at end of file diff --git a/circuitpython/lib/tinyusb/tools/top.mk b/circuitpython/lib/tinyusb/tools/top.mk new file mode 100644 index 0000000..84523a5 --- /dev/null +++ b/circuitpython/lib/tinyusb/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/circuitpython/lib/tinyusb/tools/usb_drivers/tinyusb_win_usbser.inf b/circuitpython/lib/tinyusb/tools/usb_drivers/tinyusb_win_usbser.inf new file mode 100644 index 0000000..e7f7a9b --- /dev/null +++ b/circuitpython/lib/tinyusb/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 |