Skip to content

Commit

Permalink
configs/imxrt1050-evk: Add knsh configuration.. PROTECTED mode NSH bu…
Browse files Browse the repository at this point in the history
…ild.
  • Loading branch information
gregory-nutt committed Jun 8, 2018
1 parent 8d73337 commit 05ad720
Show file tree
Hide file tree
Showing 17 changed files with 858 additions and 21 deletions.
4 changes: 2 additions & 2 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,8 @@ config ARM_MPU
depends on ARCH_HAVE_MPU
select ARCH_USE_MPU
---help---
Build in support for the ARM Cortex-M3/4 Memory Protection Unit (MPU).
Check your chip specifications first; not all Cortex-M3/4 chips
Build in support for the ARM Cortex-M3/4/7 Memory Protection Unit (MPU).
Check your chip specifications first; not all Cortex-M3/4/7 chips
support the MPU.

config ARM_MPU_NREGIONS
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/imxrt/chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

#define ARMV7M_PERIPHERAL_INTERRUPTS IMXRT_IRQ_NEXTINT

/* Cache line sizes (in bytes)for the SAMV71 */
/* Cache line sizes (in bytes)for the i.MX RT */

#define ARMV7M_DCACHE_LINESIZE 32 /* 32 bytes (8 words) */
#define ARMV7M_ICACHE_LINESIZE 32 /* 32 bytes (8 words) */
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/src/imxrt/imxrt_mpuinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
* Name: imxrt_mpu_initialize
*
* Description:
* Configure the MPU to permit user-space access to only restricted SAM3/4
* Configure the MPU to permit user-space access to only restricted i.MXRT
* resources.
*
****************************************************************************/
Expand All @@ -92,10 +92,10 @@ void imxrt_mpu_initialize(void)

ARM_DMB();

#ifdef CONFIG_SAMV7_QSPI
#ifdef CONFIG_IMXFT_QSPI
/* Make QSPI memory region strongly ordered */

mpu_priv_stronglyordered(SAM_QSPIMEM_BASE, SAM_QSPIMEM_SIZE);
mpu_priv_stronglyordered(IMXRT_QSPIMEM_BASE, IMXRT_QSPIMEM_SIZE);

#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/imxrt/imxrt_mpuinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ extern "C"
* Name: imxrt_mpu_initialize
*
* Description:
* Configure the MPU to permit user-space access to only unrestricted SAMV7
* Configure the MPU to permit user-space access to only unrestricted i.MXRT
* resources.
*
****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/imxrt/imxrt_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@ void __start(void)
imxrt_boardinitialize();

#ifdef CONFIG_ARM_MPU
#ifdef CONFIG_BUILD_PROTECTED
/* For the case of the separate user-/kernel-space build, perform whatever
* platform specific initialization of the user memory is required.
* Normally this just means initializing the user space .data and .bss
* segments.
*/

#ifdef CONFIG_BUILD_PROTECTED
imxrt_userspace();
#endif

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/imxrt/imxrt_start.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void imxrt_lowsetup(void);
* Name: imxrt_boardinitialize
*
* Description:
* All SAMV7 architectures must provide the following entry point. This entry
* All i.MXRT architectures must provide the following entry point. This entry
* point is called early in the initialization -- after clocking and memory have
* been configured but before caches have been enabled and before any devices have
* been initialized.
Expand Down
84 changes: 83 additions & 1 deletion configs/imxrt1050-evk/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ LEDs and buttons

This LED is not used by the board port unless CONFIG_ARCH_LEDS is
defined. In that case, the usage by the board port is defined in
include/board.h and src/sam_autoleds.c. The LED is used to encode
include/board.h and src/imxrt_autoleds.c. The LED is used to encode
OS-related events as follows:

------------------- ----------------------- ------
Expand Down Expand Up @@ -166,6 +166,88 @@ Configurations
Configuration sub-directories
-----------------------------

knsh:

This is identical to the nsh configuration below except that NuttX
is built as a protected mode, monolithic module and the user applications
are built separately. It is recommends to use a special make command;
not just 'make' but make with the following two arguments:

make pass1 pass2

In the normal case (just 'make'), make will attempt to build both user-
and kernel-mode blobs more or less interleaved. This actual works!
However, for me it is very confusing so I prefer the above make command:
Make the user-space binaries first (pass1), then make the kernel-space
binaries (pass2)

NOTES:

1. At the end of the build, there will be several files in the top-level
NuttX build directory:

PASS1:
nuttx_user.elf - The pass1 user-space ELF file
nuttx_user.hex - The pass1 Intel HEX format file (selected in defconfig)
User.map - Symbols in the user-space ELF file

PASS2:
nuttx - The pass2 kernel-space ELF file
nuttx.hex - The pass2 Intel HEX file (selected in defconfig)
System.map - Symbols in the kernel-space ELF file

The J-Link programmer will except files in .hex, .mot, .srec, and .bin
formats.

2. Combining .hex files. If you plan to use the .hex files with your
debugger or FLASH utility, then you may need to combine the two hex
files into a single .hex file. Here is how you can do that.

a. The 'configs/samv71-xult/knsh/defconfigtail' of the nuttx.hex file should look something like this
(with my comments added beginning with #):

$ tail nuttx.hex
#xx xxxx 00 data records
...
:10 C93C 00 000000000040184000C2010000000000 90
:10 C94C 00 2400080000801B4000C01B4000001C40 5D
:10 C95C 00 00401C4000000C4050BF0060FF000100 74
#xx xxxx 05 Start Linear Address Record
:04 0000 05 6000 02C1 D4
#xx xxxx 01 End Of File record
:00 0000 01 FF

Use an editor such as vi to remove the 05 and 01 records.

b. The 'head' of the nuttx_user.hex file should look something like
this (again with my comments added beginning with #):

$ head nuttx_user.hex
#xx xxxx 04 Extended Linear Address Record
:02 0000 04 6020 7A
#xx xxxx 00 data records
:10 0000 00 8905206030002060F2622060FC622060 80
:10 0010 00 0000242008002420080024205C012420 63
:10 0020 00 140024203D0020603100206071052060 14
...

Nothing needs to be done here. The nuttx_user.hex file should
be fine.

c. Combine the edited nuttx.hex and un-edited nuttx_user.hex
file to produce a single combined hex file:

$ cat nuttx.hex nuttx_user.hex >combined.hex

Then use the combined.hex file with the to write the FLASH image.
If you do this a lot, you will probably want to invest a little time
to develop a tool to automate these steps.

STATUS: This configuration was added on 8 June 2018 primarily to assure
that all of the components are in place to support the PROTECTED mode
build. This configuration, however, has not been verified as of this
writing.

netnsh:

This configuration is similar to the nsh configuration except that is
Expand Down
2 changes: 1 addition & 1 deletion configs/imxrt1050-evk/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

/* This LED is not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/sam_autoleds.c. The LED is used to encode
* include/board.h and src/imxrt_autoleds.c. The LED is used to encode
* OS-related events as follows:
*
* -------------------- ----------------------------- ------
Expand Down
2 changes: 2 additions & 0 deletions configs/imxrt1050-evk/kernel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/nuttx_user.elf

122 changes: 122 additions & 0 deletions configs/imxrt1050-evk/kernel/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
############################################################################
# configs/imxrt1050-evk/kernel/Makefile
#
# Copyright (C) 2018 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################

-include $(TOPDIR)/Make.defs

# This is the directory for the board-specific header files

BOARD_INCLUDE = $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)include

# The entry point name (if none is provided in the .config file)

CONFIG_USER_ENTRYPOINT ?= user_start
ENTRYPT = $(patsubst "%",%,$(CONFIG_USER_ENTRYPOINT))

# Get the paths to the libraries and the links script path in format that
# is appropriate for the host OS

ifeq ($(WINTOOL),y)
# Windows-native toolchains
USER_LIBPATHS = ${shell for path in $(USERLIBS); do dir=`dirname $(TOPDIR)$(DELIM)$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
USER_LDSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld}"
USER_LDSCRIPT += -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld}"
USER_HEXFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.hex}"
USER_SRECFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.srec}"
USER_BINFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.bin}"
else
# Linux/Cygwin-native toolchain
USER_LIBPATHS = $(addprefix -L$(TOPDIR)$(DELIM),$(dir $(USERLIBS)))
USER_LDSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld
USER_LDSCRIPT += -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld
USER_HEXFILE += "$(TOPDIR)$(DELIM)nuttx_user.hex"
USER_SRECFILE += "$(TOPDIR)$(DELIM)nuttx_user.srec"
USER_BINFILE += "$(TOPDIR)$(DELIM)nuttx_user.bin"
endif

USER_LDFLAGS = --undefined=$(ENTRYPT) --entry=$(ENTRYPT) $(USER_LDSCRIPT)
USER_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(USERLIBS))))
USER_LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}"

# Source files

CSRCS = imxrt_userspace.c
COBJS = $(CSRCS:.c=$(OBJEXT))
OBJS = $(COBJS)

# Targets:

all: $(TOPDIR)$(DELIM)nuttx_user.elf $(TOPDIR)$(DELIM)User.map
.PHONY: nuttx_user.elf depend clean distclean

$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)

# Create the nuttx_user.elf file containing all of the user-mode code

nuttx_user.elf: $(OBJS)
$(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"
$(Q) cp -a nuttx_user.elf $(TOPDIR)$(DELIM)nuttx_user.elf
ifeq ($(CONFIG_INTELHEX_BINARY),y)
@echo "CP: nuttx_user.hex"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex nuttx_user.elf $(USER_HEXFILE)
endif
ifeq ($(CONFIG_MOTOROLA_SREC),y)
@echo "CP: nuttx_user.srec"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec nuttx_user.elf $(USER_SRECFILE)
endif
ifeq ($(CONFIG_RAW_BINARY),y)
@echo "CP: nuttx_user.bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary nuttx_user.elf $(USER_BINFILE)
endif

$(TOPDIR)$(DELIM)User.map: nuttx_user.elf
@echo "MK: User.map"
$(Q) $(NM) nuttx_user.elf >$(TOPDIR)$(DELIM)User.map
$(Q) $(CROSSDEV)size nuttx_user.elf

.depend:

depend: .depend

clean:
$(call DELFILE, nuttx_user.elf)
$(call DELFILE, "$(TOPDIR)$(DELIM)nuttx_user.*")
$(call DELFILE, "$(TOPDIR)$(DELIM)User.map")
$(call CLEAN)

distclean: clean
Loading

0 comments on commit 05ad720

Please sign in to comment.