8000 atmel-samd: Introduce a nvm module for non-volatile byte-level memory… · adafruit/circuitpython@266be30 · GitHub
[go: up one dir, main page]

Skip to content

Commit 266be30

Browse files
tannewtdhalbert
authored andcommitted
atmel-samd: Introduce a nvm module for non-volatile byte-level memory access. (#203)
* atmel-samd: Introduce a nvm module for non-volatile byte-level memory access. This allows for persisting small configuration values even when the file system is read-only from CircuitPython. Fixes #160 * Review feedback: * Add tests. * Fix non-zero index. * Fix len()
1 parent dd1c4fc commit 266be30

32 files changed

+575
-25
lines changed

atmel-samd/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ SRC_COMMON_HAL = \
252252
microcontroller/__init__.c \
253253
microcontroller/Pin.c \
254254
neopixel_write/__init__.c \
255+
nvm/__init__.c \
256+
nvm/ByteArray.c \
255257
os/__init__.c \
256258
pulseio/__init__.c \
257259
pulseio/PulseIn.c \

atmel-samd/boards/arduino_zero/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212

1313
#include "internal_flash.h"
1414

15+
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
16+
1517
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)

atmel-samd/boards/circuitplayground_express/mpconfigboard.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525

2626
#include "spi_flash.h"
2727

28-
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000)
28+
// If you change this, then make sure to update the linker scripts as well to
29+
// make sure you don't overwrite code.
30+
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
31+
32+
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
2933

3034
#include "flash_S25FL216K.h"
3135
#include "flash_GD25Q16C.h"

atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111

1212
#include "internal_flash.h"
1313

14+
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
15+
1416
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)

atmel-samd/boards/feather_m0_basic/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111

1212
#include "internal_flash.h"
1313

14+
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
15+
1416
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)

atmel-samd/boards/feather_m0_express/mpconfigboard.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323

2424
#include "spi_flash.h"
2525

26-
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000)
26+
// If you change this, then make sure to update the linker scripts as well to
27+
// make sure you don't overwrite code.
28+
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
29+
30+
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
2731

2832
#include "flash_S25FL216K.h"
2933
#include "flash_GD25Q16C.h"

atmel-samd/boards/gemma_m0/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01 | PORT_PA24 | PORT_PA25)
1212
#define MICROPY_PORT_B (0)
1313

14+
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
15+
1416
#include "internal_flash.h"
1517

1618
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)

atmel-samd/boards/metro_m0_express/mpconfigboard.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525

2626
#include "spi_flash.h"
2727

28-
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000)
28+
// If you change this, then make sure to update the linker scripts as well to
29+
// make sure you don't overwrite code.
30+
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
31+
32+
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
2933

3034
#include "flash_S25FL216K.h"
3135
#include "flash_GD25Q16C.h"

atmel-samd/boards/samd21x18-bootloader-crystalless.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/* Specify the memory areas */
66
MEMORY
77
{
8-
/* Leave 8KiB for the bootloader, 256b for persistent config (clock), and 64k for the flash file system. */
9-
FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000 - 0x2000 - 0x100 - 0x010000
8+
/* Leave 8KiB for the bootloader, 256b for persistent config (clock), 64k for the flash file system and 256b for the user config. */
9+
FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000 - 0x2000 - 0x100 - 0x010000 - 0x100
1010
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x008000 /* 32 KiB */
1111
}
1212

atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
/* Specify the memory areas */
66
MEMORY
77
{
8-
FLASH (rx) : ORIGIN = 0x00000000 + 0x2000, LENGTH = 0x00040000 - 0x2000 - 0x100 /* Leave 8KiB for the bootloader and 256b for config. */
8+
/* Leave 8KiB for the bootloader, 256b for internal config and 256b for user config. */
9+
FLASH (rx) : ORIGIN = 0x00000000 + 0x2000, LENGTH = 0x00040000 - 0x2000 - 0x100 - 0x100
910
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x008000 /* 32 KiB */
1011
}
1112

0 commit comments

Comments
 (0)
0