summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-04-17 16:23:28 -0700
committerScott Shawcroft <scott@tannewt.org>2020-05-15 15:36:16 -0700
commit6aaab005c5f3a781fec229640c74bf44a601fc97 (patch)
treed81d0c4d0387a15f8ea764ea31062d47527a4390 /supervisor
parent0d8bca92e208e705150097d26db6a5390dc9eb9b (diff)
Initial ESP32S2 port.
Basic blinky works but doesn't check pins.
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/port.h3
-rwxr-xr-xsupervisor/shared/memory.c2
-rwxr-xr-xsupervisor/shared/stack.c26
-rwxr-xr-xsupervisor/shared/stack.h2
-rw-r--r--supervisor/shared/usb/tusb_config.h2
-rw-r--r--supervisor/shared/usb/usb.c2
-rw-r--r--supervisor/supervisor.mk11
7 files changed, 33 insertions, 15 deletions
diff --git a/supervisor/port.h b/supervisor/port.h
index ccbb314ad..8a12d34c8 100644
--- a/supervisor/port.h
+++ b/supervisor/port.h
@@ -29,6 +29,7 @@
#include "py/mpconfig.h"
+#include "supervisor/memory.h"
#include "supervisor/shared/safe_mode.h"
// Provided by the linker;
@@ -60,6 +61,8 @@ uint32_t *port_stack_get_limit(void);
// Get stack top address
uint32_t *port_stack_get_top(void);
+supervisor_allocation* port_fixed_stack(void);
+
// Get heap bottom address
uint32_t *port_heap_get_bottom(void);
diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c
index d52334eb4..8ae8a1699 100755
--- a/supervisor/shared/memory.c
+++ b/supervisor/shared/memory.c
@@ -129,5 +129,7 @@ supervisor_allocation* allocate_memory(uint32_t length, bool high) {
}
void supervisor_move_memory(void) {
+ #if CIRCUITPY_DISPLAYIO
supervisor_display_move_memory();
+ #endif
}
diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c
index 2b7b1c03a..e7aa956b0 100755
--- a/supervisor/shared/stack.c
+++ b/supervisor/shared/stack.c
@@ -41,22 +41,24 @@ supervisor_allocation* stack_alloc = NULL;
#define EXCEPTION_STACK_SIZE 1024
void allocate_stack(void) {
- mp_uint_t regs[10];
- mp_uint_t sp = cpu_get_regs_and_sp(regs);
- mp_uint_t c_size = (uint32_t) port_stack_get_top() - sp;
+ if (port_fixed_stack() != NULL) {
+ stack_alloc = port_fixed_stack();
+ current_stack_size = stack_alloc->length;
+ } else {
+ mp_uint_t regs[10];
+ mp_uint_t sp = cpu_get_regs_and_sp(regs);
- if (port_stack_get_top() != port_heap_get_top()) {
- return;
+ mp_uint_t c_size = (uint32_t) port_stack_get_top() - sp;
+ stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true);
+ if (stack_alloc == NULL) {
+ stack_alloc = allocate_memory(c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE, true);
+ current_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE;
+ } else {
+ current_stack_size = next_stack_size;
+ }
}
- stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true);
- if (stack_alloc == NULL) {
- stack_alloc = allocate_memory(c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE, true);
- current_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE;
- } else {
- current_stack_size = next_stack_size;
- }
*stack_alloc->ptr = STACK_CANARY_VALUE;
}
diff --git a/supervisor/shared/stack.h b/supervisor/shared/stack.h
index 1fb43be57..7096f0b3e 100755
--- a/supervisor/shared/stack.h
+++ b/supervisor/shared/stack.h
@@ -43,6 +43,8 @@ bool stack_ok(void);
// exception when the stack has likely overwritten a portion of the heap.
void assert_heap_ok(void);
+#ifndef STACK_CANARY_VALUE
#define STACK_CANARY_VALUE 0x017829ef
+#endif
#endif // MICROPY_INCLUDED_SUPERVISOR_STACK_H
diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h
index 1b0c83416..627de743e 100644
--- a/supervisor/shared/usb/tusb_config.h
+++ b/supervisor/shared/usb/tusb_config.h
@@ -52,7 +52,9 @@
#define CFG_TUSB_DEBUG 0
/*------------- RTOS -------------*/
+#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_NONE
+#endif
//#define CFG_TUD_TASK_QUEUE_SZ 16
//#define CFG_TUD_TASK_PRIO 0
//#define CFG_TUD_TASK_STACK_SZ 150
diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c
index 774055a82..edf810118 100644
--- a/supervisor/shared/usb/usb.c
+++ b/supervisor/shared/usb/usb.c
@@ -75,7 +75,9 @@ void usb_init(void) {
void usb_background(void) {
if (usb_enabled()) {
+ #if CFG_TUSB_OS == OPT_OS_NONE
tud_task();
+ #endif
tud_cdc_write_flush();
}
}
diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk
index d6422f074..195e4a9b2 100644
--- a/supervisor/supervisor.mk
+++ b/supervisor/supervisor.mk
@@ -3,7 +3,6 @@ SRC_SUPERVISOR = \
supervisor/port.c \
supervisor/shared/autoreload.c \
supervisor/shared/board.c \
- supervisor/shared/display.c \
supervisor/shared/filesystem.c \
supervisor/shared/flash.c \
supervisor/shared/micropython.c \
@@ -104,6 +103,14 @@ else
CFLAGS += -DUSB_AVAILABLE
endif
+SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o))
+
+ifeq ($(CIRCUITPY_DISPLAYIO), 1)
+ SRC_SUPERVISOR += \
+ supervisor/shared/display.c
+
+ SUPERVISOR_O += $(BUILD)/autogen_display_resources.o
+endif
ifndef USB_INTERFACE_NAME
USB_INTERFACE_NAME = "CircuitPython"
endif
@@ -182,8 +189,6 @@ ifeq ($(USB_RENUMBER_ENDPOINTS), 0)
USB_DESCRIPTOR_ARGS += --no-renumber_endpoints
endif
-SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o)) $(BUILD)/autogen_display_resources.o
-
$(BUILD)/supervisor/shared/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h
$(BUILD)/autogen_usb_descriptor.c $(BUILD)/genhdr/autogen_usb_descriptor.h: autogen_usb_descriptor.intermediate