Skip to content

Commit bde6b2d

Browse files
authored
Merge branch 'adafruit:main' into main
2 parents 3ea5d4e + 55c3e9f commit bde6b2d

File tree

7 files changed

+45
-31
lines changed

7 files changed

+45
-31
lines changed

ports/atmel-samd/Makefile

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,21 @@ else
104104
CFLAGS += -DNDEBUG
105105

106106
# Do a default shrink for small builds, including all SAMD21 builds.
107-
ifeq ($(CIRCUITPY_FULL_BUILD),0)
108-
SHRINK_BUILD = 1
109-
else
110-
ifeq ($(CHIP_FAMILY), samd21)
111-
SHRINK_BUILD = 1
112-
endif
113-
endif
114-
115107
# -finline-limit can shrink the image size.
116108
# -finline-limit=80 or so is similar to not having it on.
117109
# There is no simple default value, though.
118-
ifeq ($(SHRINK_BUILD), 1)
110+
ifeq ($(CIRCUITPY_FULL_BUILD),0)
119111
CFLAGS += -finline-limit=45
112+
else
113+
ifeq ($(CHIP_FAMILY), samd21)
114+
# max-inline-insns-auto increases the size of SAMD51 builds.
115+
CFLAGS += -finline-limit=45 --param max-inline-insns-auto=110
116+
endif
120117
endif
121118

122119
# We used to do this but it seems to not reduce space any more, at least in gcc 11.
123120
# Leave it here, commented out, just for reference.
124-
# --param inline-unit-growth=15 --param max-inline-insns-auto=20
121+
# --param inline-unit-growth=15
125122

126123
ifdef CFLAGS_BOARD
127124
CFLAGS += $(CFLAGS_BOARD)

ports/espressif/common-hal/microcontroller/Processor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ float common_hal_mcu_processor_get_voltage(void) {
6464

6565
uint32_t common_hal_mcu_processor_get_frequency(void) {
6666
#if defined(CONFIG_IDF_TARGET_ESP32)
67-
return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 100000;
67+
return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000;
6868
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
6969
return CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ * 1000000;
7070
#elif defined(CONFIG_IDF_TARGET_ESP32S2)

ports/raspberrypi/common-hal/socketpool/Socket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,6 @@ bool socketpool_socket(socketpool_socketpool_obj_t *self,
706706
case MOD_NETWORK_SOCK_STREAM: {
707707
// Register the socket object as our callback argument.
708708
tcp_arg(socket->pcb.tcp, (void *)socket);
709-
// Register our error callback.
710-
tcp_err(socket->pcb.tcp, _lwip_tcp_error);
711709
break;
712710
}
713711
case MOD_NETWORK_SOCK_DGRAM: {
@@ -916,10 +914,11 @@ void socketpool_socket_close(socketpool_socket_obj_t *socket) {
916914
case SOCKETPOOL_SOCK_STREAM: {
917915
// Deregister callback (pcb.tcp is set to NULL below so must deregister now)
918916
tcp_arg(socket->pcb.tcp, NULL);
919-
tcp_err(socket->pcb.tcp, NULL);
920-
tcp_recv(socket->pcb.tcp, NULL);
921917

922918
if (socket->pcb.tcp->state != LISTEN) {
919+
tcp_err(socket->pcb.tcp, NULL);
920+
tcp_recv(socket->pcb.tcp, NULL);
921+
923922
// Schedule a callback to abort the connection if it's not cleanly closed after
924923
// the given timeout. The callback must be set before calling tcp_close since
925924
// the latter may free the pcb; if it doesn't then the callback will be active.
@@ -977,6 +976,7 @@ void common_hal_socketpool_socket_connect(socketpool_socket_obj_t *socket,
977976
// Register our receive callback.
978977
MICROPY_PY_LWIP_ENTER
979978
tcp_recv(socket->pcb.tcp, _lwip_tcp_recv);
979+
tcp_err(socket->pcb.tcp, _lwip_tcp_error);
980980
socket->state = STATE_CONNECTING;
981981
err = tcp_connect(socket->pcb.tcp, &dest, port, _lwip_tcp_connected);
982982
if (err != ERR_OK) {

shared-bindings/gifio/OnDiskGif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
//|
9898
//| display_bus.send(42, struct.pack(">hh", 0, odg.bitmap.width - 1))
9999
//| display_bus.send(43, struct.pack(">hh", 0, odg.bitmap.height - 1))
100-
//| display_bus.send(44, d.bitmap)
100+
//| display_bus.send(44, odg.bitmap)
101101
//|
102102
//| # The following optional code will free the OnDiskGif and allocated resources
103103
//| # after use. This may be required before loading a new GIF in situations

shared-module/os/getenv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ STATIC void close_file(file_arg *active_file) {
7272
// nothing
7373
}
7474
STATIC bool is_eof(file_arg *active_file) {
75-
return f_eof(active_file);
75+
return f_eof(active_file) || f_error(active_file);
7676
}
7777

7878
// Return 0 if there is no next character (EOF).

shared-module/usb_hid/Device.c

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,24 +293,40 @@ uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t
293293
// Callback invoked when we receive Set_Report request through control endpoint
294294
void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize) {
295295
(void)itf;
296-
if (report_type == HID_REPORT_TYPE_INVALID) {
297-
report_id = buffer[0];
298-
buffer++;
299-
bufsize--;
296+
297+
usb_hid_device_obj_t *hid_device = NULL;
298+
size_t id_idx;
299+
300+
if (report_id == 0 && report_type == HID_REPORT_TYPE_INVALID) {
301+
// This could be a report with a non-zero report ID in the first byte, or
302+
// it could be for report ID 0.
303+
// Heuristic: see if there's a device with report ID 0, and if its report length matches
304+
// the size of the incoming buffer. In that case, assume the first byte is not the report ID,
305+
// but is data. Otherwise use the first byte as the report id.
306+
if (usb_hid_get_device_with_report_id(0, &hid_device, &id_idx) &&
307+
hid_device &&
308+
hid_device->out_report_buffers[id_idx] &&
309+
hid_device->out_report_lengths[id_idx] == bufsize) {
310+
// Use as is, with report_id 0.
311+
} else {
312+
// No matching report ID 0, so use the first byte as the report ID.
313+
report_id = buffer[0];
314+
buffer++;
315+
bufsize--;
316+
}
300317
} else if (report_type != HID_REPORT_TYPE_OUTPUT && report_type != HID_REPORT_TYPE_FEATURE) {
301318
return;
302319
}
303320

304-
usb_hid_device_obj_t *hid_device;
305-
size_t id_idx;
306-
// Find device with this report id, and get the report id index.
307-
if (usb_hid_get_device_with_report_id(report_id, &hid_device, &id_idx)) {
321+
// report_id might be changed due to parsing above, so test again.
322+
if ((report_id == 0 && report_type == HID_REPORT_TYPE_INVALID) ||
323+
// Fetch the matching device if we don't already have the report_id 0 device.
324+
(usb_hid_get_device_with_report_id(report_id, &hid_device, &id_idx) &&
325+
hid_device &&
326+
hid_device->out_report_buffers[id_idx] &&
327+
hid_device->out_report_lengths[id_idx] == bufsize)) {
308328
// If a report of the correct size has been read, save it in the proper OUT report buffer.
309-
if (hid_device &&
310-
hid_device->out_report_buffers[id_idx] &&
311-
hid_device->out_report_lengths[id_idx] >= bufsize) {
312-
memcpy(hid_device->out_report_buffers[id_idx], buffer, bufsize);
313-
hid_device->out_report_buffers_updated[id_idx] = true;
314-
}
329+
memcpy(hid_device->out_report_buffers[id_idx], buffer, bufsize);
330+
hid_device->out_report_buffers_updated[id_idx] = true;
315331
}
316332
}

supervisor/shared/web_workflow/web_workflow.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ void supervisor_start_web_workflow(void) {
261261
const mcu_reset_reason_t reset_reason = common_hal_mcu_processor_get_reset_reason();
262262
if (reset_reason != RESET_REASON_POWER_ON &&
263263
reset_reason != RESET_REASON_RESET_PIN &&
264+
reset_reason != RESET_REASON_DEEP_SLEEP_ALARM &&
264265
reset_reason != RESET_REASON_UNKNOWN &&
265266
reset_reason != RESET_REASON_SOFTWARE) {
266267
return;

0 commit comments

Comments
 (0)