summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-07-30 07:24:48 -0500
committerJeff Epler <jepler@gmail.com>2020-07-30 07:24:48 -0500
commitd69f081c04f32c93054335470cdd4c063fd7cbcb (patch)
tree53f00a8fd4efa3f2c59ec3085808a9fc2cafc7d4 /tools
parent57464998c0c97010f6fc5ed1aea009ce6b010272 (diff)
parent531c1e046cf46e626268995de4c34097addc9b60 (diff)
Merge remote-tracking branch 'origin/main' into blm_badge
Diffstat (limited to 'tools')
-rwxr-xr-xtools/build_release_files.py11
-rw-r--r--tools/gen_usb_descriptor.py34
2 files changed, 28 insertions, 17 deletions
diff --git a/tools/build_release_files.py b/tools/build_release_files.py
index 3563dd99f..98e81499e 100755
--- a/tools/build_release_files.py
+++ b/tools/build_release_files.py
@@ -5,6 +5,7 @@
# SPDX-License-Identifier: MIT
import os
+import multiprocessing
import sys
import subprocess
import shutil
@@ -27,6 +28,8 @@ sha, version = build_info.get_version_info()
languages = build_info.get_languages()
exit_status = 0
+cores = multiprocessing.cpu_count()
+print('building boards with parallelism {}'.format(cores))
for board in build_boards:
bin_directory = "../bin/{}/".format(board)
os.makedirs(bin_directory, exist_ok=True)
@@ -41,8 +44,8 @@ for board in build_boards:
# But sometimes a particular language needs to be built from scratch, if, for instance,
# CFLAGS_INLINE_LIMIT is set for a particular language to make it fit.
clean_build_check_result = subprocess.run(
- "make -C ../ports/{port} TRANSLATION={language} BOARD={board} check-release-needs-clean-build | fgrep 'RELEASE_NEEDS_CLEAN_BUILD = 1'".format(
- port = board_info["port"], language=language, board=board),
+ "make -C ../ports/{port} TRANSLATION={language} BOARD={board} check-release-needs-clean-build -j {cores} | fgrep 'RELEASE_NEEDS_CLEAN_BUILD = 1'".format(
+ port = board_info["port"], language=language, board=board, cores=cores),
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
clean_build = clean_build_check_result.returncode == 0
@@ -51,8 +54,8 @@ for board in build_boards:
build_dir += "-{language}".format(language=language)
make_result = subprocess.run(
- "make -C ../ports/{port} TRANSLATION={language} BOARD={board} BUILD={build}".format(
- port = board_info["port"], language=language, board=board, build=build_dir),
+ "make -C ../ports/{port} TRANSLATION={language} BOARD={board} BUILD={build} -j {cores}".format(
+ port = board_info["port"], language=language, board=board, build=build_dir, cores=cores),
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
build_duration = time.monotonic() - start_time
diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py
index adec33100..fb91fd334 100644
--- a/tools/gen_usb_descriptor.py
+++ b/tools/gen_usb_descriptor.py
@@ -23,6 +23,8 @@ ALL_HID_DEVICES_SET=frozenset(ALL_HID_DEVICES.split(','))
DEFAULT_HID_DEVICES='KEYBOARD,MOUSE,CONSUMER,GAMEPAD'
parser = argparse.ArgumentParser(description='Generate USB descriptors.')
+parser.add_argument('--highspeed', default=False, action='store_true',
+ help='descriptor for highspeed device')
parser.add_argument('--manufacturer', type=str,
help='manufacturer of the device')
parser.add_argument('--product', type=str,
@@ -40,8 +42,6 @@ parser.add_argument('--hid_devices', type=lambda l: tuple(l.split(',')), default
parser.add_argument('--interface_name', type=str,
help='The name/prefix to use in the interface descriptions',
default=DEFAULT_INTERFACE_NAME)
-parser.add_argument('--msc_max_packet_size', type=int, default=64,
- help='Max packet size for MSC')
parser.add_argument('--no-renumber_endpoints', dest='renumber_endpoints', action='store_false',
help='use to not renumber endpoint')
parser.add_argument('--cdc_ep_num_notification', type=int, default=0,
@@ -62,8 +62,8 @@ parser.add_argument('--midi_ep_num_out', type=int, default=0,
help='endpoint number of MIDI OUT')
parser.add_argument('--midi_ep_num_in', type=int, default=0,
help='endpoint number of MIDI IN')
-parser.add_argument('--output_c_file', type=argparse.FileType('w'), required=True)
-parser.add_argument('--output_h_file', type=argparse.FileType('w'), required=True)
+parser.add_argument('--output_c_file', type=argparse.FileType('w', encoding='UTF-8'), required=True)
+parser.add_argument('--output_h_file', type=argparse.FileType('w', encoding='UTF-8'), required=True)
args = parser.parse_args()
@@ -185,11 +185,15 @@ cdc_data_interface = standard.InterfaceDescriptor(
standard.EndpointDescriptor(
description="CDC data out",
bEndpointAddress=args.cdc_ep_num_data_out | standard.EndpointDescriptor.DIRECTION_OUT,
- bmAttributes=standard.EndpointDescriptor.TYPE_BULK),
+ bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
+ bInterval=0,
+ wMaxPacketSize=512 if args.highspeed else 64),
standard.EndpointDescriptor(
description="CDC data in",
bEndpointAddress=args.cdc_ep_num_data_in | standard.EndpointDescriptor.DIRECTION_IN,
- bmAttributes=standard.EndpointDescriptor.TYPE_BULK),
+ bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
+ bInterval=0,
+ wMaxPacketSize=512 if args.highspeed else 64),
])
cdc_interfaces = [cdc_comm_interface, cdc_data_interface]
@@ -207,13 +211,13 @@ msc_interfaces = [
bEndpointAddress=args.msc_ep_num_in | standard.EndpointDescriptor.DIRECTION_IN,
bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
bInterval=0,
- wMaxPacketSize=args.msc_max_packet_size),
+ wMaxPacketSize=512 if args.highspeed else 64),
standard.EndpointDescriptor(
description="MSC out",
bEndpointAddress=(args.msc_ep_num_out | standard.EndpointDescriptor.DIRECTION_OUT),
bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
bInterval=0,
- wMaxPacketSize=args.msc_max_packet_size)
+ wMaxPacketSize=512 if args.highspeed else 64),
]
)
]
@@ -319,13 +323,16 @@ audio_midi_interface = standard.InterfaceDescriptor(
standard.EndpointDescriptor(
description="MIDI data out to {}".format(args.interface_name),
bEndpointAddress=args.midi_ep_num_out | standard.EndpointDescriptor.DIRECTION_OUT,
- bmAttributes=standard.EndpointDescriptor.TYPE_BULK),
+ bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
+ bInterval=0,
+ wMaxPacketSize=512 if args.highspeed else 64),
midi.DataEndpointDescriptor(baAssocJack=[midi_in_jack_emb]),
standard.EndpointDescriptor(
description="MIDI data in from {}".format(args.interface_name),
bEndpointAddress=args.midi_ep_num_in | standard.EndpointDescriptor.DIRECTION_IN,
bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
- bInterval = 0x0),
+ bInterval = 0x0,
+ wMaxPacketSize=512 if args.highspeed else 64),
midi.DataEndpointDescriptor(baAssocJack=[midi_out_jack_emb]),
])
@@ -540,15 +547,15 @@ h_file.write("""\
#include <stdint.h>
extern const uint8_t usb_desc_dev[{device_length}];
-// Make sure the control buffer is big enough to fit the descriptor.
-#define CFG_TUD_ENUM_BUFFER_SIZE {max_configuration_length}
extern const uint8_t usb_desc_cfg[{configuration_length}];
extern uint16_t usb_serial_number[{serial_number_length}];
extern uint16_t const * const string_desc_arr [{string_descriptor_length}];
extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}];
-#define USB_HID_NUM_DEVICES {hid_num_devices}
+#define CFG_TUSB_RHPORT0_MODE ({rhport0_mode})
+
+#define USB_HID_NUM_DEVICES {hid_num_devices}
// Vendor name included in Inquiry response, max 8 bytes
#define CFG_TUD_MSC_VENDOR "{msc_vendor}"
@@ -563,6 +570,7 @@ extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}];
max_configuration_length=max(hid_descriptor_length, descriptor_length),
string_descriptor_length=len(pointers_to_strings),
hid_report_descriptor_length=len(bytes(combined_hid_report_descriptor)),
+ rhport0_mode='OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED' if args.highspeed else 'OPT_MODE_DEVICE',
hid_num_devices=len(args.hid_devices),
msc_vendor=args.manufacturer[:8],
msc_product=args.product[:16]))