curl: (3) <url> malformed <<installing repo error>> - Android

while trying to install repo and running cmd
$ curl http://android.git.kernel.org/repo >~/bin/repo
i get the following error.
Code:
import optparse
import os
import re
import readline
import subprocess
import sys
home_dot_repo = os.path.expanduser('~/.repoconfig')
gpg_dir = os.path.join(home_dot_repo, 'gnupg')
extra_args = []
init_optparse = optparse.OptionParser(usage="repo init -u url [options]")
# Logging
group = init_optparse.add_option_group('Logging options')
group.add_option('-q', '--quiet',
dest="quiet", action="store_true", default=False,
help="be quiet")
# Manifest
group = init_optparse.add_option_group('Manifest options')
group.add_option('-u', '--manifest-url',
dest='manifest_url',
help='manifest repository location', metavar='URL')
group.add_option('-o', '--origin',
dest='manifest_origin',
help="use REMOTE instead of 'origin' to track upstream",
metavar='REMOTE')
group.add_option('-b', '--manifest-branch',
dest='manifest_branch',
help='manifest branch or revision', metavar='REVISION')
group.add_option('-m', '--manifest-name',
dest='manifest_name',
help='initial manifest file (deprecated)',
metavar='NAME.xml')
group.add_option('--mirror',
dest='mirror', action='store_true',
help='mirror the forrest')
# Tool
group = init_optparse.add_option_group('repo Version options')
group.add_option('--repo-url',
dest='repo_url',
help='repo repository location', metavar='URL')
group.add_option('--repo-branch',
dest='repo_branch',
help='repo branch or revision', metavar='REVISION')
group.add_option('--no-repo-verify',
dest='no_repo_verify', action='store_true',
help='do not verify repo source code')
class CloneFailure(Exception):
"""Indicate the remote clone of repo itself failed.
"""
def _Init(args):
"""Installs repo by cloning it over the network.
"""
opt, args = init_optparse.parse_args(args)
if args or not opt.manifest_url:
init_optparse.print_usage()
sys.exit(1)
url = opt.repo_url
if not url:
url = REPO_URL
extra_args.append('--repo-url=%s' % url)
branch = opt.repo_branch
if not branch:
branch = REPO_REV
extra_args.append('--repo-branch=%s' % branch)
if branch.startswith('refs/heads/'):
branch = branch[len('refs/heads/'):]
if branch.startswith('refs/'):
print >>sys.stderr, "fatal: invalid branch name '%s'" % branch
raise CloneFailure()
if not os.path.isdir(repodir):
try:
os.mkdir(repodir)
except OSError, e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' % (
repodir, e.strerror)
# Don't faise CloneFailure; that would delete the
# name. Instead exit immediately.
#
sys.exit(1)
_CheckGitVersion()
try:
if _NeedSetupGnuPG():
can_verify = _SetupGnuPG(opt.quiet)
else:
can_verify = True
if not opt.quiet:
print >>sys.stderr, 'Getting repo ...'
print >>sys.stderr, ' from %s' % url
dst = os.path.abspath(os.path.join(repodir, S_repo))
_Clone(url, dst, opt.quiet)
if can_verify and not opt.no_repo_verify:
rev = _Verify(dst, branch, opt.quiet)
else:
rev = 'refs/remotes/origin/%s^0' % branch
_Checkout(dst, branch, rev, opt.quiet)
except CloneFailure:
if opt.quiet:
print >>sys.stderr, \
'fatal: repo init failed; run without --quiet to see why'
raise
def _CheckGitVersion():
cmd = [GIT, '--version']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
ver_str = proc.stdout.read().strip()
proc.stdout.close()
proc.wait()
if not ver_str.startswith('git version '):
print >>sys.stderr, 'error: "%s" unsupported' % ver_str
raise CloneFailure()
ver_str = ver_str[len('git version '):].strip()
ver_act = tuple(map(lambda x: int(x), ver_str.split('.')[0:3]))
if ver_act < MIN_GIT_VERSION:
need = '.'.join(map(lambda x: str(x), MIN_GIT_VERSION))
print >>sys.stderr, 'fatal: git %s or later required' % need
raise CloneFailure()
def _NeedSetupGnuPG():
if not os.path.isdir(home_dot_repo):
return True
kv = os.path.join(home_dot_repo, 'keyring-version')
if not os.path.exists(kv):
return True
kv = open(kv).read()
if not kv:
return True
kv = tuple(map(lambda x: int(x), kv.split('.')))
if kv < KEYRING_VERSION:
return True
return False
def _SetupGnuPG(quiet):
if not os.path.isdir(home_dot_repo):
try:
os.mkdir(home_dot_repo)
except OSError, e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' % (
home_dot_repo, e.strerror)
sys.exit(1)
if not os.path.isdir(gpg_dir):
try:
os.mkdir(gpg_dir, 0700)
except OSError, e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' % (
gpg_dir, e.strerror)
sys.exit(1)
env = dict(os.environ)
env['GNUPGHOME'] = gpg_dir
cmd = ['gpg', '--import']
try:
proc = subprocess.Popen(cmd,
env = env,
stdin = subprocess.PIPE)
except OSError, e:
if not quiet:
print >>sys.stderr, 'warning: gpg (GnuPG) is not available.'
print >>sys.stderr, 'warning: Installing it is strongly encouraged.'
print >>sys.stderr
return False
proc.stdin.write(MAINTAINER_KEYS)
proc.stdin.close()
if proc.wait() != 0:
print >>sys.stderr, 'fatal: registering repo maintainer keys failed'
sys.exit(1)
print
fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w')
fd.write('.'.join(map(lambda x: str(x), KEYRING_VERSION)) + '\n')
fd.close()
return True
def _SetConfig(local, name, value):
"""Set a git configuration option to the specified value.
"""
cmd = [GIT, 'config', name, value]
if subprocess.Popen(cmd, cwd = local).wait() != 0:
raise CloneFailure()
def _Fetch(local, quiet, *args):
cmd = [GIT, 'fetch']
if quiet:
cmd.append('--quiet')
err = subprocess.PIPE
else:
err = None
cmd.extend(args)
cmd.append('origin')
proc = subprocess.Popen(cmd, cwd = local, stderr = err)
if err:
proc.stderr.read()
proc.stderr.close()
if proc.wait() != 0:
raise CloneFailure()
def _Clone(url, local, quiet):
"""Clones a git repository to a new subdirectory of repodir
"""
try:
os.mkdir(local)
except OSError, e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' \
% (local, e.strerror)
raise CloneFailure()
cmd = [GIT, 'init', '--quiet']
try:
proc = subprocess.Popen(cmd, cwd = local)
except OSError, e:
print >>sys.stderr
print >>sys.stderr, "fatal: '%s' is not available" % GIT
print >>sys.stderr, 'fatal: %s' % e
print >>sys.stderr
print >>sys.stderr, 'Please make sure %s is installed'\
' and in your path.' % GIT
raise CloneFailure()
if proc.wait() != 0:
print >>sys.stderr, 'fatal: could not create %s' % local
raise CloneFailure()
_SetConfig(local, 'remote.origin.url', url)
_SetConfig(local, 'remote.origin.fetch',
'+refs/heads/*:refs/remotes/origin/*')
_Fetch(local, quiet)
_Fetch(local, quiet, '--tags')
def _Verify(cwd, branch, quiet):
"""Verify the branch has been signed by a tag.
"""
cmd = [GIT, 'describe', 'origin/%s' % branch]
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd = cwd)
cur = proc.stdout.read().strip()
proc.stdout.close()
proc.stderr.read()
proc.stderr.close()
if proc.wait() != 0 or not cur:
print >>sys.stderr
print >>sys.stderr,\
"fatal: branch '%s' has not been signed" \
% branch
raise CloneFailure()
m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur)
if m:
cur = m.group(1)
if not quiet:
print >>sys.stderr
print >>sys.stderr, \
"info: Ignoring branch '%s'; using tagged release '%s'" \
% (branch, cur)
print >>sys.stderr
env = dict(os.environ)
env['GNUPGHOME'] = gpg_dir
cmd = [GIT, 'tag', '-v', cur]
proc = subprocess.Popen(cmd,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
cwd = cwd,
env = env)
out = proc.stdout.read()
proc.stdout.close()
err = proc.stderr.read()
proc.stderr.close()
if proc.wait() != 0:
print >>sys.stderr
print >>sys.stderr, out
print >>sys.stderr, err
print >>sys.stderr
raise CloneFailure()
return '%s^0' % cur
def _Checkout(cwd, branch, rev, quiet):
"""Checkout an upstream branch into the repository and track it.
"""
cmd = [GIT, 'update-ref', 'refs/heads/default', rev]
if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
raise CloneFailure()
_SetConfig(cwd, 'branch.default.remote', 'origin')
_SetConfig(cwd, 'branch.default.merge', 'refs/heads/%s' % branch)
cmd = [GIT, 'symbolic-ref', 'HEAD', 'refs/heads/default']
if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
raise CloneFailure()
cmd = [GIT, 'read-tree', '--reset', '-u']
if not quiet:
cmd.append('-v')
cmd.append('HEAD')
if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
raise CloneFailure()
def _FindRepo():
"""Look for a repo installation, starting at the current directory.
"""
dir = os.getcwd()
repo = None
while dir != '/' and not repo:
repo = os.path.join(dir, repodir, REPO_MAIN)
if not os.path.isfile(repo):
repo = None
dir = os.path.dirname(dir)
return (repo, os.path.join(dir, repodir))
class _Options:
help = False
def _ParseArguments(args):
cmd = None
opt = _Options()
arg = []
for i in xrange(0, len(args)):
a = args[i]
if a == '-h' or a == '--help':
opt.help = True
elif not a.startswith('-'):
cmd = a
arg = args[i + 1:]
break
return cmd, opt, arg
def _Usage():
print >>sys.stderr,\
"""usage: repo COMMAND [ARGS]
repo is not yet installed. Use "repo init" to install it here.
The most commonly used repo commands are:
init Install repo in the current working directory
help Display detailed help on a command
For access to the full online help, install repo ("repo init").
"""
sys.exit(1)
def _Help(args):
if args:
if args[0] == 'init':
init_optparse.print_help()
else:
print >>sys.stderr,\
"error: '%s' is not a bootstrap command.\n"\
' For access to online help, install repo ("repo init").'\
% args[0]
else:
_Usage()
sys.exit(1)
def _NotInstalled():
print >>sys.stderr,\
'error: repo is not installed. Use "repo init" to install it here.'
sys.exit(1)
def _NoCommands(cmd):
print >>sys.stderr,\
"""error: command '%s' requires repo to be installed first.
Use "repo init" to install it here.""" % cmd
sys.exit(1)
def _RunSelf(wrapper_path):
my_dir = os.path.dirname(wrapper_path)
my_main = os.path.join(my_dir, 'main.py')
my_git = os.path.join(my_dir, '.git')
if os.path.isfile(my_main) and os.path.isdir(my_git):
for name in ['git_config.py',
'project.py',
'subcmds']:
if not os.path.exists(os.path.join(my_dir, name)):
return None, None
return my_main, my_git
return None, None
def _SetDefaultsTo(gitdir):
global REPO_URL
global REPO_REV
REPO_URL = gitdir
proc = subprocess.Popen([GIT,
'--git-dir=%s' % gitdir,
'symbolic-ref',
'HEAD'],
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
REPO_REV = proc.stdout.read().strip()
proc.stdout.close()
proc.stderr.read()
proc.stderr.close()
if proc.wait() != 0:
print >>sys.stderr, 'fatal: %s has no current branch' % gitdir
sys.exit(1)
def main(orig_args):
main, dir = _FindRepo()
cmd, opt, args = _ParseArguments(orig_args)
wrapper_path = os.path.abspath(__file__)
my_main, my_git = _RunSelf(wrapper_path)
if not main:
if opt.help:
_Usage()
if cmd == 'help':
_Help(args)
if not cmd:
_NotInstalled()
if cmd == 'init':
if my_git:
_SetDefaultsTo(my_git)
try:
_Init(args)
except CloneFailure:
for root, dirs, files in os.walk(repodir, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
os.rmdir(repodir)
sys.exit(1)
main, dir = _FindRepo()
else:
_NoCommands(cmd)
if my_main:
main = my_main
ver_str = '.'.join(map(lambda x: str(x), VERSION))
me = [main,
'--repo-dir=%s' % dir,
'--wrapper-version=%s' % ver_str,
'--wrapper-path=%s' % wrapper_path,
'--']
me.extend(orig_args)
me.extend(extra_args)
try:
os.execv(main, me)
except OSError, e:
print >>sys.stderr, "fatal: unable to start %s" % main
print >>sys.stderr, "fatal: %s" % e
sys.exit(148)
if __name__ == '__main__':
main(sys.argv[1:])
curl: (3) <url> malformed
Thoughts?

nm, got it..... thanks for all the quick help.
/sarcasm

I have the same issue. Could you please tell me what you've done to get rid of this error?
Thanks,

I just went to the url, copied the text into gedit(as root) and saved as repo.

Related

Invalid conversion!

I'm trying to build CM10.2 for an Allwinner A31 device. I also have an A31 dev tree for stock 4.2.2, which has the Cedarx framework I need, so I've imported it into the CM dev tree. Most things build fine without any, or much, changes but I'm getting the below error and haven't been able to fix it.
I've looked at just about everything and there doesn't seam to be a reason for the error. I have some "C" experience and I can handle some things but this is beyond my understanding.
Code:
frameworks/av/media/CedarX-Projects/CedarA/CedarARender.cpp: In member function 'android::status_t android::CedarAAudioPlayer::start(bool)':
frameworks/av/media/CedarX-Projects/CedarA/CedarARender.cpp:122:46: error: invalid conversion from 'int' to 'audio_output_flags_t' [-fpermissive]
In file included from frameworks/av/media/CedarX-Projects/CedarA/CedarARender.cpp:22:0:
frameworks/av/include/media/AudioTrack.h:168:25: error: initializing argument 6 of 'android::AudioTrack::AudioTrack(audio_stream_type_t, uint32_t, audio_format_t, audio_channel_mask_t, int, audio_output_flags_t, android::AudioTrack::callback_t, void*, int, int)' [-fpermissive]
make: *** [/home/curt/android/system/out/target/product/novo9/obj/SHARED_LIBRARIES/libCedarA_intermediates/CedarARender.o] Error 1
The CedarARender.cpp code is:
Code:
mAudioTrack = new AudioTrack(
AUDIO_STREAM_MUSIC, mSampleRate, AUDIO_FORMAT_PCM_16_BIT,
(mNumChannels == 2)
? AUDIO_CHANNEL_OUT_STEREO
: AUDIO_CHANNEL_OUT_MONO,
0, 0, &AudioCallback, this, 0); //This is line 122! The first "0".
These are the header lines referenced in the error:
Code:
AudioTrack( audio_stream_type_t streamType,
uint32_t sampleRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
audio_channel_mask_t channelMask = 0,
int frameCount = 0,
audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
callback_t cbf = NULL,
void* user = NULL,
int notificationFrames = 0,
int sessionId = 0);
The value of AUDIO_OUTPUT_FLAG_NONE is from <system/audio.h>:
Code:
typedef enum {
AUDIO_OUTPUT_FLAG_NONE = 0x0, // no attributes
AUDIO_OUTPUT_FLAG_DIRECT = 0x1, // this output directly connects a track
// to one output stream: no software mixer
AUDIO_OUTPUT_FLAG_PRIMARY = 0x2, // this output is the primary output of
// the device. It is unique and must be
// present. It is opened by default and
// receives routing, audio mode and volume
// controls related to voice calls.
AUDIO_OUTPUT_FLAG_FAST = 0x4, // output supports "fast tracks",
// defined elsewhere
AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8,// use deep audio buffers
#ifdef QCOM_HARDWARE
//Qualcomm Flags
AUDIO_OUTPUT_FLAG_LPA = 0x1000, // use LPA
AUDIO_OUTPUT_FLAG_TUNNEL = 0x2000, // use Tunnel
AUDIO_OUTPUT_FLAG_VOIP_RX = 0x4000, // use this flag in combination with DIRECT to
// indicate HAL to activate EC & NS
// path for VOIP calls
AUDIO_OUTPUT_FLAG_INCALL_MUSIC = 0x8000 //use this flag for incall music delivery
#endif
} audio_output_flags_t;
My question is, why is the "0" causing an error? I tried putting "AUDIO_OUTPUT_FLAG_NONE" and "0x0" in it's place but still get the error.
Any help would be appreciate!

[help] .242 stock kernel

I have been trying to decompile the stock .242 kernel, as i wanted to make a kexec patched one.
but for some strange reason, it does not have android_magic, and fails to decompile it,
Split_boot.pl I have been using.
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;
######################################################################
## 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
=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 $k_offset = $PAGE_SIZE;
my $r_offset = $k_offset + ($n * $PAGE_SIZE);
my $s_offset = $r_offset + ($m * $PAGE_SIZE);
(my $base = $IMAGE_FN) =~ s/.*\/(.*)$/$1/;
my $k_file = $base . "-kernel";
my $r_file = $base . "-ramdisk.gz";
my $s_file = $base . "-second.gz";
# 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";
}
######################################################################
## 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 */
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
unsigned unused[2]; /* future expansion: should be 0 */
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 tags_addr
read(INF, $buf, UNSIGNED_SIZE);
my ($tags_addr) = unpack("V", $buf);
# get the page size (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE);
my ($p_size) = unpack("V", $buf);
# Ignore unused
read(INF, $buf, UNSIGNED_SIZE * 2);
# 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 "Board name: $name\n";
printf "Command line: $cmdline\n";
printf "Base address: (0x%08x)\n", $tags_addr - 0x00000100;
# Save the values
$PAGE_SIZE = $p_size;
$KERNEL_SIZE = $k_size;
$RAMDISK_SIZE = $r_size;
$SECOND_SIZE = $s_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];
}
Console output
Code:
Android Magic not found in .242.img. Giving up.
Any help would be greatly appreciated.
Saatvik Shukla said:
I have been trying to decompile the stock .242 kernel, as i wanted to make a kexec patched one.
but for some strange reason, it does not have android_magic, and fails to decompile it,
Split_boot.pl I have been using.
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;
######################################################################
## 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
=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 $k_offset = $PAGE_SIZE;
my $r_offset = $k_offset + ($n * $PAGE_SIZE);
my $s_offset = $r_offset + ($m * $PAGE_SIZE);
(my $base = $IMAGE_FN) =~ s/.*\/(.*)$/$1/;
my $k_file = $base . "-kernel";
my $r_file = $base . "-ramdisk.gz";
my $s_file = $base . "-second.gz";
# 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";
}
######################################################################
## 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 */
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
unsigned unused[2]; /* future expansion: should be 0 */
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 tags_addr
read(INF, $buf, UNSIGNED_SIZE);
my ($tags_addr) = unpack("V", $buf);
# get the page size (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE);
my ($p_size) = unpack("V", $buf);
# Ignore unused
read(INF, $buf, UNSIGNED_SIZE * 2);
# 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 "Board name: $name\n";
printf "Command line: $cmdline\n";
printf "Base address: (0x%08x)\n", $tags_addr - 0x00000100;
# Save the values
$PAGE_SIZE = $p_size;
$KERNEL_SIZE = $k_size;
$RAMDISK_SIZE = $r_size;
$SECOND_SIZE = $s_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];
}
Console output
Code:
Android Magic not found in .242.img. Giving up.
Any help would be greatly appreciated.
Click to expand...
Click to collapse
AIK is the way to go:
http://forum.xda-developers.com/showthread.php?t=2073775

