Skip to content

Commit fdaff00

Browse files
committed
Make some space for NVM #1042
1 parent bcb87ff commit fdaff00

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

ports/nrf/boards/adafruit_nrf52840_s140_v6.ld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
0x000ED000..0x000F3FFF (28KB ) Private Config Data (Bonding, Keys, etc.)
1313
0x000AD000..0x000ECFFF (256KB) User Filesystem
14-
1514
0x00026000..0x000ACFFF (540KB) Application Code (including ISR vector)
1615
0x00001000..0x00025FFF (148KB) SoftDevice
1716
0x00000000..0x00000FFF (4KB) Master Boot Record

ports/nrf/common-hal/nvm/ByteArray.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@
3131

3232
#include "peripherals/nrf/nvm.h"
3333

34+
// defined in linker
35+
extern uint32_t __fatfs_flash_start_addr[];
36+
extern uint32_t __fatfs_flash_length[];
37+
38+
#define NVM_START_ADDR ((uint32_t)__fatfs_flash_start_addr + \
39+
(uint32_t)__fatfs_flash_length - CIRCUITPY_INTERNAL_NVM_SIZE)
40+
3441
uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) {
35-
return self->len;
42+
return CIRCUITPY_INTERNAL_NVM_SIZE;
3643
}
3744

3845
static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_t *bytes) {
@@ -52,7 +59,7 @@ static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_
5259
bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self,
5360
uint32_t start_index, uint8_t* values, uint32_t len) {
5461

55-
uint32_t address = self->start_address + start_index;
62+
uint32_t address = NVM_START_ADDR + start_index;
5663
uint32_t offset = address % FLASH_PAGE_SIZE;
5764
uint32_t page_addr = address - offset;
5865

@@ -69,5 +76,5 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self,
6976

7077
void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self,
7178
uint32_t start_index, uint32_t len, uint8_t* values) {
72-
memcpy(values, (uint8_t *)(self->start_address + start_index), len);
79+
memcpy(values, (uint8_t *)(NVM_START_ADDR + start_index), len);
7380
}

ports/nrf/peripherals/nrf/nvm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,19 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
//#include "py/obj.h"
2928
#include "py/runtime.h"
3029

3130
#include <stdio.h>
3231
#include <string.h>
3332

3433
#include "nrf_nvmc.h"
3534

35+
#define FLASH_PAGE_SIZE (4096)
36+
3637
#ifdef BLUETOOTH_SD
3738
#include "ble_drv.h"
3839
#include "nrf_sdm.h"
3940

40-
#define FLASH_PAGE_SIZE (4096)
41-
4241
STATIC void sd_flash_operation_start(void) {
4342
sd_flash_operation_status = SD_FLASH_OPERATION_IN_PROGRESS;
4443
}

ports/nrf/supervisor/internal_flash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ uint32_t supervisor_flash_get_block_size(void) {
6767
}
6868

6969
uint32_t supervisor_flash_get_block_count(void) {
70-
return ((uint32_t) __fatfs_flash_length) / FILESYSTEM_BLOCK_SIZE ;
70+
return ((uint32_t) __fatfs_flash_length - CIRCUITPY_INTERNVAL_NVM_SIZE) / FILESYSTEM_BLOCK_SIZE ;
7171
}
7272

7373
mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {

0 commit comments

Comments
 (0)