Adb for Raspberry pi

Search This thread

trevd

Inactive Recognized Developer
Jul 19, 2011
895
1,271
Hull
Samsung Galaxy Tab 4
Hi Adam.


I've built you a adb, version 1.0.29 which is based off the linaro Jellybean 4.1.1 JRO03R sources, It is a totally self contained statically linked binary which has a target arch of armv5te, which should be just fine. I don't have a PI to test it on but I did the next best thing [ link: qemu-emulating-raspberry-pi-the-easy-way ] It seems to function OK but the proof will be in the testing. If it has trouble listing devices or making connection then run the following command line to give an idea of what's going wrong.
Code:
ADB_TRACE=all ./adb

Hope That Helps!
Trev
 

Attachments

  • adb-armv5te-static.7z
    151.6 KB · Views: 293

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,827
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
Hi Adam.


I've built you a adb, version 1.0.29 which is based off the linaro Jellybean 4.1.1 JRO03R sources, It is a totally self contained statically linked binary which has a target arch of armv5te, which should be just fine. I don't have a PI to test it on but I did the next best thing [ link: qemu-emulating-raspberry-pi-the-easy-way ] It seems to function OK but the proof will be in the testing. If it has trouble listing devices or making connection then run the following command line to give an idea of what's going wrong.
Code:
ADB_TRACE=all ./adb

Hope That Helps!
Trev

It's way more than i've seen before on this version! It's not connecting to the server though. Here's the output you requested. I have to elevate sudo on my device because I do not have permissions assinged to open my Nexus7 from adb.

Code:
pi@raspberrypi ~/adb $ ADB_TRACE=all ./adb kill-server
system/core/adb/adb.c::main():Handling commandline()
system/core/adb/adb_client.c::_adb_connect():_adb_connect: host:kill
pi@raspberrypi ~/adb $ sudo ADB_TRACE=all ./adb devices
system/core/adb/adb.c::main():Handling commandline()
system/core/adb/adb_client.c::adb_query():adb_query: host:devices
system/core/adb/adb_client.c::_adb_connect():_adb_connect: host:version
system/core/adb/adb_client.c::adb_connect():adb_connect: service host:devices
* daemon not running. starting it now on port 5038 *
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
pi@raspberrypi ~/adb $ sudo ADB_TRACE=all ./adb reboot
system/core/adb/adb.c::main():Handling commandline()
system/core/adb/adb_client.c::_adb_connect():_adb_connect: host:version
system/core/adb/adb_client.c::adb_connect():adb_connect: service reboot:
* daemon not running. starting it now on port 5038 *
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
pi@raspberrypi ~/adb $

here's an strace ./adb reboot
Code:
pi@raspberrypi ~/adb $ strace ./adb reboot
execve("./adb", ["./adb", "reboot"], [/* 28 vars */]) = 0
gettid()                                = 3012
set_tls(0x5b0a0, 0x5b1a0, 0x5b19c, 0x40, 0x5b0a0) = 0
open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3
read(3, "\237`\271\264", 4)             = 4
close(3)                                = 0
clock_gettime(CLOCK_MONOTONIC, {805, 485324377}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400aa000
madvise(0x400aa000, 4096, 0xc /* MADV_??? */) = -1 EINVAL (Invalid argument)
mprotect(0x400aa000, 4096, PROT_READ)   = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(5038), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
close(3)                                = 0
mprotect(0x400aa000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x400aa000, 4096, PROT_READ)   = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
brk(0)                                  = 0x69000
brk(0x69000)                            = 0x69000
brk(0x6a000)                            = 0x6a000
mprotect(0x400aa000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x400aa000, 4096, PROT_READ)   = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "* daemon not running. starting i"..., 53* daemon not running. starting it now on port 5038 *
) = 53
pipe([3, 4])                            = 0
getpid()                                = 3012
readlink("/proc/3012/exe", "/home/pi/adb/adb", 4095) = 16
fork()                                  = 3013
close(4)                                = 0
read(3, "Inv", 3)                       = 3
close(3)                                = 0
write(2, "ADB server didn't ACK\n", 22ADB server didn't ACK
) = 22
write(2, "* failed to start daemon *\n", 27* failed to start daemon *
) = 27
write(2, "error: cannot connect to daemon\n", 32error: cannot connect to daemon
) = 32
mprotect(0x400aa000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x400aa000, 4096, PROT_READ)   = 0
mprotect(0x400aa000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x400aa000, 4096, PROT_READ)   = 0
munmap(0x400aa000, 4096)                = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
exit_group(1)                           = ?
pi@raspberrypi ~/adb $
 

