From ed099f1cea9e554a410ff81ebfe8537bf8a56ad7 Mon Sep 17 00:00:00 2001 From: Yanfeng Liu Date: Sat, 29 Jun 2024 09:42:57 +0800 Subject: [PATCH] riscv/k230: revise canmv230:nsbi This revises ld-nuttsbi.script for easier use. It also adjusts canmv230/nsbi to fit both k230d and k230 devices. Signed-off-by: Yanfeng Liu --- .../k230/canmv230/configs/nsbi/defconfig | 8 +-- .../k230/canmv230/scripts/ld-nuttsbi.script | 53 +++++++++++++++++-- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/boards/risc-v/k230/canmv230/configs/nsbi/defconfig b/boards/risc-v/k230/canmv230/configs/nsbi/defconfig index 2fd563fd66..f47007c8b1 100644 --- a/boards/risc-v/k230/canmv230/configs/nsbi/defconfig +++ b/boards/risc-v/k230/canmv230/configs/nsbi/defconfig @@ -31,9 +31,9 @@ CONFIG_ARCH_HEAP_VBASE=0xC0200000 CONFIG_ARCH_INTERRUPTSTACK=3072 CONFIG_ARCH_KERNEL_STACKSIZE=3072 CONFIG_ARCH_PGPOOL_MAPPING=y -CONFIG_ARCH_PGPOOL_PBASE=0x8600000 -CONFIG_ARCH_PGPOOL_SIZE=10485760 -CONFIG_ARCH_PGPOOL_VBASE=0x8600000 +CONFIG_ARCH_PGPOOL_PBASE=0x6200000 +CONFIG_ARCH_PGPOOL_SIZE=14680064 +CONFIG_ARCH_PGPOOL_VBASE=0x6200000 CONFIG_ARCH_RISCV=y CONFIG_ARCH_TEXT_NPAGES=128 CONFIG_ARCH_TEXT_VBASE=0xC0000000 @@ -76,7 +76,7 @@ CONFIG_NUTTSBI_MTIMECMP_BASE=0xf04004000 CONFIG_NUTTSBI_MTIME_BASE=0xf0400bff8 CONFIG_PATH_INITIAL="/system/bin" CONFIG_RAM_SIZE=16777216 -CONFIG_RAM_START=0x8080000 +CONFIG_RAM_START=0x6000000 CONFIG_RAW_BINARY=y CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 diff --git a/boards/risc-v/k230/canmv230/scripts/ld-nuttsbi.script b/boards/risc-v/k230/canmv230/scripts/ld-nuttsbi.script index 1c0ace8b2f..725a5fdad3 100644 --- a/boards/risc-v/k230/canmv230/scripts/ld-nuttsbi.script +++ b/boards/risc-v/k230/canmv230/scripts/ld-nuttsbi.script @@ -18,16 +18,59 @@ * ****************************************************************************/ +#include + +/* We use a linear layout of zones: kflash, ksram and pgpool. They are + * defined by CONFIG_RAM_xx and CONFIG_ARCH_PGPOOL_xx as below: + * + * |>--- CONFIG_RAM_SIZE ------------------------------------<| + * | |>- CONFIG_ARCH_PGPOOL_SIZE --<| + * +-------------+-------------+------------------------------+ + * | kflash/text : ksram zone | pgpool zone | + * +-------------+-------------+------------------------------+ + * ^CONFIG_RAM_START ^CONFIG_ARCH_PGPOOL_PBASE + * + * We require that: + * + * a) KRAM_TOTAL(= CONFIG_ARCH_PGPOOL_PBASE - CONFIG_RAM_START) > 0 + * b) CONFIG_RAM_SIZE == CONFIG_ARCH_PGPOOL_SIZE + KRAM_TOTAL + * + * The split of kernel memory can be adjusted below via KSRAM_SIZE + * The script warns if PGPOOL doesn't end at end of configured RAM. + */ + +#define PGRAM_ADDR (CONFIG_ARCH_PGPOOL_PBASE) +#define PGRAM_SIZE (CONFIG_ARCH_PGPOOL_SIZE) +#define PGRAM_END (PGRAM_ADDR + PGRAM_SIZE) +#define CFRAM_END (CONFIG_RAM_START + CONFIG_RAM_SIZE) + +#if (PGRAM_ADDR < CONFIG_RAM_START) || (PGRAM_END > CFRAM_END) +#error "invalid RAM or PGPOOL config!" +#endif + +#if (PGRAM_END < CFRAM_END) +#warning "wasted memory after PGPOOL!" +#endif + +/* Adjust KSRAM_SIZE here for your needs */ + +#define KSRAM_SIZE (KRAM_TOTAL * 3 / 4) + +#define KRAM_TOTAL (PGRAM_ADDR - KTEXT_ADDR) +#define KTEXT_SIZE (KRAM_TOTAL- KSRAM_SIZE) +#define KTEXT_ADDR (CONFIG_RAM_START) +#define KSRAM_ADDR (KTEXT_ADDR + KTEXT_SIZE) + MEMORY { - kflash (rx) : ORIGIN = 0x8000000, LENGTH = 384K /* w/ cache */ - ksram (rwx) : ORIGIN = 0x8080000, LENGTH = 128K /* w/ cache */ - pgram (rwx) : ORIGIN = 0x8600000, LENGTH = 10M /* w/ cache */ + kflash (rx) : ORIGIN = KTEXT_ADDR, LENGTH = KTEXT_SIZE + ksram (rwx) : ORIGIN = KSRAM_ADDR, LENGTH = KSRAM_SIZE + pgram (rwx) : ORIGIN = PGRAM_ADDR, LENGTH = PGRAM_SIZE } OUTPUT_ARCH("riscv") -/* Provide the kernel boundaries */ +/* Boundaries referred in board memory map header */ __kflash_start = ORIGIN(kflash); __kflash_size = LENGTH(kflash); @@ -42,7 +85,7 @@ __pgheap_size = LENGTH(pgram); SECTIONS { - . = 0x8000000; + . = KTEXT_ADDR; .text : {