[TUTORIAL/REFERENCE] Building the android kernel (Mac OS) - Android Software/Hacking General [Developers Only]

Many people have MacBooks and they MacBooks have a terminal. This terminal runs bash and other unix commands, so why can't we compile a kernel. That's what I thought at first... Then the errors started...
I will not be responsible if you bork, brick, or blow up your devices in the process​
Notes: This is using clang, gcc should also work using this procedure, just with a few alterations exactly like compiling on linux
This guide is intended to help people compile their kernel on OSX
Step 1: Getting the dependencies and setting up build environment
Installing package managers:
Xcode HAS to be installed for this to work! If you just want the command line tools, type "xcode-select --install". To set the OS to use the command line tools from the app, type "xcode-select --switch /Applications/Xcode.app/Contents/Developer"
Install homebrew here: http://brew.sh
Install macports here (Follow source instructions): http://https://guide.macports.org/chunked/installing.macports.html
Set up build environment:
The android developers website gives great instructions on how to do this, but they use macports, which I tend to stay away from. However, this guide will use macports until I can figure out the homebrew alternatives for these packages
MacPorts packages: gmake libsdl git gnupg bison (exclude the git packages if you already have them)
Reference site: https://source.android.com/setup/build/initializing
Case Sensitive disk image - Android anything won't build unless the filesystem is case sensitive (APFS isn't), so we need to create a sparseimage for it
Go into disk utility and hit file, new image, blank image or Command-N
Set (in this order) Image Format: sparse disk image, Format: Mac OS Extended (Journaled, case-sensitive), Size: 20GB, Name: Android
Create the new image
Edit your bash profile by entering "open -a TextEdit ~/.bash_profile" and make a mountAndroid function
mountandroid() { hdiutil attach ~/android.sparseimage -mountpoint /Volumes/android; }
Open a new terminal window and type mountandroid
Your new disk image is mounted at /Volumes/android
Setting the PATH:
Open your bash_profile
add this line:
export PATH="/usr/local/bin:$PATH"
export PATH="/opt/local/bin:$PATH"
Save and open a new window
Step 2 - Cloning the kernel: I don't know where you get your kernels from, but you should know the basics on how to clone a source, clone the source to /Volumes/android
Step 3 - Getting the Toolchain: For now, I use prebuilts via the NDK, However, Crosstool-ng is a viable option
Download the NDK here https://developer.android.com/ndk/downloads/
Make a standalone Toolchain inside your case sensitive image (For arm64 devices: use the guide for BOTH arm and arm64)
https://developer.android.com/ndk/guides/standalone_toolchain
Step 4 - Linking it all together:
Creating a script to use (inside kernel source folder)
make O=out ARCH=arm64 **Your_defconfig**
make -j4 O=out ARCH=arm64 CC='/Volumes/android/**Toolchain folder**/bin/clang' CLANG_TRIPLE=aarch64-linux-gnu CROSS_COMPILE_ARM32='/Volumes/android/**Toolchain arm folder**/bin/arm-linux-androideabi-' CROSS_COMPILE='/Volumes/android/**Toolchain arm folder**/bin/aarch64-linux-android-'
The arm64 devices have to use the CROSS_COMPILE_ARM32 line, if you don't have this, just omit the line
Then just type ./**Script Name**.sh (make sure to chmod +x or 755 it first) and you're good to go!
Step 5 - Errors... Those stupid errors!: There are a few known errors that can be easily fixed, but they're very annoying
elf.h error - Open the file /usr/local/include and make a new file, elf.h
Paste this in there:
#include "../opt/libelf/include/libelf/gelf.h"
#define R_386_NONE 0
#define R_386_32 1
#define R_386_PC32 2
#define R_ARM_NONE 0
#define R_ARM_PC24 1
#define R_ARM_ABS32 2
#define R_MIPS_NONE 0
#define R_MIPS_16 1
#define R_MIPS_32 2
#define R_MIPS_REL32 3
#define R_MIPS_26 4
#define R_MIPS_HI16 5
#define R_MIPS_LO16 6
#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
#define R_PPC_ADDR32 1 /* 32bit absolute address */
#define R_PPC64_ADDR64 38 /* doubleword64 S + A */
#define R_SH_DIR32 1
#define R_SPARC_64 32 /* Direct 64 bit */
#define R_X86_64_64 1 /* Direct 64 bit */
#define R_390_32 4 /* Direct 32 bit. */
#define R_390_64 22 /* Direct 64 bit. */
#define R_MIPS_64 18
#define EF_ARM_EABIMASK 0XFF000000
#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
vdsomunge.c errors (all fixed with this simple file from torvalds himself)
Replace your arch/arm/vdso/vdsomunge.c file with this one
vdso_offset_sigtramp undeclared (shows signal.c in terminal)
change the file arch/arm64/vdso/gen_vdso_offsets.sh
Replace the last line to this - 's/^\([0-9a-fA-F]*\) . VDSO_\([a-zA-Z0-9_]*\)$/\#define vdso_offset_\2 0x\1/p'
This removes the "t" in the "2t0x" part
So, after this, your kernel should be built without any complications! I have some requests in the post below, so help me out and gimme a thanks!

Things I need help finding:
Building crosstool-ng on mac
building Dragon TC on mac or a clang 8.0 toolchain
Please put your solutions in the comments so I can include them in the main thread

thanks for the guide!
I'm having one problem though
Code:
Undefined symbols for architecture x86_64:
"_OPENSSL_init_crypto", referenced from:
_main in cc6WbheD.o
ld: symbol(s) not found for architecture x86_64

I posted a complete revision alongside a recent kernel, but below is a summary of the changes / updates for using this guide in 2021
StarKissed/StarKissed_I005_1
Contribute to StarKissed/StarKissed_I005_1 development by creating an account on GitHub.
github.com
Disclaimer: As of June 2021, Android no longer supports building on Mac
arch/arm64/vdso/gen_vdso_offsets.sh =>
arch/arm64/kernel/vdso/gen_vdso_offsets.sh
Code:
brew install gnu-sed
export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH
readlink: illegal option -- f
usage: readlink [-n] [file ...]
Code:
brew install coreutils
export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH
find: -printf: unknown primary or operator
Code:
brew install findutils
export PATH=/usr/local/opt/findutils/libexec/gnubin:$PATH
Homebrew alternatives
Code:
brew install make
brew install sdl
brew install gnupg
brew install bison
Quick Homebrew Alternatives
Enter "homebrew [command name]" in google search
Enter command from https://formulae.brew.sh/formula/

