summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-12-11 22:52:59 -0500
committerDan Halbert <halbert@halwitz.org>2019-12-11 22:52:59 -0500
commit8176325130422b89bd1eb778780d6655c79f271b (patch)
treecdb25ad587333a0fa0425cc132d028a644fcd6ea /supervisor
parentae64a669ddd47c5e5ed01b6f94f8c206f1f65cf6 (diff)
parentb220befef80018c9d0a280a98597e96cd5350808 (diff)
Merge remote-tracking branch 'adafruit/master' into ld-cleanup
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/shared/external_flash/external_flash.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c
index 99df553e1..9d38c07d8 100644
--- a/supervisor/shared/external_flash/external_flash.c
+++ b/supervisor/shared/external_flash/external_flash.c
@@ -324,6 +324,10 @@ static bool allocate_ram_cache(void) {
return true;
}
+ if (MP_STATE_MEM(gc_pool_start) == 0) {
+ return false;
+ }
+
MP_STATE_VM(flash_ram_cache) = m_malloc_maybe(blocks_per_sector * pages_per_block * sizeof(uint32_t), false);
if (MP_STATE_VM(flash_ram_cache) == NULL) {
return false;
@@ -367,7 +371,7 @@ static void release_ram_cache(void) {
if (supervisor_cache != NULL) {
free_memory(supervisor_cache);
supervisor_cache = NULL;
- } else {
+ } else if (MP_STATE_MEM(gc_pool_start)) {
m_free(MP_STATE_VM(flash_ram_cache));
}
MP_STATE_VM(flash_ram_cache) = NULL;
@@ -415,7 +419,7 @@ static bool flush_ram_cache(bool keep_cache) {
write_flash(current_sector + (i * pages_per_block + j) * SPI_FLASH_PAGE_SIZE,
MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j],
SPI_FLASH_PAGE_SIZE);
- if (!keep_cache && supervisor_cache == NULL) {
+ if (!keep_cache && supervisor_cache == NULL && MP_STATE_MEM(gc_pool_start)) {
m_free(MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j]);
}
}