GT-S 5300 kernel recompile - Android Q&A, Help & Troubleshooting

Good morning from Germany!
I would like to recompile my kernel on the gt-s 5300 device, so that i could install / setup some application and modules.
Basically i would like to enable the usb gadget on this android device, as far as i am informed, a kernel recompile is needed.
i have done a few kernel recompiles for linux systems, but never for a android smartphone.
maybe someone could point me to the right path ?
thanks all for your help!
kind regards

no help ?
no help ?
thanks a lot ...

Self-plug.
http://forum.xda-developers.com/showthread.php?t=1748297

thewadegeek said:
Self-plug.
http://forum.xda-developers.com/showthread.php?t=1748297
Click to expand...
Click to collapse
Hello,
Yes I have read your post - and everything worked fine.
My question now is how to get my own module to be compiled?
I have my sourcecode but not sure where to place the module and what references in which Makefile have to be done ..?
Thanks for your help.
Kind regards

Stock GT-5300 kernel built, but won't boot
I've been able to create a zImage from the GT-S5300 open source kernel code, using the bcm21553_cori_04_defconfig as indicated by the accompanying readme file.
However, when I use this kernel to create a boot.img and download using Odin, I get a quick S5300 startup screen, then nothing.
At this point, I'm just trying to build a stock kernel, no modifications. I'm looking for helpful hints on where to find any debug or error messages that will help indicate what is going wrong. I can use Odin to put the prebuilt stock kernel back, and it boots ok once again.
I've compared my boot.img with a stock boot.img (samfirmware sourced), and they are similar in terms of addresses and pagesizes. The ramfs file is also stock, taken from that same stock boot.img. The built kernel is a bit larger than the stock and I'm not sure if I should expect my built kernel to be exactly the same size, or if it's ok for it to be a few KBs different.
Any other parameters or configurations that I might be missing or should check? (And to samsungkid, were there any special steps that you took?)
Thank You!

ric105 said:
I've been able to create a zImage from the GT-S5300 open source kernel code, using the bcm21553_cori_04_defconfig as indicated by the accompanying readme file.
However, when I use this kernel to create a boot.img and download using Odin, I get a quick S5300 startup screen, then nothing.
At this point, I'm just trying to build a stock kernel, no modifications. I'm looking for helpful hints on where to find any debug or error messages that will help indicate what is going wrong. I can use Odin to put the prebuilt stock kernel back, and it boots ok once again.
I've compared my boot.img with a stock boot.img (samfirmware sourced), and they are similar in terms of addresses and pagesizes. The ramfs file is also stock, taken from that same stock boot.img. The built kernel is a bit larger than the stock and I'm not sure if I should expect my built kernel to be exactly the same size, or if it's ok for it to be a few KBs different.
Any other parameters or configurations that I might be missing or should check? (And to samsungkid, were there any special steps that you took?)
Thank You!
Click to expand...
Click to collapse
Thanks for bashing my thread...
Might be better to create your own ?

Will do.
samsungkid said:
Thanks for bashing my thread...
Might be better to create your own ?
Click to expand...
Click to collapse
Hadn't seen much traffic on S5300, saw you 'everything worked fine' comment, and thought I might find some tips here.
I will post a separate thread.
Regards

ric105 said:
Hadn't seen much traffic on S5300, saw you 'everything worked fine' comment, and thought I might find some tips here.
I will post a separate thread.
Regards
Click to expand...
Click to collapse
yes please - coz this thread is still open...
waiting for someone to reply for my last questions...

ric105 said:
I've been able to create a zImage from the GT-S5300 open source kernel code, using the bcm21553_cori_04_defconfig as indicated by the accompanying readme file.
However, when I use this kernel to create a boot.img and download using Odin, I get a quick S5300 startup screen, then nothing.
At this point, I'm just trying to build a stock kernel, no modifications. I'm looking for helpful hints on where to find any debug or error messages that will help indicate what is going wrong. I can use Odin to put the prebuilt stock kernel back, and it boots ok once again.
I've compared my boot.img with a stock boot.img (samfirmware sourced), and they are similar in terms of addresses and pagesizes. The ramfs file is also stock, taken from that same stock boot.img. The built kernel is a bit larger than the stock and I'm not sure if I should expect my built kernel to be exactly the same size, or if it's ok for it to be a few KBs different.
Any other parameters or configurations that I might be missing or should check? (And to samsungkid, were there any special steps that you took?)
Thank You!
Click to expand...
Click to collapse
have you checked command line?

Resolved by switching toolchains. OP query remains...
mr.harsh said:
have you checked command line?
Click to expand...
Click to collapse
No errors reported anywhere that I could find, but thanks for the response.
UPDATE: I resolved my original issue: toolchain was wrong. The readme from samsung tried to tell me, but I refused to listen... Once I changed to the Code Sourcery toolchain, the zImage loaded fine.
But back to samsungkid's issue....
I believe he is still trying to get his own custom module compiled into the kernel. I know that building a module separately as an LKM would work technically, but I don't know if that makes sense for the use case.
Regards

cleudde thetical
ric105 said:
No errors reported anywhere that I could find, but thanks for the response.
UPDATE: I resolved my original issue: toolchain was wrong. The readme from samsung tried to tell me, but I refused to listen... Once I changed to the Code Sourcery toolchain, the zImage loaded fine.
But back to samsungkid's issue....
I believe he is still trying to get his own custom module compiled into the kernel. I know that building a module separately as an LKM would work technically, but I don't know if that makes sense for the use case.
Regards
Click to expand...
Click to collapse
Yes, I would be glad if someone could help me with this...
still working on it
Thanks for every information you can give me !

Maybe I need to give you more details, so:
I downloaded the corresponding kernel for my samsung device.
Then I unpacked the file and opened the readme file, which states:
HOW TO BUILD KERNEL 2.6.35 FOR GT-S5300
1. How to Build
- get Toolchain
Visit http://www.codesourcery.com/, download and install Sourcery G++ Lite 2009q3-68 toolchain for ARM EABI.
Extract kernel source and move into the top directory.
$ cd common/
$ make bcm21553_cori_04_defconfig
$ make
2. Output files
- Kernel : kernel/common/arch/arm/boot/zImage
3. How to make .tar binary for downloading into target.
- change current directory to kernel/common/arch/arm/boot
- type following command
$ tar cvf GT-S5300_Kernel_Gingerbread.tar zImage
Click to expand...
Click to collapse
So I downloaded the appropriate toolchain and created my directories under /root/projects/android
[email protected]:~/projects/android# ls
infofiles kernel tarballs toolchain
Click to expand...
Click to collapse
In the directory infofiles are only the readme files from Samsung.
Kernel contains the extracted files from the archives, downloaded from Samsung.
tarballs contain all the tarballs meaning the kernel.tar.gz and the toolchain.tar.gz
toolchain contains the extracted files from toolchain
I then do all the thinks written in the readme file:
[email protected]:~/projects/android# cd kernel/common/
[email protected]:~/projects/android/kernel/common# make bcm21553_cori_04_defconfig
#
# configuration written to .config
#
Click to expand...
Click to collapse
and then I run into an error:
[email protected]:~/projects/android/kernel/common# make
scripts/kconfig/conf -s arch/arm/Kconfig
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CC kernel/bounds.s
arm-eabi-gcc: error trying to exec 'cc1': execvp: No such file or directory
make[1]: *** [kernel/bounds.s] Error 1
make: *** [prepare0] Error 2
Click to expand...
Click to collapse
So could please, anybody help me with me issue?
Thank you !

no one ?

Have you EXPORTed variables to point to the compiler directory?
A guess, but is the error message saying it cannot find the cross compile toolchain? Generally, you need to either export a couple of variables, or add them to the make command line. Something like:
ARCH=arm SUBARCH=arm CROSS_COMPILE= /home/yourhome/toolchains/.../arm-none-eabi- make
Hope it helps.

ric105 said:
A guess, but is the error message saying it cannot find the cross compile toolchain? Generally, you need to either export a couple of variables, or add them to the make command line. Something like:
ARCH=arm SUBARCH=arm CROSS_COMPILE= /home/yourhome/toolchains/.../arm-none-eabi- make
Hope it helps.
Click to expand...
Click to collapse
Thanks.
I added the path to the toolchain directly into the $PATH variable...
Even tried your above statement - the same error again

Maybe need this...
You may need to edit the Makefile:
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?=arm
#this is original ---> CROSS_COMPILE ?=/home/aniruddh/sgy/arm-eabi-4.4.3/bin/arm-eabi-
CROSS_COMPILE ?=/home/your_user_name_here/arm-2009q3/bin/arm-none-eabi-
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
Then you will run 'make' without export any variables.
Regards

tokomotxo said:
You may need to edit the Makefile:
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?=arm
#this is original ---> CROSS_COMPILE ?=/home/aniruddh/sgy/arm-eabi-4.4.3/bin/arm-eabi-
CROSS_COMPILE ?=/home/your_user_name_here/arm-2009q3/bin/arm-none-eabi-
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
Then you will run 'make' without export any variables.
Regards
Click to expand...
Click to collapse
THAT, did the trick!
Thanks a lot for this awesome hint !
I own you

samsungkid said:
THAT, did the trick!
Thanks a lot for this awesome hint !
I own you
Click to expand...
Click to collapse
Thanks to you :good:

tokomotxo said:
Thanks to you :good:
Click to expand...
Click to collapse
Maybe you could answer me another question?
When I want to compile a normal .c program (like a Hello World Program) for my Samsung phone, how would I proceed?
Do I have to write a Makefile for this?
Thanks

Related

[HOW-TO] extract kernel from source, compile, and insert on GPE (510)