juampapo546 said:
thanks for the guide!
I'm having one problem though
Code:
Undefined symbols for architecture x86_64:
"_OPENSSL_init_crypto", referenced from:
_main in cc6WbheD.o
ld: symbol(s) not found for architecture x86_64
Click to expand...
Click to collapse
Code:
brew install openssl
export PKG_CONFIG_PATH=/usr/local/opt/[email protected]/lib/pkgconfig:$PKG_CONFIG_PATH
You may also need to explicitly include in scripts/Makefile
Code:
HOST_EXTRACFLAGS += -I$(srctree)/tools/include
ifeq ($(shell uname),Darwin)
HOST_EXTRACFLAGS += -I/usr/local/opt/[email protected]/include -L/usr/local/opt/[email protected]/lib
endif

Related

Got agcc, got Android source compiled, got Hello, World to work. How to do bash?

How do I port bash? DO I just export CC=~/bin/agcc and run make?
Is this the same with any console application I wish to port onto Android?
Where I'm at:
I got Hello, world! to work. The a.out binary gave this output warning during ld linkage - but the a.out binary ran on my Android phone under console emulation for sure!
Code:
[email protected]:~/mydroid/xdev$ cat hello.c
#include <stdio.h>
int main() {
printf("Hello, world!\n");
}
[email protected]:~/mydroid/xdev$ agcc hello.c
/home/kinesis/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/bin/ld: warning: /tmp/ccpQIsji.o uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
[email protected]:~/mydroid/xdev$ file a.out
a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[email protected]:~/mydroid/xdev$
I can confirm that bash will work using this guide and the CodeSourcery G++ toolkit.
http://www.kbrandt.com/2009/06/how-to-cross-compile-the-bash-shell-for-android-15.html
The joy one feels after executing their own ARM bash binary is priceless.

[Resolved] [SOLVED] "[arch/x86/kernel] Error 2" Error while compiling X86 Kernel

