Custom Android Build - What I wish I would have known

I recently acquired a VIM4 and some supporting accessories to replace a tablet I installed in my car several years back. I wanted to switch to a more modern device that might afford me better capabilities than a tablet that was impossible to keep charged (I did not drive the vehicle enough)

Getting the VIM to work well in an automotive setting meant I would need to change the Android image to enable a secondary logic board to help manage its power. While I have plenty of experience with Linux and as an Android user, I’ve never tried building a custom Android ROM. It was a little more complicated than the old “configure, make, make image.”

This post contains the notes I took during this journey. I’m leaving them here in the hope that they may help another person get started with a custom rom on the VIM4. Note, I am running all of this from a Debian 12 (Bookworm).

Preparing for the Build

  • Make sure you have a ton of disk space in your build root. I have a filesystem dedicated to this, and it’s sitting at 95% of 480GB after a successful build.
  • Khadas Docs: VIM4 Build Android [Khadas Docs]
    • Build out the prerequisites in the AOSP documentation. Don’t bother downloading the source tree from the AOSP project; you will be pulling the Android source from Khadas instead (see next document).
    • You will download Android as part of the VIM4 Build Android [Khadas Docs] document. However, there are a couple of gotcha’s I ran into.
      • This may have been my fault, but I did need to pull large files from git (git lfs pull) in two different locations:
        • ${PROJECT_ROOT}/device/khadas
        • ${PROJECT_ROOT}/common
    • I had to install these supporting packages as part of the process. Note that there may be more; read the docs!
      • android-tools-adb git-core gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig repo openjdk-17-jdk automake make git gperf zip dos2unix bison perl gcc g++ tig pkg-config cpp-aarch64-linux-gnu libssl-dev gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu libncurses5 libncurses5-dev minicom

The Build

  1. I highly recommend using the “” script from the VIM4 Build Android [Khadas Docs] document.
  2. As I am cross-compiling, I had to set compiler flags for the Android build. Oddly enough, I did not need it for the u-boot or kernel builds (the flags caused build failures for u-boot or the kernel, but I don’t recall which). Next build, I’ll move these into the to make my life easier
    1. export CROSS_COMPILE=aarch64-linux-gnu-
    2. export ARCH=arm64

Burning the ROM

This part was the trickiest for me to figure out. I had hoped that Oowow would allow me to burn the image, but after a couple of hours of playing around, I threw in the towel and hit the documentation again. Alas, while I found documentation, I still needed to figure out how I was to proceed.

The “VIM4 Boot into Upgrade Mode” document noted a method for burning the ROM in serial mode. So I gave it a try, but it ultimately failed (or I missed a step). Then I came across a post in the forums (Flashing Methods). This post showed that the best way to flash the image was to use the “burn-tool” after placing the board in “upgrade mode.”

One note on the burn-tool, Khadas only supports Ubuntu. I had to modify the install script to make it function on Debian, but once installed it seems to be working ok.

I hope someone might find this helpful. Cheers!


hi rpkish,
(1) To build the VIMs SDK source code, you need to install the extra toolchains for cross-compiling.
(2) try the follow cmd to pull large files.
repo forall -c ‘git lfs pull’
(3) you can install OS into eMMC via USB Flash Tool
(4)Recommend using the Ubuntu operating system for compilation.