Decrypting LUA files

Hey
I'm trying to decrypt the LUA files.
I'm running the game on my phone
I run this script
Code:
#!/usr/bin/env python
import frida
import sys
package_name = "com.elex.nikkigp"
def get_messages_from_js(message, data):
if message['type'] == 'send':
print("[*] {0}".format(message['payload']))
else:
print(message)
jsc = """
var _address = Module.findExportByName( "libcocos2dcpp.so", "Z13xxtea_decryptPhjS_jPj");
if (null === _address)
throw 'xxtea_decrypt NOT FOUND';
Interceptor.attach (_address, {
onEnter: function (args) {
console.log("----------------BEGIN----------------");
console.log(hexdump(Memory.readByteArray(args[2], 12),{
offset: 0,
length: 12,
header: true,
ansi: true
}));
},
onLeave: function (retval) {
console.log("Decrypt:");
console.log(hexdump(Memory.readByteArray(retval, 16),{
offset: 0,
length: 16,
header: true,
ansi: true
}));
console.log("-----------------END-----------------");
}
});
"""
process = frida.get_usb_device().attach(package_name)
script = process.create_script(jsc)
script.on('message',get_messages_from_js)
script.load()
print("[*] Start Script")
sys.stdin.read()
Error xxtea_decrypt NOT FOUND
Although the xxtea_decrypt function in libcocos2dcpp yes.

