Good day for you. I just started to learn and work with android kernel development or internals. I purchased a development board on-line that uses AM3359 - TI Processor. Works fine with factory Images and I booted from SD_CARD.
Later I read the documentation and I tried to compile the kernel. Everything went well as expected. I do have a little questions that I would like to clear it regarding the files that were created.
I had a section in documentation in which I was asked to Create a Root FileSystem which gave me a file called ubi.img - What is this file ?
Later I was asked to create a tarball file providing the roots path which created me an other file rootfs.tar.bz2 - What is this file ?
My question is... both the files used the files from rootfs directory to create these files. What are these files for? What exactly ubi.img does and what is it used for? Is it used for flashing it to nand and rootfs.tar.bz2 is to boot if I am booting from SD_CARD ???
Thanks & Regards
I don't know much about AM3359 - TI Processor, but on most smartphones and also in the linux kernel requires a ramdisk which is usually compressed mostly it's a .gz file.
According to my experience when the file is decompressed and usually it contains hardware initialization routines which the kernel runs first during startup.
The .img files are where everything is stored.
Most commonly :
BOOT.img - Read Only Contains ramdisk and
the rootfs this are usually zImage + rootfs.tar.bz2
System.img- Also read only although can be remounted as read+write Contains
the operating system files e.g binaries like su, busybox etc.
Userdata.img- This is where all the users data and settings are stored.
The above are all that's necessary to get a system up and running.But we might have others such as Uboot.img Preloader etc, it varies depending on the platform.
Related
Background
I moved to my new AT&T Samsung phone. unfortunately this is is at Android 10 with selinux enforced
there is no way I can change it to permissive and anyway with the proven insecurity it is not worth doing it.
My WhatsApp folder has to be bound to a specific ext4 partition I created on my micro SD card. earlier with a custom ROM running permissive Linux this was possible without much Ado.
What I am trying to do
with enforced SeLinux stock ROM running Android 10 I would like to bind mount my WhatsApp data to /data/sdxt3/WhatsApp
which is the ext4 partition I created that I earlier mentioned .
Used the following guides for this:
Correctly Bind Mount Android Folder
BindFs Guide
Fuse Guide
Android-NDK-Cross-Compile-Build-Automator
bindfs is a brilliant idea but the Utilities needed to compile are very fragile & and I am running into a whole plethora of errors. Here is my compile output studded with errors -output
my questions
-how do I compile bindfs correctly for my Android architecture which is arm64-v8a ( and also need 1 for armeabi-v7a ) . the guide online is extremely convoluted especially for a noob like me
-with enforced Linux what are the options other than bindfs to achieve the above functionality.
maybe this may sound rhetoric because there isn't any AFAIK ( adoptable storage given my situation is not an option ) but I am nonetheless hopelessly optimistic.
-the source code for my stock ROM is available I would like to modify it so it can support ext4 natively without me writing a custom script to Mount it. How do I compile a custom kernel for my ROM with the kind of modifications I want .Can someone point me to a detailed guide without any ambiguity.
Hy Guys ..
I'm making a custom kernel project for my device, the project is almost done, but I'm having constraints about the camera, and in the kernel source there are no suitable drivers for my phone,
my last choice is just to unpack zimage stock .. can it be unpacked or not?
My Devices:
Smartfren Andromax Ec C46B2H
Qualcomm Snapdragon 410 Msm8916
Yes, but not much.
Similar to what Chris pointed out, the zImage is a binary blob which is self extracting when run by the cpu on system bootup.
So you can manually look into the initial uncompression code and do it yourself to get an uncompressed kernel binary also known as: uImage
Thats it. You cannot unpack it any further without counting disassembly.
This is in relation to this XDA thread and my thread on xda. This is a cross post from XDA, trying my luck on here.
Device specs, just in case someone asks
Device Specifications:
Current Android Version: Android Lollipop 5.1.1
Chipset: Marvell Armada PXA1908 (Note: Due to this being a rarely used chip, the CF-Auto root won't work)
Custom Recovery Status: TWRP 3.0.2-0 (Not working with lollipop)
Root Status (This is technically why I am here): Android KitKat 4.4.4 (Root), Android Lollipop 5.1.1 (NO ROOT Yet)
ARMv8 64-bit
Now let's get into my steps up to the point and then my problem.
Note: In the kernel readme it states to use the toolchain 4.8 but when I use it, it complains of not being able to find gcc. Also in the read me it states "get Toolchain download and install arm-eabi-4.8 toolchain for ARM EABI.(64bit)" and when reading up on it, it says to use aarch64 for ARM 64 Bit devices.
Device Source Code can be found at Here
cd ~/android
export CROSS_COMPILE=~/android/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-
cd ~/android/kernel
make ARCH=arm64 pxa1908_xcover3lte_eur_defconfig
make ARCH=arm64
This outputs: Image, Image.gz, .dts and .dtb files.
Where's the kernel readme (I believe this hasn't been update since kitkat) says the output will be,
- Kernel : Kernel/arch/arm/boot/zImage
- module : Kernel/drivers//.ko
Note: when trying to compile with the 32- bit ARM toolchain it fails, as the config is found in arm64, wheres other configs are found in arm.
So know I have a kernel (Image or Image.gz), and some .dts and .dtb files. Now to unpack boot.img, this is where problems occur. When trying to use tools like abootimg or the various different versions of unmkbootimg, they complain about non-standard boot.img.
or
While also try saving it as a zImage when its meant to be a Image.gz, or they extract it without throwing any errors, but when looking at the extracted files with a hex editor, it is all 00 throughout the files, therefore a useless file.
So therefor I tried manually unpacking with a hex editor and managed to get the kernel. Left is my Compiled and Right is the hex version.
Notice the difference in size, is this because the kernel in boot.img is stripped of its debugging items while mine isn't? If so I should look up on how to fix that.
But I am having troubles trying to extract the ramdisk via hex.
So is anyone able to Teach/Help me extract the boot.img properly (with tools like unmkbootimg or with a hex editor)
I have attached necessary files if you want to have a look at them yourself.
Files: Samsung xCover3 Files
Any help is appreciated.
After Numerous trial and error, I finally managed to output ramdisk.cpio.gz.
The start of a Gzip file in hex is, 1F 8B 08, therefor when using the search function in you had editor application you can narrow down your results to 1 or 2 files (2 Files for me as my kernel and ramdisk are both gzipped). You then follow it all the way down till you find a big bunch of zeros(seems like they are passing between files). When you reach the bunch of zeros include the first "00" at the end of the other hexidecial. E.G. End of one of my gzip files is "CE 24 00 00 00....00 (ZERO PADDING BETWEEN FILES), Threaded the end of my file is "CE 24 00".
Knowing this I was able to successfully extract and verify both my kernel and ramdisk files are correct.
I've noticed that I have some directories inside my android phone which look the same.
What the different between /sbin, /system/sbin, /system/bin, /system/xbin?
/system is the main Android directory for storing immutable components generated by the build of the AOSP. This includes native binaries, native libraries, framework packages, and stock apps. It’s usually mounted read-only from a separate image from the root file system, which is itself mounted from a RAM disk image.
Android also includes many directories commonly found in any Linux system, such as /dev, /proc, /sys, /sbin, /root, /mnt, and /etc. These directories often serve similar if not identical purposes to the ones they serve on any Linux system, although they are very often trimmed down, as is the case of /sbin and /etc, and in some cases are empty, such as /root.
More than 150 command-line utilities are scattered throughout Android’s root file system. /system/bin contains the majority of them, but some “extras” are in /system/xbin, and a handful are in /sbin.
/sbin: In Linux, this would hold binaries essential to the system administrator. In Android, it contains only ueventd and adbd.
/bin: All native binaries and daemons built as part of the AOSP. All modules built with BUILD_EXECUTABLE are here. The only exception is adbd, which has the LOCAL_MODULE_PATH set to /sbin and is therefore installed there instead.
/xbin: “Extra” binaries generated by some of the packages that are built within the AOSP but aren’t essential to the system’s operation.
Thanks goes to Mr: Karim Yaghmour , The great ; The author of Embedded Android tutorial.
I am building the android source code and getting new system.img . I try to flash the new system.img on a device and I see that I need another file called boot.img. What is this file ? what is used for ? how can I get it for my device ?
boot.img contains the kernel and ramdisk, critical files necessary to load the device before the filesystem can be mounted. You have to generate the boot.img yourself using mkbootimg, a tool provided by AOSP.
All the details you need are available at this xda-developers thread.
This google discussion thread may also be useful