Commit e374df3e authored by Yuri Tikhonov's avatar Yuri Tikhonov
Browse files

RT72064. cortex-m3: set linker memory layout via configuration files



Note, this patch also:
- removes the gap between RAM_BUF and MALLOC (additional 4K are
  used for MALLOC now: 8K -> 12K);
- exports memory layout via _mem_xxx symbols, so:
-- use _mem_ram_buf_xxx in cmd_cptf.c instead of hard-coded vals;
-- use _mem_stack_xxx instead of armboot_start;
-- use _mem_stack_end in start.c instead of hard-coded val.
Signed-off-by: default avatarYuri Tikhonov <yur@emcraft.com>
parent fbbaf013
......@@ -23,8 +23,10 @@
#include <string.h>
#include "envm.h"
#define SOC_RAM_BUFFER_BASE 0x20004000
#define SOC_RAM_BUFFER_SIZE 0x8000
extern char _mem_ram_buf_base, _mem_ram_buf_size;
#define SOC_RAM_BUFFER_BASE (ulong)(&_mem_ram_buf_base)
#define SOC_RAM_BUFFER_SIZE (ulong)(&_mem_ram_buf_size)
/*
* Write the eNVM and, optionally, reset the CPU.
......
......@@ -20,6 +20,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
PLATFORM_CPPFLAGS += -DCONFIG_MEM_NVM_BASE=$(CONFIG_MEM_NVM_BASE)
PLATFORM_CPPFLAGS += -DCONFIG_MEM_NVM_LEN=$(CONFIG_MEM_NVM_LEN)
PLATFORM_CPPFLAGS += -DCONFIG_MEM_RAM_BASE=$(CONFIG_MEM_RAM_BASE)
PLATFORM_CPPFLAGS += -DCONFIG_MEM_RAM_LEN=$(CONFIG_MEM_RAM_LEN)
PLATFORM_CPPFLAGS += -DCONFIG_MEM_RAM_BUF_LEN=$(CONFIG_MEM_RAM_BUF_LEN)
PLATFORM_CPPFLAGS += -DCONFIG_MEM_MALLOC_LEN=$(CONFIG_MEM_MALLOC_LEN)
PLATFORM_CPPFLAGS += -DCONFIG_MEM_STACK_LEN=$(CONFIG_MEM_STACK_LEN)
PLATFORM_CPPFLAGS += -I$(TOPDIR)/cpu/$(CPU)
PLATFORM_RELFLAGS += -g2 -mthumb -mcpu=cortex-m3 -fsigned-char -O2 -fno-builtin-puts -fno-common -ffixed-r8
......
......@@ -30,8 +30,8 @@ extern char _data_lma_start;
extern char _data_start;
extern char _data_end;
extern char _mem_stack_base, _mem_stack_end;
unsigned long _armboot_start;
extern char armboot_start;
extern char _bss_start;
extern char _bss_end;
......@@ -64,9 +64,8 @@ unsigned int vectors[] __attribute__((section(".vectors"))) = {
/*
* The first word is the stack base address (stack grows downwards)
* Stack is defined by reserving an area at high RAM in u-boot.lds.
* All A2F variants have at least 64K of internal Flash.
*/
[0] = 0x20010000,
[0] = (unsigned long)&_mem_stack_end,
/*
* Reset entry point
......@@ -123,7 +122,7 @@ void _start(void)
* the malloc pool right behind the stack. See how armboot_start
* is defined in the CPU specific .lds file.
*/
_armboot_start = (unsigned long)&armboot_start;
_armboot_start = (unsigned long)&_mem_stack_base;
start_armboot();
}
......
......@@ -25,11 +25,16 @@ ENTRY(_start)
MEMORY
{
NVM (r): ORIGIN = 0x00000000, LENGTH = 256K
RAM (rw): ORIGIN = 0x20000000, LENGTH = 16K
RAM_BUF (r): ORIGIN = 0x20004000, LENGTH = 32K
MALLOC (r): ORIGIN = 0x2000D000, LENGTH = 8K
STACK (r): ORIGIN = 0x2000F000, LENGTH = 4K
NVM (r): ORIGIN = CONFIG_MEM_NVM_BASE, \
LENGTH = CONFIG_MEM_NVM_LEN
RAM (rw): ORIGIN = CONFIG_MEM_RAM_BASE, \
LENGTH = CONFIG_MEM_RAM_LEN
RAM_BUF (r): ORIGIN = ORIGIN(RAM) + LENGTH(RAM), \
LENGTH = CONFIG_MEM_RAM_BUF_LEN
MALLOC (r): ORIGIN = ORIGIN(RAM_BUF) + LENGTH(RAM_BUF), \
LENGTH = CONFIG_MEM_MALLOC_LEN
STACK (r): ORIGIN = ORIGIN(MALLOC) + LENGTH(MALLOC), \
LENGTH = CONFIG_MEM_STACK_LEN
}
SECTIONS
......@@ -74,7 +79,6 @@ SECTIONS
.stack :
{
armboot_start = .;
*(.stack)
} >STACK
......@@ -83,3 +87,18 @@ SECTIONS
*(*)
}
}
/*
* Export memory addresses
*/
_mem_nvm_base = ORIGIN(NVM);
_mem_nvm_size = LENGTH(NVM);
_mem_ram_base = ORIGIN(RAM);
_mem_ram_size = LENGTH(RAM);
_mem_ram_buf_base = ORIGIN(RAM_BUF);
_mem_ram_buf_size = LENGTH(RAM_BUF);
_mem_malloc_base = ORIGIN(MALLOC);
_mem_malloc_size = LENGTH(MALLOC);
_mem_stack_base = ORIGIN(STACK);
_mem_stack_size = LENGTH(STACK);
_mem_stack_end = ORIGIN(STACK) + LENGTH(STACK);
......@@ -89,6 +89,22 @@
*/
#undef CONFIG_USE_IRQ
/*
* Memory layout configuration
*/
#define CONFIG_MEM_NVM_BASE (0x00000000)
#define CONFIG_MEM_NVM_LEN (256 * 1024)
#define CONFIG_MEM_RAM_BASE (0x20000000)
#define CONFIG_MEM_RAM_LEN (16 * 1024)
#define CONFIG_MEM_RAM_BUF_LEN (32 * 1024)
#define CONFIG_MEM_MALLOC_LEN (12 * 1024)
#define CONFIG_MEM_STACK_LEN (4 * 1024)
/*
* malloc() pool size
*/
#define CONFIG_SYS_MALLOC_LEN CONFIG_MEM_MALLOC_LEN
/*
* Configuration of the external memory
*/
......
......@@ -85,6 +85,22 @@
*/
#undef CONFIG_USE_IRQ
/*
* Memory layout configuration
*/
#define CONFIG_MEM_NVM_BASE (0x00000000)
#define CONFIG_MEM_NVM_LEN (256 * 1024)
#define CONFIG_MEM_RAM_BASE (0x20000000)
#define CONFIG_MEM_RAM_LEN (16 * 1024)
#define CONFIG_MEM_RAM_BUF_LEN (32 * 1024)
#define CONFIG_MEM_MALLOC_LEN (12 * 1024)
#define CONFIG_MEM_STACK_LEN (4 * 1024)
/*
* malloc() pool size
*/
#define CONFIG_SYS_MALLOC_LEN CONFIG_MEM_MALLOC_LEN
/*
* Configuration of the external memory
*/
......@@ -160,12 +176,6 @@
#define CONFIG_BAUDRATE 115200
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
/*
* MALLOC_LEN can't be more than the specified size!
* Refer to u-boot.lds for further details.
*/
#define CONFIG_SYS_MALLOC_LEN (1024*8)
/*
* Console I/O buffer size
*/
......
......@@ -86,6 +86,22 @@
*/
#undef CONFIG_USE_IRQ
/*
* Memory layout configuration
*/
#define CONFIG_MEM_NVM_BASE (0x00000000)
#define CONFIG_MEM_NVM_LEN (256 * 1024)
#define CONFIG_MEM_RAM_BASE (0x20000000)
#define CONFIG_MEM_RAM_LEN (16 * 1024)
#define CONFIG_MEM_RAM_BUF_LEN (32 * 1024)
#define CONFIG_MEM_MALLOC_LEN (12 * 1024)
#define CONFIG_MEM_STACK_LEN (4 * 1024)
/*
* malloc() pool size
*/
#define CONFIG_SYS_MALLOC_LEN CONFIG_MEM_MALLOC_LEN
/*
* Configuration of the external memory
*/
......@@ -161,12 +177,6 @@
#define CONFIG_BAUDRATE 115200
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
/*
* MALLOC_LEN can't be more than the specified size!
* Refer to u-boot.lds for further details.
*/
#define CONFIG_SYS_MALLOC_LEN (1024*8)
/*
* Console I/O buffer size
*/
......
......@@ -74,6 +74,22 @@
*/
#undef CONFIG_USE_IRQ
/*
* Memory layout configuration
*/
#define CONFIG_MEM_NVM_BASE (0x00000000)
#define CONFIG_MEM_NVM_LEN (1024 * 1024)
#define CONFIG_MEM_RAM_BASE (0x20000000)
#define CONFIG_MEM_RAM_LEN (16 * 1024)
#define CONFIG_MEM_RAM_BUF_LEN (32 * 1024)
#define CONFIG_MEM_MALLOC_LEN (12 * 1024)
#define CONFIG_MEM_STACK_LEN (4 * 1024)
/*
* malloc() pool size
*/
#define CONFIG_SYS_MALLOC_LEN CONFIG_MEM_MALLOC_LEN
/*
* Configuration of the external memory
*/
......@@ -99,12 +115,6 @@
#define CONFIG_BAUDRATE 115200
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
/*
* MALLOC_LEN can't be more than the specified size!
* Refer to u-boot.lds for further details.
*/
#define CONFIG_SYS_MALLOC_LEN (8 * 1024)
/*
* Console I/O buffer size
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment