STM32F4-Discovery: Add a configuration for testing libc++
This commit is contained in:
parent
09f31d1371
commit
e748a43f99
@ -39,6 +39,7 @@ Contents
|
||||
- UG-2864AMBAG01 / UG-2864HSWEG01
|
||||
- STM32F4Discovery-specific Configuration Options
|
||||
- BASIC
|
||||
- Testing LLVM LIBC++ with NuttX
|
||||
- Configurations
|
||||
|
||||
Development Environment
|
||||
@ -1205,6 +1206,87 @@ BASIC
|
||||
0.0000002
|
||||
>
|
||||
|
||||
Testing LLVM LIBC++ with NuttX
|
||||
==============================
|
||||
|
||||
You can use LLVM LIBC++ on NuttX to get a C++ compiler with C++11 features.
|
||||
Follow these steps to get it working:
|
||||
|
||||
Clone the needed repositories:
|
||||
|
||||
$ git clone https://www.bitbucket.org/acassis/libcxx
|
||||
|
||||
$ git clone https://www.bitbucket.org/nuttx/apps
|
||||
|
||||
$ git clone https://www.bitbucket.org/nuttx/nuttx
|
||||
|
||||
Install the libcxx files on NuttX:
|
||||
|
||||
$ cd libcxx
|
||||
|
||||
$ ./install.sh ../nuttx
|
||||
Installing LLVM/libcxx in the NuttX source tree
|
||||
Installation suceeded
|
||||
|
||||
Enter inside NuttX and compile it:
|
||||
|
||||
$ cd ../nuttx
|
||||
|
||||
$ ./tools/configure.sh stm32f4discovery/testlibcxx
|
||||
Copy files
|
||||
Refreshing...
|
||||
|
||||
$ ls -l nuttx.bin
|
||||
-rwxrwxr-x 1 alan alan 58112 Ago 8 11:08 nuttx.bin
|
||||
|
||||
Plug the MiniUSB cable in the STM32F4Discovery board and flash the firmware:
|
||||
|
||||
$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init \
|
||||
-c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000"
|
||||
|
||||
...
|
||||
|
||||
Info : device id = 0x10036413
|
||||
Info : flash size = 1024kbytes
|
||||
target halted due to breakpoint, current mode: Thread
|
||||
xPSR: 0x61000000 pc: 0x20000046 msp: 0x20001d60
|
||||
wrote 65536 bytes from file nuttx.bin in 2.959432s (21.626 KiB/s)
|
||||
|
||||
Connect the USB/Serial 3.3V dongle to PA2(board TX) and PA3(board RX) use
|
||||
minicom or other serial console configured to 115200 8n1.
|
||||
|
||||
Press Reset pin of the board and you will see:
|
||||
|
||||
NuttShell (NSH)
|
||||
nsh> ?
|
||||
help usage: help [-v] [<cmd>]
|
||||
|
||||
[ cmp free mh sh usleep
|
||||
? dirname help mv sleep xd
|
||||
basename dd hexdump mw test
|
||||
break echo kill pwd time
|
||||
cat exec ls rm true
|
||||
cd exit mb rmdir uname
|
||||
cp false mkdir set unset
|
||||
|
||||
Builtin Apps:
|
||||
helloxx
|
||||
|
||||
nsh>
|
||||
|
||||
|
||||
Just type helloxx:
|
||||
|
||||
nsh> helloxx
|
||||
helloxx_main: Saying hello from the dynamically constructed instance
|
||||
CHelloWorld::HelloWorld: Hello, World!!
|
||||
helloxx_main: Saying hello from the instance constructed on the stack
|
||||
CHelloWorld::HelloWorld: Hello, World!!
|
||||
helloxx_main: Saying hello from the statically constructed instance
|
||||
CHelloWorld::HelloWorld: Hello, World!!
|
||||
|
||||
nsh>
|
||||
|
||||
Configurations
|
||||
==============
|
||||
|
||||
|
130
configs/stm32f4discovery/testlibcxx/Make.defs
Normal file
130
configs/stm32f4discovery/testlibcxx/Make.defs
Normal file
@ -0,0 +1,130 @@
|
||||
############################################################################
|
||||
# configs/stm32f4discovery/testlibcxx/Make.defs
|
||||
#
|
||||
# Copyright (C) 2017 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}/.config
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
CPP = $(CROSSDEV)gcc -E
|
||||
LD = $(CROSSDEV)ld
|
||||
AR = $(ARCROSSDEV)ar rcs
|
||||
NM = $(ARCROSSDEV)nm
|
||||
OBJCOPY = $(CROSSDEV)objcopy
|
||||
OBJDUMP = $(CROSSDEV)objdump
|
||||
|
||||
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e \
|
||||
's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
|
||||
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
|
||||
|
||||
LDSCRIPT = ld.script
|
||||
LIBSUPXX = ${shell $(CC) $(CXXFLAGS) --print-file-name=libsupc++.a}
|
||||
EXTRA_LIBPATHS = -L "${shell dirname "$(LIBSUPXX)"}"
|
||||
EXTRA_LIBS = -lsupc++
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
# Windows-native toolchains
|
||||
DIRLINK = $(TOPDIR)/tools/copydir.sh
|
||||
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
|
||||
MKDEP = $(TOPDIR)/tools/mkwindeps.sh
|
||||
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
||||
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" \
|
||||
-isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" \
|
||||
-isystem "${shell cygpath -w $(TOPDIR)/include/libcxx}"
|
||||
ARCHSCRIPT = -T "${shell cygpath -w \
|
||||
$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
|
||||
else
|
||||
# Linux/Cygwin-native toolchain
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
|
||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include \
|
||||
-isystem $(TOPDIR)/include/cxx -isystem $(TOPDIR)/include/libcxx
|
||||
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
ARCHOPTIMIZATION = -g
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_DEBUG_NOOPT),y)
|
||||
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing \
|
||||
-fno-strength-reduce -fomit-frame-pointer
|
||||
endif
|
||||
|
||||
ARCHCFLAGS = -fno-builtin
|
||||
ifeq ($(CONFIG_LIBCXX_EXCEPTION),y)
|
||||
ARCHCPUFLAGSXX = -fno-builtin
|
||||
else
|
||||
ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions -fcheck-new
|
||||
endif
|
||||
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
|
||||
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
|
||||
ARCHDEFINES =
|
||||
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
|
||||
|
||||
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) \
|
||||
$(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
|
||||
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGS) $(ARCHXXINCLUDES)
|
||||
CXXFLAGS += $(ARCHDEFINES) $(EXTRADEFINES) -pipe -std=c++11 -DCLOCK_MONOTONIC \
|
||||
-D__NuttX__
|
||||
CXXFLAGS += -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
|
||||
CXXFLAGS += -pedantic -D_DEBUG -D_LIBCPP_BUILD_STATIC -D_LIBCPP_NO_EXCEPTIONS
|
||||
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
|
||||
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
|
||||
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
NXFLATLDFLAGS1 = -r -d -warn-common
|
||||
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
|
||||
LDNXFLATFLAGS = -e main -s 2048
|
||||
|
||||
ASMEXT = .S
|
||||
OBJEXT = .o
|
||||
LIBEXT = .a
|
||||
EXEEXT =
|
||||
|
||||
ifneq ($(CROSSDEV),arm-nuttx-elf-)
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTINCLUDES = -I.
|
||||
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
|
||||
HOSTLDFLAGS =
|
56
configs/stm32f4discovery/testlibcxx/defconfig
Normal file
56
configs/stm32f4discovery/testlibcxx/defconfig
Normal file
@ -0,0 +1,56 @@
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="stm32f4discovery"
|
||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_FLOAT_H=y
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_C99_BOOL8=y
|
||||
CONFIG_DISABLE_MOUNTPOINT=y
|
||||
CONFIG_DISABLE_POLL=y
|
||||
CONFIG_EXAMPLES_HELLOXX=y
|
||||
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
|
||||
CONFIG_EXAMPLES_NSH=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HOST_WINDOWS=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_FLOATINGPOINT=y
|
||||
CONFIG_LIBC_LOCALE=y
|
||||
CONFIG_LIBC_LOCALTIME=y
|
||||
CONFIG_LIBC_WCHAR=y
|
||||
CONFIG_LIBCXX=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_ONEXIT_MAX=4
|
||||
CONFIG_SCHED_ONEXIT=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=2
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2012
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_USART2_RXBUFSIZE=128
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USART2_TXBUFSIZE=128
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WDOG_INTRESERVE=0
|
Loading…
Reference in New Issue
Block a user