I am trying to run some ARM assembly codes on Snapdragon 810 development board to evaluate performance on Cortex-A53 and A57 processors. My codes are nothing to do with android applications and they are C/Assembly coeds. Moreover, I want to get remote access to the board preferably via SSH and run gcc commands. The board default OS in Android Lollipop and my first intention was to install Linux on it to make things work desirably. However, Qualcomm customer support informed me that Linux isn't supported by this board and I have to deal with Android.
I've already searched over various forums. Some of them suggest to root the Android device, install QuickSSHD or SSHDroid on the device and simply SSH to it. However, I am not sure if the provided console has the capability of running gcc commands, generating executable and running it. Others, suggest to generate executable using cross-compilation and push the executable via adb console and run it on the Android device. This approach makes more sense, but I need to have remote access via SSH to the board and edit my code on the device continuously.
My question is, what is the best and easiest approach to get remote access via SSH to this device, compile and run C/ARM Assembly code, transfer files and get the real timing of my codes?!
Cross compile is the easiest option to generate the executable. Else you will have to port GCC to the target first. Don't even bother.
And Adb is a lot better when dealing with Android devices as you need not install any additional applications/executables to get it working. Adb can work on TCP connection as well. So there is no need of SSH for the task. And if the device is rooted, "adb root" followed by "adb shell" would give you the root console.
Usually we use windows/linux machines to pull logcat info from an android device.
Is it possible to use android tablet/phone to act as host and get the logs from another android phone connected to it?
This is possible. The host Android device needs to be defined as a USB host. Then, once a connection is established, all of the same commands can be run, assuming that ADB is installed on the host device.
See here for more discussion on USB Host Mode support and compatible cables: https://android.stackexchange.com/questions/36887/how-can-i-determine-if-my-device-has-usb-host-mode-otg-support
It is useful to have a terminal program, such as Terminal IDE to issue commands from, and using busybox to provide additional commands would also be beneficial.
ADB comes as part of the AOSP source, so it a device is based off AOSP, then it will possibly include ADB. ADB source is located in /system/core/adb in the AOSP source tree.
Here is an example of a session where a Nitrogen6X (host) running a custom AOSP is used to connect to a Galaxy S3 cellphone (client). Note the use of Busybox and ADB, both of which are installed on the host. Busybox also happens to be installed on the client, but this is not necessary:
Thus in order to pull logs, just use regular ADB commands (e.g. to copy files), or run logcat, as indicated below:
I'm trying to flash google apps into a genymotion emulator. I can do this using the drag and drop feature, but it's required for my project that the google apps .zip is already loaded into the genymotion machine and it's flashed internally. (To avoid having to interact with the desktop)
I've checked questions like this where the flashing is achieved but using the clockworkmod recovery (Which I couldn't install on genymotion). Since there's no docs on the genymotion recovery mode I can't find the commands to flash the zip, but I'm pretty sure they exist.
Which commands can be used for flashing a .zip from the terminal?
The commands can also be run in the machine that's holding the genymotion.
Genymotion VMs contain some special scripts that interface with their launcher and skin controls. The one that you need is /system/bin/flash-archive.sh which is what gets run when you drag & drop a .zip archive.
You can run flash-archive.sh directly using ADB or from a process within the VM. So if you have the zip in /sdcard/Download/gapps.zip, you can run the following command from the host machine:
adb shell flash-archive.sh /sdcard/Download/gapps.zip
adb reboot
Don't forget to install the ARM translation package first, if applicable. It can be done using the same sequence.
Paul's answer is good.
Also, we will soon release features related to continuous integration and automation. A command line tool will be included on these features. It allows you to do all what you can do with your mouse, but through the command line. It will be available to paid licenses.
You can find a demo we did at Droidcon Paris here.
i rooted my android device then i go to adb shell, then type su to enter wpa_cli. i surprise that this appeared : wpa_cli: not found although i get information when i type : wpa_supplicant?
i know that wpa_cli from same library wpa_supplicant?
from this link
android is linux based!! so why these commands can't be found in their kernel ?
Because wpa_supplicant is not a library, it's an executable. Brief introduction is here: http://en.wikipedia.org/wiki/Wpa_supplicant and source code is here: https://github.com/android/platform_external_wpa_supplicant
Yes, wpa_cli is built from the same code base, but is not included on most phones. Android uses the wpa_crl.c/wpa_ctrl.h interface, not the command line utility wpa_cli.
The kernel doesn't contain commands and executables invoked through a shell.
First of all, I believe, it's not a duplicate question. I don't want to write a native app with NDK, I just want to use Android device as a cheap Linux server. Server, in this context, means a program, which has no UI. Also, the server is written in bare C++, but uses no libraries at all, so that's why should that question differ from others.
The story
We've written a small server for Linux, it has a webserver interface, so you connect to it with a vanilla browser, and you can play with it. We've compiled it to Linux/x86, Linux/ARM (GuruPlug), Linux/PPC (some kind of NAS), and Mac OS X Darwin platforms.
The Linux/ARM version also runs well on my Palm Pré smartphone. I've just copied the executable onto my phone (in webOS scene, there's no such thing like jailbreak, there's an official "developer mode", which if you activate by typing a secret key combination, you can log in to your phone with ssh or use local ssh app). So, our small server program (daemon, may say) is running on even the smallest Linux devices. (It's funny, when connect with your giga-powered desktop machine's browser to a smartphone server.)
The server program is designed to run on even the smallest Linux (as I said, it runs on NAS, router, smartphone), it requires only STDLIB and PTHREADS.
The question
What't the straight way to get that simple server program run on an Android device?
We have no Android device yet. But I assume, any ARM-based one will do. The server's memory footprint is so small, that it will be no problem.
I assume, the device must be rooted to copy executable to it and run.
I don't want to install a whole new Linux on the device. It should keep running Android, while our server works in the background. The Linux distribution which enough for Dalvik, is enough for our server, I'm pretty sure.
The server should use no external things (USB, touchscreen, audio, camera, mic - thanks, not) only a port for webserver (e.g. 8080), which is not allocated by Android.
I have ARM GCC toolchain, the installation of it is not the part of the question (except if there're tricks).
The installation of the program should be manual (scp, whatever). Also, I don't want to make a package or any automated deployment.
The problem of the launching of the server program is another question, we'd ignore now.
So, I want just do the same thing with an Android device (phone, tablet), just as I did on my webOS device: copy the server program and run on it. Computers are for that, running programs, aren't they? ;)
I have not really tried it, but it should be possible to use the ARM GCC compiler you have, or the one provided by the Android NDK to compile native application, the same as you would use it on your desktop.
If your application is small (not too many files), you can manage the compilation by hand (or in a simple Makefile). The following commands are from the LuaJIT compilation guide for Android:
/tmp$ cat test.c
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}
/tmp$ NDK=/opt/ndk
/tmp$ NDKABI=8
/tmp$ NDKVER=$NDK/toolchains/arm-linux-androideabi-4.4.3
/tmp$ NDKP=$NDKVER/prebuilt/darwin-x86/bin/arm-linux-androideabi-
/tmp$ NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
/tmp$ ${NDKP}gcc $NDKF -o test test.c
/tmp$ file test
test: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
Obviously, use linux-x86 instead of darwin-x86 if you are on Linux (not Mac OS X, also not sure about Windows), and change the path to NDK to where you installed it.
Now you have to move the compiled binary somewhere to your Android device, and run adb shell to see if it works:
/tmp$ ADB=/opt/sdk/platform-tools/adb
/tmp$ $ADB push test /data/
332 KB/s (3343 bytes in 0.009s)
/tmp$ $ADB shell
# /data/test
Hello world!
You definitely need a rooted android device.
I recommend that you install busybox to get a bunch of nice command line tools such as wget, tar, gzip and many more.
You can get shell access to your device by using adb shell and then su to get root access. You can either use adb push or wget to put your server on the device.
The /system partition is mounted as read only and depending on the manufacturer there are a lot of protections that restrict you from writing there so you should copy your server somewhere on the /data partition (e.g. mkdir /data/myserver). After this, everything should be pretty straight forward.
Perhaps the question is more a sysadmin issue (how to install your executable on your Android device) than a developer issue (how to cross compile a C program for Android)?
I have a chroot partition with my android galaxy phone. It is arm with floating point processor, so all kinds of compilers work. Warning to you: the busybox/android distro utils don't run as GNU software. Their tar have problem unpacking the first thing I tried. POSIX tar not supported. Their zip have problem with some field 1 or 8. Their mount works like somthing from space. Their partition itself that you will want to have software put on does not support sym link. After a few weeks working on the chroot partition, I start to feel that the whole android is just a new underlying BIOS, with lots of firmware.