riscv/k230: revise canmv230:pnsh
This revises canm230:pnsh in a few ways: - adjusting linker scripts structure, - asserting PMP setting results, - adjusting configs for both k230d and k230 devices. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
parent
723cbb0170
commit
211e2cd8b9
8 changed files with 92 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -46,6 +46,7 @@
|
|||
/nuttx
|
||||
/nuttx-*
|
||||
/nuttx.*
|
||||
/nuttx_user*
|
||||
/staging
|
||||
/tags
|
||||
/TAGS
|
||||
|
|
|
@ -127,8 +127,11 @@ void k230_userspace(void)
|
|||
|
||||
static void configure_mpu(void)
|
||||
{
|
||||
riscv_append_pmp_region(UFLASH_F, UFLASH_START, UFLASH_SIZE);
|
||||
riscv_append_pmp_region(USRAM_F, USRAM_START, USRAM_SIZE);
|
||||
int ret;
|
||||
ret = riscv_append_pmp_region(UFLASH_F, UFLASH_START, UFLASH_SIZE);
|
||||
DEBUGASSERT(ret == 0);
|
||||
ret = riscv_append_pmp_region(USRAM_F, USRAM_START, USRAM_SIZE);
|
||||
DEBUGASSERT(ret == 0);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BUILD_PROTECTED */
|
||||
|
|
2
boards/risc-v/k230/canmv230/.gitignore
vendored
Normal file
2
boards/risc-v/k230/canmv230/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
kernel/nuttx_user*
|
||||
scripts/*.tmp
|
|
@ -48,11 +48,11 @@ CONFIG_NSH_ARCHINIT=y
|
|||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NUTTX_USERSPACE=0x8040000
|
||||
CONFIG_NUTTX_USERSPACE=0x6040000
|
||||
CONFIG_PASS1_BUILDIR="boards/risc-v/k230/canmv230/kernel"
|
||||
CONFIG_PATH_INITIAL="/system/bin"
|
||||
CONFIG_RAM_SIZE=16777216
|
||||
CONFIG_RAM_START=0x8000000
|
||||
CONFIG_RAM_SIZE=3145728
|
||||
CONFIG_RAM_START=0x6000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
|
|
|
@ -30,12 +30,12 @@ ENTRYPT = $(patsubst "%",%,$(CONFIG_INIT_ENTRYPOINT))
|
|||
# is appropriate for the host OS
|
||||
|
||||
USER_LIBPATHS = $(addprefix -L,$(call CONVERT_PATH,$(addprefix $(TOPDIR)$(DELIM),$(dir $(USERLIBS)))))
|
||||
USER_LDSCRIPT = -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)ld-userland.script)
|
||||
USER_LDSCRIPT = $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)ld-userland.script)
|
||||
USER_HEXFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.hex)
|
||||
USER_SRECFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.srec)
|
||||
USER_BINFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.bin)
|
||||
|
||||
USER_LDFLAGS = -melf64lriscv --undefined=$(ENTRYPT) --entry=$(ENTRYPT) $(USER_LDSCRIPT)
|
||||
USER_LDFLAGS = -melf64lriscv --undefined=$(ENTRYPT) --entry=$(ENTRYPT) -T $(addsuffix .tmp,$(USER_LDSCRIPT))
|
||||
USER_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(USERLIBS))))
|
||||
USER_LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}"
|
||||
|
||||
|
@ -47,19 +47,22 @@ OBJS = $(COBJS)
|
|||
|
||||
# Targets:
|
||||
|
||||
all: $(TOPDIR)$(DELIM)nuttx_user.elf $(TOPDIR)$(DELIM)User.map
|
||||
.PHONY: nuttx_user.elf depend clean distclean
|
||||
all: $(TOPDIR)$(DELIM)nuttx_user $(TOPDIR)$(DELIM)User.map
|
||||
.PHONY: nuttx_user depend clean distclean
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(addsuffix .tmp,$(USER_LDSCRIPT)): $(USER_LDSCRIPT)
|
||||
$(call PREPROCESS,$(patsubst %.tmp,%,$@),$@)
|
||||
|
||||
# Create the nuttx_user.elf file containing all of the user-mode code
|
||||
|
||||
nuttx_user.elf: $(OBJS)
|
||||
nuttx_user: $(OBJS) $(addsuffix .tmp,$(USER_LDSCRIPT))
|
||||
$(Q) $(LD) -o $@ $(USER_LDFLAGS) $(USER_LIBPATHS) $(OBJS) --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC)
|
||||
|
||||
$(TOPDIR)$(DELIM)nuttx_user.elf: nuttx_user.elf
|
||||
@echo "LD: nuttx_user.elf"
|
||||
$(TOPDIR)$(DELIM)nuttx_user: nuttx_user
|
||||
@echo "LD: nuttx_user"
|
||||
$(Q) cp -a $^ $(TOPDIR)$(DELIM)$^
|
||||
ifeq ($(CONFIG_INTELHEX_BINARY),y)
|
||||
@echo "CP: nuttx_user.hex"
|
||||
|
@ -74,17 +77,17 @@ ifeq ($(CONFIG_RAW_BINARY),y)
|
|||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $^ $(USER_BINFILE)
|
||||
endif
|
||||
|
||||
$(TOPDIR)$(DELIM)User.map: nuttx_user.elf
|
||||
$(TOPDIR)$(DELIM)User.map: nuttx_user
|
||||
@echo "MK: User.map"
|
||||
$(Q) $(NM) -n $^ >$(TOPDIR)$(DELIM)User.map
|
||||
$(Q) $(CROSSDEV)size $^
|
||||
|
||||
.depend:
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, nuttx_user.elf)
|
||||
$(call DELFILE, nuttx_user)
|
||||
$(call DELFILE, $(addsuffix .tmp,$(USER_LDSCRIPT)))
|
||||
$(call DELFILE, "$(TOPDIR)$(DELIM)nuttx_user.*")
|
||||
$(call DELFILE, "$(TOPDIR)$(DELIM)User.map")
|
||||
$(call CLEAN)
|
||||
|
|
66
boards/risc-v/k230/canmv230/scripts/ld-protected.mem
Normal file
66
boards/risc-v/k230/canmv230/scripts/ld-protected.mem
Normal file
|
@ -0,0 +1,66 @@
|
|||
/****************************************************************************
|
||||
* boards/risc-v/k230/canmv230/scripts/ld-protected.mem
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/* Memory layout for ld-protected.script and ld-userland.script
|
||||
*
|
||||
* |-CONFIG_RAM_START
|
||||
* | |-CONFIG_NUTTX_USERSPACE
|
||||
* +--------+----------+--------+--------+
|
||||
* | kflash | uflash | ksram | usram |
|
||||
* +--------+----------+--------+--------+
|
||||
* |>-- FLASH_SIZE ---<|>-- SRAM_SIZE --<|
|
||||
*
|
||||
*/
|
||||
|
||||
#define KFLASH_ADDR (CONFIG_RAM_START)
|
||||
#define UFLASH_ADDR (CONFIG_NUTTX_USERSPACE)
|
||||
#define KFLASH_SIZE (UFLASH_ADDR - KFLASH_ADDR)
|
||||
#define UFLASH_SIZE (KFLASH_SIZE)
|
||||
|
||||
#define FLASH_SIZE (0x100000) /* needs be POT */
|
||||
#define SRAM_SIZE (0x200000) /* needs be POT */
|
||||
|
||||
#if KFLASH_SIZE < 0
|
||||
#error "Invalid KFLASH_SIZE!"
|
||||
#endif
|
||||
|
||||
#if KFLASH_SIZE + UFLASH_SIZE > FLASH_SIZE
|
||||
#error "Adjust FLASH_SIZE please!"
|
||||
#endif
|
||||
|
||||
#if CONFIG_RAM_SIZE < FLASH_SIZE + SRAM_SIZE
|
||||
#error "CONFIG_RAM_SIZE too small?"
|
||||
#endif
|
||||
|
||||
#define KSRAM_SIZE (SRAM_SIZE / 2)
|
||||
#define USRAM_SIZE (SRAM_SIZE - KSRAM_SIZE)
|
||||
|
||||
#define KSRAM_ADDR (KFLASH_ADDR + FLASH_SIZE)
|
||||
#define USRAM_ADDR (KSRAM_ADDR + KSRAM_SIZE)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
kflash (rx) : ORIGIN = KFLASH_ADDR, LENGTH = KFLASH_SIZE
|
||||
uflash (rx) : ORIGIN = UFLASH_ADDR, LENGTH = UFLASH_SIZE
|
||||
ksram (rwx) : ORIGIN = KSRAM_ADDR, LENGTH = KSRAM_SIZE
|
||||
usram (rwx) : ORIGIN = USRAM_ADDR, LENGTH = USRAM_SIZE
|
||||
}
|
|
@ -18,17 +18,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* NOTE: This shares memory layout with ld-userland.script */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
kflash (rx) : ORIGIN = 0x8000000, LENGTH = 256K /* w/ cache */
|
||||
uflash (rx) : ORIGIN = 0x8040000, LENGTH = 256K /* w/ cache */
|
||||
|
||||
ksram (rwx) : ORIGIN = 0x8200000, LENGTH = 1024K /* w/ cache */
|
||||
usram (rwx) : ORIGIN = 0x8300000, LENGTH = 1024K /* w/ cache */
|
||||
}
|
||||
|
||||
#include "ld-protected.mem"
|
||||
|
||||
OUTPUT_ARCH("riscv")
|
||||
|
||||
|
|
|
@ -18,16 +18,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* NOTE: This shares memory layout with ld-protected.script */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
kflash (rx) : ORIGIN = 0x8000000, LENGTH = 256K /* w/ cache */
|
||||
uflash (rx) : ORIGIN = 0x8040000, LENGTH = 256K /* w/ cache */
|
||||
|
||||
ksram (rwx) : ORIGIN = 0x8200000, LENGTH = 1024K /* w/ cache */
|
||||
usram (rwx) : ORIGIN = 0x8300000, LENGTH = 1024K /* w/ cache */
|
||||
}
|
||||
#include "ld-protected.mem"
|
||||
|
||||
OUTPUT_ARCH("riscv")
|
||||
|
||||
|
|
Loading…
Reference in a new issue