cdesai

Inactive Recognized Developer
Jan 16, 2011
2,296
4,089
IN YOUR HEAD
An adb binary is built for the device already by default, it lives under /system/bin/adb.
So, just grab one from your device and use it (if you get around the linking problems), or compile it.

Setup your pc for building android (source.android.pc), and get AOSP master.
Once done, select any suitable target (type lunch to get a list).

make $OUT/system/bin/adb will do the job.

[ /home/cdesai/android/cm/10/out/target/product/p1/system/bin/adb: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped ] - so you'll need to force it to be static, do that at system/core/adb/Android.mk (https://android.googlesource.com/platform/system/core/+/master/adb/Android.mk - line 134)
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,827
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
An adb binary is built for the device already by default, it lives under /system/bin/adb.
So, just grab one from your device and use it (if you get around the linking problems), or compile it.

Setup your pc for building android (source.android.pc), and get AOSP master.
Once done, select any suitable target (type lunch to get a list).

make $OUT/system/bin/adb will do the job.

[ /home/cdesai/android/cm/10/out/target/product/p1/system/bin/adb: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped ] - so you'll need to force it to be static, do that at system/core/adb/Android.mk (https://android.googlesource.com/platform/system/core/+/master/adb/Android.mk - line 134)
That looks like what I need, and I tried to grab the binary, then link in the dependencies to debian, but it didn't work.

here is "file /bin/adb" which is a working, but older copy of adb for raspi.
Code:
/bin/adb: setuid setgid ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.26, BuildID[sha1]=0x8ffd8c80a0705dc113149612e3067931208bfd70, not stripped

Unfortunately, I don't really understand what is required to bend that Makefile. My knowledge limits end at specifying build folders, adding CC flags, and adding/removing tags... you know, the standard build-it-yourself stuff. I only really understand C Headers.
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,827
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
I found this command bugreport

Code:
pi@raspberrypi ~/adb $ ./adb bugreport
system/core/adb/adb.c::main():Handling commandline()
system/core/adb/commandline.c::adb_commandline():interactive shell loop. buff=shell:bugreport
system/core/adb/adb_client.c::_adb_connect():_adb_connect: host:version
system/core/adb/adb_client.c::adb_connect():adb_connect: service shell:bugreport
* daemon not running. starting it now on port 5038 *
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
system/core/adb/commandline.c::adb_commandline():interactive shell loop. return r=-1

Looks like it is having a problem instantiating a new shell process?
 

E:V:A

Inactive Recognized Developer
Dec 6, 2011
1,447
2,222
-∇ϕ
A couple of things:

  • Make sure you don't have a firewall blocking adb
  • If you're on windows make sure you don't have a defunct adb already running. (Check with task-manager and kill it.) And make sure you run it as administrator.
  • Make sure USB Debugging is enabled in the device (if available)
  • If you are using Ubuntu, add your USB vendor ID (VID) to the file 51-android.rules. See here for more details. Then do this:
    Code:
    sudo ./adb kill-server
    sudo ./adb start-server
Not sure if any of this helps, since I have no idea of what you're doing or how your setup looks...
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,827
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
A couple of things:

  • Make sure you don't have a firewall blocking adb
  • If you're on windows make sure you don't have a defunct adb already running. (Check with task-manager and kill it.) And make sure you run it as administrator.
  • Make sure USB Debugging is enabled in the device (if available)
  • If you are using Ubuntu, add your USB vendor ID (VID) to the file 51-android.rules. See here for more details. Then do this:
    Code:
    sudo ./adb kill-server
    sudo ./adb start-server
Not sure if any of this helps, since I have no idea of what you're doing or how your setup looks...
I have a working copy on my system but it's old. I need a new copy of adb for the adb restore command. it has to be built for arm and statically linked
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,827
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
I asked JBQ on G+ and he offered this..
Assuming that you can't pretend that your host environment is Pi (which probably wouldn't work in practice anyway), my best guess would be to either run "make adb showcommands" and see what gets built, or to look at the makefiles, figure out the list of relevant source files, and write a script that simply compiles all that with the Pi cross-compiler and links them against the Pi libraries.
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,827
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
ok.. by playing around with some of Rebellos's source from above and the compilier flags, I was able to make this output
Code:
pi@raspberrypi ~/Desktop/adbcompile/adb $ make adb
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o adb.o adb.c
In file included from sysdeps.h:260:0,
                 from adb.c:30:
/home/pi/adb/system/core/include/cutils/sockets.h: In function 'android_get_control_socket':
/home/pi/adb/system/core/include/cutils/sockets.h:55:2: warning: implicit declaration of function 'strlcpy' [-Wimplicit-function-declaration]
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o adb_client.o adb_client.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o commandline.o commandline.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o console.o console.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o fdevent.o fdevent.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o file_sync_client.o file_sync_client.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o file_sync_service.o file_sync_service.c
file_sync_service.c: In function 'do_send':
file_sync_service.c:280:9: warning: variable 'is_link' set but not used [-Wunused-but-set-variable]
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o framebuffer_service.o framebuffer_service.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o get_my_path_linux.o get_my_path_linux.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o jdwp_service.o jdwp_service.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o log_service.o log_service.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o services.o services.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o sockets.o sockets.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o transport.o transport.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o transport_local.o transport_local.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o transport_usb.o transport_usb.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o usb_linux.o usb_linux.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o usb_vendors.o usb_vendors.c
gcc -I/home/pi/adb/system/core/include -g -DADB_HOST=1 -DADB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter -D_XOPEN_SOURCE -D_GNU_SOURCE -fno-short-enums -mfloat-abi=softfp -march=armv6  -O2 -c -fmessage-length=0 -o utils.o utils.c
gcc -march=armv6 -print-multi-lib -mfloat-abi=softfp  -o adb adb.o adb_client.o commandline.o console.o fdevent.o file_sync_client.o file_sync_service.o framebuffer_service.o get_my_path_linux.o jdwp_service.o log_service.o services.o sockets.o transport.o transport_local.o transport_usb.o usb_linux.o usb_vendors.o utils.o  -L ../lib_armv6/ -lpthread -lcutils -lzipfile -lz 
.;
pi@raspberrypi ~/Desktop/adbcompile/adb $ ls
MODULE_LICENSE_APACHE2  adb.h               commandline.c  fdevent.o            framebuffer_service.c  log_service.c  sockets.dia  transport_local.c  usb_vendors.c
Makefile                adb.o               commandline.o  file_sync_client.c   framebuffer_service.o  log_service.o  sockets.o    transport_local.o  usb_vendors.h
NOTICE                  adb_client.c        console.c      file_sync_client.o   get_my_path_linux.c    mutex_list.h   sysdeps.h    transport_usb.c    usb_vendors.o
OVERVIEW.TXT            adb_client.h        console.o      file_sync_service.c  get_my_path_linux.o    services.c     transport.c  transport_usb.o    utils.c
SERVICES.TXT            adb_client.o        fdevent.c      file_sync_service.h  jdwp_service.c         services.o     transport.h  usb_linux.c        utils.h
adb.c                   adb_host_armv6.zip  fdevent.h      file_sync_service.o  jdwp_service.o         sockets.c      transport.o  usb_linux.o        utils.o
but there was no binary.. odd.
 

Foamyguy

Member
Nov 29, 2010
6
0
Little help

From what I can gather you've got an older version of ADB that is working correctly on the RasPi but you are trying to compile a newer version.

I have thus far been unable to make any version of it work on my raspberry pi.

Is there any chance that you could post a link to the older (working) adb binary that runs on Raspberry pi?

Also (sorry, still a bit of a noob in this space) once I've got a binary what would I need to do to make it run? I've tried 3 different ones that I've found linked in threads on this topic(including the one that trevd posted at the top of page 3) and have had no success yet.

I've been pasting them in /usr/local/bin/ I also added a 99-android.rules file to /etc/udev/rules.d/ Once I do those if I try to run an adb command I get either "Segmentation Fault" or "Illegal Instruction". The latter is what I get from the binary that trevd posted.

Is there something else I need to do to get this set up? I am not looking to do anything fancy yet, just want to be able to get an adb command to execute properly on the Raspberry Pi.
 

trevd

Inactive Recognized Developer
Jul 19, 2011
895
1,271
Hull
Samsung Galaxy Tab 4

Not a problem! ( in the end ). It's all part of the android fun and a great little learning experience!

I'm just setting up a git repo for armv6 now, Gotta get me some of that PI.

EDIT: I attached the built binary and here's a hotfile link [adb-129-armv6-static.7z] of the same file for good measure.

Now I can sleep easy :D

EDIT2: Needs to be run as root at the moment, I'm confident I'll be able to remove this requirement with a little more investigation.

