[Raspberry Pi Development] jogco:
Really simple way of building the latest adb on Raspberry Pi

Hi,

After trolling all these "adb on RPi" threads on this and other forums, I thought I'd share what I found works for me (first post btw! ).

It's really simple in fact: You can obtain a subset of the Android source tree and build only adb (and necessary libs), the subset is about 25 MB and builds in minutes on a RPi rev B.

Before anyone ask why: trust me, I needed to have the latest stock (no changes) adb running on RPi. The other versions just didn't fit the bill.

I have used these sources, to which I attribute my success :)

http://xdaforums.com/showthread.php?t=2047891

https://source.android.com/source/building.html

http://stackoverflow.com/questions/5904765/build-android-adb-for-arm-processor

http://lackingrhoticity.blogspot.se/2010/02/how-to-build-adb-android-debugger.html

So here's what I've got:

I booted with a new raspbian image: Raspbian "June 2014" version dated 2014-06-20. I don't think it is essential which version.

I then set up the RPi for AOSP:

sudo apt-get install git build-essential libncurses5-dev libssl-dev

I then clone the necessary repositories into a suitable directory

mkdir aosp
cd aosp
git clone https://android.googlesource.com/platform/system/core.git system/core
git clone https://android.googlesource.com/platform/external/zlib.git external/zlib

This will clone the master branch, so there is a chance that the following does not work depending on what has been done in Android.

For that reason, these are the commits I used:

32e2f1be039482762303378113c817ba99466953 ./system/core/.git
8d977782c1cfe9d75cc9a464439c2ff1e27e1665 ./external/zlib/.git

The adb source is in system/core/adb.

Create a Makefile in system/core/adb with the following content:

SRCS+= adb.c
SRCS+= adb_client.c
SRCS+= commandline.c
SRCS+= console.c
SRCS+= file_sync_client.c
SRCS+= fdevent.c
SRCS+= get_my_path_linux.c
SRCS+= services.c
SRCS+= sockets.c
SRCS+= transport.c
SRCS+= transport_local.c
SRCS+= transport_usb.c
SRCS+= usb_linux.c
SRCS+= usb_vendors.c
SRCS+= adb_auth_host.c

VPATH+= ../libcutils
SRCS+= socket_inaddr_any_server.c
SRCS+= socket_local_client.c
SRCS+= socket_local_server.c
SRCS+= socket_loopback_client.c
SRCS+= socket_loopback_server.c
SRCS+= socket_network_client.c
SRCS+= load_file.c

VPATH+= ../libzipfile
SRCS+= centraldir.c
SRCS+= zipfile.c

VPATH+= ../../../external/zlib/src
SRCS+= adler32.c
SRCS+= compress.c
SRCS+= crc32.c
SRCS+= deflate.c
SRCS+= infback.c
SRCS+= inffast.c
SRCS+= inflate.c
SRCS+= inftrees.c
SRCS+= trees.c
SRCS+= uncompr.c
SRCS+= zutil.c

CPPFLAGS+= -DADB_HOST=1
CPPFLAGS+= -DHAVE_FORKEXEC=1
CPPFLAGS+= -DHAVE_SYMLINKS
CPPFLAGS+= -DHAVE_TERMIO_H
CPPFLAGS+= -DHAVE_OFF64_T
CPPFLAGS+= -D_GNU_SOURCE
CPPFLAGS+= -D_XOPEN_SOURCE
CPPFLAGS+= -DWORKAROUND_BUG6558362
CPPFLAGS+= -I.
CPPFLAGS+= -I../include
CPPFLAGS+= -I../../../external/zlib

CFLAGS+= -O2 -g -Wall -Wno-unused-parameter
#LDFLAGS= -static
LIBS= -lrt -lpthread -lssl

TOOLCHAIN=
CC= $(TOOLCHAIN)gcc
LD= $(TOOLCHAIN)gcc

OBJS= $(SRCS:.c=.o)

all: adb

adb: $(OBJS)
$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)

clean:
rm -rf $(OBJS)

Now, just:

cd system/core/adb
make adb

That's it. The rest is testing.