From c800bc8c82710757d347d1a1b5cf3359d3f71433 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Fri, 15 Jan 2021 20:19:25 +0200 Subject: [PATCH 1/2] Add PRU cross tool target Add sample configuration for building cross toolchain for the TI PRU. PRU cores are present in many of the BeagleBone single board computers. More information about the PRU can be found in https://bbb.io/pru Signed-off-by: Dimitar Dimitrov --- config/arch/pru.in | 8 ++++++++ config/kernel/linux.in | 2 +- samples/pru/crosstool.config | 15 +++++++++++++++ samples/pru/reported.by | 3 +++ scripts/build/arch/pru.sh | 5 +++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 config/arch/pru.in create mode 100644 samples/pru/crosstool.config create mode 100644 samples/pru/reported.by create mode 100644 scripts/build/arch/pru.sh diff --git a/config/arch/pru.in b/config/arch/pru.in new file mode 100644 index 00000000..f26dc7a5 --- /dev/null +++ b/config/arch/pru.in @@ -0,0 +1,8 @@ +# PRU specific config options + +## no-package +## select ARCH_SUPPORTS_8 +## select ARCH_DEFAULT_8 +## +## help The TI PRU core, as defined by: +## help http://bbb.io/pru diff --git a/config/kernel/linux.in b/config/kernel/linux.in index 2602b53d..6ff81924 100644 --- a/config/kernel/linux.in +++ b/config/kernel/linux.in @@ -1,6 +1,6 @@ # Linux kernel options -## depends on !ARCH_AVR && !ARCH_MSP430 && !ARCH_MOXIE +## depends on !ARCH_AVR && !ARCH_MSP430 && !ARCH_MOXIE && !ARCH_PRU ## select KERNEL_SUPPORTS_SHARED_LIBS ## help Build a toolchain targeting systems running Linux as a kernel. diff --git a/samples/pru/crosstool.config b/samples/pru/crosstool.config new file mode 100644 index 00000000..5072dd67 --- /dev/null +++ b/samples/pru/crosstool.config @@ -0,0 +1,15 @@ +CT_CONFIG_VERSION="3" +CT_ARCH_PRU=y +CT_OMIT_TARGET_VENDOR=y +# CT_DEMULTILIB is not set +# CT_LIBC_NEWLIB_FVWRITE_IN_STREAMIO is not set +# CT_LIBC_NEWLIB_UNBUF_STREAM_OPT is not set +# CT_LIBC_NEWLIB_FSEEK_OPTIMIZATION is not set +# CT_LIBC_NEWLIB_ATEXIT_DYNAMIC_ALLOC is not set +# CT_LIBC_NEWLIB_MULTITHREAD is not set +CT_LIBC_NEWLIB_EXTRA_SECTIONS=y +# CT_LIBC_NEWLIB_WIDE_ORIENT is not set +CT_LIBC_NEWLIB_NANO_MALLOC=y +CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_CC_LANG_CXX=y +CT_COMP_TOOLS_MAKE=y diff --git a/samples/pru/reported.by b/samples/pru/reported.by new file mode 100644 index 00000000..eafd0c45 --- /dev/null +++ b/samples/pru/reported.by @@ -0,0 +1,3 @@ +reporter_name="Dimitar Dimitrov" +reporter_url="https://github.com/dinuxbg/gnupru" +reporter_comment="PRU cross toolchain" diff --git a/scripts/build/arch/pru.sh b/scripts/build/arch/pru.sh new file mode 100644 index 00000000..c4d61ceb --- /dev/null +++ b/scripts/build/arch/pru.sh @@ -0,0 +1,5 @@ +# Compute PRU-specific values + +CT_DoArchTupleValues() { + CT_TARGET_ARCH="${CT_ARCH}" +} From e7d0485ca2fece06e66e22162805b0e388bcc449 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Fri, 15 Jan 2021 20:23:10 +0200 Subject: [PATCH 2/2] Add package with PRU linker scripts and headers Include the gnuprumcu package in PRU cross toolchain. Toolchain is somewhat useless without device specs and linker scripts for the various SoCs. Signed-off-by: Dimitar Dimitrov --- config/comp_libs/gnuprumcu.in | 2 + ...0001-HACK-Fix-paths-for-crosstool-ng.patch | 41 +++++++++ packages/gnuprumcu/0.5.0/chksum | 4 + packages/gnuprumcu/0.5.0/version.desc | 0 packages/gnuprumcu/package.desc | 6 ++ samples/pru/crosstool.config | 1 + scripts/build/companion_libs/400-gnuprumcu.sh | 89 +++++++++++++++++++ 7 files changed, 143 insertions(+) create mode 100644 config/comp_libs/gnuprumcu.in create mode 100644 packages/gnuprumcu/0.5.0/0001-HACK-Fix-paths-for-crosstool-ng.patch create mode 100644 packages/gnuprumcu/0.5.0/chksum create mode 100644 packages/gnuprumcu/0.5.0/version.desc create mode 100644 packages/gnuprumcu/package.desc create mode 100644 scripts/build/companion_libs/400-gnuprumcu.sh diff --git a/config/comp_libs/gnuprumcu.in b/config/comp_libs/gnuprumcu.in new file mode 100644 index 00000000..1ee9cfab --- /dev/null +++ b/config/comp_libs/gnuprumcu.in @@ -0,0 +1,2 @@ +# gnuprumcu config file +## depends on ARCH_PRU diff --git a/packages/gnuprumcu/0.5.0/0001-HACK-Fix-paths-for-crosstool-ng.patch b/packages/gnuprumcu/0.5.0/0001-HACK-Fix-paths-for-crosstool-ng.patch new file mode 100644 index 00000000..e2511806 --- /dev/null +++ b/packages/gnuprumcu/0.5.0/0001-HACK-Fix-paths-for-crosstool-ng.patch @@ -0,0 +1,41 @@ +From b045b2c65e26153813abadc2d065afdd52612fb0 Mon Sep 17 00:00:00 2001 +From: Dimitar Dimitrov +Date: Fri, 15 Jan 2021 18:52:09 +0200 +Subject: [PATCH] HACK: Fix paths for crosstool-ng + +For some reason crosstool-ng modifies the default +binutils/ld path for ldscripts. Align our respective +path. + +Signed-off-by: Dimitar Dimitrov +--- + ldscripts/Makefile.am | 2 +- + ldscripts/Makefile.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/ldscripts/Makefile.am b/ldscripts/Makefile.am +index 23c5903..b6984d5 100644 +--- a/ldscripts/Makefile.am ++++ b/ldscripts/Makefile.am +@@ -47,4 +47,4 @@ dist_pru_DATA = \ + pruelf-tda4vm.icssg1.tx_pru1.x + + +-prudir = $(exec_prefix)/$(target_alias)/lib ++prudir = $(libdir) +diff --git a/ldscripts/Makefile.in b/ldscripts/Makefile.in +index b58975f..b7aecd2 100644 +--- a/ldscripts/Makefile.in ++++ b/ldscripts/Makefile.in +@@ -300,7 +300,7 @@ dist_pru_DATA = \ + pruelf-tda4vm.icssg1.tx_pru0.x \ + pruelf-tda4vm.icssg1.tx_pru1.x + +-prudir = $(exec_prefix)/$(target_alias)/lib ++prudir = $(libdir) + all: all-am + + .SUFFIXES: +-- +2.20.1 + diff --git a/packages/gnuprumcu/0.5.0/chksum b/packages/gnuprumcu/0.5.0/chksum new file mode 100644 index 00000000..80870332 --- /dev/null +++ b/packages/gnuprumcu/0.5.0/chksum @@ -0,0 +1,4 @@ +md5 gnuprumcu-0.5.0.tar.gz ee6110995491dac1a834ca7045931391 +sha1 gnuprumcu-0.5.0.tar.gz 94eb2aeb88f5654fa041bed07c2fb7860af95047 +sha256 gnuprumcu-0.5.0.tar.gz 917043152188ad4626f888dbb620e816a523c0599f9a758230a7d687daf915af +sha512 gnuprumcu-0.5.0.tar.gz cc3071913db9c364c2e3966ab580b703700c85a3d292e230b5536df45b54e0137dc1e83a2fae80947e3c1ad178e5b6b6d8319a3d576653b423178c443386bd17 diff --git a/packages/gnuprumcu/0.5.0/version.desc b/packages/gnuprumcu/0.5.0/version.desc new file mode 100644 index 00000000..e69de29b diff --git a/packages/gnuprumcu/package.desc b/packages/gnuprumcu/package.desc new file mode 100644 index 00000000..8956bdaa --- /dev/null +++ b/packages/gnuprumcu/package.desc @@ -0,0 +1,6 @@ +origin='dinux.eu' +repository='git https://github.com/dinuxbg/gnuprumcu.git' +bootstrap='autoreconf -vfi' +relevantpattern='*.*.*' +archive_formats='.tar.gz' +mirrors='https://github.com/dinuxbg/gnuprumcu/releases/download/v${CT_GNUPRUMCU_VERSION}' diff --git a/samples/pru/crosstool.config b/samples/pru/crosstool.config index 5072dd67..529ebd9c 100644 --- a/samples/pru/crosstool.config +++ b/samples/pru/crosstool.config @@ -12,4 +12,5 @@ CT_LIBC_NEWLIB_EXTRA_SECTIONS=y CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y CT_CC_LANG_CXX=y +CT_COMP_LIBS_GNUPRUMCU=y CT_COMP_TOOLS_MAKE=y diff --git a/scripts/build/companion_libs/400-gnuprumcu.sh b/scripts/build/companion_libs/400-gnuprumcu.sh new file mode 100644 index 00000000..14546f38 --- /dev/null +++ b/scripts/build/companion_libs/400-gnuprumcu.sh @@ -0,0 +1,89 @@ +# Build script for gnuprumcu + +do_gnuprumcu_get() { :; } +do_gnuprumcu_extract() { :; } +do_gnuprumcu_for_build() { :; } +do_gnuprumcu_for_host() { :; } +do_gnuprumcu_for_target() { :; } + +if [ "${CT_COMP_LIBS_GNUPRUMCU}" = "y" ]; then + +do_gnuprumcu_get() { + CT_Fetch GNUPRUMCU +} + +do_gnuprumcu_extract() { + CT_ExtractPatch GNUPRUMCU +} + + +do_gnuprumcu_for_target() { + local -a gnuprumcu_opts + + CT_DoStep INFO "Installing gnuprumcu for the target" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gnuprumcu-target-${CT_TARGET}" + + gnuprumcu_opts+=( "destdir=${CT_SYSROOT_DIR}" ) + gnuprumcu_opts+=( "host=${CT_HOST}" ) + + gnuprumcu_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) + gnuprumcu_opts+=( "prefix=${CT_PREFIX_DIR}" ) + do_gnuprumcu_backend "${gnuprumcu_opts[@]}" + + CT_Popd + CT_EndStep +} + + +# Build gnuprumcu +# Parameter : description : type : default +# destdir : out-of-tree install dir : string : / +# host : machine to run on : tuple : (none) +# prefix : prefix to install into : dir : (none) +# cflags : cflags to use : string : (empty) +# ldflags : ldflags to use : string : (empty) +# shared : also buils shared lib : bool : n +do_gnuprumcu_backend() { + local destdir="/" + local host + local prefix + local cflags + local ldflags + local shared + local -a extra_config + local arg + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoLog EXTRA "Configuring gnuprumcu" + + CT_DoExecLog CFG \ + CC="${host}-gcc" \ + RANLIB="${host}-ranlib" \ + CFLAGS="${cflags}" \ + LDFLAGS="${ldflags}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/gnuprumcu/configure" \ + --build=${CT_BUILD} \ + --host=${host} \ + --target=${CT_TARGET} \ + --prefix="${prefix}" \ + "${extra_config[@]}" + + CT_DoLog EXTRA "Building gnuprumcu" + CT_DoExecLog ALL make + + CT_DoLog EXTRA "Installing gnuprumcu" + + # Guard against $destdir$prefix == // + # which is a UNC path on Cygwin/MSYS2 + if [[ ${destdir} == / ]] && [[ ${prefix} == /* ]]; then + destdir= + fi + + CT_DoExecLog ALL make instroot="${destdir}" install +} + +fi # CT_COMP_LIBS_GNUPRUMCU