check that boot device is interface #0; remove instrumentation
This commit is contained in:
parent
75f1019436
commit
a911cbef51
|
@ -551,6 +551,10 @@ msgstr ""
|
|||
msgid "Bit depth must be multiple of 8."
|
||||
msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Boot device must be first device (interface #0)."
|
||||
msgstr ""
|
||||
|
||||
#: ports/mimxrt10xx/common-hal/busio/UART.c
|
||||
msgid "Both RX and TX required for flow control"
|
||||
msgstr ""
|
||||
|
|
|
@ -97,9 +97,8 @@ const mp_obj_property_t mcu_processor_reset_reason_obj = {
|
|||
//|
|
||||
//| Is `None` if the temperature is not available."""
|
||||
//|
|
||||
extern volatile float indicator;
|
||||
STATIC mp_obj_t mcu_processor_get_temperature(mp_obj_t self) {
|
||||
float temperature = indicator; // common_hal_mcu_processor_get_temperature();
|
||||
float temperature = common_hal_mcu_processor_get_temperature();
|
||||
return isnan(temperature) ? mp_const_none : mp_obj_new_float(temperature);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,12 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_hid_disable_obj, usb_hid_disable);
|
|||
//| will be ignored, and the predefined report descriptor will be used.
|
||||
//| But if the host does not request the boot keyboard,
|
||||
//| the descriptor provided by `Device.KEYBOARD` will be used.
|
||||
//|
|
||||
//| The HID boot device must usually be the first or only device presented by CircuitPython.
|
||||
//| The HID device will be USB interface number 0.
|
||||
//| To make sure it is the first device, disable other USB devices, including CDC and MSC (CIRCUITPY).
|
||||
//| If you specify a non-zero ``boot_device``, and it is not the first device, CircuitPython
|
||||
//| will enter safe mode to report this error.
|
||||
//| """
|
||||
//| ...
|
||||
//|
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
#include "supervisor/memory.h"
|
||||
#include "supervisor/usb.h"
|
||||
|
||||
volatile float indicator = 0.1f;
|
||||
|
||||
static const uint8_t usb_hid_descriptor_template[] = {
|
||||
0x09, // 0 bLength
|
||||
0x04, // 1 bDescriptorType (Interface)
|
||||
|
@ -85,10 +83,9 @@ static usb_hid_device_obj_t hid_devices[MAX_HID_DEVICES];
|
|||
// If 0, USB HID is disabled.
|
||||
static mp_int_t num_hid_devices;
|
||||
|
||||
// Which boot device is available 0: no boot devices, 1: boot keyboard, 2: boot mouse.
|
||||
// Which boot device is available? 0: no boot devices, 1: boot keyboard, 2: boot mouse.
|
||||
// This value is set by usb_hid.enable(), and used to build the HID interface descriptor.
|
||||
// The value is remembered here from boot.py to code.py.
|
||||
|
||||
static uint8_t hid_boot_device;
|
||||
|
||||
// Whether a boot device was requested by a SET_PROTOCOL request from the host.
|
||||
|
|
|
@ -169,6 +169,9 @@ void print_safe_mode_message(safe_mode_t reason) {
|
|||
case USB_TOO_MANY_INTERFACE_NAMES:
|
||||
message = translate("USB devices specify too many interface names.");
|
||||
break;
|
||||
case USB_BOOT_DEVICE_NOT_INTERFACE_ZERO:
|
||||
message = translate("Boot device must be first device (interface #0).");
|
||||
break;
|
||||
case WATCHDOG_RESET:
|
||||
message = translate("Watchdog timer expired.");
|
||||
break;
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef enum {
|
|||
WATCHDOG_RESET,
|
||||
USB_TOO_MANY_ENDPOINTS,
|
||||
USB_TOO_MANY_INTERFACE_NAMES,
|
||||
USB_BOOT_DEVICE_NOT_INTERFACE_ZERO,
|
||||
NO_HEAP,
|
||||
} safe_mode_t;
|
||||
|
||||
|
|
|
@ -228,6 +228,11 @@ static void usb_build_configuration_descriptor(void) {
|
|||
|
||||
#if CIRCUITPY_USB_HID
|
||||
if (usb_hid_enabled()) {
|
||||
if (usb_hid_boot_device() > 0 && descriptor_counts.current_interface > 0) {
|
||||
// Hosts using boot devices generally to expect them to be at interface zero,
|
||||
// and will not work properly otherwise.
|
||||
reset_into_safe_mode(USB_BOOT_DEVICE_NOT_INTERFACE_ZERO);
|
||||
}
|
||||
descriptor_buf_remaining += usb_hid_add_descriptor(
|
||||
descriptor_buf_remaining, &descriptor_counts, ¤t_interface_string,
|
||||
usb_hid_report_descriptor_length(), usb_hid_boot_device());
|
||||
|
|
Loading…
Reference in New Issue