My experience to port CWM Recovery to my coolpad 5310 - Android General

It took me about one week to port cwm recovery to coolpad 5310, which build on msm8610 according to the default.prop.
I'd like to share my experience and code here if anybody need it.
First, I began with this guide:
http://xda-university.com/as-a-developer/porting-clockworkmod-recovery-to-a-new-device
It's very clear, but with a error. I should type
Code:
lunch cm_<device name>-eng
instead of
Code:
lunch full_<device name>-eng
. I guess that the information needed being updated.
It was definitely worth notice that I pull the cm-10.2 instead of cm-11 for my phone coming with Android 4.3.1. I think with same version the CWM recovery may be easier to port.
Then I flashed the img file to my device with fastboot. But when I reboot device into recovery, the phone did it but reboot again to android. It's tough because I have no idea how to debug.
Luckily, when I try
Code:
fastboot boot <recovery img>
by accident, I find following information:
Code:
FAILED (remote: dtb not found)
After a google, I find mkbootimg_tools and repack the recovery I compiled with the img.dt from stock recovery. The kernel and adbd boot!
But there was nothing on my screen. I found the recovery program exited with segmentation fault. So I explore the /tmp/recovery.log and compare it with log file from stock recovery. I found following info in my recovery.log:
Code:
ERROR: failed to mmap framebuffer
and there was no framebuffer info in my recovery.log.
After reading code, adding debug info in code and googling information about msm8610, I almost got the reason. Qualcomm do something strange and we could no operate /dev/graphics/fb0 directly. I have no idea how to resolve it.
Then I find this discussion, and cover it. The problem is so alike, but I cannot still resolve my problem until I found there is no file named graphics_overly.c in my code tree. Finally, I found it in code tree of cm-11.0, then I checkout to cm-11.0 and built it. The recovery program run well.
There is two thing worth noticing. Firstly, I'm sure the only variable taking effect is TARGET_USES_QCOM_BSP := true after reading the code. Then, adding --dt dt.img to BOARD_MKBOOTIMG_ARGS could avoid repack the recovery.img any more.
The final problem is that my /sdcard is symlinked to /sdcard so I could not mount sdcard on it. I have fix the bug and now I'm trying to post the patch to upstream(Cyanogenmod): http://review.cyanogenmod.org/#/c/80390/
There is some files:
The project on my github.
The recovery.img, it's fast in China, but maybe slow in other countries, so I also upload it as an attachment.

Related

Nandroid v2.0 - Full NAND backup and restore tool (tried and tested!)