[Help] Build from source failed but make otapackage worked

Been lurking on XDA for a while trying to soak up all the good info here. Finally decided to have a go at building a ROM from source. I'm using Ubuntu in a virtual machine, managed to setup my local repository, included necessary device tree and kernel with custom local manifest.
The build process fails at 99% on the very last step which is creating the flashable zip. I found it quite annoying after waiting 3 hours for it to build, but figured everything is there to create the zip. I then tried make otapackage and it successfully spat out a flashable zip.
I''m perfectly comfortable with command line interfaces but i'm a complete Linux noob, last time I experimented with a Unix flavour was Amix (Amiga port of UNIX System V R4) and couldn't wrap my head around it. Ubuntu is a lot friendlier but I still don't get what the error message is trying to tell me. Can anyone give me a clue?
Code:
[ 99% 16544/16545] build /home/nicholas/aospex/out/target/product/lithium/aosp_lithium-ota-19b2cd9547.zip
FAILED: /home/nicholas/aospex/out/target/product/lithium/aosp_lithium-ota-19b2cd9547.zip
/bin/bash -c "(echo \"Package OTA: /home/nicholas/aospex/out/target/product/lithium/aosp_lithium-ota-19b2cd9547.zip\" ) && (PATH=/home/nicholas/aospex/out/host/linux-x86/bin/:\$PATH MKBOOTIMG=/home/nicholas/aospex/out/host/linux-x86/bin/mkbootimg ./build/tools/releasetools/ota_from_target_files -v --block --extracted_input_target_files /home/nicholas/aospex/out/target/product/lithium/obj/PACKAGING/target_files_intermediates/aosp_lithium-target_files-19b2cd9547 -p /home/nicholas/aospex/out/host/linux-x86 -k build/target/product/security/testkey --backup=true /home/nicholas/aospex/out/target/product/lithium/obj/PACKAGING/target_files_intermediates/aosp_lithium-target_files-19b2cd9547.zip /home/nicholas/aospex/out/target/product/lithium/aosp_lithium-ota-19b2cd9547.zip )"
Package OTA: /home/nicholas/aospex/out/target/product/lithium/aosp_lithium-ota-19b2cd9547.zip
running: openssl pkcs8 -in build/target/product/security/testkey.pk8 -inform DER -nocrypt
--- target info ---
blockimgdiff_versions = (str) 3,4
blocksize = (int) 262144
boot_size = (int) 67108864
build.prop = (dict) {'ro.build.display.id': 'aosp_lithium-userdebug 8.1.0 OPM6.171019.030.H1 19b2cd9547 test-keys', 'ro.wifi.channels': '', 'ro.treble.enabled': 'false', 'ro.modversion': 'AospExtended-v5.8-20180818-2322-UNOFFICIAL', 'ro.build.id': 'OPM6.171019.030.H1', 'ro.product.cpu.abilist': 'arm64-v8a,armeabi-v7a,armeabi', 'ro.build.product': 'lithium', 'ro.build.host': 'nicholas-VirtualBox', 'ro.product.name': 'lithium', 'ro.build.version.security_patch': '2018-08-05', 'ro.product.manufacturer': 'Xiaomi', 'ro.extended.display.version': 'AospExtended-v5.8-UNOFFICIAL', 'ro.product.cpu.abilist32': 'armeabi-v7a,armeabi', 'ro.build.version.incremental': '19b2cd9547', 'ro.build.version.preview_sdk': '0', 'dalvik.vm.isa.arm.features': 'default', 'ro.build.tags': 'test-keys', 'dalvik.vm.isa.arm64.variant': 'kryo', 'ro.aex.device': 'lithium', 'ro.build.version.sdk': '27', 'ro.extended.releasetype': 'UNOFFICIAL', 'ro.build.date': 'Sun Aug 19 00:22:22 BST 2018', 'dalvik.vm.isa.arm.variant': 'kryo', 'dalvik.vm.lockprof.threshold': '500', 'ro.product.locale': 'en-US', 'ro.build.fingerprint': 'Xiaomi/lithium/lithium:7.0/NRD90M/V9.5.5.0.NAAMIFA:user/release-keys', 'ro.build.date.utc': '1534634542', 'ro.build.characteristics': 'default', 'ro.product.cpu.abilist64': 'arm64-v8a', 'ro.build.expect.modem': '2018-07-04 19:18:52,8.7.5', 'ro.build.user': 'nicholas', 'dalvik.vm.isa.arm64.features': 'default', 'ro.expect.recovery_id': '0xeed4e453264d12e67c8b4daa242b8636714b9623000000000000000000000000', 'ro.product.device': 'lithium', 'ro.build.version.all_codenames': 'REL', 'dalvik.vm.stack-trace-dir': '/data/anr', 'ro.build.description': 'lithium-user 7.0 NRD90M V9.5.5.0.NAAMIFA release-keys', 'ro.build.flavor': 'aosp_lithium-userdebug', 'ro.product.cpu.abi': 'arm64-v8a', 'ro.bionic.ld.warning': '1', 'ro.product.brand': 'Xiaomi', 'persist.sys.dalvik.vm.lib.2': 'libart.so', 'ro.build.version.release': '8.1.0', 'ro.build.version.codename': 'REL', 'ro.extended.version': 'v5.8', 'media.recorder.show_manufacturer_and_model': 'true', 'ro.build.type': 'userdebug', 'ro.product.model': 'MI MIX', 'ro.build.version.base_os': '', 'net.bt.name': 'Android'}
default_system_dev_certificate = (str) build/target/product/security/testkey
device_type = (str) MMC
ext_mkuserimg = (str) mkuserimg_mke2fs.sh
extfs_sparse_flag = (str) -s
fs_type = (str) ext4
fstab = (dict) {'none': <common.Partition object at 0x7f3adc335350>, '/cache': <common.Partition object at 0x7f3adc32d9d0>, '/boot': <common.Partition object at 0x7f3adc32d910>, '/system': <common.Partition object at 0x7f3adc32d990>, '/dsp': <common.Partition object at 0x7f3adc32dc10>, '/frp': <common.Partition object at 0x7f3adc3352d0>, '/persist': <common.Partition object at 0x7f3adc32da90>, '/recovery': <common.Partition object at 0x7f3adc32d950>, '/firmware': <common.Partition object at 0x7f3adc32dc50>, '/bt_firmware': <common.Partition object at 0x7f3adc32dc90>, '/misc': <common.Partition object at 0x7f3adc335310>, '/data': <common.Partition object at 0x7f3adc32da10>, '/vendor': <common.Partition object at 0x7f3adc32da50>}
fstab_version = (int) 2
mkbootimg_args = (str)
mkbootimg_version_args = (str) --os_version 8.1.0 --os_patch_level 2018-08-05
multistage_support = (str) 1
ota_override_device = (str) lithium
recovery_api_version = (int) 3
recovery_as_boot = (str)
recovery_mount_options = (str) ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc
recovery_size = (int) 67108864
selinux_fc = (str) /home/nicholas/aospex/out/target/product/lithium/obj/PACKAGING/target_files_intermediates/aosp_lithium-target_files-19b2cd9547/META/file_contexts.bin
squashfs_sparse_flag = (str) -s
system_size = (int) 3221225472
tool_extensions = (str) device/xiaomi/msm8996-common
use_set_metadata = (str) 1
userdata_size = (int) 58846064640
vendor_fs_type = (str) ext4
vendor_size = (int) 872415232
(using device-specific extensions from target_files)
--- can't determine the cache partition size ---
loaded device-specific extensions from /home/nicholas/aospex/out/target/product/lithium/obj/PACKAGING/target_files_intermediates/aosp_lithium-target_files-19b2cd9547/META/releasetools.py
using prebuilt recovery.img from IMAGES...
Traceback (most recent call last):
File "./build/tools/releasetools/ota_from_target_files", line 1647, in <module>
main(sys.argv[1:])
File "./build/tools/releasetools/ota_from_target_files", line 1602, in main
WriteFullOTAPackage(input_zip, output_zip)
File "./build/tools/releasetools/ota_from_target_files", line 570, in WriteFullOTAPackage
system_tgt = GetImage("system", OPTIONS.input_tmp)
File "./build/tools/releasetools/ota_from_target_files", line 328, in GetImage
return sparse_img.SparseImage(path, mappath, clobbered_blocks)
File "/home/nicholas/aospex/build/make/tools/releasetools/sparse_img.py", line 39, in __init__
header = struct.unpack("<I4H4I", header_bin)
struct.error: unpack requires a string argument of length 28
ninja: build stopped: subcommand failed.
01:55:58 ninja failed with: exit status 1
I think my repo didnt sync properly, i did make clobber and then repo sync and everything works fine now!

