Browse Source

add basic zephyr experiments, add xtensa newlib support

Waldemar Brodkorb 6 years ago
parent
commit
f855b1d7bf

+ 3 - 0
mk/build.mk

@@ -177,6 +177,9 @@ endif
 ifeq ($(ADK_TARGET_OS_FROSTED),y)
 	$(MAKE) -f mk/build.mk package/hostcompile toolchain/final target/config-prepare target/compile target/install target/targethelp
 endif
+ifeq ($(ADK_TARGET_OS_ZEPHYR),y)
+	$(MAKE) -f mk/build.mk package/hostcompile toolchain/final target/config-prepare target/compile target/install target/targethelp
+endif
 ifeq ($(ADK_TARGET_OS_LINUX),y)
 	$(MAKE) -f mk/build.mk package/hostcompile toolchain/final target/config-prepare target/compile package_clean package/compile root_clean package/install target/install package_index
 endif

+ 2 - 0
mk/vars.mk

@@ -238,10 +238,12 @@ endif
 # special architecture optimization flags
 ifeq ($(ADK_TARGET_ARCH_XTENSA),y)
 ifeq ($(ADK_TARGET_BIG_ENDIAN),)
+ifeq ($(ADK_TARGET_LIB_NEWLIB),)
 TARGET_CFLAGS+=		-mlongcalls -mauto-litpools
 TARGET_CXXFLAGS+=	-mlongcalls -mauto-litpools
 endif
 endif
+endif
 ifeq ($(ADK_TARGET_ARCH_MICROBLAZE),y)
 TARGET_CFLAGS+=		-mxl-barrel-shift
 TARGET_CXXFLAGS+=	-mxl-barrel-shift

+ 1 - 1
scripts/create-menu

@@ -98,7 +98,7 @@ config ADK_TARGET_CHOOSE_ARCH
 	bool "choose architecture"
 
 EOD
-for os in linux frosted baremetal; do
+for os in linux frosted zephyr baremetal; do
   for arch in $(cat $topdir/target/$os/arch.lst);do
     OS=$(echo $os | tr '[:lower:]' '[:upper:]')
     ARCH=$(echo $arch | tr '[:lower:]' '[:upper:]')

+ 12 - 0
target/Makefile

@@ -140,6 +140,11 @@ config-prepare: $(ADK_TOPDIR)/.config
 	    >$(BUILD_DIR)/.frostedapps
 endif
 
+ifeq ($(ADK_TARGET_OS_ZEPHYR),y)
+config-prepare: $(ADK_TOPDIR)/.config
+	echo foo
+endif
+
 ifeq ($(ADK_TARGET_OS_FROSTED),y)
 prepare: frosted-prepare
 compile: frosted-compile
@@ -147,6 +152,13 @@ install: frosted-install
 targethelp: frosted-targethelp
 endif
 
+ifeq ($(ADK_TARGET_OS_ZEPHYR),y)
+prepare: zephyr-prepare
+compile: zephyr-compile
+install: zephyr-install
+targethelp: zephyr-targethelp
+endif
+
 ifeq ($(ADK_TARGET_OS_LINUX),y)
 prepare: $(ADK_TARGET_ARCH)-prepare
 compile: $(ADK_TARGET_ARCH)-compile

+ 11 - 2
target/config/Config.in.libc

@@ -127,7 +127,9 @@ config ADK_TARGET_LIB_NEWLIB
 		ADK_TARGET_ARCH_X86 || \
 		ADK_TARGET_ARCH_X86_64 || \
 		ADK_TARGET_ARCH_XTENSA) && \
-		(ADK_TARGET_OS_BAREMETAL || ADK_TARGET_OS_FROSTED)
+		(ADK_TARGET_OS_BAREMETAL || \
+		 ADK_TARGET_OS_FROSTED || \
+		 ADK_TARGET_OS_ZEPHYR )
 	help
 	  https://sourceware.org/newlib/
 
@@ -166,12 +168,19 @@ config ADK_TARGET_LIB_MUSL_GIT
 
 config ADK_TARGET_LIB_NEWLIB_2_5_0
 	bool "2.5.0"
-	depends on ADK_TARGET_LIB_NEWLIB && !ADK_TARGET_ARCH_RISCV && !ADK_TARGET_OS_FROSTED
+	depends on ADK_TARGET_LIB_NEWLIB \
+		&& !ADK_TARGET_ARCH_RISCV \
+		&& !ADK_TARGET_ARCH_XTENSA \
+		&& !ADK_TARGET_OS_FROSTED
 
 config ADK_TARGET_LIB_NEWLIB_RISCV
 	bool "2.4.0-riscv"
 	depends on ADK_TARGET_LIB_NEWLIB && ADK_TARGET_ARCH_RISCV
 