So after I successfully install kali linux on my Galaxy tab 3 10.1 P5220 LTE, I decided to mod the original kernel from the opensource samsung site. Everything goes well until i am going to compile it with "make" or "make ARCH=i386",it keep showing the following error:
This is the error in the terminal,
Code:
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.
CHK include/linux/version.h
CHK include/generated/utsrelease.h
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CC arch/x86/kernel/apic/io_apic.o
cc1: warnings being treated as errors
arch/x86/kernel/apic/io_apic.c: In function 'ioapic_read_entry':
arch/x86/kernel/apic/io_apic.c:471: error: 'eu' is used uninitialized in this function
make[3]: *** [arch/x86/kernel/apic/io_apic.o] Error 1
make[2]: *** [arch/x86/kernel/apic] Error 2
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2
and this is Line 422 to line 480 of io_apic.o
Code:
static void __io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
{
struct io_apic __iomem *io_apic = io_apic_base(apic);
if (sis_apic_bug)
writel(reg, &io_apic->index);
writel(value, &io_apic->data);
}
static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
{
struct irq_pin_list *entry;
unsigned long flags;
raw_spin_lock_irqsave(&ioapic_lock, flags);
for_each_irq_pin(entry, cfg->irq_2_pin) {
unsigned int reg;
int pin;
pin = entry->pin;
reg = io_apic_read(entry->apic, 0x10 + pin*2);
/* Is the remote IRR bit set? */
if (reg & IO_APIC_REDIR_REMOTE_IRR) {
raw_spin_unlock_irqrestore(&ioapic_lock, flags);
return true;
}
}
raw_spin_unlock_irqrestore(&ioapic_lock, flags);
return false;
}
union entry_union {
struct { u32 w1, w2; };
struct IO_APIC_route_entry entry;
};
static struct IO_APIC_route_entry __ioapic_read_entry(int apic, int pin)
{
union entry_union eu;
eu.w1 = io_apic_read(apic, 0x10 + 2 * pin);
eu.w2 = io_apic_read(apic, 0x11 + 2 * pin);
return eu.entry;
}
static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
{
union entry_union eu;
unsigned long flags;
raw_spin_lock_irqsave(&ioapic_lock, flags);
eu.entry = __ioapic_read_entry(apic, pin);
raw_spin_unlock_irqrestore(&ioapic_lock, flags);
return eu.entry;
}
so is there anything that i can do to fix this error and compile successfully? I am using Kali Linux to compile it btw. Thanks in advance!
My Suggestion, not a complain.
First I suggest you delete [Urgent] from Title. Why, because to the one that could help you that [Urgent] means nothing. In fact there is people here that may skip your thread just not to get involved in this [Urgent] matter. Sadly out TAB3 10.1 tablet has very little audience, so you never know when you question in fact will be answer, if they are answer at all.
On the original question. problem compiling X86 Kernel.
You need to compile all this kernels with gcc 4.6. If not you end up in all sort of errors. So if you had install a new Linux Distro, the first thing you need to do is to install gcc 4.6 and make it your default compilation environment.
In Ubuntu this is done with
Code:
sudo apt-get install gcc-4.6 g++-4.6 gcc-4.6-multilib g++-4.6-multilib
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
I suggest you google for help since you claim to use Kali (not Ubuntu).
You need to ensure that you use a 32bit environment!!! So in my case I do own a 64bit Desktop but I have install a 32bit version of Ubuntu to ensure maximum compatibility and less none sense errors.
Even more Readme tell us .
Code:
- get Toolchain
From google aosp(http://source.android.com/source/downloading.html)
recommend : android-4.2.2_r1 release.
But ripo of android-4.2.2_r1 release takes for ever and finally is incomplete!.
I suggest you get AndroidNDK and setup at least 4.2.2, I my self download usually "android-14" to ensure that my compilations of NDK are as compatible as it can be with older android phone models. But For Kernel Toolchain almost any one is good.
So you toolchain should be at
Code:
androidndk/toolchains/x86-4.6/prebuilt/linux-x86/bin
So your kernel Makefile modification should look like
Code:
CROSS_COMPILE ?= /<user directory>/bin/androidndk/toolchains/x86-4.6/prebuilt/linux-x86/bin/i686-linux-android-
I hope this help you and others if needed.
Now I took your last post and copied here
Jacker31 said:
Well it have been a long story, I posted a thread about my error, here : http://forum.xda-developers.com/general/help/question-error-2-error-compiling-x86-t3047439 but in the end i found out i used the wrong toolchain. So i redownloaded the correct version and try again. It works but another error popup, its about some Broadcom error. I can successfully compile it after i disabled it in menuconfig. But instead of getting a Zimage i got a Bzimage. So Idk what to do with it. I googled a tones of information but still have no idea what to do with that bzimage. I used Kali Linux to compile and those kernel files are from http://opensource.samsung.com/reception/receptionSub.do?method=sub&sub=F&searchValue=p5220 GT-P5220_SEA_KK_Opensource. Now i am trying to install builduntu and try to compile it again. Any tips or helps? especially with that bzimage
Click to expand...
Click to collapse
I have compiled the original open source kernels without errors. As why you get "Broadcom error." I do not Know. I suggest You ensure you can compile the original sources of the kernel without errors before you begin any modification.
I Know when you compile successfully you end up with bzImage inside "arch/x86/boot". This is fine. the difference between "bzImage" and "zImage" is the compression method. It is seems that the bootloader can detect and adjust to any of those formats. So you only need to rename it to where ever is you need. To include bzImage in a boot.img I use AIK as suggested by my friend moonbutt74.
http://forum.xda-developers.com/showthread.php?t=2073775
So in my case I almost always end up renaming "bzImage" to "boot.img-zImage" and placecing it inside the "AIK/split_img" folder.
r2d23cpo said:
My Suggestion, not a complain.
First I suggest you delete [Urgent] from Title. Why, because to the one that could help you that [Urgent] means nothing. In fact there is people here that may skip your thread just not to get involved in this [Urgent] matter. Sadly out TAB3 10.1 tablet has very little audience, so you never know when you question in fact will be answer, if they are answer at all.
On the original question. problem compiling X86 Kernel.
You need to compile all this kernels with gcc 4.6. If not you end up in all sort of errors. So if you had install a new Linux Distro, the first thing you need to do is to install gcc 4.6 and make it your default compilation environment.
In Ubuntu this is done with
Code:
sudo apt-get install gcc-4.6 g++-4.6 gcc-4.6-multilib g++-4.6-multilib
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
I suggest you google for help since you claim to use Kali (not Ubuntu).
You need to ensure that you use a 32bit environment!!! So in my case I do own a 64bit Desktop but I have install a 32bit version of Ubuntu to ensure maximum compatibility and less none sense errors.
Even more Readme tell us .
Code:
- get Toolchain
From google aosp(http://source.android.com/source/downloading.html)
recommend : android-4.2.2_r1 release.
But ripo of android-4.2.2_r1 release takes for ever and finally is incomplete!.
I suggest you get AndroidNDK and setup at least 4.2.2, I my self download usually "android-14" to ensure that my compilations of NDK are as compatible as it can be with older android phone models. But For Kernel Toolchain almost any one is good.
So you toolchain should be at
Code:
androidndk/toolchains/x86-4.6/prebuilt/linux-x86/bin
So your kernel Makefile modification should look like
Code:
CROSS_COMPILE ?= /<user directory>/bin/androidndk/toolchains/x86-4.6/prebuilt/linux-x86/bin/i686-linux-android-
I hope this help you and others if needed.
Now I took your last post and copied here
I have compiled the original open source kernels without errors. As why you get "Broadcom error." I do not Know. I suggest You ensure you can compile the original sources of the kernel without errors before you begin any modification.
I Know when you compile successfully you end up with bzImage inside "arch/x86/boot". This is fine. the difference between "bzImage" and "zImage" is the compression method. It is seems that the bootloader can detect and adjust to any of those formats. So you only need to rename it to where ever is you need. To include bzImage in a boot.img I use AIK as suggested by my friend moonbutt74.
http://forum.xda-developers.com/showthread.php?t=2073775
So in my case I almost always end up renaming "bzImage" to "boot.img-zImage" and placecing it inside the "AIK/split_img" folder.
Click to expand...
Click to collapse
Thanks for that reply, i already fix that error by downloading the exact same toolchain in the README_KERNEL. Now i am trying to workout why my fastboot cannot detect my p5220 and how to compile it into a flashable .zip file so i can flash it with cwm or philz.
Are you planning to release a tutorial how you managed to install kali on your galaxy tab?
Sure, I will write it how, you will see it in any minutes now.
Are you planning to release a tutorial how you managed to install kali on your galaxy tab?
Click to expand...
Click to collapse
@Max4000
http://forum.xda-developers.com/gal...-to-run-kali-linux-galaxy-tab-3-10-1-t3050203
here you go...

[Guide][Q&A][How To Build SOKP From Source][ Build SOKP for any open source** device]

[Guide][Q&A][How To Build SOKP From Source][ Build SOKP for any open source** device]
Building SOKP from source for Any Device !!!​
Some Important Links Of SOKP
Official Web Page
Features of SOKP
Change-Logs of SOKP
Source Code
Credits:
@Stephen for his guide written to build cm for Shamu.
Part-1 Preparation : Setting up Build Environment & Downloading SOKP Source*
This guide will walk you through, how to build SOKP for any other device source. To complete this, you will need a PC with either virtual box setup and Ubuntu or duel boot Windows and Ubuntu or else system with ubuntu installed as standalone OS. I recommend Ubuntu 14.04LTS version of Ubuntu for this purpose .
Recommended configuration of PC required for build Process:
Processor : Intel I5
Ram * * * : Min 8GB
Hard Disk : 250 GB
OS * * * *: Ubuntu 14.04 LTS
A Decent net connection with unlimited Data Plan and min of 1Mbps speed .[Dont try this in 512Kbps net connection]
I won't go into too much detail on how to setup Ubuntu on your PC. For this guide, you do need to know the basic commands and how to use Ubuntu.
Some use-full links :
A list of basic Ubuntu commands
Ubuntu: A Beginner’s Guide
Virtual Box
Ubuntu ISO
Disclaimer:
I am not responsible for any damage done to your device, thermal nuclear war etc.
Please use at your own risk. Your warranty may be affected if you install a custom rom.
I am also not responsible if you go over your payment plan when downloading the source code.
It is large over 25gb+ so be careful *!!!!
So assuming you have Ubuntu 14.* set up, you will need to now set up your build environment
First on their guide it talks about installing the SDK tools. You do not need these to build the ROM. You only really need ADB commands. I installed fastboot as well.
Install ADB command
Code:
sudo apt-get install android-tools-adb
Install Fastboot command
Code:
sudo apt-get install android-tools-fastboot
Install Java
Code:
sudo apt-get install openjdk-7-jdk
Setting up the build Environment:
Code:
sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev*
git gnupg ccache lzop flex bison gperf build-essential zip curl libc6-dev lib32ncurses5-dev x11proto-core-dev lib32z1-dev g++-multilib tofrodos python-markdown libxml2-utils xsltproc libreadline6-dev lib32readline-gplv2-dev libncurses5-dev bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev phablet-tools pngquant*
If you have a 64bit PC install the following:*
Code:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
Setting your build directory - This can be any folder you want. for my example I will use sokp as my root folder. Remember that Ubuntu is case sensitive when switching folders.*
Code:
mkdir -p ~/sokp
Install Repo
Code:
mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo
Now for the good bit! We are about to download the source for SOKP *Warning: The download is large and will take a long time to download. *I believe the download is 25gb+ in size, so you will have to take this into consideration. Note: I will not be held responsible if you go over your payment plan with your service provider.
Identify Yourself to the Repo*
Code:
git config --global user.email "[email protected]"*
git config --global user.name "yourpreferredusername"
Initialize the SOKP source repository
Code:
cd ~/sokp - this is your root folder
repo init -u repo init -u git://github.com/SOKP/platform_manifest.git -b sokp-l5.1
Download the source code
Code:
repo sync
or
Code:
repo sync -f
If repo sync errors and stops during download, don't worry you can simply run the command again and it will pick up were it left off.When you have completed the download run it again, to make sure it completes with out any errors. This way you know you have downloaded the full source code.*
Backup your home directory[optional]
Also at this point, what I do is make a backup using the inbuilt backup software in ubuntu. This backs up my entire home directory to a secondary hard drive I have set up in my PC. This way if I have any issues and need to start from scratch, I can simply delete my android directory, then restore from backup.*
This will Finish your Preparation Part .
STEP 2: Adding device support to SOKP:​
Now, Lets add the device specific trees:
Add your own device tree in the local manifest. Here in sokp we use sokp_manifest.xml
For this, create a new file .repo/local_manifests/sokp_manifest.xml, & use something in similar terms:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
* <project name="device_samsun_trltexx" path="device/samsung/trltexx" remote="github" revision="sokp-l5.1" />
</manifest>
CAUTION: Your device tree, kernel source, vendor props etc WILL be different. Search & find out where your device specific sources are located.
After adding this do a
Code:
repo sync
so that device related trees are downloaded
After Downloading the device tree you need to add some files in order to compile SOKP. The files which are needed to add and modified are mentioned bellow.
1)sokp.mk*
Create a file called sokp.mk in device tree and add all informations related to your device as mentioned bellow.[I have taken Note-4[trltexx] as example so relpace it by your device. ]
The General templet of sokp.mk is follows*
Code:
#
# Copyright (C) 2015 The Sonic Open Kang Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# * * *http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
$(call inherit-product, device/samsung/trltexx/full_trltexx.mk)
# Enhanced NFC
$(call inherit-product, vendor/sokp/config/nfc_enhanced.mk)
# Inherit common SOKP phone.
$(call inherit-product, vendor/sokp/config/common_full_phone.mk)
PRODUCT_DEVICE := trltexx
PRODUCT_NAME := sokp_trltexx
Example*
2)sokp.dependencies*
This file will contain details of all discrepancy trees which required[kernel, vendor, etc] to compile the SOKP. This file will fetch required trees when build process starts so this must be filled with proper remote and branch details.
Create a file called sokp.dependencies *in device tree and add all informations trees which is needed by *your device as mentioned bellow
A Example of sokp.dependencies the contents of this file will change from device to device how ever templet is common.
Code:
[
* {
* * "repository": "device_samsung_trlte-common",
* * "target_path": "device/samsung/trlte-common",
"branch": * * *"sokp-l5.1"
* },
* {
* * "repository": "device_qcom_common",
* * "target_path": "device/qcom/common",
"branch": * * *"sokp-l5.1"
* },
* {
* * "repository": "device_samsung_qcom-common",
* * "target_path": "device/samsung/qcom-common",
"branch": * * *"sokp-l5.1"
* },
* {
* * "repository": "kernel_samsung_trlte",
* * "target_path": "kernel/samsung/trlte",
"branch": * * *"sokp-l5.1"
* },
* {
* * "repository": *"proprietary_vendor_samsung",
* * "target_path": "vendor/samsung",
* * "branch": * * *"sokp-l5.1"
* }
]
Here we take trltexx as device and added its kernel ,vendor and hardware dependencies in file which will fetch when you starts build process.*
So you need to mention trees of kernel, device common, vendor , and hardware in above file with proper branch name and remote .
Example
3)vendorsetup.sh
Create a vendorsetup.sh in your device tree and fill it with your device details as mentioned bellow
Code:
add_lunch_combo sokp_trltexx-eng
Example
4)BoardConfig.mk
TWRP Flags:
Since we use TWRP as boot able recovery in SOKP you need to add some flags related to TWRP in BoardConfig.mk in your device tree.
Add screen resolution of your device also here in BoardConfig.mk
Setting SELinux Permissive:
SOKP needs a SELinux Permissive state. so we should add this to BOARD_KERNEL_CMDLINE in BoardConfig.mk
Code:
androidboot.selinux=permissive
Example
5)Adding your device in Vendor SOKP :
Open the file sokp.devices in directory vendor/sokp/ of your source and your device name in sokp.devices file*
Example
STEP-3: Building SOKP​
By assuming you have completed step-1 and step-2 successfully lets go to final step of building SOKP
In order to Build SOKP you need to navigate to source folder via terminal which you have download in step-1 ie sokp*
Now Excute following commands in terminal to start build process
Code:
cd (source folder )
*
ie (source folder ) is sokp here in this guide*
&*
Code:
. build/envsetup.sh
After initiating build process execute bellow mentioned command to start build
Code:
brunch (device)]
*
ie (device) is trltexx in this guide ..you need to input your device name *in place (device) when you are building sokp for *your required device.
If all the 3 steps are done correctly now the building should start .
initially it will look for dependency *in sokp.dependencies and it will fetch device dependent hardware, vendor ,kernel tress as we mentioned in part-2.
If you face any build related issues feel free to create a post here we are most happy to help you in order to complete you build .
MISC*
Turn on caching to speed up build
You can speed up subsequent builds by adding: the following command to your to your .bashrc file To do this close your terminal window and then reopen and type ./.bashrc - A text editor will open. Add this line to the bottom of the page.
Code:
export USE_CCACHE=1
Close the text editor and save the file
Then in the command window type the following. SOKP recommend 50GB, but you can change to what ever you want.
Code:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
one more in case
Thanks a lot for this amazing guide @Adi Shakthi aka AudioGod bro.

