|
@@ -20,13 +20,22 @@
|
20
|
20
|
|
21
|
21
|
#include "hardware/flash.h"
|
22
|
22
|
#include "pico/flash.h"
|
|
23
|
+#include "pico/btstack_flash_bank.h"
|
23
|
24
|
|
24
|
25
|
#include "config.h"
|
25
|
26
|
#include "log.h"
|
26
|
27
|
#include "mem.h"
|
27
|
28
|
|
28
|
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
|
40
|
static struct mem_data data_ram = MEM_DATA_INIT;
|
32
|
41
|
static const uint8_t *data_flash = (const uint8_t *)(XIP_BASE + FLASH_OFFSET);
|