How to extract the boot image from your tablet, set up adb, compile a new kernel with cool options, and put it back on your device!
UPDATED for Lolipop 12-4-14
This is a complete guide from start to finish, copy and paste style. If you own a gpe510, or any other AOSP device and a computer running Debian Linux, you can do all of this.
If all you want is the modified kernel, download from here:
Sleekai Kernel For The LG GPad 8.3 V510(GPE)
​
I am hoping people will add to this with new ideas and patches in order to make the GPE a better device. I see the potential for all sorts of neat stuff.
This guide assumes a basic knowledge of linux operating systems. I am using a Debian 64 bit (wheezy stable) to compile my kernel. I have used many, many hours of the day to figure this out properly, with specific thanks going to Pete of Pete's Blog for his image tools.
But first, lets keep this simple. As usual, you are on your own if you brick your device, though I don't see how you could if you are paying attention!
There are dependencies for building your own kernel, and you will definitely want to use a 64 bit system as a 32 bit will not work properly for kitkat.
Here are all of the packages you will need, and they will draw in further dependencies when you install, but these are it! So, here we go:
Open a terminal, su to root and:
Code:
dpkg --add-architecture i386
##This will allow for the use of some 32 bit librarys that we will need for both adb and the kernel compile. Then:
Code:
apt-get update ; apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 libc6-i686:i386 lzop liblzo2-dev libgpm2:i386 git-core git gnupg flex bison gperf libsdl1.2-dev libesd0-dev build-essential zip curl gedit libncurses5-dev zlib1g-dev fakeroot lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
Next, you will need to install adb and have your permissions set up.
In order to do this you will need to go into the developer options on your device to enable debugging on your tablet. Go to settings/about tablet/build number, and tap on build number several times to unlock the developer options.
then:
You will need to create new udev rules for your device in/etc/udev/rules.d on your computer.
Use "lsusb" in your terminal to find the manufactures code of your device. it will show up as a nexus 4, or Google device.
You will need to create a file in your computer in /etc/udev/rules.d/99-android.rules.
You can use gedit if you like:
Code:
gedit /etc/udev/rules.d/99-android.rules
Put the following inside and save, changing the manufactures code as necessary to fit your device, and change “your-login” to your login name on your computer.
Code:
# Google Nexus devices
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", OWNER="your-login" # Google Nexus devices
18d1 is the manufacturers code.
You will then want to restart udev on your computer:
Code:
service udev restart
you will now have permissions to access your android device from user space.
Now to download adb and get started. You should probably not use adb from the Debian repositories, as it may be an older version. the V510 is using kitkat android and needs the latest build of adb to work properly. It is a good idea to get rid of any old adb files on your computer first. The code below will do just that.
Code:
apt-get purge android-tools-adb android-tools-fastboot
Now download the latest adb bundle from here:
http://developer.android.com/sdk/index.html
Move it into a new directory,
*note -the version number may be different.
Code:
mkdir ~/adb
Code:
cd ~/adb
Code:
unzip adt-bundle-linux-x86_64-20131030.zip
su to root and Move the bundle to /opt:
Code:
mv adt-bundle-linux-x86_64-20131030 /opt/android-sdk-linux-x86_64-20131030
Other google products reside in /opt, this should too. This takes a minute or so on slow machines.
Next we need to link adb to /usr/bin
Code:
ln -s /opt/android-sdk-linux-x86_64-20131030/sdk/platform-tools/adb /usr/bin
Code:
ln -s /opt/android-sdk-linux-x86_64-20131030/sdk/platform-tools/fastboot /usr/bin
We are ready to begin working on the device! first start the adb server and look for your device.
Code:
adb start-server
Code:
adb devices
You will then need to confirm the connection on your tablet screen to allow access from your computer.
Okay, wev'e got this first part set up. it's time to begin working on a kernel!
Lets get started.
I want to extract and build my zimage in $userspace, so open a terminal from /home and:
Code:
mkdir ~/android
Download the source package LG-V510(G-Pad 8.3 Google Play Edition)_Android_KK_V510_11c from here :
https://www.lg.com/global/support/opensource/opensourceList?types=ALL&search=lgv510
and open it to find three folders, including a kernel folder. Move the kernel folder to ~/android and then:
Code:
cd ~/android
Download the current eabi-4.6 Google tool chain to ~/android to cross compile your android kernel:
Code:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8
When it completes, enter ~/android/kernel and get ready to compile a new kernel from the source code.
Code:
cd ~/android/kernel
Do the following each time you compile another kernel. This insures the correct path.
Code:
export PATH=$PATH:~/android/arm-eabi-4.8/bin
Code:
arm-eabi-gcc --version
you should get:
Code:
arm-eabi-gcc (GCC) 4.6.x-google 20120106 (prerelease)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Continue on! we are not done yet!
Code:
export ARCH=arm
Code:
export SUBARCH=arm
Code:
export CROSS_COMPILE=arm-eabi-
Code:
export KERNEL_DEFCONFIG=palman_defconfig
Code:
make clean
Code:
make palman_defconfig
Doing the above prepares your kernel build environment, while the following code opens a interface to configure the kernel. You can simplify this later however you wish.
But for now,
Code:
make menuconfig
At this point make whatever changes you wish to the config file. for a list of the changes I have made, and that are in the kernel available to download, look in the sleekai kernel thread. (At start of thread, or in my signature).
After saving your changes,
Code:
make
Or conversely
Code:
make -o2
which will optimize the make. I recommend using simply "make" first, as the other may not properly show errors should any occur.
and go make a pot of coffee, and probably drink the whole pot! This will take a while.
At the end you will see that the "zimage is ready"
If you have errors, then you probably have dependency problems. If not, Yay! You compiled your first kernel, but we are not done yet!
The zimage you just produced is stored in /kernel/arch/arm/boot/zImage
To put both the zimage and any modules into a separate folder inside of ~/android so as to make extracting them easier:
Code:
mkdir ~/android/kernel_output
Code:
cp ~/android/kernel/arch/arm/boot/zImage ~/android/kernel_output/zImage
Code:
find ~/android/kernel -name "*.ko" -exec cp {} ~/android/kernel_output/ \;
The above code will find all the modules for your kernel. We don't need them for this tutorial, but it still is mighty handy!
Extract your boot image (boot.emmc.win) for the ramdisk You may also download the stock.zip from the sleekai kernel thread
Now make a backup to transfer to your computer.
Reboot to recovery on your tablet. I'm using TWRP. If you are using something else it should be just as easy.
Code:
adb reboot recovery
Only tick the boot
make a backup to your sd card. I changed the name to boot.bac to keep it simple
reboot
make sure the backup of boot is present using a file explorer. I am using ES File explorer.
On your computer, pull the file using adb
Code:
adb start-server
Code:
adb devices
Code:
adb pull /storage/sdcard1/TWRP/BACKUPS/LG0000606708987/boot.bac /home/sleek
sleek is my user name, replace with yours or use tilde.
What we are after is the "boot.emmc.win" file. We will only need this and the zImage to compile a new boot image and run it on your tablet.
The tools to extract the kernel and ramdisk from the boot.emmc.win you will need the following boot image tools installed on your computer.
So, again, lets keep this simple. All the tools are forked to my github for ease of use.
So lets install the tools! Ready?
As Root:
Code:
mkdir /usr/src/android
Code:
mkdir /usr/src/android/boot
Code:
cd /usr/src/android/
Code:
git clone https://github.com/sleekmason/bootimg-tools.git
Code:
cd bootimg-tools/libmincrypt/
Code:
gcc -c *.c -I../include
Code:
ar rcs libmincrypt.a *.o
Code:
cd ../mkbootimg
Code:
gcc mkbootimg.c -o mkbootimg -I../include ../libmincrypt/libmincrypt.a
Code:
cp mkbootimg /usr/local/bin/
Code:
cd ../cpio
Code:
gcc mkbootfs.c -o mkbootfs -I../include
Code:
cp mkbootfs /usr/local/bin/
Code:
cd /usr/src/android/bootimg-tools/mkbootimg/
Code:
wget https://raw.github.com/sleekmason/bootimg-tools/master/mkbootimg/unmkbootimg.c
Code:
gcc -o unmkbootimg unmkbootimg.c
Code:
cp unmkbootimg /usr/local/bin/
Now everything is in place to make a new boot image for your tablet!
Finishing this up is easy.
As root, we made a directory in /usr/src/android/boot for your boot.emmc.win file to be torn apart:
Code:
cd /usr/src/android/boot
Copy your new zImage and the boot.emmc.win file you extracted from your device.
Note* "/home/sleek" is the path on my computer, and should be changed to reflect yours!
Code:
cp /home/sleek/android/kernel_output/zImage /usr/src/android/boot
Code:
cp /home/sleek/boot.emmc.win /usr/src/android/boot
Now unpack the boot.emmc.win file to get the ram disk
Code:
unmkbootimg -i boot.emmc.win
Now you may remove the current boot.emmc.win file, and the resultant kernel file as we will be making new ones, and rename the zImage file you moved here to "kernel".
Code:
rm boot.emmc.win kernel && mv zImage kernel
Now repack using the command given to you during the unpack:
Code:
mkbootimg --base 0 --pagesize 2048 --kernel_offset 0x80208000 --ramdisk_offset 0x82200000 --second_offset 0x81100000 --tags_offset 0x80200100 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=palman lpj=67677 vmalloc=300M' --kernel kernel --ramdisk ramdisk.cpio.gz -o boot.emmc.win
Note* For 500 users this may be different. Simply use the command from the prompt.
You should now have a brand new boot.emmc.win image in /usr/src/android/boot!!
To push back on your device to test
Code:
adb reboot bootloader
Code:
fastboot boot boot.emmc.win
USING the above will only put your kernel build into memory and should not hurt your device if something goes wrong. Use the command below to make it permanent.
If everything works well, you should see the change you made to the /general/perf-localversion/ in your settings under kernel. from there it's up to you to hack away! make new and unique kernels!
If you want your kernel to survive reboot do;
Code:
fastboot flash boot boot.emmc.win
then:
Code:
fastboot reboot
You can expect a slow bootup on the first go around as your new kernel populates the widgets, etc..
NOTE*For the use of the latest eabi-4.7 google toolchain, you will need the libglibc libraries from the "testing" branch as gcc 4.7 is in testing. I advise completing the guide with eabi 4.6 first before trying 4.7.
The gamma correction though enabled in 4.6, isn't near as good as the native compile using 4.7. If you want the screen to look like it does in my kernels, you will need 4.7
For the eabi-4.7:
Code:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7
That's it! Good luck! Remember, If you post a kernel you have made, you will need to show your kernel source, etc . . . Git hub is a good choice to keep track of changes you make. Best regards, Sleekmason
If you are a v500 user and want to build your own kernel!
First, read the above post as you will be following the steps listed there.​
There are just a couple of changes that you will need to do, and maybe a riddle to figure out as well. Read on.
You will need to download the v500 source from here: https://www.lg.com/global/support/opensource/opensourceList?superOsCategoryId=CAT00000001&osCategoryId=
Look for the LGV500 kernel source.
Where it says "palman" for the defconfig items, you will want to replace that with the defconfig for the 500, so replace palman with awifi-perf,
like this:
Code:
export KERNEL_DEFCONFIG=awifi-perf_defconfig
Code:
make awifi-perf_defconfig
Important
Follow the guide and build with the Google Toolchain eabi4.6 first
LG compiled for the 500 and 510 using the eabi4.6. It works, and will give you a feel for the process, and allow you to use your kernel.
Note*
I use the google toolchain eabi-4.7 for the sleekai kernels as it changes the gamma to reasonable defaults on the 510 without further tweaking. After compiling a kernel or two to get a feel for it, you should try using the 4.7 toolchain. To do so, you will probably need the libglibc libraries from the "testing" branch. Look it up.
caveat: I recieved a compile error for the v500 when I used the eabi-4.7 . . . . . yeah. You'll have to work that out.
There is a modified anykernel script for emmc devices out there (Search Google or here in xda). You will have to use the anykernel script after making your boot.emmc.win image as fastboot won't work on the 500. There may be another way .... But I don't know what it is.
Edit* There are now two different kernels for the LG GPad 8.3 V500(awifi) located in the development section of the forum.
Best of luck! -sleekmason
Can this be used to create a kernel for the non Google Play Edition Gpad to be able to allow us to install the Google Play edition ROM on it
Sent from my SM-N900W8 using Tapatalk
Canadoc said:
Can this be used to create a kernel for the non Google Play Edition Gpad to be able to allow us to install the Google Play edition ROM on it
Sent from my SM-N900W8 using Tapatalk
Click to expand...
Click to collapse
I would think so. I edited the above to show how to put the image back on your device. You should be able to use any source you wish to compile with. My thoughts are that you might wish to examine the differences in the ram disk if any.
sleekmason said:
Howdy, I would like to share how to download the kernel source for the gpe, compile a new custom kernel, and insert into your LG gpad GPE 510.
...
Click to expand...
Click to collapse
Thanks for the guide. Making GPE kernel was my next step in trying to get the GPE ROM to work on v510.
I just made guide for getting your Android build environment going if you want to use it on your blog or where ever.
http://forum.xda-developers.com/showthread.php?t=2629008
The problem with v500 is that it does not have fastboot so we can not flash kernel like how you can on v510.
@ AndroidUser00110001 Hi! I know that somebody tweaked the Any kernel to work on emmc devices... Maybe it could be adapted? Actually getting the menuconfig and make should be the same process as well as repacking the image. I take it just getting it back on the 500 device is the problem?
I will add your link to this post for setting up a build environment if that is okay.
sleekmason said:
@ AndroidUser00110001 Hi! I know that somebody tweaked the Any kernel to work on emmc devices... Maybe it could be adapted? Actually getting the menuconfig and make should be the same process as well as repacking the image. I take it just getting it back on the 500 device is the problem?
I will add your link to this post for setting up a build environment if that is okay.
Click to expand...
Click to collapse
Is that the koush any kernel? I was going to mess with that too. I just need a small break now. Took a few days to get new system exactly how I want it.
Go ahead and use guide...mo problem at all.
AndroidUser00110001 said:
Is that the koush any kernel? I was going to mess with that too. I just need a small break now. Took a few days to get new system exactly how I want it.
Go ahead and use guide...mo problem at all.
Click to expand...
Click to collapse
Yes, from here: http://forum.xda-developers.com/showthread.php?t=847265
I noted that boot was on block nncblk0p21 on our device, and not 22? better double check that. I tried it Anykernel as well to no avail when getting this set up. Fastboot is Awesome!
It's taxing to get it set up right. Seems like things change very often for the dependencies based on other package changes. I ussually go with testing but redid two partitions with stable. The 32 bit is just going to sit there, which seems kinda silly due to the need for extra packages in 64 to compile for 32 but whatever. Yeah.
AndroidUser00110001 said:
Thanks for the guide. Making GPE kernel was my next step in trying to get the GPE ROM to work on v510.
I just made guide for getting your Android build environment going if you want to use it on your blog or where ever.
http://forum.xda-developers.com/showthread.php?t=2629008
The problem with v500 is that it does not have fastboot so we can not flash kernel like how you can on v510.
Click to expand...
Click to collapse
I don't understand, what are the differences bettween the v500 and v510? they both have the same hardware, but not the same boot partition or something like that?
ayziaa said:
I don't understand, what are the differences bettween the v500 and v510? they both have the same hardware, but not the same boot partition or something like that?
Click to expand...
Click to collapse
The boot on the 500 cannot be fully unlocked.
This is not the appropriate place to ask that kind of question should be asked in general or in troubleshooting. Also, there are already many threads about this same question please use the search utility to find them. Thank you.
i was thinking of writing a tutorial about this as well for the v500 but this better than i would have done Well done...
sleekmason said:
Yes, from here: http://forum.xda-developers.com/showthread.php?t=847265
I noted that boot was on block nncblk0p21 on our device, and not 22? better double check that. I tried it Anykernel as well to no avail when getting this set up. Fastboot is Awesome!
It's taxing to get it set up right. Seems like things change very often for the dependencies based on other package changes. I ussually go with testing but redid two partitions with stable. The 32 bit is just going to sit there, which seems kinda silly due to the need for extra packages in 64 to compile for 32 but whatever. Yeah.
Click to expand...
Click to collapse
Another tool that i ported to the lg g pad a bit back along with loki-doki...
Quick hint, dont bother with direct mmc naming as qcom (i dont know if the other chip makers do the same thing, as i have only had qcom devices) has given us a simple naming scheme...
should only be used by people who know how to use this,
darkassain said:
i was thinking of writing a tutorial about this as well for the v500 but this better than i would have done Well done...
Another tool that i ported to the lg g pad a bit back along with loki-doki...
Quick hint, dont bother with direct mmc naming as qcom (i dont know if the other chip makers do the same thing, as i have only had qcom devices) has given us a simple naming scheme...
should only be used by people who know how to use this,
Click to expand...
Click to collapse
Thank you! Have you successfully used your script to push a kernel onto the 500 Or 510?
I would think this could be very handy for sharing a custom kernel for the 510, but would like to see somebody report a positive test result. Very cool!
sleekmason said:
Thank you! Have you successfully used your script to push a kernel onto the 500 Or 510?
I would think this could be very handy for sharing a custom kernel for the 510, but would like to see somebody report a positive test result. Very cool!
Click to expand...
Click to collapse
yes back before when there wasnt a overclocked kernel i basically used this to push it when i would compile just the kernel (didnt maintain so i now use dyn's)...
yes this is only for the v500 as this has the extra loki step, but it shouldnt be hard to modify so it does not do that extra step
darkassain said:
i was thinking of writing a tutorial about this as well for the v500 but this better than i would have done Well done...
Another tool that i ported to the lg g pad a bit back along with loki-doki...
Quick hint, dont bother with direct mmc naming as qcom (i dont know if the other chip makers do the same thing, as i have only had qcom devices) has given us a simple naming scheme...
should only be used by people who know how to use this,
Click to expand...
Click to collapse
Hi, can you just use a generic anykernel updater script too?
For example to flash a packed boot.img
Code:
run_program("/tmp/busybox", "dd", "if=/dev/block/platform/msm_sdcc.1/by-name/boot", "of=/tmp/boot.img");
run_program("/tmp/unpackbootimg", "-i", "/tmp/boot.img", "-o", "/tmp/");
run_program("/tmp/repack-ramdisk.sh");
run_program("/tmp/mkbootimg.sh");
run_program("/tmp/busybox", "dd", "if=/tmp/newboot.img", "of=/dev/block/platform/msm_sdcc.1/by-name/boot");
mako and flo can do like this.. I think HTC One as well, since they are all similar qcom chipsets maybe this device can too
poondog said:
Hi, can you just use a generic anykernel updater script too?
For example to flash a packed boot.img
Code:
run_program("/tmp/busybox", "dd", "if=/dev/block/platform/msm_sdcc.1/by-name/boot", "of=/tmp/boot.img");
run_program("/tmp/unpackbootimg", "-i", "/tmp/boot.img", "-o", "/tmp/");
run_program("/tmp/repack-ramdisk.sh");
run_program("/tmp/mkbootimg.sh");
run_program("/tmp/busybox", "dd", "if=/tmp/newboot.img", "of=/dev/block/platform/msm_sdcc.1/by-name/boot");
mako and flo can do like this.. I think HTC One as well, since they are all similar qcom chipsets maybe this device can too
Click to expand...
Click to collapse
thanks for reminding me the any kernel uploaded by me won't work as it doesn't parse Loki images xorrectly, I'll upload the correct one once I have access to my pc
darkassain said:
thanks for reminding me the any kernel uploaded by me won't work as it doesn't parse Loki images xorrectly, I'll upload the correct one once I have access to my pc
Click to expand...
Click to collapse
could you please re-post to a different thread rather than hijacking this thread, as your script does not work with the 510 currently and I do not want to go to get confused with my kernel how to. what started out to maybe become relevant apparently will not and so shouldn't be confused with what I'm doing here. I will be happy to try working with your script if you would open up an appropriate thread. Thank you.
Installed kenel and booted. Now to install trickster mod and fix the dang gamma.
gunnyman said:
Installed kenel and booted. Now to install trickster mod and fix the dang gamma.
Click to expand...
Click to collapse
Excellent!! Pleased to know that you are able to use it. Have you changed your gamma settings?
I did on mine and am pleased with the result. I'm using 248, 252, 255 using trickster mod What are you going with?
sleekmason said:
Excellent!! Pleased to know that you are able to use it. Have you changed your gamma settings?
I did on mine and am pleased with the result. I'm using 248, 252, 255 using trickster mod What are you going with?
Click to expand...
Click to collapse
havent messed around too much.
I had a thought about this and I think it would be awesome if we could incorporate faux123's bits for gamma and color control. His fauxcontrol offers much more granular control than trickster.
I'm thankful to have what we have, and THANK YOU for sharing it, but like any good geek I WANTS MOAR!!!!!
gunnyman said:
havent messed around too much.
I had a thought about this and I think it would be awesome if we could incorporate faux123's bits for gamma and color control. His fauxcontrol offers much more granular control than trickster.
I'm thankful to have what we have, and THANK YOU for sharing it, but like any good geek I WANTS MOAR!!!!!
Click to expand...
Click to collapse
me too! I'll look into it. There are other apps besides trickster to give you more control. I think at the kernel level everything we need is unlocked. And yeah, he knows his business like nobody else eh? I'm just persistent.

[HELP] Compiling Android from source (sm-g360f)

Hi there,
I have Samsung Galaxy Core Prime LTE and I could not find any custom ROMs so I decided that I will try to compile it myself. I downloaded the LineageOS source code from git (cm 14.1), the device trees and kernel from here: github/MSM8916-Samsung, and the samsung vendor files from the extraxt-files.sh script. The qcom-common files from here: github/CyanogenMod/android_device_samsung_qcom-common. Then I set up the environment (source build/envsetup.sh), ran breakfast and everything went fine. And then came brunch... It's running for about 40-50 minutes, and then stopes because "ninja: build stopped: subcommand failed". Here's the output from my terminal: https:/ /drive.google.com/fi le/d/0Bzbi _UspTWqac3ZkV2RhRjJGeW8/view?usp=drivesdk (remove spaces - sorry for that, but I cannot add links yet)
If the ninja log is needed I will post it.
Can someone help me to understand the code and find out why it is failing?
(I am new to developing stuff, but I have already compiled programs back in the days, and I am familiar with Linux, which is my daily driver)
what version of linux are you using at the moment?
Ubuntu 17.04, but I have also tried it on 16.10 last week, and openjdk-8
wasowski02 said:
Ubuntu 17.04, but I have also tried it on 16.10 last week, and openjdk-8
Click to expand...
Click to collapse
I can't speak for others but I have not had success building anything android on 15.10,16.04,16.10... I always end up on a wild goose chase with all the compiling errors. I have consistently compiled without errors using 14.04 with oracle java 8 as that is what many of the manufacturers are using to make their own builds. If or oracle spits errors with 14.04 i try to use the rule of thumb and thats openjdk-6 and jre for LP, openjdk-7 and jre for MM and openjdk-8 for nougat builds but im only working on MM builds at the moment so your results may vary. Hope this helps a bit, just remember you can use sudo update-alternatives --display java to switch versions on the fly if needed and make sure you incorporate Google prebuilts as well. good luck ?
Sent from my LGLS676 using Tapatalk
Sands207 said:
I can't speak for others but I have not had success building anything android on 15.10,16.04,16.10... I always end up on a wild goose chase with all the compiling errors. I have consistently compiled without errors using 14.04 with oracle java 8 as that is what many of the manufacturers are using to make their own builds. If or oracle spits errors with 14.04 i try to use the rule of thumb and thats openjdk-6 and jre for LP, openjdk-7 and jre for MM and openjdk-8 for nougat builds but im only working on MM builds at the moment so your results may vary. Hope this helps a bit, just remember you can use sudo update-alternatives --display java to switch versions on the fly if needed and make sure you incorporate Google prebuilts as well. good luck ?
Click to expand...
Click to collapse
Then I will try 14.04 and see what happens. Thanks for help
@Sands207 Is there by any chance a site where you can learn to do this? Tutorial for noobs of sort.
Sent from my SM-N920P using Tapatalk
ninja_unmatched said:
@Sands207 Is there by any chance a site where you can learn to do this? Tutorial for noobs of sort.
Click to expand...
Click to collapse
Yes, luckily for us xda members we have our own Android college built right into xda https://forum.xda-developers.com/general/xda-university its a great starting point and rom compiling guide is also there. Its all aimed to help new folks find their way ? jump right in ?
If you need TWRP for it I have it. It was built by blaz3r64, but since AA51 is down I can upload it for you. I can confirm that it works on both the ST Galaxy Core Prime and the Boost Prevail LTE.
Sent from my XT1609 using Tapatalk
RealWelder said:
If you need TWRP for it I have it. It was built by blaz3r64, but since AA51 is down I can upload it for you. I can confirm that it works on both the ST Galaxy Core Prime and the Boost Prevail LTE.
Click to expand...
Click to collapse
So I have already downloaded the official TWRP, but thanks for your interest.
I have tried to compile using ubuntu 14.04 (with openjdk-8) as @Sands207, but I get this error:
Code:
FAILED: /bin/bash -c "prebuilts/misc/linux-x86/bison/bison -d --defines=/home/karol/android/system/out/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_y.h -o /home/karol/android/system/out/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_y.cpp system/tools/aidl/aidl_language_y.yy"
/bin/bash: prebuilts/misc/linux-x86/bison/bison: No such file or directory
wasowski02 said:
So I have already downloaded the official TWRP, but thanks for your interest.
I have tried to compile using ubuntu 14.04 (with openjdk-8) as @Sands207, but I get this error:
Code:
FAILED: /bin/bash -c "prebuilts/misc/linux-x86/bison/bison -d --defines=/home/karol/android/system/out/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_y.h -o /home/karol/android/system/out/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_y.cpp system/tools/aidl/aidl_language_y.yy"
/bin/bash: prebuilts/misc/linux-x86/bison/bison: No such file or directory
Click to expand...
Click to collapse
I recommend trying this keychain as it has full support for what you are attempting https://forum.xda-developers.com/showthread.php?t=3606941 I have tried it myself but Id recommend cleaning your build folder before incorporating them, maybe even a reboot as well. i had forgotten about this but it has far more tools than the normal keychain.
Sent from my LGLS676 using Tapatalk
---------- Post added at 04:29 PM ---------- Previous post was at 04:22 PM ----------
remember to select the right architecture ??
Sent from my LGLS676 using Tapatalk
Sands207 said:
I recommend trying this keychain as it has full support for what you are attempting https://forum.xda-developers.com/showthread.php?t=3606941 I have tried it myself but Id recommend cleaning your build folder before incorporating them, maybe even a reboot as well. i had forgotten about this but it has far more tools than the normal keychain.
Sent from my LGLS676 using Tapatalk
---------- Post added at 04:29 PM ---------- Previous post was at 04:22 PM ----------
remember to select the right architecture ?
Click to expand...
Click to collapse
So I downloaded the new toolchain/keychain/cross compiler (just to make sure - this is the same, yes?), but I cannot find how to choose it to compile android. The official post says:
Code:
# for arm64
export CROSS_COMPILE=$(pwd)/bin/aarch64-linux-gnu-
but as I'm not compiling the kernel I assume it is not what I need (I think) and
Code:
echo $CROSS_COMPILE
does not return anything by default. If I should have used the export function then which file should I choose, because there are many (-strip, -strings, -size, -run, etc.).
There is a directory called toolchain (it contains only binutils) in the folder containing the source code. Should I add a folder called gcc and put the files there? Or maybe I have to run brunch with some options or change an entry in a configuration/make file?
I use the aarch64 version, but not the newest (20170515 not 20170520).
wasowski02 said:
So I downloaded the new toolchain/keychain/cross compiler (just to make sure - this is the same, yes?), but I cannot find how to choose it to compile android. The official post says:
but as I'm not compiling the kernel I assume it is not what I need (I think) and
does not return anything by default. If I should have used the export function then which file should I choose, because there are many (-strip, -strings, -size, -run, etc.).
There is a directory called toolchain (it contains only binutils) in the folder containing the source code. Should I add a folder called gcc and put the files there? Or maybe I have to run brunch with some options or change an entry in a configuration/make file?
I use the aarch64 version, but not the newest (20170515 not 20170520).
Click to expand...
Click to collapse
I do think as you said you will need to run brunch but resetting up your build & source environment to use the new keychain as you attempted to switch from one keychain to the other as well may help if this doesn't work as well take a look at your build configuration. rc file and make sure you don't have double entries or the new keychain missing i usually import the prebuilts i need as I am using arm architecture at the moment but i either download the individual keychain i need and place it in my source folder when i setup my build environment to be added to the build along with my sources before i run lunch because my source folder is untouched by me besides that at that point. I'll be home in an hour or so I'm going to see if i can track down some info to help you get untangled but i do recommend downloading the folder and making a gcc folder with the toolchain folder for arm64 as you said and and adding it to your build ensuring it is clean besides what you need and adding it then attempt to compile again.
I'm​ not sure if I should use aarch64. I have an armv7-a-neon (so 64-bit) and the internet says that aarch64 and arm64 is pretty much the same, but maybe I am wrong and I should use arm instead. But I think that does not matter until I put the new toolchain both to the aarch64 and arm directory (I guess the compilation process will choose the right one automatically). So I've put the compilers into prebuilts/gcc/linux-x86/... folders, but should I delete the old compilers? And then run the environment setup again (all this stuff starts to make sense to me ?)
Sent from my SM-G360F using Tapatalk
wasowski02 said:
I'm​ not sure if I should use aarch64. I have an armv7-a-neon (so 64-bit) and the internet says that aarch64 and arm64 is pretty much the same, but maybe I am wrong and I should use arm instead. But I think that does not matter until I put the new toolchain both to the aarch64 and arm directory (I guess the compilation process will choose the right one automatically). So I've put the compilers into prebuilts/gcc/linux-x86/... folders, but should I delete the old compilers? And then run the environment setup again (all this stuff starts to make sense to me )
Sent from my SM-G360F using Tapatalk
Click to expand...
Click to collapse
Yes you should delete the old ones and set up your enviroment again and it should include them. Also yes the compile proccess should pick the correct one in your case as long as you include them and you have, you are heading in the right direction for sure. :good:
Sands207 said:
Yes you should delete the old ones and set up your enviroment again and it should include them. Also yes the compile proccess should pick the correct one in your case as long as you include them and you have, you are heading in the right direction for sure. :good:
Click to expand...
Click to collapse
So I deleted the old ones and I get this error:
Code:
ninja: error: 'prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-strip', needed by '/home/karol/android/system/out/target/product/coreprimeltexx/obj/lib/libdl.so', missing and no known rule to make it
I guess it's because somewhere in a configuration file there is an entry for the old compiler. I have deleted the out directory and played with the envsetup.sh file (about line 210 there is something about compilers),
Code:
# defined in core/config.mk
targetgccversion=
targetgccversion2=
export TARGET_GCC_VERSION=$targetgccversion
# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
export ANDROID_TOOLCHAIN=
export ANDROID_TOOLCHAIN_2ND_ARCH=
local ARCH=$(get_build_var TARGET_ARCH)
case $ARCH in
x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
;;
x86_64) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
;;
arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
;;
arm64) toolchaindir=aarch64/aarch64-linux-android-$targetgccversion/bin;
toolchaindir2=arm/arm-linux-androideabi-$targetgccversion2/bin
;;
mips|mips64) toolchaindir=mips/mips64el-linux-android-$targetgccversion/bin
;;
*)
echo "Can't find toolchain for unknown architecture: $ARCH"
toolchaindir=xxxxxxxxx
;;
esac
but this did not work either. The ninja files don't contain any gcc configuration. So where can I find the right configuration file? (I can't find the suggested configuration.rc file)
wasowski02 said:
So I deleted the old ones and I get this error:
I guess it's because somewhere in a configuration file there is an entry for the old compiler. I have deleted the out directory and played with the envsetup.sh file (about line 210 there is something about compilers),
but this did not work either. The ninja files don't contain any gcc configuration. So where can I find the right configuration file?
Click to expand...
Click to collapse
I usually compile using clang or maven as I only build AOSP atm https://ninja-build.org/manual.html this page includes directions that should assist you. Do you have maven or clang installed on your linux box?
Sands207 said:
I usually compile using clang or maven as I only build AOSP atm https://ninja-build.org/manual.html this page includes directions that should assist you. Do you have maven or clang installed on your linux box?
Click to expand...
Click to collapse
So it seems that nor klang nor maven is installed on my machine (but as my computer claims ninja is not installed either I guess that they may be installed somewhere in the build directories). Should I try them instead of ninja?
wasowski02 said:
So it seems that nor klang nor maven is installed on my machine (but as my computer claims ninja is not installed either I guess that they may be installed somewhere in the build directories). Should I try them instead of ninja?
Click to expand...
Click to collapse
yes absolutely
Sands207 said:
yes absolutely
Click to expand...
Click to collapse
So what I understand is:
(1) Install maven or clang (let's say clang because I found it in the official ubuntu repository)
(2) Configure brunch to use clang instead of ninja
So I checked the internet if there are any options I can use with brunch to run clang, but I didn't find any. Also looked through the envsetup.sh file, but there is nothing there, or I missed it.
wasowski02 said:
So what I understand is:
(1) Install maven or clang (let's say clang because I found it in the official ubuntu repository)
(2) Configure brunch to use clang instead of ninja
So I checked the internet if there are any options I can use with brunch to run clang, but I didn't find any. Also looked through the envsetup.sh file, but there is nothing there, or I missed it.
Click to expand...
Click to collapse
tonight i will try doing some digging to see if i can help you. im away from my computer right now but ill do what i can. i would try would maven. clang assists with aosp primarily but maven should work for you as far as using a custom command to run maven, log out or reboot after you install it and run brunch as you normally would also please read this https://clang.llvm.org/comparison.html

Building Samsung Open-Source Kernel and disable DEFEX

I'm going to show you how to build a custom kernel, and a custom boot.img.
Requirements
A linux OS
Kernel source code from Samsung
Android Image Kitchen (Required for the SEANDROID metadata it appends automatically)
GCC Cross Compilation Toolchain 4.8 (You may just clone the repo with git, or download a zip)
Hypothetical workspace directory on the filesystem: /workspace, now prepare it like this:
/workspace/kernel - this is where the kernel source code will be, this is what we will build. Extract the downloaded Kernel.tar.gz here
/workspace/build - this is the kernel compilation result, populated by the build
/workspace/toolchain - this is the required cross-compilation toolchain you download or check-out from the google link
/workspace/kitchen - Extract Android Image Kitchen here
Click to expand...
Click to collapse
Go to http://opensource.samsung.com/reception.do and search for SM-J415, download one of the results, extract Kernel.tar.gz to /workspace/kernel. I believe SWA stands for South West Asia, and MAE - Middle-east Africa, it doesn't matter which you pick, it is related to radio regulations.
Now overwrite the file /workspace/kernel/build_kernel.sh with:
Code:
#!/bin/bash
# The cross compilation toolchain path
export TOOLCHAIN=$(pwd)/../toolchain/arm-linux-androideabi-4.8
# This is the directory for the compiled kernel
export OUTDIR="O=$(pwd)/../build"
export PATH=$TOOLCHAIN/bin:$PATH
export ARCH=arm
export CROSS_COMPILE=arm-linux-androideabi-
export THREADS=$(nproc --all)
export COMMON_ARGS="-j$THREADS $OUTDIR arch=arm CFLAGS_MODULE=-fno-pic arch=arm"
if [ "$1" == "build" ]; then
make $COMMON_ARGS j4primelte_sea_open_defconfig
make $COMMON_ARGS
elif [ "$1" == "rebuild" ]; then
make $COMMON_ARGS
elif [ "$1" == "clean" ]; then
make $COMMON_ARGS distclean
make $COMMON_ARGS clean
else
echo "./build_kernel.sh build|rebuild|clean"
fi
Building kernel source code
Run the script:
$ cd /workspace/kernel/
edit: /workspace/kernel/arch/arm/configs/j4primelte_sea_open_defconfig
change CONFIG_SECURITY_DEFEX=y to CONFIG_SECURITY_DEFEX=n
$ bash build_kernel.sh build
It should build normally, if it fails there's something wrong with your OS setup. After a long time, you should see the compiled and compressed kernel with the DTP appended at:
/workspace/target/arch/arm/boot/zImage-dtb
The kernel configuration it created from the defconfig files in the kernel source tree is at
/workspace/target/.config
Build a new boot.img
$ cd /workspace/kitchen
$ bash unpackimg.sh /path/to/a/boot/or/recovery.img
Now you will have the unpacked kernel in: /workspace/kitchen/split_img/boot.img-zImage
Delete it
$ rm split_img/boot.img-zImage
Link the built custom kernel there instead
$ ln -s /workspace/target/arch/arm/boot/zImage-dtb /workspace/kitchen/split_img/boot.img-zImage
Now each time you create the boot.img, it will include your custom kernel instead.
Tweak the files and ramdisk as much as you want, and repackage the boot.img
$ bash repackimg.sh
Now you have a boot.img at /workspace/kitchen/image-new.img that is ready to flash to the device. You can unpack custom recoveries the same way as you unpacked boot.img to make them use your custom kernel.
Kernel configurations tried
CONFIG_SECURITY=n - boot loop
CONFIG_SECURITY_SELINUX=n - boot loop
CONFIG_SECURITY_DEFEX=n - works
CONFIG_DM_VERITY=n - works, does not prevent initramfs from using DM-VERITY, you still need some sort of ramdisk hack to disable verification of the next boot phase after initrd.
Often when editing the defconfig files, the same variables are declared in many different files so you might be better off using "sed' to change the variables, example:
$ grep -lr "CONFIG_SECURITY=y" | while read line; do sed -i 's/CONFIG_SECURITY=y/CONFIG_SECURITY=n/g' $line; done
When running "build_kernel.sh build", it will print "configuration written to .config" so verify that the variable was actually changed in the final config /workspace/build/.config
kapmino269 said:
and I think ,They aren't kernel see
Click to expand...
Click to collapse
No that is the latest kernel source code running on the latest firmware. You can use either of those 2 downloads from opensource.samsung.com
kapmino269 said:
it isn't working .
Click to expand...
Click to collapse
The kernel source code is on the Samsung opensource website.... there are two versions one that is MEA ( for Middle East and Africa roms) and the other one for SWA. It works if compiled properly
kapmino269 said:
ok
i have questions loop device depend on kernel and if it is .
How to add support?
Click to expand...
Click to collapse
It seems it depends on the kernel support but I haven't actually tried messing around that stuff
kapmino269 said:
it isn't working .
Click to expand...
Click to collapse
You need to install gcc, python and make before you run the command bash build_kernel.sh build
sudo apt install gcc make python
kapmino269 said:
I knew steps man I used Ubuntu for 2 years without windows .
thank you .
Click to expand...
Click to collapse
Do you tried make mrproper and make clean before you run build_kernel.sh?
kapmino269 said:
ok
i have questions loop device depend on kernel and if it is .
How to add support?
Click to expand...
Click to collapse
Type "make xconfig" in the kernel directory, and a window will open for configuring the .config file in that same directory.
Search for "Loopback device support" and add a checkmark (not a dot, so that the module is built into the kernel.)
kapmino269 said:
it isn't working .
Click to expand...
Click to collapse
Can you please provide a log or something? It sounds like you are missing dependencies in your operating system for building kernels.
how do you flash the new boot.img with a samsung device?
kapmino269 said:
By twrp
Click to expand...
Click to collapse
Thanks!!
I ended up using https://forum.xda-developers.com/showthread.php?t=2446269 which is pretty easy as well.
I am now stuck on how to enable wifi after flashing a different kernal.
Kernal = samsung opensource
Rom = nouget 7.1.1 (different to opensource kernal)
Any suggestions?
heavy load said:
Thanks!!
I ended up using https://forum.xda-developers.com/showthread.php?t=2446269 which is pretty easy as well.
I am now stuck on how to enable wifi after flashing a different kernal.
Kernal = samsung opensource
Rom = nouget 7.1.1 (different to opensource kernal)
Any suggestions?
Click to expand...
Click to collapse
Install the Magisk module LIBSECURE_STORAGE COMPANION
ashyx said:
Install the Magisk module LIBSECURE_STORAGE COMPANION
Click to expand...
Click to collapse
Thanks Ashyx, I had a play with your kernal on github, nice work there!
I ended up downloading a stock rom matching the samsung opensource kernal build number, worked out of the box.
kapmino269 said:
See that :
@ashyx any help
I NEED TO ADD SOME MODULES.
Click to expand...
Click to collapse
It's telling you the path to the defconfig doesn't exist.
Either the name is wrong or it doesn't exist in the config directory.
kapmino269 said:
This, I solved it yesterday, Thanks .
But I have 2 problems :
1- Device is arm and at bulid_kernel.sh tell me to use toolchain arch64 ,
Which I should Use arm or arm64 ,
I confused as cpu is arm64 .
https://www.qualcomm.com/products/snapdragon/processors/425
Or
Ndk
https://developer.android.com/ndk/downloads/index.html
2- Which command I should write after menuconfig
./build_kernel.sh
Or
make -jX .
Click to expand...
Click to collapse
Just use whichever is in the build script.
You will need to add menuconfig to build_kernel.sh before make or your changes will be lost.
Then run build_kernel.sh
kapmino269 said:
@ashyx ,all is ok .
The error from clang and there is 2 config files .
Fixed and I will test kernel but I have problem when compiling I choose lz4 type ,do U see I should choose another .
Also where is zimage now ,i compiled manually not with build_kernel.sh .
Click to expand...
Click to collapse
You don't need the export arguments which are contradictory anyway, as you have already defined your toolchain and architecture before hand.
Also the boot image does not need to be lz4. The compiler will tell you where the finished zImage is when completed. You should find it in the boot directory of the arm64 directory if you are not using OUT_DIR statements.
kapmino269 said:
Sorry ashyx this is last thing ,
-You told me later that device is arm not arm64 .
In Your twrp thread .
-Also defconfig of device in /arch/arm .
-Arch=arm in build_kernel.sh .
-Gsi system armaonly only work on the device .
-All apps told that device is arm .
I confused ,
Please tell that it is right to use arm64 tool chain .
Or How did U build it ?
By arm64 toolchain or arm toolchain ?
Very Thank U .
Click to expand...
Click to collapse
I was just going by the screen shot you posted. Like I said your commands are contradictory.
You have both arm and arm64 toolchains defined in the same script.
You also have an export statement for arm64 directly under a statement for an arm toolchain.
Not sure why you added both?
As far as I can see the architecture you're compiling for is arm, so you need an arm toolchain.
kapmino269 said:
It contains errors
Click to expand...
Click to collapse
This is the script I use.
You will need to modify the path to your toolchain.
can i use the source code to build kernel for android 10 one ui if the source built for mm

[REFERENCE] My experience building the Tucana kernel & Rom

Little info on what this all is.
If you are expecting a working kernel or rom after reading this all. That is not what this thread is.
What this all is intended for is material to help with getting you to the next step, if you are at a road block.
What will you gain from all this?
A fair bit of knowledge on working with msm-4.14 kernel and maybe others.
Make sure to have your search bar ready with a piece of the issue (key word of the error will do) and go through the hidden tabs until you pick up your error, with the browser search function (ctrl+f on most browsers)
Spoiler: OLD info
Method I used for building the kernel
1. Dowload AOSP common-kernel-4.14 through git
OR
ANDROID 10 Specific
refs/heads/q-common-android-4.14 - kernel/manifest - Git at Google
2. Download Xiaomi TUCANA-Q-SOURCE for android 10 source code from MiCode git.
ALL VARIANTS
GitHub - MiCode/Xiaomi_Kernel_OpenSource: Xiaomi Mobile Phone Kernel OpenSource
Xiaomi Mobile Phone Kernel OpenSource. Contribute to MiCode/Xiaomi_Kernel_OpenSource development by creating an account on GitHub.
github.com
**OR**
TUCANA Android 10
GitHub - MiCode/Xiaomi_Kernel_OpenSource at tucana-q-oss
Xiaomi Mobile Phone Kernel OpenSource. Contribute to MiCode/Xiaomi_Kernel_OpenSource development by creating an account on GitHub.
github.com
3. extract if you did not use git to download sources.
You will need AOSP 10 R29 downloaded. R29 Matches Stock MIUI 12.0.4
4. mkdir kernelbuild (can be what ever) then extract both AOSP KERNEL (git) ,build, common, kernel, prebuilts, master-prebuilts folders to the kernelbuild folder.
5. just use TUCANA source and don't merge with AOSP common source. Don't delete common either
4. copy AOSP kernel folder (contains 4.14) to TUCANA source and merge (Still not sure if you need to do this)
5. make sure you have AOSP-10 from git already. If not, repo it.
6. Go to AOSP-10 REPO>prebuilts>gcc>linux-x86>aarch64 location and get (aarch64-linux-android-4.9) folder and copy it to root Tucana source files folder make a directory call toolchain TUCANA source. in prebuilts>gcc>linux-x86>aarch64 folder replace and merge all
7. Not sure if this is outdated but got the export info from MSM section at https://github.com/MiCode/Xiaomi_Kernel_OpenSource/wiki/How-to-compile-kernel-standalone
e.g.
export CROSS_COMPILE=/<toolchain-location/prebuilts>GCC>/bin/aarch64-linux-android-
mkdir out
cd out
Taken from mi code section for MSM 4.14
export ARCH=arm64
export SUBARCH=arm64
export DTC_EXT=dtc
Set CONFIG_BUILD_ARM64_DT_OVERLAY=y
(does not work from what i can tell. Have to enable using menuconfig)
if not inside the "out" folder use O=out on next command, will also have to type cd ../ to go back in source if using this command.
(-jN (N is for a number))
make -jN tucana_user_defconfig
make menuconfig (configure config to your liking)
use save button (highlight save and press enter, can use arrow key right and left as well)
make -jN
Or it could be
make -jN ARCH=arm64
After doing all this, for me the build fails. Its driving me insane!
I think I also was using the wrong AOSP kernel, was using common-4.14 and now using this one
refs/heads/q-common-android-4.14 - kernel/manifest - Git at Google
guessing the Q is for Android 10
MY DEMON!!!!!
1615228944041.png
i think it is not working because i am using Android 10 R41 and should be using Android 10 R29. Testing it now.
Alright, went from ubuntu version 20 to 18 (Bionic is more reliable and easier to set up).
Had 20, due to bionic auto updated (my own fault).
Version 20 does work with some modding and adding bionic to the repo's of ubuntu.
I tried using AOSP toolchain and also Qualcomm's (QQ-LLV) LLV toolchain 8.0 for clang.
The part from MiCode wiki on github is saying to use CLANG_Triple with aarch64-linux-gnu which I can not find this file anywhere.
Not in QQ-LLV, AOSP-10-R29 aarch64 that is located in prebuilts > gcc
so the main problem I am getting is the cpu timer failing, during the build process. I try to modify the config by typing "make menuconfig" and then change the cpu govern type from performance to ondemand and saving it as .config (not sure if it is supposed to be the same name as the tucana-user-defconfig, let me know if this is the problem)
the AOSP android version I am using is R29. The AOSP kernel I am using is common-4.14
none of these files have aarch64-linux-gnu.
I am starting to slowly give up on this whole thing. spent 7 days just to get a cpu timer problem during build.
Oh and the source i am using is from Micode github under tucana for android 10 (Q)
Just sprung up an idea. I think i am supposed to first use Qualcomms LLVM toolchain 8.0 with the Mi source code package to make up the files needed in order to use anything from AOSP. please let me know if this is correct.
No matter what guide i find for it, it shows CLANG_TRIPLE=aarch64-linux-gnu- and every time. it just can not find it. no idea how to get this.
it work in clang triple for -gnu
AOSP-Q-Kernel-4.14.117
refs/heads/q-common-android-4.14 - kernel/manifest - Git at Google
Spoiler: Kbuild config
ARCH=arm64
SUBARCH=arm64
BRANCH=android-4.14
CLANG_TRIPLE=aarch64-linux-gnu-
CROSS_COMPILE=aarch64-linux-android-
DEFCONFIG=tucana_user_defconfig
KERNEL_DIR=xsource
DTC_EXT=dtc
DTS_EXT=dts
CC=clang
LZ4_RAMDISK=1
POST_DEFCONFIG_CMDS=""
EXTRA_CMDS=''
CLANG_PREBUILT_BIN=prebuilts-master/clang/host/linux-x86/clang-r353983c/bin
LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin
REAL_CC=prebuilts/ndk/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang
BUILDTOOLS_PREBUILT_BIN=build/build-tools/path/linux-x86
FILES="
O=/out
arch/arm64/boot/Image.gz
vmlinux
System.map
"
STOP_SHIP_TRACEPRINTK=1
OMFG!!!!!!! VICTORY!!!!!!!!
I think.
1615380568663.png
MAYBE!!!!!
1615380671546.png
Spoiler: New info
Alright Managed to fix most of the problems in the OLD area, mostly due to path issues, always check your paths (PATH).
Spoiler: build.config
ARCH=arm64
SUBARCH=arm64
BRANCH=K4.14Q
CLANG_TRIPLE=aarch64-linux-gnu-
CROSS_COMPILE=~/android/xkernel/tsource/toolchains/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
CROSS_COMPILE_ARM32=~/android/xkernel/tsource/toolchains/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-
KBUILD_DEFCONFIG=~/android/xkernel/tsource/arch/arm64/configs/tucana_user_defconfig
DEFCONFIG=tucana_user_defconfig
POST_DEFCONFIG_CMDS="check_defconfig"
DTC_EXT=dtc
DTC_PREBUILTS_BIN=/scripts/dtc
KBUILD_OUTPUT=out
HOSTCC=gcc
CC=clang
AS=clang
AR=ar
CLANG_PREBUILT_BIN=/toolchains/clang/host/linux-x86/clang-r353983c/bin
BUILDTOOLS_PREBUILT_BIN=/toolchains/build-tools/linux-x86/bin
FILES="
arch/arm64/boot/Image.gz
vmlinux
System.map
"
Don't know if most of what is in there is needed or if everything I need is there but that is what i have so far.
One thing that i know always does not work is the check_defconfig. fails to match every time.
Tried using ld.ldd and it just keeps saying the vmlinux file size is too large. I have not given up and can say i have learned a lot.
Will update more as I go.
Spoiler: Links
Toolchain and kbuild config help
Hello I have been trying to extract the kernel from Tucana android 10 source. I would like to know if anyone has a working config to be able to build up the kernel. I have a config but it does not extract everything, well I don't think it does...
forum.xda-developers.com
[SOLVED] dts not found
Hello. Been working on how to get a device kernel from source for the Mi note 10 pro (Mi CC9 Pro). I have gotten up to the point where it builds but fails due to dts folder is not found. I need an example of what goes in DTC_EXT= All I see on...
forum.xda-developers.com
Spoiler: UPDATE 2022 WORKING BUILD WITH ISSUES
Alright I decided to give it another shot in 2022 because of getting replies.
1. Get your source from device brand. (https://github.com/MiCode/Xiaomi_Kernel_OpenSource)
2. Use Mi code wiki to learn how to build (https://github.com/MiCode/Xiaomi_Kernel_OpenSource/wiki)
3. Go right hand side for standalone kernel. Because the how to section just waste hours on end with nothing built and Soong and clang errors.
4. Follow msm-4.14 for a guide. (https://github.com/MiCode/Xiaomi_Kernel_OpenSource/wiki/How-to-compile-kernel-standalone)
5. Make sure to have dtc binary file from aosp source (https://android.googlesource.com/platform/prebuilts/misc/) choose your android version. Check device for android version. Can use CPU ID in playstore under System, section API LEVEL.
6. Get llvm Snapdragon from Qualcomm. (https://developer.qualcomm.com/software/snapdragon-llvm-compiler-android) I used both but you should be able to use 8.0. both have off same results during the build process.
7. Get Aosp gcc
(https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/)
8. Put LLVM Snapdragon toolchain and AOSP gcc into a folder in root of kernel folder called toolchain.
9. Run the script mi provided. Change the 6.0 on the last 2 make commands to 8.0 unless you are already using 6.0, then you can leave it at 6.0.
10. Build.
11. Get a boot.img extractor from github or on these forums. I can't recommend one yet, due to not having full success. Can search boot.img extractor or boot.img unpacked as seperate search terms.
**Recommendation**
Boot and Recovery
GitHub - xiaolu/mkbootimg_tools: Unpack and repack boot.img,support dtb(dt.img).
Unpack and repack boot.img,support dtb(dt.img). Contribute to xiaolu/mkbootimg_tools development by creating an account on GitHub.
github.com
OR
Android Kitchen
GitHub - osm0sis/Android-Image-Kitchen: Automated scripts to unpack/repack Android kernel/recovery images + ramdisks
Automated scripts to unpack/repack Android kernel/recovery images + ramdisks - GitHub - osm0sis/Android-Image-Kitchen: Automated scripts to unpack/repack Android kernel/recovery images + ramdisks
github.com
OR
Android Kitchen
GitHub - cfig/Android_boot_image_editor: Parsing and re-packing Android boot.img/vbmeta.img/payload.bin, supporting Android 13
Parsing and re-packing Android boot.img/vbmeta.img/payload.bin, supporting Android 13 - GitHub - cfig/Android_boot_image_editor: Parsing and re-packing Android boot.img/vbmeta.img/payload.bin, supp...
github.com
12. Extract boot.img from stock rom.
13. Put image.gz.dtb in unpacked boot image. Delete original file and rename new one as the same name.
14. Repack boot.img and either upload using fastboot or use twrp to install the boot.img
The problem I have at the moment is I am unable to use touch input at all. It boots loads system but can't touch anything. No input at all. Hardware buttons work though.
Might be solution on 3rd post to no touch input. https://forum.xda-developers.com/t/reference-how-to-compile-an-android-kernel.3627297/page-43
VMLINUX FIX: HERE
Hi @Squida, I've also been on this road, I just hit a milestone when I actually have something booting (but not much working), see the thread I started if it works for you too
b100dian said:
Hi @Squida, I've also been on this road, I just hit a milestone when I actually have something booting (but not much working), see the thread I started if it works for you too
Click to expand...
Click to collapse
Spoiler: Reply
Hey mate, thanks for the reply. Could you put a link to your thread so I can check it out.
Found it: https://forum.xda-developers.com/t/building-lineageos-17-1-from-source.4245417/
I also have posted on Qualcomm forums.
LINK: https://developer.qualcomm.com/forum/qdn-forums/software/snapdragon-llvm-compiler-android/68403
I found out qcomm has its own builder for msm devices. It's known as QAEP. I have been trying to build the sm6150 with Tucana defconfig. The thread above is the issue I have in trying to build it. No idea how to get "SDClang" so as soon as I work that out. It should build with QAEP instead of using AOSP.
There's a commit where I add SDCLANG support (but I don't think that's needed, is backed out atm) https://github.com/alibei/android_d...mmit/efbb3c66aa0d385e58052675402489c13392576e )There's a similar commit in the kernel.
You need to register to Qualcomm to download it, and unzip it in kernel/toolchains, just as https://github.com/MiCode/Xiaomi_Kernel_OpenSource/wiki/How-to-compile-kernel-standalone says under "You must get llvm clang from qcom". You just have to get the 8.x version.
Some snippets for the commands I've tried https://gist.github.com/b100dian/40c8dbe746ff181aff71ee10a75a5f3c
Spoiler: Reply
Yeah I am not trying to use Lineage sources. so far steps I have taken are as follows.
1. Mi source code download of Tucana android 10, data source, wifi source, audio source.
2. Extracted Mi tucana source in a directory (also tried the git way to update CAF tags).
3. using AOSP as the source for build. I tried using Clang with cross compile with gcc (GNU)
4. with using all AOSP toolchains so clang and gcc from AOSP and then using LLVM clang as reall cc, due to it does not contain clang itself.
all that for kernel and it builds but I feel its missing drivers. due to the warnings that Qcom gives. also got wifi modules installed but not audio. Audio source is a little different then the wifi source.
For the proprietary binaries. I used lineage Extract script with the lineage 17.1 tucana proprietary-files.txt list.
extraction worked on miui_TUCANAGlobal_V12.0.4.0.QFDMIXM_be49be8fa0_10.0.zip.
but of course the device tree is missing, found the platform sm6150 device tree on QAEP. so now trying to use QAEP to build not only the kernel but the rom as well using QAEP instead of AOSP. think we need to use QAEP, then using the files built. can then move over to aosp for upgrading, etc.
Could you explain this error considering you managed to get SDClang working. it may solve my problem. error provided below.
Spoiler: sdclang error
I have a SDCLANG_PATH set in BoardConfig.mk in the commit I pointed to earlier.
Basically is from a toolchains folder creaded with `tar -xvzf snapdragon-llvm-8.0.6-linux64.tar.gz` in the kernel/xiaomi/tucana folder
b100dian said:
I have a SDCLANG_PATH set in BoardConfig.mk in the commit I pointed to earlier.
Basically is from a toolchains folder creaded with `tar -xvzf snapdragon-llvm-8.0.6-linux64.tar.gz` in the kernel/xiaomi/tucana folder
Click to expand...
Click to collapse
what i have setup in boardconfig is as follows.
ifneq ($(HOST_OS),linux)
SDCLANG := true
SDCLANG_PATH := toolchain/ndk/android-ndk-r22/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin
SDCLANG_LTO_DEFS := device/qcom/common/sdllvm-lto-defs.mk
endif
this has been added just above wifi. still fails with same error.
Spoiler: Boardconfig.mk
Image:
I think I just solved it, so i noticed you talk about Boardconfig.mk and when i checked out your git code, it had in the same config the target. well QAEP is a little different it not only has a Boardconfig file but also a AndroidBoard config file. so i think i am supposed to be adding it in there instead of Boardconfig. testing it now.
Spoiler: AndroidBoard.mk
Something else i also noticed that is not working.
Spoiler: .ko files missing
And can confirm above configuration changes are not working, not sure where it is located to tell it the path.
I cannot speak for QAEP (I barely began reading about lineage but in my case I don't have out/target/product/sm6150 at all, only out/target/product/tucana, which seems to be the name of the kernel (or device or vendor). Do you also have other repos pulled in that contain kernel named sm6150? Like https://github.com/LineageOS/android_kernel_xiaomi_sm6150 Maybe you should not have both
b100dian said:
I cannot speak for QAEP (I barely began reading about lineage but in my case I don't have out/target/product/sm6150 at all, only out/target/product/tucana, which seems to be the name of the kernel (or device or vendor). Do you also have other repos pulled in that contain kernel named sm6150? Like https://github.com/LineageOS/android_kernel_xiaomi_sm6150 Maybe you should not have both
Click to expand...
Click to collapse
Spoiler: b100dian reply
So where yours is out/target/product/tucana, the one for QAEP is SM6150 which is in the same location. so I think maybe on the right track here. also thanks for the help for llvm dragon, had to set bin path, for it to work. but i have not gone a built the rom yet, doing the kernel build first now.
Instead of relying on QAEP builder. I went and got kernel/build from code-aurora for android 10 r40 and ended up getting misc linux folder in kernel also gcc and build tools from the device tag release repo on codeaurora.
Usually i was using AOSP but now switched over to all QAEP tools and sources.
I am testing the Micode Audio and wifi source. got wifi working during kernel build by adding this below.
EXT_MODULES="
mods/wlan/qcacld-3.0
"
IN_KERNEL_MODULES=1
I believe that installs the wifi drivers for the device as a module. but building with clang, gcc and gnu as clang tripple this is all related to only kernel building.
Spoiler: Update
Done an overhaul on everything for the kernel. decided to switch from QAEP to AOSP.
Reason for the switch, I noticed with AOSP I am able to not only download the kernel/msm4.14 common folder but it also downloads build, prebuilts, prebuilts-master folders with everything included.
Differences aside from what I mentioned above.
AOSP common-4.14 comes with up to date builder, gcc, clang, etc. But when I download the release tag for example, LA.UM.9.1.r1-06700-SMxxx0.0 at codeaurora on the otherhand, it only downloads the common folder and no extra folders for it.
So then in turn. you have to go on codeaurora and download by using git clone, the build folder for what ever android version it is. for example, I had android version 29 (r29) though it does not exist in the branch list on codeaurora so i went with 28.
I should also note that making the change from QAEP to AOSP I started again with the kernel source.
With making the change, I have noticed improvements right away, but also I noticed that having CC=clang, the build would not work untill I also put in HOSTCC=gcc. guessing its to do with the AOSP version being a little different. still using QualComms LLVM clang compiler for everything clang related.
Spoiler: Problems I have so far.
***Error-1***
Have it building but get this spam, been trying to solve it.
***Error-2***
This error pops up when using LD=ld.lld
this is what is set in the build.config
***CONFIG-1***
LD=ld.lld
LD_LIBRARY_PATH=toolchain/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/lib/clang/8.0.6/lib/linux/aarch64:$LD_LIBRARY_PATH
export O=out/android-4.14 LD_LIBRARY_PATH
**RESULTS**
***CONFIG-2***
LD=ld.lld
HOSTLDFLAGS="-fuse-ld=lld" (added it so i can modify)
LD_LIBRARY_PATH=toolchain/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/lib/clang/8.0.6/lib:$LD_LIBRARY_PATH
export O=out/android-4.14 LD_LIBRARY_PATH
**RESULTS**
Same as above.
Spoiler: Config commands
This right here may have just solved all my problems. can confirm in all my config tries. Never once thought to put aarch64-linux-android before all variable values.
SOURCE: https://developer.android.com/ndk/guides/standalone_toolchain
# Tell configure what tools to use.
target_host=aarch64-linux-android
export AR=$target_host-ar
export AS=$target_host-clang
export CC=$target_host-clang
export CXX=$target_host-clang++
export LD=$target_host-ld
export STRIP=$target_host-strip
Also discovered that LD=ld.lld is for clang compiler. could be why the above Problem is happening.
This is using the toolschains without NDK, may have to put qualcomm and gcc in NDK and path them.
So after trying to downgrade to android 10 from 11, had no luck in doing so.
So now sticking with android 11 and I can safely say that I have reached a mile stone.
I ended up downloading android 11 R30 and using all the tool chains from AOSP while still using Qualcomm's LLVM compiler 8.0.6 as REAL_CC. But the clang pre-built path is clang from AOSP. Just trying to work out how to include the Xiaomi audio source. Unable to work out where to put it. Still testing, have not given up.
Hi @Squida, where is `mods/wlan/qcacld-3.0` from, the qcom talos referenced above in BoardConfig.mk?
Do you have an exact link to the repo?
In the meantime I can confirm I am missing something form the kernel. If I build everything myself and replace _just_ the kernel (with my dtb appended etc) it has sound/wireless, so knowing what wifi / audio module to link in seems the way to go.
b100dian said:
Hi @Squida, where is `mods/wlan/qcacld-3.0` from, the qcom talos referenced above in BoardConfig.mk?
Do you have an exact link to the repo?
In the meantime I can confirm I am missing something form the kernel. If I build everything myself and replace _just_ the kernel (with my dtb appended etc) it has sound/wireless, so knowing what wifi / audio module to link in seems the way to go.
Click to expand...
Click to collapse
Spoiler: Reply
No problem at all, anything to get this build done lol.
All links are for Android 11
If you want Android 10, replace pheonix-r-oss with tucana-q-oss
**Example for Android 10**
GitHub - MiCode/Xiaomi_Kernel_OpenSource at tucana-q-oss
Xiaomi Mobile Phone Kernel OpenSource. Contribute to MiCode/Xiaomi_Kernel_OpenSource development by creating an account on GitHub.
github.com
******ANDROID 11******
***SOURCE***
GitHub - MiCode/Xiaomi_Kernel_OpenSource at phoenix-r-oss
Xiaomi Mobile Phone Kernel OpenSource. Contribute to MiCode/Xiaomi_Kernel_OpenSource development by creating an account on GitHub.
github.com
***DATA***
GitHub - MiCode/vendor_qcom_opensource_data-kernel at phoenix-r-oss
xiaomi opensource for data-kernel. Contribute to MiCode/vendor_qcom_opensource_data-kernel development by creating an account on GitHub.
github.com
***AUDIO***
GitHub - MiCode/vendor_qcom_opensource_audio-kernel at phoenix-r-oss
Contribute to MiCode/vendor_qcom_opensource_audio-kernel development by creating an account on GitHub.
github.com
***WIFI (mods/wlan/qcacld-3.0)***
MiCode/vendor_qcom_opensource_wlan
Contribute to MiCode/vendor_qcom_opensource_wlan development by creating an account on GitHub.
github.com
Thanks, I think I get now what you're saying with 'talos', I poked at those repos now.
It seems to me the modules are built out of tree, as they don't appear in the extracted kernel config. (See https://github.com/b100dian/Xiaomi_Kernel_OpenSource/commit/0f4b062ef806aaad6ad02e2efd87809e8b7250c6).
Also, having dlkm from https://source.codeaurora.org/quic/la/device/qcom/common/tree/?h=LA.UM.8.9.r1-03800-sm6150.0 does not seem to help automate the build, I get all sorts of errors when AndroidKernelModule.mk is included and it includes back the AndroidKernel.mk..
Getting these into drivers/staging seems easier at first but..for now, I've only managed to build wlan.ko but that still errors out with `wlan: disagrees about version of symbol module_layout` :-S
b100dian said:
Spoiler: Reply
Thanks, I think I get now what you're saying with 'talos', I poked at those repos now.
It seems to me the modules are built out of tree, as they don't appear in the extracted kernel config. (See https://github.com/b100dian/Xiaomi_Kernel_OpenSource/commit/0f4b062ef806aaad6ad02e2efd87809e8b7250c6).
Also, having dlkm from https://source.codeaurora.org/quic/la/device/qcom/common/tree/?h=LA.UM.8.9.r1-03800-sm6150.0 does not seem to help automate the build, I get all sorts of errors when AndroidKernelModule.mk is included and it includes back the AndroidKernel.mk..
Getting these into drivers/staging seems easier at first but..for now, I've only managed to build wlan.ko but that still errors out with `wlan: disagrees about version of symbol module_layout` :-S
Click to expand...
Click to collapse
Spoiler: Reply
It seems you are having a similar issue.
When doing everything I have done so far, The biggest wall for me is getting <LD=LD.lld> to work properly, I either get clang error with a file having a linking problem with using clang from QQ llvm compiler. And when I switch over to using AOSP's 4.14 stable kernel prebuilts-master clang. It works but then another error to do with CPU timer pops up. Which was originally because of using gcc instead of clang in the CC=clang environment variable, or removing it out of the build.config file.
i myself did a major overhaul of Ubuntu and have upgraded to LTS 20.04 from 18 bionic.
Noticed some things right away.
When you install gcc-multilib and g++-multilib. You get version 9 instead of you being on Ubuntu bionic and getting version 7. Also faster in general with general use of the operating system using Oracle vmbox. On windows 10.
Apart from linking errors, kernel is buding but only with not having LD=LD.lld in the build.config file.
Spoiler: wifi-info
And for the wifi qcom. Mods folder I added manually. Inside the devices source folder. Then copied WLAN sources inside and renamed the folder to just WLAN.
Spoiler: where I am at now
I have got both android 11 and android 10 kernel and ROMs. Also went and downloaded the kernel for coral. That's how I found out about the wifi and how I got a lot of the settings for the build.config.
I am gonna have a break on this whole thing, gotten to a point where with android 11 Xiaomi Phoenix. I get one error with a file in kbuild, using the same config settings for android 10. I get none. Apart from the qcom space which is either DTC not working or failing at some point. Not sure if we need to use LD=LD.lld I have been reading it is not needed due to the builder choosing the correct one for you.
Overall though it builds. Just the spam for qcom warnings I just can not get rid of and it's to do with the sensors.
If anyone has information on what causes the qcom spam. Please let me know, thank you.
Plus this all started with vmlinux not working right. Something to do with channel scratch. Can not fix it.
Spoiler: My Thoughts
I have just found this exploring info on the rom.
Build AOSP with LineageOS device tree
My device (Xiaomi Redmi Note 5, whyred) have official LineageOS support and therefore there is device tree and kernel. I want to build AOSP without any modifications or tweaks. How can I use (or po...
stackoverflow.com
Key part taken from above link.
**Its hard to build pure AOSP than other ROMs. While building a custom ROM a lot of components wont work**
I think for our devices we have no choice but to use QAEP instead of AOSP, it explains why it fails to build properly. we first need a full working rom and then I think we can move over to AOSP and modify lets say, coral device and match it for our device. Though I think it is just easier using QAEP and why QAEP exists in the first place.
When I used QAEP, I got the SDCLANG problem, the build process according to the Micode git wiki, section "How to use" explains on how to configure and by the looks of the guide. It seems simple as cooking a boiled egg with only a couple of modifications to a device tree and adding your kernel to the kernel folder. It is supposed to build. I myself get SDClang path problems when using QAEP though.
I will go back to QAEP but i will be using all android 11 sources. due to unable to downgrade my phone from android 11 to 10. Having issues at the moment with TWRP installing. Shows my folder structure folder and file names. all random characters.
I will update as i get further in building the kernel and rom
Spoiler: Thoughts2
So I am now merging the built kernel into the kernel directory of AOSP 10. Made a folder called common and moved the built kernel into it. Also made a folder called prebuilts and put in all the .gz into it under a folder called 4.14. discovered that the AOSP 10 picked up the common folder with the built kernel but is having errors with Android.bp, will update as I find out more. Right now, just tinkering.
This is the issue when you have the build tools outside the source folder.
Could be a path I have not set properly. once I removed the command from POST_DEFCONFIG_CMDS="" it is now building.
Couple of things to note.
REAL_CC= I believe has now changed to HOSTCC=. Command is not found in any files in the build directory of the AOSP 4.14 STABLE Kernel.
QualComms LLVM 8.0.6 Compiler does not contain clang files. you still need to either download it, or just use the one in AOSP 4.14 Stable kernel, plus the clang version in AOSP stable kernel is a later version and also contains clang version for android 10+ instead of android 9.
New error I get after changes mentioned above are made.
Not sure where to put -fPIC to make the command function.
Fixed it, was a pathing issue with folders.
But now I am stuck now on finding out the directory for LD_LIBRARY_PATH=
Code:
DTC arch/arm64/boot/dts/qcom/apq8016-sbc.dtb
dtc: error while loading shared libraries: /home/avm/dev/source/kernel/prebuilts-master/ndk/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/lib/libc++.so: file too short
make[4]: *** [scripts/Makefile.lib:325: arch/arm64/boot/dts/qcom/apq8016-sbc.dtb] Error 127
make[3]: *** [/home/avm/dev/source/kernel/mi10/scripts/Makefile.build:676: arch/arm64/boot/dts/qcom] Error 2
make[2]: *** [arch/arm64/Makefile:187: dtbs] Error 2
make[2]: *** Waiting for unfinished jobs....
CC lib/rhashtable.o
Spoiler: Extra Discovered Info
${ROOT_DIR} is used. With it and you don't need to export it. Builder already knows what it is. so you use it like this for example
************************************
CC=${ROOT_DIR}/path-to-QQ_LLVM_COMPILER clang binary file, located in bin folder.
Also do this for ld.lld
LD=${ROOT_DIR}/path-to-ld.lld
************************************
Found another odd thing that happens
Having CC=PATH-TO-QQ-llvm-compiler/clang with CC_PREBUILT_BIN as aosp's location and HOSTCC=clang
It builds.
But with LD=
It fails.
I try using QQ-LLVM-Compiler as CC_Prebuilt_bin=
Fails.
So far I have managed to get to this point.
And can safely say that using QualComs LLVM 8.0.6 compiler does not work with android 10 so stick with AOSP's prebuilt clang either in Kernel stable git or AOSP android-Number-Revision
Again, REAL_CC does not work, nor show up in the enviroment as a used command.
These below all do.
<CC=>, <HOSTCC=>, <HOSTLDFLAGS=-fuse-ld=lld>, <NM=llvm-nm>, <OBJCOPY=llvm-objcopy>, <HOSTLD=>, <LD=>,
HOSTCC= will use what is put in CLANG_PREBUILT_BIN=
CC= you are able to add QQ-LLVM-COMPILER's clang and it will run.
Proof of QQ-LLVM-COMPILER failing, when using it for <CLANG_PREBUILT_BIN=>
Instead of using AOSP's clang.
So far that is all I have seen pop up.
All these changes were done with the Kernel AOSP-COMMON-4.14-STABLE build, kernel, prebuilts, prebuilts-master folders and then with the devices source in a folder with a build.config file in the same location as the AOSP-kernel build folders. this all seems to work, Only thing I lose out on, is using POST_DEFCONFIG_CMDS="" to use make menuconfig.
Reason that make does not work is because according to AOSP coral's kernel you have another build.config file which is with the build folder, prebuilts, master-prebuilts folders which connects to the main build.config.common and clang config that has the extra commands. So in turn I do not think we use LD=ld.lld
We let the builder choose it for us.
95% sure that the DTC is what is causing qcom to have that warning spam.
Device tree compiler (DTC) linking seems to be the full cause of all the issues.
Okay to prevent fixdep.c:105:10: error all you need to do is have HOSTCC=gcc and it works. so then in turn. You can now use QQ LLVM Clang compiler in CLANG_PREBUILT_BIN= instead of AOSP.
Spoiler: Helpful Links
GitHub - nathanchance/android-kernel-clang: Information on compiling Android kernels with Clang
Information on compiling Android kernels with Clang - GitHub - nathanchance/android-kernel-clang: Information on compiling Android kernels with Clang
github.com
Spoiler: Still going
Still going at it, manage to find out a couple of things.
If your build is failing due to files missing, check your build directory and make sure the files in the path folder and in Linux-x86>bin folders are indeed "symlinked" something I was unaware of with Linux due to me being a windows user. none of the icons can have an X on it. it means its broken. this solved a ton of my issues during Rom building.
the build folder itself is a symlink folder. (Not all files)
Just locate and put files in correct places. so instead of having a folder called toolchains, like we are told on the Micode wiki, etc. If you use the AOSP-kernel build, prebuilts, prebuilts-master. which contains all kernel and build tools. and are already linked. so then you just add QQ-LLVM-Compiler to either prebuilts or pre-builts master and link it in the config.
If you do all this correctly and having all files in the proper location, you should not have any more build errors in regards to missing files.
Summed up
Build directory contains symlinks to binary files which are located in prebuilts and prebuilts-master. you need all 3 folders in the device source root directory.
Inside the build directory you will find a file called build.config, its not a config. its a symlink for one. Rename it to the build.config.Aarch64 for example, or what ever your config is called located in your root devices source directory. this solved a **** load of my problems.
The problem I have now is actually got to do with Repo, AOSP, QAEP. found out using the manual install method of repo makes it so you can download off google when you have the pgp key installed. but having it installed this way, stuffs up gpg for QAEP. I am looking for a way to merge all PGP keys in one location.
and to get QAEP downloading without showing this error.
All you have to do is remove the manual repo you installed and then also deleting the .repoconfig folder and .gnupg folder.
Then install repo with <sudo snap install git-repo>
it will work, you will get a public key under john doe and it will use CAF as well. problem is. You lose out on public key to AOSP and also the repo that is inside the AOSP folder needs to be replaced. trying it just causes errors though.
What happens when you do above by removing the manual repo and adding the snap git-repo
So why does it matter that I need both public keys to work?
Because I am using AOSP and also QAEP for testing.
I'll be sticking with the snap instal git-repo for now. i'll have to work out how to add the key from AOSP.
**Error when going back to AOSP**
**what happens when you delete the repo folder inside .repo of AOSP**
Only way I got it to work is by removing the snap install version of repo and install the manual way.
But then I lose out on CAF.
Think i may have worked out what is happening with the keys. 2 folders are being made. .repoconfig and .gnupg.
.gnupg only gets created when using AOSP pgp key.
and there is a gnupg folder in .repoconfig, might be a command to merge the files.
this command below makes it so you can change the name.
--config-name
put it at the end of the repo init command.
from what I understand for the tucana_user_defconfig.
#CONFIG_BUILD_ARM64_DT_OVERLAY does not need to be set. for mi 9, yes. not for mi note 10. Just pulled the defconfig from my device using the command below.
**EXTRACT DEFCONFIG FROM DEVICE**
MSM devices
CMD> adb pull /proc/config.gz
files appears as config.gz in same directory
I should also note that I ran 2 builds one with DT_OVERLAY=Y and then one =N
the outcome was with the change of CONFIG_BUILD_ARM64_DT_OVERLAY=n
That is not how it is setup, the proper way to disable it is as follows.
#CONFIG_BUILD_ARM64_DT_OVERLAY is not set
I got a bigger file size for Image.gz-dtb. instead of under 20MB
Have it on so you can extract DTBO and dtb files. having it off stops it from extracting.
THIS error or what ever the hell it is, is driving me insane.
My understanding is that DTBO (overlay), when enabled, ends up in dtbo.img, and when disabled, probably ends up in dtb which is appened to the kernel Image.gz.
The gsi_write_channel_scratch error is... maybe this helps? https://github.com/ClangBuiltLinux/linux/issues/931#issuecomment-599681910
Spoiler: reply
Btw, thank you @Squida for pointing me out the correct repos for wifi and audio, I managed to compile both into my build and the audio one inline (the wifi needs to be insmod'ed).
b100dian said:
My understanding is that DTBO (overlay), when enabled, ends up in dtbo.img, and when disabled, probably ends up in dtb which is appened to the kernel Image.gz.
The gsi_write_channel_scratch error is... maybe this helps? https://github.com/ClangBuiltLinux/linux/issues/931#issuecomment-599681910
Spoiler: reply
Btw, thank you @Squida for pointing me out the correct repos for wifi and audio, I managed to compile both into my build and the audio one inline (the wifi needs to be insmod'ed).
Click to expand...
Click to collapse
Spoiler: Reply
You sir, are a Legend!
Okay So if I am reading that right.
If you mean DT_OVERLAY=y in defconfig, makes it so I can get the dtbo.img file. I tried adding the dtbo.img to the list of files for extraction and with it on, no dtbo image is made nor found, with it off. still the same thing but unable to extract any dtb or dtbo images from the boot directory. have to have it on.
dtbo.img just does not want to extract for me.
Again, using the clang config and not the mi 9 config used on Micode wiki.
the Micode Wiki settings do not work correctly. you lose out on about a GB of stuff and I know its a DTC issue I have been having due to the Qcom spam.
I have reduced the space though so now you can actually scroll through the whole build process, including the spam.
I will definitely be looking into that solution for channel scratch.
Also if you could please show me the config for the SDClang settings you put it to get it to detect. I tried looking over your git page and failed to understand why you have it in boardconfig.mk and if lineage has other files for the device.
Reason being is because on QAEP it talks about SDclang-3.8 and i have no idea where it is.. Supposed to be in QQ-LLVM-compiler and you copy it to the prebuilts folders, it just does not exist to do that.
the major problem I have is building the device tree when building the kernel. from my understanding, Xiaomi have set it up so DTC creates a Device tree for you. well that is the part that is failing and the whole reason why I can not make a rom.
My guess because you are using lineage sources, everything I am talking about. they already did for you. I am trying to do it all manually. learning purposes.
Okay so it turns out, we need LD=ld.lld
Though we must modify files, this is ridiculous just to get your own rom for xiaomi devices.
This thread below may have the solution for me and an easier one then having to modify files manually. Might have to update the Devices Kernel to the stable aosp 4.14 kernel. this is my theory anyway.
[REFERENCE] How to get an Android kernel up to date with linux-stable
Introduction Hello everyone! This will be a thread to assist people with getting their device's Android kernel up to date with the latest linux-stable tag from kernel.org. This process will henceforth be referred to as "upstreaming". This thread...
forum.xda-developers.com
Squida said:
Spoiler: Reply
You sir, are a Legend!
Okay So if I am reading that right.
If you mean DT_OVERLAY=y in defconfig, makes it so I can get the dtbo.img file. I tried adding the dtbo.img to the list of files for extraction and with it on, no dtbo image is made nor found, with it off. still the same thing but unable to extract any dtb or dtbo images from the boot directory. have to have it on.
dtbo.img just does not want to extract for me.
Again, using the clang config and not the mi 9 config used on Micode wiki.
the Micode Wiki settings do not work correctly. you lose out on about a GB of stuff and I know its a DTC issue I have been having due to the Qcom spam.
I have reduced the space though so now you can actually scroll through the whole build process, including the spam.
I will definitely be looking into that solution for channel scratch.
Also if you could please show me the config for the SDClang settings you put it to get it to detect. I tried looking over your git page and failed to understand why you have it in boardconfig.mk and if lineage has other files for the device.
Reason being is because on QAEP it talks about SDclang-3.8 and i have no idea where it is.. Supposed to be in QQ-LLVM-compiler and you copy it to the prebuilts folders, it just does not exist to do that.
the major problem I have is building the device tree when building the kernel. from my understanding, Xiaomi have set it up so DTC creates a Device tree for you. well that is the part that is failing and the whole reason why I can not make a rom.
My guess because you are using lineage sources, everything I am talking about. they already did for you. I am trying to do it all manually. learning purposes.
Click to expand...
Click to collapse
Spoiler: Reply
My guess because you are using lineage sources, everything I am talking about. they already did for you. I am trying to do it all manually. learning purposes.
Click to expand...
Click to collapse
Of course, this is the reason. I don't know exactly how the lineage build scripts generate dtbo.img. There's make bootimage, make vendorimage and maybe make dtboimage too. Probably this command helps you generate it, but I don't think I had success with that: https://forum.xda-developers.com/t/...nel-dtbo-for-redmi-k20.3973787/#post-80354635
The image size differs and the one created by lineage build scripts is the same size as the original one.
I also have console spam when the device tree is generated, I just didnt sweat on it as being an error.
BoardConfig is probably central to the lineage build, but I assume the variables set here are available to kernel's make commands.
For a lineage-less built I used the first two commands here: https://gist.github.com/b100dian/40c8dbe746ff181aff71ee10a75a5f3c (the rest of the things are my attempts to construct back the boot.img with the kernel).
To actually boot the kernel you can gzip it, and append the dtb file to it (
like
Code:
cat Image.gz dtb > Image.gz-dtb
).
, and _then_ reconstruct a deconstructed original boot.img with that (w/o the --dtb parameter if I remember correctly). But I think kernel output already has -dtb concatenated in out/arch/arm64/boot
b100dian said:
Spoiler: Reply
Of course, this is the reason. I don't know exactly how the lineage build scripts generate dtbo.img. There's make bootimage, make vendorimage and maybe make dtboimage too. Probably this command helps you generate it, but I don't think I had success with that: https://forum.xda-developers.com/t/...nel-dtbo-for-redmi-k20.3973787/#post-80354635
The image size differs and the one created by lineage build scripts is the same size as the original one.
I also have console spam when the device tree is generated, I just didnt sweat on it as being an error.
BoardConfig is probably central to the lineage build, but I assume the variables set here are available to kernel's make commands.
For a lineage-less built I used the first two commands here: https://gist.github.com/b100dian/40c8dbe746ff181aff71ee10a75a5f3c (the rest of the things are my attempts to construct back the boot.img with the kernel).
To actually boot the kernel you can gzip it, and append the dtb file to it (
like
Code:
cat Image.gz dtb > Image.gz-dtb
).
, and _then_ reconstruct a deconstructed original boot.img with that (w/o the --dtb parameter if I remember correctly). But I think kernel output already has -dtb concatenated in out/arch/arm64/boot
Click to expand...
Click to collapse
Thanks for the quick reply.
Spoiler: Might be the solution to DTC
Code:
DTC_EXT=~/android/lineage/prebuilts/tools-lineage/linux-x86/dtc/dtc ARCH=arm64 SUBARCH=arm64 CROSS_COMPILE=${PWD}/toolchain/bin/aarch64-linux-android- make O=../tucana-out REAL_CC=${PWD}/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu - vendor/tucana_user_defconfig
DTC_EXT=~/android/lineage/prebuilts/tools-lineage/linux-x86/dtc/dtc ARCH=arm64 SUBARCH=arm64 CROSS_COMPILE=${PWD}/toolchain/bin/aarch64-linux-android- make -j8 O=../tucana-out/ REAL_CC=${PWD}/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- 2>&1 | tee ../kernel.log
Above solution might be the key thing to solving my issues with DTC. i can safely say I never once put the ARCH= and SUBARCH= in DTC_EXT= this may have solved it.
As for the rom building itself, I may have to use AOSP over QAEP, due to the whole SDCLANG issue
Link:
https://developer.qualcomm.com/forum/qdn-forums/software/snapdragon-llvm-compiler-android/68403#comment-18264
Those issues are all related to QAEP, I have less problems with AOSP.
Just don't have a device tree for it. that is why I need DTC working perfectly.
For what it is worth, tried looking for a default device tree that was not based off lineage-os. No luck thus far.
But isn't the device tree what's in arch/arm64/boot/dts/qcom/ in the kernel sources?
There's even a Makefile there where you can see CONFIG_BUILD_ARM64_DT_OVERLAY in use
b100dian said:
But isn't the device tree what's in arch/arm64/boot/dts/qcom/ in the kernel sources?
There's even a Makefile there where you can see CONFIG_BUILD_ARM64_DT_OVERLAY in use
Click to expand...
Click to collapse
Spoiler: Reply
Lmao holy ****, I think I know where I stuffed up. I was navigating extract only at boot. Did not go further then boot directory lol. I'll test now with navigating to qcom. Thanks for the tip.
***UPDATE***
Managed to work out why all these problems are occurring.
Okay so from what I understand, there is 2 building methods.
1. Using terminal and using export commands.
2. build.config file
To test the theory to make sure that indeed there is a double up on builds, I decided to put the whole Micode Mi 9 export guide into the build.config that I have (made a backup of it) after executing it did indeed show errors.
so then I investigate how it is failing and it came to my attention that the export method for the make defconfig and then build is seperate for build.config.
for the kbuild, we issue the environment variables for example, these below.
When I say its Kbuild variables, it could be clang or gcc. Not 100% sure though.
Spoiler: Kbuild Environment Variables
# PRE_DEFCONFIG_CMDS
# Command evaluated before `make defconfig`
#
# POST_DEFCONFIG_CMDS
# Command evaluated after `make defconfig` and before `make`.
#
# POST_KERNEL_BUILD_CMDS
# Command evaluated after `make`.
#
# EXTRA_CMDS
# Command evaluated after building and installing kernel and modules.
#
# DIST_CMDS
# Command evaluated after copying files to DIST_DIR
#
# VENDOR_RAMDISK_CMDS
# When building vendor boot image, VENDOR_RAMDISK_CMDS enables the build
# config file to specify command(s) for further altering the prebuilt vendor
# ramdisk binary. For example, the build config file could add firmware files
# on the vendor ramdisk (lib/firmware) for testing purposes.
Spoiler: extra-info
and instead of having "make" command by itself I put it for example in PRE_DEFCONFIG_CMDS="make <code>*
and it will add in REAL_CC, etc to the defconfig and upon making the build it should inturn do the rest.
Does anyone know the environment variable for kernel build so i can then put in the make command for the build and include REAL_CC=, etc. I managed to get the first make command for the defconfig working.
PRE_DEFCONFIG_CMDS="make O=out/android-4.14 REAL_CC=${PWD}/prebuilts-master/ndk/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- tucana_user_defconfig"
I just now have to get the below command working. not sure what environment variable to put it under.
make -j$(nproc) O=out/android-4.14 REAL_CC=${PWD}/prebuilts-master/ndk/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- 2>&1 | tee kernel.log
Found it!
By searching in build directory then build.sh file.
and *_setup_env.sh* has settings as well that will help.
***********************************
export MAKE_ARGS=$*
Could be useful
CC_LD_ARG
***********************************
echo "========================================================"
echo " Building kernel"
set -x
(cd ${OUT_DIR} && make O=${OUT_DIR} ${CC_LD_ARG} ${MAKE_ARGS})
set +x
***Linux update script***
GitHub - android-linux-stable/script: A script to help with merging linux-stable into your own repository
A script to help with merging linux-stable into your own repository - GitHub - android-linux-stable/script: A script to help with merging linux-stable into your own repository
github.com
Better to use CAF for MSM devices.
[REFERENCE] Merge latest CAF Tag in Kernel
Introduction: Hello folks! In this thread I will be guiding you about how you can merge latest CAF tags in your CAF based kernel. Many people who just started compiling the kernels still don't know how to merge a CAF tag because there isn't any...
forum.xda-developers.com
Upon further research on the topic of MAKE_ARGS=$*
from what I now understand and please keep in mind, I am in no way a programmer or good with Linux overall.
I think the $* symbol is a value itself, so from my understanding. If i use lets say $S=Something I have just made an variable that will be used in MAKE_ARGS=$*
If my theory for this is correct, this is how I add in the make variables for the last build command to start the build.
Should be able to do this.
make -j$(nproc) O=out/android-4.14 REAL_CC=${PWD}/prebuilts-master/ndk/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- 2>&1 | tee kernel.log
Oh and the config is make commands, found that out as well. you have MAKE and SOONG commands and configs. I so prefer Make variables over Soong. looks easier to read for me.
Found a build config on mi code, sources, issues section
SOURCE
Spoiler: build.config-mi11
#!/bin/bash
export OUT=${PWD}/out
export ARCH=arm64
export SUBARCH=arm64
export TARGET_BUILD_VARIANT=userdebug
#export DTC_EXT=dtc
export CROSS_COMPILE=${PWD}/toolchains/aarch64-linux-android-4.9/bin/aarch64-linux-android-
export KERNEL_DEFCONFIG=venus-qgki_defconfig
#set CONFIG_BUILD_ARM64_DT_OVERLAY=y
#set BUILD_CONFIG=build.config.gki.aarch64
O=$OUT REAL_CC=${PWD}/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- ${PWD}/scripts/gki/generate_defconfig.sh $KERNEL_DEFCONFIG
make O=$OUT REAL_CC=${PWD}/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- vendor/$KERNEL_DEFCONFIG
make -j$(nproc) O=$OUT REAL_CC=${PWD}/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- 2>&1 | tee kernel.log
The build config above is indeed for Mi11, we do not need gsi settings or the 3rd command starting with O=$OUT for Mi note 10 pro
By implementing the changes above, outcome below.
Just now have to resolve kernel issues and this should build with no more issues. it has been a massive adventure.
the errors above are due to remnants of old files from merges that were not undone properly. deleted the devices source and recreated it again. problems are now gone will update on outcome.
I still can not seem to get it completely built. Max Image.gz-dtb file size is 28.5MB so far. and the highest I have gotten. still get VMLINUX issues which tells me just maybe Xiaomi themselves have not updated the build scripts to suite the latest CAF changes.
All speculation at the moment.
Had a look at this area
GitHub - MiCode/kernel_build
Contribute to MiCode/kernel_build development by creating an account on GitHub.
github.com
Turns out, build config for CC9 Pro. does not exist hence why all the problems Using AOSP's.
I believe it needs to be full modified in order to work with Tucana, due to Xiaomi not releasing a build script for it. so another solution would be to modify or try and use another device on the list in the link to be able to build it. not even export using the Mi 9 works so I have to dig deeper on getting a config and build script for it.
Spoiler: Current build.config
ARCH=arm64
SUBARCH=arm64
BRANCH=android-4.14
CLANG_TRIPLE=aarch64-linux-gnu-
CROSS_COMPILE=aarch64-linux-android-
TARGET_BUILD_VARIANT=userdebug
DEFCONFIG=tucana_user_defconfig
SKIP_DEFCONFIG=1
PRE_DEFCONFIG_CMDS="make O=out/android-4.14 REAL_CC=${ROOT_DIR}/prebuilts-master/ndk/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- ${DEFCONFIG} && make O=out/android-4.14 menuconfig"
POST_DEFCONFIG_CMDS=""
KERNEL_DIR=.
EXTRA_CMDS=""
HOSTCC=gcc
CC=clang
DTC_EXT=${ROOT_DIR}/prebuilts-master/misc/linux-x86/dtc/dtc
LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin
CLANG_PREBUILT_BIN=prebuilts-master/ndk/toolchains/llvm-Snapdragon_LLVM_for_Android_8.0/prebuilt/linux-x86_64/bin
LZ4_PREBUILTS_BIN=prebuilts-master/misc/linux-x86/lz4
DTC_PREBUILTS_BIN=prebuilts-master/misc/linux-x86/dtc
LIBUFDT_PREBUILTS_BIN=prebuilts-master/misc/linux-x86/libufdt
BUILDTOOLS_PREBUILT_BIN=build/build-tools/path/linux-x86
OUT_DIR=out/android-4.14
FILES="
arch/arm64/boot/Image
arch/arm64/boot/Image.gz
arch/arm64/boot/Image.gz-dtb
arch/arm64/boot/dts/qcom/tucana-sdmmagpie-overlay.dtbo
arch/arm64/boot/dts/qcom/sdmmagpie.dtb
vmlinux
System.map
.config
"
EXT_MODULES="
private/msm-tucana-modules/wlan/qcacld-3.0
"
IN_KERNEL_MODULES=1
STOP_SHIP_TRACEPRINTK=1
The config does not build vmlinux, DTC properly, dtbo.img. Still working on it.
I also did try first doing the standalone export way. Just constantly getting ld error --fix-something and to fix it, by using CC=clang and HOSTCC=gcc
but then you resort to having to use the build.config file. for some reason the standalone export method just does not work with cc and hostcc
and that is using the QQ LLVM/clang 8.0 toolchain with AOSP's GCC while having 2 directories. toolchain(GCC) and toolchains(QQ-LLVM/Clang) with QQ-llvm/clang's build directory inside the devices source root directory as well, according to MiCode Wiki under MSM-4.14.
Tried attaching the last make command to the DTC_EXT= and it fails, still unable to find the build kernel argument to change the command manually. Only have POST_KERNEL_BUILD
No luck at all with the export combo.
As for the build.config.
I get a build using AOSP'S GCC and QQ-LLVM/CLANG 8.0
But it is not complete.
I also use the build, prebuilts, prebuilts-master from AOSP's 4.14 Common kernel repo.
the reason for this, is because Xiaomi have not released kernel build files for the device. from what I have found.

Question Propietary blobs/files for Odin

Hey, does anyone know how to get the propietary blobs out of the device? I'm kinda done with MIUI and i wanna try to compile some custom rom and maybe a legit twrp.
SanHelios said:
Hey, does anyone know how to get the propietary blobs out of the device? I'm kinda done with MIUI and i wanna try to compile some custom rom and maybe a legit twrp.
Click to expand...
Click to collapse
lol i am looking for the same
check this out
vamsi209 said:
lol i am looking for the same
check this out
Click to expand...
Click to collapse
what shall i check out?
SanHelios said:
what shall i check out?
Click to expand...
Click to collapse
Extracting proprietary blobs from LineageOS zip files | LineageOS Wiki
wiki.lineageos.org
SanHelios said:
Hey, does anyone know how to get the propietary blobs out of the device? I'm kinda done with MIUI and i wanna try to compile some custom rom and maybe a legit twrp.
Click to expand...
Click to collapse
Trying to look for the Chinese tool to flash the unofficial TWRP, once I manage to do that will try help on grabbing those needed proprietary blobs. May need guide on how to pull the blobs, am still a noob
dan079 said:
Trying to look for the Chinese tool to flash the unofficial TWRP, once I manage to do that will try help on grabbing those needed proprietary blobs. May need guide on how to pull the blobs, am still a noob
Click to expand...
Click to collapse
Me too... TWRP is tricky, since it can only be done by this OneInject-function of TWRP, but it's possible. I tried the 'current' unofficial release of TWRP for this, but all i got was a reboot to BL.
vamsi209 said:
Extracting proprietary blobs from LineageOS zip files | LineageOS Wiki
wiki.lineageos.org
Click to expand...
Click to collapse
yshalsager, who created the Firmware-script, told me the same.. here is his answer.
"
Hi,
Thanks for your words, glad to hear my work helps.
You can use LineageOS extract files script that will generate vendor tree for you. It is available in any device tree but you should use one of your device so it reads from its proprietary-files.txt or something.
"
Maybe LOS is closer than we think.
SanHelios said:
yshalsager, who created the Firmware-script, told me the same.. here is his answer.
"
Hi,
Thanks for your words, glad to hear my work helps.
You can use LineageOS extract files script that will generate vendor tree for you. It is available in any device tree but you should use one of your device so it reads from its proprietary-files.txt or something.
"
Maybe LOS is closer than we think.
Click to expand...
Click to collapse
niceee, so for mix 4, i extracted the twrp trees using this,
[SCRIPT] TWRP device tree generator
Create a TWRP-compatible device tree only from an Android recovery image (or a boot image if the device uses non-dynamic partitions A/B) of your device's stock ROM. It has been confirmed that this script supports images built starting from...
forum.xda-developers.com
setup the local repo for building twrp trees, using these
1. Installing the tools
A Python library/script to automatically generate TWRP-compatible device tree from a boot/recovery image - twrpdtgen/twrpdtgen
github-wiki-see.page
tried building but the device doesn't lunch after following the steps shown above,
Code:
http://www.hastebin.com/jonexiyowu.md
and one of the dev https://github.com/imjyotiraditya , helped me build an aospa rom for g8x,
now he is on to building twrp for our device odin.
if anyone has twrp trees, we can try geting aospa build ready for our device
vamsi209 said:
niceee, so for mix 4, i extracted the twrp trees using this,
[SCRIPT] TWRP device tree generator
Create a TWRP-compatible device tree only from an Android recovery image (or a boot image if the device uses non-dynamic partitions A/B) of your device's stock ROM. It has been confirmed that this script supports images built starting from...
forum.xda-developers.com
setup the local repo for building twrp trees, using these
1. Installing the tools
A Python library/script to automatically generate TWRP-compatible device tree from a boot/recovery image - twrpdtgen/twrpdtgen
github-wiki-see.page
tried building but the device doesn't lunch after following the steps shown above,
Code:
http://www.hastebin.com/jonexiyowu.md
and one of the dev https://github.com/imjyotiraditya , helped me build an aospa rom for g8x,
now he is on to building twrp for our device odin.
if anyone has twrp trees, we can try geting aospa build ready for our device
Click to expand...
Click to collapse
hey, i'm trying it right now... was able to manage a device tree from the latest weekly of the EU-rom. Repo is syncing right now for the aosp-twrp-11 repository.
U used the same script for the recovery trees?
vamsi209 said:
U used the same script for the recovery trees?
Click to expand...
Click to collapse
yes, i extracted it from the boot.img.
Update... build/envsetup.sh error, anyone any suggestions?
Update managed to get envsetup.sh to work, got following error messages
source build/envsetup.sh
including device/xiaomi/odin/vendorsetup.sh
COMMON_LUNCH_CHOICES: Befehl nicht gefunden.
COMMON_LUNCH_CHOICES: Befehl nicht gefunden.
lunch twrp_odin-eng
In file included from build/make/core/config.mk:291:
In file included from build/make/core/envsetup.mk:266:
build/make/core/product_config.mk:155: error: Can not locate config makefile for product "twrp_odin".
23:22:04 dumpvars failed with: exit status 1
WARNING: Trying to fetch a device that's already there
Traceback (most recent call last):
File "/home/dave/AOSP-Recovery/vendor/twrp/build/tools/roomservice.py", line 431, in <module>
fetch_device(device)
File "/home/dave/AOSP-Recovery/vendor/twrp/build/tools/roomservice.py", line 399, in fetch_device
git_data = search_gerrit_for_device(device)
File "/home/dave/AOSP-Recovery/vendor/twrp/build/tools/roomservice.py", line 86, in search_gerrit_for_device
device_data = check_repo_exists(git_data, device)
File "/home/dave/AOSP-Recovery/vendor/twrp/build/tools/roomservice.py", line 62, in check_repo_exists
raise Exception("{device} not found,"
Exception: odin not found,exiting roomservice
In file included from build/make/core/config.mk:291:
In file included from build/make/core/envsetup.mk:266:
build/make/core/product_config.mk:155: error: Can not locate config makefile for product "twrp_odin".
23:22:05 dumpvars failed with: exit status 1
** Don't have a product spec for: 'twrp_odin'
** Do you have the right repo manifest?
Anyone a good guess?
Did you had any luck, or any chance I can help?
Puksom said:
Did you had any luck, or any chance I can help?
Click to expand...
Click to collapse
well, i made some progress, but i failed again. I posted a thread in the official twrp forum. Maybe you might want to take a look at it.. thx.
Post in thread '[DEV]How to compile TWRP touch recovery' https://forum.xda-developers.com/t/dev-how-to-compile-twrp-touch-recovery.1943625/post-85686505
Puksom said:
Did you had any luck, or any chance I can help?
Click to expand...
Click to collapse
I'm a total beginner, so i might be wrong. But as far as i can tell, the makefiles of the extracted device tree need to be update or even completely rebuild.
Hi, it seems like I was able to execute the script successfully.
It didn't work on Windows because it got stuck on the execution of unpackimg.bat.
I ran it on Linux and it worked (after chmod 777 of boot.img). This is the command I ran:
python3 -m twrpdtgen -o ./odin ./boot.img
output:
Code:
TWRP device tree generator
Version 1.3.0
[INFO] Cloning AIK...
Done! You can find the device tree in odin/xiaomi/odin
I took boot.img from the latest MIUI 12.5.7.0 China Stable
Now I have what it seems to be the device tree (odin.zip) but I don't know what to do it it or what it is.
radoinc said:
Hi, it seems like I was able to execute the script successfully.
It didn't work on Windows because it got stuck on the execution of unpackimg.bat.
I ran it on Linux and it worked (after chmod 777 of boot.img). This is the command I ran:
python3 -m twrpdtgen -o ./odin ./boot.img
output:
Code:
TWRP device tree generator
Version 1.3.0
[INFO] Cloning AIK...
Done! You can find the device tree in odin/xiaomi/odin
I took boot.img from the latest MIUI 12.5.7.0 China Stable
Now I have what it seems to be the device tree (odin.zip) but I don't know what to do it it or what it is.
Click to expand...
Click to collapse
This is great, so we know this script works and does what it is supposed to do...
I checked the makefiles to see if there are any differences, but there are none. So it suggests that it doesn't matter, from which version you get the files from. I love, that the users of the Mi Mix 4 are more open so compiling than the community of the MI 11 Ultra is..
SanHelios said:
This is great, so we know this script works and does what it is supposed to do...
I checked the makefiles to see if there are any differences, but there are none. So it suggests that it doesn't matter, from which version you get the files from. I love, that the users of the Mi Mix 4 are more open so compiling than the community of the MI 11 Ultra is..
Click to expand...
Click to collapse
I'm trying to replicate your steps but I get the same "Can not locate config makefile for product "twrp_odin"." as you did above. In the other topic I see you managed to get past that step.
I see you get some output after executing envsetup.sh and it seems like this is related to the device tree.
Can you please share what you did with the device tree before attempting to compile twrp? I'd like to try myself but I can't find clear instructions.
radoinc said:
I'm trying to replicate your steps but I get the same "Can not locate config makefile for product "twrp_odin"." as you did above. In the other topic I see you managed to get past that step.
I see you get some output after executing envsetup.sh and it seems like this is related to the device tree.
Can you please share what you did with the device tree before attempting to compile twrp? I'd like to try myself but I can't find clear instructions.
Click to expand...
Click to collapse
Acutally i left it completely unchanged, the only thing i did was to change the repository. I deleted the aosp-repository and took the omni-twrp-repository
(https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni)
mkdir twrp
cd twrp
repo init -u git://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git -b twrp-10.0
repo sync
after syncing was complete, i followed these instructions
4. Build TWRP from source
A Python library/script to automatically generate TWRP-compatible device tree from a boot/recovery image - twrpdtgen/twrpdtgen
github-wiki-see.page
SanHelios said:
Acutally i left it completely unchanged, the only thing i did was to change the repository. I deleted the aosp-repository and took the omni-twrp-repository
(https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni)
mkdir twrp
cd twrp
repo init -u git://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git -b twrp-10.0
repo sync
after syncing was complete, i followed these instructions
4. Build TWRP from source
A Python library/script to automatically generate TWRP-compatible device tree from a boot/recovery image - twrpdtgen/twrpdtgen
github-wiki-see.page
Click to expand...
Click to collapse
Thanks! Now I managed to get the same result as you. The error seems to be raised by mkbootimg.py:
Python:
def write_header(args):
BOOT_IMAGE_HEADER_V1_SIZE = 1648
BOOT_IMAGE_HEADER_V2_SIZE = 1660
BOOT_MAGIC = 'ANDROID!'.encode()
if (args.header_version > 2):
raise ValueError('Boot header version %d not supported' % args.header_version)
To me it seems like this Omni repo includes old version of mkbootimg.py, because in the google repos I can see that the current version of this function looks like this:
Python:
def write_header(args):
if args.header_version > 4:
raise ValueError(
f'Boot header version {args.header_version} not supported')
if args.header_version in {3, 4}:
return write_header_v3_and_above(args)
It seems like Boot header version 3 was introduced with Android 11: https://source.android.com/devices/bootloader/boot-image-header
I think we can't do much with the Omnia repos until they get updated with current mkbootimg.
radoinc said:
Thanks! Now I managed to get the same result as you. The error seems to be raised by mkbootimg.py:
Python:
def write_header(args):
BOOT_IMAGE_HEADER_V1_SIZE = 1648
BOOT_IMAGE_HEADER_V2_SIZE = 1660
BOOT_MAGIC = 'ANDROID!'.encode()
if (args.header_version > 2):
raise ValueError('Boot header version %d not supported' % args.header_version)
To me it seems like this Omni repo includes old version of mkbootimg.py, because in the google repos I can see that the current version of this function looks like this:
Python:
def write_header(args):
if args.header_version > 4:
raise ValueError(
f'Boot header version {args.header_version} not supported')
if args.header_version in {3, 4}:
return write_header_v3_and_above(args)
It seems like Boot header version 3 was introduced with Android 11: https://source.android.com/devices/bootloader/boot-image-header
I think we can't do much with the Omnia repos until they get updated with current mkbootimg.
Click to expand...
Click to collapse
My question is, do the makefiles from the devicetree need to be adjusted or completely rebuild to android 11 parameters? I.e. rhe command "add_lunch_combo" is obsolete and "COMMAND_LUNCH_CHOICES" took its place..
Sorry in advance for this nooby questions...

Categories

Resources