1adeb 2-------- 3 4**adeb** (also known as **androdeb**) provides a powerful Linux shell 5environment 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 8adeb. 9 10Usecases 11-------- 121. Powerful development environment with all tools ready to go (editors, 13compilers, tracers, perl/python etc) for your on-device development. 14 152. No more cross-compiler needed: Because it comes with gcc and clang, one can 16build target packages natively without needing to do any cross compilation. We even 17ship git, and have support to run apt-get to get any missing development packages 18from the web. 19 203. Using these one can run popular tools such as BCC that are difficult to run 21in an Android environment due to lack of packages, dependencies and 22cross-compilation needed for their operation. [Check BCC on Android using 23adeb](https://github.com/joelagnel/adeb/blob/master/BCC.md) for more 24information on that. 25 264. No more crippled tools: Its often a theme to build a static binary with 27features disabled, because you couldn't cross-compile the feature's dependencies. One 28classic example is perf. However, thanks to adeb, we can build perf natively 29on 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 36free space in the data partition. If you would like to use other architectures, 37see the [Other Architectures](https://github.com/joelagnel/adeb/blob/master/README.md#how-to-use-adeb-for-other-architectures-other-than-arm64) section. 38 39Host: 40A machine running recent Ubuntu or Debian, with 4GB of memory and 4GB free space. 41Host needs debootstrap and qemu-debootstrap packages. 42To install it, run `sudo apt-get install qemu-user-static debootstrap`. 43Other distributions may work but they are not tested. 44 45Quick Start Instructions 46------------------------ 47* First clone this repository into adb and cd into it. 48``` 49cd adeb 50 51# Add some short cuts: 52sudo ln -s $(pwd)/adeb /usr/bin/adeb 53 54# 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. 58# Disclaimer: Google is not liable for the below URL and this 59# is just an example. 60export ADEB_REPO_URL="github.com/joelagnel/adeb/" 61``` 62 63* Installing adeb onto your device: 64First make sure device is connected to system 65Then run, for the base image: 66``` 67adeb prepare 68``` 69The previous command only downloads and installs the base image. 70Instead if you want to download and install the full image, do: 71``` 72adeb prepare --full 73``` 74 75* Now run adeb shell to enter your new environment!: 76``` 77adeb shell 78``` 79 80* Once done, hit `CTRL + D` and you will exit out of the shell. 81To remove adeb from the device, run: 82``` 83adeb remove 84``` 85If you have multiple devices connected, please add `-s <serialnumber>`. 86Serial numbers of all devices connected can be obtained by `adb devices`. 87 88* To update an existing adeb clone on your host, run: 89``` 90adeb git-pull 91``` 92 93More advanced usage instructions 94-------------------------------- 95### Install kernel headers in addition to preparing adeb device: 96``` 97adeb prepare --kernelsrc /path/to/kernel-source 98``` 99 100### Update kernel headers onto an already prepared device: 101 102If you need to put kernel sources for an existing install, run: 103``` 104adeb prepare --kernelsrc /path/to/kernel-source --skip-install 105``` 106Note: The kernel sources should have been built (atleast build should have started). 107 108### Build and prepare device with a custom rootfs locally: 109 110The adeb fs will be prepared locally by downloading packages as needed: 111``` 112adeb prepare --build 113``` 114This is unlike the default behavior, where the adeb rootfs is itself pulled from the web. 115 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``` 120 121### Add kernel headers to device in addition to building locally: 122``` 123adeb prepare --build --kernelsrc /path/to/kernel-source/ 124``` 125 126### Build/install a base image with BCC: 127``` 128adeb prepare --build --bcc --kernelsrc /path/to/kernel-source/ 129``` 130Note: BCC is built from source. Also `--kernelsrc` is recommended for tools to 131function unless device has them already. 132 133### Extract the FS from the device, after its prepared: 134``` 135adeb prepare --buildtar /path/ 136``` 137After device is prepared, it will extract the root fs from it 138and store it as a tar archive at `/path/adeb-fs.tgz`. This 139can be used later. 140 141### Use a previously prepared adeb rootfs tar from local: 142``` 143adeb prepare --archive /path/adeb-fs.tgz 144``` 145 146### Build a standalone raw EXT4 image out of the FS: 147``` 148adeb prepare --build-image /path/to/image.img 149``` 150This can then be passed to Qemu as -hda. Note: This option doesn't need a 151device connected. 152 153### How to use adeb for other Architectures (other than ARM64) 154By default adeb assumes the target Android device is based on ARM64 155processor architecture. For other architectures, use the --arch option. For 156example for x86_64 architecture, run: 157``` 158adeb prepare --build --arch amd64 --bcc --kernelsrc /path/to/kernel-source/ 159``` 160Note: The --download option ignores the --arch flag. This is because we only 161provide pre-built filesystems for ARM64 at the moment. 162 163Common Trouble shooting 164----------------- 1651. Installing g++ with `apt-get install g++` fails. 166 167Solution: 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/ 174