+config ADK_TARGET_LIB_NEWLIB_XTENSA
+	bool "xtensa"
+	depends on ADK_TARGET_LIB_NEWLIB && ADK_TARGET_ARCH_XTENSA
+
 config ADK_TARGET_LIB_NEWLIB_FROSTED
 	bool "frosted-git"
 	depends on ADK_TARGET_LIB_NEWLIB && ADK_TARGET_OS_FROSTED

+ 5 - 0
target/config/Config.in.os

@@ -14,6 +14,11 @@ config ADK_TARGET_OS_FROSTED
 	help
 	  Create a frosted appliance or toolchain.
 
+config ADK_TARGET_OS_ZEPHYR
+	bool "Zephyr"
+	help
+	  Create a zephyr appliance or toolchain.
+
 config ADK_TARGET_OS_BAREMETAL
 	bool "Bare metal"
 	help

+ 0 - 0
target/zephyr/Config.in


+ 33 - 0
target/zephyr/Makefile

@@ -0,0 +1,33 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+include $(ADK_TOPDIR)/rules.mk
+
+prepare:
+	if [ ! -d $(BUILD_DIR)/zephyr ]; then \
+		cd $(BUILD_DIR) ;\
+		git clone https://github.com/zephyrproject-rtos/zephyr.git ;\
+	fi
+	if [ ! -d $(BUILD_DIR)/zephyr-kconfig ]; then \
+		mkdir $(BUILD_DIR)/zephyr-kconfig ;\
+	fi
+	cd $(BUILD_DIR)/zephyr-kconfig && \
+		PATH='$(HOST_PATH)' cmake $(BUILD_DIR)/zephyr/scripts && \
+		make
+	source $(BUILD_DIR)/zephyr/zephyr-env.sh
+
+compile:
+	export GCCXTENSA_TOOLCHAIN_PATH="$(TOOLCHAIN_DIR)"
+	export ZEPHYR_GCC_VARIANT=gccxtensa
+	if [ ! -d $(BUILD_DIR)/zephyr/samples/hello_world/build ]; then \
+		mkdir $(BUILD_DIR)/zephyr/samples/hello_world/build ;\
+	fi
+	cd $(BUILD_DIR)/zephyr/samples/hello_world/build && \
+		cmake -DBOARD=qemu_xtensa .. && \
+		make
+
+install:
+
+targethelp:
+
+clean:

+ 4 - 0
target/zephyr/arch.lst

@@ -0,0 +1,4 @@
+arc
+arm
+x86_64
+xtensa

+ 7 - 0
toolchain/newlib/Makefile.inc

@@ -22,6 +22,13 @@ PKG_RELEASE:=		1
 PKG_SITES:=		https://github.com/riscv/riscv-newlib.git
 DISTFILES:=		${PKG_NAME}-${PKG_VERSION}.tar.xz
 endif
+ifeq ($(ADK_TARGET_LIB_NEWLIB_XTENSA),y)
+PKG_VERSION:=		xtensa
+PKG_GIT:=		branch
+PKG_RELEASE:=		1
+PKG_SITES:=		https://github.com/jcmvbkbc/newlib-xtensa.git
+DISTFILES:=		${PKG_NAME}-${PKG_VERSION}.tar.xz
+endif
 ifeq ($(ADK_TARGET_LIB_NEWLIB_FROSTED),y)
 PKG_VERSION:=		frosted
 PKG_GIT:=		branch

+ 12 - 0
toolchain/newlib/patches/newlib-xtensa/fix-tooldir.patch

@@ -0,0 +1,12 @@
+diff -Nur newlib-xtensa.orig/configure newlib-xtensa/configure
+--- newlib-xtensa.orig/configure	2017-12-29 15:26:12.000000000 +0100
++++ newlib-xtensa/configure	2017-12-29 15:35:01.420208845 +0100
+@@ -6847,7 +6847,7 @@
+ 
+ # Some systems (e.g., one of the i386-aix systems the gas testers are
+ # using) don't handle "\$" correctly, so don't use it here.
+-tooldir='${exec_prefix}'/${target_noncanonical}
++tooldir='${exec_prefix}'
+ build_tooldir=${tooldir}
+ 
+ # Create a .gdbinit file which runs the one in srcdir