Skip to contentSkip to conversation

android-tools: add new package

PATCH Superseded Gary Bisson 2 participants 3 messages Sep 13, 2015 – Nov 8, 2015

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 android-tools: add new package

From: Thomas Petazzoni <[email protected]>

This package allows to build the fastboot and adb host utilities, which can be used to interact with target devices implementing one of these protocols.

The work behind the host utilities was funded by ECA Group
<http://www.ecagroup.com>. ECA Group is the copyright owner of the contributed code.

The package also allows to build fastboot, adb and adbd daemon for the target.

Regarding adbd, the target is required to have the FunctionFS USB Gadget configuration. Then the following commands enable the use of adb:

 # modprobe g_ffs idVendor=0x18d1 idProduct=0x4e42 \
   iSerialNumber="buildroot"
 # mkdir -p /dev/usb-ffs/adb
 # mount -t functionfs adb /dev/usb-ffs/adb -o uid=2000,gid=2000
 # adbd &

---
This patch is the follow-up of "android-tools: new host package"
http://patchwork.ozlabs.org/patch/467019/

To which has been squashed "android-tools: add target and adbd support"
http://patchwork.ozlabs.org/patch/516635/

Since v2:
- added default selection for adb (host) and adbd (target)
- switched from debian to ubuntu package to get adbd support
- added target and adbd support
- removed AndroidConfig.h as not needed anymore (defines in Makefiles)
- removed libselinux dependency for adb/adbd

Since v1:
- fixed typos
- added android-tools.hash

---
 package/Config.in                                  |   1 +
 package/Config.in.host                             |   1 +
 .../0001-Fix-makefiles-for-out-of-tree-build.patch | 162 +++++++++++++
 .../0002-Fix-adbd-for-non-Ubuntu-systems.patch     | 264 +++++++++++++++++++++
 package/android-tools/Config.in                    |  39 +++
 package/android-tools/Config.in.host               |  25 ++
 package/android-tools/android-tools.hash           |   3 +
 package/android-tools/android-tools.mk             |  85 +++++++
 8 files changed, 580 insertions(+)
 create mode 100644 package/android-tools/0001-Fix-makefiles-for-out-of-tree-build.patch
 create mode 100644 package/android-tools/0002-Fix-adbd-for-non-Ubuntu-systems.patch
 create mode 100644 package/android-tools/Config.in
 create mode 100644 package/android-tools/Config.in.host
 create mode 100644 package/android-tools/android-tools.hash
 create mode 100644 package/android-tools/android-tools.mk
package/Config.in +1 -0
index 030477a..072ea95 100644
@@ -1454,6 +1454,7 @@ endmenu
 
 menu "System tools"
 	source "package/acl/Config.in"
+	source "package/android-tools/Config.in"
 	source "package/attr/Config.in"
 	source "package/audit/Config.in"
 if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
package/Config.in.host +1 -0
index 1e047aa..c24a79f 100644
@@ -1,5 +1,6 @@
 menu "Host utilities"
 
+	source "package/android-tools/Config.in.host"
 	source "package/checkpolicy/Config.in.host"
 	source "package/cramfs/Config.in.host"
 	source "package/dfu-util/Config.in.host"
package/android-tools/0001-Fix-makefiles-for-out-of-tree-build.patch new file +162 -0

162 lines not on this page · raw message

package/android-tools/0002-Fix-adbd-for-non-Ubuntu-systems.patch new file +264 -0

264 lines not on this page · raw message

package/android-tools/Config.in new file +39 -0
new file mode 100644
index 0000000..a8048bd
@@ -0,0 +1,39 @@
+config BR2_PACKAGE_ANDROID_TOOLS
+       bool "android-tools"
+       help
+         This package contains the fastboot and adb utilities, that
+         can be used to interact with target devices using of these
+         protocols.
+
+if BR2_PACKAGE_ANDROID_TOOLS
+
+config BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT
+       bool "fastboot"
+       select BR2_PACKAGE_LIBSELINUX
+       select BR2_PACKAGE_ZLIB
+       help
+         This option will build and install the fastboot utility for
+         the target, which can be used to reflash other target devices
+         implementing the fastboot protocol.
+
+config BR2_PACKAGE_ANDROID_TOOLS_ADB
+       bool "adb"
+       select BR2_PACKAGE_OPENSSL
+       select BR2_PACKAGE_ZLIB
+       help
+         This option will build and install the adb utility for the
+         target, which can be used to interact with other target devices
+         implementing the ADB protocol.
+
+config BR2_PACKAGE_ANDROID_TOOLS_ADBD
+       bool "adbd"
+       default y if !BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT
+       default y if !BR2_PACKAGE_ANDROID_TOOLS_ADB
+       select BR2_PACKAGE_OPENSSL
+       select BR2_PACKAGE_ZLIB
+       help
+         This option will build and install the adbd utility for the
+         target, which can be used to interact with a host machine
+         implementing the ADB protocol.
+
+endif
package/android-tools/Config.in.host new file +25 -0
new file mode 100644
index 0000000..4f16e9c
@@ -0,0 +1,25 @@
+config BR2_PACKAGE_HOST_ANDROID_TOOLS
+       bool "android-tools"
+       help
+         This package contains the fastboot and adb utilities, that
+         can be used to interact with target devices using of these
+         protocols.
+
+if BR2_PACKAGE_HOST_ANDROID_TOOLS
+
+config BR2_PACKAGE_HOST_ANDROID_TOOLS_FASTBOOT
+       bool "fastboot"
+       help
+         This option will build and install the fastboot utility for
+         the host, which can be used to reflash target devices
+         implementing the fastboot protocol.
+
+config BR2_PACKAGE_HOST_ANDROID_TOOLS_ADB
+       bool "adb"
+       default y if !BR2_PACKAGE_HOST_ANDROID_TOOLS_FASTBOOT
+       help
+         This option will build and install the adb utility for the
+         host, which can be used to interact with target devices
+         implementing the ADB protocol.
+
+endif
package/android-tools/android-tools.hash new file +3 -0
new file mode 100644
index 0000000..5d8ae59
@@ -0,0 +1,3 @@
+# locally computed
+sha512	c5bfd3c8e514809db257ba5559c865742768b7520b38aa2f53185aff5c328e5cf7fb328a6ff6450eeddd5056985f232d492eba63a87978440e2147e26d62f458  android-tools_4.2.2+git20130218.orig.tar.xz
+sha512	aa3fee593cecf5d9a5fbc60b18d67dadc5b832fdea75a098ec7371b8f774673af3a3b6052d7eecaf315943beaa984a1f5a3c114a698620275af1682bd05d4d23  android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz
package/android-tools/android-tools.mk new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
2.5.1
#1 lore raw

PATCH v3 1/1 android-tools: add new package

Gary,

Thanks for following-up on this, and sorry for the slow response. I have a few comments, and one build issue.

Quoted 27 lines · Gary Bisson
package/android-tools/Config.in new file +21 -0
new file mode 100644
index 0000000..a8048bd
@@ -0,0 +1,39 @@
+config BR2_PACKAGE_ANDROID_TOOLS
+       bool "android-tools"
+       help
+         This package contains the fastboot and adb utilities, that
+         can be used to interact with target devices using of these
+         protocols.
+
+if BR2_PACKAGE_ANDROID_TOOLS
+
+config BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT
+       bool "fastboot"
+       select BR2_PACKAGE_LIBSELINUX
+       select BR2_PACKAGE_ZLIB
+       help
+         This option will build and install the fastboot utility for
+         the target, which can be used to reflash other target devices
+         implementing the fastboot protocol.
+
+config BR2_PACKAGE_ANDROID_TOOLS_ADB
+       bool "adb"
+       select BR2_PACKAGE_OPENSSL

package/android-tools/Config.in line 31

Quoted 10 lines
package/android-tools/Config.in new file +10 -0
+       select BR2_PACKAGE_ZLIB
+       help
+         This option will build and install the adb utility for the
+         target, which can be used to interact with other target devices
+         implementing the ADB protocol.
+
+config BR2_PACKAGE_ANDROID_TOOLS_ADBD
+       bool "adbd"
+       default y if !BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT
+       default y if !BR2_PACKAGE_ANDROID_TOOLS_ADB

I would prefer to see the top-level option do:

	select BR2_PACKAGE_ANDROID_TOOLS_ADBD if \
		!BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT && !BR2_PACKAGE_ANDROID_TOOLS_ADB

so that we ensure that at least one of the three sub-options is enabled.

package/android-tools/Config.in.host line 2

Quoted 8 lines
package/android-tools/Config.in.host new file +2 -0
new file mode 100644
index 0000000..4f16e9c
@@ -0,0 +1,25 @@
+config BR2_PACKAGE_HOST_ANDROID_TOOLS
+       bool "android-tools"

Same here.

package/android-tools/android-tools.hash line 3

Quoted 9 lines
package/android-tools/android-tools.hash new file +3 -0
new file mode 100644
index 0000000..5d8ae59
@@ -0,0 +1,3 @@
+# locally computed
+sha512	c5bfd3c8e514809db257ba5559c865742768b7520b38aa2f53185aff5c328e5cf7fb328a6ff6450eeddd5056985f232d492eba63a87978440e2147e26d62f458  android-tools_4.2.2+git20130218.orig.tar.xz
+sha512	aa3fee593cecf5d9a5fbc60b18d67dadc5b832fdea75a098ec7371b8f774673af3a3b6052d7eecaf315943beaa984a1f5a3c114a698620275af1682bd05d4d23  android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz

Right now, for locally computed hashes, we generally use sha256.

package/android-tools/android-tools.mk line 7

Quoted 13 lines
package/android-tools/android-tools.mk new file +7 -0
new file mode 100644
index 0000000..25817d5
@@ -0,0 +1,85 @@
+################################################################################
+#
+# android-tools
+#
+################################################################################
+
+ANDROID_TOOLS_SITE = https://launchpad.net/ubuntu/+archive/primary/+files/

The / at the end should be removed.

package/android-tools/android-tools.mk line 11

Quoted 4 lines
package/android-tools/android-tools.mk new file +4 -0
+ANDROID_TOOLS_VERSION = 4.2.2+git20130218
+ANDROID_TOOLS_SOURCE = android-tools_$(ANDROID_TOOLS_VERSION).orig.tar.xz
+ANDROID_TOOLS_EXTRA_DOWNLOADS = android-tools_$(ANDROID_TOOLS_VERSION)-3ubuntu41.debian.tar.gz
+HOST_ANDROID_TOOLS_EXTRA_DOWNLOADS = $(ANDROID_TOOLS_EXTRA_DOWNLOADS)

Not a problem of your patch, but I believe it is silly that we have to specify the <pkg>_EXTRA_DOWNLOADS explicitly for both target and host. The host value should be inherited from the target one, like we do for _SITE, _SOURCE, _VERSION and so on. However, this can be done later, so your patch is acceptable as is from this point of view.

package/android-tools/android-tools.mk line 23

Quoted 12 lines
package/android-tools/android-tools.mk new file +12 -0
+ANDROID_TOOLS_LICENSE = Apache-2.0
+ANDROID_TOOLS_LICENSE_FILES = debian/copyright
+xx
+# Extract the Debian tarball inside the sources
+define ANDROID_TOOLS_DEBIAN_EXTRACT
+	$(call suitable-extractor,$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS))) \
+		$(DL_DIR)/$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS)) | \
+		$(TAR) -C $(@D) $(TAR_OPTIONS) -
+endef
+
+HOST_ANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT
+ANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT

Same for extract hooks.

package/android-tools/android-tools.mk line 31

Quoted 8 lines
package/android-tools/android-tools.mk new file +8 -0
+
+# Apply the Debian patches before applying the Buildroot patches
+define ANDROID_TOOLS_DEBIAN_PATCH
+	$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*
+endef
+
+HOST_ANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH
+ANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH

And patch hooks. Theoretically, the download, extract and patch steps should always be exactly the same between the target variant and the host variant of a given package.

However, the biggest issue I got with this package is that the target variant doesn't build. I.e:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2015.08-647-gc356fb2.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_7=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_ANDROID_TOOLS=y
BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT=y
BR2_PACKAGE_ANDROID_TOOLS_ADB=y
BR2_PACKAGE_ANDROID_TOOLS_ADBD=y
# BR2_TARGET_ROOTFS_TAR is not set

doesn't build, due to __b64_pton not being defined. The Debian patches introduce the use of this function, but it only provides an implementation for b64_pton(). However, what puzzles me is that the C library also implements b64_pton(). Changing the Debian patch to use b64_pton() instead of __b64_pton() fixes the build, but I'm not sure it's the correct solution.

Could you have a look into this (and the other minor comments), and post an updated version of the patch ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH v3 1/1 android-tools: add new package

Hi Thomas,

Quoted 4 lines · Thomas Petazzoni

Gary,

Thanks for following-up on this, and sorry for the slow response. I have a few comments, and one build issue.

No problem, there's no rush.

Quoted 42 lines · Gary Bisson
Quoted 28 lines
package/android-tools/Config.in new file +21 -0
new file mode 100644
index 0000000..a8048bd
@@ -0,0 +1,39 @@
+config BR2_PACKAGE_ANDROID_TOOLS
+       bool "android-tools"
+       help
+         This package contains the fastboot and adb utilities, that
+         can be used to interact with target devices using of these
+         protocols.
+
+if BR2_PACKAGE_ANDROID_TOOLS
+
+config BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT
+       bool "fastboot"
+       select BR2_PACKAGE_LIBSELINUX
+       select BR2_PACKAGE_ZLIB
+       help
+         This option will build and install the fastboot utility for
+         the target, which can be used to reflash other target devices
+         implementing the fastboot protocol.
+
+config BR2_PACKAGE_ANDROID_TOOLS_ADB
+       bool "adb"
+       select BR2_PACKAGE_OPENSSL

package/android-tools/Config.in line 31

Quoted 10 lines
package/android-tools/Config.in new file +10 -0
+       select BR2_PACKAGE_ZLIB
+       help
+         This option will build and install the adb utility for the
+         target, which can be used to interact with other target devices
+         implementing the ADB protocol.
+
+config BR2_PACKAGE_ANDROID_TOOLS_ADBD
+       bool "adbd"
+       default y if !BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT
+       default y if !BR2_PACKAGE_ANDROID_TOOLS_ADB

I would prefer to see the top-level option do:

Quoted 4 lines
        select BR2_PACKAGE_ANDROID_TOOLS_ADBD if \
                !BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT && !BR2_PACKAGE_ANDROID_TOOLS_ADB

so that we ensure that at least one of the three sub-options is enabled.

Ok, will be fixed in next version.

Quoted 11 lines

package/android-tools/Config.in.host line 2

Quoted 8 lines
package/android-tools/Config.in.host new file +2 -0
new file mode 100644
index 0000000..4f16e9c
@@ -0,0 +1,25 @@
+config BR2_PACKAGE_HOST_ANDROID_TOOLS
+       bool "android-tools"

Same here.

Quoted 11 lines

package/android-tools/android-tools.hash line 3

Quoted 9 lines
package/android-tools/android-tools.hash new file +3 -0
new file mode 100644
index 0000000..5d8ae59
@@ -0,0 +1,3 @@
+# locally computed
+sha512       c5bfd3c8e514809db257ba5559c865742768b7520b38aa2f53185aff5c328e5cf7fb328a6ff6450eeddd5056985f232d492eba63a87978440e2147e26d62f458  android-tools_4.2.2+git20130218.orig.tar.xz
+sha512       aa3fee593cecf5d9a5fbc60b18d67dadc5b832fdea75a098ec7371b8f774673af3a3b6052d7eecaf315943beaa984a1f5a3c114a698620275af1682bd05d4d23  android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz

Right now, for locally computed hashes, we generally use sha256.

Same.

Quoted 16 lines

package/android-tools/android-tools.mk line 7

Quoted 13 lines
package/android-tools/android-tools.mk new file +7 -0
new file mode 100644
index 0000000..25817d5
@@ -0,0 +1,85 @@
+################################################################################
+#
+# android-tools
+#
+################################################################################
+
+ANDROID_TOOLS_SITE = https://launchpad.net/ubuntu/+archive/primary/+files/

The / at the end should be removed.

Quoted 10 lines

package/android-tools/android-tools.mk line 11

Quoted 4 lines
package/android-tools/android-tools.mk new file +4 -0
+ANDROID_TOOLS_VERSION = 4.2.2+git20130218
+ANDROID_TOOLS_SOURCE = android-tools_$(ANDROID_TOOLS_VERSION).orig.tar.xz
+ANDROID_TOOLS_EXTRA_DOWNLOADS = android-tools_$(ANDROID_TOOLS_VERSION)-3ubuntu41.debian.tar.gz
+HOST_ANDROID_TOOLS_EXTRA_DOWNLOADS = $(ANDROID_TOOLS_EXTRA_DOWNLOADS)

Not a problem of your patch, but I believe it is silly that we have to specify the <pkg>_EXTRA_DOWNLOADS explicitly for both target and host. The host value should be inherited from the target one, like we do for _SITE, _SOURCE, _VERSION and so on. However, this can be done later, so your patch is acceptable as is from this point of view.

Well maybe there are some cases where it would only be needed for either the target or the host.

Quoted 58 lines

package/android-tools/android-tools.mk line 23

Quoted 12 lines
package/android-tools/android-tools.mk new file +12 -0
+ANDROID_TOOLS_LICENSE = Apache-2.0
+ANDROID_TOOLS_LICENSE_FILES = debian/copyright
+xx
+# Extract the Debian tarball inside the sources
+define ANDROID_TOOLS_DEBIAN_EXTRACT
+     $(call suitable-extractor,$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS))) \
+             $(DL_DIR)/$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS)) | \
+             $(TAR) -C $(@D) $(TAR_OPTIONS) -
+endef
+
+HOST_ANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT
+ANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT

Same for extract hooks.

package/android-tools/android-tools.mk line 31

Quoted 8 lines
package/android-tools/android-tools.mk new file +8 -0
+
+# Apply the Debian patches before applying the Buildroot patches
+define ANDROID_TOOLS_DEBIAN_PATCH
+     $(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*
+endef
+
+HOST_ANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH
+ANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH

And patch hooks. Theoretically, the download, extract and patch steps should always be exactly the same between the target variant and the host variant of a given package.

However, the biggest issue I got with this package is that the target variant doesn't build. I.e:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2015.08-647-gc356fb2.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_7=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_ANDROID_TOOLS=y
BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT=y
BR2_PACKAGE_ANDROID_TOOLS_ADB=y
BR2_PACKAGE_ANDROID_TOOLS_ADBD=y
# BR2_TARGET_ROOTFS_TAR is not set

doesn't build, due to __b64_pton not being defined. The Debian patches introduce the use of this function, but it only provides an implementation for b64_pton(). However, what puzzles me is that the C library also implements b64_pton(). Changing the Debian patch to use b64_pton() instead of __b64_pton() fixes the build, but I'm not sure it's the correct solution.

Quoted 2 lines

Could you have a look into this (and the other minor comments), and post an updated version of the patch ?

So I confirm the build fails with this uclibc toolchain. At a first glance I would just rename __b64_pton to b64_pton since the base64.c seems to be added for that. Plus the C library in the toolchain you provided doesn't seem to have b64_pton implemented. By renaming it seems to build fine with both glibc and uclibc.

But then I tried to build using the musl experimental toolchain and it seems to brings other issues so I'll fix it too before offering another version.

Regards,
Gary