This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compiling Tinkerboard's Android
#1
Rainbow 
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  Wink
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/how-do-i-set-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.
1, download repo.
"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

repo might ask you to confirm your name and email address. please do so. it should then tell you success. Your directory will still appear empty, but there is a .repo folder there with some info.

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:
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
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 Smile

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
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:
Code:
cd {croot}
source build/envsetup.sh
lunch rk3288-userdebug
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.

  1. Compiling the kernel. (~8 minutes at -j8)
    Code:
    cd {croot}/kernel
    make ARCH=arm rockchip_defconfig
    make ARCH=arm rk3288-miniarm.img -j8
  2. Compiling u-boot (-1.5 minutes at -j8)
    Code:
    cd {croot}/u-boot
    make rk3288_secure_defconfig
    make -j8
  3. Compiling system image (~50 minutes at -j28)
    Code:
    cd {croot}
    make -j28 > buildlog.log 2>&1 &
Note about step 3: "> buildlog.log 2>&1 &" pipes all output to a file, buildlog.log, and puts the process in the background. This unblocks your shell and ensures you have a log of the build. If you do not do this, you will likely lose build information as it throws a lot of data at the screen. also note that it takes 50 minutes at -j28 for a fresh build. be prepared to wait hours for this to complete.

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.

Now, you'll need a windows machine (sorry). find a way to get the following files over to that windows machine:
{croot}/RKDocs/android_SOP_eng_7.1.2.docx
{croot}/RKTools/linux/Linux_Pack_Firmware/rockdev/update.img

now, on windows, open the android_SOP_eng_7.1.2.docx document. There should be an attached file you can access by double clicking on  the SpiImageTools_v1.36.7z. unzip that and throw it on your desktop in a folder.
  1. Run the program inside! yes. it's in chinese. If you don't read Chinese, that's okay.
  2. Just click the top button. it'll pop open a file select dialog, select your update.img you brought over.
  3. Now click the bottom button and watch the blue progress bar ping-pong for a while. This can take a while (10+ minutes sometimes).
  4. 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.
  5. Grab data.bin.
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.

  1. Open etcher.
  2. Click "Select Image". It'll warn you it's not bootable. that's okay, Continue.
  3. Select your flashing device. You can flash an SD card or the Tinkerboard S directly if you're using one.
  4. Click flash and wait for it to complete.
All done, you now should be able to boot into android on your device! If you really want some fun, to into Settings->About Device and look at the kernel version. It'll have your build machine's name in the description! Show it to all of your friends so they think you understand the kernel when you're secretly scared of touching it.

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.
[-] The following 4 users Like kbungo's post:
  • Bala Krishna Ragala, Leskriim, lobo, Tinker Board
Reply
#2
thank you very much it's perfect for me! can we do it with the ubuntu version of the tinkerboard?
 I'm french

Reply
#3
Thank you for sharing you experience with the forum. 
(09-12-2018, 07:27 PM)kbungo Wrote: Compiling system image (~50 minutes at -j28)


AFAIK the -j is related to how many jobs a computer can take. Suppose to have a I7 CPU, there could be 8 threads available . I suspect that the PC can't do more at once and it may cause unresponsiveness to the system. Unless we use to share the compilation load by distcc Wink
Reply
#4
@kbungo: Thank you for your guide!
I faced some error when I try to download with your command:
Code:
repo init -u https://bitbucket.org/TinkerBoard_Android/manifest.git -b /sbc/tinkerboard/asus/Android-7.1.2
...
curl: (22) The requested URL returned error: 404 Not Found
Server does not provide clone.bundle; ignoring.
fatal: Invalid refspec '+refs/heads//sbc/tinkerboard/asus/Android-7.1.2:refs/remotes/origin//sbc/tinkerboard/asus/Android-7.1.2'
fatal: Invalid refspec '+refs/heads//sbc/tinkerboard/asus/Android-7.1.2:refs/remotes/origin//sbc/tinkerboard/asus/Android-7.1.2'
fatal: cannot obtain manifest https://bitbucket.org/TinkerBoard_Android/manifest.git

But with this command it was working:
Code:
repo init -u https://git@bitbucket.org/TinkerBoard_Android/manifest.git -b sbc/tinkerboard/asus/Android-7.1.2
...
remote: Counting objects: 532, done.        
remote: Compressing objects: 100% (198/198), done.        
remote: Total 532 (delta 338), reused 459 (delta 313)        
Receiving objects: 100% (532/532), 383.41 KiB | 0 bytes/s, done.
Resolving deltas: 100% (338/338), done.
From https://bitbucket.org/TinkerBoard_Android/manifest
 * [new branch]      sbc/tinkerboard/asus/Android-6.0.1 -> origin/sbc/tinkerboard/asus/Android-6.0.1
 * [new branch]      sbc/tinkerboard/asus/Android-7.1.2 -> origin/sbc/tinkerboard/asus/Android-7.1.2
repo has been initialized in /home/joerg/Development/tinker/Nougat
Reply
#5
(09-13-2018, 07:00 AM)Leskriim Wrote: thank you very much it's perfect for me! can we do it with the ubuntu version of the tinkerboard?

Sadly I do not have experience with the Ubuntu code or their linux release for tinkerboard.  Sad   or else I would

(09-13-2018, 07:04 AM)Im4Tinker Wrote: Thank you for sharing you experience with the forum. 
(09-12-2018, 07:27 PM)kbungo Wrote: Compiling system image (~50 minutes at -j28)


AFAIK the -j is related to how many jobs a computer can take. Suppose to have a I7 CPU, there could be 8 threads available . I suspect that the PC can't do more at once and it may cause unresponsiveness to the system. Unless we use to share the compilation load by distcc Wink

That is correct. that is why at the beginning of that section (Section 4), in paragraph two, i make a note that i run with very high j and that you shouldn't. Wink

Section 4, paragraph two for reference:
kbungo Wrote: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.

(09-13-2018, 05:38 PM)lobo Wrote: @kbungo: Thank you for your guide!
I faced some error when I try to download with your command:
Code:
repo init -u https://bitbucket.org/TinkerBoard_Android/manifest.git -b /sbc/tinkerboard/asus/Android-7.1.2
...
curl: (22) The requested URL returned error: 404 Not Found
Server does not provide clone.bundle; ignoring.
fatal: Invalid refspec '+refs/heads//sbc/tinkerboard/asus/Android-7.1.2:refs/remotes/origin//sbc/tinkerboard/asus/Android-7.1.2'
fatal: Invalid refspec '+refs/heads//sbc/tinkerboard/asus/Android-7.1.2:refs/remotes/origin//sbc/tinkerboard/asus/Android-7.1.2'
fatal: cannot obtain manifest https://bitbucket.org/TinkerBoard_Android/manifest.git

But with this command it was working:
Code:
repo init -u https://git@bitbucket.org/TinkerBoard_Android/manifest.git -b sbc/tinkerboard/asus/Android-7.1.2
...
remote: Counting objects: 532, done.        
remote: Compressing objects: 100% (198/198), done.        
remote: Total 532 (delta 338), reused 459 (delta 313)        
Receiving objects: 100% (532/532), 383.41 KiB | 0 bytes/s, done.
Resolving deltas: 100% (338/338), done.
From https://bitbucket.org/TinkerBoard_Android/manifest
 * [new branch]      sbc/tinkerboard/asus/Android-6.0.1 -> origin/sbc/tinkerboard/asus/Android-6.0.1
 * [new branch]      sbc/tinkerboard/asus/Android-7.1.2 -> origin/sbc/tinkerboard/asus/Android-7.1.2
repo has been initialized in /home/joerg/Development/tinker/Nougat

Awesome, I'll add a note! I probably have some crazy configuration that lets me not include that. I've added a note in that section, paraphrasing what you've stated. Please let me know if you are unhappy with my rewrite. It includes a link to your comment for people to see the exact issue Smile
[-] The following 1 user Likes kbungo's post:
  • Im4Tinker
Reply
#6
Anyone can share where we can get the SpiImage_tools? I can not open it in docx (it deals like an attached picture, not 7z format) -Sad
Reply
#7
Where do you want to be answered ?
You've already asked in another post.
Reply
#8
Hi all,
the SpiImageTool can be downloaded here:
Code:
git clone https://github.com/rockchip-linux/tools.git
Alternativly you can go to the web page and download id by the 'Clone or download' button.

Btw., I was able to start the prog on my linux pc with PlayOnLinux.


Also I did an OTA package and installed it as update.zip to /data/media/0. This way the windows prog is not needed, but a working Android.

Code:
adb root
adb push out/target/product/rk3288/rk3288-ota-eng.xxxxx.zip /data/media/0/update.zip

But with the fresh install and also with the OTA update, I get this message on the start screen: "There's an internal problem with your device. Contact your manufacturer for details.". I don't have this with the image provided from Asus.
   
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)