Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Hosted Weblate 2021-04-24 16:31:32 +02:00
commit 929485e7ce
15 changed files with 32 additions and 10 deletions

4
main.c
View File

@ -60,6 +60,7 @@
#include "supervisor/shared/translate.h" #include "supervisor/shared/translate.h"
#include "supervisor/shared/workflow.h" #include "supervisor/shared/workflow.h"
#include "supervisor/usb.h" #include "supervisor/usb.h"
#include "supervisor/workflow.h"
#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/Processor.h"
@ -188,7 +189,10 @@ STATIC void stop_mp(void) {
#endif #endif
background_callback_reset(); background_callback_reset();
#if CIRCUITPY_USB
usb_background(); usb_background();
#endif
gc_deinit(); gc_deinit();
} }

View File

@ -201,7 +201,7 @@ SRC_C += \
peripherals/rmt.c \ peripherals/rmt.c \
supervisor/shared/memory.c supervisor/shared/memory.c
ifneq ($(USB),FALSE) ifneq ($(CIRCUITPY_USB),0)
SRC_C += lib/tinyusb/src/portable/espressif/esp32s2/dcd_esp32s2.c SRC_C += lib/tinyusb/src/portable/espressif/esp32s2/dcd_esp32s2.c
endif endif

View File

@ -136,7 +136,7 @@ SRC_C += \
lib/utils/sys_stdio_mphal.c \ lib/utils/sys_stdio_mphal.c \
supervisor/shared/memory.c supervisor/shared/memory.c
ifneq ($(USB),FALSE) ifneq ($(CIRCUITPY_USB),0)
SRC_C += lib/tinyusb/src/portable/valentyusb/eptri/dcd_eptri.c SRC_C += lib/tinyusb/src/portable/valentyusb/eptri/dcd_eptri.c
endif endif

View File

@ -310,7 +310,7 @@ mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t n
uint32_t src = lba2addr(block); uint32_t src = lba2addr(block);
memcpy(dest, (uint8_t *)src, FILESYSTEM_BLOCK_SIZE * num_blocks); memcpy(dest, (uint8_t *)src, FILESYSTEM_BLOCK_SIZE * num_blocks);
#if USB_AVAILABLE #if CIRCUITPY_USB
usb_background(); usb_background();
#endif #endif
@ -347,7 +347,7 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
src += count * FILESYSTEM_BLOCK_SIZE; src += count * FILESYSTEM_BLOCK_SIZE;
num_blocks -= count; num_blocks -= count;
#if USB_AVAILABLE #if CIRCUITPY_USB
usb_background(); usb_background();
#endif #endif
} }

View File

@ -177,6 +177,7 @@ SRC_C += \
sd_mutex.c \ sd_mutex.c \
supervisor/shared/memory.c supervisor/shared/memory.c
ifneq ($(CIRCUITPY_USB),0)
# USB source files for nrf52840 # USB source files for nrf52840
ifeq ($(MCU_SUB_VARIANT),nrf52840) ifeq ($(MCU_SUB_VARIANT),nrf52840)
SRC_C += \ SRC_C += \
@ -187,6 +188,7 @@ ifeq ($(MCU_SUB_VARIANT),nrf52833)
SRC_C += \ SRC_C += \
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c
endif endif
endif # CIRCUITPY_USB
ifeq ($(CIRCUITPY_NETWORK),1) ifeq ($(CIRCUITPY_NETWORK),1)
CFLAGS += -DMICROPY_PY_NETWORK=1 CFLAGS += -DMICROPY_PY_NETWORK=1

View File

