Search code examples
androidmakefilev4l2

Cross Compiling v4l2-ctl for Android


I've got a usb camera working on android (via Android On-The-Go), and I'm looking to change the exposure of the camera. I've been able to get this to work by using v4l2-ctl on a linux machine, and I'm hoping to do the same on my Android device.

The install file mentions the following:

Android Cross Compiling and Installing:
----------------

v4l-utils will only build using the complete AOSP source tree, because of the
stlport dependency.

List of v4l-utils that supply an Android.mk makefile:
* utils/v4l2-compliance
* utils/v4l2-ctl
* utils/v4l2-dbg

To cross compile an utility you must first configure the shell with Android's
envsetup.sh to add the mm alias, before running lunch to select your target
device.

cd /path/to/aosp
source build/envsetup.sh
lunch
cd /path/to/v4l-utils
cd <utility>
mm

So I downloaded the android source, ran the first two commands and lunch successfully. I then cd'd into v4l-utils/v4l2-ctl and ran mm. I got the following error:

make: *** No rule to make target `out/target/product/generic/obj/lib/crtbegin_dynamic.o', needed by `out/target/product/generic/obj/EXECUTABLES/v4l2-ctl_intermediates/LINKED/v4l2-ctl'.  Stop.

What can I try to fix this?

Note: Normal compilation works: I can make all of v4l2 with ./bootstrap.sh, ./configure, and then make.


Solution

  • I've figured out how to do it! I found that the instructions worked great, except for these two points:

    Download and Build the Entire Android Source

    • Before doing anything, you need to download and make the full Android source. This means setting up your environment, downloading it, and then building it.
    • Make sure that you're downloading the correct version of the Android source (that is, the version that's running on your phone).
    • For a faster download, run repo-sync with -c, for the current branch only
    • I suggest getting a large hourly billed server and running it on there. The network connection will be better, and the machine is probably better than your own. I got an 8 core, 16GB machine on DigitalOcean.
    • When running lunch, I just chose the first option: aosp_arm-eng

    Set the TOP Variable

    • When doing the mm step, you'll get an error saying Couldn't locate the top of the tree. Try setting TOP. So run export TOP=/location/of/android/source