Browse Source

take into account flash pages used by btstack

Thomas Buck 1 year ago
parent
commit
2ea940b714
1 changed files with 10 additions and 1 deletions
  1. 10
    1
      src/mem.c

+ 10
- 1
src/mem.c View File

20
 
20
 
21
 #include "hardware/flash.h"
21
 #include "hardware/flash.h"
22
 #include "pico/flash.h"
22
 #include "pico/flash.h"
23
+#include "pico/btstack_flash_bank.h"
23
 
24
 
24
 #include "config.h"
25
 #include "config.h"
25
 #include "log.h"
26
 #include "log.h"
26
 #include "mem.h"
27
 #include "mem.h"
27
 
28
 
28
 #define FLASH_LOCK_TIMEOUT_MS 500
29
 #define FLASH_LOCK_TIMEOUT_MS 500
29
-#define FLASH_OFFSET (PICO_FLASH_SIZE_BYTES - FLASH_SECTOR_SIZE)
30
+
31
+/*
32
+ * Last two flash pages are used by BTstack.
33
+ * So we use the third-last page for our persistent storage.
34
+ */
35
+#define FLASH_OFFSET (PICO_FLASH_BANK_STORAGE_OFFSET - FLASH_SECTOR_SIZE)
36
+
37
+// TODO make sure last flash page is not filled by compiler
38
+// TODO add checksum
30
 
39
 
31
 static struct mem_data data_ram = MEM_DATA_INIT;
40
 static struct mem_data data_ram = MEM_DATA_INIT;
32
 static const uint8_t *data_flash = (const uint8_t *)(XIP_BASE + FLASH_OFFSET);
41
 static const uint8_t *data_flash = (const uint8_t *)(XIP_BASE + FLASH_OFFSET);

Loading…
Cancel
Save