Skip to content

Commit a576301

Browse files
finneyjmicrobit-carlos
authored andcommitted
Expose address that marks the usable top of flash memory
1 parent c60c8b0 commit a576301

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

inc/MicroBitConfig.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@
6868
#endif
6969

7070
#ifndef MICROBIT_DEFAULT_SCRATCH_PAGE
71-
#define MICROBIT_DEFAULT_SCRATCH_PAGE ( MICROBIT_BOOTLOADER_ADDRESS - MICROBIT_CODEPAGESIZE * 4)
71+
#ifdef SOFTDEVICE_PRESENT
72+
#define MICROBIT_DEFAULT_SCRATCH_PAGE ( MICROBIT_BOOTLOADER_ADDRESS - MICROBIT_CODEPAGESIZE * 4)
73+
#else
74+
#define MICROBIT_DEFAULT_SCRATCH_PAGE ( 0x7E000 )
75+
#endif
7276
#endif
7377

7478
#ifndef MICROBIT_STORAGE_SCRATCH_PAGE
@@ -87,6 +91,9 @@
8791
#endif
8892
#endif
8993

94+
#ifndef MICROBIT_TOP_OF_FLASH
95+
#define MICROBIT_TOP_OF_FLASH ( MICROBIT_DEFAULT_SCRATCH_PAGE )
96+
#endif
9097

9198
#ifndef MICROBIT_APP_REGION_END
9299
#define MICROBIT_APP_REGION_END ( MICROBIT_DEFAULT_SCRATCH_PAGE)

model/MicroBit.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,8 @@ void microbit_dmesg_flush()
474474
#endif
475475
}
476476

477+
uint32_t *microbit_top_of_flash()
478+
{
479+
return (uint32_t *) MICROBIT_TOP_OF_FLASH;
480+
}
481+

model/MicroBit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ namespace codal
316316
}
317317

318318
void microbit_dmesg_flush();
319+
uint32_t *microbit_top_of_flash();
319320

320321
#if CONFIG_ENABLED(CODAL_USE_GLOBAL_NAMESPACE)
321322
using namespace codal;

0 commit comments

Comments
 (0)