Building Android for VIM3 according to directions

Hello all, I am trying to learn how to build android for VIM3 and I am a beginner.
I am following the directions here and moveing step by step down the list.

I have found that several prerequisites are needed that are not mentioned.
I installed repo and git that are not mentioned for instance…
I found an alternate method to install git-lfs
So here is where I am running into more problems that I need help with:

Download the andoid source code…
we are supplied this command:
repo init -u https://github.com/khadas/android_manifest.git -b khadas-vims-pie

but it fails like so:
dale@UB18:~$ repo init -u https://github.com/khadas/android_manifest.git -b khadas-vims-pie
File “/home/dale/.repo/repo/main.py”, line 79
file=sys.stderr)
^
SyntaxError: invalid syntax

Can anyone assist please :slight_smile:

I found a way past this error by switching to python3 with these two commands:

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python3 /usr/bin/python

The below info is left here for examination only, it did not work:

The following are prerequisites needed to complete the objective to download the source code for android under Ubuntu 18.04

Package “git”
followed with config
Package “git-lfs”
Package “repo”
followed by change of default python to python3

  1. sudo apt update
  2. sudo apt install git
    2a) git config --global user.name “Your Name”
    2b) git config --global user.email “youremail@domain.com
  3. wget https://packagecloud.io/github/git-lfs/packages/ubuntu/bionic/git-lfs_2.13.2_amd64.deb/download.deb -O git-lfs_2.13.2_amd64.deb
    3a) sudo dpkg -i git-lfs_2.13.2_amd64.deb
    3b) git lfs install
  4. sudo apt install repo
  5. sudo rm /usr/bin/python
  6. sudo ln -s /usr/bin/python3 /usr/bin/python

From this point “repo init” followed up with “repo sync” commands should work.

EDIT: it appears some of the prerequisites are not complete somehow as the U-Boot components failed to repo sync
The above steps do not work.

3 Likes

Super! Great job !!!
:+1::+1::+1:

I am getting there lol
I am sure other newbies will run into this too :slight_smile:

1 Like

I seem to have found something else that is missing.
when I go to build the UBOOT it failed on the .mk command
here is a cut paste from the building android source code khadas vim3 wiki

Building

Note: Before you start to build, make sure you have done all the Preparations listed above.

Build U-Boot:

$ cd PATH_YOUR_PROJECT
$ cd bootloader/uboot
$ ./mk TARGET

But my result is simply this:

dale@UB18:~/WORKING_DIRECTORY/bootloader/uboot$ ./mk kvim3
bash: ./mk: No such file or directory

@JustSumDad I suspect it was caused by an error in the synchronization process. Please execute the synchronization code command again to confirm that there is no error in the process.

repo sync -c 

Saying “other newbies” implies that you are a newbie. Whether you are a newbie or not, only you can truly know. However, I feel it only fair to inform you, that if you are successful in completing this task, you will be putting your newbie status in extreme jeopardy. :grin:

2 Likes

Thank you for the suggestion but sadly it did not go…

Checking out projects: 100% (951/951), done.
repo sync has finished successfully.
dale@UB18:~/WORKING_DIRECTORY/bootloader/uboot$ ./mk kvim3
bash: ./mk: No such file or directory

I don’t think synchronization code is OK just by looking at it here. You need to search the “error” character to see the confirmation.
In addition, you can use the following command to see if there is any problem with your uboot synchronization:

cd bootloader/uboot
git branch
git status
git log

Feedback the above command results.

I think I found the problem, the bootloader/uboot folders did not exist until I mkdir them myself, so they are empty. I thought this was simply a workspace that would be used with process’s yet to come.

I think this may be due to my manually performing the prerequisites. I found a command that appears to resolve all the prerequisites in one shot. I am going to test this on a fresh Ubuntu load now. Found at https://source.android.com/setup/build/initializing

$ sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g+±multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig

NEW THINKING-tested working (ANDY9 compiles at least)

  1. sudo apt update
  2. sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g+±multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig

2a) git config --global user.name “Your Name”
2b) git config --global user.email “youremail@domain.com

  1. sudo apt install git-lfs
  2. sudo apt install repo
    ---- Steps 5 and 6 force the use of python3 -this may affect use of python on other projects.
  3. sudo rm /usr/bin/python
  4. sudo ln -s /usr/bin/python3 /usr/bin/python

next install toolchains as per Khadas wiki

From this point “repo init” followed up with “repo sync” commands should work.

TESTED: Able to build U-Boot and build Android source code as per Khadas Wiki

1 Like

a few days straight of learning and I have somewhat of a handle on this :slight_smile:
I now have two machines compiling at the same time, one doing Andy9 as a learning experience and one doing Andy11 because wtf…

Question tho, by default, Android is built with the 4.19 kernel and I see that 5.4 is an option. Likely there are other versions as well…
Are there advantages and or disadvantages to these different versions and for a tablet build that will do minimal if any media work what would be suggested?
my goal is a tablet build that will be used primarily as a CARPC so navigation and music over bluetooth are my main goals.

Thanx

2 Likes

@RDFTKV
I officially withdraw my newbie status and move firmly into the beginner plus category.
I have worked out all the packages needed to repo sync and compile under Ubuntu 20.04 and have a compile operation of the VIM3 Android 11 AOSP going right now :slight_smile:

Now all I have to work out when its done is how to flash it to the VIM3 :slight_smile:

1 Like

Ubuntu 20.04 prep steps: I had an abundance of issues until I did sudo for almost everything.

Sudo apt update
sudo apt upgrade
sudo apt install openssh-server screen python git openjdk-8-jdk android-tools-adb bc bison
build-essential curl flex g+±multilib gcc-multilib gnupg gperf imagemagick lib32ncurses-dev
lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev
libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc yasm zip zlib1g-dev
libtinfo5 libncurses5

sudo snap install git-repo
sudo wget ‘https://storage.googleapis.com/git-repo-downloads/repo’ -P /usr/local/sbin/
sudo chmod +x /usr/local/sbin/repo
sudo apt install git-lfs
sudo git config --global user.email “youremail@domain.com”
sudo git config --global user.name “Your Name”

  • Prerequisites done - now to sync repo

mkdir -p “workspace name of your choice”
cd “whatever named folder you did above”
sudo repo init -u platform/manifest - Git at Google -b master
sudo repo sync -j3

Android Build Env instructions : (no sudo on these steps)

. ./build/envsetup.sh
lunch yukawa-userdebug
make TARGET_USE_TABLET_LAUNCHER=true TARGET_VIM3=true TARGET_KERNEL_USE=5.4 -j3

Notes:
I only use -j3 as my cpu is a four core i5 desktop CPU and I want to keep one core free.
If your CPU has more cores or HT by all means increase -jxx to suit. On my i9 at work I would do -j18
I suggest more than 16gb ram, I had 16 and it was complaining but I had some spare 4gb sticks so I expanded to 24Gb if you have a bunch more threads to process with you may need more than that.

build completed successfully (05:17:36 (hh:mm:ss))

I have also found that the flashing instructions on the BayLibre Github page do not work under Ubuntu 20.04 unless you do a sudo -s first

2 Likes

@goenjoy
Can you (or anyone else) help me with a few things please:

  1. in building the AOSP do I need to build the kernel separately?
    I ask this one because it appears as I follow the directions I repo sync -> Build AOSP -> Flash Android Boot-loader-> Flash Android Images -> Build Kernel Source -> rebuild and flash your board…???

It seams strange to me that I have to build the kernel and flash it in AFTER the other steps??
it seems like I should build the kernel before the flash, not after and then flash again??

  1. The toolchains outlined in the instructions @ Install Extra Toolchains For The Amlogic Platform | Khadas Documentation
    Are these required for the Android 11 AOSP ?

  2. in building the kernel I am running into errors:
    ale@ShopUB20:~/workspace-andy11/hikey-linaro$ export PATH=workspace-andy11/prebuilts/clang/host/linux-x86/clang-r399163b/bin:$PATH
    dale@ShopUB20:~/workspace-andy11/hikey-linaro$ export PATH=workspace-andy11/prebuilts/gas/linux-x86:$PATH
    dale@ShopUB20:~/workspace-andy11/hikey-linaro$ export PATH=workspace-andy11/prebuilts/misc/linux-x86/lz4:$PATH
    dale@ShopUB20:~/workspace-andy11/hikey-linaro$ export ARCH=arm64
    dale@ShopUB20:~/workspace-andy11/hikey-linaro$ export CROSS_COMPILE=aarch64-linux-gnu-
    dale@ShopUB20:~/workspace-andy11/hikey-linaro$ export LLVM=1
    dale@ShopUB20:~/workspace-andy11/hikey-linaro$ sudo make meson_defconfig


