diff options
Diffstat (limited to 'external/meta-openembedded/meta-oe/recipes-devtools/android-tools')
5 files changed, 310 insertions, 4 deletions
diff --git a/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup index f7d99737..26cf30ed 100644 --- a/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup +++ b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup @@ -1,11 +1,23 @@ #!/bin/sh +[ ! -e /dev/pts ] && mkdir -p /dev/pts +[ ! -e /dev/pts/0 ] && mount devpts /dev/pts -t devpts + # TODO enable the lines below once we have support for getprop # retrieve the product info from Android # manufacturer=$(getprop ro.product.manufacturer Android) # model=$(getprop ro.product.model Android) # serial=$(getprop ro.serialno 0123456789ABCDEF) +#below are now needed in order to use FunctionFS for ADB, tested to work with 3.4+ kernels +if grep -q functionfs /proc/filesystems; then + mkdir -p /dev/usb-ffs/adb + mount -t functionfs adb /dev/usb-ffs/adb + #android-gadget-setup doesn't provide below 2 and without them it won't work, so we provide them here. + echo adb > /sys/class/android_usb/android0/f_ffs/aliases + echo ffs > /sys/class/android_usb/android0/functions +fi + manufacturer="$(cat /system/build.prop | grep -o 'ro.product.manufacturer=.*' | cut -d'=' -f 2)" model="$(cat /system/build.prop | grep -o 'ro.product.model=.*' | cut -d'=' -f 2)" # get the device serial number from /proc/cmdline directly(since we have no getprop on @@ -17,7 +29,7 @@ echo $manufacturer > /sys/class/android_usb/android0/iManufacturer echo $model > /sys/class/android_usb/android0/iProduct echo "0" > /sys/class/android_usb/android0/enable -echo "18d1" > /sys/class/android_usbid_usb/android0/idVendor +echo "18d1" > /sys/class/android_usb/android0/idVendor echo "D002" > /sys/class/android_usb/android0/idProduct echo "adb" > /sys/class/android_usb/android0/functions echo "1" > /sys/class/android_usb/android0/enable diff --git a/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch new file mode 100644 index 00000000..a8434afb --- /dev/null +++ b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch @@ -0,0 +1,189 @@ +From 48ddf4fb999931942c359350fb31cd557514e1c6 Mon Sep 17 00:00:00 2001 +From: Chenxi Mao <maochenxi@eswin.com> +Date: Mon, 20 Apr 2020 15:27:22 +0800 +Subject: [PATCH 1/1] adb: Support riscv64 + +--- + include/cutils/atomic-inline.h | 2 + + include/cutils/atomic-riscv64.h | 156 ++++++++++++++++++++++++++++++++ + 2 files changed, 158 insertions(+) + create mode 100644 include/cutils/atomic-riscv64.h + +diff --git a/include/cutils/atomic-inline.h b/include/cutils/atomic-inline.h +index a31e913579..b5dc38209c 100644 +--- a/include/cutils/atomic-inline.h ++++ b/include/cutils/atomic-inline.h +@@ -55,6 +55,8 @@ extern "C" { + #include <cutils/atomic-mips64.h> + #elif defined(__mips__) + #include <cutils/atomic-mips.h> ++#elif defined(__riscv) && __riscv_xlen == 64 ++#include <cutils/atomic-riscv64.h> + #else + #error atomic operations are unsupported + #endif +diff --git a/include/cutils/atomic-riscv64.h b/include/cutils/atomic-riscv64.h +new file mode 100644 +index 0000000000..2664db5a86 +--- /dev/null ++++ b/include/cutils/atomic-riscv64.h +@@ -0,0 +1,156 @@ ++/* ++ * Copyright (C) 2014 The Android Open Source Project ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * 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. ++ * ++ * 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. ++ */ ++ ++#ifndef ANDROID_CUTILS_ATOMIC_RISCV64_H ++#define ANDROID_CUTILS_ATOMIC_RISCV64_H ++ ++#include <stdint.h> ++ ++#ifndef ANDROID_ATOMIC_INLINE ++#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) ++#endif ++ ++/* ++ TODOAArch64: Revisit the below functions and check for potential ++ optimizations using assembly code or otherwise. ++*/ ++ ++extern ANDROID_ATOMIC_INLINE ++void android_compiler_barrier(void) ++{ ++ __asm__ __volatile__ ("" : : : "memory"); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++void android_memory_barrier(void) ++{ ++ __asm__ __volatile__ ("fence rw,rw" : : : "memory"); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_acquire_load(volatile const int32_t *ptr) ++{ ++ int32_t value = *ptr; ++ android_memory_barrier(); ++ return value; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_release_load(volatile const int32_t *ptr) ++{ ++ android_memory_barrier(); ++ return *ptr; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) ++{ ++ *ptr = value; ++ android_memory_barrier(); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++void android_atomic_release_store(int32_t value, volatile int32_t *ptr) ++{ ++ android_memory_barrier(); ++ *ptr = value; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int android_atomic_cas(int32_t old_value, int32_t new_value, ++ volatile int32_t *ptr) ++{ ++ return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, ++ volatile int32_t *ptr) ++{ ++ int status = android_atomic_cas(old_value, new_value, ptr); ++ android_memory_barrier(); ++ return status; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int android_atomic_release_cas(int32_t old_value, int32_t new_value, ++ volatile int32_t *ptr) ++{ ++ android_memory_barrier(); ++ return android_atomic_cas(old_value, new_value, ptr); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) ++{ ++ int32_t prev, status; ++ android_memory_barrier(); ++ do { ++ prev = *ptr; ++ status = android_atomic_cas(prev, prev + increment, ptr); ++ } while (__builtin_expect(status != 0, 0)); ++ return prev; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_inc(volatile int32_t *addr) ++{ ++ return android_atomic_add(1, addr); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_dec(volatile int32_t *addr) ++{ ++ return android_atomic_add(-1, addr); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) ++{ ++ int32_t prev, status; ++ android_memory_barrier(); ++ do { ++ prev = *ptr; ++ status = android_atomic_cas(prev, prev & value, ptr); ++ } while (__builtin_expect(status != 0, 0)); ++ return prev; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) ++{ ++ int32_t prev, status; ++ android_memory_barrier(); ++ do { ++ prev = *ptr; ++ status = android_atomic_cas(prev, prev | value, ptr); ++ } while (__builtin_expect(status != 0, 0)); ++ return prev; ++} ++ ++#endif /* ANDROID_CUTILS_ATOMIC_RISCV_H */ +-- +2.17.1 + diff --git a/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff new file mode 100644 index 00000000..3ead649b --- /dev/null +++ b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff @@ -0,0 +1,39 @@ +Description: adb: Make compatible with openssl 1.1 + OpenSSL version 1.1 brought some API changes which broke the build here, + fix that by accessing rsa->n (and e) directly, using RSA_get0_key instead. +Author: Chirayu Desai <chirayudesai1@gmail.com +Last-Update: 2016-11-10 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- + system/core/adb/adb_auth_host.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/adb/adb_auth_host.c ++++ b/adb/adb_auth_host.c +@@ -75,6 +75,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa, + BIGNUM* rem = BN_new(); + BIGNUM* n = BN_new(); + BIGNUM* n0inv = BN_new(); ++ BIGNUM* e = BN_new(); + + if (RSA_size(rsa) != RSANUMBYTES) { + ret = 0; +@@ -82,7 +83,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa, + } + + BN_set_bit(r32, 32); +- BN_copy(n, rsa->n); ++ RSA_get0_key(rsa, &n, &e, NULL); + BN_set_bit(r, RSANUMWORDS * 32); + BN_mod_sqr(rr, r, n, ctx); + BN_div(NULL, rem, n, r32, ctx); +@@ -96,7 +97,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa, + BN_div(n, rem, n, r32, ctx); + pkey->n[i] = BN_get_word(rem); + } +- pkey->exponent = BN_get_word(rsa->e); ++ pkey->exponent = BN_get_word(e); + + out: + BN_free(n0inv); diff --git a/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch new file mode 100644 index 00000000..8524517c --- /dev/null +++ b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch @@ -0,0 +1,52 @@ +From f4f9d24860e1b5cd4f6a014f3fda7cd33ebe5be7 Mon Sep 17 00:00:00 2001 +From: Petr Lautrbach <plautrba@redhat.com> +Date: Sat, 27 Jul 2019 08:20:20 -0700 +Subject: [PATCH] libselinux: Do not define gettid() if glibc >= 2.30 is used +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since version 2.30 glibc implements gettid() system call wrapper, see +https://sourceware.org/bugzilla/show_bug.cgi?id=6399 + +Fixes: +cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -c -o procattr.o procattr.c +procattr.c:28:14: error: static declaration of ‘gettid’ follows non-static declaration + 28 | static pid_t gettid(void) + | ^~~~~~ +In file included from /usr/include/unistd.h:1170, + from procattr.c:2: +/usr/include/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here + 34 | extern __pid_t gettid (void) __THROW; + | ^~~~~~ + +Signed-off-by: Petr Lautrbach <plautrba@redhat.com> +Acked-by: Stephen Smalley <sds@tycho.nsa.gov> +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- + src/procattr.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +--- a/src/procattr.c ++++ b/src/procattr.c +@@ -8,7 +8,19 @@ + #include "selinux_internal.h" + #include "policy.h" + +-#ifndef __BIONIC__ ++/* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and ++ * has a definition for it */ ++#ifdef __BIONIC__ ++ #define OVERRIDE_GETTID 0 ++#elif !defined(__GLIBC_PREREQ) ++ #define OVERRIDE_GETTID 1 ++#elif !__GLIBC_PREREQ(2,29) ++ #define OVERRIDE_GETTID 1 ++#else ++ #define OVERRIDE_GETTID 0 ++#endif ++ ++#if OVERRIDE_GETTID + static pid_t gettid(void) + { + return syscall(__NR_gettid); diff --git a/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools_5.1.1.r37.bb b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools_5.1.1.r37.bb index 2604f65e..fb6125e2 100644 --- a/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools_5.1.1.r37.bb +++ b/external/meta-openembedded/meta-oe/recipes-devtools/android-tools/android-tools_5.1.1.r37.bb @@ -4,11 +4,11 @@ LICENSE = "Apache-2.0 & GPL-2.0 & BSD-2-Clause & BSD-3-Clause" LIC_FILES_CHKSUM = " \ file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \ file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 \ - file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=8bef8e6712b1be5aa76af1ebde9d6378 \ + file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=cb641bc04cda31daea161b1bc15da69f \ file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \ " DEPENDS = "libbsd libpcre zlib libcap" -DEPENDS_append_class-target = " openssl10" +DEPENDS_append_class-target = " openssl" ANDROID_MIRROR = "android.googlesource.com" @@ -37,10 +37,14 @@ SRC_URI = " \ file://core/0010-Use-linux-capability.h-on-linux-systems-too.patch;patchdir=system/core \ file://core/0011-Remove-bionic-specific-calls.patch;patchdir=system/core \ file://core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch;patchdir=system/core \ + file://core/adb_libssl_11.diff;patchdir=system/core \ + file://core/0013-adb-Support-riscv64.patch;patchdir=system/core \ file://extras/0001-ext4_utils-remove-selinux-extensions.patch;patchdir=system/extras \ file://extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch;patchdir=system/extras \ file://libselinux/0001-Remove-bionic-specific-calls.patch;patchdir=external/libselinux \ + file://libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch;patchdir=external/libselinux \ file://android-tools-adbd.service \ + file://build/0001-Riscv-Add-risc-v-Android-config-header.patch;patchdir=build \ file://gitignore \ file://adb.mk;subdir=${BPN} \ file://adbd.mk;subdir=${BPN} \ @@ -57,6 +61,10 @@ B = "${WORKDIR}/${BPN}" ARM_INSTRUCTION_SET_armv4 = "arm" ARM_INSTRUCTION_SET_armv5 = "arm" +COMPATIBLE_HOST_powerpc = "(null)" +COMPATIBLE_HOST_powerpc64 = "(null)" +COMPATIBLE_HOST_powerpc64le = "(null)" + inherit systemd SYSTEMD_SERVICE_${PN} = "android-tools-adbd.service" @@ -88,13 +96,19 @@ do_compile() { aarch64) export android_arch=linux-arm64 ;; + riscv64) + export android_arch=linux-riscv64 + ;; mips|mipsel) export android_arch=linux-mips ;; + mips64|mips64el) + export android_arch=linux-mips64 + ;; powerpc|powerpc64) export android_arch=linux-ppc ;; - i586|x86_64) + i586|i686|x86_64) export android_arch=linux-x86 ;; esac |