[Samsung] Unpacking 'Non-Standard' Boot.img Problems for 64 Bit Device

This is in relation to this and my post on xda.
The main reason I want to make a custom kernel is to gain root and once I successfully have then add other CPU governors, and since this is considered a low activity device on xda I will have to do this myself. Also I you are just gonna say use twrp to flash SuperSU, well I can't as it seems to not work with the device when its running Lollipop 5.1.1
Device Specifications:
Current Android Version: Android Lollipop 5.1.1
Chipset: Marvell Armada PXA1908 (Note: Due to this being a rarely used chip, the CF-Auto root won't work)
Custom Recovery Status: TWRP 3.0.2-0 (More on this later on)
Root Status (This is why I am here): Android KitKat 4.4.4 (Root) , Android Lollipop 5.1.1 (NO ROOT Yet)
ARMv8 64-bit
Now let's get into my steps up to the point and then my problem.
Note: In the kernel readme it states to use the toolchain 4.8 but when I use it, it complains of not being able to find gcc. Also in the read me it states "get Toolchain download and install arm-eabi-4.8 toolchain for ARM EABI.(64bit)" and when reading up on it, https://developer.android.com/ndk/guides/standalone_toolchain.html#syt , it says to use aarch64 for ARM 64 Bit devices.
Device Source Code can be found at Here
Code:
cd ~/android
export CROSS_COMPILE=~/android/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-
cd ~/android/kernel
make ARCH=arm64 pxa1908_xcover3lte_eur_defconfig
make ARCH=arm64
This outputs: Image, Image.gz, .dts and .dtb files.
Where's the kernel readme (I believe this hasn't been update since kitkat) says the output will be,
- Kernel : Kernel/arch/arm/boot/zImage
- module : Kernel/drivers/*/*.ko
Note: when trying to compile with the 32- bit ARM toolchain it fails, as the config is found in arm64, wheres other configs are found in arm.
So know I have a kernel (Image or Image.gz), and some .dts and .dtb files. Now to unpack boot.img, this is where problems occur. When trying to use tools like abootimg or the various different versions of unmkbootimg, they complain about non-standard boot.img.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
or
While also try saving it as a zImage when its meant to be a Image.gz, or they extract it without throwing any errors, but when looking at the extracted files with a hex editor, it is all 00 throughout the files, therefore a useless file.
So their for I tried manually unpacking with a hex editor and managed to get the kernel. Left is my Compiled and Right is the hex version.
Notice the difference in size, is this because the kernel in boot.img is stripped of its debugging items while mine isn't? If so I should look up on how to fix that.
But am having troubles trying to extract the ramdisk via hex.
So is anyone able to either:
a) Help me extract the boot.img properly (with tools like unmkbootimg or with a hex editor)
or
b) do this for me and explain how you achieved it so I myself is am able to do it when needed.
I have attached necessary files if you want to have a look at them yourself.
Any help is appreciated.
FIles(XDA attachments not working): https://drive.google.com/file/d/0B_5mtquWAP3MZjJQay1ERFprbnM/view?usp=sharing
After Numerous trial and error, I finally managed to output ramdisk.cpio.gz.
The start of a Gzip file in hex is, 1F 8B 08, therefor when using the search function in you had editor application you can narrow down your results to 1 or 2 files (2 Files for me as my kernel and ramdisk are both gzipped). You then follow it all the way down till you find a big bunch of zeros(seems like they are passing between files). When you reach the bunch of zeros include the first "00" at the end of the other hexidecial. E.G. End of one of my gzip files is "CE 24 00 00 00....00 (ZERO PADDING BETWEEN FILES), Threaded the end of my file is "CE 24 00".
Knowing this I was able to successfully extract and verify both my kernel and ramdisk files are correct.
Perl script for unpacking
Code:
#!/usr/bin/perl
######################################################################
#
# File : split_bootimg.pl
# Author(s) : William Enck <[email protected]>
# Description : Split appart an Android boot image created
# with mkbootimg. The format can be found in
# android-src/system/core/mkbootimg/bootimg.h
#
# Thanks to alansj on xda-developers.com for
# identifying the format in bootimg.h and
# describing initial instructions for splitting
# the boot.img file.
#
# Last Modified : Tue Dec 2 23:36:25 EST 2008
# By : William Enck <[email protected]>
#
# Copyright (c) 2008 William Enck
#
######################################################################
use strict;
use warnings;
# Turn on print flushing
$|++;
######################################################################
## Global Variables and Constants
my $SCRIPT = __FILE__;
my $IMAGE_FN = undef;
# Constants (from bootimg.h)
use constant BOOT_MAGIC => 'ANDROID!';
use constant BOOT_MAGIC_SIZE => 8;
use constant BOOT_NAME_SIZE => 16;
use constant BOOT_ARGS_SIZE => 512;
# Unsigned integers are 4 bytes
use constant UNSIGNED_SIZE => 4;
# Parsed Values
my $PAGE_SIZE = undef;
my $KERNEL_SIZE = undef;
my $RAMDISK_SIZE = undef;
my $SECOND_SIZE = undef;
my $DT_SIZE = undef;
######################################################################
## Main Code
&parse_cmdline();
&parse_header($IMAGE_FN);
=format (from bootimg.h)
** +-----------------+
** | boot header | 1 page
** +-----------------+
** | kernel | n pages
** +-----------------+
** | ramdisk | m pages
** +-----------------+
** | second stage | o pages
** +-----------------+
**
** n = (kernel_size + page_size - 1) / page_size
** m = (ramdisk_size + page_size - 1) / page_size
** o = (second_size + page_size - 1) / page_size
** p = (dt_size + page_size - 1) / page_size
**
** 0. all entities are page_size aligned in flash
** 1. kernel and ramdisk are required (size != 0)
** 2. second is optional (second_size == 0 -> no second)
** 3. load each element (kernel, ramdisk, second) at
** the specified physical address (kernel_addr, etc)
** 4. prepare tags at tag_addr. kernel_args[] is
** appended to the kernel commandline in the tags.
** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
** 6. if second_size != 0: jump to second_addr
** else: jump to kernel_addr*/
=cut
my $n = int(($KERNEL_SIZE + $PAGE_SIZE - 1) / $PAGE_SIZE);
my $m = int(($RAMDISK_SIZE + $PAGE_SIZE - 1) / $PAGE_SIZE);
my $o = int(($SECOND_SIZE + $PAGE_SIZE - 1) / $PAGE_SIZE);
my $p = int(($DT_SIZE + $PAGE_SIZE - 1) / $PAGE_SIZE);
my $k_offset = $PAGE_SIZE;
my $r_offset = $k_offset + ($n * $PAGE_SIZE);
my $s_offset = $r_offset + ($m * $PAGE_SIZE);
my $t_offset = $s_offset + ($o * $PAGE_SIZE);
(my $base = $IMAGE_FN) =~ s/.*\/(.*)$/$1/;
my $k_file = "kernel.gz";
my $r_file = "ramdisk.gz";
my $s_file = "second.gz";
my $t_file = "dt.img";
# The kernel is always there
print "Writing $k_file ...";
&dump_file($IMAGE_FN, $k_file, $k_offset, $KERNEL_SIZE);
print " complete.\n";
# The ramdisk is always there
print "Writing $r_file ...";
&dump_file($IMAGE_FN, $r_file, $r_offset, $RAMDISK_SIZE);
print " complete.\n";
# The Second stage bootloader is optional
unless ($SECOND_SIZE == 0) {
print "Writing $s_file ...";
&dump_file($IMAGE_FN, $s_file, $s_offset, $SECOND_SIZE);
print " complete.\n";
}
# The DT.img stage is optional
unless ($DT_SIZE == 0) {
print "Writing $t_file ...";
&dump_file($IMAGE_FN, $t_file, $t_offset, $DT_SIZE);
print " complete.\n";
}
######################################################################
## Supporting Subroutines
=header_format (from bootimg.h)
struct boot_img_hdr
{
unsigned char magic[BOOT_MAGIC_SIZE];
unsigned kernel_size; /* size in bytes */
unsigned kernel_addr; /* physical load addr */
unsigned ramdisk_size; /* size in bytes */
unsigned ramdisk_addr; /* physical load addr */
unsigned second_size; /* size in bytes */
unsigned second_addr; /* physical load addr */
uint32_t dt_size; /* device tree size in bytes */
uint32_t dt_addr; /* device tree address in bytes */
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
unsigned char cmdline[BOOT_ARGS_SIZE];
unsigned id[8]; /* timestamp / checksum / sha1 / etc */
};
=cut
sub parse_header {
my ($fn) = @_;
my $buf = undef;
open INF, $fn or die "Could not open $fn: $!\n";
binmode INF;
# Read the Magic
read(INF, $buf, BOOT_MAGIC_SIZE);
unless ($buf eq BOOT_MAGIC) {
die "Android Magic not found in $fn. Giving up.\n";
}
# Read kernel size and address (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE * 2);
my ($k_size, $k_addr) = unpack("VV", $buf);
# Read ramdisk size and address (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE * 2);
my ($r_size, $r_addr) = unpack("VV", $buf);
# Read second size and address (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE * 2);
my ($s_size, $s_addr) = unpack("VV", $buf);
# Read dt size and address (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE * 2);
my ($t_size, $t_addr) = unpack("VV", $buf);
# Ignore tags_addr
read(INF, $buf, UNSIGNED_SIZE);
# get the page size (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE);
my ($p_size) = unpack("V", $buf);
# Read the name (board name)
read(INF, $buf, BOOT_NAME_SIZE);
my $name = $buf;
# Read the command line
read(INF, $buf, BOOT_ARGS_SIZE);
my $cmdline = $buf;
# Ignore the id
read(INF, $buf, UNSIGNED_SIZE * 8);
# Close the file
close INF;
# Print important values
printf "Page size: %d (0x%08x)\n", $p_size, $p_size;
printf "Kernel size: %d (0x%08x)\n", $k_size, $k_size;
printf "Ramdisk size: %d (0x%08x)\n", $r_size, $r_size;
printf "Second size: %d (0x%08x)\n", $s_size, $s_size;
printf "dt size: %d (0x%08x)\n", $t_size, $t_size;
printf "Board name: $name\n";
printf "Command line: $cmdline\n";
# Save the values
$PAGE_SIZE = $p_size;
$KERNEL_SIZE = $k_size;
$RAMDISK_SIZE = $r_size;
$SECOND_SIZE = $s_size;
$DT_SIZE = $t_size;
}
sub dump_file {
my ($infn, $outfn, $offset, $size) = @_;
my $buf = undef;
open INF, $infn or die "Could not open $infn: $!\n";
open OUTF, ">$outfn" or die "Could not open $outfn: $!\n";
binmode INF;
binmode OUTF;
seek(INF, $offset, 0) or die "Could not seek in $infn: $!\n";
read(INF, $buf, $size) or die "Could not read $infn: $!\n";
print OUTF $buf or die "Could not write $outfn: $!\n";
close INF;
close OUTF;
}
######################################################################
## Configuration Subroutines
sub parse_cmdline {
unless ($#ARGV == 0) {
die "Usage: $SCRIPT boot.img\n";
}
$IMAGE_FN = $ARGV[0];
}
The reason why none of tools support our image is because it has different header format. For example mkbootimg:
Code:
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
unsigned unused[2]; /* future expansion: should be 0 */
but we need for our kernel such a code
Code:
unsigned dt_size; /* device tree size in bytes */
unsigned dt_addr; /* device tree address in bytes */
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
akuhak said:
Perl script for unpacking
The reason why none of tools support our image is because it has different header format. For example mkbootimg:but we need for our kernel such a code
Click to expand...
Click to collapse
Yes @akuhak I had realised that about a week ago (header sizes), also another thing is most of these tools deal with a zImage, where's I boot.img has a hOmage (which is a 64 byte uImage header followed by the kernel. I have succesfully unpacked this boot.img (the kernel, ramdisk and dt.img).
Now if this script works it will be good for other users, but for me my need has already been done.
I am just having trouble trying to get this booting up on my phone when I repack it (I haven't been paying to much attention to this project becuse of exam revision)
Edit: I have tested it and verified thatvit works by comparing the files produced by hand and the files produced by this script via the sha1sum command. I have uploaded it onto my xCover3 post linking back here and giving the credit to you for posting it here. Thanks for your help
It easier to found already existing tool. Our device (I am owning Xcover 3 too) has pxa1088 board. It is known that similar boards has similar structure. So i found these thread github(dot)com/kumajaya/degas-mkbootimg (he has also topic here in xda with his researchs)
It has the same board so these tools works fine for us The only difference I noticed - header unknown value is 0x03000000 for our device and 0x02000000 for Galaxy Tab 4. Maybe something wrong with dtb image - I didn't check these yet.
BTW our phone has same characteristics as Samsung SM-G531F Galaxy Grand Prime (same board, same cpu, same gpu, only screen a bit different) and grandprimevelte has 5.1.1 android onboard and working TWRP recovery (I was trying to flash it but was unsuccessful).
As for same board - For Example Xcover 3 Value Edition has completely different board (exynos3475 with mali-t760mp8 gpu). The same characteristics as for Samsung SM-J200 Galaxy J2. So we can use root methods from j2lte. This means - flash TWRP then install SuperSu zip archive - thats all.
But we cannot use TWRP from VE cause of very different hardwares.
Now Im working on improving degas utilities...
akuhak said:
It easier to found already existing tool. Our device (I am owning Xcover 3 too) has pxa1088 board. It is known that similar boards has similar structure. So i found these thread github(dot)com/kumajaya/degas-mkbootimg (he has also topic here in xda with his researchs)
It has the same board so these tools works fine for us The only difference I noticed - header unknown value is 0x03000000 for our device and 0x02000000 for Galaxy Tab 4. Maybe something wrong with dtb image - I didn't check these yet.
BTW our phone has same characteristics as Samsung SM-G531F Galaxy Grand Prime (same board, same cpu, same gpu, only screen a bit different) and grandprimevelte has 5.1.1 android onboard and working TWRP recovery (I was trying to flash it but was unsuccessful).
As for same board - For Example Xcover 3 Value Edition has completely different board (exynos3475 with mali-t760mp8 gpu). The same characteristics as for Samsung SM-J200 Galaxy J2. So we can use root methods from j2lte. This means - flash TWRP then install SuperSu zip archive - thats all.
But we cannot use TWRP from VE cause of very different hardwares.
Now Im working on improving degas utilities...
Click to expand...
Click to collapse
TWRP for xcover3 value editio came out about 7 says ago, and apparently one user has tried it and is working on their value edition version. (When I had a quick look at the source code yesterdau I happenend to notice it was a exynos board). I had previously tried the dagas scripts and they didn't work for our image at the time, yet your providerd version does. Great idea for searching up the board name (Marvell) as that is one of the only things I hadn't thought to Google.
Feel free to compile TWRP under android 5.1.1 branch. I can/will chime in with relevant info, as well as you can use info from TWRPs source code on the other twrp versions of our device. The only reason I haven't tried it as of yet is becuse i using my my mobile data 99% of the time and just don't have the data to so are downloading source code.
As for the dt.img, I veriefed the scripts output to my on manually extraction and it's the same for both files. (Sha1). But there is a little bit of trailing data (anything past SEANDROIDENFORCING) which is ignored, I am not sure id it's importance as of yet(other then SuperSu omits it from the boot.img when using SuperSu.zip.
Will pop back into here later today.
Ok I completed my tools collection for pxa1088
Source Code: github(dot)com/AKuHAK/pxa1088-mkbootimg
All necessary utilities can be achieved via my modified android_img_repack_tools repo: github(dot)com/AKuHAK/android_img_repack_tool
By just typing ./configure and make
If you are scared by traffic I released tools in one archive: github(dot)com/AKuHAK/android_img_repack_tools/releases/tag/1st.
How to use? I created README in github: github(dot)com/AKuHAK/pxa1088-mkbootimg/blob/master/README
Tools can extract and than pack back boot.img and recovery.img from XCover3. If you didn't extract uImage and dtb.img you can repack boot.img (recovery.img) without hash sum changes. If you extract zImage from uImage and than pack again in uImage your resulting uImage will be different cause uIimage header contain timestamp which will be taken from your PC settings. But resulting uImage still HAVE to be valid.
akuhak said:
Ok I completed my tools collection for pxa1088
Source Code: github(dot)com/AKuHAK/pxa1088-mkbootimg
All necessary utilities can be achieved via my modified android_img_repack_tools repo: github(dot)com/AKuHAK/android_img_repack_tool
By just typing ./configure and make
If you are scared by traffic I released tools in one archive: github(dot)com/AKuHAK/android_img_repack_tools/releases/tag/1st.
How to use? I created README in github: github(dot)com/AKuHAK/pxa1088-mkbootimg/blob/master/README
Tools can extract and than pack back boot.img and recovery.img from XCover3. If you didn't extract uImage and dtb.img you can repack boot.img (recovery.img) without hash sum changes. If you extract zImage from uImage and than pack again in uImage your resulting uImage will be different cause uIimage header contain timestamp which will be taken from your PC settings. But resulting uImage still HAVE to be valid.
Click to expand...
Click to collapse
Cool, will have a look tomorrow, it's hitting 1am for me now. Just one quick correction in the above post of yours. You mention zImage is extracted from the uImage. That is incorrect, is is in fact just a gzipped kernel image (Image.gz) not a zImage.
Yes I know both types of formats are compressed, but our device runs a armv8 cpu which is 64 bits (albeit our kernel is using a 32 but instruction set not a 64 bit instruction set and this means or OS is also 32 bits then). Apon reading the documentation found in the source code, you will realise that it can only handle a) the uncompressed kernel image (Image) or b) a compressed version of the image in gzip format (Image.gz). This is further proven when looking at the boot.img with a hex editor as you can clearly see 2 Files that start with the gzip header format (1F 8B 08) which are the gzipped kernel (also if you go back by 64 bytes then you will be at the start of the uImage header which holds or the appropriate info about the kernel.uImage file) and our ramdisk.
So hopefully you may have just made a mistake in the above post, but if not then you are outputting the incorrect file, which may confuse some users of they don't know much but just wanted to compile the kernel from source.
Sorry about the above rant, will now have a quick look at your github. Thanks for your work you have put into this phone.
Edit: when you mention the android img repack tools, did you use this, http://forum.xda-developers.com/showthread.php?t=2600364 , and if so what modification have you done since I already have the downloaded (used the last of my mobile data last month to get it)
EDIT2: Gonna have a mess around with them tomorrow. One question, sorry for sounding like a noon, but how does the compression differs between normal gzip and minigzip, how will these differences affect a repacked ramdisk and what got you onto that piece of info.
And I had a quick look at your github, seen all your ps2 back related source code.you using FMCB, a hardmod (a chip) or a internal hardrive via an Ethernet adapter. I see sp193, doctorxyz, have commuted to your repo, so sounds like your a ps2 dev, which is cool as ****
1) About zImage. Maybe I need to be more clear: Xcover 3 kernel has uImage onboard with gzip compression. You can extract kernel from that gzipped uImage - I just thought that zImage is name for extracted kernel Sorry if I made mistake in this case.
uImage can be created with use of u-boot tool (denx(dot)de/wiki/U-Boot/WebHome)
For example
Code:
mkimage -I boot.uImage
will provide such an information for our device
Code:
Image Name: pxa1928dkb linux
Created: Wed May 18 15:13:06 2016
Image Type: AArch64 Linux Kernel Image (gzip compressed)
Data Size: 6616640 Bytes = 6461.56 kB = 6.31 MB
Load Address: 01000000
Entry Point: 01000000
This information is extracted from uImage kernel (64 bytes). After header we will see our gzipped kernel - you are right. I just simply extracted it with 7zip from boot.img-uImage.
The difference is that your way didn't use uImage header at all - so you will be unable to pack it back without mistakes - or your gzipped kernel have to be completely the same in size which is almost impossible to achieve. With use of mkimage you can alter kernels (of course only if samsung doesnt check something else) and get correct uImage in output.
2) About difference between minigzip and gzip. In fact I don't know why its happened but I didn't found a reason why ramdisk have to be packed exactly with minigzip. I tried almost all flag combinations with gzip but I get the same result that was in output file only with minigzip
As about kernel it is packed with maximum compression without name with normal gzip.
So assuming minigzip for ramdisk, gzip -n -9 for kernel. But Im completely sure that we can use any combination of gzipers and image still will be valid (but of course will be different in hash). We need to use exactly this combination only if we need to get the same file.
3) Yes Im using exactly this kitchen - I just removed all branches except 5.1.1 added minigzip, my tools and u-boot mkimage tool generation.
4) Yes Im one of still alive ps2 developers I just realized that my phone isn't rooted and started to dig what I can do with it.
akuhak said:
1) About zImage. Maybe I need to be more clear: Xcover 3 kernel has uImage onboard with gzip compression. You can extract kernel from that gzipped uImage - I just thought that zImage is name for extracted kernel Sorry if I made mistake in this case.
uImage can be created with use of u-boot tool (denx(dot)de/wiki/U-Boot/WebHome)
For example will provide such an information for our device
This information is extracted from uImage kernel (64 bytes). After header we will see our gzipped kernel - you are right. I just simply extracted it with 7zip from boot.img-uImage.
The difference is that your way didn't use uImage header at all - so you will be unable to pack it back without mistakes - or your gzipped kernel have to be completely the same in size which is almost impossible to achieve. With use of mkimage you can alter kernels (of course only if samsung doesnt check something else) and get correct uImage in output.
2) About difference between minigzip and gzip. In fact I don't know why its happened but I didn't found a reason why ramdisk have to be packed exactly with minigzip. I tried almost all flag combinations with gzip but I get the same result that was in output file only with minigzip
As about kernel it is packed with maximum compression without name with normal gzip.
So assuming minigzip for ramdisk, gzip -n -9 for kernel. But Im completely sure that we can use any combination of gzipers and image still will be valid (but of course will be different in hash). We need to use exactly this combination only if we need to get the same file.
3) Yes Im using exactly this kitchen - I just removed all branches except 5.1.1 added minigzip, my tools and u-boot mkimage tool generation.
4) Yes Im one of still alive ps2 developers I just realized that my phone isn't rooted and started to dig what I can do with it.
Click to expand...
Click to collapse
1) yes a zImage is one type of you can get when compiling for ARM Devices, you Device is ARM64 so thierare differences. As for extracting the kernel I have always include the 64 byte header (since the middle of last week when I realised that it was there after running binwalk against the file). So yea your assumption was correct up untill a week ago.
2) Interesting. I will be sure to make changes accordingly.
3) cool I have 2 out of four so will download accordingly
4) cool, that the development scene is still going since the ps2 reached it 16 birthday this year.
5) as for root on this device chainfire has needed to go Systemless after/on 6.0 device or 5.1.1. Samsung devices, so to achive root on those devices it requires the modification of boot.img. what his SuperSu.zip does is patch the sepolicy file to allow 3 rules to run in permissive, modify other bits of the ramdisk accordingly to allow for it to run services and mount su.img at boot and it creates and place the necessary files inside su.img. I have completed all that by hand after reading his update-script numerous times. My only roadblock has been try to get the boot.img to boot.I was currently in the process, of try (I have tried alot of different ways including mkbootimg etc.) Manuallying replacing the ramdisk contents with the modified version, and then modify the bootmimg header to continue any modifed value (ramdisk size and dt offset) but am only partially done as I haven't had the chance the last few days to do it.
Awesome tool, unpack, repacked without a single modification and then ran "sha1sum" to both boot.img's and they are exactly the same. You are amazing . I have referenced your tools in this thread (http://forum.xda-developers.com/android/development/4-4-4-5-1-1-6-0-1-samsung-xcover3-t3465132 ) straight to your github. Now to try my modified ramdisk and see If my phone can boot it. Will post results soon.
======
Yes I can boot custom boot.img, without the SEANDORIDENFORCEING showing up. I can see my ramdisk changes, work, I can type adb root and I don't get the product in build message, but trying to do anything that requires root e.g. trying to push su.img to /data or /cache, gets me the error permission denied, but hey I am half way there to getting root.

