
Hello everyone!
The information on how to compile Tinkerboard's Android source code seems to be scattered across some WIKI pages and many other sources, so I figured I would compose a guide here as well as provide a place where people can ask questions and post their compilation errors.
I will skip the introductions and fun and get straight to the instructions
DISCLAIMER: I am not associated with ASUS.
Preparation:
"repo" is a tool created by google to handle the downloading/updating/uploading of the massive number of git repositories that compose Android. repo uses a manifest to instruct it on things like what remote to use, what branch to look at and even what exact commit to checkout. It is very powerful and is a great way to manage a large number of projects that are all inter-connected.
My instructions are basically stolen from Google's repo install Instructions, with minor adjustments:
Open a terminal and execute:
ensure that /usr/bin is in your $PATH. if it is not, add it
2, prepare your working directory.
Great, so now choose somewhere you want to put the source. I put my source in /home/kbungo/projects/firmware/asus/android-7.1.2/, which I will now refer to as {croot}. You can put it wherever you like, just make sure it's a reasonable permission space (do not choose / it probably won't be fun.)
go to {croot}, and execute the following:
in this example, I have selected: Android 7, current release. -b is for branch, as you can see in the linked repo. -m is for what manifest file to use, which defaults to default.xml. you have options though! here are the approximate commands for different things you may want to be making.
a couple CURL failures to obtain some sort of bundle are completely normal.
One user, lobo, provides a fix I have paraphrased below. Click the green arrow on this quote to see the full comment.

3, Downloading source or Updating existing source.
this is simple. if you already have the source, downloading from new and updating existing source is the same.
repo sync is the command.
-j4 specifies 4 download tasks at a time. I took down a corporate network running -j8 so please be careful.
-c specifices "do not sync other branches." if i am looking for the 6.0 source code, do not also get the branch information for Android 7. This keeps the git info cleaner and speeds the sync up a little.
-q is quiet... otherwise you'll get your console window destroyed with output and it's really hard to tell what your progress is.
This is a slow process. When doing a new project, i usually let it run over the weekend or overnight. It will take many hours depending on your internet speed. be patient. If it keeps failing, try -j1 so you can see what project is failing and we can troubleshoot from there.
Instructions from here forward are for Android-7.1.2. There are slightly different compile commands for u-boot and kernel for Android-6.0.1. To be certain, these commands are taken from {croot}/RKDocs/, where you can find an SOP document (hopefully). If it's desired I do a guide on Android 6, i will do that as well in the future.
4, Compiling source
congratulations, you have the Tinkerboard Source Code! you are ready to compile. There are three primary things you need to compile, the kernel, u-boot, system image. Lets talk about that.
In this section, all -j flags should be decided based on the number of cores you have on your build machine. If you have a user laptop instead of a server, please decide accordingly. I use VERY HIGH -j values when compiling because I compile on a professional server dedicated to firmware work... it has something like 32 cores I can play with.
Before you do anything with source code, you should ALWAYS do the following:
this adds some handy tools to your arsenal. you can find more on those elsewhere, mostly it adds some environment variables and initializes some stuff.
A lot of people start getting failures at this point. That's okay, don't be discouraged! just ask.
5, Building a single image.
So we've got a kernel, u-boot, and a system image... what now?
Easy. You now have a file, {croot}/RKTools/linux/Linux_Pack_Firmware/rockdev/update.img. This is almost your flashable image! you're really close, i promise.
On windows, please go to the following link and download the SPI Image Tool, place it in a folder on your desktop or somewhere you can easily find it.
Thank you again to lobo for providing an easier source for the SpiImagetool!
6, Flashing the image.
For the sake of cross-platform instructions, I will not be using win32diskimager as the instructions suggest. I will use etcher. You can use whatever you want to flash data.bin onto the image.
Happy Tinkering!
Advice from experience:
The information on how to compile Tinkerboard's Android source code seems to be scattered across some WIKI pages and many other sources, so I figured I would compose a guide here as well as provide a place where people can ask questions and post their compilation errors.
I will skip the introductions and fun and get straight to the instructions

DISCLAIMER: I am not associated with ASUS.
Preparation:
- You will need an Ubuntu machine. Google still reccomends Ubuntu 14 and Ubuntu 16, but I am using Ubuntu 18 and it seems fine (with some minor bugs).
- Install openjdk-8
Code:sudo apt-get install openjdk-8-jdk
- Install various other packages
Code:sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip
- You will want to setup CCACHE. trust me, it's worth it it can take 50 minute builds down to 20 minute builds. See here: https://askubuntu.com/questions/470545/h...-up-ccache
- Be aware, that compiling Android is a place where you want to be generous with your disk space. you should be prepared to download 60+GB of source code ALONE, and you should expect that to increase by an additional 50% when you include compiled files. All said and done I would recommend a minimum of 100GB of space with ccache, compiled code, source code all considered. You can definitely get away with less than this, but you should have plenty of room prepared.
"repo" is a tool created by google to handle the downloading/updating/uploading of the massive number of git repositories that compose Android. repo uses a manifest to instruct it on things like what remote to use, what branch to look at and even what exact commit to checkout. It is very powerful and is a great way to manage a large number of projects that are all inter-connected.
My instructions are basically stolen from Google's repo install Instructions, with minor adjustments:
Open a terminal and execute:
Code:
curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo
chmod a+x /usr/bin/repo
ensure that /usr/bin is in your $PATH. if it is not, add it
Code:
export PATH=$PATH:/usr/bin
2, prepare your working directory.
Great, so now choose somewhere you want to put the source. I put my source in /home/kbungo/projects/firmware/asus/android-7.1.2/, which I will now refer to as {croot}. You can put it wherever you like, just make sure it's a reasonable permission space (do not choose / it probably won't be fun.)
go to {croot}, and execute the following:
Code:
repo init -u https://bitbucket.org/TinkerBoard_Android/manifest.git -b /sbc/tinkerboard/asus/Android-7.1.2 -m android_20180817_v14.1.2.50.xml
in this example, I have selected: Android 7, current release. -b is for branch, as you can see in the linked repo. -m is for what manifest file to use, which defaults to default.xml. you have options though! here are the approximate commands for different things you may want to be making.
- Android 6, most recent release:
Code:repo init -u https://bitbucket.org/TinkerBoard_Android/manifest.git -b /sbc/tinkerboard/asus/Android-6.0.1 -m android_20180712_v13.14.0.95.xml
- Android 6, development build:
Code:repo init -u https://bitbucket.org/TinkerBoard_Android/manifest.git -b /sbc/tinkerboard/asus/Android-6.0.1
- Android 7, development build:
Code:repo init -u https://bitbucket.org/TinkerBoard_Android/manifest.git -b /sbc/tinkerboard/asus/Android-7.1.2
a couple CURL failures to obtain some sort of bundle are completely normal.
One user, lobo, provides a fix I have paraphrased below. Click the green arrow on this quote to see the full comment.
(09-13-2018, 05:38 PM)lobo Wrote: If you receive an error with initilization, such as the following:This fix should be applicable with all urls provided, just change https://bitbucket.org to https://git@bitbucket.org and you should be good to go
Code:fatal: cannot obtain manifest https://bitbucket.org/TinkerBoard_Android/manifest.git
Please try the following command instead. (The url includes a git user).
Code:repo init -u https://git@bitbucket.org/TinkerBoard_Android/manifest.git -b sbc/tinkerboard/asus/Android-7.1.2

3, Downloading source or Updating existing source.
this is simple. if you already have the source, downloading from new and updating existing source is the same.
Code:
repo sync -j4 -c -q
-j4 specifies 4 download tasks at a time. I took down a corporate network running -j8 so please be careful.
-c specifices "do not sync other branches." if i am looking for the 6.0 source code, do not also get the branch information for Android 7. This keeps the git info cleaner and speeds the sync up a little.
-q is quiet... otherwise you'll get your console window destroyed with output and it's really hard to tell what your progress is.
This is a slow process. When doing a new project, i usually let it run over the weekend or overnight. It will take many hours depending on your internet speed. be patient. If it keeps failing, try -j1 so you can see what project is failing and we can troubleshoot from there.
Instructions from here forward are for Android-7.1.2. There are slightly different compile commands for u-boot and kernel for Android-6.0.1. To be certain, these commands are taken from {croot}/RKDocs/, where you can find an SOP document (hopefully). If it's desired I do a guide on Android 6, i will do that as well in the future.
4, Compiling source
congratulations, you have the Tinkerboard Source Code! you are ready to compile. There are three primary things you need to compile, the kernel, u-boot, system image. Lets talk about that.
In this section, all -j flags should be decided based on the number of cores you have on your build machine. If you have a user laptop instead of a server, please decide accordingly. I use VERY HIGH -j values when compiling because I compile on a professional server dedicated to firmware work... it has something like 32 cores I can play with.
Before you do anything with source code, you should ALWAYS do the following:
Code:
cd {croot}
source build/envsetup.sh
lunch rk3288-userdebug
- Compiling the kernel. (~8 minutes at -j8)
Code:cd {croot}/kernel
make ARCH=arm rockchip_defconfig
make ARCH=arm rk3288-miniarm.img -j8 - Compiling u-boot (-1.5 minutes at -j8)
Code:cd {croot}/u-boot
make rk3288_secure_defconfig
make -j8 - Compiling system image (~50 minutes at -j28)
Code:cd {croot}
make -j28 > buildlog.log 2>&1 &
A lot of people start getting failures at this point. That's okay, don't be discouraged! just ask.
5, Building a single image.
So we've got a kernel, u-boot, and a system image... what now?
Code:
cd {croot}
./mkimage.sh
cd {croot}/RKTools/linux/Linux_Pack_Firmware/rockdev
./collectImages.sh && ./mkupdate.sh
Easy. You now have a file, {croot}/RKTools/linux/Linux_Pack_Firmware/rockdev/update.img. This is almost your flashable image! you're really close, i promise.
On windows, please go to the following link and download the SPI Image Tool, place it in a folder on your desktop or somewhere you can easily find it.
lobo Wrote:https://github.com/rockchip-linux/tools/..._v1.36.zip
- Run the program you just downloaded. yes. it's in chinese. If you don't read Chinese, that's okay.
- Just click the top button. it'll pop open a file select dialog, select your update.img you brought over.
- Now click the bottom button and watch the blue progress bar ping-pong for a while. This can take a while (10+ minutes sometimes).
- Come back when a chinese dialog popups and hit okay. the folder you placed the executable in should now have 3 .img files: boot0.bin, boot1.bin and data.bin.
- Grab data.bin.
Thank you again to lobo for providing an easier source for the SpiImagetool!
6, Flashing the image.
For the sake of cross-platform instructions, I will not be using win32diskimager as the instructions suggest. I will use etcher. You can use whatever you want to flash data.bin onto the image.
- Open etcher.
- Click "Select Image". It'll warn you it's not bootable. that's okay, Continue.
- Select your flashing device. You can flash an SD card or the Tinkerboard S directly if you're using one.
- Click flash and wait for it to complete.
Happy Tinkering!
Advice from experience:
- Things will fail. Things will break. Things will not boot. That's okay. Keep a log of what you changed, and just undo changes until it works again!
- There are 600+ projects in the Android Tinkerboard build. You don't need to know what they all do. You just need to learn the organization and get an idea of where things are.
- android has a special version of sgrep that lets you search all the android source easily. if you're looking for something, find a some characters that seem unique to your problem (some UI text or something) and use sgrep to find it.
- avoid changing the /frameworks projects as much as possible. If you have to, you have to, but that's the core underpinnings of how android works. Some apps may no longer act correctly if you change too much.
- Choose one thing to change at a time and test it like crazy. Don't be afraid to make changes, but always test small changes.
- You do not need to know what you're doing. you need to know what you did. Always remember how to undo your changes.