How to flash my custom Android binary from AOSP source code? - Google Pixel XL Questions & Answers

Hello, I'm working on a project with Pixel XL so, I'm trying to build Android source code and flash its output on my Pixel XL.
But there are some problems during flashing the img files.
This is my history how I have done so far.
1. Downloaded Android source code from AOSP home page and built it successfully. My build commands are:
Code:
$ source build/envsetup.sh
$ lunch aosp_arm64-eng
$ make -j8
and the output is:
Code:
[email protected]:~/AOSP/out/target/product/generic_arm64$ ls
android-info.txt build_fingerprint.txt cache.img current_build_config.mk dex_bootjars installed-files.json module-info.json obj_arm ramdisk.img root system userdata.img
boot.img cache clean_steps.mk data
2. I tried to flash the img files onto the device:
Code:
$ fastboot flash system system.img
$ fastboot flash boot boot.img
$ fastboot flash cache cache.img
However, it seems that Pixel XL does not have cache partition so that the last command failed.
3. After I executed above commands, I rebooted the device and it trapped in boot loop:
warning for bootloader unlock -> Google logo -> warning for bootloader unlock -> ...(repeat) -> enter recovery mode and stay in the mode for a while(about 5 min) -> warning for bootloader unlock -> ...(repeat)
What did I do in wrong way? I just built Android source for eng binary because I need root privilege.
And How can I build and flash Android source code for eng binary?
Please give me any small clue to resolve it.
Thanks!

Related

Back to Stock (4.1.2 image) and re-root project - Help needed

Hello again.
After having ROMed and MODing to my liking, I decided to go back to stock since the 4.1.2 is up for my GN version (maguro).No other partition has been flashed (radio, kernel, etc).
My goal is to get into a stock state using 4.1.2 images and be unrooted.
I am thinking of booting into fastboot then:
fastboot flash all yakju-jzo54k-factory-92ff9457.tgz
I guess that command should:
- flash everything inside the .tgz
- install stock recovery image
- unroot the phone (?)
but wouldn't clear my data and apps I guess.So afterwards I could either:
- fastboot erase userdata
- lock and unlock the bootloader
The goal is to erase all apps and /sdcard parition.Right or wrong?
After I am set up I would like to root the phone but doing it manually and not via CWM .zip installation.
Is there a guide somewhere explaining what needs to be done for rooting cause searching didn't help much...
Thanks in advance.
The GNex toolkit is your friend....
http://forum.xda-developers.com/showthread.php?t=1392310
Download it, connect to phone to PC and follow the prompts. I recently did the same thing (I'm on VZW) completely unrooted and back to stock when VZW released the 4.1 update. Used it for a week or two and came back to CM10 Nightlies. Used the toolkit and re-rooted and what not....
I would recommend donating and getting the auto update feature activated. The link above includes the most recent released download, but it was actually a ways behind if you have the auto update feature active. The dev does not require a certain amount donated, so I felt $15 was plenty.
(Just checked the download link is 7.8 and the auto update brings you up to 8.2)
TR-909 said:
Hello again.
After having ROMed and MODing to my liking, I decided to go back to stock since the 4.1.2 is up for my GN version (maguro).No other partition has been flashed (radio, kernel, etc).
My goal is to get into a stock state using 4.1.2 images and be unrooted.
I am thinking of booting into fastboot then:
fastboot flash all yakju-jzo54k-factory-92ff9457.tgz
I guess that command should:
- flash everything inside the .tgz
- install stock recovery image
- unroot the phone (?)
but wouldn't clear my data and apps I guess.So afterwards I could either:
- fastboot erase userdata
- lock and unlock the bootloader
The goal is to erase all apps and /sdcard parition.Right or wrong?
After I am set up I would like to root the phone but doing it manually and not via CWM .zip installation.
Is there a guide somewhere explaining what needs to be done for rooting cause searching didn't help much...
Thanks in advance.
Click to expand...
Click to collapse
OK, let's get started.
- extract yakju-jzo54k-factory-92ff9457.tgz (tgz means it's a tar file, further compressed with gzip), in the end you'll see:
valhalla% ls -ltch gimages/yakju-jzo54k
total 246M
-rwxr-xr-x 1 bk201 users 831 Oct 13 10:47 flash-all.sh
-rw-r--r-- 1 bk201 users 2.3M Oct 13 10:46 bootloader-maguro-primelc03.img
-rw-r--r-- 1 bk201 users 232M Oct 13 10:46 image-yakju-jzo54k.zip
-rw-r--r-- 1 bk201 users 13M Oct 13 10:46 radio-maguro-i9250xxlf1.img
-rw-r--r-- 1 bk201 users 789 Oct 13 10:46 flash-base.sh
Click to expand...
Click to collapse
- edit flash-all.sh, which contains:
Code:
fastboot flash bootloader bootloader-maguro-primelc03.img
fastboot reboot-bootloader
sleep 5
fastboot flash radio radio-maguro-i9250xxlf1.img
fastboot reboot-bootloader
sleep 5
fastboot -w update image-yakju-jzo54k.zip
from here, we will flash bootloader, radio, and update-image, but to do it manually, first we need to extract image-yakju-jzo54k.zip.
valhalla% unzip -l gimages/yakju-jzo54k/image-yakju-jzo54k.zip
Archive: gimages/yakju-jzo54k/image-yakju-jzo54k.zip
Length Date Time Name
--------- --------- ----- ----
4472832 2009-01-01 00:00 boot.img
4823040 2009-01-01 00:00 recovery.img
410365584 2009-01-01 00:00 system.img
140856312 2012-10-03 22:09 userdata.img
93 2012-10-02 15:03 android-info.txt
--------- -------
Click to expand...
Click to collapse
- last step, all the files in the same folder (i'm assuming you have fastboot in your path and device in bootloader mode, connected to the pc), enter the following commands:
Code:
1) fastboot flash bootloader bootloader-maguro-primelc03.img
2) fastboot reboot-bootloader
(..device will reboot into bootloader, obviously wait for bootloader screen to come up again)
3) (optional but recommended) fastboot flash radio radio-maguro-i9250xxlf1.img
4) fastboot reboot-bootloader
5) fastboot flash recovery recovery.img
6) fastboot flash boot boot.img
7) fastboot flash system system.img
8) (will wipe /data/media; optional) fastboot flash userdata userdata.img
TR-909 said:
The goal is to erase all apps and /sdcard parition.Right or wrong?
Click to expand...
Click to collapse
It's best to fresh start yes, but userdata is just /data/media.
also, with this process, no need to unroot. /system will be wiped.
if you want to root manually, and i'm pulling this from my head, you just need to push su binary to /system/xbin and chmod 0755 06755 it, and push supersu.apk to /system/app and chmod 0644 it. attention, this will either require the use of an exploit (for example, the one available to root without unlocking bl), or
Code:
fastboot boot cwm_or_twrp.img
....remount system rw (we have temp root because of custom recovery)
Code:
mount -o rw /dev/block/platform/omap/omap_hsmmc.0/by-name/system /system
push su binary/supersu.apk to the previously said locations and set permissions (i've checked a flashable zip i got from efrant and it seems it's 06755)
Code:
adb push supersu/system/xbin/su /sytem/xbin/su
adb shell chmod 06755 /system/xbin/su
adb push supersu/system/bin/su /system/bin/su
adb shell chmod 06755 /system/bin/su
adb push supersu/system/app/Superuser.apk /system/app/Superuser.apk
adb shell chmod 0644 /system/app/Superuser.apk
adb reboot
done. someone please post if i missed/got anything wrong. this is i would go about it.
you could just have read this.
Hey bk201doesntexist.
Actually I read the guide of efrant and was questioning myself about fastboot flash all command but I probably haven't understand it well.I am going to proceed and do all steps as you suggest.
Back to work... will report soon.
Thanks.
EDIT: Currently on 4.1.2 updating gapps, whole procedure took less than 3 minutes including reboots! Didn't thoroughly check new update but first I am going to bring back my apps and stuff through TiB.
About Rooting: so basically I should boot temporarily on CWM and Adb do the root thingie.Ok let me look into it...

[Q] Issues with Signing Android Factory Images, ROMs and OTA Files.

I am doing R&D on FOTA(Firmware Update Over the Air) using Nexus 7-Wifi(grouper). For which I followed the following steps.
1. Downloaded the android source from source.android.com for v 4.2.2_r1 and v 4.3_r1
2. Downloaded the binaries for grouper, extract it to my source folder.
3. Then I compiled the source code using following commands.
i. source build/envsetup.sh
ii. lunch full_grouper-userdebug
iii. make -j8 dist
4. After few tries, I had success in compiling the source for Nexus 7(grouper).
5. I got following files in $out/source_4.2.2/dist folder
-----------------------------------------------
adb*
android-common-carousel.jar
android-common.jar
android-info.txt
android-support-v13.jar
android-support-v4.jar
android-support-v7-gridlayout.jar
build.prop
com.android.nfc_extras.jar
fastboot*
full_grouper-apps-eng.root.zip
full_grouper-emulator-eng.root.zip
full_grouper-img-eng.root.zip
full_grouper-ota-eng.root.zip
full_grouper-symbols-eng.root.zip
full_grouper-target_files-eng.root.zip
gpl_source.tgz
guava.jar
installed-files.txt
jsr305.jar
mkbootfs*
mkbootimg*
mkyaffs2image*
mp4parser.jar
package-stats.txt
ramdisk.img
signapk.jar
vendor_owner_info.txt
-----------------------------------------------
6. Then I generated my own keys using /development/tools/make_key tool for media, testkey, releasekey, shared, platform.
Assume my keys are locate at /keys folder.
7. Then I created a signed target zip file using following command.
/source/build/tools/releasetools/sign_target_files_apks -v -p ../host/linux-x86 -d /keys full_grouper-target_files-eng.root.zip signed_target_files.zip
8. From signed target zip file I create
/source/build/tools/releasetools/img_from_target_files -v -p ../host/linux-x86 signed_target_files.zip signed_img_from_target_files.zip
9. Then I flashed the signed_img_from_target_files.zip using fastboot command using the following script:
----------------------------------------------------------------------
fastboot oem unlock
fastboot erase boot
fastboot erase cache
fastboot erase recovery
fastboot erase system
fastboot erase userdata
fastboot reboot-bootloader
sleep 10
fastboot -w update signed_img_from_target_files.zip
----------------------------------------------------------------------
10. The device gets flashed well and is working, but I am getting an log while flashing in which it is unable to find boot.sig, system.sig and recovery.sig
11. Now the otacerts.zip file contains a testkey which is not the one that I signed it with.
file located at "/system/etc/security/otacerts.zip" on device.
12. Now since the otacerts.zip is signed with the default key it gives a mismatch error which I tried to flash an OTA update which is signed by the my custom key.
Now my doubt is:
How can I add boot.sig, recovery.sig and system.sig to signed_img_from_target_files.zip?
Is there anything I am doing wrong?
Does the recovery checks the current ROM keys from "/system/etc/security/otacerts.zip"?
What is the correct procedure to sign the OTA update?
i am posting this reply just for people who are looking for help too,
you need to explicitly define "BUILD_SECURE := true" in your device make file so that android/build/core/Makefile will use device/*/$(TARGET_DEVICE)/releasekey.x509.pem for OTA_PUBLIC_KEYS

[Q] [SOLVED] Failed to create my own system.img

Hi all,
I'm trying to create my own system.img for the Nexus 7 2013 Wifi from the stock system.img from https://developers.google.com/android/nexus/images 5.0.2 LRX22G. Basically I did it the common way using the android repack tools http://forum.xda-developers.com/showthread.php?t=2600364 and I'm also using branch android-5.0.2_r1 from the git repo.
I'm flashing with the simple:
Code:
fastboot flash system mysystem.img
The problem I'm having is, even with an unmodified tree from system.img, the image I created always get the device stuck at the boot Google logo screen. If I flash the original system.img, then it is fine, so I think my flashing part is working.
The command line I used to create the image is:
Code:
./mkuser.img.sh -s /path/to/loop_mounted_system/ mysystem.img ext4 system 880803840
which will run:
Code:
make_ext4fs -s -T -1 -l 880803840 -a system mysystem.img /path/to/loop_mounted_system/
Has anyone here actually managed to create a working system.img?
Any suggestions would be much appreciated, thanks!
UPDATE: Using ext2simg instead of mkuserimg.sh/make_ext4fs fixes the problem!

[HowTO] Get rid of annoying "Kernel is not seandroid enforcing" message....

Hi,
I started to play with kernel hacking/configuration and I found the annoying red message
After a lot of research i found that we can get rid of it by adding at the end of boot.img file the SEANDROIDENFORCE text string, as following
echo SEANDROIDENFORCE >> boot.img
Best regards,
Marc
serdeliuk said:
Hi,
I started to play with kernel hacking/configuration and I found the annoying red message
After a lot of research i found that we can get rid of it by adding at the end of boot.img file the SEANDROIDENFORCE text string, as following
echo SEANDROIDENFORCE >> boot.img
Best regards,
Marc
Click to expand...
Click to collapse
Thanks.. Work bro..
diphons said:
Thanks.. Work bro..
Click to expand...
Click to collapse
Yeah, I'd like recommend to find a solution to get also rid of "set warranty bit kernel/recovery", the yellow warning is really annoying!
I was able to append the boot.img file with SEANDROIDENFORCE text string.
But how do you exactly write it back?
I'm on samsung note 4.
Code:
adb reboot recovery
adb shell
dd if=/dev/block/bootdevice/by-name/BOOT of=/sdcard/boot.img
echo SEANDROIDENFORCE >> /sdcard/boot.img
If i try to switch if and of path, I get an error
Code:
dd if=/sdcard/boot.img of=/dev/block/bootdevice/by-name/BOOT
dd: writing '/dev/block/bootdevice/by-name/BOOT': No space left on device
UnknownPlanet said:
I was able to append the boot.img file with SEANDROIDENFORCE text string.
But how do you exactly write it back?
Code:
adb reboot recovery
adb shell
dd if=/dev/block/bootdevice/by-name/BOOT of=/sdcard/boot.img
echo SEANDROIDENFORCE >> /sdcard/boot.img
If i try to switch if and of path, I get an error
Code:
dd if=/sdcard/boot.img of=/dev/block/bootdevice/by-name/BOOT
dd: writing '/dev/block/bootdevice/by-name/BOOT': No space left on device
Click to expand...
Click to collapse
In order to write the boot.img you need to use fastboot/bootloader mode of your device, adb reboot bootloader, then use `fastboot flash boot boot.img`
Alternatively, you can put the boot.img on your /sdcard boot to twrp then `cat boot.img > /dev/your/boot/partition`
The no space left on the device means that your file is bigger than the destination which is unusual if you built that boot img, from your example it seems that you save your partition and do not use a built boot.img
serdeliuk said:
In order to write the boot.img you need to use fastboot/bootloader mode of your device, adb reboot bootloader, then use `fastboot flash boot boot.img`
Alternatively, you can put the boot.img on your /sdcard boot to twrp then `cat boot.img > /dev/your/boot/partition`
Click to expand...
Click to collapse
It doesn't work, I'm on samsung note 4. I also have latest TWRP installed.
fastboot device keep saying:
< waiting for any device >
UnknownPlanet said:
It doesn't work, I'm on samsung note 4. I also have latest TWRP installed.
fastboot device keep saying:
< waiting for any device >
Click to expand...
Click to collapse
you need to find how to boot your device in bootloader mode, usually volDOWN+power together
serdeliuk said:
Alternatively, you can put the boot.img on your /sdcard boot to twrp then `cat boot.img > /dev/your/boot/partition`
Click to expand...
Click to collapse
Still error
Code:
~ # cat /sdcard/boot.img > /dev/block/bootdevice/by-name/BOOT
cat: write error: No space left on device
serdeliuk said:
The no space left on the device means that your file is bigger than the destination which is unusual if you built that boot img, from your example it seems that you save your partition and do not use a built boot.img
Click to expand...
Click to collapse
I use Custom ROM of Hani Base v1.01 here:
[ROM][6.0.1][TW][N910C/H/U] Hani Base v1.01 [18-04-2016][Deodexed][PreRooted]
Welcome to Hani Base ROM thread! Samsung Galaxy Note 4 SM-N910C N910CXXU2DPCB TW 6.0.1 THREAD INDEX: I. INTRODUCTION II. FEATURES III. DOWNLOADS IV. HOW TO FLASH #_____________________________# #include ...
forum.xda-developers.com
I have succcessfuly get and edit the boot.img but I don't know how to flash it back. Forking to make another whole custom ROM is not an option. I won't learn anything.
It's just a tiny append why so difficult.
serdeliuk said:
you need to find how to boot your device in bootloader mode, usually volDOWN+power together
Click to expand...
Click to collapse
There's no bootloader in my samsung note 4, adb reboot bootloader goes to system instead.
Home+Power+VolumeDown enters the download mode, but even then fastboot device still doesn't respond.
Do I need to use Odin or what?
You may need to ask questions about your boot options on the dedicated channel for your device, i do not own such device, but download mode is the fastboot mode as far as can remember, "fastboot devices" should show your device listed when in download mode.
Your steps to flash the boot.img fail because the file is bigger than your boot partition, does not fit there, you may need to seek for help form the img developers to see what to do. You can try to flash the boot.img on recovery partitions which is usually bigger and reboot to recovery, but pay attention, if you don't know how to go back to fastboot mode you are stuck with a bricked device
I was able to flash it without any change in the boot partition size by editing it manually using hex editor.
These are my steps
Code:
adb reboot recovery
adb shell "dd if=/dev/block/bootdevice/by-name/BOOT of=/sdcard/boot.img"
adb pull /sdcard/boot.img
I use Frhed hex editor to edit the last 16 bytes of boot.img into SEANDROIDENFORCE
Code:
adb push boot.img /sdcard/boot.img
adb shell "dd if=/sdcard/boot.img of=/dev/block/bootdevice/by-name/BOOT"
The problem right now is that, the red text is still there. What should be my next step?
UnknownPlanet said:
I was able to flash it without any change in the boot partition size by editing it manually using hex editor.
These are my steps
Code:
adb reboot recovery
adb shell "dd if=/dev/block/bootdevice/by-name/BOOT of=/sdcard/boot.img"
adb pull /sdcard/boot.img
I use Frhed hex editor to edit the last 16 bytes of boot.img into SEANDROIDENFORCE
Code:
adb push boot.img /sdcard/boot.img
adb shell "dd if=/sdcard/boot.img of=/dev/block/bootdevice/by-name/BOOT"
The problem right now is that, the red text is still there. What should be my next step?
Click to expand...
Click to collapse
I don't know if editing the boot.img works, probably should do, however, i found this solution poking around with third party device trees and worked for my samsung galaxy tab, if do not work on your phone then you may need to dig a bit deeper, however, if you use a third party image maybe you ask them why you have that on your screen, maybe they have another fix. Probably a bit of more info can be found here https://github.com/osm0sis/dhtbsign but i didn't spent time to read it. You can ask the developer about more info.
Your solution of device tree / dhtb is impressive on it's own, that's another big learning curve.
But I think I know the problem, because the Custom ROM Hani Base above is using H-Vitamin Kernal which is SELinux Permissive. No matter how I edit the boot.img file the red text message will always appears, unless I flash it with another kernel which is SELinux Enforcing.
UPDATE
This is even weirder.
By updating SuperSU into the latest version, the red text is missing from system mode. It still persist in recovery mode tough, because, well twrp need full access to begin with.
No Magisk here, it was an old custom ROM.
All official app from playstore is now gone but the official xda thread still remain:
[STABLE][2017.05.27] SuperSU v2.82
*** Urgent Update Notice *** We are deeply sorry about the installation errors and failures happened in v2.80. The new update v2.81 has rolled out on XDA and Play Store to fix the problem occured in v2.80. Chainfire has also...
forum.xda-developers.com
From reading the last pages of the thread, I got the official site of chainfire to download it.
SuperSU Download
The file name is
sr5-supersu-v2.82-sr5-20171001224502.zip
Just flash it with latest TWRP and you're done.
I still don't understand how could updating SuperSU could fix the problem.
But what a long journey, thank you so much @serdiluk , I learn so much things.

Pre Rooted PATCHED_BOOT.IMG (10.0.4) for Magisk Root

Original tutorial located at https://forum.xda-developers.com/oneplus-7t/how-to/guide-how-to-root-oneplus-7t-twrp-t3979307
Hello all. Just providing this file for convenience. All credit goes to original author of the guides. This file is a pre-rooted, magisk patched boot.img for firmware version 10.0.4. Use this boot.img for flashing/booting if you are on version 10.0.4 and want to have root using magisk.
!!!I AM NOT RESPONSIBLE FOR ANY DAMAGE DONE TO YOUR DEVICE. USE COMMON SINCE AND YOU WILL BE OK!!​
STEP 1 - Put phone into fastboot mode
Code:
adb reboot fastboot
STEP 2 - Boot the patched boot.img. Download here
Code:
fastboot boot patched_boot_10.0.4.img
STEP 3 - Backup current boot.img. Open an adb shell and find which block device contains your boot partition and then using dd, make a copy of it.
Open ADB Shell
Code:
adb shell
then
Code:
su
Find boot partition
Code:
ls -lah /dev/block/bootdevice/by-name | grep -i boot
You will see something like this as output:
boot_a -> /dev/block/sde11
boot_b -> /dev/block/sde38
Make copy of boot partition(s)
Code:
dd if=/dev/sde11 of=/sdcard/boot_backup.img
DO THIS FOR BOTH BOOT PARTITIONS, LABEL ACCORDINGLY. JUST IN CASE!
Backup boot.img file(s) to PC
FROM YOUR PC, OPEN COMMAND PROMPT AND DO FOR BOTH IMAGES.
Code:
adb pull /sdcard/boot_backup.img
STEP 4 - Install magisk manager
Get magisk manager APK from here. Download the app-release.apk and install on phone.
Code:
adb install app-release.apk
STEP 5 - Open magisk manager and select Install -> Direct Install.
After you have completed the above steps, if everything worked correctly, and you followed the steps with common sense, everything should be good to go.
The download link is not working. Do you still have a patched 10.0.4 boot image?

Categories

Resources