diff options
| author | hathach <[email protected]> | 2025-02-12 11:28:16 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-02-12 11:28:16 +0700 |
| commit | 87adc63226a59e6c2602b1bc453ced77d44fedba (patch) | |
| tree | 1e47a80bfab09dbac47312b4242939df03ec7796 /tools | |
| parent | b41f5eadb3143d0bfaf211d9bc84c95e5d623c29 (diff) | |
| parent | 5afcfb7522c4fd8b50512cfb277d8a3ccdbc5453 (diff) | |
Merge branch 'master' into fork/atoktoto/midihost
# Conflicts:
# hw/bsp/rp2040/family.cmake
# src/class/midi/midi.h
# src/class/midi/midi_device.c
# src/device/usbd_control.c
# src/host/hcd.h
# src/host/usbh.c
# src/host/usbh.h
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/build.py | 268 | ||||
| -rw-r--r-- | tools/build_board.py | 69 | ||||
| -rw-r--r-- | tools/build_esp32sx.py | 101 | ||||
| -rw-r--r-- | tools/build_family.py | 74 | ||||
| -rwxr-xr-x[-rw-r--r--] | tools/build_utils.py | 144 | ||||
| -rw-r--r-- | tools/codespell/exclude-file.txt | 0 | ||||
| -rw-r--r-- | tools/codespell/ignore-words.txt | 14 | ||||
| -rwxr-xr-x | tools/gen_doc.py | 117 | ||||
| -rw-r--r-- | tools/get_dependencies.py | 25 | ||||
| -rwxr-xr-x | tools/get_deps.py | 309 | ||||
| -rwxr-xr-x[-rw-r--r--] | tools/iar_gen.py | 128 | ||||
| -rw-r--r-- | tools/iar_template.ipcf | 391 | ||||
| -rwxr-xr-x | tools/make_release.py | 53 | ||||
| -rwxr-xr-x[-rw-r--r--] | tools/mksunxi.py | 2 | ||||
| -rwxr-xr-x | tools/pcapng_to_corpus.py | 44 | ||||
| -rw-r--r-- | tools/top.mk | 30 | ||||
| m--------- | tools/uf2 | 0 | ||||
| -rw-r--r-- | tools/usb_drivers/tinyusb_win_usbser.inf | 2 |
18 files changed, 1209 insertions, 562 deletions
diff --git a/tools/build.py b/tools/build.py new file mode 100755 index 000000000..633d2b582 --- /dev/null +++ b/tools/build.py @@ -0,0 +1,268 @@ +#!/usr/bin/env python3 +import argparse +import random +import os +import sys +import time +import subprocess +from pathlib import Path +from multiprocessing import Pool + +import build_utils + +STATUS_OK = "\033[32mOK\033[0m" +STATUS_FAILED = "\033[31mFailed\033[0m" +STATUS_SKIPPED = "\033[33mSkipped\033[0m" + +RET_OK = 0 +RET_FAILED = 1 +RET_SKIPPED = 2 + +build_format = '| {:30} | {:40} | {:16} | {:5} |' +build_separator = '-' * 95 +build_status = [STATUS_OK, STATUS_FAILED, STATUS_SKIPPED] + +verbose = False + +# ----------------------------- +# Helper +# ----------------------------- +def run_cmd(cmd): + #print(cmd) + r = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + title = f'Command Error: {cmd}' + if r.returncode != 0: + # print build output if failed + if os.getenv('GITHUB_ACTIONS'): + print(f"::group::{title}") + print(r.stdout.decode("utf-8")) + print(f"::endgroup::") + else: + print(title) + print(r.stdout.decode("utf-8")) + elif verbose: + print(cmd) + print(r.stdout.decode("utf-8")) + return r + + +def find_family(board): + bsp_dir = Path("hw/bsp") + for family_dir in bsp_dir.iterdir(): + if family_dir.is_dir(): + board_dir = family_dir / 'boards' / board + if board_dir.exists(): + return family_dir.name + return None + + +def get_examples(family): + all_examples = [] + for d in os.scandir("examples"): + if d.is_dir() and 'cmake' not in d.name and 'build_system' not in d.name: + for entry in os.scandir(d.path): + if entry.is_dir() and 'cmake' not in entry.name: + if family != 'espressif' or 'freertos' in entry.name: + all_examples.append(d.name + '/' + entry.name) + + if family == 'espressif': + all_examples.append('device/board_test') + all_examples.append('device/video_capture') + all_examples.append('host/device_info') + all_examples.sort() + return all_examples + + +def print_build_result(board, example, status, duration): + if isinstance(duration, (int, float)): + duration = "{:.2f}s".format(duration) + print(build_format.format(board, example, build_status[status], duration)) + +# ----------------------------- +# CMake +# ----------------------------- +def cmake_board(board, toolchain, build_flags_on): + ret = [0, 0, 0] + start_time = time.monotonic() + + build_dir = f'cmake-build/cmake-build-{board}' + build_flags = '' + if len(build_flags_on) > 0: + build_flags = ' '.join(f'-D{flag}=1' for flag in build_flags_on) + build_flags = f'-DCFLAGS_CLI="{build_flags}"' + build_dir += '-f1_' + '_'.join(build_flags_on) + + family = find_family(board) + if family == 'espressif': + # for espressif, we have to build example individually + all_examples = get_examples(family) + for example in all_examples: + if build_utils.skip_example(example, board): + ret[2] += 1 + else: + rcmd = run_cmd(f'cmake examples/{example} -B {build_dir}/{example} -G "Ninja" ' + f'-DBOARD={board} {build_flags}') + if rcmd.returncode == 0: + rcmd = run_cmd(f'cmake --build {build_dir}/{example}') + ret[0 if rcmd.returncode == 0 else 1] += 1 + else: + rcmd = run_cmd(f'cmake examples -B {build_dir} -G "Ninja" -DBOARD={board} -DCMAKE_BUILD_TYPE=MinSizeRel ' + f'-DTOOLCHAIN={toolchain} {build_flags}') + if rcmd.returncode == 0: + cmd = f"cmake --build {build_dir}" + # circleci docker return $nproc as 36 core, limit parallel according to resource class. Required for IAR, also prevent crashed/killed by docker + if os.getenv('CIRCLECI'): + resource_class = { 'small': 1, 'medium': 2, 'medium+': 3, 'large': 4 } + for rc in resource_class: + if rc in os.getenv('CIRCLE_JOB'): + cmd += f' --parallel {resource_class[rc]}' + break + rcmd = run_cmd(cmd) + ret[0 if rcmd.returncode == 0 else 1] += 1 + + example = 'all' + print_build_result(board, example, 0 if ret[1] == 0 else 1, time.monotonic() - start_time) + return ret + + +# ----------------------------- +# Make +# ----------------------------- +def make_one_example(example, board, make_option): + # Check if board is skipped + if build_utils.skip_example(example, board): + print_build_result(board, example, 2, '-') + r = 2 + else: + start_time = time.monotonic() + # skip -j for circleci + if not os.getenv('CIRCLECI'): + make_option += ' -j' + make_cmd = f"make -C examples/{example} BOARD={board} {make_option}" + # run_cmd(f"{make_cmd} clean") + build_result = run_cmd(f"{make_cmd} all") + r = 0 if build_result.returncode == 0 else 1 + print_build_result(board, example, r, time.monotonic() - start_time) + + ret = [0, 0, 0] + ret[r] = 1 + return ret + + +def make_board(board, toolchain): + print(build_separator) + all_examples = get_examples(find_family(board)) + start_time = time.monotonic() + ret = [0, 0, 0] + with Pool(processes=os.cpu_count()) as pool: + pool_args = list((map(lambda e, b=board, o=f"TOOLCHAIN={toolchain}": [e, b, o], all_examples))) + r = pool.starmap(make_one_example, pool_args) + # sum all element of same index (column sum) + ret = list(map(sum, list(zip(*r)))) + example = 'all' + print_build_result(board, example, 0 if ret[1] == 0 else 1, time.monotonic() - start_time) + return ret + + +# ----------------------------- +# Build Family +# ----------------------------- +def build_boards_list(boards, toolchain, build_system, build_flags_on): + ret = [0, 0, 0] + for b in boards: + r = [0, 0, 0] + if build_system == 'cmake': + r = cmake_board(b, toolchain, build_flags_on) + elif build_system == 'make': + r = make_board(b, toolchain) + ret[0] += r[0] + ret[1] += r[1] + ret[2] += r[2] + return ret + + +def build_family(family, toolchain, build_system, build_flags_on, one_per_family, boards): + all_boards = [] + for entry in os.scandir(f"hw/bsp/{family}/boards"): + if entry.is_dir() and entry.name != 'pico_sdk': + all_boards.append(entry.name) + all_boards.sort() + + ret = [0, 0, 0] + # If only-one flag is set, select one random board + if one_per_family: + for b in boards: + # skip if -b already specify one in this family + if find_family(b) == family: + return ret + all_boards = [random.choice(all_boards)] + + ret = build_boards_list(all_boards, toolchain, build_system, build_flags_on) + return ret + + +# ----------------------------- +# Main +# ----------------------------- +def main(): + global verbose + + parser = argparse.ArgumentParser() + parser.add_argument('families', nargs='*', default=[], help='Families to build') + parser.add_argument('-b', '--board', action='append', default=[], help='Boards to build') + parser.add_argument('-t', '--toolchain', default='gcc', help='Toolchain to use, default is gcc') + parser.add_argument('-s', '--build-system', default='cmake', help='Build system to use, default is cmake') + parser.add_argument('-f1', '--build-flags-on', action='append', default=[], help='Build flag to pass to build system') + parser.add_argument('-1', '--one-per-family', action='store_true', default=False, help='Build only one random board inside a family') + parser.add_argument('-v', '--verbose', action='store_true', help='Verbose output') + args = parser.parse_args() + + families = args.families + boards = args.board + toolchain = args.toolchain + build_system = args.build_system + build_flags_on = args.build_flags_on + one_per_family = args.one_per_family + verbose = args.verbose + + if len(families) == 0 and len(boards) == 0: + print("Please specify families or board to build") + return 1 + + print(build_separator) + print(build_format.format('Board', 'Example', '\033[39mResult\033[0m', 'Time')) + total_time = time.monotonic() + result = [0, 0, 0] + + # build families + all_families = [] + if 'all' in families: + for entry in os.scandir("hw/bsp"): + if entry.is_dir() and entry.name != 'espressif' and os.path.isfile(entry.path + "/family.cmake"): + all_families.append(entry.name) + else: + all_families = list(families) + all_families.sort() + + # succeeded, failed, skipped + for f in all_families: + r = build_family(f, toolchain, build_system, build_flags_on, one_per_family, boards) + result[0] += r[0] + result[1] += r[1] + result[2] += r[2] + + # build boards + r = build_boards_list(boards, toolchain, build_system, build_flags_on) + result[0] += r[0] + result[1] += r[1] + result[2] += r[2] + + total_time = time.monotonic() - total_time + print(build_separator) + print(f"Build Summary: {result[0]} {STATUS_OK}, {result[1]} {STATUS_FAILED} and took {total_time:.2f}s") + print(build_separator) + return result[1] + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools/build_board.py b/tools/build_board.py deleted file mode 100644 index 8d10ef820..000000000 --- a/tools/build_board.py +++ /dev/null @@ -1,69 +0,0 @@ -import os -import sys -import time -import subprocess -from multiprocessing import Pool - -import build_utils - -SUCCEEDED = "\033[32msucceeded\033[0m" -FAILED = "\033[31mfailed\033[0m" -SKIPPED = "\033[33mskipped\033[0m" - -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 __name__ == '__main__': - # If examples are not specified in arguments, build all - all_examples = [] - for dir1 in os.scandir("examples"): - if dir1.is_dir(): - for entry in os.scandir(dir1.path): - if entry.is_dir(): - all_examples.append(dir1.name + '/' + 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() - - # Get dependencies - for b in all_boards: - subprocess.run("make -C examples/device/board_test BOARD={} get-deps".format(b), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - - print(build_separator) - print(build_utils.build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM')) - total_time = time.monotonic() - - # succeeded, failed, skipped - total_result = [0, 0, 0] - for example in all_examples: - print(build_separator) - with Pool(processes=os.cpu_count()) as pool: - pool_args = list((map(lambda b, e=example: [e, b], all_boards))) - result = pool.starmap(build_utils.build_example, pool_args) - # sum all element of same index (column sum) - result = list(map(sum, list(zip(*result)))) - - # add to total result - total_result = list(map(lambda x, y: x + y, total_result, result)) - - total_time = time.monotonic() - total_time - print(build_separator) - print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(total_result[0], SUCCEEDED, total_result[1], - FAILED, total_result[2], SKIPPED, total_time)) - print(build_separator) - - sys.exit(total_result[1]) diff --git a/tools/build_esp32sx.py b/tools/build_esp32sx.py deleted file mode 100644 index 2947a0a6b..000000000 --- a/tools/build_esp32sx.py +++ /dev/null @@ -1,101 +0,0 @@ -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/tools/build_family.py b/tools/build_family.py deleted file mode 100644 index c6c64d2b3..000000000 --- a/tools/build_family.py +++ /dev/null @@ -1,74 +0,0 @@ -import os -import sys -import time -from multiprocessing import Pool - -import build_utils - -SUCCEEDED = "\033[32msucceeded\033[0m" -FAILED = "\033[31mfailed\033[0m" -SKIPPED = "\033[33mskipped\033[0m" - -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 - - -def build_family(example, family): - all_boards = [] - for entry in os.scandir("hw/bsp/{}/boards".format(family)): - if entry.is_dir() and entry.name != 'pico_sdk': - all_boards.append(entry.name) - filter_with_input(all_boards) - all_boards.sort() - - with Pool(processes=os.cpu_count()) as pool: - pool_args = list((map(lambda b, e=example: [e, b], all_boards))) - result = pool.starmap(build_utils.build_example, pool_args) - # sum all element of same index (column sum) - return list(map(sum, list(zip(*result)))) - - -if __name__ == '__main__': - # If examples are not specified in arguments, build all - all_examples = [] - for dir1 in os.scandir("examples"): - if dir1.is_dir(): - for entry in os.scandir(dir1.path): - if entry.is_dir(): - all_examples.append(dir1.name + '/' + 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() - - print(build_separator) - print(build_utils.build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM')) - total_time = time.monotonic() - - # succeeded, failed, skipped - total_result = [0, 0, 0] - for example in all_examples: - print(build_separator) - for family in all_families: - fret = build_family(example, family) - total_result = list(map(lambda x, y: x + y, total_result, fret)) - - total_time = time.monotonic() - total_time - print(build_separator) - print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(total_result[0], SUCCEEDED, total_result[1], - FAILED, total_result[2], SKIPPED, total_time)) - print(build_separator) - - sys.exit(total_result[1]) diff --git a/tools/build_utils.py b/tools/build_utils.py index f457c7986..2998f940d 100644..100755 --- a/tools/build_utils.py +++ b/tools/build_utils.py @@ -1,6 +1,7 @@ +#!/usr/bin/env python3 import subprocess import pathlib -import time +import re build_format = '| {:29} | {:30} | {:18} | {:7} | {:6} | {:6} |' @@ -13,110 +14,83 @@ def skip_example(example, board): ex_dir = pathlib.Path('examples/') / example bsp = pathlib.Path("hw/bsp") - if (bsp / board / "board.mk").exists(): - # board without family - board_dir = bsp / board - family = "" - mk_contents = "" - else: - # board within family - 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" + # board within family + board_dir = list(bsp.glob("*/boards/" + board)) + if not board_dir: + # Skip unknown boards + return True - # family.mk - if not family_mk.exists(): - family_mk = family_dir / "family.mk" + board_dir = list(board_dir)[0] + family_dir = board_dir.parent.parent + family = family_dir.name - mk_contents = family_mk.read_text() + # family.mk + family_mk = family_dir / "family.mk" + mk_contents = family_mk.read_text() # Find the mcu, first in family mk then board mk if "CFG_TUSB_MCU=OPT_MCU_" not in mk_contents: - board_mk = board_dir / "board.cmake" + board_mk = board_dir / "board.mk" if not board_mk.exists(): - board_mk = board_dir / "board.mk" - + board_mk = board_dir / "board.cmake" 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_"):] + mcu = "NONE" + if family == "espressif": + for line in mk_contents.splitlines(): + match = re.search(r'set\(IDF_TARGET\s+"([^"]+)"\)', line) + if match: + mcu = match.group(1).upper() + break + else: + 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_"):] + if mcu != "NONE": + break # Skip all OPT_MCU_NONE these are WIP port if mcu == "NONE": return True + max3421_enabled = False + for line in mk_contents.splitlines(): + if "MAX3421_HOST=1" in line or 'MAX3421_HOST 1' in line: + max3421_enabled = True + break + 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(): + if 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(): + if ("mcu:" + mcu in skips or + "board:" + board in skips or + "family:" + family in skips): + return True + + if 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) + if not ("mcu:" + mcu in onlys or + ("mcu:MAX3421" in onlys and max3421_enabled) or + "board:" + board in onlys or + "family:" + family in onlys): + return True return False -def build_example(example, board): - start_time = time.monotonic() - flash_size = "-" - sram_size = "-" - - # succeeded, failed, skipped - ret = [0, 0, 0] - - # Check if board is skipped - if skip_example(example, board): - status = SKIPPED - ret[2] = 1 - print(build_format.format(example, board, status, '-', flash_size, sram_size)) - else: - 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: - status = SUCCEEDED - ret[0] = 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: - status = FAILED - ret[1] = 1 - - build_duration = time.monotonic() - start_time - print(build_format.format(example, board, status, "{:.2f}s".format(build_duration), flash_size, sram_size)) - - if build_result.returncode != 0: - print(build_result.stdout.decode("utf-8")) - - return ret - +def build_size(make_cmd): + size_output = subprocess.run(make_cmd + ' size', shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8").splitlines() + for i, l in enumerate(size_output): + text_title = 'text data bss dec' + if text_title in l: + size_list = size_output[i+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 build_size(example, 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) + return (0, 0) diff --git a/tools/codespell/exclude-file.txt b/tools/codespell/exclude-file.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tools/codespell/exclude-file.txt diff --git a/tools/codespell/ignore-words.txt b/tools/codespell/ignore-words.txt new file mode 100644 index 000000000..957cbd86b --- /dev/null +++ b/tools/codespell/ignore-words.txt @@ -0,0 +1,14 @@ +synopsys +sie +tre +thre +hsi +fro +dout +mot +te +attch +endianess +pris +busses +ser diff --git a/tools/gen_doc.py b/tools/gen_doc.py new file mode 100755 index 000000000..ab07bc116 --- /dev/null +++ b/tools/gen_doc.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +import re +import pandas as pd +from tabulate import tabulate +from pathlib import Path +from get_deps import deps_all + +# TOP is tinyusb root dir +TOP = Path(__file__).parent.parent.resolve() + + +# ----------------------------------------- +# Dependencies +# ----------------------------------------- +def gen_deps_doc(): + deps_rst = Path(TOP) / "docs/reference/dependencies.rst" + df = pd.DataFrame.from_dict(deps_all, orient='index', columns=['Repo', 'Commit', 'Required by']) + df = df[['Repo', 'Commit', 'Required by']].sort_index() + df = df.rename_axis("Local Path") + + outstr = f"""\ +************ +Dependencies +************ + +MCU low-level peripheral driver and external libraries for building TinyUSB examples + +{tabulate(df, headers="keys", tablefmt='rst')} +""" + + with deps_rst.open('w') as f: + f.write(outstr) + + +# ----------------------------------------- +# Dependencies +# ----------------------------------------- +def extract_metadata(file_path): + metadata = {} + try: + with open(file_path, 'r') as file: + content = file.read() + # Match metadata block + match = re.search(r'/\*\s*metadata:(.*?)\*/', content, re.DOTALL) + if match: + block = match.group(1) + # Extract key-value pairs + for line in block.splitlines(): + key_value = re.match(r'\s*(\w+):\s*(.+)', line) + if key_value: + key, value = key_value.groups() + metadata[key] = value.strip() + except FileNotFoundError: + pass + return metadata + + +def gen_boards_doc(): + # 'Manufacturer' : { 'Board' } + vendor_data = {} + # 'Board' : [ 'Name', 'Family', 'url', 'note' ] + all_boards = {} + # extract metadata from family.c + for family_dir in sorted((Path(TOP) / "hw/bsp").iterdir()): + if family_dir.is_dir(): + family_c = family_dir / "family.c" + if not family_c.exists(): + family_c = family_dir / "boards/family.c" + f_meta = extract_metadata(family_c) + if not f_meta: + continue + manuf = f_meta.get('manufacturer', '') + if manuf not in vendor_data: + vendor_data[manuf] = {} + # extract metadata from board.h + for board_dir in sorted((family_dir / "boards").iterdir()): + if board_dir.is_dir(): + b_meta = extract_metadata(board_dir / "board.h") + if not b_meta: + continue + b_entry = [ + b_meta.get('name', ''), + family_dir.name, + b_meta.get('url', ''), + b_meta.get('note', '') + ] + vendor_data[manuf][board_dir.name] = b_entry + boards_rst = Path(TOP) / "docs/reference/boards.rst" + with boards_rst.open('w') as f: + title = f"""\ +**************** +Supported Boards +**************** + +The board support code is only used for self-contained examples and testing. It is not used when TinyUSB is part of a larger project. +It is responsible for getting the MCU started and the USB peripheral clocked with minimal of on-board devices + +- One LED : for status +- One Button : to get input from user +- One UART : needed for logging with LOGGER=uart, maybe required for host/dual examples + +Following boards are supported""" + f.write(title) + for manuf, boards in sorted(vendor_data.items()): + f.write(f"\n\n{manuf}\n") + f.write(f"{'-' * len(manuf)}\n\n") + df = pd.DataFrame.from_dict(boards, orient='index', columns=['Name', 'Family', 'URL', 'Note']) + df = df.rename_axis("Board") + f.write(tabulate(df, headers="keys", tablefmt='rst')) + + +# ----------------------------------------- +# Main +# ----------------------------------------- +if __name__ == "__main__": + gen_deps_doc() + gen_boards_doc() diff --git a/tools/get_dependencies.py b/tools/get_dependencies.py deleted file mode 100644 index e7d3e0a76..000000000 --- a/tools/get_dependencies.py +++ /dev/null @@ -1,25 +0,0 @@ -import os -import sys -import subprocess - - -# dependency lookup (ABC sorted) -# deps = { -# 'LPC11UXX' : [ [] ] -# } - - -def get_family_dep(family): - for entry in os.scandir("hw/bsp/{}/boards".format(family)): - if entry.is_dir(): - result = subprocess.run("make -C examples/device/board_test BOARD={} get-deps".format(entry.name), - shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - print(result.stdout.decode("utf-8")) - return result.returncode - -status = 0 -all_family = sys.argv[1:] -for f in all_family: - status += get_family_dep(f) - -sys.exit(status)
\ No newline at end of file diff --git a/tools/get_deps.py b/tools/get_deps.py new file mode 100755 index 000000000..c8459c1f1 --- /dev/null +++ b/tools/get_deps.py @@ -0,0 +1,309 @@ +#!/usr/bin/env python3 +import argparse +import sys +import subprocess +from pathlib import Path +from multiprocessing import Pool + +# Mandatory Dependencies that is always fetched +# path, url, commit, family (Alphabet sorted by path) +deps_mandatory = { + 'lib/FreeRTOS-Kernel': ['https://github.com/FreeRTOS/FreeRTOS-Kernel.git', + 'cc0e0707c0c748713485b870bb980852b210877f', + 'all'], + 'lib/lwip': ['https://github.com/lwip-tcpip/lwip.git', + '159e31b689577dbf69cf0683bbaffbd71fa5ee10', + 'all'], + 'tools/uf2': ['https://github.com/microsoft/uf2.git', + 'c594542b2faa01cc33a2b97c9fbebc38549df80a', + 'all'], +} + +# Optional Dependencies per MCU +# path, url, commit, family (Alphabet sorted by path) +deps_optional = { + 'hw/mcu/allwinner': ['https://github.com/hathach/allwinner_driver.git', + '8e5e89e8e132c0fd90e72d5422e5d3d68232b756', + 'fc100s'], + 'hw/mcu/analog/max32' : ['https://github.com/analogdevicesinc/msdk.git', + 'b20b398d3e5e2007594e54a74ba3d2a2e50ddd75', + 'max32650 max32666 max32690 max78002'], + 'hw/mcu/bridgetek/ft9xx/ft90x-sdk': ['https://github.com/BRTSG-FOSS/ft90x-sdk.git', + '91060164afe239fcb394122e8bf9eb24d3194eb1', + 'brtmm90x'], + 'hw/mcu/broadcom': ['https://github.com/adafruit/broadcom-peripherals.git', + '08370086080759ed54ac1136d62d2ad24c6fa267', + 'broadcom_32bit broadcom_64bit'], + 'hw/mcu/gd/nuclei-sdk': ['https://github.com/Nuclei-Software/nuclei-sdk.git', + '7eb7bfa9ea4fbeacfafe1d5f77d5a0e6ed3922e7', + 'gd32vf103'], + 'hw/mcu/infineon/mtb-xmclib-cat3': ['https://github.com/Infineon/mtb-xmclib-cat3.git', + 'daf5500d03cba23e68c2f241c30af79cd9d63880', + 'xmc4000'], + 'hw/mcu/microchip': ['https://github.com/hathach/microchip_driver.git', + '9e8b37e307d8404033bb881623a113931e1edf27', + 'sam3x samd11 samd21 samd51 samd5x_e5x same5x same7x saml2x samg'], + 'hw/mcu/mindmotion/mm32sdk': ['https://github.com/hathach/mm32sdk.git', + 'b93e856211060ae825216c6a1d6aa347ec758843', + 'mm32'], + 'hw/mcu/nordic/nrfx': ['https://github.com/NordicSemiconductor/nrfx.git', + '7c47cc0a56ce44658e6da2458e86cd8783ccc4a2', + 'nrf'], + 'hw/mcu/nuvoton': ['https://github.com/majbthrd/nuc_driver.git', + '2204191ec76283371419fbcec207da02e1bc22fa', + 'nuc'], + 'hw/mcu/nxp/lpcopen': ['https://github.com/hathach/nxp_lpcopen.git', + 'b41cf930e65c734d8ec6de04f1d57d46787c76ae', + 'lpc11 lpc13 lpc15 lpc17 lpc18 lpc40 lpc43'], + 'hw/mcu/nxp/mcux-sdk': ['https://github.com/hathach/mcux-sdk.git', + '144f1eb7ea8c06512e12f12b27383601c0272410', + 'kinetis_k kinetis_k32l2 kinetis_kl lpc51 lpc54 lpc55 mcx imxrt'], + 'hw/mcu/raspberry_pi/Pico-PIO-USB': ['https://github.com/sekigon-gonnoc/Pico-PIO-USB.git', + 'fe9133fc513b82cc3dc62c67cb51f2339cf29ef7', + 'rp2040'], + 'hw/mcu/renesas/fsp': ['https://github.com/renesas/fsp.git', + 'edcc97d684b6f716728a60d7a6fea049d9870bd6', + 'ra'], + 'hw/mcu/renesas/rx': ['https://github.com/kkitayam/rx_device.git', + '706b4e0cf485605c32351e2f90f5698267996023', + 'rx'], + 'hw/mcu/silabs/cmsis-dfp-efm32gg12b': ['https://github.com/cmsis-packs/cmsis-dfp-efm32gg12b.git', + 'f1c31b7887669cb230b3ea63f9b56769078960bc', + 'efm32'], + 'hw/mcu/sony/cxd56/spresense-exported-sdk': ['https://github.com/sonydevworld/spresense-exported-sdk.git', + '2ec2a1538362696118dc3fdf56f33dacaf8f4067', + 'spresense'], + 'hw/mcu/st/cmsis_device_c0': ['https://github.com/STMicroelectronics/cmsis_device_c0.git', + 'fb56b1b70c73b74eacda2a4bcc36886444364ab3', + 'stm32c0'], + 'hw/mcu/st/cmsis_device_f0': ['https://github.com/STMicroelectronics/cmsis_device_f0.git', + '2fc25ee22264bc27034358be0bd400b893ef837e', + 'stm32f0'], + 'hw/mcu/st/cmsis_device_f1': ['https://github.com/STMicroelectronics/cmsis_device_f1.git', + '6601104a6397299b7304fd5bcd9a491f56cb23a6', + 'stm32f1'], + 'hw/mcu/st/cmsis_device_f2': ['https://github.com/STMicroelectronics/cmsis_device_f2.git', + '182fcb3681ce116816feb41b7764f1b019ce796f', + 'stm32f2'], + 'hw/mcu/st/cmsis_device_f3': ['https://github.com/STMicroelectronics/cmsis_device_f3.git', + '5e4ee5ed7a7b6c85176bb70a9fd3c72d6eb99f1b', + 'stm32f3'], + 'hw/mcu/st/cmsis_device_f4': ['https://github.com/STMicroelectronics/cmsis_device_f4.git', + '2615e866fa48fe1ff1af9e31c348813f2b19e7ec', + 'stm32f4'], + 'hw/mcu/st/cmsis_device_f7': ['https://github.com/STMicroelectronics/cmsis_device_f7.git', + '25b0463439303b7a38f0d27b161f7d2f3c096e79', + 'stm32f7'], + 'hw/mcu/st/cmsis_device_g0': ['https://github.com/STMicroelectronics/cmsis_device_g0.git', + '3a23e1224417f3f2d00300ecd620495e363f2094', + 'stm32g0'], + 'hw/mcu/st/cmsis_device_g4': ['https://github.com/STMicroelectronics/cmsis_device_g4.git', + 'ce822adb1dc552b3aedd13621edbc7fdae124878', + 'stm32g4'], + 'hw/mcu/st/cmsis_device_h7': ['https://github.com/STMicroelectronics/cmsis_device_h7.git', + '60dc2c913203dc8629dc233d4384dcc41c91e77f', + 'stm32h7'], + 'hw/mcu/st/cmsis_device_h5': ['https://github.com/STMicroelectronics/cmsis_device_h5.git', + 'cd2d1d579743de57b88ccaf61a968b9c05848ffc', + 'stm32h5'], + 'hw/mcu/st/cmsis_device_l0': ['https://github.com/STMicroelectronics/cmsis_device_l0.git', + '69cd5999fd40ae6e546d4905b21635c6ca1bcb92', + 'stm32l0'], + 'hw/mcu/st/cmsis_device_l1': ['https://github.com/STMicroelectronics/cmsis_device_l1.git', + '7f16ec0a1c4c063f84160b4cc6bf88ad554a823e', + 'stm32l1'], + 'hw/mcu/st/cmsis_device_l4': ['https://github.com/STMicroelectronics/cmsis_device_l4.git', + '6ca7312fa6a5a460b5a5a63d66da527fdd8359a6', + 'stm32l4'], + 'hw/mcu/st/cmsis_device_l5': ['https://github.com/STMicroelectronics/cmsis_device_l5.git', + 'd922865fc0326a102c26211c44b8e42f52c1e53d', + 'stm32l5'], + 'hw/mcu/st/cmsis_device_u5': ['https://github.com/STMicroelectronics/cmsis_device_u5.git', + '5ad9797c54ec3e55eff770fc9b3cd4a1aefc1309', + 'stm32u5'], + 'hw/mcu/st/cmsis_device_wb': ['https://github.com/STMicroelectronics/cmsis_device_wb.git', + '9c5d1920dd9fabbe2548e10561d63db829bb744f', + 'stm32wb'], + 'hw/mcu/st/stm32-mfxstm32l152': ['https://github.com/STMicroelectronics/stm32-mfxstm32l152.git', + '7f4389efee9c6a655b55e5df3fceef5586b35f9b', + 'stm32h7'], + 'hw/mcu/st/stm32c0xx_hal_driver': ['https://github.com/STMicroelectronics/stm32c0xx_hal_driver.git', + '41253e2f1d7ae4a4d0c379cf63f5bcf71fcf8eb3', + 'stm32c0'], + 'hw/mcu/st/stm32f0xx_hal_driver': ['https://github.com/STMicroelectronics/stm32f0xx_hal_driver.git', + '0e95cd88657030f640a11e690a8a5186c7712ea5', + 'stm32f0'], + 'hw/mcu/st/stm32f1xx_hal_driver': ['https://github.com/STMicroelectronics/stm32f1xx_hal_driver.git', + '1dd9d3662fb7eb2a7f7d3bc0a4c1dc7537915a29', + 'stm32f1'], + 'hw/mcu/st/stm32f2xx_hal_driver': ['https://github.com/STMicroelectronics/stm32f2xx_hal_driver.git', + 'c75ace9b908a9aca631193ebf2466963b8ea33d0', + 'stm32f2'], + 'hw/mcu/st/stm32f3xx_hal_driver': ['https://github.com/STMicroelectronics/stm32f3xx_hal_driver.git', + '1761b6207318ede021706e75aae78f452d72b6fa', + 'stm32f3'], + 'hw/mcu/st/stm32f4xx_hal_driver': ['https://github.com/STMicroelectronics/stm32f4xx_hal_driver.git', + '04e99fbdabd00ab8f370f377c66b0a4570365b58', + 'stm32f4'], + 'hw/mcu/st/stm32f7xx_hal_driver': ['https://github.com/STMicroelectronics/stm32f7xx_hal_driver.git', + 'f7ffdf6bf72110e58b42c632b0a051df5997e4ee', + 'stm32f7'], + 'hw/mcu/st/stm32g0xx_hal_driver': ['https://github.com/STMicroelectronics/stm32g0xx_hal_driver.git', + 'e911b12c7f67084d7f6b76157a4c0d4e2ec3779c', + 'stm32g0'], + 'hw/mcu/st/stm32g4xx_hal_driver': ['https://github.com/STMicroelectronics/stm32g4xx_hal_driver.git', + '8b4518417706d42eef5c14e56a650005abf478a8', + 'stm32g4'], + 'hw/mcu/st/stm32h7xx_hal_driver': ['https://github.com/STMicroelectronics/stm32h7xx_hal_driver.git', + 'd8461b980b59b1625207d8c4f2ce0a9c2a7a3b04', + 'stm32h7'], + 'hw/mcu/st/stm32h5xx_hal_driver': ['https://github.com/STMicroelectronics/stm32h5xx_hal_driver.git', + '2cf77de584196d619cec1b4586c3b9e2820a254e', + 'stm32h5'], + 'hw/mcu/st/stm32l0xx_hal_driver': ['https://github.com/STMicroelectronics/stm32l0xx_hal_driver.git', + 'fbdacaf6f8c82a4e1eb9bd74ba650b491e97e17b', + 'stm32l0'], + 'hw/mcu/st/stm32l1xx_hal_driver': ['https://github.com/STMicroelectronics/stm32l1xx_hal_driver.git', + '44efc446fa69ed8344e7fd966e68ed11043b35d9', + 'stm32l1'], + 'hw/mcu/st/stm32l4xx_hal_driver': ['https://github.com/STMicroelectronics/stm32l4xx_hal_driver.git', + 'aee3d5bf283ae5df87532b781bdd01b7caf256fc', + 'stm32l4'], + 'hw/mcu/st/stm32l5xx_hal_driver': ['https://github.com/STMicroelectronics/stm32l5xx_hal_driver.git', + '675c32a75df37f39d50d61f51cb0dcf53f07e1cb', + 'stm32l5'], + 'hw/mcu/st/stm32u5xx_hal_driver': ['https://github.com/STMicroelectronics/stm32u5xx_hal_driver.git', + '4d93097a67928e9377e655ddd14622adc31b9770', + 'stm32u5'], + 'hw/mcu/st/stm32wbxx_hal_driver': ['https://github.com/STMicroelectronics/stm32wbxx_hal_driver.git', + '2c5f06638be516c1b772f768456ba637f077bac8', + 'stm32wb'], + 'hw/mcu/ti': ['https://github.com/hathach/ti_driver.git', + '143ed6cc20a7615d042b03b21e070197d473e6e5', + 'msp430 msp432e4 tm4c'], + 'hw/mcu/wch/ch32v103': ['https://github.com/openwch/ch32v103.git', + '7578cae0b21f86dd053a1f781b2fc6ab99d0ec17', + 'ch32v10x'], + 'hw/mcu/wch/ch32v20x': ['https://github.com/openwch/ch32v20x.git', + 'c4c38f507e258a4e69b059ccc2dc27dde33cea1b', + 'ch32v20x'], + 'hw/mcu/wch/ch32v307': ['https://github.com/openwch/ch32v307.git', + '184f21b852cb95eed58e86e901837bc9fff68775', + 'ch32v307'], + 'hw/mcu/wch/ch32f20x': ['https://github.com/openwch/ch32f20x.git', + '77c4095087e5ed2c548ec9058e655d0b8757663b', + 'ch32f20x'], + 'lib/CMSIS_5': ['https://github.com/ARM-software/CMSIS_5.git', + '2b7495b8535bdcb306dac29b9ded4cfb679d7e5c', + 'imxrt kinetis_k32l2 kinetis_kl lpc51 lpc54 lpc55 mcx mm32 msp432e4 nrf saml2x ' + 'lpc11 lpc13 lpc15 lpc17 lpc18 lpc40 lpc43 ' + 'stm32c0 stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32g0 stm32g4 stm32h5 ' + 'stm32h7 stm32l0 stm32l1 stm32l4 stm32l5 stm32u5 stm32wb ' + 'sam3x samd11 samd21 samd51 samd5x_e5x same5x same7x saml2x samg ' + 'tm4c '], + 'lib/CMSIS_6': ['https://github.com/ARM-software/CMSIS_6.git', + 'b0bbb0423b278ca632cfe1474eb227961d835fd2', + 'ra'], + 'lib/sct_neopixel': ['https://github.com/gsteiert/sct_neopixel.git', + 'e73e04ca63495672d955f9268e003cffe168fcd8', + 'lpc55'], +} + +# combined 2 deps +deps_all = {**deps_mandatory, **deps_optional} + +# TOP is tinyusb root dir +TOP = Path(__file__).parent.parent.resolve() + + +def run_cmd(cmd): + return subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + + +def get_a_dep(d): + if d not in deps_all.keys(): + print('{} is not found in dependency list') + return 1 + url = deps_all[d][0] + commit = deps_all[d][1] + families = deps_all[d][2] + + print(f'cloning {d} with {url}') + + p = Path(TOP / d) + git_cmd = f"git -C {p}" + + # Init git deps if not existed + if not p.exists(): + p.mkdir(parents=True) + run_cmd(f"{git_cmd} init") + run_cmd(f"{git_cmd} remote add origin {url}") + + # Check if commit is already fetched + result = run_cmd(f"{git_cmd} rev-parse HEAD") + head = result.stdout.decode("utf-8").splitlines()[0] + run_cmd(f"{git_cmd} reset --hard") + if commit != head: + run_cmd(f"{git_cmd} fetch --depth 1 origin {commit}") + run_cmd(f"{git_cmd} checkout FETCH_HEAD") + + return 0 + + +def find_family(board): + bsp_dir = Path(TOP / "hw/bsp") + for family_dir in bsp_dir.iterdir(): + if family_dir.is_dir(): + board_dir = family_dir / 'boards' / board + if board_dir.exists(): + return family_dir.name + return None + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('families', nargs='*', default=[], help='Families to fetch') + parser.add_argument('-b', '--board', action='append', default=[], help='Boards to fetch') + parser.add_argument('-f1', '--build-flags-on', action='append', default=[], help='Have no effect') + parser.add_argument('--print', action='store_true', help='Print commit hash only') + args = parser.parse_args() + + families = args.families + boards = args.board + print_only = args.print + + status = 0 + deps = list(deps_mandatory.keys()) + + if 'all' in families: + deps += deps_optional.keys() + else: + families = list(families) + if boards is not None: + for b in boards: + f = find_family(b) + if f is not None: + families.append(f) + + for f in families: + for d in deps_optional: + if d not in deps and f in deps_optional[d][2]: + deps.append(d) + + if print_only: + pvalue = {} + # print only without arguments, always add CMSIS_5 + if len(families) == 0 and len(boards) == 0: + deps.append('lib/CMSIS_5') + for d in deps: + commit = deps_all[d][1] + pvalue[d] = commit + print(pvalue) + else: + with Pool() as pool: + status = sum(pool.map(get_a_dep, deps)) + return status + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/iar_gen.py b/tools/iar_gen.py index 73c8b29fc..8d45659db 100644..100755 --- a/tools/iar_gen.py +++ b/tools/iar_gen.py @@ -1,51 +1,87 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 import os +import sys import xml.dom.minidom as XML +import glob -# Read base configuration -base = "" -with open("iar_template.ipcf") as f: - base = f.read() +def Main(): + # 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) + # 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) + +def ListPath(path, blacklist=[]): + # Get all .c files + files = glob.glob(f'../{path}/**/*.c', recursive=True) + files.extend(glob.glob(f'../{path}/**/*.h', recursive=True)) + # Filter + files = [x for x in files if all(y not in x for y in blacklist)] + # Get common dir list + dirs = [] + for file in files: + dir = os.path.dirname(file) + if dir not in dirs: + dirs.append(dir) + # Print .c grouped by dir + for dir in dirs: + print('<group name="' + dir.replace('../', '').replace('\\','/') + '">') + for file in files: + if os.path.dirname(file) == dir: + print(' <path>$TUSB_DIR$/' + file.replace('../','').replace('\\','/')+'</path>') + print('</group>') + +def List(): + ListPath('src', [ 'template.c', 'dcd_synopsys.c', 'dcd_esp32sx.c' ]) + ListPath('lib/SEGGER_RTT') + +if __name__ == "__main__": + if os.path.dirname(os.getcwd()) != 'tools': + os.chdir('tools') + if (len(sys.argv) > 1): + if (sys.argv[1] == 'l'): + List() + else: + Main() diff --git a/tools/iar_template.ipcf b/tools/iar_template.ipcf index ba54fe057..33a6ef045 100644 --- a/tools/iar_template.ipcf +++ b/tools/iar_template.ipcf @@ -4,142 +4,273 @@ <includePath> <path>$TUSB_DIR$/src</path> <path>$TUSB_DIR$/lib/SEGGER_RTT/RTT</path> + <path>$TUSB_DIR$/lib/SEGGER_RTT/Config</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> + <path>$TUSB_DIR$/src/tusb.h</path> + <path>$TUSB_DIR$/src/tusb_option.h</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> + <group name="src/class/audio"> + <path>$TUSB_DIR$/src/class/audio/audio_device.c</path> + <path>$TUSB_DIR$/src/class/audio/audio.h</path> + <path>$TUSB_DIR$/src/class/audio/audio_device.h</path> + </group> + <group name="src/class/bth"> + <path>$TUSB_DIR$/src/class/bth/bth_device.c</path> + <path>$TUSB_DIR$/src/class/bth/bth_device.h</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> + <path>$TUSB_DIR$/src/class/cdc/cdc.h</path> + <path>$TUSB_DIR$/src/class/cdc/cdc_device.h</path> + <path>$TUSB_DIR$/src/class/cdc/cdc_host.h</path> + <path>$TUSB_DIR$/src/class/cdc/cdc_rndis.h</path> + <path>$TUSB_DIR$/src/class/cdc/cdc_rndis_host.h</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> + <path>$TUSB_DIR$/src/class/dfu/dfu.h</path> + <path>$TUSB_DIR$/src/class/dfu/dfu_device.h</path> + <path>$TUSB_DIR$/src/class/dfu/dfu_rt_device.h</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> + <path>$TUSB_DIR$/src/class/hid/hid.h</path> + <path>$TUSB_DIR$/src/class/hid/hid_device.h</path> + <path>$TUSB_DIR$/src/class/hid/hid_host.h</path> + </group> + <group name="src/class/midi"> + <path>$TUSB_DIR$/src/class/midi/midi_device.c</path> + <path>$TUSB_DIR$/src/class/midi/midi.h</path> + <path>$TUSB_DIR$/src/class/midi/midi_device.h</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> + <path>$TUSB_DIR$/src/class/msc/msc.h</path> + <path>$TUSB_DIR$/src/class/msc/msc_device.h</path> + <path>$TUSB_DIR$/src/class/msc/msc_host.h</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> + <path>$TUSB_DIR$/src/class/net/ncm.h</path> + <path>$TUSB_DIR$/src/class/net/net_device.h</path> + </group> + <group name="src/class/usbtmc"> + <path>$TUSB_DIR$/src/class/usbtmc/usbtmc_device.c</path> + <path>$TUSB_DIR$/src/class/usbtmc/usbtmc.h</path> + <path>$TUSB_DIR$/src/class/usbtmc/usbtmc_device.h</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> + <path>$TUSB_DIR$/src/class/vendor/vendor_device.h</path> + <path>$TUSB_DIR$/src/class/vendor/vendor_host.h</path> + </group> + <group name="src/class/video"> + <path>$TUSB_DIR$/src/class/video/video_device.c</path> + <path>$TUSB_DIR$/src/class/video/video.h</path> + <path>$TUSB_DIR$/src/class/video/video_device.h</path> + </group> + <group name="src/common"> + <path>$TUSB_DIR$/src/common/tusb_fifo.c</path> + <path>$TUSB_DIR$/src/common/tusb_common.h</path> + <path>$TUSB_DIR$/src/common/tusb_compiler.h</path> + <path>$TUSB_DIR$/src/common/tusb_debug.h</path> + <path>$TUSB_DIR$/src/common/tusb_fifo.h</path> + <path>$TUSB_DIR$/src/common/tusb_mcu.h</path> + <path>$TUSB_DIR$/src/common/tusb_private.h</path> + <path>$TUSB_DIR$/src/common/tusb_types.h</path> + <path>$TUSB_DIR$/src/common/tusb_verify.h</path> + </group> + <group name="src/device"> + <path>$TUSB_DIR$/src/device/usbd.c</path> + <path>$TUSB_DIR$/src/device/usbd_control.c</path> + <path>$TUSB_DIR$/src/device/dcd.h</path> + <path>$TUSB_DIR$/src/device/usbd.h</path> + <path>$TUSB_DIR$/src/device/usbd_pvt.h</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/hcd.h</path> + <path>$TUSB_DIR$/src/host/hub.h</path> + <path>$TUSB_DIR$/src/host/usbh.h</path> + <path>$TUSB_DIR$/src/host/usbh_pvt.h</path> + </group> + <group name="src/portable/analog/max3421"> + <path>$TUSB_DIR$/src/portable/analog/max3421/hcd_max3421.c</path> + </group> + <group name="src/portable/bridgetek/ft9xx"> + <path>$TUSB_DIR$/src/portable/bridgetek/ft9xx/dcd_ft9xx.c</path> + </group> + <group name="src/portable/chipidea/ci_fs"> + <path>$TUSB_DIR$/src/portable/chipidea/ci_fs/dcd_ci_fs.c</path> + <path>$TUSB_DIR$/src/portable/chipidea/ci_fs/ci_fs_kinetis.h</path> + <path>$TUSB_DIR$/src/portable/chipidea/ci_fs/ci_fs_mcx.h</path> + <path>$TUSB_DIR$/src/portable/chipidea/ci_fs/ci_fs_type.h</path> + </group> + <group name="src/portable/chipidea/ci_hs"> + <path>$TUSB_DIR$/src/portable/chipidea/ci_hs/dcd_ci_hs.c</path> + <path>$TUSB_DIR$/src/portable/chipidea/ci_hs/hcd_ci_hs.c</path> + <path>$TUSB_DIR$/src/portable/chipidea/ci_hs/ci_hs_imxrt.h</path> + <path>$TUSB_DIR$/src/portable/chipidea/ci_hs/ci_hs_lpc18_43.h</path> + <path>$TUSB_DIR$/src/portable/chipidea/ci_hs/ci_hs_mcx.h</path> + <path>$TUSB_DIR$/src/portable/chipidea/ci_hs/ci_hs_type.h</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> + <path>$TUSB_DIR$/src/portable/ehci/ehci.h</path> + <path>$TUSB_DIR$/src/portable/ehci/ehci_api.h</path> + </group> + <group name="src/portable/mentor/musb"> + <path>$TUSB_DIR$/src/portable/mentor/musb/dcd_musb.c</path> + <path>$TUSB_DIR$/src/portable/mentor/musb/hcd_musb.c</path> + <path>$TUSB_DIR$/src/portable/mentor/musb/musb_msp432e.h</path> + <path>$TUSB_DIR$/src/portable/mentor/musb/musb_tm4c.h</path> + <path>$TUSB_DIR$/src/portable/mentor/musb/musb_type.h</path> + </group> + <group name="src/portable/microchip/pic"> + <path>$TUSB_DIR$/src/portable/microchip/pic/dcd_pic.c</path> + </group> + <group name="src/portable/microchip/pic32mz"> + <path>$TUSB_DIR$/src/portable/microchip/pic32mz/dcd_pic32mz.c</path> + <path>$TUSB_DIR$/src/portable/microchip/pic32mz/usbhs_registers.h</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> + <path>$TUSB_DIR$/src/portable/microchip/samx7x/common_usb_regs.h</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> + <path>$TUSB_DIR$/src/portable/nxp/khci/hcd_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> + <path>$TUSB_DIR$/src/portable/nxp/lpc17_40/dcd_lpc17_40.h</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/ohci"> + <path>$TUSB_DIR$/src/portable/ohci/ohci.c</path> + <path>$TUSB_DIR$/src/portable/ohci/ohci.h</path> + </group> + <group name="src/portable/raspberrypi/pio_usb"> + <path>$TUSB_DIR$/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c</path> + <path>$TUSB_DIR$/src/portable/raspberrypi/pio_usb/hcd_pio_usb.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> + <path>$TUSB_DIR$/src/portable/raspberrypi/rp2040/rp2040_usb.h</path> + </group> + <group name="src/portable/renesas/rusb2"> + <path>$TUSB_DIR$/src/portable/renesas/rusb2/dcd_rusb2.c</path> + <path>$TUSB_DIR$/src/portable/renesas/rusb2/hcd_rusb2.c</path> + <path>$TUSB_DIR$/src/portable/renesas/rusb2/rusb2_common.c</path> + <path>$TUSB_DIR$/src/portable/renesas/rusb2/rusb2_ra.h</path> + <path>$TUSB_DIR$/src/portable/renesas/rusb2/rusb2_rx.h</path> + <path>$TUSB_DIR$/src/portable/renesas/rusb2/rusb2_type.h</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> + <path>$TUSB_DIR$/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.h</path> + </group> + <group name="src/portable/st/typec"> + <path>$TUSB_DIR$/src/portable/st/typec/typec_stm32.c</path> + </group> + <group name="src/portable/sunxi"> + <path>$TUSB_DIR$/src/portable/sunxi/dcd_sunxi_musb.c</path> + <path>$TUSB_DIR$/src/portable/sunxi/musb_def.h</path> + </group> + <group name="src/portable/synopsys/dwc2"> + <path>$TUSB_DIR$/src/portable/synopsys/dwc2/dcd_dwc2.c</path> + <path>$TUSB_DIR$/src/portable/synopsys/dwc2/dwc2_bcm.h</path> + <path>$TUSB_DIR$/src/portable/synopsys/dwc2/dwc2_efm32.h</path> + <path>$TUSB_DIR$/src/portable/synopsys/dwc2/dwc2_esp32.h</path> + <path>$TUSB_DIR$/src/portable/synopsys/dwc2/dwc2_gd32.h</path> + <path>$TUSB_DIR$/src/portable/synopsys/dwc2/dwc2_stm32.h</path> + <path>$TUSB_DIR$/src/portable/synopsys/dwc2/dwc2_type.h</path> + <path>$TUSB_DIR$/src/portable/synopsys/dwc2/dwc2_xmc.h</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> + <path>$TUSB_DIR$/src/portable/valentyusb/eptri/dcd_eptri.h</path> + </group> + <group name="src/portable/wch"> + <path>$TUSB_DIR$/src/portable/wch/dcd_ch32_usbfs.c</path> + <path>$TUSB_DIR$/src/portable/wch/dcd_ch32_usbhs.c</path> + <path>$TUSB_DIR$/src/portable/wch/ch32_usbhs_reg.h</path> + </group> + <group name="src/typec"> + <path>$TUSB_DIR$/src/typec/usbc.c</path> + <path>$TUSB_DIR$/src/typec/pd_types.h</path> + <path>$TUSB_DIR$/src/typec/tcd.h</path> + <path>$TUSB_DIR$/src/typec/usbc.h</path> + </group> + <group name="src/class/cdc/serial"> + <path>$TUSB_DIR$/src/class/cdc/serial/ch34x.h</path> + <path>$TUSB_DIR$/src/class/cdc/serial/cp210x.h</path> + <path>$TUSB_DIR$/src/class/cdc/serial/ftdi_sio.h</path> + </group> + <group name="src/osal"> + <path>$TUSB_DIR$/src/osal/osal.h</path> + <path>$TUSB_DIR$/src/osal/osal_freertos.h</path> + <path>$TUSB_DIR$/src/osal/osal_mynewt.h</path> + <path>$TUSB_DIR$/src/osal/osal_none.h</path> + <path>$TUSB_DIR$/src/osal/osal_pico.h</path> + <path>$TUSB_DIR$/src/osal/osal_rtthread.h</path> + <path>$TUSB_DIR$/src/osal/osal_rtx4.h</path> + </group> + <group name="lib/SEGGER_RTT/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> + <path>$TUSB_DIR$/lib/SEGGER_RTT/RTT/SEGGER_RTT.h</path> + </group> + <group name="lib/SEGGER_RTT/Config"> + <path>$TUSB_DIR$/lib/SEGGER_RTT/Config/SEGGER_RTT_Conf.h</path> + </group> </files> - + </iarProjectConnection> diff --git a/tools/make_release.py b/tools/make_release.py new file mode 100755 index 000000000..c1caf3300 --- /dev/null +++ b/tools/make_release.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +import re +import gen_doc + +version = '0.18.0' + +print('version {}'.format(version)) +ver_id = version.split('.') + +################### +# src/tusb_option.h +################### +f_option_h = 'src/tusb_option.h' +with open(f_option_h) as f: + fdata = f.read() + fdata = re.sub(r'(#define TUSB_VERSION_MAJOR *) \d+', r"\1 {}".format(ver_id[0]), fdata) + fdata = re.sub(r'(#define TUSB_VERSION_MINOR *) \d+', r"\1 {}".format(ver_id[1]), fdata) + fdata = re.sub(r'(#define TUSB_VERSION_REVISION *) \d+', r"\1 {}".format(ver_id[2]), fdata) + +# Write the file out again +with open(f_option_h, 'w') as f: + f.write(fdata) + +################### +# repository.yml +################### +f_repository_yml = 'repository.yml' +with open(f_repository_yml) as f: + fdata = f.read() + +if fdata.find(version) < 0: + fdata = re.sub(r'("0-latest"): "\d+\.\d+\.\d+"', r'"{}": "{}"\r\n \1: "{}"'.format(version, version, version), fdata) + with open(f_repository_yml, 'w') as f: + f.write(fdata) + +################### +# library.json +################### +f_library_json = 'library.json' +with open(f_library_json) as f: + fdata = f.read() + fdata = re.sub(r'( {4}"version":) "\d+\.\d+\.\d+"', rf'\1 "{version}"', fdata) + +with open(f_library_json, 'w') as f: + f.write(fdata) + +################### +# docs/info/changelog.rst +################### + +gen_doc.gen_deps_doc() + +print("Update docs/info/changelog.rst") diff --git a/tools/mksunxi.py b/tools/mksunxi.py index 04786f429..fd8557cfc 100644..100755 --- a/tools/mksunxi.py +++ b/tools/mksunxi.py @@ -45,4 +45,4 @@ 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 + exit(process_file(sys.argv[1], sys.argv[2])) diff --git a/tools/pcapng_to_corpus.py b/tools/pcapng_to_corpus.py new file mode 100755 index 000000000..3089f0bb6 --- /dev/null +++ b/tools/pcapng_to_corpus.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +import argparse +import pcapng +import zipfile +import hashlib + +def extract_packets(pcap_file): + """Reads a wireshark packet capture and extracts the binary packets""" + packets = [] + with open(pcap_file, 'rb') as fp: + scanner = pcapng.FileScanner(fp) + for block in scanner: + if isinstance(block, pcapng.blocks.EnhancedPacket): + packets.append(block.packet_data) + return packets + +def build_corpus_zip(zip_file_output, packets): + """Builds a zip file with a file per packet + + The structure of this zip corpus is a simple content addressable storage + i.e. seed_file_name == sha256_digest(packet). + """ + with zipfile.ZipFile(zip_file_output, 'a') as out: + for packet in packets: + hash = hashlib.sha256(packet).hexdigest() + if hash not in out.namelist(): + out.writestr(hash, packet) + + +def main(pcap_file, output_zip_file): + packets = extract_packets(pcap_file) + build_corpus_zip(output_zip_file, packets) + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + prog = "pcapng_to_corpus.py", + description="""Converts a wireshark capture to a zip of binary packet + files suitable for an oss-fuzz corpus. In the case the + zip corpus already exists, this script will modify + the zip file in place adding seed entries.""") + parser.add_argument('pcapng_capture_file') + parser.add_argument('oss_fuzz_corpus_zip') + args = parser.parse_args() + main(args.pcapng_capture_file, args.oss_fuzz_corpus_zip) diff --git a/tools/top.mk b/tools/top.mk deleted file mode 100644 index 84523a557..000000000 --- a/tools/top.mk +++ /dev/null @@ -1,30 +0,0 @@ -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 deleted file mode 160000 -Subproject 19615407727073e36d81bf239c52108ba92e766 diff --git a/tools/usb_drivers/tinyusb_win_usbser.inf b/tools/usb_drivers/tinyusb_win_usbser.inf index e7f7a9b22..659f048ae 100644 --- a/tools/usb_drivers/tinyusb_win_usbser.inf +++ b/tools/usb_drivers/tinyusb_win_usbser.inf @@ -105,4 +105,4 @@ DRIVERFILENAME ="usbser" MFGNAME="tinyusb.org" INSTDISK="tinyusb CDC Driver" DESCRIPTION="tinyusb Serial" -SERVICE="USB RS-232 Emulation Driver"
\ No newline at end of file +SERVICE="USB RS-232 Emulation Driver" |
