I compiled source code referring to http://source.android.com/source/building-running.html and downloaded apt binaries for my Nexus 4g s .I did following after building:
fastboot flash recovery recovery.img
fastboot flash boot boot.img
fastboot flash system system.img
fastboot flash userdata userdata.img
fastboot erase userdata
fastboot erase cache
Now, I cannot see anything on my phone. What could be wrong? Wasn't the source I built suitable for my device? But, I am pretty sure I have downloaded correct source code and binaries.
To rescue your device back, use fast boot to flash the factory image back.
To check why you have this issue, please check:
If you did not see ANYTHING after reboot, your boot.img (contains kernel) is not correct
If you just see the boot animation but it goes on forever, your system.img is not correct
You should:
Make sure you have download the correct source code and switch to the correct branch
Make sure you are using the correct build configuration by lunch and select correct product
The AOSP does not contains everything, you have to download or pull out from your old system to get the proprietary binaries.
Related
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've got a spare Nexus 5, and I've decided to play along and try to build android for it. However, when I try to boot what I've built, it shows only the 'Google Logo and open padlock' splashscren, and does nothing more.
My steps in building the whole android os:
Kernel:
I download msm kernel from git, then I check out remotes/origin/android-msm-hammerhead-3.4-marshmallow-mr1 branch, then I build the kernel in following way:
export PATH=/home/netaro/Android/AndroidSourceCode/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/:$PATH
cd MSMKernel
export ARCH=arm
export CROSS_COMPILE=arm-linux-androideabi-
make clean
make hammerhead_defconfig
make CONFIG_NO_ERROR_ON_MISMATCH=y CONFIG_FRAME_WARN=0
Then, I copy arch/arm/boot/Image and arch/arm/boot/zImage-dtb to where android source code lives, to device/lge/hammerhead-kernel directory.
Then, I build android by doing following steps ->
. ./build/envsetup.sh
make clean
lunch 19
#tried selecting kernel by this variable, but changes nothing, won't boot
#export TARGET_PREBUILT_KERNEL=/home/netaro/Android/MSMKernel/arch/arm/boot/zImage-dtb
make updatepackage -j4
After it all builds, I unzip out/target/product/hammerhead/aosp-hammerhead...zip package, boot the phone to fastboot, and fastboot flash each element:
fastboot flash boot boot.img
fastboot flash system.img
fastboot flash cache cache.img
fastboot flash recovery recovery.img
fastboot flash userdata userfata.img
Then, I select Start in bootloader, and it stops on the 'Google with open padlock' screen... Android source code is synced to a marshmallow source code via repo sync (I don't remember the name right now).
So, what am I doing wrong? Is there something I'm missing?
Okay, seem solved. It seems like qcom-hammerhead-... binaries from google's "Binaries for Nexus Devices" site are required to make it work. Download qcom-hammerhead-... from there, unpack to where source code lives, and rebuild.
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 am stuck flashing android to my nexus 7.
Steps to build image:
branch: refs/tags/android-4.4.2_r1
lunch : aosp_flo-userdebug
What i´ve done so far after building the image:
Like descibed in docs:
http://source.android.com/source/building-running.html
sudo fastboot flashall -w -p /home/stefan/bin/out/target/product/flo/
Gives me the following error:
could not load android-info.txt: No such file or directory.
So no luck with that, tried searching google but didnt find anything.
Downloaded an official rom 4.4.2 (KOT49H) from the nexus driver page:
https://developers.google.com/android/nexus/drivers
Deleted everything in the update package (zip) and putted my files in.
Then did sudo sh flash-all.sh
This method do flash the rom onto the device, but it also wont boot.
It hangs on the google splash screen.....
Is there anybody who can tell me how to properly flash my AOSP rom to device?
Your number 2 definitely will not work, and you shouldn't bother going down that route.
So the first issue you might have is you may be trying to build the wrong image, there are two Nexus 7s. Grouper is the designation for the first generation Nexus 7 and Flo is the designation of the 2013 Nexus 7, so make sure you have those right.
The second issue you may be having is the build may be failing. Are you sure that your make completed successfully? Your final message should say something similiar to
Install system fs image: out/target/blah/blah/blah/system.img
If you didn't see a line like that your build failed in which case you should diagnose that.
The third issue is you may be pointing at the wrong file. The line you are giving expects a full package, and you may not have created one. Try doing this instead:
sudo su
. build/envsetup.sh
lunch aosp_flo-userdebug
fastboot flashall -w
This will look for the generated files from the build automatically without you having to point at them, so long as you have selected the proper lunch option. Another issue you may be having is you may be confusing your shell with sudo, I am guessing you haven't bothered setting up the proper USB Permissions (see configuring USB access on the AOSP Build Guide. If you don't want to bother setting up USB permissions, then just initialize your environment as the super user after you have built when you need to flash (not before, or all your files will belong to root!)
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.