This commit is contained in:
Nick Moore 2019-04-04 20:27:25 +11:00
parent f22c01a05e
commit 02dd32da60
4 changed files with 13 additions and 8 deletions

View File

@ -11,7 +11,6 @@
0x000ED000..0x000F3FFF (28KB ) Private Config Data (Bonding, Keys, etc.)
0x000AD000..0x000ECFFF (256KB) User Filesystem
0x00026000..0x000ACFFF (540KB) Application Code (including ISR vector)
0x00001000..0x00025FFF (148KB) SoftDevice
0x00000000..0x00000FFF (4KB) Master Boot Record

View File

@ -31,8 +31,15 @@
#include "peripherals/nrf/nvm.h"
// defined in linker
extern uint32_t __fatfs_flash_start_addr[];
extern uint32_t __fatfs_flash_length[];
#define NVM_START_ADDR ((uint32_t)__fatfs_flash_start_addr + \
(uint32_t)__fatfs_flash_length - CIRCUITPY_INTERNAL_NVM_SIZE)
uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) {
return self->len;
return CIRCUITPY_INTERNAL_NVM_SIZE;
}
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_
bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self,
uint32_t start_index, uint8_t* values, uint32_t len) {
uint32_t address = self->start_address + start_index;
uint32_t address = NVM_START_ADDR + start_index;
uint32_t offset = address % FLASH_PAGE_SIZE;
uint32_t page_addr = address - offset;
@ -69,5 +76,5 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self,
void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self,
uint32_t start_index, uint32_t len, uint8_t* values) {
memcpy(values, (uint8_t *)(self->start_address + start_index), len);
memcpy(values, (uint8_t *)(NVM_START_ADDR + start_index), len);
}

View File

@ -25,7 +25,6 @@
* THE SOFTWARE.
*/
//#include "py/obj.h"
#include "py/runtime.h"
#include <stdio.h>
@ -33,12 +32,12 @@
#include "nrf_nvmc.h"
#define FLASH_PAGE_SIZE (4096)
#ifdef BLUETOOTH_SD
#include "ble_drv.h"
#include "nrf_sdm.h"
#define FLASH_PAGE_SIZE (4096)
STATIC void sd_flash_operation_start(void) {
sd_flash_operation_status = SD_FLASH_OPERATION_IN_PROGRESS;
}

View File

@ -67,7 +67,7 @@ uint32_t supervisor_flash_get_block_size(void) {
}
uint32_t supervisor_flash_get_block_count(void) {
return ((uint32_t) __fatfs_flash_length) / FILESYSTEM_BLOCK_SIZE ;
return ((uint32_t) __fatfs_flash_length - CIRCUITPY_INTERNVAL_NVM_SIZE) / FILESYSTEM_BLOCK_SIZE ;
}
mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {