Fixups for adafruit/circuitpython#1042
This commit is contained in:
parent
02dd32da60
commit
83dad37562
@ -74,12 +74,9 @@ const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
|
||||
.base = {
|
||||
.type = &nvm_bytearray_type,
|
||||
},
|
||||
.len = CIRCUITPY_INTERNAL_NVM_SIZE,
|
||||
.start_address = FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_P0_00), MP_ROM_PTR(&pin_P0_00) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_P0_01), MP_ROM_PTR(&pin_P0_01) },
|
||||
|
@ -25,4 +25,10 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define FLASH_PAGE_SIZE (4096)
|
||||
|
||||
#ifndef CIRCUITPY_INTERNAL_NVM_SIZE
|
||||
#define CIRCUITPY_INTERNAL_NVM_SIZE (0)
|
||||
#endif
|
||||
|
||||
void nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data);
|
||||
|
@ -67,13 +67,21 @@ uint32_t supervisor_flash_get_block_size(void) {
|
||||
}
|
||||
|
||||
uint32_t supervisor_flash_get_block_count(void) {
|
||||
return ((uint32_t) __fatfs_flash_length - CIRCUITPY_INTERNVAL_NVM_SIZE) / FILESYSTEM_BLOCK_SIZE ;
|
||||
return ((uint32_t) __fatfs_flash_length - CIRCUITPY_INTERNAL_NVM_SIZE) / FILESYSTEM_BLOCK_SIZE ;
|
||||
}
|
||||
|
||||
void supervisor_flash_flush(void) {
|
||||
if (_flash_page_addr == NO_CACHE) return;
|
||||
|
||||
// Skip if data is the same
|
||||
if (memcmp(_flash_cache, (void *)_flash_page_addr, FLASH_PAGE_SIZE) != 0) {
|
||||
nrf_nvm_safe_flash_page_write(_flash_page_addr, _flash_cache);
|
||||
}
|
||||
}
|
||||
|
||||
mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {
|
||||
// Must write out anything in cache before trying to read.
|
||||
nrf_nvm_safe_flash_page_write(_flash_page_addr, _flash_cache);
|
||||
_flash_page_addr = NO_CACHE;
|
||||
supervisor_flash_flush();
|
||||
|
||||
uint32_t src = lba2addr(block);
|
||||
memcpy(dest, (uint8_t*) src, FILESYSTEM_BLOCK_SIZE*num_blocks);
|
||||
@ -107,3 +115,7 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
|
||||
|
||||
return 0; // success
|
||||
}
|
||||
|
||||
void supervisor_flash_release_cache(void) {
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,6 @@
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
|
||||
#define FLASH_PAGE_SIZE 0x1000
|
||||
|
||||
#define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms
|
||||
#define INTERNAL_FLASH_IDLE_TICK(tick) (((tick) & INTERNAL_FLASH_SYSTICK_MASK) == 2)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user