Skip to content

Commit

Permalink
Expose address that marks the usable top of flash memory
Browse files Browse the repository at this point in the history
  • Loading branch information
finneyj committed Mar 6, 2025
1 parent 4ff7ad2 commit 9390b19
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion inc/MicroBitConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@
#endif

#ifndef MICROBIT_DEFAULT_SCRATCH_PAGE
#define MICROBIT_DEFAULT_SCRATCH_PAGE ( MICROBIT_BOOTLOADER_ADDRESS - MICROBIT_CODEPAGESIZE * 4)
#ifdef SOFTDEVICE_PRESENT
#define MICROBIT_DEFAULT_SCRATCH_PAGE ( MICROBIT_BOOTLOADER_ADDRESS - MICROBIT_CODEPAGESIZE * 4)
#else
#define MICROBIT_DEFAULT_SCRATCH_PAGE ( 0x7E000 )
#endif
#endif

#ifndef MICROBIT_STORAGE_SCRATCH_PAGE
Expand All @@ -87,6 +91,9 @@
#endif
#endif

#ifndef MICROBIT_TOP_OF_FLASH
#define MICROBIT_TOP_OF_FLASH ( MICROBIT_DEFAULT_SCRATCH_PAGE )
#endif

#ifndef MICROBIT_APP_REGION_END
#define MICROBIT_APP_REGION_END ( MICROBIT_DEFAULT_SCRATCH_PAGE)
Expand Down
5 changes: 5 additions & 0 deletions model/MicroBit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,8 @@ void microbit_dmesg_flush()
#endif
}

uint32_t *microbit_top_of_flash()
{
return (uint32_t *) MICROBIT_TOP_OF_FLASH;
}

1 change: 1 addition & 0 deletions model/MicroBit.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ namespace codal
}

void microbit_dmesg_flush();
uint32_t *microbit_top_of_flash();

#if CONFIG_ENABLED(CODAL_USE_GLOBAL_NAMESPACE)
using namespace codal;
Expand Down

0 comments on commit 9390b19

Please sign in to comment.