mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 09:00:23 +08:00
renesas-ra/boards: Update linker script to detect code flash overflow.
Changes in this commit: - Add FLASH_FS region to linker script. - Add flash storage start & end symbols to linker script. - Use flash storage start & end symbols in flashbdev.c Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
This commit is contained in:
parent
e35bcb0f0b
commit
45a85f5a35
@ -5,7 +5,8 @@
|
|||||||
/* Linker script to configure memory regions. */
|
/* Linker script to configure memory regions. */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 /* 256KB */
|
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00037000 /* 220KB/256KB */
|
||||||
|
FLASH_FS (r) : ORIGIN = 0x00037000, LENGTH = 0x00009000 /* 36KB/256KB */
|
||||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* 32KB */
|
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* 32KB */
|
||||||
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00002000 /* 8KB */
|
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00002000 /* 8KB */
|
||||||
ID_CODE (rx) : ORIGIN = 0x01010018, LENGTH = 0x00000020 /* 32bytes */
|
ID_CODE (rx) : ORIGIN = 0x01010018, LENGTH = 0x00000020 /* 32bytes */
|
||||||
@ -296,3 +297,6 @@ _ram_start = ORIGIN(RAM);
|
|||||||
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
||||||
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
||||||
_heap_end = __HeapLimit; /* tunable */
|
_heap_end = __HeapLimit; /* tunable */
|
||||||
|
|
||||||
|
_micropy_hw_internal_flash_storage_start = ORIGIN(FLASH_FS);
|
||||||
|
_micropy_hw_internal_flash_storage_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS);
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
/* Linker script to configure memory regions. */
|
/* Linker script to configure memory regions. */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 /* 256KB */
|
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00037000 /* 220KB/256KB */
|
||||||
|
FLASH_FS (r) : ORIGIN = 0x00037000, LENGTH = 0x00009000 /* 36KB/256KB */
|
||||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* 32KB */
|
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* 32KB */
|
||||||
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00002000 /* 8KB */
|
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00002000 /* 8KB */
|
||||||
ID_CODE (rx) : ORIGIN = 0x01010018, LENGTH = 0x00000020 /* 32bytes */
|
ID_CODE (rx) : ORIGIN = 0x01010018, LENGTH = 0x00000020 /* 32bytes */
|
||||||
@ -296,3 +297,6 @@ _ram_start = ORIGIN(RAM);
|
|||||||
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
||||||
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
||||||
_heap_end = __HeapLimit; /* tunable */
|
_heap_end = __HeapLimit; /* tunable */
|
||||||
|
|
||||||
|
_micropy_hw_internal_flash_storage_start = ORIGIN(FLASH_FS);
|
||||||
|
_micropy_hw_internal_flash_storage_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS);
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
/* Linker script to configure memory regions. */
|
/* Linker script to configure memory regions. */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000 /* 512KB */
|
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00070000 /* 448KB/512KB */
|
||||||
|
FLASH_FS (r) : ORIGIN = 0x00070000, LENGTH = 0x00010000 /* 64KB/512KB */
|
||||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00018000 /* 96KB */
|
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00018000 /* 96KB */
|
||||||
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00002000 /* 8KB */
|
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00002000 /* 8KB */
|
||||||
ID_CODE (rx) : ORIGIN = 0x01010018, LENGTH = 0x00000020 /* 32bytes */
|
ID_CODE (rx) : ORIGIN = 0x01010018, LENGTH = 0x00000020 /* 32bytes */
|
||||||
@ -296,3 +297,6 @@ _ram_start = ORIGIN(RAM);
|
|||||||
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
||||||
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
||||||
_heap_end = __HeapLimit; /* tunable */
|
_heap_end = __HeapLimit; /* tunable */
|
||||||
|
|
||||||
|
_micropy_hw_internal_flash_storage_start = ORIGIN(FLASH_FS);
|
||||||
|
_micropy_hw_internal_flash_storage_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS);
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
/* Linker script to configure memory regions. */
|
/* Linker script to configure memory regions. */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000 /* 512KB */
|
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00060000 /* 384KB/512KB */
|
||||||
|
FLASH_FS (r) : ORIGIN = 0x00060000, LENGTH = 0x00020000 /* 128KB/512KB */
|
||||||
RAM (rwx) : ORIGIN = 0x1FFE0000, LENGTH = 0x00040000 /* 256KB */
|
RAM (rwx) : ORIGIN = 0x1FFE0000, LENGTH = 0x00040000 /* 256KB */
|
||||||
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00002000 /* 8KB */
|
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00002000 /* 8KB */
|
||||||
ID_CODE (rx) : ORIGIN = 0x0100A150, LENGTH = 0x00000010 /* 32bytes */
|
ID_CODE (rx) : ORIGIN = 0x0100A150, LENGTH = 0x00000010 /* 32bytes */
|
||||||
@ -296,3 +297,6 @@ _ram_start = ORIGIN(RAM);
|
|||||||
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
||||||
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
||||||
_heap_end = __HeapLimit; /* tunable */
|
_heap_end = __HeapLimit; /* tunable */
|
||||||
|
|
||||||
|
_micropy_hw_internal_flash_storage_start = ORIGIN(FLASH_FS);
|
||||||
|
_micropy_hw_internal_flash_storage_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS);
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
/* Linker script to configure memory regions. */
|
/* Linker script to configure memory regions. */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00100000 /* 1MB */
|
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x000e0000 /* 896KB/1MB */
|
||||||
|
FLASH_FS (r) : ORIGIN = 0x000e0000, LENGTH = 0x00020000 /* 128KB/1MB */
|
||||||
RAM (rwx) : ORIGIN = 0x1FFE0000, LENGTH = 0x00060000 /* 384KB */
|
RAM (rwx) : ORIGIN = 0x1FFE0000, LENGTH = 0x00060000 /* 384KB */
|
||||||
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00008000 /* 32KB */
|
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x00008000 /* 32KB */
|
||||||
ID_CODE (rx) : ORIGIN = 0x0100A150, LENGTH = 0x00000010 /* 32bytes */
|
ID_CODE (rx) : ORIGIN = 0x0100A150, LENGTH = 0x00000010 /* 32bytes */
|
||||||
@ -296,3 +297,6 @@ _ram_start = ORIGIN(RAM);
|
|||||||
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
||||||
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
_heap_start = __HeapBase; /* heap starts just after statically allocated memory */
|
||||||
_heap_end = __HeapLimit; /* tunable */
|
_heap_end = __HeapLimit; /* tunable */
|
||||||
|
|
||||||
|
_micropy_hw_internal_flash_storage_start = ORIGIN(FLASH_FS);
|
||||||
|
_micropy_hw_internal_flash_storage_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS);
|
||||||
|
@ -34,65 +34,30 @@
|
|||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#if defined(RA4M1) | defined(RA4M3) | defined(RA4W1) | defined(RA6M1) | defined(RA6M2) | defined(RA6M3)
|
|
||||||
#include "ra_flash.h"
|
#include "ra_flash.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
|
#if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
|
||||||
|
|
||||||
// #define DEBUG_FLASH_BDEV
|
// The linker script specifies flash storage locations.
|
||||||
|
extern uint8_t _micropy_hw_internal_flash_storage_start;
|
||||||
|
extern uint8_t _micropy_hw_internal_flash_storage_end;
|
||||||
|
|
||||||
// Here we try to automatically configure the location and size of the flash
|
#define FLASH_MEM_SEG1_START_ADDR \
|
||||||
// pages to use for the internal storage. We also configure the location of the
|
((long)&_micropy_hw_internal_flash_storage_start)
|
||||||
// cache used for writing.
|
#define FLASH_MEM_SEG1_NUM_BLOCKS \
|
||||||
|
((&_micropy_hw_internal_flash_storage_end - &_micropy_hw_internal_flash_storage_start) / 512)
|
||||||
|
|
||||||
#if defined(RA4M1)
|
#if defined(RA4M1) | defined(RA4M3) | defined(RA4W1)
|
||||||
|
|
||||||
STATIC byte flash_cache_mem[0x800] __attribute__((aligned(16))); // 2K
|
|
||||||
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
|
|
||||||
#define FLASH_SECTOR_SIZE_MAX (0x800) // 2k max
|
#define FLASH_SECTOR_SIZE_MAX (0x800) // 2k max
|
||||||
#define FLASH_MEM_SEG1_START_ADDR (0x37000) // sector 1
|
#elif defined(RA6M1) | defined(RA6M2) | defined(RA6M3)
|
||||||
#define FLASH_MEM_SEG1_NUM_BLOCKS (72) // sectors 1,2,...,72
|
|
||||||
|
|
||||||
#elif defined(RA4M3)
|
|
||||||
STATIC byte flash_cache_mem[0x800] __attribute__((aligned(16))); // 2K
|
|
||||||
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
|
|
||||||
#define FLASH_SECTOR_SIZE_MAX (0x800) // 2k max
|
|
||||||
#define FLASH_MEM_SEG1_START_ADDR (0x37000) // sector 1
|
|
||||||
#define FLASH_MEM_SEG1_NUM_BLOCKS (72) // sectors 1,2,...,72
|
|
||||||
|
|
||||||
#elif defined(RA4W1)
|
|
||||||
STATIC byte flash_cache_mem[0x800] __attribute__((aligned(16))); // 2K
|
|
||||||
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
|
|
||||||
#define FLASH_SECTOR_SIZE_MAX (0x800) // 2k max
|
|
||||||
#define FLASH_MEM_SEG1_START_ADDR (0x70000) // sector 1
|
|
||||||
#define FLASH_MEM_SEG1_NUM_BLOCKS (128) // sectors 1,2,...,128
|
|
||||||
|
|
||||||
#elif defined(RA6M1)
|
|
||||||
STATIC byte flash_cache_mem[0x8000] __attribute__((aligned(16))); // 32K
|
|
||||||
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
|
|
||||||
#define FLASH_SECTOR_SIZE_MAX (0x8000) // 32k max
|
#define FLASH_SECTOR_SIZE_MAX (0x8000) // 32k max
|
||||||
#define FLASH_MEM_SEG1_START_ADDR (0x60000) // sector 1
|
|
||||||
#define FLASH_MEM_SEG1_NUM_BLOCKS (256) // sectors 1,2,...,256
|
|
||||||
|
|
||||||
#elif defined(RA6M2)
|
|
||||||
STATIC byte flash_cache_mem[0x8000] __attribute__((aligned(16))); // 32K
|
|
||||||
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
|
|
||||||
#define FLASH_SECTOR_SIZE_MAX (0x8000) // 32k max
|
|
||||||
#define FLASH_MEM_SEG1_START_ADDR (0xe0000) // sector 1
|
|
||||||
#define FLASH_MEM_SEG1_NUM_BLOCKS (512) // sectors 1,2,...,512
|
|
||||||
|
|
||||||
#elif defined(RA6M3)
|
|
||||||
STATIC byte flash_cache_mem[0x8000] __attribute__((aligned(16))); // 32K
|
|
||||||
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
|
|
||||||
#define FLASH_SECTOR_SIZE_MAX (0x8000) // 32k max
|
|
||||||
#define FLASH_MEM_SEG1_START_ADDR (0x60000) // sector 1
|
|
||||||
#define FLASH_MEM_SEG1_NUM_BLOCKS (256) // sectors 1,2,...,256
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "no internal flash storage support for this MCU"
|
#error "no internal flash storage support for this MCU"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
STATIC byte flash_cache_mem[FLASH_SECTOR_SIZE_MAX] __attribute__((aligned(16)));
|
||||||
|
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
|
||||||
|
|
||||||
#if !defined(FLASH_MEM_SEG2_START_ADDR)
|
#if !defined(FLASH_MEM_SEG2_START_ADDR)
|
||||||
#define FLASH_MEM_SEG2_START_ADDR (0) // no second segment
|
#define FLASH_MEM_SEG2_START_ADDR (0) // no second segment
|
||||||
#define FLASH_MEM_SEG2_NUM_BLOCKS (0) // no second segment
|
#define FLASH_MEM_SEG2_NUM_BLOCKS (0) // no second segment
|
||||||
|
Loading…
Reference in New Issue
Block a user