EDIT3: After some hacking around with the android build system, I compiled a real adb host using the native toolchain on the pi, I've attached a zip which contain said binary aswell as the makefiles used.
 

Attachments

  • adbarmv6.7z
    1.3 MB · Views: 26,089
Last edited:

Foamyguy

Member
Nov 29, 2010
6
0
Thanks for posting that binary.

aside from running as root is there anything else that would need to be done to get that running on the Raspberry pi? Is it built for a specific raspberry pi image? should it work with the first one from the pi quickstart page?

Whenever I try to run any adb commands the only output I get is "Segmentation Fault"
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,827
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
It should work for raspian. You have something wrong with your system. I think you need libusb and that's about it.

However, this binary is incomplete. It should not need sudo to run and even with sudo it's reporting ??????? for certain devices and refusing to do anything. But, this problem will not cause a segmentation fault. Try the default raspian.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 20
    Update: trevd has managed to make a proper adb 1.0.29 frm source. For those who wish to simply use the binary, you can download it here http://xdaforums.com/attachment.php?attachmentid=1392336&d=1349930509


    From trevd:
    If anyone wants to hack on this I've setup an armv6 device tree on github to use the with AOSP source you can clone it to <aosp_sources>/device/generic/armv6 then do
    Code:
    lunch mini_armv6-userdebug && make -j4
    ......
    more here http://xdaforums.com/showpost.php?p=32632468&postcount=41






    --- OLD ----
    I'm trying to build ADB 1.0.28 or higher for the Raspberry Pi. I found a guide here: http://lackingrhoticity.blogspot.com/2010/02/how-to-build-adb-android-debugger.html but it's out of date since we can no longer access kernel.org directly. So, I'm trying to find a new way.

    I spoke to Entropy512 and he suggested using the Cyanogenmod repository. So, here's what I have so far.

    Code:
    sudo apt-get install build-essential libncurses5-dev openjdk-7-jre openjdk-7-jdk bison
    mkdir adb
    cd adb
    git clone git://github.com/CyanogenMod/android_system_core.git system/core
    git clone git://github.com/CyanogenMod/android_build.git build
    git clone git://github.com/CyanogenMod/android_external_zlib.git external/zlib
    git clone git://github.com/CyanogenMod/android_bionic.git bionic
    echo "include build/core/main.mk" >Makefile


    I edited the adb/build/core/main.mk to reflect the version of JDK and JRE I have on my system. I'm not sure if they are even required at this point... Anyway, I modified the grep statements to find OpenJDK IcedTea instead of Oracle's version. Here's some snippits from the build/core/main.mk file.. make these match the values for your system's "java -version" and "javac -version"

    build/core/main.mk
    Code:
    .
    .
    .
    # Check for the correct version of java
    java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.7[\. "$$]')
    #Removed the next 3 lines
    
    
    .
    
    # Check for the correct version of javac
    javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.7[\. "$$]')

    So this puts me here:
    Code:
    pi@raspberrypi ~/adb $ make out/host/linux-x86/bin/adb
    ^[[A^[[B============================================
    PLATFORM_VERSION_CODENAME=REL
    PLATFORM_VERSION=4.0.4
    TARGET_PRODUCT=full
    TARGET_BUILD_VARIANT=eng
    TARGET_BUILD_TYPE=release
    TARGET_BUILD_APPS=
    TARGET_ARCH=arm
    TARGET_ARCH_VARIANT=armv7-a
    HOST_ARCH=x86
    HOST_OS=linux
    HOST_BUILD_TYPE=release
    BUILD_ID=IMM76L
    ============================================
    build/core/tasks/kernel.mk:68: **********************************************************
    build/core/tasks/kernel.mk:69: * Kernel source found, but no configuration was defined  *
    build/core/tasks/kernel.mk:70: * Please add the TARGET_KERNEL_CONFIG variable to your   *
    build/core/tasks/kernel.mk:71: * BoardConfig.mk file                                    *
    build/core/tasks/kernel.mk:72: **********************************************************
    host C: adb <= system/core/adb/adb.c
    cc1: error: unrecognized command line option ‘-m32’
    make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb.o] Error 1
    pi@raspberrypi ~/adb $

    I'm still working on the rest. help would be appreciated. I can't get it to build on my desktop either. I really need help with this.
    6
    Hi Folks

    If anyone wants to hack on this I've setup an armv6 device tree on github to use the with AOSP source you can clone it to <aosp_sources>/device/generic/armv6 then do
    Code:
    lunch mini_armv6-userdebug && make -j4

    It's currently setup to compile to armv5te as adding true armv6 support require modification of build/core/combo/TARGET_linux-arm.mk
    It also sets BUILD_TINY_ANDROID := true automatically to only build do a minimal build, what you will end up with is Android image that is bootable on the PI, it will only start /sbin/adbd. ( see below ) :D

    Tiny android build time takes about 1 minute on my AMD FX8120 with make -j16 set

    I've left what is describe below as a reference. Although It looked like it worked in the end It simply didn't do the job. I'm not fully sure of the reasons why but It's not something I'll be investigating further as It's not the correct way of doing making an adb for a host

    A modification has to be made to the the <aosp_sources>/system/core/adb/Android.mk in the aosp tree, this forces the device-as-host version to use port 5037 instead of 5038

    Code:
    # adb host tool for device-as-host
    # =========================================================
    ifneq ($(SDK_ONLY),true)
    include $(CLEAR_VARS)
    
    LOCAL_LDLIBS := -lrt -lncurses -lpthread
    
    LOCAL_SRC_FILES := \
    	adb.c \
    	console.c \
    	transport.c \
    	transport_local.c \
    	transport_usb.c \
    	commandline.c \
    	adb_client.c \
    	sockets.c \
    	services.c \
    	file_sync_client.c \
    	get_my_path_linux.c \
    	usb_linux.c \
    	utils.c \
    	usb_vendors.c \
    	fdevent.c
    
    LOCAL_CFLAGS := \
    	-g \
    	-DADB_HOST=1 \
    	-Wall \
    	-Wno-unused-parameter \
    	-D_XOPEN_SOURCE \
    	-D_GNU_SOURCE 
    
    [B]# LOCAL_CFLAGS += -DADB_HOST_ON_TARGET=1 
    # Removed Adb host on target to for the binary to use the host port 5037 instead of the target host port 5038[/B]
    
    # adb can't be built without optimizations, so we enforce -O2 if no
    # other optimization flag is set - but we don't override what the global
    # flags are saying if something else is given (-Os or -O3 are useful)
    ifeq ($(findstring -O, $(TARGET_GLOBAL_CFLAGS)),)
    LOCAL_CFLAGS += -O2
    endif
    ifneq ($(findstring -O0, $(TARGET_GLOBAL_CFLAGS)),)
    LOCAL_CFLAGS += -O2
    endif
    
    LOCAL_MODULE := adb
    [B]LOCAL_FORCE_STATIC_EXECUTABLE := true[/B]
    LOCAL_STATIC_LIBRARIES := libzipfile libunz libcutils, [B]libc[/B]
    
    include $(BUILD_EXECUTABLE)
    endif


    The highlights are in bold, It's statically linked against aosp libc ( bionic ). You may want to make sure you have ncurses installed on the PI using apt or something similar.
    which should make it alright on any distro but as Adam has already noted there are still issues. It really is bit of a dirty hack!

    The binary can be found at target/product/armv6/system/bin/adb in the directory you compile android too ( which is normally a directory call "out" in the android source tree )

    I am currently running this [ Linaro Tiny Android Script ] on my Pi Emulator, I see how long it take, From what I gather it only grabs a subset of the sources and it should build a real adb host version using the toolchain on the pi.
    6
    Hi Adam.


    I've built you a adb, version 1.0.29 which is based off the linaro Jellybean 4.1.1 JRO03R sources, It is a totally self contained statically linked binary which has a target arch of armv5te, which should be just fine. I don't have a PI to test it on but I did the next best thing [ link: qemu-emulating-raspberry-pi-the-easy-way ] It seems to function OK but the proof will be in the testing. If it has trouble listing devices or making connection then run the following command line to give an idea of what's going wrong.
    Code:
    ADB_TRACE=all ./adb

    Hope That Helps!
    Trev
    5

    Not a problem! ( in the end ). It's all part of the android fun and a great little learning experience!

    I'm just setting up a git repo for armv6 now, Gotta get me some of that PI.

    EDIT: I attached the built binary and here's a hotfile link [adb-129-armv6-static.7z] of the same file for good measure.

    Now I can sleep easy :D

    EDIT2: Needs to be run as root at the moment, I'm confident I'll be able to remove this requirement with a little more investigation.

    EDIT3: After some hacking around with the android build system, I compiled a real adb host using the native toolchain on the pi, I've attached a zip which contain said binary aswell as the makefiles used.
    3
    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.

    ....
    Now, just:

    Code:
    cd system/core/adb
    make adb

    That's it. The rest is testing.


    @jogco Nice one dude!

    AFAIK @AdamOutler does actively maintain an armv6 adb host in his Casual project.

    Regardless building from source whether necessary or not is something you should ever have to defend, especially not on XDA ain't the RPI Forums where I'm sure some folks would question you breathe if I wasn't endorsed by the Foundation. I do hope the whole thing wasn't to much of a Pain in the ass to figure out however because I'm gonna be that guy which shows you a much simpler way to do what you've just done. :eek: Personally I hate it when it happens to me, so sorry dude!

    So "no-oping" static_library.mk shared_library.mk and executable.mk in the build/core directory disables $(TARGET_BUILD_EXECUTABLE), TARGET_BUILD_SHARED_LIBRARY and TARGET_BUILD_SHARED_LIBRARY found in the various Android.mk fragments. which negates the need to create your own makefile as we just use the host side of the build system. It's also what I effectively did a few years back ( earlier in the thread ) .. but I was young, naive and eager to please... It was a bit hacky to say the least :eek:

    Anyway here's my 2014 version! - Well it's not adb specific although I did use it as an example ( #2 ) It "should" build any host binary as long as you give it all the dependencies


    Code:
    #!/bin/bash
    #
    # Namee : build-aosp-host-binaries 
    # Description : A Convient script to build android aosp host binaries
    #               without syncing the full platform sources
    #
    # Copyright (C) 2014 Trevor Drake
    #
    # This program is free software; you can redistribute it and/or
    # modify it under the terms of the GNU General Public License
    # as published by the Free Software Foundation; either version 2
    # of the License, or (at your option) any later version.
    # 
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    # 
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    # 
    # Assumes you know what dependencies a specific modules has.
    # If you are missing some dependencies the build will fail
    # You can generally figure it out from the error out
    # http://androidxref.com is also an handy resource :)
    #
    #
    # usage : build-aosp-host-binaries <module> <branch> <source repositories>
    #
    # examples 
    # #1 Sqlite - sqlite3 has a dependency on liblog so need both the
    #             external/sqlite source repo as well as system/core for liblog
    #
    # ./build-aosp-host-binaries sqlite3 master external/sqlite system/core
    #
    # #2 adb - adb is located in the system/core repository and depends on 
    #	   libunz libcrytpo_static, which can be found in external/zlib 
    #          and external/openssl repectively
    #
    # ./build-aosp-host-binaries adb master external/openssl external/zlib system/core
    #
    # #3 mkbootfs - mkbootfs doesn't have any external dependencies.
    #               so we only need the source repository which is system/core
    #
    #
    # /build-aosp-host-binaries mkbootfs master system/core
    
    # use the first argument as the module name
    # e.g adb mkbootfs or whatever 
    LOCAL_MODULE=$1
    # Select a branch 
    LOCAL_BRANCH=$2
    # discard the first argument
    shift 2
    # Glob the rest of the arguments as local Dependencies
    # Also add build external/stlport and external/libcxx 
    # as they seem to be required by most projects
    LOCAL_DEPENDS="$* build external/stlport external/libcxx"
    
    # Make a temporary build directory
    TMPDIR=`mktemp -dt quick.XXXXXXXXXX`
    echo $TMPDIR
    
    # Shallow clone the repos  into the temp directory 
    # --depth 1 automatically set --single-branch on
    for gr in $LOCAL_DEPENDS; 
        do 
    	git clone --depth 1 --branch $LOCAL_BRANCH https://android.googlesource.com/platform/$gr $TMPDIR/$gr; 
        done 
    
    # A Cheap trick to disable any target builds which may exist for the modules Android.mk
    cat /dev/null > $TMPDIR/build/core/static_library.mk > $TMPDIR/build/core/shared_library.mk > $TMPDIR/build/core/executable.mk
    
    # Usual android build system envsetup nonsense
    # We don't need to do lunch as we are not building for a target
    . $TMPDIR/build/envsetup.sh
    
    
    # use the build systems m command as we don't have a top level Makefile
    time m -C$TMPDIR  -j16 $LOCAL_MODULE

    The script lives here https://github.com/trevd/building-android with some other android compiling fun. I've not tried it on an arm host ( it should work ) , So Let me know how you get on if you do use it. Obviously you got your own solution already... it's there anyway :silly:.

    Thanks
    trevd

    Welcome to XDA BTW! - If only more folks Post #1 were like this. :good: