[Q] Kernel Configuration - Android Software/Hacking General [Developers Only]

I'm trying to get a kernel config file '.config' from an existing kernel....
Besides
Code:
cat /proc/config.gz
and the script.
Code:
extract-ikconfig
is there any other way to get the configuration of a kernel?
(e.g: If an OEM leaves '.config' out of their kernel source.)
Thanks!
I only ask because the config.gz doesn't exist on the device, and extract-ikconfig says
Code:
extract-ikconfig: cannot find kernel config
Which I googled and some results said that it could be because of the compression method, but I even used the 'patched' version from the later 2.6.X kernels. So I doubt its the compression method used in the kernel.

+1
I have this problem with the kernels shipped by my manufacturer. Is there a repository anywhere of known good configs that can be used for reference?

Related

[GUIDE] Kernel Build Guide

This is a basic kernel build guide, to help those that keep coming into IRC asking for help.
If you follow this, you should have a working kernel that will work with ext4 or RFS.
NOTE::I wrote this at 1am, when Im kinda falling asleep, so there might be errors. Please let me know, and Ill fix it up
What you need:
A Linux system, with about 2gb free (This is written for 32bit systems, 64bit will need a compatible toolchain)
Development libraries
The kernel source
An ARM toolchain
An initramfs from an existing kernel
Downloads
EB13 source - search for D700 under mobile phone
Code Sourcery 2009q3 ARM toolchain
Daemon's Ext4/RFS Initramfs
Steps:
Set up the build environment
The first thing you need to do is set up the build environment.
For Ubuntu or other Debian-based system, you need the build-essential package and libncurses.
You can install this by running this command:
Code:
sudo apt-get install build-essential libncurses5-dev
If your not running Ubuntu/Debian, the packages are gcc, g++, libc-dev, and make.
Next, your going to need a directory for all your kernel build. You can't have spaces in any folder name. Im going to use /home/tortel/build/ for the rest of this guide.
Now you need to extract the kernel source to your directory. In the Samsung source file, its SPH-D700_kernel.tar
Next, extract the ARM toolchain into your build directory.
Last, extract your initramfs into the directory.
After this, your build directory should contain 4 things:
Code:
arm-2009q3/
eb13init/
Kernel/
build.sh
For this guide, Im not going to use the build.sh. If you want to, you'll need to configure that yourself.
Configure your kernel
Now the fun begins.
You need to edit the Kernel/Makefile file, and change line 184 to match where your toolchain is. My line 184:
Code:
CROSS_COMPILE ?= /home/tortel/build/arm2009q3/bin/arm-none-linux-gnueabi-
Now you need to configure the kernel.
The kernel configuration file is called .config, which is hidden by default (Ctrl+H shows hidden files in GNOME). You need to set lines 81-91, so it uses your initramfs. My lines:
Code:
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="/home/tortel/kernel/eb13init/"
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_INITRAMFS_ROOT_GID=0
CONFIG_RD_GZIP=y
CONFIG_RD_BZIP2=y
CONFIG_RD_LZMA=y
# CONFIG_INITRAMFS_COMPRESSION_NONE is not set
CONFIG_INITRAMFS_COMPRESSION_GZIP=y
# CONFIG_INITRAMFS_COMPRESSION_BZIP2 is not set
# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set
This will build your initramfs into the kernel image.
Now, your set to build.
Build the kernel
This is the easy part. Open a terminal, cd to build/Kernel and run make.
The commands:
Code:
cd build/Kernel/
make
If you have more than one core, you should add -j {1+ # of CPU cores} to make so it finishes faster. It only takes about 5min on my 2ghz C2D laptop.
Make it flashable!
Congrats, its built!
The file you want is Kernel/arch/arm/boot/zImage in your kernel source directory. After make finishes, run:
Code:
cp arch/arm/boot/zImage ..
This copies your kernel image file into your main build directory. Now, you need to put it into a flashable zip. To make it easy, here. Just throw the zImage into the root of that zip, put it on your SD card, and flash it.
Might want later
Advanced config stuff to come
Might want this too
Thank you for this, I'm glad too see this and others who have contributed great guides like this.
sent from "The Other Woman"
I was one of those people who kept bothering lol. I learned how to compile a kernal in two day though, now im on my way making a OC/UV Voodoo color kernal (coming soon) :]
Thanks alot
globalninja said:
I was one of those people who kept bothering lol. I learned how to compile a kernal in two day though, now im on my way making a OC/UV Voodoo color kernal (coming soon) :]
Thanks alot
Click to expand...
Click to collapse
what should I look into for making the changes necessary for an overclocking kernel?
Thanks for this helpful thread, and I had a question previously, that someone pm'ed me for. OP, please remove this reply if you feel inclined to. I had a question about the initramfs because my computer was having problems loading the page for the link.
Hey guys, kindof a noob to this.
How can I get an initramfs for DI18? Ideally, I could just use the one in the stock ROM unmodified, but I have no idea how to obtain it.
I figured it out! Used the scripts here to extract it from zImage:
http://forum.xda-developers.com/showthread.php?t=901152

[Q] kernel compilation steps for starters

Hi guys,
I'd like to tinker around a bit with the tiamat or other kernels for the Xoom
are the following steps enough to get it working ?
- clone the repo
- adjust toolchain paths (or create an external script that does it)
- make stingray_defconfig
- make -j2
- test-boot the zImage via fastboot
- if it's successful copy over the kernel-modules & flash the kernel via fastboot
how about an initramfs ?
have I forgotten anything ?
Many thanks in advance for your help !
edit:
slowly understanding how all this works,
still might need some help
I think that will get you started. I'm not an expert, but when I'm tinkering with kernels I pull the proc config strait from the device after flashing the kernel I want to modify. That way I know that the default config is correct. For example, if I wanted to modify the kernel running on an EOS nightly, after cloning the repo I would flash the EOS nightly ROM containing the kernel I want to modify. Then run the following commands to pull the kernel config from the kernel running on my device:
Code:
adb pull /proc/config.gz .
gunzip config.gz
mv config .config
The .config then goes in the root of the kernel source directory. That may do exactly the same thing as the "make defconfig" you mentioned but I just prefer to trust the defaults from the ROM and not the repo.

[GUIDE] How to compile Sidekick 4G Kernel [Ubuntu]

1) download source code from https://opensource.samsung.com/index.jsp. You are looking for source code for SGH-T839.
2) Get initramfs (Need to make a kernel package)
Extract it using extract boot http://www.mediafire.com/?lc12eceeh617b97.
This is why I am looking for a boot.img
extract it
Code:
tar -xvf extractboot.tar.gz
now move into directory with extract boot and copy your boot.img into here and do
Code:
./extractboot boot.img
3) Get mkboot tools
http://www.mediafire.com/?w06d1m6n1dgo4op
untar it by doing
Code:
tar -xvf $FILENAMEHERE
Add the bin directory to your path by moving to the bin directory and copying down the path then
Now you will add this to your path by editing your .bashrc file.
Go to your bashrc file
Code:
gedit ~/.bashrc
and adding this
Code:
PATH=$PATH:/FULLDIRECTORYYOUWROTEDOWN/
export PATH
4) Download the ARM toolchain
https://sourcery.mentor.com/sgpp/lite/arm/portal/package5385/public/arm-none-linux-gnueabi/arm-2009q3-67-arm-none-linux-gnueabi.bin
and
https://sourcery.mentor.com/sgpp/lite/arm/portal/package5355/public/arm-none-eabi/arm-2009q3-68-arm-none-eabi.bin
5) Install the ARM Toolchain
create the directory /opt/toolchains/arm-2009q3/
Code:
sudo mkdir /opt/toolchains/arm-2009q3/
then install the toolchain using /opt/toolchains/arm-2009q3/
as the install directory
Code:
sudo chmod +x arm-2009q3-68-arm-none-eabi.bin
sudo chmod +x arm-2009q3-67-arm-none-linux-gnueabi.bin
sudo ./arm-2009q3-67-arm-none-linux-gnueabi.bin -i console
sudo ./arm-2009q3-68-arm-none-eabi.bin -i console
6) Compile
Extract your source code and go to the directory Kernel and do the following
WARNING: MAKE SURE THERE ARE NO SPACES IN YOUR FILEPATH BECAUSE THE MAKEFILE DOESNT LIKE THEM.
Code:
make clean
make arch=arm sidekick_rev02_defconfig
make ARCH=arm HOSTCFLAGS="-g -O3" -j8 CROSS_COMPILE=/opt/toolchain/bin/arm-none-eabi-
Now copy any of the resulting compiled ko files into the initramfs file you have extracted and you should have what you need to package a kernel.
you forget initramfs
windxixi said:
you forget initramfs
Click to expand...
Click to collapse
yeah I kept it out so that somebody would post a boot.img then could do steps related to that. I am looking for a boot.img to get initramfs from
unpack zImage
Sent from my SGH-T839 using XDA
---------- Post added at 08:46 AM ---------- Previous post was at 07:49 AM ----------
and how to pack a boot.img?
A request to anyone building SK4G kernels.
Please disable the keystroke logging printk statements in the file:
Code:
drivers/input/keyboard/s3c-keypad.c
The lines look like this:
Code:
//printk("\nkey Pressed : key %d map %d\n",i, pdata->keycodes[i]);
and
Code:
//printk("\nkey Released : %d map %d\n",i,pdata->keycodes[i]);
It is possible to recover the actual keystrokes from the numerical codes those statements log, and the messages go into the dmesg buffer. So it's pretty easy to extract them and determine exactly what the user typed.
In the latest Samsung sources I've seen, those lines were already commented out. It makes sense to enable them while debugging a new ROM build, but please do disable them prior to building a kernel intended for general consumption.
Do you guys know if the available source code will produce a kernel that will work with kj2? the kernel version in SGH-T839_Opensource_Update1 looks to match up, but I compilied a zImage and it didn't boot on stock kj2. but I could very well be missing something.
I have done a small amount of kernel work on an HTC device, but I basically just used the Rom Kitchen to pack up my zImages with a boot.img-ramdisk to create a boot.img. I guess I might need a little more instruction for packing up a Samsung kernel. Is it also an option to just tar up the zImage and flash it with Odin/Heindall?
Thanks for this thread, and for any other advice!
Sent from my SGH-T839 using Tapatalk 2
In case it might be useful to someone else working on building a kernel.
The official and Bali_SK4G sources both seem to insist on building with debug symbols enabled for some of the modules. In particular, i was ending up with dhd.ko being 2.4 MB in size, where it should have been less than 400 KB.
The ideal case would be to determine why the debug symbols are being included -- commenting out the labelled debug options in the bcm4329 Makefile didn't accomplish this.
But a workaround is to strip the modules after the build is finished, before assembling the initramfs.
Has anyone been able to build a working zImage for KJ2 using Dr. Honk's Bali sources [1] and sduvick's KJ2 ramdisk files [2]?
I have been able to build a zImage of a reasonable size (6520 KB). But when I flash this to the KERNEL partition using heimdall, the device boot loops to the B&W Sidekick logo. It doesn't get far enough to show any adb log output.
I can then use the same heimdall flashing procedure to flash the Platypus Egg v1 zImage, or other KJ2-compatible zImage files, and the device boots and works properly.
So I'm trying to figure out what I'm doing wrong in building my zImage. If anyone has any advice I would be appreciative.
[1] https://github.com/drhonk/Bali_SK4G
[2] https://github.com/sduvick/SK4g_KJ2_Ramdisk
I got an updated Bali_SK4G kernel booting using the ramdisk from GenericGinger 2.0.
I have worked up some patches to disable the logging of keystrokes and other more trivial debug spew in dmesg. Also included is a Makefile patch that was required for the compile to complete with my toolchain.
https://carbon.flatlan.net/nxd/patches_Bali_SK4G_nxd.tar.bz2
md5sum: 5d14ac32de155cdca0fd82f14bc4ceca
These patches are GPL licensed, in compliance with the license for the Linux kernel itself. I make no guarantees about their suitability for any purpose. I grant permission to use them to anyone who would like to do so, so long as they comply with the GPL.
I'd like to make a compiled kernel available with these changes, but XDA's rules can be interpreted to mean that I must obtain permission from a series of upstream contributors, some of whom may not be reachable. Perhaps a moderator will clarify the parameters of the permission rule.

