blob: 23ae44d544bb226d560f6dcc36ee9044c8797eb7 [file] [log] [blame] [view]
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -07001adeb
Joel Fernandes652141b2018-04-01 21:15:48 -07002--------
Joel Fernandes0301c042018-03-30 16:28:57 -07003
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -07004**adeb** (also known as **androdeb**) provides a powerful Linux shell
Joel Fernandesc7551962018-07-10 14:12:19 -07005environment where one can run popular and mainstream Linux tracing, compiling,
6editing and other development tools on an existing Android device. All the
7commands typically available on a modern Linux system are supported in
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -07008adeb.
Joel Fernandes63981702018-04-01 20:30:55 -07009
10Usecases
11--------
Joel Fernandes8ff0b5f2018-04-01 21:13:03 -0700121. Powerful development environment with all tools ready to go (editors,
Joel Fernandes63981702018-04-01 20:30:55 -070013compilers, tracers, perl/python etc) for your on-device development.
14
Joel Fernandes8ff0b5f2018-04-01 21:13:03 -0700152. No more cross-compiler needed: Because it comes with gcc and clang, one can
Joel Fernandes63981702018-04-01 20:30:55 -070016build target packages natively without needing to do any cross compilation. We even
Joel Fernandesafea46d2018-04-01 21:08:23 -070017ship git, and have support to run apt-get to get any missing development packages
18from the web.
Joel Fernandes63981702018-04-01 20:30:55 -070019
Joel Fernandes1fdb3182018-04-01 21:13:27 -0700203. Using these one can run popular tools such as BCC that are difficult to run
Joel Fernandes (Google)fa32e592018-05-29 11:49:20 -070021in an Android environment due to lack of packages, dependencies and
22cross-compilation needed for their operation. [Check BCC on Android using
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -070023adeb](https://github.com/joelagnel/adeb/blob/master/BCC.md) for more
Joel Fernandes (Google)fa32e592018-05-29 11:49:20 -070024information on that.
Joel Fernandes63981702018-04-01 20:30:55 -070025
Joel Fernandes1fdb3182018-04-01 21:13:27 -0700264. No more crippled tools: Its often a theme to build a static binary with
Joel Fernandes63981702018-04-01 20:30:55 -070027features disabled, because you couldn't cross-compile the feature's dependencies. One
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -070028classic example is perf. However, thanks to adeb, we can build perf natively
Joel Fernandes63981702018-04-01 20:30:55 -070029on device without having to cripple it.
30
31Requirements for running
32------------------------
33Target:
34An ARM64 android N or later device which has "adb root" supported. Typically
35this is a build in a userdebug configuration. Device should have atleast 2 GB
Joel Fernandes (Google)fa32e592018-05-29 11:49:20 -070036free space in the data partition. If you would like to use other architectures,
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -070037see the [Other Architectures](https://github.com/joelagnel/adeb/blob/master/README.md#how-to-use-adeb-for-other-architectures-other-than-arm64) section.
Joel Fernandes63981702018-04-01 20:30:55 -070038
39Host:
40A machine running recent Ubuntu or Debian, with 4GB of memory and 4GB free space.
Joel Fernandes2a4c77d2018-04-02 10:15:50 -070041Host needs debootstrap and qemu-debootstrap packages.
Joel7dd36e62018-04-03 12:35:23 -070042To install it, run `sudo apt-get install qemu-user-static debootstrap`.
Joel Fernandes25976502018-04-02 09:59:48 -070043Other distributions may work but they are not tested.
Joel Fernandes63981702018-04-01 20:30:55 -070044
Joel Fernandes9bb0c842018-04-01 20:38:35 -070045Quick Start Instructions
46------------------------
Joel Fernandes (Google)a1dd6a82018-07-25 16:47:53 -070047* First clone this repository into adb and cd into it.
Joel Fernandes9bb0c842018-04-01 20:38:35 -070048```
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -070049cd adeb
Joel Fernandesc7551962018-07-10 14:12:19 -070050
51# Add some short cuts:
Joel Fernandesaefebd12018-07-10 14:17:19 -070052sudo ln -s $(pwd)/adeb /usr/bin/adeb
Joel Fernandes (Google)db9005f2018-07-25 16:44:12 -070053
Erick Reyeseb6bc732018-08-16 15:39:48 -070054# Cached image downloads result in a huge speed-up. These are automatic if you
55# cloned the repository using git. However, if you downloaded the repository
56# as a zip file (or you want to host images elsewere), you could set the
57# ADEB_REPO_URL environment variable in your bashrc file.
Joel Fernandes (Google)db9005f2018-07-25 16:44:12 -070058# Disclaimer: Google is not liable for the below URL and this
59# is just an example.
Erick Reyesdd195c02018-08-16 14:50:47 -070060export ADEB_REPO_URL="github.com/joelagnel/adeb/"
Joel Fernandes9bb0c842018-04-01 20:38:35 -070061```
62
Joel Fernandes6975db22018-07-11 20:53:16 -070063* Installing adeb onto your device:
Joel Fernandes16181992018-07-11 20:59:08 -070064First make sure device is connected to system
65Then run, for the base image:
Joel Fernandes9bb0c842018-04-01 20:38:35 -070066```
Joel Fernandes6975db22018-07-11 20:53:16 -070067adeb prepare
68```
Joel Fernandesb97601f2018-07-11 20:56:39 -070069The previous command only downloads and installs the base image.
70Instead if you want to download and install the full image, do:
71```
Joel Fernandes6975db22018-07-11 20:53:16 -070072adeb prepare --full
Joel Fernandes9bb0c842018-04-01 20:38:35 -070073```
74
Joel Fernandesc7551962018-07-10 14:12:19 -070075* Now run adeb shell to enter your new environment!:
Joel Fernandes9bb0c842018-04-01 20:38:35 -070076```
Joel Fernandesc7551962018-07-10 14:12:19 -070077adeb shell
Joel Fernandes9bb0c842018-04-01 20:38:35 -070078```
Joel Fernandes961b69b2018-04-02 23:14:36 -070079
80* Once done, hit `CTRL + D` and you will exit out of the shell.
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -070081To remove adeb from the device, run:
Joel Fernandes961b69b2018-04-02 23:14:36 -070082```
Joel Fernandesc7551962018-07-10 14:12:19 -070083adeb remove
Joel Fernandes961b69b2018-04-02 23:14:36 -070084```
85If you have multiple devices connected, please add `-s <serialnumber>`.
86Serial numbers of all devices connected can be obtained by `adb devices`.
87
ErickReyesR82574e12018-07-31 00:25:18 -060088* To update an existing adeb clone on your host, run:
Joel Fernandesc6bb4962018-07-08 11:00:32 -070089```
Joel Fernandesc7551962018-07-10 14:12:19 -070090adeb git-pull
Joel Fernandesc6bb4962018-07-08 11:00:32 -070091```
92
Joel Fernandes93b7f2e2018-04-01 20:58:20 -070093More advanced usage instructions
94--------------------------------
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -070095### Install kernel headers in addition to preparing adeb device:
Joel Fernandes93b7f2e2018-04-01 20:58:20 -070096```
Joel Fernandes6975db22018-07-11 20:53:16 -070097adeb prepare --kernelsrc /path/to/kernel-source
Joel Fernandes93b7f2e2018-04-01 20:58:20 -070098```
99
Joel Fernandesbc32b492018-04-01 21:15:24 -0700100### Update kernel headers onto an already prepared device:
Joel Fernandes1a0e2592018-04-01 21:00:51 -0700101
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700102If you need to put kernel sources for an existing install, run:
103```
Joel Fernandesc7551962018-07-10 14:12:19 -0700104adeb prepare --kernelsrc /path/to/kernel-source --skip-install
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700105```
106Note: The kernel sources should have been built (atleast build should have started).
107
Joel Fernandes1a0e2592018-04-01 21:00:51 -0700108### Build and prepare device with a custom rootfs locally:
109
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -0700110The adeb fs will be prepared locally by downloading packages as needed:
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700111```
Joel Fernandes6975db22018-07-11 20:53:16 -0700112adeb prepare --build
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700113```
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -0700114This is unlike the default behavior, where the adeb rootfs is itself pulled from the web.
Joel Fernandes6975db22018-07-11 20:53:16 -0700115
116If you wish to do a full build (that is locally prepare a rootfs with all packages, including bcc, then do):
117```
118adeb prepare --full --build
119```
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700120
Joel Fernandesda816a82018-04-01 21:02:11 -0700121### Add kernel headers to device in addition to building locally:
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700122```
Joel Fernandes6975db22018-07-11 20:53:16 -0700123adeb prepare --build --kernelsrc /path/to/kernel-source/
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700124```
125
Joel Fernandes6975db22018-07-11 20:53:16 -0700126### Build/install a base image with BCC:
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700127```
Joel Fernandes6975db22018-07-11 20:53:16 -0700128adeb prepare --build --bcc --kernelsrc /path/to/kernel-source/
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700129```
Joel Fernandes6975db22018-07-11 20:53:16 -0700130Note: BCC is built from source. Also `--kernelsrc` is recommended for tools to
131function unless device has them already.
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700132
Joel Fernandesda816a82018-04-01 21:02:11 -0700133### Extract the FS from the device, after its prepared:
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700134```
Joel Fernandes6975db22018-07-11 20:53:16 -0700135adeb prepare --buildtar /path/
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700136```
137After device is prepared, it will extract the root fs from it
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -0700138and store it as a tar archive at `/path/adeb-fs.tgz`. This
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700139can be used later.
140
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -0700141### Use a previously prepared adeb rootfs tar from local:
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700142```
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -0700143adeb prepare --archive /path/adeb-fs.tgz
Joel Fernandes93b7f2e2018-04-01 20:58:20 -0700144```
Joel Fernandes (Google)9c3ae932018-05-28 14:34:48 -0700145
146### Build a standalone raw EXT4 image out of the FS:
147```
Joel Fernandes16181992018-07-11 20:59:08 -0700148adeb prepare --build-image /path/to/image.img
Joel Fernandes (Google)9c3ae932018-05-28 14:34:48 -0700149```
150This can then be passed to Qemu as -hda. Note: This option doesn't need a
151device connected.
Joel Fernandes (Google)fa32e592018-05-29 11:49:20 -0700152
Joel Fernandes (Google)ac628742018-07-16 18:55:40 -0700153### How to use adeb for other Architectures (other than ARM64)
154By default adeb assumes the target Android device is based on ARM64
Joel Fernandes (Google)fa32e592018-05-29 11:49:20 -0700155processor architecture. For other architectures, use the --arch option. For
156example for x86_64 architecture, run:
157```
Joel Fernandes6975db22018-07-11 20:53:16 -0700158adeb prepare --build --arch amd64 --bcc --kernelsrc /path/to/kernel-source/
Joel Fernandes (Google)fa32e592018-05-29 11:49:20 -0700159```
160Note: The --download option ignores the --arch flag. This is because we only
161provide pre-built filesystems for ARM64 at the moment.
Joel Fernandes (Google)76e84642018-07-27 20:04:30 -0700162
163Common Trouble shooting
164-----------------
1651. Installing g++ with `apt-get install g++` fails.
Joel Fernandes (Google)02db2fd2018-07-27 20:05:17 -0700166
Liu Changchengf44ca952018-08-02 14:38:58 +0800167Solution: Run `adeb shell apt-get update` after the `adeb prepare` stage.
168
1692. It's too slow to use debootstrap to create debian fs
170
171Solution: Use a local mirror, for example in China you could use
172https://mirror.tuna.tsinghua.edu.cn/debian/ instead of debian official website
173http://deb.debian.org/debian/