@ -98,6 +98,7 @@ void SD_EVT_IRQHandler(void) {
uint32_t evt_id; uint32_t evt_id;
while (sd_evt_get(&evt_id) != NRF_ERROR_NOT_FOUND) { while (sd_evt_get(&evt_id) != NRF_ERROR_NOT_FOUND) {
switch (evt_id) { switch (evt_id) {
#if CIRCUITPY_USB
// usb power event // usb power event
case NRF_EVT_POWER_USB_DETECTED: case NRF_EVT_POWER_USB_DETECTED:
case NRF_EVT_POWER_USB_POWER_READY: case NRF_EVT_POWER_USB_POWER_READY:
@ -109,6 +110,7 @@ void SD_EVT_IRQHandler(void) {
tusb_hal_nrf_power_event(usbevt); tusb_hal_nrf_power_event(usbevt);
} }
break; break;
#endif
// Set flag indicating that a flash operation has finished. // Set flag indicating that a flash operation has finished.
case NRF_EVT_FLASH_OPERATION_SUCCESS: case NRF_EVT_FLASH_OPERATION_SUCCESS:

View File

@ -351,8 +351,11 @@ void common_hal_bleio_adapter_set_enabled(bleio_adapter_obj_t *self, bool enable
} else { } else {
err_code = sd_softdevice_disable(); err_code = sd_softdevice_disable();
} }
#if CIRCUITPY_USB
// Re-init USB hardware // Re-init USB hardware
init_usb_hardware(); init_usb_hardware();
#endif
check_nrf_error(err_code); check_nrf_error(err_code);

View File

@ -238,7 +238,7 @@ SRC_C += \
lib/utils/sys_stdio_mphal.c \ lib/utils/sys_stdio_mphal.c \
supervisor/shared/memory.c supervisor/shared/memory.c
ifneq ($(USB),FALSE) ifneq ($(CIRCUITPY_USB),0)
SRC_C += lib/tinyusb/src/portable/st/synopsys/dcd_synopsys.c SRC_C += lib/tinyusb/src/portable/st/synopsys/dcd_synopsys.c
endif endif

View File

@ -334,6 +334,9 @@ CFLAGS += -DCIRCUITPY_TOUCHIO=$(CIRCUITPY_TOUCHIO)
CIRCUITPY_UHEAP ?= 0 CIRCUITPY_UHEAP ?= 0
CFLAGS += -DCIRCUITPY_UHEAP=$(CIRCUITPY_UHEAP) CFLAGS += -DCIRCUITPY_UHEAP=$(CIRCUITPY_UHEAP)
CIRCUITPY_USB ?= 1
CFLAGS += -DCIRCUITPY_USB=$(CIRCUITPY_USB)
# Disable by default for now, until we have dynamic enabling. # Disable by default for now, until we have dynamic enabling.
CIRCUITPY_USB_CDC ?= 0 CIRCUITPY_USB_CDC ?= 0
# Secondary CDC is usually available if there are at least 8 endpoints. # Secondary CDC is usually available if there are at least 8 endpoints.

View File

@ -59,7 +59,11 @@ STATIC supervisor_run_reason_t _run_reason;
//| """Returns the USB enumeration status (read-only).""" //| """Returns the USB enumeration status (read-only)."""
//| //|
STATIC mp_obj_t supervisor_runtime_get_usb_connected(mp_obj_t self) { STATIC mp_obj_t supervisor_runtime_get_usb_connected(mp_obj_t self) {
#if CIRCUITPY_USB
return mp_obj_new_bool(tud_ready()); return mp_obj_new_bool(tud_ready());
#else
return mp_const_false;
#endif
} }
MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_usb_connected_obj, supervisor_runtime_get_usb_connected); MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_usb_connected_obj, supervisor_runtime_get_usb_connected);

View File

@ -160,7 +160,9 @@ void common_hal_storage_remount(const char *mount_path, bool readonly, bool disa
} }
void common_hal_storage_erase_filesystem(void) { void common_hal_storage_erase_filesystem(void) {
#if CIRCUITPY_USB
usb_disconnect(); usb_disconnect();
#endif
mp_hal_delay_ms(1000); mp_hal_delay_ms(1000);
filesystem_init(false, true); // Force a re-format. filesystem_init(false, true); // Force a re-format.
common_hal_mcu_reset(); common_hal_mcu_reset();

View File

@ -26,7 +26,5 @@
#pragma once #pragma once
extern void supervisor_workflow_reset(void);
extern bool supervisor_workflow_connecting(void); extern bool supervisor_workflow_connecting(void);
extern bool supervisor_workflow_active(void); extern bool supervisor_workflow_active(void);

View File

@ -25,6 +25,7 @@
*/ */
#include "supervisor/serial.h" #include "supervisor/serial.h"
#include "supervisor/workflow.h"
void serial_early_init(void) { void serial_early_init(void) {
@ -49,3 +50,6 @@ bool serial_bytes_available(void) {
void serial_write(const char *text) { void serial_write(const char *text) {
(void)text; (void)text;
} }
void supervisor_workflow_reset(void) {
}

View File

@ -59,7 +59,7 @@ $(BUILD)/supervisor/shared/external_flash/external_flash.o: $(HEADER_BUILD)/devi
endif endif
ifeq ($(USB),FALSE) ifeq ($(CIRCUITPY_USB),0)
ifeq ($(wildcard supervisor/serial.c),) ifeq ($(wildcard supervisor/serial.c),)
SRC_SUPERVISOR += supervisor/stub/serial.c SRC_SUPERVISOR += supervisor/stub/serial.c
else else
@ -122,8 +122,6 @@ else
lib/tinyusb/src/class/vendor/vendor_device.c \ lib/tinyusb/src/class/vendor/vendor_device.c \
endif endif
CFLAGS += -DUSB_AVAILABLE
endif endif
SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o)) SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o))

View File

@ -26,5 +26,7 @@
#pragma once #pragma once
void supervisor_workflow_reset(void);
// True when the user could be actively iterating on their code. // True when the user could be actively iterating on their code.
bool workflow_active(void); bool workflow_active(void);