*** Can’t find default configuration “arch/x86/configs/meson_defconfig”!


make[1]: *** [scripts/kconfig/Makefile:90: meson_defconfig] Error 1
make: *** [Makefile:591: meson_defconfig] Error 2
dale@ShopUB20:~/workspace-andy11/hikey-linaro$

I tried to flash the android image into the VIM3 and ran into a non bootable device.

Thanx

@jasonl Please help with this compilation error.

1 Like

In most cases you shouldn’t need to compile the kernel separately, although this does seem to be the case of android R (11.x) the practice of pre building the kernel image, at least from what I’ve seen. If the rom you are building is pie based and the rom isn’t able to compile properly, you might be missing a prerequisite for building the kernel.

@JustSumDad for android 11 aosp ,
1 : building the AOSP do not need to build the kernel separately ,under device/amlogic/yukawa-kernel directory has kernel image
2 : no need to install toolchains outlined in the instructions
3 : export AOSP_TOPDIR=/home/lxx/Downloads/android_pie/vim3l
export PATH=${AOSP_TOPDIR}/prebuilts/clang/host/linux-x86/clang-r399163b/bin:$PATH
export PATH=${AOSP_TOPDIR}/prebuilts/gas/linux-x86:$PATH
export PATH=${AOSP_TOPDIR}/prebuilts/misc/linux-x86/lz4:$PATH
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
export LLVM=1
make meson_defconfig
make DTC_FLAGS="-@" -j10
these is my kernel build steps ,you can reference
only according to the docs Khadas_VIM3 · Wiki · BayLibre / amlogic / Android TV / aosp / device / amlogic / yukawa · GitLab

2 Likes

The link you have provided for reference is the one I am following. I the only error I can decern is the setting of the variable APSP_TOPDIR=
I believe I should use:
export AOSP_TOPDIR=workspace-andy11

but it still did not work:

dale@ShopUB20:~$ export AOSP_TOPDIR=workspace-andy11
dale@ShopUB20:~$ cd ${AOSP_TOPDIR}
dale@ShopUB20:~/workspace-andy11$ export PATH=${AOSP_TOPDIR}/prebuilts/clang/host/linux-x86/clang-r399163b/bin:$PATH
dale@ShopUB20:~/workspace-andy11$ export PATH=${AOSP_TOPDIR}/prebuilts/gas/linux-x86:$PATH
dale@ShopUB20:~/workspace-andy11$ export PATH=${AOSP_TOPDIR}/prebuilts/misc/linux-x86/lz4:$PATH
dale@ShopUB20:~/workspace-andy11$ export ARCH=arm64
dale@ShopUB20:~/workspace-andy11$ export CROSS_COMPILE=aarch64-linux-gnu-
dale@ShopUB20:~/workspace-andy11$ export LLVM=1
dale@ShopUB20:~/workspace-andy11$ cd hikey-linaro
dale@ShopUB20:~/workspace-andy11/hikey-linaro$ make meson_defconfig
mkdir: cannot create directory ‘.tmp_2347’: Permission denied
mkdir: cannot create directory ‘.tmp_2349’: Permission denied
mkdir: cannot create directory ‘.tmp_2351’: Permission denied
mkdir: cannot create directory ‘.tmp_2353’: Permission denied
mkdir: cannot create directory ‘.tmp_2355’: Permission denied
mkdir: cannot create directory ‘.tmp_2357’: Permission denied
mkdir: cannot create directory ‘.tmp_2359’: Permission denied
HOSTCC scripts/basic/fixdep
/bin/sh: 1: clang: not found
make[1]: *** [scripts/Makefile.host:107: scripts/basic/fixdep] Error 127
make: *** [Makefile:524: scripts_basic] Error 2
dale@ShopUB20:~/workspace-andy11/hikey-linaro$ sudo make meson_defconfig


*** Can’t find default configuration “arch/x86/configs/meson_defconfig”!


make[1]: *** [scripts/kconfig/Makefile:90: meson_defconfig] Error 1
make: *** [Makefile:591: meson_defconfig] Error 2