diff options
| author | Dan Halbert <halbert@halwitz.org> | 2019-10-28 18:15:02 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2019-10-28 18:15:02 -0400 |
| commit | 1505da784f228d43df41a773cfe504e7e4da330a (patch) | |
| tree | 67381e6cc5e9a63b7374b008ff9bfff36f9f680b | |
| parent | 7b79ac37399927070e1931022f5759393202ed3d (diff) | |
wip
| -rw-r--r-- | ports/atmel-samd/boards/common.template.ld | 10 | ||||
| -rw-r--r-- | ports/atmel-samd/boards/sam32/mpconfigboard.h | 2 | ||||
| -rw-r--r-- | ports/atmel-samd/ld_defines.c | 7 | ||||
| -rw-r--r-- | ports/atmel-samd/mpconfigport.h | 36 | ||||
| -rw-r--r-- | ports/atmel-samd/supervisor/internal_flash.c | 2 | ||||
| -rw-r--r-- | ports/atmel-samd/supervisor/internal_flash.h | 11 | ||||
| -rw-r--r-- | py/circuitpy_mpconfig.h | 6 |
7 files changed, 41 insertions, 33 deletions
diff --git a/ports/atmel-samd/boards/common.template.ld b/ports/atmel-samd/boards/common.template.ld index e02bbfab0..aebda87c2 100644 --- a/ports/atmel-samd/boards/common.template.ld +++ b/ports/atmel-samd/boards/common.template.ld @@ -3,15 +3,7 @@ /* Specify the memory areas */ MEMORY { - /* CIRCUITPY_BOOTLOADER_SIZE is size of bootloader, if any. - * SAMD21 Arduino and UF2 bootloaders are 8KiB. SAMD51 UF2 is 6KiB. - * FLASH_SIZE is defined in ASF4. - * RAM_SIZE is defined in mpconfigport.h, from constants from ASF4. - * CIRCUITPY_INTERNAL_CONFIG_SIZE is size of an optional hidden config area, used currently - * for crystalless USB timing calibration. - * CIRCUITPY_INTERNAL_NVM_SIZE is the size of microntroller.nvm. - */ - FLASH (rx) : ORIGIN = 0x00000000 + ${BOOTLOADER_SIZE}, LENGTH = ${FLASH_SIZE} - ${BOOTLOADER_SIZE} - ${CIRCUITPY_INTERNAL_CONFIG_SIZE} - ${CIRCUITPY_INTERNAL_NVM_SIZE} + FLASH (rx) : ORIGIN = 0x00000000 + ${BOOTLOADER_SIZE}, LENGTH = ${CIRCUITPY_FIRMWARE_SIZE} RAM (xrw) : ORIGIN = 0x20000000, LENGTH = ${RAM_SIZE} } diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.h b/ports/atmel-samd/boards/sam32/mpconfigboard.h index 3c6f52ebc..bd9f5e398 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.h +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.h @@ -9,7 +9,7 @@ #define MICROPY_PORT_A (PORT_PA24 | PORT_PA25) #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define MICROPY_PORT_D (0) +#define MICROPY_PORT_D (0) // No microcontroller.nvm #define CIRCUITPY_INTERNAL_NVM_SIZE 0 diff --git a/ports/atmel-samd/ld_defines.c b/ports/atmel-samd/ld_defines.c index 62838ca4b..d8a7a209b 100644 --- a/ports/atmel-samd/ld_defines.c +++ b/ports/atmel-samd/ld_defines.c @@ -7,8 +7,7 @@ // This will be post-processed by tools/gen_ld_files.py to extract the name and vlaue. BOOTLOADER_SIZE; ///DEFINE_VALUE BOOTLOADER_SIZE -RAM_SIZE; ///DEFINE_VALUE RAM_SIZE lambda f: f.rstrip("UL") -FLASH_SIZE; ///DEFINE_VALUE FLASH_SIZE lambda f: f.rstrip("UL") -CIRCUITPY_INTERNAL_CONFIG_SIZE; ///DEFINE_VALUE CIRCUITPY_INTERNAL_CONFIG_SIZE -CIRCUITPY_INTERNAL_NVM_SIZE; ///DEFINE_VALUE CIRCUITPY_INTERNAL_NVM_SIZE +RAM_SIZE; ///DEFINE_VALUE RAM_SIZE def noUL(expr): import re; return re.sub( +FLASH_SIZE; ///DEFINE_VALUE FLASH_SIZE lambda expr: expr.rstrip("UL") +CIRCUITPY_FIRMWARE_SIZE; ///DEFINE_VALUE CIRCUITPY_FIRMWARE_SIZE CIRCUITPY_DEFAULT_STACK_SIZE; ///DEFINE_VALUE CIRCUITPY_DEFAULT_STACK_SIZE diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 21adb1002..3334ce153 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -32,10 +32,10 @@ #ifdef SAMD21 -// Default is 0, set by py/circuitpy_mpconfig.h #if INTERNAL_FLASH_FILESYSTEM -// 64kB -#define INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024) +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024) +#else +#define CIRCUITPYINTERNAL_FLASH_FILESYSTEM_SIZE (0) #endif #ifndef CIRCUITPY_INTERNAL_NVM_SIZE @@ -86,6 +86,15 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE (8192) #endif +// If CIRCUITPY is internal, use half of flash for it. +#ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE + #if INTERNAL_FLASH_FILESYSTEM + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (FLASH_SIZE/2) + #else + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) + #endif +#endif + // HSRAM_SIZE is defined in the ASF4 include files for each SAMD51 chip. #define RAM_SIZE HSRAM_SIZE #define BOOTLOADER_SIZE (16*1024) @@ -104,6 +113,27 @@ #endif // SAMD51 +// Flash layout, starting at 0x00000000 +// +// bootloader (8 or 16kB) +// firmware +// internal config, used to store crystalless clock calibration info (optional) +// microntroller.nvm (optional) +// internal CIRCUITPY flash filesystem (optional) + +// Bootloader starts at 0x00000000. +#define CIRCUITPY_FIRMWARE_START_ADDR BOOTLOADER_SIZE + +// Total space available for code, after subtracting size of other regions used for non-code. +#define CIRCUITPY_FIRMWARE_SIZE \ + (FLASH_SIZE - BOOTLOADER_SIZE - CIRCUITPY_INTERNAL_CONFIG_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE - \ + CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE) + +#define CIRCUITPY_INTERNAL_CONFIG_START_ADDR (CIRCUITPY_FIRMWARE_START_ADDR + CIRCUITPY_FIRMWARE_SIZE) +#define CIRCUITPY_INTERNAL_NVM_START_ADDR (CIRCUITPY_INTERNAL_CONFIG_START_ADDR + CIRCUITPY_INTERNAL_CONFIG_SIZE) +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR \ + (CIRCUITPY_INTERNAL_NVM_START_ADDR + CIRCUITPY_INTERNAL_NVM_SIZE) + // Turning off audioio, audiobusio, and touchio as necessary // due to limitations of chips is handled in mpconfigboard.mk diff --git a/ports/atmel-samd/supervisor/internal_flash.c b/ports/atmel-samd/supervisor/internal_flash.c index 6dd5ac0a7..a8ff5adfa 100644 --- a/ports/atmel-samd/supervisor/internal_flash.c +++ b/ports/atmel-samd/supervisor/internal_flash.c @@ -86,7 +86,7 @@ void flash_flush(void) { static int32_t convert_block_to_flash_addr(uint32_t block) { if (0 <= block && block < INTERNAL_FLASH_PART1_NUM_BLOCKS) { // a block in partition 1 - return INTERNAL_FLASH_MEM_SEG1_START_ADDR + block * FILESYSTEM_BLOCK_SIZE; + return CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR + block * FILESYSTEM_BLOCK_SIZE; } // bad block return -1; diff --git a/ports/atmel-samd/supervisor/internal_flash.h b/ports/atmel-samd/supervisor/internal_flash.h index 0939a3454..df8b495cc 100644 --- a/ports/atmel-samd/supervisor/internal_flash.h +++ b/ports/atmel-samd/supervisor/internal_flash.h @@ -32,16 +32,7 @@ #include "sam.h" -#ifdef SAMD51 -#define TOTAL_INTERNAL_FLASH_SIZE (FLASH_SIZE / 2) -#endif - -#ifdef SAMD21 -#define TOTAL_INTERNAL_FLASH_SIZE 0x010000 -#endif - -#define INTERNAL_FLASH_MEM_SEG1_START_ADDR (FLASH_SIZE - TOTAL_INTERNAL_FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE) -#define INTERNAL_FLASH_PART1_NUM_BLOCKS (TOTAL_INTERNAL_FLASH_SIZE / FILESYSTEM_BLOCK_SIZE) +#define INTERNAL_FLASH_PART1_NUM_BLOCKS (CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE) #define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms #define INTERNAL_FLASH_IDLE_TICK(tick) (((tick) & INTERNAL_FLASH_SYSTICK_MASK) == 2) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 91e2e223c..227376ead 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -167,6 +167,7 @@ typedef long mp_off_t; #define mp_import_stat mp_vfs_import_stat #define mp_builtin_open_obj mp_vfs_open_obj + // extra built in names to add to the global namespace #define MICROPY_PORT_BUILTINS \ { MP_OBJ_NEW_QSTR(MP_QSTR_help), (mp_obj_t)&mp_builtin_help_obj }, \ @@ -669,11 +670,6 @@ void run_background_tasks(void); #define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000 #endif -// Default is no internal flash filesystem. -#ifndef INTERNAL_FLASH_FILESYSTEM_SIZE -#define INTERNAL_FLASH_FILESYSTEM_SIZE (0) -#endif - #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" #endif // __INCLUDED_MPCONFIG_CIRCUITPY_H |
