Skip to content

Commit 2637e5b

Browse files
tannewtdhalbert
authored andcommitted
Move the nRF saved word
Instead of putting it in our uninit section, we need to ensure it is also uninit by the UF2 bootloader. We both leave at least the first 32k of RAM for the soft device, so place our word just before the end of 32k. This is ok because we only use it before the SD is started. Fixes #9143 and doesn't require a bootloader change.
1 parent 25dd72d commit 2637e5b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ports/nrf/supervisor/port.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,16 @@ uint32_t *port_stack_get_top(void) {
283283
return &_estack;
284284
}
285285

286-
// Place the word in the uninitialized section so it won't get overwritten.
287-
__attribute__((section(".uninitialized"))) uint32_t _saved_word;
286+
// Place the word in the first 32k of RAM. This is saved by us and the
287+
// bootloader for the soft device. We only use it before the soft device uses
288+
// that memory.
289+
#define SAVED_WORD ((uint32_t *)(0x20008000 - 4))
288290
void port_set_saved_word(uint32_t value) {
289-
_saved_word = value;
291+
*SAVED_WORD = value;
290292
}
291293

292294
uint32_t port_get_saved_word(void) {
293-
return _saved_word;
295+
return *SAVED_WORD;
294296
}
295297

296298
uint64_t port_get_raw_ticks(uint8_t *subticks) {

0 commit comments

Comments
 (0)