[GUIDE] How To Compile Kernel & DTBO For Redmi K20

Introduction :
I'm not an expert in kernel development, but would like to share the steps that I followed to build my kernel. If any of other kernel developers out there would like to add on some tips or correct something, please do!
Pre-requisites :
Ubuntu or any other Linux based OS
Stable Internet Connection
Patience
Step 1 : Setup Build Environment
Open the terminal and enter the following :
Code:
sudo apt-get install git ccache automake flex lzop bison \
gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 \
g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev \
libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush \
schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev \
pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl \
libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev \
x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip
Step 2 : Download Required Files
Download device source :
Code:
git clone --depth=1 https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git -b davinci-p-oss davinci-p-oss
Download a compatible GCC toolchain (Using AOSP's GCC for this guide) :
Code:
cd davinci-p-oss
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 toolchain
Download a compatible CLANG toolchain (Using AOSP's CLANG for this guide) : Download
Move the downloaded file in the davinci-p-oss folder manually and then extract using the following command :
Code:
tar vxzf linux-x86-android-9.0.0_r48-clang-4691093.tar.gz
Download the device-tree-compiler attached below and place it in /usr/bin
Step 3 : Make device specific changes
Make these changes in the /kernel/module.c file.
If you are not familiar with github, you can check out many github guides available on XDA, for now you can just download the module.c file attached to this thread and replace the one in /kernel folder with the downloaded one!
Now, browse back to davinci-p-oss directory, and open the davinci_user_defconfig located in \arch\arm64\configs
Add the following lines :
Code:
CONFIG_BUILD_ARM64_DT_OVERLAY=y
CONFIG_MODULE_FORCE_LOAD=y
WIFI & Audio won't work if you don't make these changes, apparently Xiaomi decided to skip wlan & audio drivers in pie sources.
Step 4 : Building The Kernel
Code:
cd davinci-p-oss
rm -rf out
mkdir out
export ARCH=arm64
export SUBARCH=arm64
export DTC_EXT=dtc
make O=out ARCH=arm64 davinci_user_defconfig
PATH="${PWD}/bin:${PWD}/toolchain/bin:${PATH}" \
make -j$(nproc --all) O=out \
ARCH=arm64 \
CC=clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-android- | tee kernel.log
Step 5 : How To Get Help If You Encounter Errors
A kernel.log file will be generated in davinci-p-oss folder, find the line which says error.
If you can't figure out the solution, attach the kernel.log in your reply to this thread.
Step 6 : Booting The Kernel
Once you're done with Step 4, browse to /out/arch/arm64/boot & you'll find the Image.gz-dtb file (compiled zImage)
Download the anykernel template for davinci from attachments and add your Image.gz-dtb file to the archive.
Boot in TWRP, backup your stock kernel & flash the anykernel zip.
References :
Information on compiling Android kernels with Clang by nathanchance
How to compile kernel standalone by Xiaomi
Kernel Builder Virtual Machine & device specific changes by mslezak
AnyKernel3 Template by osm0sis
Wahoo Kernel Tools by frap129
Regards,
acervenky
Using QCom Clang To Compile Kernel [Xiaomi's Guide]
Step 1 : Setup Build Environment
Open the terminal and enter the following :
Code:
sudo apt-get install git ccache automake flex lzop bison \
gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 \
g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev \
libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush \
schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev \
pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl \
libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev \
x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip
Step 2 : Download Required Files
Download device source :
Code:
git clone --depth=1 https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git -b davinci-p-oss davinci-p-oss
Download a compatible GCC toolchain (Using AOSP's GCC for this guide) :
Code:
cd davinci-p-oss
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 toolchain
Download the Qcom CLANG : Download
Move the downloaded file in the davinci-p-oss folder manually and then extract using the following command :
Code:
tar vxzf snapdragon-llvm-compiler-android-linux64-609.tar.gz
Download the device-tree-compiler attached below and place it in /usr/bin
Step 3 : Make device specific changes
Make these changes in the /kernel/module.c file.
If you are not familiar with github, you can check out many github guides available on XDA, for now you can just download the module.c file attached to this thread and replace the one in /kernel folder with the downloaded one!
Now, browse back to davinci-p-oss directory, and open the davinci_user_defconfig located in \arch\arm64\configs
Add the following lines :
Code:
CONFIG_BUILD_ARM64_DT_OVERLAY=y
CONFIG_MODULE_FORCE_LOAD=y
WIFI & Audio won't work if you don't make these changes, apparently Xiaomi decided to skip wlan & audio drivers in pie sources.
Step 4 : Building The Kernel
Code:
cd davinci-p-oss
rm -rf out
mkdir out
export ARCH=arm64
export SUBARCH=arm64
export DTC_EXT=dtc
export CROSS_COMPILE=${PWD}/toolchain/bin/aarch64-linux-android-
make O=out REAL_CC=${PWD}/toolchains/llvm-Snapdragon_LLVM_for_Android_6.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- davinci_user_defconfig
make -j$(nproc) O=out REAL_CC=${PWD}/toolchains/llvm-Snapdragon_LLVM_for_Android_6.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- 2>&1 | tee kernel.log
Step 5 : How To Get Help If You Encounter Errors
A kernel.log file will be generated in davinci-p-oss folder, find the line which says error.
If you can't figure out the solution, attach the kernel.log in your reply to this thread.
Step 6 : Booting The Kernel
Once you're done with Step 4, browse to /out/arch/arm64/boot & you'll find the Image.gz-dtb file (compiled zImage)
Download the anykernel template for davinci from attachments and add your Image.gz-dtb file to the archive.
Boot in TWRP, backup your stock kernel & flash the anykernel zip.
This method is mentioned in Xiaomi's Wiki, you can choose any according to your preference!
Regards,
acervenky
How To Compile Custom DTBO
DTBO files have been used on our device primarily to change the refresh rates.
Pre-requisites :
Compiled kernel without any errors
Step 1 : Download Required Files
Download libufdt utils from this link.
Open the terminal in the downloaded file's location.
Code:
tar vxzf libufdt-master-utils.tar.gz
Step 2 : Compile dtbo.img
Code:
cd /libufdt-master-utils/src
python mkdtboimg.py create /home/user/davinci-p-oss/out/arch/arm64/boot/dtbo.img /home/user/davinci-p-oss/out/arch/arm64/boot/dts/qcom/*.dtbo
Step 3 : Flash The Compiled dtbo.img
The compiled dtbo.img file will be located in /davinci-p-oss/out/arch/arm64/boot/ (same output folder of zImage)
Backup your stock dtbo.img and flash the newly compiled dtbo.img
References :
Kernel Builder by mslezak
Regards,
acervenky
reserved3
Nice guide @acervenky
Thank you very much
----------------------------------------------
EDIT: compiled without errors
oddly enough I am not able to compile their kernel using this methodology. I believe it is something to do with Clang.
I can, however, compile the elementalX kernel for the Essential PH1, using both google's and uber's toolchains
https://gitlab.com/westernmass-hosting/android/elemental-x/compiler
I am going to see if I can replicate being able to compile for Mi9 using the same methology
I successfully compiled the kernel and dtbo using the Ubuntu VM linked in OP, but the dtbo.img is only 3MB.
When I dumped my Mi 9T's dtbo it's 32MB. Is this normal?
I compared the output from
Code:
mkdtboimg.py dump
and it seems that dt_entry_count is 24 in the compiled dtbo compared to 28 in my dumped dtbo.
I'm running the global V10.3.11.0 MIUI ROM.
Any ideas?
BLUuuE83 said:
I successfully compiled the kernel and dtbo using the Ubuntu VM linked in OP, but the dtbo.img is only 3MB.
When I dumped my Mi 9T's dtbo it's 32MB. Is this normal?
I compared the output from
Code:
mkdtboimg.py dump
and it seems that dt_entry_count is 24 in the compiled dtbo compared to 28 in my dumped dtbo.
I'm running the global V10.3.11.0 MIUI ROM.
Any ideas?
Click to expand...
Click to collapse
Yes it is normal.
Regards,
acervenky
Hi! Can you please tell me where do i find the files for GPU and CPU frequencies? Thanks!
acervenky said:
Yes it is normal.
Regards,
acervenky
Click to expand...
Click to collapse
Just another question if you don't mind.
What happens if I set too low display timings? I know with a computer monitor it'll just black screen but Windows will reset to defaults after 15 seconds if you don't do anything.
Will I just get a black screen meaning I brick my phone?
draand28 said:
Hi! Can you please tell me where do i find the files for GPU and CPU frequencies? Thanks!
Click to expand...
Click to collapse
You can't change the CPU frequencies, however to edit GPU frequencies you can edit these files:
Code:
arch/arm64/boot/dts/qcom/sm8150-gpu-v2.dtsi
arch/arm64/boot/dts/qcom/sm8150-v2.dtsi
BLUuuE83 said:
Just another question if you don't mind.
What happens if I set too low display timings? I know with a computer monitor it'll just black screen but Windows will reset to defaults after 15 seconds if you don't do anything.
Will I just get a black screen meaning I brick my phone?
Click to expand...
Click to collapse
If you set the timings too low/high they'll reset to the default values.
Regards,
acervenky
Hi! Thanks for answering. I have edited those frequencies but nothing changed on the phone. Still 585mhz maximum on gpu, even though I have tried different modifications (700,800,825). Even tried to add new steps above the original ones. I got the refresh rate mod working though. Also, if you can tell me the location of thermal configuration, that would be great. I have found a sm8150-thermal.dtsi file but can't figure out the actual temperatures, there are just some too low to be correct numbers.
I'll leave you with the modifications that I've made to the gpu and gpu-v2 files.
Code:
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
&soc {
pil_gpu: qcom,kgsl-hyp {
compatible = "qcom,pil-tz-generic";
qcom,pas-id = <13>;
qcom,firmware-name = "a640_zap";
};
msm_bus: qcom,kgsl-busmon{
label = "kgsl-busmon";
compatible = "qcom,kgsl-busmon";
};
gpubw: qcom,gpubw {
compatible = "qcom,devbw";
governor = "bw_vbif";
qcom,src-dst-ports = <26 512>;
operating-points-v2 = <&suspendable_ddr_bw_opp_table>;
};
gpu_opp_table: gpu-opp-table {
compatible = "operating-points-v2";
opp-825000000 {
opp-hz = /bits/ 64 <825000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
};
opp-735000000 {
opp-hz = /bits/ 64 <735000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
};
opp-675000000 {
opp-hz = /bits/ 64 <675000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_NOM_L1>;
};
opp-553850000 {
opp-hz = /bits/ 64 <553850000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_NOM>;
};
opp-486460000 {
opp-hz = /bits/ 64 <486460000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS_L2>;
};
opp-379650000 {
opp-hz = /bits/ 64 <379650000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS_L1>;
};
opp-309110000 {
opp-hz = /bits/ 64 <309110000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS>;
};
opp-215000000 {
opp-hz = /bits/ 64 <215000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
};
opp-96000000 {
opp-hz = /bits/ 64 <96000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
};
};
msm_gpu: qcom,[email protected] {
label = "kgsl-3d0";
compatible = "qcom,kgsl-3d0", "qcom,kgsl-3d";
status = "ok";
reg = <0x2c00000 0x40000>, <0x2c61000 0x800>,
<0x6900000 0x44000>, <0x780000 0x6fff>;
reg-names = "kgsl_3d0_reg_memory", "cx_dbgc",
"qdss_gfx", "qfprom_memory";
interrupts = <0 300 0>;
interrupt-names = "kgsl_3d0_irq";
qcom,id = <0>;
qcom,chipid = <0x06040000>;
qcom,initial-pwrlevel = <5>;
qcom,gpu-quirk-secvid-set-once;
qcom,gpu-quirk-cx-gdsc;
qcom,idle-timeout = <64>; //msecs
qcom,no-nap;
qcom,highest-bank-bit = <15>;
qcom,min-access-length = <32>;
qcom,ubwc-mode = <3>;
qcom,snapshot-size = <0x200000>; //bytes
qcom,gpu-qdss-stm = <0x161c0000 0x40000>; // base addr, size
qcom,tsens-name = "tsens_tz_sensor12";
#cooling-cells = <2>;
tzone-names = "gpuss-0-usr", "gpuss-1-usr";
qcom,pm-qos-active-latency = <1000>;
qcom,l2pc-cpu-mask-latency = <1000>;
qcom,pm-qos-wakeup-latency = <100>;
clocks = <&clock_gpucc GPU_CC_CXO_CLK>,
<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
<&clock_gcc GCC_GPU_MEMNOC_GFX_CLK>,
<&clock_gpucc GPU_CC_CX_GMU_CLK>,
<&clock_gpucc GPU_CC_AHB_CLK>,
<&clock_cpucc L3_GPU_VOTE_CLK>;
clock-names = "rbbmtimer_clk", "mem_clk",
"mem_iface_clk", "gmu_clk",
"gpu_cc_ahb", "l3_vote";
qcom,isense-clk-on-level = <1>;
/* Bus Scale Settings */
qcom,gpubw-dev = <&gpubw>;
qcom,bus-control;
qcom,msm-bus,name = "grp3d";
qcom,bus-width = <32>;
qcom,msm-bus,num-cases = <13>;
qcom,msm-bus,num-paths = <1>;
qcom,msm-bus,vectors-KBps =
<26 512 0 0>,
<26 512 0 400000>, // 1 bus=100
<26 512 0 600000>, // 2 bus=150
<26 512 0 800000>, // 3 bus=200
<26 512 0 1200000>, // 4 bus=300
<26 512 0 1648000>, // 5 bus=412
<26 512 0 2188000>, // 6 bus=547
<26 512 0 2724000>, // 7 bus=681
<26 512 0 3072000>, // 8 bus=768
<26 512 0 4068000>, // 9 bus=1017
<26 512 0 5184000>, // 10 bus=1296
<26 512 0 6220000>, // 11 bus=1555
<26 512 0 7216000>; // 12 bus=1804
/* GDSC regulator names */
regulator-names = "vddcx", "vdd";
/* GDSC oxili regulators */
vddcx-supply = <&gpu_cx_gdsc>;
vdd-supply = <&gpu_gx_gdsc>;
/* GPU OPP data */
operating-points-v2 = <&gpu_opp_table>;
/* GPU related llc slices */
cache-slice-names = "gpu", "gpuhtw";
cache-slices = <&llcc 12>, <&llcc 11>;
qcom,l3-pwrlevels {
#address-cells = <1>;
#size-cells = <0>;
compatible = "qcom,l3-pwrlevels";
qcom,[email protected] {
reg = <0>;
qcom,l3-freq = <0>;
};
qcom,l3-pwrl[email protected] {
reg = <1>;
qcom,l3-freq = <864000000>;
};
qcom,[email protected] {
reg = <2>;
qcom,l3-freq = <1344000000>;
};
};
/* GPU Mempools */
qcom,gpu-mempools {
#address-cells = <1>;
#size-cells = <0>;
compatible = "qcom,gpu-mempools";
/* 4K Page Pool configuration */
qcom,[email protected] {
reg = <0>;
qcom,mempool-page-size = <4096>;
qcom,mempool-reserved = <2048>;
qcom,mempool-allocate;
};
/* 8K Page Pool configuration */
qcom,[email protected] {
reg = <1>;
qcom,mempool-page-size = <8192>;
qcom,mempool-reserved = <1024>;
qcom,mempool-allocate;
};
/* 64K Page Pool configuration */
qcom,[email protected] {
reg = <2>;
qcom,mempool-page-size = <65536>;
qcom,mempool-reserved = <256>;
};
/* 1M Page Pool configuration */
qcom,[email protected] {
reg = <3>;
qcom,mempool-page-size = <1048576>;
qcom,mempool-reserved = <32>;
};
};
/* Power levels */
qcom,gpu-pwrlevels {
#address-cells = <1>;
#size-cells = <0>;
compatible = "qcom,gpu-pwrlevels";
qcom,[email protected] {
reg = <0>;
qcom,gpu-freq = <600000000>;
qcom,bus-freq = <12>;
qcom,bus-min = <10>;
qcom,bus-max = <12>;
};
qcom,[email protected] {
reg = <1>;
qcom,gpu-freq = <553850000>;
qcom,bus-freq = <10>;
qcom,bus-min = <9>;
qcom,bus-max = <11>;
};
qcom,[email protected] {
reg = <2>;
qcom,gpu-freq = <486460000>;
qcom,bus-freq = <9>;
qcom,bus-min = <8>;
qcom,bus-max = <10>;
};
qcom,[email protected] {
reg = <3>;
qcom,gpu-freq = <379650000>;
qcom,bus-freq = <8>;
qcom,bus-min = <7>;
qcom,bus-max = <9>;
};
qcom,[email protected] {
reg = <4>;
qcom,gpu-freq = <309110000>;
qcom,bus-freq = <5>;
qcom,bus-min = <5>;
qcom,bus-max = <7>;
};
qcom,[email protected] {
reg = <5>;
qcom,gpu-freq = <215000000>;
qcom,bus-freq = <4>;
qcom,bus-min = <3>;
qcom,bus-max = <5>;
};
qcom,[email protected] {
reg = <6>;
qcom,gpu-freq = <0>;
qcom,bus-freq = <0>;
qcom,bus-min = <0>;
qcom,bus-max = <0>;
};
};
};
kgsl_msm_iommu: qcom,[email protected] {
compatible = "qcom,kgsl-smmu-v2";
reg = <0x02CA0000 0x10000>;
/* CB5(ATOS) & CB5/6/7 are protected by HYP */
qcom,protect = <0xa0000 0xc000>;
clocks =<&clock_gcc GCC_GPU_CFG_AHB_CLK>,
<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
<&clock_gcc GCC_GPU_MEMNOC_GFX_CLK>;
clock-names = "iface_clk", "mem_clk", "mem_iface_clk";
qcom,secure_align_mask = <0xfff>;
qcom,retention;
qcom,hyp_secure_alloc;
gfx3d_user: gfx3d_user {
compatible = "qcom,smmu-kgsl-cb";
label = "gfx3d_user";
iommus = <&kgsl_smmu 0x0 0x401>;
qcom,gpu-offset = <0xa8000>;
};
gfx3d_secure: gfx3d_secure {
compatible = "qcom,smmu-kgsl-cb";
label = "gfx3d_secure";
iommus = <&kgsl_smmu 0x2 0x400>;
};
};
gmu: qcom,[email protected] {
label = "kgsl-gmu";
compatible = "qcom,gpu-gmu";
reg = <0x2c6a000 0x30000>,
<0xb280000 0x10000>,
<0xb480000 0x10000>;
reg-names = "kgsl_gmu_reg",
"kgsl_gmu_pdc_cfg",
"kgsl_gmu_pdc_seq";
interrupts = <0 304 0>, <0 305 0>;
interrupt-names = "kgsl_hfi_irq", "kgsl_gmu_irq";
qcom,msm-bus,name = "cnoc";
qcom,msm-bus,num-cases = <2>;
qcom,msm-bus,num-paths = <1>;
qcom,msm-bus,vectors-KBps =
<26 10036 0 0>, // CNOC off
<26 10036 0 100>; // CNOC on
regulator-names = "vddcx", "vdd";
vddcx-supply = <&gpu_cx_gdsc>;
vdd-supply = <&gpu_gx_gdsc>;
clocks = <&clock_gpucc GPU_CC_CX_GMU_CLK>,
<&clock_gpucc GPU_CC_CXO_CLK>,
<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
<&clock_gcc GCC_GPU_MEMNOC_GFX_CLK>,
<&clock_gpucc GPU_CC_AHB_CLK>;
clock-names = "gmu_clk", "cxo_clk", "axi_clk",
"memnoc_clk", "gpu_cc_ahb";
/* AOP mailbox for sending ACD enable and disable messages */
mboxes = <&qmp_aop 0>;
mbox-names = "aop";
qcom,gmu-pwrlevels {
#address-cells = <1>;
#size-cells = <0>;
compatible = "qcom,gmu-pwrlevels";
/* GMU power levels must go from lowest to highest */
qcom,[email protected] {
reg = <0>;
qcom,gmu-freq = <0>;
};
qcom,[email protected] {
reg = <1>;
qcom,gmu-freq = <200000000>;
};
};
gmu_user: gmu_user {
compatible = "qcom,smmu-gmu-user-cb";
iommus = <&kgsl_smmu 0x4 0x400>;
};
gmu_kernel: gmu_kernel {
compatible = "qcom,smmu-gmu-kernel-cb";
iommus = <&kgsl_smmu 0x5 0x400>;
};
};
};
Code:
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
&soc {
gpu_opp_table_v2: gpu_opp_table_v2 {
compatible = "operating-points-v2";
opp-825000000 {
opp-hz = /bits/ 64 <825000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
};
opp-735000000 {
opp-hz = /bits/ 64 <735000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
};
opp-675000000 {
opp-hz = /bits/ 64 <675000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_NOM_L1>;
};
opp-585000000 {
opp-hz = /bits/ 64 <585000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_NOM>;
};
opp-499200000 {
opp-hz = /bits/ 64 <499200000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS_L2>;
};
opp-427000000 {
opp-hz = /bits/ 64 <427000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS_L1>;
};
opp-345000000 {
opp-hz = /bits/ 64 <345000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS>;
};
opp-257000000 {
opp-hz = /bits/ 64 <257000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
};
opp-96000000 {
opp-hz = /bits/ 64 <96000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
};
};
};
acervenky said:
How To Compile Custom DTBO
DTBO files have been used on our device primarily to change the refresh rates.
Pre-requisites :
Compiled kernel without any errors
Step 1 : Download Required Files
Download libufdt utils from this link.
Open the terminal in the downloaded file's location.
Code:
tar vxzf libufdt-master-utils.tar.gz
Step 2 : Compile dtbo.img
Code:
cd /libufdt-master-utils/src
python mkdtboimg.py create /home/user/davinci-p-oss/out/arch/arm64/boot/dtbo.img /home/user/davinci-p-oss/out/arch/arm64/boot/dts/qcom/*.dtbo
Step 3 : Flash The Compiled dtbo.img
The compiled dtbo.img file will be located in /davinci-p-oss/out/arch/arm64/boot/ (same output folder of zImage)
Backup your stock dtbo.img and flash the newly compiled dtbo.img
References :
Kernel Builder by mslezak
Regards,
acervenky
Click to expand...
Click to collapse
What is the DTBO ? For what is it and why does it need changes ?
I followed instruction to build on Ubuntu 20.04 and got following console output
make[1]: Entering directory '/home/android/sources/k/davinci-p-oss/out'
../scripts/gcc-version.sh: line 32: printf: Is: invalid number
../scripts/gcc-version.sh: line 32: printf: your: invalid number
../scripts/gcc-version.sh: line 32: printf: PATH: invalid number
../scripts/gcc-version.sh: line 32: printf: set: invalid number
../scripts/gcc-version.sh: line 32: printf: correctly?: invalid number
../scripts/gcc-version.sh: line 32: printf: Is: invalid number
../scripts/gcc-version.sh: line 32: printf: your: invalid number
../scripts/gcc-version.sh: line 32: printf: PATH: invalid number
../scripts/gcc-version.sh: line 32: printf: set: invalid number
../scripts/gcc-version.sh: line 32: printf: correctly?: invalid number
/bin/sh: 1: [: 0000: unexpected operator
HOSTCC scripts/basic/fixdep
GEN ./Makefile
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[4]: *** [../scripts/kconfig/Makefile:40: silentoldconfig] Error 1
make[3]: *** [../Makefile:529: silentoldconfig] Error 2
make[2]: Nothing to be done for '/home/android/sources/k/davinci-p-oss/out'.
kernel.log
make[1]: Entering directory '/home/android/sources/k/davinci-p-oss/out'
GEN ./Makefile
scripts/kconfig/conf --silentoldconfig Kconfig
make[1]: Nothing to be done for '/home/android/sources/k/davinci-p-oss/out'.
make[1]: Leaving directory '/home/android/sources/k/davinci-p-oss/out'
#### build completed successfully (21 seconds) ####
Any advice on how to fix it?
Best Regards,
I found issues. Compile successfully with default .bashrc and Ubuntu 18.04
VD171 said:
What is the DTBO ? For what is it and why does it need changes ?
Click to expand...
Click to collapse
DTB=Device Tree Blobs
From Oreo, device hardware blobs load outside of kernel.
When you turn on your device, these components load step by step:
1- first ramdisk. Say how OS may load. Set permission for each partition.
2- second kernel boot. Say any hardware how to communicate with operation system.
3- dtb/dtbo partition load. Help any hardware work property.
Without dtb, your boot.img not booted or boot on old dtbs.img on your phone. (If you lot of changes on your kernel codes, old blobs not enough for standard performance)
For more info see:
https://source.android.com/devices/architecture/dto/partitions
GenomeX said:
DTB=Device Tree Blobs
From Oreo, device hardware blobs load outside of kernel.
When you turn on your device, these components load step by step:
1- first ramdisk. Say how OS may load. Set permission for each partition.
2- second kernel boot. Say any hardware how to communicate with operation system.
3- dtb/dtbo partition load. Help any hardware work property.
Without dtb, your boot.img not booted or boot on old dtbs.img on your phone. (If you lot of changes on your kernel codes, old blobs not enough for standard performance)
For more info see:
https://source.android.com/devices/architecture/dto/partitions
Click to expand...
Click to collapse
With all the details it was very easy to understand what it is and how DTB/DTBO works.
Thank you very much for an amazing answer.
How to make dtbo.img to dts
acervenky said:
Introduction :
I'm not an expert in kernel development, but would like to share the steps that I followed to build my kernel. If any of other kernel developers out there would like to add on some tips or correct something, please do!
Pre-requisites :
Ubuntu or any other Linux based OS
Stable Internet Connection
Patience
Step 1 : Setup Build Environment
Open the terminal and enter the following :
Code:
sudo apt-get install git ccache automake flex lzop bison \
gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 \
g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev \
libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush \
schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev \
pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl \
libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev \
x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip
Step 2 : Download Required Files
Download device source :
Code:
git clone --depth=1 https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git -b davinci-p-oss davinci-p-oss
Download a compatible GCC toolchain (Using AOSP's GCC for this guide) :
Code:
cd davinci-p-oss
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 toolchain
Download a compatible CLANG toolchain (Using AOSP's CLANG for this guide) : Download
Move the downloaded file in the davinci-p-oss folder manually and then extract using the following command :
Code:
tar vxzf linux-x86-android-9.0.0_r48-clang-4691093.tar.gz
Download the device-tree-compiler attached below and place it in /usr/bin
Step 3 : Make device specific changes
Make these changes in the /kernel/module.c file.
If you are not familiar with github, you can check out many github guides available on XDA, for now you can just download the module.c file attached to this thread and replace the one in /kernel folder with the downloaded one!
Now, browse back to davinci-p-oss directory, and open the davinci_user_defconfig located in \arch\arm64\configs
Add the following lines :
Code:
CONFIG_BUILD_ARM64_DT_OVERLAY=y
CONFIG_MODULE_FORCE_LOAD=y
WIFI & Audio won't work if you don't make these changes, apparently Xiaomi decided to skip wlan & audio drivers in pie sources.
Step 4 : Building The Kernel
Code:
cd davinci-p-oss
rm -rf out
mkdir out
export ARCH=arm64
export SUBARCH=arm64
export DTC_EXT=dtc
make O=out ARCH=arm64 davinci_user_defconfig
PATH="${PWD}/bin:${PWD}/toolchain/bin:${PATH}" \
make -j$(nproc --all) O=out \
ARCH=arm64 \
CC=clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-android- | tee kernel.log
Step 5 : How To Get Help If You Encounter Errors
A kernel.log file will be generated in davinci-p-oss folder, find the line which says error.
If you can't figure out the solution, attach the kernel.log in your reply to this thread.
Step 6 : Booting The Kernel
Once you're done with Step 4, browse to /out/arch/arm64/boot & you'll find the Image.gz-dtb file (compiled zImage)
Download the anykernel template for davinci from attachments and add your Image.gz-dtb file to the archive.
Boot in TWRP, backup your stock kernel & flash the anykernel zip.
References :
Information on compiling Android kernels with Clang by nathanchance
How to compile kernel standalone by Xiaomi
Kernel Builder Virtual Machine & device specific changes by mslezak
AnyKernel3 Template by osm0sis
Wahoo Kernel Tools by frap129
Regards,
acervenky
Click to expand...
Click to collapse

Categories

Resources