View Single Post
Old 02-19-2013, 01:35 PM   #11
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
K3 specifics (from binaries)

The K3 kernel is compressed, which makes it a lot more fun - - -

Find the gzip magic number:
Code:
core2quad K3 $ od -A d -t x1 main_kernel-3.4.img | grep '1f 8b 08 00'
0013408 68 65 20 6b 65 72 6e 65 6c 2e 0a 00 1f 8b 08 00
Copy all after that magic number:
Code:
core2quad K3 $ dd if=main_kernel-3.4.img bs=1 skip=13420 of=main_kernel-3.4.gz
2154388+0 records in
2154388+0 records out
2154388 bytes (2.2 MB) copied, 8.9767 s, 240 kB/s
Notice that you have to count upto (including the first byte) the magic number.

Check that you got what you expected:
Code:
core2quad K3 $ od -A d -t x1 main_kernel-3.4.gz | grep '1f 8b 08 00'
0000000 1f 8b 08 00 fb 7d 42 50 02 03 9c bd 0d 7c 54 c5

core2quad K3 $ file main_kernel-3.4.gz
main_kernel-3.4.gz: gzip compressed data, from Unix, last modified: Sat Sep  1 16:28:27 2012, max compression
The magic number is now aligned at the start of the file, and 'file' recognizes it.

Uncompress the little sucker:
Code:
core2quad K3 $ gunzip main_kernel-3.4
gzip: main_kernel-3.4.gz: decompression OK, trailing garbage ignored
Well Phooey, how many times did they compress this thing?

Code:
core2quad K3 $ od -A d -t x1 main_kernel-3.4 | grep '1f 8b 08 00'
0098944 1f 8b 08 00 f7 7d 42 50 02 03 bc 5a 0f 6c 14 57
3001360 47 5f 53 54 1f 8b 08 00 f5 7d 42 50 02 03 94 3c
Two compressed files inside of a compressed file, oh what fun we have.

The first file:

Code:
core2quad K3 $ od -A d -t x1 main_kernel-3.4 | grep '1f 8b 08 00'
0098944 1f 8b 08 00 f7 7d 42 50 02 03 bc 5a 0f 6c 14 57

3001360 47 5f 53 54 1f 8b 08 00 f5 7d 42 50 02 03 94 3c
core2quad K3 $ dd if=main_kernel-3.4 bs=1 skip=98944 of=main_kernel-3.4.b.gz
3776904+0 records in
3776904+0 records out
3776904 bytes (3.8 MB) copied, 15.7225 s, 240 kB/s

core2quad K3 $ od -A d -t x1 main_kernel-3.4.b.gz | grep '1f 8b 08 00'
0000000 1f 8b 08 00 f7 7d 42 50 02 03 bc 5a 0f 6c 14 57
2902416 47 5f 53 54 1f 8b 08 00 f5 7d 42 50 02 03 94 3c

core2quad K3 $ file main_kernel-3.4.b.gz
main_kernel-3.4.b.gz: gzip compressed data, from Unix, last modified: Sat Sep  1 16:28:23 2012, max compression

core2quad K3 $ gunzip main_kernel-3.4.b.gz
gzip: main_kernel-3.4.b.gz: decompression OK, trailing garbage ignored

core2quad K3 $ file main_kernel-3.4.b
main_kernel-3.4.b: ASCII cpio archive (SVR4 with no CRC)
The first of the two compressed files statically linked to the kernel (making them GPL) is the initramFS.

So turn that into a file system tree again, just for the interested (keep in mind, this binary is staticly linked into a GPL binary).

Code:
core2quad K3 $ mkdir initramfs-3.4

core2quad K3 $ cd initramfs-3.4

core2quad initramfs-3.4 $ sudo su

core2quad initramfs-3.4 # cpio -i -d -m --no-absolute-filenames -I ../main_kernel-3.4.b
cpio: Removing leading `/' from member names
2073 blocks
You **MUST** be 'root' to preserve permissions and ownership (and create any special files).
So it is utmost importance that you include that: "--no-absolute-filenames" option unless you intend to trash your workstation.

What did that give us?
Code:
core2quad initramfs-3.4 # ls -l
total 28
drwxr-xr-x 2 1004 5000 4096 2013-02-19 13:53 bin
drwxr-xr-x 7 root root 4096 2013-02-19 13:53 dev
lrwxrwxrwx 1 root root   18 2013-02-19 13:53 init -> /bin/recovery-util
drwxr-xr-x 3 1004 5000 4096 2013-02-19 13:53 lib
drwxr-xr-x 2 root root 4096 2012-09-01 16:28 proc
drwx------ 2 root root 4096 2012-09-01 16:28 root
drwxr-xr-x 2 1004 5000 4096 2012-09-01 16:28 sbin
drwxr-xr-x 2 root root 4096 2012-09-01 16:28 sys
Since everything in that is (now) GPL because it was staticly linked into a GPL binary, will just tar-ball it and attach it here.
BIG NOTE: There is a way to build a kernel that uses an initramfs file that **DOES NOT** require it to be staticly linked into the kernel binary. Since Amazon chose to give this one away, we will just accept their offer here.

The second file:

Code:
core2quad K3 $ dd if=main_kernel-3.4 bs=1 skip=3001364 of=main_kernel-3.4.a.gz
874484+0 records in
874484+0 records out
874484 bytes (874 kB) copied, 3.37191 s, 259 kB/s
core2quad K3 $ od -A d -t x1 main_kernel-3.4.a.gz | grep '1f 8b 08 00'
0000000 1f 8b 08 00 f5 7d 42 50 02 03 94 3c db 72 db 36
Check what that yielded:
Code:
core2quad K3 $ file main_kernel-3.4.a.gz
main_kernel-3.4.a.gz: gzip compressed data, from Unix, last modified: Sat Sep  1 16:28:21 2012, max compression
Give that one a chance:
Code:
core2quad K3 $ gunzip main_kernel-3.4.a
gzip: main_kernel-3.4.a.gz: decompression OK, trailing garbage ignored
Ah, that file-in-a-file is the compressed kernel configuration file (at run-time, accessible in /proc).
That will do for this post.

K3(kernel-3.4):
Code:
Linux-2.6.26-rt-lab126
armv6
- - - - -
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.26-rt-lab126
# Sat Sep  1 14:28:21 2012
- - - - -
CONFIG_ARCH_MXC=y
CONFIG_ARCH_MX35=y
CONFIG_SDMA_IRAM_SIZE=0x1000
CONFIG_MX35_OPTIONS=y
CONFIG_MACH_MX35_LUIGI=y
CONFIG_MACH_LUIGI_LAB126=y
CONFIG_PROC_BOOTDATA=y
CONFIG_PROC_BOARDID=y
CONFIG_ARCH_HAS_RNGC=y
CONFIG_ARCH_HAS_EVTMON=y
CONFIG_DMA_ZONE_SIZE=24
CONFIG_UTMI_MXC=y
CONFIG_MXC_PWM=y
CONFIG_CPU_32=y
CONFIG_CPU_V6=y
CONFIG_CPU_32v6=y
CONFIG_CPU_ABRT_EV6=y
CONFIG_CPU_PABRT_NOIFAR=y
CONFIG_CPU_CACHE_V6=y
CONFIG_CPU_CACHE_VIPT=y
CONFIG_CPU_COPY_V6=y
CONFIG_CPU_TLB_V6=y
CONFIG_CPU_HAS_ASID=y
CONFIG_CPU_CP15=y
CONFIG_CPU_CP15_MMU=y
CONFIG_ARM_THUMB=y
CONFIG_OUTER_CACHE=y
CONFIG_CACHE_L2X0=y
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
CONFIG_PREEMPT_NONE=y
CONFIG_HZ=100
CONFIG_AEABI=y
CONFIG_OABI_COMPAT=y
- - - - plus a lot more of course - - - -
Will just save that .config file and attach it here.
Code:
core2quad K3 $ mv main_kernel-3.4.a dot-config-3.4
core2quad K3 $ gzip dot-config-3.4
Attached Files
File Type: gz dot-config-3.4.gz (8.8 KB, 241 views)
File Type: gz initramfs-3.4.tar.gz (508.3 KB, 259 views)

Last edited by knc1; 02-19-2013 at 03:37 PM.
knc1 is offline   Reply With Quote