[Guide] Arch-Linux Building Khadas Source Android 9

Most here build Android with Ubuntu as I build with Arch Linux, and as everyone that uses Arch, its most of the time a pain in the butt because it seems to always use the latest software. Not to mention
you compile most stuff your self (AUR) packages, Anyhow…
If anyone has tried to build Khadas Android 9 Source with Arch Linux, you will most likely
run into 3 errors, Make sure you install uboot-tools as well…

First Error:

FAILED: out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/dtc-lexer.c 
/bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/dtc-lexer.c external/dtc/dtc-lexer.l"
flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.

With this Error, it has to do with FLEX prebuilt… doesnt matter how many times you
change your locales or whatever, this error will not go away. Lucky for us Google gives us the source code.
so CD prebuilts/misc/linux-x86/flex

then extract: flex-2.5.39.tar.gz CD into the extracted archive,
run, ./configure then make
then copy it into the flex prebuilt dir, then rename or delete the old one.
and make sure the new one is renamed using the same name as the old one.

That takes care or Error 1 that you will come across:

as For 2nd ERROR:

FAILED: out/target/product/kvim3/android-info.txt 
/bin/bash -c "(build/make/tools/check_radio_versions.py device/khadas/kvim3/board-info.txt ) && (grep -v '#' device/khadas/kvim3/board-info.txt > out/target/product/kvim3/android-info.txt )"
  File "/home/eliminater74/Aosp-Builds/Builds/KHADAS-2/build/make/tools/check_radio_versions.py", line 56
    print "*** Error opening \"%s.sha1\"; can't verify %s" % (fn, key)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

This is related to python, Arch ships with Python 3 but you need python 2 to compile this,
you can either convert everything over so that it works with python3 or
you can do this:

## PYTHON 2 Enviroment 
virtualenv -p 2 envname
source envname/bin/activate

then start compile again… should work this time.

Next and hopefully last error you will run into is this:

/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[3]: *** [scripts/Makefile.host:110: scripts/dtc/dtc] Error 1
make[2]: *** [/home/eliminater74/Aosp-Builds/Builds/KHADAS-2/common/scripts/Makefile.build:650: scripts/dtc] Error 2
make[2]: *** Waiting for unfinished jobs....
  HOSTCC  scripts/recordmcount
make[1]: *** [/home/eliminater74/Aosp-Builds/Builds/KHADAS-2/common/Makefile:570: scripts] Error 2
make[1]: Leaving directory '/home/eliminater74/Aosp-Builds/Builds/KHADAS-2/out/target/product/kvim3/obj/KERNEL_OBJ'
make: *** [Makefile:152: sub-make] Error 2
make: Leaving directory '/home/eliminater74/Aosp-Builds/Builds/KHADAS-2/common'
[ 50% 36430/71685] target thumb C++: libsimpleperf <= system/extras/simpleperf/cmd_record.cpp
ninja: build stopped: subcommand failed.
19:07:18 ninja failed with: exit status 1

and the fix is covered here: https://forum.khadas.com/t/how-to-fix-yylloc-error-when-building-android-sources-khadas-vims-pie/14719?u=eliminater74

After all 3 errors, you should be able to compile Khadas Android 9 fully without issues… and flash all images… Boots fine.

This Guide is for Arch-Linux Users Only!

My reason for this guide is so the next person doesnt have to go around looking for the answers to each and every error, I pretty much summed it all up in one Post…

So all the hard work of searching is already done… you only need to find this one post to fix all 3…

If you run into any other error with Arch Linux, just post it here and possible fix.

Again, if you run any Destro other then Arch Linux, Then this post is not for you, But your input is always welcomed…

4 Likes

wellcome Arch Linux users :wink:

1 Like