Kernel-Perf/Oprofile support?

As the title implies, I'm trying to figure out is any kernel includes perf or OProfile support.
What is perf?
https://perf.wiki.kernel.org/index.php/Main_Page
What is OProfile?
http://oprofile.sourceforge.net/news/
I know that in some sources... I can see in /arch/Kconfig:::
Some options for OProfile...
/////////////////////
config OPROFILE
tristate "OProfile system profiling"
depends on PROFILING
depends on HAVE_OPROFILE
select RING_BUFFER
select RING_BUFFER_ALLOW_SWAP
help
OProfile is a profiling system capable of profiling the
whole system, include the kernel, kernel modules, libraries,
and applications.
If unsure, say N.
config OPROFILE_EVENT_MULTIPLEX
bool "OProfile multiplexing support (EXPERIMENTAL)"
default n
depends on OPROFILE && X86
help
The number of hardware counters is limited. The multiplexing
feature enables OProfile to gather more events than counters
are provided by the hardware. This is realized by switching
between events at an user specified time interval.
If unsure, say N.
config HAVE_OPROFILE
bool
/////////////
How do I enable these?
In addition to that, I see perf under tools, how do I enable it?
<><> What I want to do?
I'm doing some college research on app's performance.
And I'm well done using MethodTracing.
I want to be able to run stress test codes on the tablet and measure the different speeds every test achieves.
Thank you.
At first glance, OProfile Event Multiplex won't work because it depends on the x86 architecture.
Im not interested only in OProfile.
As you may see, I mention Perf too.
As a possibility of tracing...
OProfile is enabled in my kernel (should be in all kernels ). Perf on the other hand, I need to check.
Thanks, can you direct me to your kernel.
Also I was trying franco Kernel, I'm seeing OProfile is enabled too, but I can't see to get it running though.
To see if OProfile is enabled in the kernels I had used, i just pull out the kernel config.gz file from my phone and read it.
What I'm trying to see...
this values with y
CONFIG_PROFILING=y
CONFIG_OPROFILE=y
CONFIG_HAVE_OPROFILE=y
CONFIG_OPROFILE_ARMV7=y
Click to expand...
Click to collapse
To get the file:::
on a terminal...
adb pull /proc/config.gz
gunzip -c config.gz > .config
Click to expand...
Click to collapse
Update:
Also one can see if OProfile is installed once inside a root terminal
Just type # opcontrol --help
It should give you some usage info about opcontrol.
opcontrol: usage:
--list-events list event types
--help this message
--verbose show extra status
--verbose-log=lvl set daemon logging verbosity during setup
levels are: all,sfile,arcs,samples,module,misc
--setup setup directories
--quick setup and select CPU_CYCLES:150000
--timer timer-based profiling
--status show configuration
--start start data collection
--stop stop data collection
--reset clears out data from current session
--shutdown kill the oprofile daeman
--callgraph=depth callgraph depth
--event=eventspec
Choose an event. May be specified multiple times.
eventspec is in the form of name[:count], where :
name: event name, see "opcontrol --list-events"
count: reset counter value
--vmlinux=file vmlinux kernel image
--kernel-range=start,end
kernel range vma address in hexadecimal
xbin (busybox) MUST be installed for this to work also.
Errors I'm having, while I'm trying to use it on my nexus 7 3G+WIFI::
..Having errors when I run setup… //Can’t see to get it running .
# opcontrol --setup
it outputs:
mount: No such device
# opcontrol --start //doesn't start the trace, says can’t find folder….
it outputs:
Cannot open /dev/oprofile/enable: No such file or directory
http://forum.xda-developers.com/showthread.php?t=2373410&page=3
I too checked for these flags only. Also during the compile it actually picked up oprofile.o etc. Therefore kernel has OProfile.
Just a heads up on perf.
PERF is a modern tool and requires some kernel components that are only supported from the 2.6.36 Linux kernel (K36) and onward. If you are using the 2.6.32 Linux kernel (K32) you should use OProfile for CPU profiling.
If you are building a custom Android/Linux kernel please check that the following lines are present in your .config:
2.6.36 KERNEL (K36)
CONFIG_PROFILING=y
CONFIG_PERF_EVENTS=y
CONFIG_HW_PERF_EVENTS=y
CONFIG_PERF_ANDROID_BACKTRACE=y
CONFIG_CACHE_PL310_PERF_EVENTS=y
You can test to see if the target device already has these kernel configuration options via the following:
adb pull /proc/config.gz config.gz &&
gunzip -c config.gz | grep '\(CONFIG_O*PROFIL\)\|\(_PERF_EVENTS\)'
see more::
http://docs.nvidia.com/tegra/data/How_To_Profile_a_Tegra_Android_NDK_Application_with_PERF.html
Actually regarding OProfile, I just tested out the commands you listed earlier. They work on my kernel perfectly.
Perf is a different story though.
sgt. meow said:
Actually regarding OProfile, I just tested out the commands you listed earlier. They work on my kernel perfectly.
Perf is a different story though.
Click to expand...
Click to collapse
Perfect, then I just need to actually succesfully build your kernel from source or get the dropbox link of the compiled kernel to work.
That's what I was trying to do yesterday.
Apparently dropbox is block in my work network.
Unfortunately Dev-Host does not want to work for me. I'll try mirroring it to Sendspace or Mediafire. Wait a while.
sgt. meow said:
Unfortunately Dev-Host does not want to work for me. I'll try mirroring it to Sendspace or Mediafire. Wait a while.
Click to expand...
Click to collapse
I got dropbox to work using a proxy..
Thank you.
Any direction on a tutorial to learn on how to build the kernel from source my self?
Update::
Flashing oxydo kernel on nexus 7 3g+wifi (tilapia) right now...
http://source.android.com/source/building-kernels.html
Adjust as needed.
sgt. meow said:
http://source.android.com/source/building-kernels.html
Adjust as needed.
Click to expand...
Click to collapse
Thank you very much.
Gonna start building, and changing parameters in .config file of the kernel.
Ultimate goals:
-Get both perf and OProfile to work with your kernel.
-Know how to replicate this task so it can be replayed later in other android kernels.