[HOW-TO] Quick Guide on How to Compile Heimdall from Source in MacOS - OSX Yosemite

So, I was able to compile and flash my Galaxy J5 from my Mac OSX Yosemite command line, and I'd like to share the experience. I'm a beginner at flashing and the Android world, so I struggled to understand I did not need Odin for taking control over my Galaxy J5.
The following should work for most versions of OSX / MacOS, as long as you have a compiler installed. But I've only tested it in my Yosemite machine.
All binary packages for Heimdall did not work for me. I was getting a persistent "libusb error -7 whilst sending packet". So I decided to build everything from source and forget about Odin, JOdin3 and the like.
I already had a development environment setup in my Mac, with the stock Xcode cc compiler. So I can only relate the additional dependencies I had to install (+ GIT). But it could be that I had additional software that is required from my brew installed packages. At the end of the post I list all my brew installed packages just in case.
1) Make sure you have a compiler (Xcode dev tools) installed. This is standard Apple stuff. Just google "install xcode mac" for your Mac version.
2) Install Homebrew (url is brew.sh), and the following packages:
Code:
brew install git
brew install cmake
3) Build libusb from source
Code:
cd /tmp
git clone https://github.com/libusb/libusb
cd libusb
./autogen.sh
make
cd /tmp
4) Build Heimdall
Code:
cd /tmp
git clone https://github.com/Benjamin-Dobell/Heimdall
cd Heimdall/
cmake -DLIBUSB_LIBRARY=/tmp/libusb/libusb -DLIBUSB_INCLUDE_DIR=/tmp/libusb/libusb -DDISABLE_FRONTEND=1 .
make
5) If you had no errors in the previous make steps, run Heimdall. You ca print your PIT, flash, etc, from the command line and never use Odin AFAIK. Take your phone into "Download Mode" (Vol Down + Home + Power button from a powered down state). Then try the print-pit Heimdall command (which takes a few minutes to complete).
Code:
cd /tmp/Heimdall/bin
sudo ./heimdall print-pit --no-reboot
sudo ./heimdall flash --17 recovery.img
etc....
BTW, move both Heimdall and libusb directories out of /tmp/ if you intend to preserve them after your Mac reboots. Create something like /Users/[your_user]/build/ to keep it safe and replave all "/tmp/" dirs in the lines above with your destination directory.
Have fun!
=====================
The following is a list of all my brew-installed packages, just in case you're missing a dependency and not sure which package I had that could make this work in my machine.
Code:
~/dev/build/Heimdall$ brew list
android-sdk gifsicle id3lib meld redis
atk git imagemagick net-snmp ruby
autoconf glew jbig2dec netcat scala
automake glib jpeg nettle sdl2
boost glm lame nexus sdl2_image
brew-cask gmp libepoxy nmap sqlite
cairo gnome-icon-theme libev node texi2html
cmake gnu-sed libffi openssl tig
cscope gnupg libogg p7zip tree
d-bus gnutls libpng pango unrar
ffmpeg go libtasn1 pcre v8
fontconfig gobject-introspection libtiff phantomjs watch
freetype gource libtool pixman webp
gawk gsettings-desktop-schemas libvo-aacenc pkg-config wget
gd gtk+3 libvorbis py2cairo x264
gdbm gtksourceview3 libvpx pygobject3 xvid
gdk-pixbuf harfbuzz libyaml python xz
geoip hicolor-icon-theme little-cms2 qemu yasm
gettext httrack macvim qt5
ghostscript icu4c maven readline

Categories

Resources