* What is Nandroid Backup v2.0?
Nandroid Backup is a set of tools and a script that will enable anyone who has root on their G1 and has the engineering/dev spl bootloader [1] (or has a dev phone) + a recovery image with busybox and adbd running as root [2] to make full system backups. These can then be restored using the fastboot [3] commandline tool and your phone in SPL/bootloader mode (hold camera + power). This allows you to create regular backups of your entire phones NAND flash so that you can restore a backup when something breaks. Its backup method works on a level that allows you to completely break, wipe or corrupt any or all partitions and still restore the phone to a working state within a few minutes. This works great for those who use their G1 for normal activities but also want to test their ideas which might break the phone, or when not having an extra G1 to keep purely as a development phone.
* Requirements for use
- Android G1 phone in recovery mode with busybox installed, including appropriate symlinks to at least tar and md5sum, as well as 'adb shell' support running as root. I recommend using JesusFreke US RC30 or UK RC8 v1.2 recovery image. You can flash the RC30 v1.2 recovery.img on your G1 if you don't want to bother constructing your own image. Of course you are free to use your own recovery image and it will work if you set it up correctly.
- dump_image-arm and mkyaffs2image|mkyaffs2image-$ARCH compiled in the current dir, as well as root on a linux/mac (POSIX) machine for constructing system and data images. root is required because the uid, gid and file permissions need to be preserved while extracting and creating the yaffs2 images. You are free to run the script as a normal user and then run the appropriate commands yourself as root; the commands are printed when you run the script as a regular user.
If you don't trust the provided binaries, you are free to compile them yourself. The source for the tools are included. For dump_image, edit nandtools/android-imagetools/Makefile so that you use the proper cross compiling gcc. For mkyaffs2img, just running make in tartools/yaffs2/utils/ should give you a binary. You are on your own in getting stuff compiled, but it should be easy to figure out from the Makefile.
* How to use this (the easy part)
Just boot your phone in recovery mode with the correct recovery.img (one that has adb shell as root + busybox installed with symlinks to tar, md5sum etc) and connect it to your pc/laptop/server. Then run the nandroid.sh script. If something is wrong or missing, it will tell you.
* What about restore?
If you have the dev phone or have root on the G1 and flashed the engineering/dev bootloader, then you can power on your phone while holding camera to get into the bootloader/SPL. It should then show some androids on skateboards (if not, you don't have the engineering/dev bootloader). Plug in your USB cable and push back until it says FASTBOOT instead of Serial0. Now you can fire up fastboot flash {partition} {file.img}.
Fastboot itself is part of the android SDK. If you download and compile your own mydroid build, it should sit in mydroid/out/host/linux-x86/bin/fastboot Perhaps in a future version I'll include a restore script, but for now I don't see the need.
One tip, if you are in fastboot mode on your phone and 'fastboot devices' doesn't show anything, try as root. You might need to edit your udev setup to allow your user to access the phone's usb device (which is different from the one you're in when in recovery or normal boot).
* Where's the source?
Sources are included. They are copies of the Android sources with various changes mostly made by Brainaid.
Everything in the zip is also also available through subversion:
svn co http://svn.infernix.net/nandroid/
Note that I DO NOT recommend checking out the latest revision unless you know damn well what you are doing. No guarantees if you play with fire. At the very least do diff against the latest released version.
* Credits
Bash script hacked together by infernix.
dump_image adapted from flash_image and extended by Brainaid.
Original mtdutils source and mkyaffs2image source by Google.
[1] http://forum.xda-developers.com/showthread.php?t=455860
[2] http://forum.xda-developers.com/showthread.php?t=443713
[3] http://www.gotontheinter.net/fastboot
DOWNLOAD HERE or:
wget http://dx.infernix.net/nandroid-2.0.zip
Originally Posted by trmacdonal
How to Restore your phone on a Windows PC using a Nandroid backup
I am going to assume you already have a Nandroid backup created on your SD card using JF 1.31's recovery Alt-B feature. The backup will create a folder called nandroid on your SD.
What you need:
The Android SDK:
Fastboot Windows Binary in this post:http://forum.xda-developers.com/showpost.php?p=3083753&postcount=1
From your Nandroid backup you need three files:
data.img
system.img
boot.img
Steps to restore your phone
1) Put the files Adb and AdbWinApi.dll from the tools folder in the Android SDK into C:\WINDOWS\System32 folder on your PC. Substitute the correct drive letter if windows is not installed on you C: drive
2) Put the Windows Fastboot.exe into the C:\WINDOWS\System32 folder on your PC
3) Create a folder on the C: drive of your PC called android. The path should be C:\Android.
4) Copy the Nandroid backup files data.img, system.img, and boot.img from your SD card to the folder called Android you created by mounting your SD card as removable disk.
5) Unplug the USB cord and power off your phone
6) Power up your phone by holding CAMERA+POWER, you should see three androids on skateboards. If you don't see this go install the Engineering boot loader
7) Plug the USB cord back into your phone and press back. The screen on your phone should say fastboot.
8) Make sure your pc is using the correct driver. Open the device manager on your pc. It is helpfull to have all other USB storage devices besides your phone unplugged for this part. Look for a USB Mass Storage device in the list of the USB devices. Right click on it and update the driver. Pick the option to browse for a driver on your pc. The driver is located in the Android SDK your downloaded in the folder called usb_driver. If this is done right you will now see a device called HTC Dream
9) Press start, go to run and type cmd (If you are on Vista just type cmd in the search box and hit enter). The command prompt will pop up.
10) Type cd C:\android
then enter the following commands:
fastboot flash system system.img
it will say Sending, then writing and say OKAY if it was successful
then type
fastboot flash userdata data.img
wait for the second OKAY and type
fastboot flash boot boot.img
wait for the second OKAY and type
fastboot reboot
Your phone should now be restored exactly as you had it when it was backed up.
This sounds great! I just recently used the other script to make a backup, but this sounds like it's been a bit more polished
I attempted to compile the yaffs2 utils under OS X 10.5 and I encountered a problem during linking:
ln -s ../yaffs_ecc.c yaffs_ecc.c
gcc -c -I/usr/include -I.. -O2 -Wall -DCONFIG_YAFFS_UTIL -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline -static yaffs_ecc.c -o yaffs_ecc.o
gcc -c -I/usr/include -I.. -O2 -Wall -DCONFIG_YAFFS_UTIL -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline -static mkyaffsimage.c -o mkyaffsimage.o
mkyaffsimage.c:120: warning: ‘yaffs_CalcNameSum’ defined but not used
gcc -o mkyaffsimage yaffs_ecc.o mkyaffsimage.o
ld: absolute addressing (perhaps -mdynamic-no-pic) used in _process_directory from mkyaffsimage.o not allowed in slidable image
collect2: ld returned 1 exit status
make: *** [mkyaffsimage] Error 1
Any thoughts? I'm heading off to google to figure out what a 'slidable image' is.
-jwb
No idea, and I don't have access to a mac. You could change the makefile and skip compiling of mkyaffsimage, you only need mkyaffs2image, but you'll probably get similar errors.
infernix said:
No idea, and I don't have access to a mac. You could change the makefile and skip compiling of mkyaffsimage, you only need mkyaffs2image, but you'll probably get similar errors.
Click to expand...
Click to collapse
Google seems to imply its a common issue, possibly solved in a later XCode rev.. We'll see how that pans out.
mkyaffs2image on mac
It built just fine for me when I did the whole mydroid build. It's in out/host/darwin-x86/bin.
Is there some way to mount the yaffs2 image, though? Does one need to do the kernel patch etc on a linux box and then use loop?
Wow this a awesome. Thanks for all the hard work everyone.
you are are ridiculous.....ly good!
so you telling me if we have root and jf's modified rc30 v1.2 and be brick our phone, there's another quarter in your pocket after you die (game over) and you can start a whole new game?
hbguy
hbguy said:
so you telling me if we have root and jf's modified rc30 v1.2 and be brick our phone, there's another quarter in your pocket after you die (game over) and you can start a whole new game?
Click to expand...
Click to collapse
If you have flashed the engineering bootloader (the androids on skateboards appear when powering on your phone while holding camera button), yes.
haha very nice ::borat voice::
P.S. For the borat fans out there, he is making a new movie, insider info baby
hbguy!
Error messages but still makes backups?
I got the following when I ran nandroid.sh on my mac. Are the error messages safe to disregard -- it seems like it worked:
Code:
nandroid v2.0
mounting system and data read-only on device
error: device not found
error: device not found
start adb portforward on port 4531
error: device not found
checking free space on cache
error: device not found
./nandroid.sh: line 152: [: -le: unary operator expected
pushing tools to /cache: dump_image-arm... error: device not found
done
Getting md5sum on device for boot...error: device not found
done ()
Dumping boot from device over tcp to backup_2008-12-19//boot.img...
error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for boot.img
Getting md5sum on device for recovery...error: device not found
done ()
Dumping recovery from device over tcp to backup_2008-12-19//recovery.img...
error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for recovery.img
Getting md5sum on device for misc...error: device not found
done ()
Dumping misc from device over tcp to backup_2008-12-19//misc.img...
error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for misc.img
Getting md5sum on device for tar for system...error: device not found
done ()
Dumping tar file for system backup_2008-12-19//system.tar...error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for system.tar
To convert system.tar to system.img, run the following commands as root:
mkdir /tmp/-system-tmp
tar x -C /tmp/-system-tmp -f backup_2008-12-19//system.tar
/Users/brock/Inbox/nandroid-2.0/mkyaffs2image /tmp/-system-tmp/system backup_2008-12-19//system.img
Make sure that /tmp/-system-tmp doesn't exist befor you extract, or use different paths.
Remember to remove the tmp dirs when you are done.
Getting md5sum on device for tar for data...error: device not found
done ()
Dumping tar file for data backup_2008-12-19//data.tar...error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for data.tar
To convert data.tar to data.img, run the following commands as root:
mkdir /tmp/-data-tmp
tar x -C /tmp/-data-tmp -f backup_2008-12-19//data.tar
/Users/brock/Inbox/nandroid-2.0/mkyaffs2image /tmp/-data-tmp/data backup_2008-12-19//data.img
Make sure that /tmp/-data-tmp doesn't exist befor you extract, or use different paths.
Remember to remove the tmp dirs when you are done.
Getting md5sum on device for tar for cache...error: device not found
done ()
Dumping tar file for cache backup_2008-12-19//cache.tar...error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for cache.tar
To convert cache.tar to cache.img, run the following commands as root:
mkdir /tmp/-cache-tmp
tar x -C /tmp/-cache-tmp -f backup_2008-12-19//cache.tar
/Users/brock/Inbox/nandroid-2.0/mkyaffs2image /tmp/-cache-tmp/cache backup_2008-12-19//cache.img
Make sure that /tmp/-cache-tmp doesn't exist befor you extract, or use different paths.
Remember to remove the tmp dirs when you are done.
removing tools from /cache: dump_image-arm... error: device not found
done
unmounting system and data on device
error: device not found
error: device not found
Backup successful.
brocktice said:
I got the following when I ran nandroid.sh on my mac. Are the error messages safe to disregard -- it seems like it worked:
Code:
nandroid v2.0
mounting system and data read-only on device
error: device not found
[/QUOTE]
This didn't work at all.
What I don't really get is that it continues at all, if the device isn't connected it should not even start.
It's a bit hard to tell because I don't have a mac here. Please run the following commands on your mac and post them:
[code]which adb
adb devices
BLAH=foo
echo "without $BLAH"
echo "with ${BLAH}"
I'll look at this soon, should have access to a mac sometime in the next few weeks
Click to expand...
Click to collapse
brocktice said:
I got the following when I ran nandroid.sh on my mac. Are the error messages safe to disregard -- it seems like it worked:
Code:
nandroid v2.0
mounting system and data read-only on device
error: device not found
error: device not found
start adb portforward on port 4531
error: device not found
checking free space on cache
error: device not found
./nandroid.sh: line 152: [: -le: unary operator expected
pushing tools to /cache: dump_image-arm... error: device not found
done
Getting md5sum on device for boot...error: device not found
done ()
Dumping boot from device over tcp to backup_2008-12-19//boot.img...
error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for boot.img
Getting md5sum on device for recovery...error: device not found
done ()
Dumping recovery from device over tcp to backup_2008-12-19//recovery.img...
error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for recovery.img
Getting md5sum on device for misc...error: device not found
done ()
Dumping misc from device over tcp to backup_2008-12-19//misc.img...
error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for misc.img
Getting md5sum on device for tar for system...error: device not found
done ()
Dumping tar file for system backup_2008-12-19//system.tar...error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for system.tar
To convert system.tar to system.img, run the following commands as root:
mkdir /tmp/-system-tmp
tar x -C /tmp/-system-tmp -f backup_2008-12-19//system.tar
/Users/brock/Inbox/nandroid-2.0/mkyaffs2image /tmp/-system-tmp/system backup_2008-12-19//system.img
Make sure that /tmp/-system-tmp doesn't exist befor you extract, or use different paths.
Remember to remove the tmp dirs when you are done.
Getting md5sum on device for tar for data...error: device not found
done ()
Dumping tar file for data backup_2008-12-19//data.tar...error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for data.tar
To convert data.tar to data.img, run the following commands as root:
mkdir /tmp/-data-tmp
tar x -C /tmp/-data-tmp -f backup_2008-12-19//data.tar
/Users/brock/Inbox/nandroid-2.0/mkyaffs2image /tmp/-data-tmp/data backup_2008-12-19//data.img
Make sure that /tmp/-data-tmp doesn't exist befor you extract, or use different paths.
Remember to remove the tmp dirs when you are done.
Getting md5sum on device for tar for cache...error: device not found
done ()
Dumping tar file for cache backup_2008-12-19//cache.tar...error: device not found
done
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
md5sum verified for cache.tar
To convert cache.tar to cache.img, run the following commands as root:
mkdir /tmp/-cache-tmp
tar x -C /tmp/-cache-tmp -f backup_2008-12-19//cache.tar
/Users/brock/Inbox/nandroid-2.0/mkyaffs2image /tmp/-cache-tmp/cache backup_2008-12-19//cache.img
Make sure that /tmp/-cache-tmp doesn't exist befor you extract, or use different paths.
Remember to remove the tmp dirs when you are done.
removing tools from /cache: dump_image-arm... error: device not found
done
unmounting system and data on device
error: device not found
error: device not found
Backup successful.
Click to expand...
Click to collapse
I had this problem too but disconnecting and reconnecting the usb cable fixed it.
SplasPood said:
I had this problem too but disconnecting and reconnecting the usb cable fixed it.
Click to expand...
Click to collapse
Well the script is supposed to check for a device and stop when theres a problem.
also if this can happen at all then other things might go wrong on mac too. I think mac requires bash variables to be called like #{VAR} and doesn't handle $VAR for some reason.
update on mac issues
OK, it seems it was all a problem on my end -- didn't have the correct set-up. I now have the appropriate recovery image (thought I did, but I guess I didn't) and it seems to work, except for this:
Code:
Comparing md5sum...parseopts.c:76: setup_check: fopen '--status': No such file or directory
The images and such now have non-zero filesize, though. That's an improvement over before.
yeah i've gotten some more reports. will make it mac OS X compatible soonish
I can't seem to figure out how to get this to work. If someone who knows linux can IM me, that'd be great. (or is there a way to do this on XP?)
AIM:adventninja
Thanks in advance
Does this also back up radio and htc secure nand partitions?
tranks
backed up successfully.
for those who get errors in the script.
i assume you have installed modiffied recovery image + jesusfreke's rc30v2 and
before running the script check this.
this steps involves having linux i dont know how its done in windows maybe its the same i dont know.
1: disconnect usb cable
2: check that you have adb program in your path, eg: /usr/bin/adb
if you dont know what adb is, adb is a program to comunicate with phone via usb (its not the same as transfering files between pc and g1),
adb program is found in android-sdk-linux_x86-1.0_r2, unpack it, and copy adb to your path, just google and find latest android sdk.
once you downloaded sdk unpacked it and copied the executable file adb to /usr/bin go to next step.
3: boot the phone into recovery mode ( power up the phone and holding "power + home" keys and a triangle will appear on its screen.
4: in your pc open konsole, su root, and plug your USB G1
5: type adb devices
if the response to this command is "HTC G1 bla bla.. found.", then you are ready to execute the script, it will no give errors and you will backup its contents.
if you dont see HTC G1 words, then its likely your phone was detected as "USB MASS STORAGE", and we dont want that. we need that its detected as a "HTC DIRECT ACCESS DEVICE".
a: control +c
b: killall adb (this is important)
c: unplug USB, plug it in another port,
d: go to step 5
hope it helps.
infernix said:
* What is Nandroid Backup v2.0?
Nandroid Backup is a set of tools and a script that will enable anyone who has root on their G1 and has the engineering/dev spl bootloader [1] (or has a dev phone) + a recovery image with busybox and adbd running as root [2] to make full system backups. These can then be restored using the fastboot [3] commandline tool and your phone in SPL/bootloader mode (hold camera + power). This allows you to create regular backups of your entire phones NAND flash so that you can restore a backup when something breaks. Its backup method works on a level that allows you to completely break, wipe or corrupt any or all partitions and still restore the phone to a working state within a few minutes. This works great for those who use their G1 for normal activities but also want to test their ideas which might break the phone, or when not having an extra G1 to keep purely as a development phone.
* Requirements for use
- Android G1 phone in recovery mode with busybox installed, including appropriate symlinks to at least tar and md5sum, as well as 'adb shell' support running as root. I recommend using JesusFreke US RC30 or UK RC8 v1.2 recovery image. You can flash the RC30 v1.2 recovery.img on your G1 if you don't want to bother constructing your own image. Of course you are free to use your own recovery image and it will work if you set it up correctly.
- dump_image-arm and mkyaffs2image|mkyaffs2image-$ARCH compiled in the current dir, as well as root on a linux/mac (POSIX) machine for constructing system and data images. root is required because the uid, gid and file permissions need to be preserved while extracting and creating the yaffs2 images. You are free to run the script as a normal user and then run the appropriate commands yourself as root; the commands are printed when you run the script as a regular user.
If you don't trust the provided binaries, you are free to compile them yourself. The source for the tools are included. For dump_image, edit nandtools/android-imagetools/Makefile so that you use the proper cross compiling gcc. For mkyaffs2img, just running make in tartools/yaffs2/utils/ should give you a binary. You are on your own in getting stuff compiled, but it should be easy to figure out from the Makefile.
* How to use this (the easy part)
Just boot your phone in recovery mode with the correct recovery.img (one that has adb shell as root + busybox installed with symlinks to tar, md5sum etc) and connect it to your pc/laptop/server. Then run the nandroid.sh script. If something is wrong or missing, it will tell you.
* What about restore?
If you have the dev phone or have root on the G1 and flashed the engineering/dev bootloader, then you can power on your phone while holding camera to get into the bootloader/SPL. It should then show some androids on skateboards (if not, you don't have the engineering/dev bootloader). Plug in your USB cable and push back until it says FASTBOOT instead of Serial0. Now you can fire up fastboot flash {partition} {file.img}.
Fastboot itself is part of the android SDK. If you download and compile your own mydroid build, it should sit in mydroid/out/host/linux-x86/bin/fastboot Perhaps in a future version I'll include a restore script, but for now I don't see the need.
One tip, if you are in fastboot mode on your phone and 'fastboot devices' doesn't show anything, try as root. You might need to edit your udev setup to allow your user to access the phone's usb device (which is different from the one you're in when in recovery or normal boot).
* Where's the source?
Sources are included. They are copies of the Android sources with various changes mostly made by Brainaid.
Everything in the zip is also also available through subversion:
svn co http://svn.infernix.net/nandroid/
Note that I DO NOT recommend checking out the latest revision unless you know damn well what you are doing. No guarantees if you play with fire. At the very least do diff against the latest released version.
* Credits
Bash script hacked together by infernix.
dump_image adapted from flash_image and extended by Brainaid.
Original mtdutils source and mkyaffs2image source by Google.
[1] http://forum.xda-developers.com/showthread.php?t=455860
[2] http://forum.xda-developers.com/showthread.php?t=443713
[3] http://www.gotontheinter.net/fastboot
DOWNLOAD HERE or:
wget http://dx.infernix.net/nandroid-2.0.zip
Click to expand...
Click to collapse
hey infernix, did you happen to get a mac version of this together? thanks!

[Q] Help please compiling kernel with initramfs support

Hi my name is ashy and I need some help regarding building a kernel from source for an ongoing project called H1droid here: h**p://samsungi8320.freeforums.org/portal.php
Basically I am just getting into this kind of stuff and at best Iam a hacker and a modder not a developer, so Linux is pretty new to me. However I learn fast and have a good grasp on what's what.
I am trying to build the Kernel for this project from this source h**p://samsungi8320.freeforums.org/onenand-mtd-multiboot-recovery-cm7-2rc1-t765.html
These sources were created originally by R3D4 who doesn't come to our fourms any more, so I am here to ask for help.
In a nut shell I am trying to build the kernel from R3D4's sources. I have Ubuntu, the tool chains, cloned the source and have managed to build the kernel. The problem is that the kernel requires to be in uImage format with built in ramdisk, however for the life of me I can't figure out how to create the valid boot.img..
I have pulled the config file from the device to use as the default .config, and haven't changed anything in menuconfig when compiling.
I have tried flashing the resulting image to the device, but it doesn't boot at all. It seems that there is no ramdisk to boot a rootfs.
I notice in .config it expects an initramfs to be in a specified directory, however my problem is I have no idea how to create the initramfs to build into the kernel when compiling.
This is probably something easy, but I have searched and searched and can't figure it out, so I am asking here for someone who has the knowledge if they can guide me in the right direction as to how to build the initramfs into the kernel and then compile it as a boot.img to flash via recovery.
I appreciate any and all help.
Thanks, ashy
Please help!
Update: I have managed to compile the kernel with built in initramfs, however the phone still doesn't boot.
Can anybody help here I'm stumped. Iam using Ubuntu 11.10 in VMware and these are the steps I have taken:
1. Clone sources as in first post
2. copy initramfs files into directory specified in config file: CONFIG_INITRAMFS_SOURCE="../out/target/product/nowplus/root"
2. Open terminal in Kernel directory
3. use command: make ARCH=arm nowplus_defconfig (this is the config file from the phone)
4. start the build of the kernel: make ARCH=arm CROSS_COMPILE=/home/user/cm7/arm-2012.03/bin/arm-none-eabi- uImage
During the compile there are warnings regarding unused variables or something, but believe these are normal. However at the end of the build modpost reports: WARNING: modpost: Found 2 section mismatch(es).
Is this significant?
Could really do with some help here, I am new at this stuff and getting really frustrated as I've been at it for 2 weeks now. I have searched and searched the whole internet for an answer.
ashyx said:
Update: I have managed to compile the kernel with built in initramfs, however the phone still doesn't boot.
Can anybody help here I'm stumped. Iam using Ubuntu 11.10 in VMware and these are the steps I have taken:
1. Clone sources as in first post
2. copy initramfs files into directory specified in config file: CONFIG_INITRAMFS_SOURCE="../out/target/product/nowplus/root"
2. Open terminal in Kernel directory
3. use command: make ARCH=arm nowplus_defconfig (this is the config file from the phone)
4. start the build of the kernel: make ARCH=arm CROSS_COMPILE=/home/user/cm7/arm-2012.03/bin/arm-none-eabi- uImage
During the compile there are warnings regarding unused variables or something, but believe these are normal. However at the end of the build modpost reports: WARNING: modpost: Found 2 section mismatch(es).
Is this significant?
Could really do with some help here, I am new at this stuff and getting really frustrated as I've been at it for 2 weeks now. I have searched and searched the whole internet for an answer.
Click to expand...
Click to collapse
Ok have managed to make a little progress, it seems the rootfs is loading as it boots up to a screen with blue A N D R O I D text and then changes to a flashing cursor in the top left of the screen. I guess this means the kernel isn't booting.
Still looking for pointers out there on this, can nobody give me a hint or a way to debug this problem?
ashyx said:
Ok have managed to make a little progress, it seems the rootfs is loading as it boots up to a screen with blue A N D R O I D text and then changes to a flashing cursor in the top left of the screen. I guess this means the kernel isn't booting.
Still looking for pointers out there on this, can nobody give me a hint or a way to debug this problem?
Click to expand...
Click to collapse
Hey, like you i'm an user which enjoy to experiment stuff with linux, so, i want just thank you to share your experience, it helped me

[Q] Building a recovery.img from scratch

Here is the theory I want.
Given a mobile phone that has a lock on it wether pin code, pattern or password, If the mobile's bootloader was unlocked I can install a custom recovery and then boot to that recovery in which I can run the adb and have access to the data in the phone. If my hypothesis is correct then how I can build a recovery.img ??
I have been reading for the recover.img for 2 weeks and almost understood how it works and most of the files in it. However, I couldn't find a tutorial of how can I build my own recovery.img
What I decided to do it to modify on the CWM recovery.img.
So I downloaded the CWM and then I unpack it to see the kernel and the initrd. After decompressing the initrd, I found many files. I made a simple test which is to run a script from the init.rc. Inside the init.rc I added two lines. The first one to mount the /data partition and then I just echoed "test" to a file called text.txt then I rebooted my device to normal boot connected to adb and checked the /data partition, but unfortunately I didn't find anything.
I would like to know what I am missing and if my theory is correct or not and how can I build my OWN recovery and have something like adb running from the start.
Thank you

Kernel compilation/booting troubleshooting for beginners

I've only recently after lot of struggle compiled my first kernel. While the information is still fresh in my mind, I want to share all the problems I encountered and what to do if you are in the same situation.
This guide is mainly for Linux users since that is what I am familiar with.
I've used this amazing guide to learn the basics. If you haven't yet, read it first.
Errors from scripts/gcc-wrapper.py
Open the file and change the first line from
Code:
#! /usr/bin/env python
to
Code:
#! /usr/bin/env python2
Kernel won't compile
* Did you forget to set and export the variables ARCH and CROSS_COMPILE?
* Do you have the right .config file present?
Try extracting the .config file from the original boot kernel and use it instead
* Are you sure you are in the correct branch?
Run git branch inside kernel's source code to verify that
* Are you using a very recent or very old version of the compiler? Some old kernels for example would only compile with gcc-4 but not gcc-7 or 8. Most kernels - at the time of writing - won't compile with gcc-8
Kernel compiles fine but won't boot
* Are you using wrong kernel configuration (.config) ?
* Try different compiler or different compiler version.
I've tried to compile my current with Android's prebuild gcc 4 compiler and it wouldn't boot, switched to gcc 7 and it booted perfectly fine.
Kernel starts but system crashes somewhere during boot
You can enable adb during boot so that you can see what causes the error.
Find this file in your extracted boot image ramdisk/default.prop
Set or update the following values
Code:
ro.adb.secure=0
ro.secure=0
persist.sys.usb.config=adb
Then you can do adb shell logcat or adb shell dmesg to see what is going on
My phone won't boot after flashing my new kernel, how do I boot to recovery?
First of all, you shouldn't have! You should test your new kernel without flashing it using fastboot.
Simply reboot to bootloader then run the command
Code:
fastboot boot /path/to/my/new-image
So what can I do now? Try to reach bootloader screen. the method differs from device to device but it involve pushing certain physical phone buttons while turning on the phone.
Once you are in the bootloader screen, you can do adb fastboot /path/to/twrp-recovery.img or even path to original boot image if you kept a backup.
ramast_ said:
I've only recently after lot of struggle compiled my first kernel. While the information is still fresh in my mind, I want to share all the problems I encountered and what to do if you are in the same situation.
This guide is mainly for Linux users since that is what I am familiar with.
I've used this amazing guide to learn the basics. If you haven't yet, read it first.
Errors from scripts/gcc-wrapper.py
Open the file and change the first line from
Code:
#! /usr/bin/env python
to
Code:
#! /usr/bin/env python2
Kernel won't compile
* Did you forget to set and export the variables ARCH and CROSS_COMPILE?
* Do you have the right .config file present?
Try extracting the .config file from the original boot kernel and use it instead
* Are you sure you are in the correct branch?
Run git branch inside kernel's source code to verify that
* Are you using a very recent or very old version of the compiler? Some old kernels for example would only compile with gcc-4 but not gcc-7 or 8. Most kernels - at the time of writing - won't compile with gcc-8
Kernel compiles fine but won't boot
* Are you using wrong kernel configuration (.config) ?
* Try different compiler or different compiler version.
I've tried to compile my current with Android's prebuild gcc 4 compiler and it wouldn't boot, switched to gcc 7 and it booted perfectly fine.
Kernel starts but system crashes somewhere during boot
You can enable adb during boot so that you can see what causes the error.
Find this file in your extracted boot image ramdisk/default.prop
Set or update the following values
Code:
ro.adb.secure=0
ro.secure=0
persist.sys.usb.config=adb
Then you can do adb shell logcat or adb shell dmesg to see what is going on
My phone won't boot after flashing my new kernel, how do I boot to recovery?
First of all, you shouldn't have! You should test your new kernel without flashing it using fastboot.
Simply reboot to bootloader then run the command
Code:
fastboot boot /path/to/my/new-image
So what can I do now? Try to reach bootloader screen. the method differs from device to device but it involve pushing certain physical phone buttons while turning on the phone.
Once you are in the bootloader screen, you can do adb fastboot /path/to/twrp-recovery.img or even path to original boot image if you kept a backup.
Click to expand...
Click to collapse
good job!
Do you have any general tutorials on kernel optimization?
wangyiling said:
good job!
Do you have any general tutorials on kernel optimization?
Click to expand...
Click to collapse
I am afraid not, sorry. I am just a beginner
@ramast_
The information you provided has solved pretty much all of the problems I was having. We need more content like this. Everything I find about kernel building explains things like you're a Linux expert, where as your post is much more layman friendly. I can't thank you enough for this.
Quick question; which version of Linux do you use?
You are very welcome, happy someone found it useful.
By Linux version I suppose you mean Linux distro (distribution).
I use Gentoo which is certainly not for beginners.
I'd suggest Ubuntu for beginners. Not because it's the best but because it has a very big community and you are more likely to find help when facing any problem.
This article explain how to cross compile arm code (how to compile code so that it can run on an arm device). Should get you started.
Best of luck
Spaceminer said:
@ramast_ I can't thank you enough for this.
Quick question; which version of Linux do you use?
Click to expand...
Click to collapse
ramast_ said:
You are very welcome, happy someone found it useful.
By Linux version I suppose you mean Linux distro (distribution).
I use Gentoo which is certainly not for beginners.
I'd suggest Ubuntu for beginners. Not because it's the best but because it has a very big community and you are more likely to find help when facing any problem.
This article explain how to cross compile arm code (how to compile code so that it can run on an arm device). Should get you started.
Best of luck
Click to expand...
Click to collapse
Thanks again. Distro is what I meant. I was thinking I should use Ubuntu, but I wanted to see what you had to say about it.

Question Bootloader Unlocked Warning

Has anybody figured out how to get rid of the Bootloader Unlocked warning when booting this phone? It certainly slows down the booting process.
I haven't figured it out yet. To be honest I've been trying to figure out what apps are safe to uninstall and a custom ROM or how to update to Android 12. But I'll definitely let you know if I figure a way out.
dfreedom834 said:
I haven't figured it out yet. To be honest I've been trying to figure out what apps are safe to uninstall and a custom ROM or how to update to Android 12. But I'll definitely let you know if I figure a way out.
Click to expand...
Click to collapse
I have been trying to build TWRP for this device. I am very close, but the mkbootimg command script is issuing a bad argument and I have been unable to trace it down so far.
Code:
[100% 4/4] Target boot image: /mnt/audio/android/twrp/out/target/product/minsk/boot.img
FAILED: /android/twrp/out/target/product/minsk/boot.img
/bin/bash -c "(/android/twrp/out/host/linux-x86/bin/mkbootimg --kernel /mnt/audio/android/twrp/out/target/product/minsk/kernel --ramdisk /android/twrp/out/target/product/minsk/ramdisk.img --base 0x00000000 --pagesize 4096 --cmdline \"console=ttyMSM0,115200n8 androidboot.hardware
=qcom androidboot.console=ttyMSM0 androidboot.memcg=1 lpm_levels.sleep_disabled=1 video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 servic
e_locator.enable=1 swiotlb=1 androidboot.usbcontroller=a600000.dwc3 earlycon=msm_geni_serial,0x880000 loop.max_part=7 printk.devkmsg=on androidboot.ha
b.csv=10 androidboot.hab.product=minsk androidboot.hab.cid=50 firmware_class.path=/vendor/firmware_mnt/image buildvariant=user buildvariant=eng\" --os
_version 16.1.0 --os_patch_level 2099-12-31 --ramdisk_offset 0x01000000 --tags_offset 0x00000100 --dtb device/motorola/minsk/prebuilt/dtb.img --header
_version 2 --output /mnt/audio/android/twrp/out/target/product/minsk/boot.img ) && (true )"
mkbootimg: error: unrecognized arguments: --dtb device/motorola/minsk/prebuilt/dtb.img
ninja: build stopped: subcommand failed.
15:01:24 ninja failed with: exit status 1
So the --dtb should be --recovery_dtbo I believe. Not sure where this command is being generated in order to fix it.
I was running into problems like that I factor rest it and turned it off. Where did you compile the boot.img from? And ya it would work better if it was trying to go to the right path. I had to find a boot.img from one of the over seas ones I kept getting it were it would root but the screen did respond.
lexridge said:
So the --dtb should be --recovery_dtbo I believe. Not sure where this command is being generated in order to fix it.
Click to expand...
Click to collapse
I could be wrong but the recovery I'm using (orange fox) does use a kernel_dtb. So it seems your recovery image kernel doesn't have the right path to the dtb binary it needs. Try searching the build directory for any _dtb/.dtb and rename accordingly. I'd you need to alter the dtb from a related SoC there are tools for unpacking and modifying those.
The recovery and boot ones would be similar I imagine since those files are a map of the device's hardware.
dfreedom834 said:
I was running into problems like that I factor rest it and turned it off. Where did you compile the boot.img from? And ya it would work better if it was trying to go to the right path. I had to find a boot.img from one of the over seas ones I kept getting it were it would root but the screen did respond.
Click to expand...
Click to collapse
I took the boot.img from the full device A11 factory image.
MINSK_RETUS_11_RPCS31.Q2-109-16-2_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip
I used the same one to create my magisk boot.img as well. I used dumpyara to build the device tree using the above file for my source which seemed to work properly. No errors in other words.
elrod16 said:
I could be wrong but the recovery I'm using (orange fox) does use a kernel_dtb. So it seems your recovery image kernel doesn't have the right path to the dtb binary it needs. Try searching the build directory for any _dtb/.dtb and rename accordingly. I'd you need to alter the dtb from a related SoC there are tools for unpacking and modifying those.
The recovery and boot ones would be similar I imagine since those files are a map of the device's hardware.
Click to expand...
Click to collapse
I have a dtbo directory containing these files:
Code:
00_kernel
01_dtbdump_amxbr.dtb
02_dtbdump_amxbr.dtb
03_dtbdump_amxbr.dtb
04_dtbdump_amxbr.dtb
05_dtbdump_amxbr.dtb
I also have a dtb.img in the root of the device tree. I will copy it to dtbo.img and see what happens. Thanks for the hint.
lexridge said:
I have a dtbo directory containing these files:
Code:
00_kernel
01_dtbdump_amxbr.dtb
02_dtbdump_amxbr.dtb
03_dtbdump_amxbr.dtb
04_dtbdump_amxbr.dtb
05_dtbdump_amxbr.dtb
I also have a dtb.img in the root of the device tree. I will copy it to dtbo.img and see what happens. Thanks for the hint.
Click to expand...
Click to collapse
I think dtb.img probably has all of the dtb files compiled together
elrod16 said:
I think dtb.img probably has all of the dtb files compiled together
Click to expand...
Click to collapse
That is my thought as well.
lexridge said:
That is my thought as well.
Click to expand...
Click to collapse
I just recently had to deal with all this crap because I didn't know GPD changed which revision of the mediatek SoC they used in the GPD XD while keeping the serial numbers the same. Flashed my old one's backup on it and half the cores were stuck offlined when it booted up. Ended up having to get ahold of the stock kernel for that board revision and patch in the correct dtb for that SoC.
I don't have links but some of the sites that delve into generic Linux kernel porting have tools for decompiling kernel_dtb files to an editable form that you can then recompile if you do have device/driver issues. Also the magisk module for enabling TWRP sdcard storage backups has some Android arm64 native binaries in it that can help with tearing apart kernel/recovery images. (They both are technically kernel images, just one boots a minimal OS).
Edit: I think any dtbo files would be individual compiled object files that get linked into the final dtb image.
Edit 2: I just saw your other comment above. Congrats, that sounds like a viable (and probably long term stable) way you found.
On another topic, I have been trying to mount /system as r/w (thru adb). It appears /system is not actually a mount point but under a different mount point. Any idea what that might be? Doing a cat on /proc/mounts yeilds a crapload of mounts, with many belonging to magisk, but no /system.
I know its been 4 month since last activity, but has there been any progress on this?
There does not seem to have been much progress on this, but I read somewhere recently that the G Stylus (2021) was either the most popular or best-selling Moto phone in 2021. Who knows if that is exactly true, but if it is indeed so popular, here's to hoping that some capable developers will take an interest in it eventually!
Several folks have mentioned that loading a GSI (Generic System Image) should be possible, but I have not had any extended downtime myself to be able to try this. But if you do, you can find some guidance for the 2020 version of the G Stylus at:
https://forum.xda-developers.com/t/...ic-system-image-on-the-moto-g-stylus.4131199/

Categories

Resources