[KERNEL] Enabling Netfilter/AFWall+ on Ainol Novo 7 Paladin (MIPS)

I spent entirely too much time on this, so I'll post my boot.img and my findings here in case it's useful to anyone else in the future.
Paladin ROMs:
This page and this thread have working links to CWM and Superuser zips.
This page has a link to an ICS 4.0.3 ROM running Linux 3.0.8. I installed this ROM, but was disappointed with the kernel's feature set. Important options like CONFIG_IP_NF_TARGET_REJECT and CONFIG_IP_NF_TARGET_LOG were disabled.
This page has a custom ROM by "pinkflozd". I wasn't able to find this image in the wild. It may have a newer kernel (3.0.23?) but AFAICT it doesn't have the Netfilter changes I needed either.
Custom kernel build:
I stumbled across this kernel and used it as a baseline. Then I enabled:
Various missing Netfilter features (e.g. LOG and REJECT targets)
CONFIG_TUN
CONFIG_CIFS
The process looks like:
Install CWM
Find the .zip file for the ROM you want to use, e.g. the ICS 4.0.3 link above
Install that ROM and make sure the stock kernel works
Create a new boot.img with the desired options enabled
Flash the new boot.img with CWM
Basic steps to create the new boot.img:
Code:
git clone -b paladin-3.0.8 git://github.com/cernekee/linux
cd linux
git submodule init
git submodule update
cd paladin
cp /path/to/boot.img orig.img
make NDK=/opt/android-ndk-r9b
# if desired, edit kernel code or .config, and rerun "make"
The scripts under linux/paladin/ will extract the ramdisk from orig.img, then create a new boot.img based on your kernel source tree. For more details on the kernel build, see paladin/README .
Kernel installation:
To flash the new image, reboot into CWM, then:
Code:
adb push boot.img /tmp/
adb shell "dd if=/tmp/boot.img bs=1048576 seek=3 count=8 of=/dev/block/mmcblk0 ; sync"
# hit the reset button again
Other random findings:
I did not have any luck with the "z4root" app, although ro.secure=0 on this ROM so "adb shell" always gives you a root shell. It did take some work to find Superuser/su binaries that worked on MIPS.
Enabling Netfilter's conntrack option seemed to cause dhd.ko to become unstable, possibly because it affected binary compatibility with existing kernel modules. So I left it alone.
This ROM is missing native iptables/ip6tables binaries, so AFWall needs to be set to use the builtin copies. The latest AFWall betas do ship with MIPS binaries now (the purpose of this exercise was to test them).
Checking the box to enable IPv6 crashes AFWall instantly. Need to investigate this.
AFWall's inbound connection option probably will not work, due to the lack of conntrack in the kernel.
This ROM appears to be missing some Java libraries needed for ICS+ VpnService apps to work.
NDK r9b is the first NDK release with support for the "MXU" SIMD instructions supported by the Ingenic JZ4770 chip. Prior to this, most people used Ingenic's special toolchain to build the kernel.
To forcibly boot into CWM, hold down VOL+ while pressing the reset button.

Categories

Resources