crypto-aes
Dan Halbert 3 years ago
parent 7b79ac3739
commit 1505da784f
  1. 10
      ports/atmel-samd/boards/common.template.ld
  2. 2
      ports/atmel-samd/boards/sam32/mpconfigboard.h
  3. 7
      ports/atmel-samd/ld_defines.c
  4. 36
      ports/atmel-samd/mpconfigport.h
  5. 2
      ports/atmel-samd/supervisor/internal_flash.c
  6. 11
      ports/atmel-samd/supervisor/internal_flash.h
  7. 6
      py/circuitpy_mpconfig.h

@ -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}
}

@ -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

@ -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

@ -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

@ -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;

@ -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)

@ -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

Loading…
Cancel
Save