diff options
| author | Ha Thach <[email protected]> | 2025-10-02 19:58:12 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-02 19:58:12 +0700 |
| commit | c1bf19ed6cf1eaa791f221c1bc5ce4b3d069f76d (patch) | |
| tree | 60fe2447d25af0ab07b80f435d79a147cf717d8f /tools | |
| parent | f655d210b17fad3d2e95c7ef07e114a2f0b6dac6 (diff) | |
| parent | 610f353d8d602c3192f9edc03669ab792056f7da (diff) | |
Merge pull request #3023 from ennebi/mtp
Add support for MTP device class
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/file2carray.py | 45 | ||||
| -rw-r--r-- | tools/iar_template.ipcf | 5 |
2 files changed, 50 insertions, 0 deletions
diff --git a/tools/file2carray.py b/tools/file2carray.py new file mode 100644 index 000000000..abfb4e21b --- /dev/null +++ b/tools/file2carray.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +import argparse +import random +import os +import sys +import time +import subprocess +from pathlib import Path +from multiprocessing import Pool +from weakref import finalize + + +def print_carray(f, payload): + while len(payload) > 0: + f.write('\n ') + f.write(', '.join('0x{:02x}'.format(x) for x in payload[0:16])) + f.write(',') + payload = payload[16:] + f.write('\n') + + +def main(): + parser = argparse.ArgumentParser(description='Convert binary files to C array format') + parser.add_argument('files', nargs='+', help='Binary files to convert') + args = parser.parse_args() + + files = args.files + for fin_name in files: + if not os.path.isfile(fin_name): + print(f"File {fin_name} does not exist") + continue + + with open(fin_name, 'rb') as fin: + contents = fin.read() + fout_name = fin_name + '.h' + with open(fout_name, 'w') as fout: + print(f"Converting {fin_name} to {fout_name}") + fout.write(f'const size_t bindata_len = {len(contents)};\n') + fout.write(f'const uint8_t bindata[] __attribute__((aligned(16))) = {{') + print_carray(fout, contents) + fout.write('};\n') + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools/iar_template.ipcf b/tools/iar_template.ipcf index 33a6ef045..2581a4702 100644 --- a/tools/iar_template.ipcf +++ b/tools/iar_template.ipcf @@ -58,6 +58,11 @@ <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/mtp"> + <path>$TUSB_DIR$/src/class/mtp/mtp_device.c</path> + <path>$TUSB_DIR$/src/class/mtp/mtp.h</path> + <path>$TUSB_DIR$/src/class/mtp/mtp_device.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> |
