Skip to content

Commit f99b9dd

Browse files
authored
Merge pull request adafruit#1546 from tannewt/fix_safe_mode
A safe mode fix and displayio fixes
2 parents a1a4959 + 473bdf4 commit f99b9dd

5 files changed

Lines changed: 14 additions & 7 deletions

File tree

main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ bool run_code_py(safe_mode_t safe_mode) {
229229
MICROPY_VM_HOOK_LOOP
230230
#endif
231231
if (reload_requested) {
232+
reload_requested = false;
232233
return true;
233234
}
234235

ports/atmel-samd/supervisor/port.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,20 @@ void reset_cpu(void) {
248248
reset();
249249
}
250250

251-
extern uint32_t _ebss;
252-
// Place the word to save just after our BSS section that gets blanked.
251+
// Place the word to save 8k from the end of RAM so we and the bootloader don't clobber it.
252+
#ifdef SAMD21
253+
uint32_t* safe_word = (uint32_t*) (HMCRAMC0_ADDR + HMCRAMC0_SIZE - 0x2000);
254+
#endif
255+
#ifdef SAMD51
256+
uint32_t* safe_word = (uint32_t*) (HSRAM_ADDR + HSRAM_SIZE - 0x2000);
257+
#endif
258+
253259
void port_set_saved_word(uint32_t value) {
254-
_ebss = value;
260+
*safe_word = value;
255261
}
256262

257263
uint32_t port_get_saved_word(void) {
258-
return _ebss;
264+
return *safe_word;
259265
}
260266

261267
/**

shared-bindings/displayio/Group.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t valu
256256

257257
if (value == MP_OBJ_SENTINEL) {
258258
// load
259-
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_group_get(self, index));
259+
return common_hal_displayio_group_get(self, index);
260260
} else if (value == mp_const_none) {
261261
common_hal_displayio_group_pop(self, index);
262262
} else {

shared-module/displayio/Group.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ size_t common_hal_displayio_group_get_len(displayio_group_t* self) {
9898
}
9999

100100
mp_obj_t common_hal_displayio_group_get(displayio_group_t* self, size_t index) {
101-
return self->children[index];
101+
return MP_OBJ_FROM_PTR(self->children[index]);
102102
}
103103

104104
void common_hal_displayio_group_set(displayio_group_t* self, size_t index, mp_obj_t layer) {

shared-module/displayio/TileGrid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ void common_hal_displayio_tilegrid_get_position(displayio_tilegrid_t *self, int1
7272
}
7373

7474
void common_hal_displayio_tilegrid_set_position(displayio_tilegrid_t *self, int16_t x, int16_t y) {
75+
self->needs_refresh = self->x != x || self->y != y;
7576
self->x = x;
7677
self->y = y;
77-
self->needs_refresh = true;
7878
}
7979

8080
mp_obj_t common_hal_displayio_tilegrid_get_pixel_shader(displayio_tilegrid_t *self) {

0 commit comments

Comments
 (0)