I am not familiar with a Android kernel compile process.
But I encountered a problem recently, and it troubled me so much.
Here is the problem descrition:
Based on Android, I build customed images including boot.img, system.img and so on.
Then I need to flash those images to physical device in order to boot to Android Home Screen.
Before compiling those images files, I have set a new kernel command line:
CONFIG_CMDLINE="root=/dev/mtdblock2 rw init=/init console=ttyS0, 115200 mem=128M uard_dma android"
After compiling those images, I opened boot.img in vim and saw the following string in it:
"root=/dev/mtdblock2 rw init=/init console=ttyS0, 115200 mem=128M uard_dma android"
But when I flashed the boot.img into device, I got the different output like this:
**Kernel command line: console=ttyO2,115200n8 earlyprintk**
In other word, I set the kernel command line value, and it was wrote into boot.img, but when
flash boot.img into device, I got a different kernel command line value.
Has anybody ever encountered this problem and got it fixed?
Really appreciating your help.
Thanks advanced!
The bootloader will be passing a command line to the kernel.
For example if u-boot bootloader is used,
it will be contained in the u-boot variable bootargs
This can be verified at the bootloader prompt.
For example if the device is using u-boot bootloader.
Connect the device to your PC over a serial prompt.
Launch a serial emulator on your PC (minicom, teraterm, hyper-terminal).
Power-on the device.
Press any key to halt the device boot at the bootloader stage itself.
Now on the u-boot prompt enter the following command:
u-boot# printenv
This will list all the uboot-variables. Note the value of variable bootargs.
This can be modified by using the following command:
u-boot# setenv bootargs ''
To save this value across reboots use the following commmand:
u-boot# saveenv
Similar functionality is available in other bootloaders as well.
Related
I am a newbie student.
I am trying to run a Raspberry Pi Emulator on QEMU.
PC specs are Intel q8200, quad-core 2,4 GHz, Nvidia GeForce 1 GB. 4GB RAM
https://prnt.sc/uvpi0h
The above image is where you can see the commands and the state of the running QEMU. And other things.
https://prnt.sc/uvplco
This is in my download folder for this project.
I've tried to run different kernels (stretch and booster), even different Pi Emulator images, but the same mistake.
I've seen that in some solutions, a guy said that he hadn't included his BIOS in commands and that helped him, but I dunno how to include or specify BIOS in CMP.
All files inside the Qemu folder (images and kernel) are matching the start.bat commands folder, so that is all ok.
I've tried to do all of that through this channel instructions, but since it is outdated, I've just downloaded the latest software.
https://www.youtube.com/watch?v=xiQX0YXYuqU&t=138s&ab_channel=TechWizTime
What could be the solution and what is the problem?
Thanks in advance!
EDIT: Windows10 pro is the OS
UPDATE 1: Added this command: -boot no -display gtk,gl=of
still the same.
UPDATE 2:
qemu-system-arm -kernel kernel-qemu-4.4.12-jessie -cpu arm1176 -m 256 -M versatilepb \
-no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
-redir tcp:5022::22 \
-hda 2016-05-27-raspbian-jessie-lite.img
I've used this to solve the problem. Although it is another version of the Raspberry Pi, for my needs it is not relevant now.
The important error message in the output is the one from the guest kernel which reads:
Error: unrecognized/unsupported machine ID (r1 = 0x00000183)
and then lists the machine types it is capable of booting on. (As a side note, providing error messages as screenshot images is rather awkward -- copying the text itself into the question makes it searchable and copyable.)
It looks like you're trying to boot a guest kernel which requires a device tree, but you haven't passed it a device tree. You need to give QEMU also a -dtb option whose argument is the correct dtb for this kernel and for the machine type ('versatilepb') that you are running it on.
I am trying to learn the kernel customization and for this I have target OnePlus 6T device. I am able to compile the kernel source code on my Ubuntu 18 with the following steps:
Download latest dtc from https://packages.ubuntu.com/cosmic/a...piler/download and install it.
Clone kernel source code: git clone https://github.com/OnePlusOSS/androi...lus_sdm845.git
Clone ToolChain: git clone -b linaro-4.9-arm-linux-androideabi https://github.com/ArchiDroid/Toolchain prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-linaro-4.8
Open terminal at prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-linaro-4.9 and run: export CROSS_COMPILE=$(pwd)/bin/aarch64-linux-android-
Navigate to kernel source code path in the same terminal.
export ARCH=arm64 && export SUBARCH=arm64
make clean
make mrproper
mkdir Out
make O=Out sdm845_defconfig
make O=Out DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y DTC_EXT=dtc -j4
Following are the last lines of compilation:
CC drivers/media/platform/msm/broadcast/tspp.mod.o
CC drivers/media/platform/msm/dvb/adapter/mpq-adapter.mod.o
CC drivers/media/platform/msm/dvb/demux/mpq-dmx-hw-plugin.mod.o
GZIP arch/arm64/boot/Image.gz
CC drivers/soc/qcom/llcc_perfmon.mod.o
CC drivers/video/backlight/lcd.mod.o
CC net/bridge/br_netfilter.mod.o
LD [M] drivers/char/rdbg.ko
LD [M] drivers/media/platform/msm/broadcast/tspp.ko
LD [M] drivers/media/platform/msm/dvb/adapter/mpq-adapter.ko
LD [M] drivers/media/platform/msm/dvb/demux/mpq-dmx-hw-plugin.ko
LD [M] drivers/soc/qcom/llcc_perfmon.ko
LD [M] drivers/video/backlight/lcd.ko
LD [M] net/bridge/br_netfilter.ko
CAT arch/arm64/boot/Image.gz-dtb
make[1]: Leaving directory '/home/.../KernelCustomization/android_kernel_oneplus_sdm845/Out'
Now, the next step is to flash the image. I have rooted OnePlus 6T device and I am confused with the three image files generated after successful compilation i.e.
arch/arm64/boot/Image.gz-dtb
arch/arm64/boot/Image.gz
arch/arm64/boot/Image
I need a favour in:
What image can I use to flash on android device?
Is booting a image with TWRP is enough to flash kernel?
Found Google documentation
https://source.android.com/devices/bootloader/partitions-images
As per following lines from google documentation:
boot: The boot partition contains a kernel image and a RAM disk combined via mkbootimg. In order to flash the kernel directly without flashing a new boot partition, a virtual partition can be used:
kernel: The virtual kernel partition overwrites only the kernel (zImage, zImage-dtb, Image.gz-dtb) by writing the new image over the old one. To do this, it determines the start location of the existing kernel image in eMMC and copies to that location, keeping in mind that the new kernel image may be larger than the existing one. The bootloader can either make space by moving any data following it or abandoning the operation with an error. If the development kernel supplied is incompatible, you may need to update the dtb partition if present, or vendor or system partition with associated kernel modules.
I think I have to use arch/arm64/boot/Image.gz-dtb for flashing the kernel. My understanding is that Image.gz-dtb is a virtual image that can be used to flash only kernel on android.
Still, I am not able to figure out the correct step to flash it. I am wondering if I will do something wrong then I will break my device so I want to be sure before flashing that it will work.
Any help or guidance will be very helpful at this moment.
I found the steps that are needed to flash the custom kernel on android device i.e.
First we need to get the boot image of stock firmware we can get it by running following commands:
adb shell "ls -la /dev/block/platform/soc/1d84000.ufshc/by-name/" > MoreInfo\msm_partitions.txt
Note the boot partition name e.g. boot_a -> /dev/block/sde11 boot_b -> /dev/block/sde39
Missing steps to make boot.img with command dd command.
Download the latest Android Image Kitchen from this thread.
Run the following with the boot image: unpackimg.sh .img
Locate the zImage file and replace it with your kernel image (rename it to what came out of the boot image)
Run the following to repack: repackimg.sh
Flash the new boot image with fastboot or TWRP!
I need some more information on the missing steps. Actually the process written above is working on devices that has only one boot partition. Does any one know how can I flash my single kernel image on a device that has a/b partitioning?
Update:
I searched over the internet for A/B partitioning and I found that these are used for seamless updates i.e. One partition is active at a time and another partition which is inactive can be used to flash the update. On reboot, another partition will become active and One partition will become inactive. More Info: https://www.xda-developers.com/how-a...opment-on-xda/
If my understanding is true then I just need to follow following steps to find the correct image to be used at the first step of flashing the kernel:
fastboot getvar all | grep “current-slot”
dd if="path to boot of active slot" of=/sdcard/boot.img
Continue with boot.img and flash the kernel with above written steps for flashing a kernel.
Anyone who has this knowledge, please confirm. I will be very thankful to you.
A/B OTA update
Firstly, you need to confirm whether your phone is A/B OTA update or not by following command
fastboot getvar slot-count
If the command returns '2', then your phone supports A/B OTA update which means you have two boot
partitions 'boot_a' and 'boot_b', otherwise, there should only be one partition 'boot'
boot image
The images you built (Image.gz-dtb) are just kernel images with device tree. They
are not enough for flashing to boot partition since there should be ramdisk and boot arguments combined.
The ramdisk content contains normal boot binaries for non-A/B OTA system or recovery binaries for
A/B OTA system. You need to find official ramdisk images and combine with your kernel image. Normally
mkbootimg will be used to create boot image in AOSP android.
Flashing
fastboot flash boot boot.img
This works on both A/B and non-A/B system since image will be flashed to default active partition (boot_a
is by default if you do not have OTA or using 'fastboot set_active' to change it)
On A/B system, you can also use 'fastboot getvar current-slot' to get active slot and specific flash
partition 'fastboot flash boot_a boot.img' or 'fastboot flash boot_b boot.img'
XDA provides scripts to flash kernel images (Image.gz-dtb) with following steps:
a. Dump boot.img from your phone
b. Extract ramdisk.img from boot.img
c. Combine Image.gz-dtb with ramdisk.img to new boot.img
d. Flash new boot.img to boot partition
https://forum.xda-developers.com/oneplus-6t/development/kernel-holydragon-t3878107
provides customized kernel and flash scripts, you should check and find your suitable way to flash your kernel image.
I downloaded a third-party ROM, and I want to run it on the emulator first before flash it into the phone. Here is the contents of cm-11-20140911-NIGHTLY-p3110.zip:
1. boot.img
2. file_contexts
3. META-INF/
4. recovery/
5. system/
I unpacked boot.img using the script unpack-bootimg.pl and get boot.img-kernel, and boot.img-ramdisk.cpio.gz. Then I repacked the system using the make_ext4fs and got system.img.
I created an AVD and execute:
emulator -system ~/cm11/system_new.img -ramdisk ~/cm11/boot.img-ramdisk.cpio.gz -kernel ~/cm11/boot.img-kernel -avd and442
but all I got is nothing, the emulator screen is just black. There is no log message from adb -s emulator-5554.
Now I am confused:
can the third-party ROM be tested by the emulator?
Am I doing the right way?
Yeah, why not.
We can flash a third-party ROM on Android AVD. But first you must know the following things:
1. The Android Emulator is itself a device, like your Moto G or Xperia
2. Every ROM is device-specific (supports a device-specific Kernel)
(on many sites/blogs you got information like you have to replace system.img file from .android\avd\avdname.avd, but it is technically incorrect, because you also require ramdisk.img.)
To do this, you need to create your own AOSP repository by downloading the particular repository and have to build your own .img files)
You can do it in two ways:
replace files system.img and ramdisk.img from location .android\avd\avdname.avd
Build your own AOSP. Before... make in "lunch" select target as: Emulator (like: genericX86), i.e., generate all emulator specific .img files
I have tried many things. It's a bit critical, but interesting. The following links may help you:
To run your cooked ROM on Emulator (link down. Try this, from archive.org).
To Create AOSP Project
I've selected several of the trace tags and when I run the trace (from DDMS) I get the following output:
Unexpected error while collecting system trace. Unable to find trace start marker 'TRACE:':
error opening /sys/kernel/debug/tracing/options/overwrite:
No such file or directory (2)
error openi(cuts off the error here)
indeed there is no debug file in the kernel directory, but which mechanism will generate the necessary path?
It looks like your cellphone is running a boot(kernel) image that does not support systrace.
"error opening /sys/kernel/debug/tracing/options/overwrite: No such file or directory (2)"
This error message means adb daemon (the adb module running on device side) could not find /sys/kernel/debug/tracing/options/overwrite on your device's file system. systrace works over adb and communicates with kernel though sysfs nodes under /sys/kernel/debug/tracing. If these nodes are not exposed on you phone for whatever reason, systrace just will not work.
So you should first get a shell on your device using:
adb shell
Then browse to confirm if /sys exists at all and if /sys/kernel/debug/tracing exists.
If they are there which is extremely unlikely, you have to debug systrace.py to figure out how come systrace think the nodes were not there. Otherwise, you need to flash a different boot image which has systrace support, because sysfs is controlled by kernel(mostly by configurations at compile time) and init.rc , both of which are part of boot image.
Flashing a different boot image might involve unlocking/rooting the device. You probably have to go to fan sites like xdadeveloper for information and image. Another option is to download the source of kernel for your device, compile kernel and make the boot image yourself. Linux is under GPL thus manufacturer of your device is obligated to release the source code of the specialized kernel they use.
-NAM
http://www.willpromo.com
You may need to slightly modify the kernel image(boot.img). The following work find for me, just for your reference.
open terminal and enter: $adb shell
(1) $su (2) $mount -t debugfs none /sys/kernel/debug. Now you should be able to see many directories under /sys/kernel/debug/. (You may cd into /sys/kernel/debug to confirm this)
Enter: $dd if=/dev/block/platform/msm_sdcc.1/by-name/boot of=/sdcard/boot.img to generate the boot.img kernel image from your device.
Use AndroidImageKitchen to unpack the boot.img and find the default.prop within Ramdisk folder. Then change ro.debuggable=0 to ro.debuggable=1. Repack the boot.img and flash boot it to your device.
Once the device boot, under terminal, enter: $adb root and message like: $restarting adbd as root may pop up. Disconnect the USB and connect again.
cd to the systrace folder, e.g. ~/androidSDK/platform-tools/systrace and use:
python systrace.py --time=10 -o mynewtrace.html sched gfx view wm
Now you may able to generate your own systrace files.
After I built the source code of android, I ran the following command and got the error.
#fastboot -w flashall
error: could not load android-info.txt
I had successfully built the source code for nexus one (build 5), and I found that there is a android-info.txt file in the directory out/target/passion/.
Also, I am sure that the phone is connected. When I run "fastboot devices", it shows the device.
Anybody know the reason?
Old thread so sorry for reactivating it, but it's still one of the top hits and it's unanswered.
My fix was to ensure I had the ANDROID_PRODUCT_OUT environment variable, and that it was pointing to
/home/{usr name}/{build directory}/out/target/product/{taget}
Again, sorry for resurrecting a dead post.
As $fastboot flashall -w
flash the Rom on connected device it needs to know which Run/Device/Product you want to flash as there might be many products available in out/target/product directory,
And so product is obtained by ANDROID_PRODUCT_OUT variable which should point to any product i.e.
/home/{usr name}/{build directory}/out/target/product/{taget}
And to set the ANDROID_PRODUCT_OUT we just need to do:
source build/envsetup.sh
lunch
and choose your product in lunch menu, so that fastboot flashall -w would know which product you wanna flash.
It depends on how the flash all script is organized. Try flashing into the partition directly.
Eg: fastboot flash system system.img
I observed this issue when trying to fastboot update an OTA package.
Eg: fastboot update xyz.zip.
Currect way to update via fastboot is
fastboot update updateImagename.img
Call lunch to set the environment variables needed.
For example,
'lunch aosp_flo-eng' can be called to make sure the environment is in order for the Nexus 7 [2013] tablet.