summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-02-13 00:35:14 -0800
committerScott Shawcroft <scott@tannewt.org>2019-02-13 15:31:06 -0800
commit473bdf48f61998ee9c51aa16c159bbc4df1d15b6 (patch)
tree29a5b62c3c5abd25de64d4477d5356fbd595a438
parent78f51792a7da468413b94c714f39bd4750412671 (diff)
A safe mode fix and displayio fixes
* Fixes safe mode on the SAMD51. The "preserved" value was being clobbered by the bootloader. * Fixes auto-reload loop when in safe mode. * Fixes reading Group children with []. * Check that a TileGrid actually moves before queueing a refresh.
-rwxr-xr-xmain.c1
-rw-r--r--ports/atmel-samd/supervisor/port.c14
-rw-r--r--shared-bindings/displayio/Group.c2
-rw-r--r--shared-module/displayio/Group.c2
-rw-r--r--shared-module/displayio/TileGrid.c2
5 files changed, 14 insertions, 7 deletions
diff --git a/main.c b/main.c
index 522484856..c1244f36c 100755
--- a/main.c
+++ b/main.c
@@ -229,6 +229,7 @@ bool run_code_py(safe_mode_t safe_mode) {
MICROPY_VM_HOOK_LOOP
#endif
if (reload_requested) {
+ reload_requested = false;
return true;
}
diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c
index 7e7e894cb..3f73d9a8f 100644
--- a/ports/atmel-samd/supervisor/port.c
+++ b/ports/atmel-samd/supervisor/port.c
@@ -248,14 +248,20 @@ void reset_cpu(void) {
reset();
}
-extern uint32_t _ebss;
-// Place the word to save just after our BSS section that gets blanked.
+// Place the word to save 8k from the end of RAM so we and the bootloader don't clobber it.
+#ifdef SAMD21
+uint32_t* safe_word = (uint32_t*) (HMCRAMC0_ADDR + HMCRAMC0_SIZE - 0x2000);
+#endif
+#ifdef SAMD51
+uint32_t* safe_word = (uint32_t*) (HSRAM_ADDR + HSRAM_SIZE - 0x2000);
+#endif
+
void port_set_saved_word(uint32_t value) {
- _ebss = value;
+ *safe_word = value;
}
uint32_t port_get_saved_word(void) {
- return _ebss;
+ return *safe_word;
}
/**
diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c
index 421dc1ae5..7b79f3229 100644
--- a/shared-bindings/displayio/Group.c
+++ b/shared-bindings/displayio/Group.c
@@ -256,7 +256,7 @@ STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t valu
if (value == MP_OBJ_SENTINEL) {
// load
- return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_group_get(self, index));
+ return common_hal_displayio_group_get(self, index);
} else if (value == mp_const_none) {
common_hal_displayio_group_pop(self, index);
} else {
diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c
index adaad1505..b48057d1b 100644
--- a/shared-module/displayio/Group.c
+++ b/shared-module/displayio/Group.c
@@ -98,7 +98,7 @@ size_t common_hal_displayio_group_get_len(displayio_group_t* self) {
}
mp_obj_t common_hal_displayio_group_get(displayio_group_t* self, size_t index) {
- return self->children[index];
+ return MP_OBJ_FROM_PTR(self->children[index]);
}
void common_hal_displayio_group_set(displayio_group_t* self, size_t index, mp_obj_t layer) {
diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c
index e4f40a5f7..c2aa9b144 100644
--- a/shared-module/displayio/TileGrid.c
+++ b/shared-module/displayio/TileGrid.c
@@ -72,9 +72,9 @@ void common_hal_displayio_tilegrid_get_position(displayio_tilegrid_t *self, int1
}
void common_hal_displayio_tilegrid_set_position(displayio_tilegrid_t *self, int16_t x, int16_t y) {
+ self->needs_refresh = self->x != x || self->y != y;
self->x = x;
self->y = y;
- self->needs_refresh = true;
}
mp_obj_t common_hal_displayio_tilegrid_get_pixel_shader(displayio_tilegrid_t *self) {