https://linux-sunxi.org/api.php?action=feedcontributions&user=Jkpage&feedformat=atomlinux-sunxi.org - User contributions [en]2024-03-29T15:42:15ZUser contributionsMediaWiki 1.35.8https://linux-sunxi.org/index.php?title=Boot_Android_from_SdCard&diff=14634Boot Android from SdCard2015-07-15T02:04:01Z<p>Jkpage: /* Requirements */</p>
<hr />
<div>== Boot Android From SdCard ==<br />
<br />
'''<big>SDcard images:</big>'''<br />
As an assist here, I have created a few '''8GB''' SDcard images for Android on the Cubieboard A10 ('''Use at your own risk, they are to be considered developmental images'''):<br />
<br />
Images based on Android TV 1.0 NAND image:<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.512mb.8gbsd.img.7z For Cubieboard A10 w/ 512MB Ram - Image]<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.512mb.8gbsd.img.md5 For Cubieboard A10 w/ 512MB Ram - MD5 for Image]<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.1024mb.8gbsd.img.7z For Cubieboard A10 w/ 1024MB Ram - Image]<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.1024mb.8gbsd.img.md5 For Cubieboard A10 w/ 1024MB Ram - MD5 for Image]<br />
Image based on Android TV 2.2 (8192cu WiFi chipset) NAND image:<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.1024mb.8gbsd.TV.2.2.img.7z For Cubieboard A10 w/ 1024MB Ram - Image]<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.1024mb.8gbsd.TV.2.2.img.md5 For Cubieboard A10 w/ 1024MB Ram - MD5 for Image]<br />
<br />
To install use 'dd' in Linux or Win32DiskImager in Windows to write the image to your SDcard.<br />
<br />
'''Notes about the above images:''' <br />
* The 512Mb image above is based on the A10-OLinuXino-LIME Android image located [https://www.olimex.com/wiki/A10-OLinuXino-LIME#Android here.] but uses the system, boot and recovery from the linux-sunxi Android TV 1.0 image and uses the Olimex u-boot image and kernel.<br />
* If you want, the Olimex image will run on the Cubieboard A10, however, as Olimex never released an A10 board with 1GB ram, the image's u-boot only supports up to 512Mb of memory. <br />
* If you boot and use the 512mb image you will be limited to 512Mb ram in Android (Keep in mind that the GPU gets assigned memory as well so with this image you have roughly 306Mb of usable memory). <br />
* All other images have a custom compiled u-boot that was compiled using the directions below on a Cubieboard A10 running Debian Server.<br />
* These images do have some apps already installed and do not come in a factory reset state. I took the liberty to install Bubbleupnp, Mxplayer, Chrome, Firefox and a few other goodies that you may find useful.<br />
* If you do not care for the already installed apps, simply do a factory reset your self on first boot.<br />
* Since you will be booting from the SDcard, you will obviously not have an SDcard available to leverage for downloads. Some apps will give errors when trying to download files as there is no 'SDcard' present. <br />
* To help with not having an SDcard available, I have left you quite a large internal storage partition, so you shouldn't have issues with installing any needed apps.<br />
* Some wifi adapters may be compatible with these images, but I am not sure which are included in the Olimex kernel. The TV 2.2 images includes the chipsets noted.<br />
* Some SDcards are really slow! The slower your card the longer it will take to boot and the more laggy things will seem. I recommend a Class 10 card for best performance (Class 4 will work, but will be slow).<br />
<br />
'''<big>For those who wish to create their own Android SDcard, continue on:</big>'''<br />
<br />
First extract needed files from an android image , You will need awutils and android tools.<br />
$ wget http://dl.linux-sunxi.org/users/arete74/tools.tar.gz<br />
$ tar -zxvf tools.tar.gz<br />
<br />
[[Awutils|AWUtils]]<br />
$ git clone https://github.com/Ithamar/awutils.git<br />
$ cd awutils<br />
$ make<br />
<br />
=== Extract file from Android Image ===<br />
<br />
Resources for Cubieboard A10:<br />
http://docs.cubieboard.org/tutorials/cb1/installation/cubieboard_android-4.0.x_release<br />
http://dl.cubieboard.org/model/cubieboard1/Image/android/<br />
<br />
In this guide the name of the Android Image is android.img<br />
$ awimage -u android.img<br />
<br />
This command creates a folder called android.dump which will contain many files.<br />
The three following files are the ones we are interested in:<br />
<br />
'''RFSFAT16_BOOT_00000000000''' (the boot partition) <br />
<br />
'''RFSFAT16_RECOVERY_0000000''' (the recovery partition)<br />
<br />
'''RFSFAT16_SYSTEM_000000000''' (the system partition, ext4 sparse)<br />
<br />
'''RFSFAT16_BOOTLOADER_00000''' (the bootloader partition)<br />
<br />
For simplicity rename:<br />
cp android.img.dump/RFSFAT16_BOOT_00000000000 ../boot.img<br />
cp android.img.dump/RFSFAT16_RECOVERY_0000000 ../recovery.img<br />
cp android.img.dump/RFSFAT16_SYSTEM_000000000 ../system.img<br />
cp android.img.dump/RFSFAT16_BOOTLOADER_00000 ../bootloader.img<br />
cd ..<br />
<br />
==== Extract Kernel and Ramdisk ====<br />
Extract the kernel and boot RAM disk as follows:<br />
<br />
$ ./tools/split_bootimg.pl boot.img<br />
Page size: 2048 (0x00000800)<br />
Kernel size: 4215036 (0x004050fc)<br />
Ramdisk size: 974998 (0x000ee096)<br />
Second size: 0 (0x00000000)<br />
Board name:<br />
Command line: console=ttyS0,115200 rw init=/init loglevel=5<br />
Writing boot.img-kernel ... complete.<br />
Writing boot.img-ramdisk.gz ... complete.<br />
<br />
Decompress the ramdisk data:<br />
$ mkdir boot<br />
$ cd boot <br />
$ gunzip -c ../boot.img-ramdisk.gz | cpio -i<br />
$ tar -cpvf ../boot.tar *<br />
$ cd ..<br />
<br />
Convert '''kernel''' to '''uImage''':<br />
$ mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n "Linux 2.6" -d boot.img-kernel uImage<br />
<br />
==== Extract system image: ====<br />
<br />
$ ./tools/simg2img system.img system1.img<br />
$ mkdir system<br />
$ mount -o loop system1.img system<br />
$ cd system<br />
$ tar -cpvf ../system.tar *<br />
$ cd ..<br />
$ umount system<br />
<br />
==== Extract recovery image: ====<br />
<br />
$ ./tools/split_bootimg.pl recovery.img<br />
Page size: 2048 (0x00000800)<br />
Kernel size: 4215036 (0x004050fc)<br />
Ramdisk size: 974998 (0x000ee096)<br />
Second size: 0 (0x00000000)<br />
Board name:<br />
Command line: console=ttyS0,115200 rw init=/init loglevel=5<br />
Writing recovery.img-kernel ... complete.<br />
Writing recovery.img-ramdisk.gz ... complete.<br />
<br />
==== Decompress the ramdisk data: ====<br />
$ mkdir recovery<br />
$ cd recovery<br />
$ gunzip -c ../recovery.img-ramdisk.gz | cpio -i<br />
$ tar -cpvf ../recovery.tar *<br />
$ cd ..<br />
<br />
=== SD card Partition ===<br />
Partitions description:<br />
<br />
WARNING: At the start we need a 17 MB unallocated partition, required for flash sunxi-spl and u-boot.bin without corrupting the SD.<br />
<br />
{| class="wikitable" |<br />
! partition<br />
! Size<br />
! Name<br />
! Fs<br />
! Description<br />
|-<br />
| /dev/sdc1<br />
| 16MiB<br />
| bootloader<br />
| VFAT<br />
| Files to assist the bootloader.<br />
|-<br />
| /dev/sdc2<br />
| 36MiB<br />
| boot<br />
| EXT4<br />
| ramdisk<br />
|-<br />
| /dev/sdc3<br />
| 500 MiB<br />
| system<br />
| EXT4<br />
| Android's /system partition<br />
|-<br />
| /dev/sdc4<br />
| Fill all space<br />
| extend<br />
| Extend Partition <br />
|-<br />
| /dev/sdc5<br />
| 300MiB<br />
| data<br />
| EXT4<br />
| <br />
|-<br />
| /dev/sdc6<br />
| 16 MiB<br />
| misc<br />
| EXT4<br />
|<br />
|-<br />
| /dev/sdc7<br />
| 36 Mib<br />
| recovery<br />
| EXT4<br />
| Android's recovery partition<br />
|-<br />
| /dev/sdc8<br />
| 125 MiB<br />
| cache<br />
| EXT4<br />
| <br />
|-<br />
| /dev/sdc9<br />
| 16 MiB<br />
| private<br />
| EXT4<br />
| <br />
|-<br />
| /dev/sdc10<br />
| 1-2 GiB<br />
| UDISK<br />
| VFAT<br />
| <br />
|-<br />
|}<br />
<br />
<br />
Now, identify the device of the card and export it as <tt>$card</tt>:<br />
<br />
$card=/dev/sdX (sdX should be replaced with the name of your device)<br />
<br />
dd if=/dev/zero of=$card bs=1M count=1<br />
sfdisk -R $card<br />
<br />
cat <<EOT | sfdisk --in-order -uM $card<br />
17,16,c<br />
,36,83<br />
,500,83<br />
,,5<br />
,300,83<br />
,16,83<br />
,36,83<br />
,125,83<br />
,16,83<br />
,,83<br />
EOT<br />
<br />
==== Format ====<br />
<br />
mkfs.vfat -n bootloader ${card}1<br />
mkfs.ext4 -L boot ${card}2<br />
mkfs.ext4 -L system ${card}3<br />
mkfs.ext4 -L data ${card}5<br />
mkfs.ext4 -L misc ${card}6<br />
mkfs.ext4 -L recovery ${card}7<br />
mkfs.ext4 -L cache ${card}8<br />
mkfs.ext4 -L private ${card}9<br />
mkfs.vfat -n UDISK ${card}10<br />
<br />
remove huge_file option from EXT4 fs (android kernel not have this option!!!)<br />
<br />
tune2fs -O ^huge_file ${card}2<br />
tune2fs -O ^huge_file ${card}3<br />
tune2fs -O ^huge_file ${card}5<br />
tune2fs -O ^huge_file ${card}6<br />
tune2fs -O ^huge_file ${card}7<br />
tune2fs -O ^huge_file ${card}8<br />
tune2fs -O ^huge_file ${card}9<br />
<br />
=== BootLoader ===<br />
<br />
For SD card booting you can try one of these pair of files from [[Miniand Hackberry|Hackberry]]:<br />
* '''1GB:''' [http://dl.miniand.com/jas-hacks/uboot/1gb/sunxi-spl.bin sunxi-spl.bin] [http://dl.miniand.com/jas-hacks/uboot/1gb/u-boot.bin u-boot.bin]<br />
* '''512MB:''' [http://dl.miniand.com/jas-hacks/uboot/512mb/sunxi-spl.bin sunxi-spl.bin] [http://dl.miniand.com/jas-hacks/uboot/512mb/u-boot.bin u-boot.bin]<br />
<br />
dd if=spl/sunxi-spl.bin of=$card bs=1024 seek=8<br />
dd if=u-boot.bin of=$card bs=1024 seek=32<br />
<br />
'''Note:''' The above will not work for the Cubieboard A10, you can try the images below or compile u-boot your self.<br />
<br />
<br />
<big>'''For Cubieboard A10:'''</big><br />
<br />
If you are in a pinch, you can try the files below, but it is recommended if you can that you compile them your self:<br />
* [http://dl.extremehosting.us/cubieboard/u-boot.img u-boot.img]<br />
* [http://dl.extremehosting.us/cubieboard/sunxi-spl.bin sunxi-spl.bin]<br />
* [http://dl.extremehosting.us/cubieboard/u-boot-sunxi-with-spl.bin u-boot-sunxi-with-spl.bin]<br />
<br />
git clone https://github.com/linux-sunxi/u-boot-sunxi.wiki.git<br />
make cubieboard_config<br />
make<br />
<br />
'''Note:''' It is recommended for best results that you compile it if you can on the device you plan to use it on.<br />
<br />
For cross compilation:<br />
<br />
git clone https://github.com/linux-sunxi/u-boot-sunxi.wiki.git<br />
make cubieboard_config CROSS_COMPILE=arm-linux-gnueabihf-<br />
<br />
Next, install your new u-boot on your sdcard:<br />
<br />
dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8<br />
<br />
or if you prefer to install the components separately:<br />
<br />
dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8<br />
dd if=u-boot.img of=/dev/sdX bs=1024 seek=40<br />
<br />
If you have issues at boot time you will find that setting up debug serial console will help a lot to find your issue.<br />
<br />
'''Reference:''' https://github.com/linux-sunxi/u-boot-sunxi/wiki<br />
<br />
=== Copy to SD card ===<br />
mkdir bootloader<br />
mount -o loop bootloader.img bootloader<br />
<br />
Copy files to bootloader partition:<br />
<br />
mount ${card}1 /mnt/<br />
cp uImage /mnt<br />
cp bootloader/script.bin /mnt<br />
<br />
cat >/mnt/uEnv.txt << EOT<br />
fexfile=script.bin<br />
kernel=uImage<br />
extraargs=root=/dev/mmcblk0p2 loglevel=8 rootwait console=ttyS0,115200 rw init=/init mac_addr=00:AE:99:A3:E4:AF<br />
boot_mmc=fatload mmc 0 0x43000000 ${fexfile}; fatload mmc 0 0x48000000 ${kernel}; bootm 0x48000000<br />
EOT<br />
<br />
Recovery uEnv.txt<br />
<br />
cat >/mnt/uEnv_recovery.txt << EOT<br />
fexfile=script.bin<br />
kernel=uImage<br />
extraargs=root=/dev/mmcblk0p7 loglevel=8 rootwait console=ttyS0,115200 rw init=/init mac_addr=00:AE:99:A3:E4:AF<br />
boot_mmc=fatload mmc 0 0x43000000 ${fexfile}; fatload mmc 0 0x48000000 ${kernel}; bootm 0x48000000<br />
EOT<br />
<br />
umount /mnt<br />
umount bootloader<br />
<br />
Copy data to Ramdisk partition:<br />
mount ${card}2 /mnt<br />
tar -xpvf boot.tar -C /mnt<br />
<br />
'''Note:''' If you would like to add additional Wifi drivers, you can actually do that here. <br />
[http://taqlim.blogspot.com/2013/06/belkin-f7d1101-wireless-usb-on-android.html This] reference will help you get the idea of what needs to be done to include additional Wifi modules for android.<br />
This page also includes the kernel modules for r8712u and directions on how to compile and add your own Wifi modules.<br />
<br />
Modify the name partition in init.sun4i.rc<br />
<br />
sed -i "s/nandd/mmcblk0p3/g" /mnt/init.sun4i.rc<br />
sed -i "s/nande/mmcblk0p5/g" /mnt/init.sun4i.rc<br />
sed -i "s/nandh/mmcblk0p8/g" /mnt/init.sun4i.rc<br />
sed -i "s/nandi/mmcblk0p10/g" /mnt/init.sun4i.rc<br />
umount /mnt<br />
<br />
Copy data to system partition:<br />
mount ${card}3 /mnt<br />
tar -xpvf system.tar -C /mnt<br />
umount /mnt<br />
<br />
Copy data to recovery partition:<br />
mount ${card}7 /mnt<br />
tar -xpvf recovery.tar -C /mnt<br />
sed -i "s/nandf/mmcblk0p6/g" /mnt/ueventd.sun4i.rc<br />
umount /mnt<br />
sync<br />
<br />
Now you can boot Android from SD card.<br />
<br />
== Automated Flash Kitchen ==<br />
<br />
Thierry Merle has assembled a Flash Kitchen originally for the Mele A2000 but it also works for other A10 devices.<br />
<br />
Download v2 from here: http://tmerle.blogspot.fr/2012/09/mele-a2000-my-own-linux-flash-kitchen.html<br />
<br />
After having put the original.img file (PhoenixCard source image), run "make build_sdcard" as root and it should create everything needed to generate the SD card boot files in sdcard/.<br />
<br />
Then, you will have to 'cd sdcard/', then run 'make DEV=/dev/sdX' (where X is the device letter of your SD card).<br />
<br />
=== Requirements ===<br />
<br />
Wine - in order to extract/build the flash image (look below for enhancements).<br />
<br />
Root access for scripts other than img_1extract.sh/img_2build.sh.<br />
<br />
The script will create /system in your [http://www.coolmuster.com/android/how-to-root-android-device.html root] directory. This is necessary if you make symbolic links in "system" filesystem.<br />
<br />
Of course, you need an original image (that you will rename as original.img) to start hacking.<br />
<br />
=== Enhancements ===<br />
<br />
* If you don't have Wine you can use Ithamar's awutils [https://github.com/Ithamar/awutils] in img_1extract.sh instead of unimg.exe. You can find more info in [[Awutils]].<br />
<br />
* Here's abootimg statically linked and stripped for i386 and amd64: https://www.dropbox.com/s/xbe2u7ai6aqaob1/abootimg_i386+amd64_statically_linked+stripped.tar.xz<br />
<br />
i386 is untested natively so to be sure also included are the static libraries libblkid.a and libuuid.a and you might need blkid.h<br />
<br />
Change the LDLIBS line in the Makefile as follows:<br />
<br />
LDLIBS=-static -lblkid -luuid -L.<br />
<br />
* #!/bin/bash and function function_name() work better together in mkA10card.sh<br />
<br />
* "partition ends on cylinder 1023, beyond the end of the disk"<br />
<br />
You have to make some adjustments to partitions.txt. It's for a 16 GB [http://www.android-mobile-manager.com/android-mobile-recovery.html SD card] and so [http://www.androidphonesoft.com/resources/recover-deleted-files-from-android-sd-card.html Disk Utility] will show something like Capacity: 18446744 TB (-8,198,815,744 bytes). So you have to calculate partitions.txt yourself.<br />
<br />
=== General information ===<br />
<br />
* When make fails and you want to run it again:<br />
<pre><br />
tar: .: Cannot change ownership to uid 1000, gid 1000: Operation not permitted"<br />
</pre><br />
FAT does not allow UID, GID and symlinks. You have to [http://www.samsung-messages-backup.com/resources/astro-file-manager-alternative.html copy the files] manually.<br />
<br />
[[Category:Tutorial]]<br />
[[Category:Android]]</div>Jkpagehttps://linux-sunxi.org/index.php?title=Boot_Android_from_SdCard&diff=14617Boot Android from SdCard2015-07-13T07:14:22Z<p>Jkpage: /* Boot Android From SdCard */</p>
<hr />
<div>== Boot Android From SdCard ==<br />
<br />
'''<big>SDcard images:</big>'''<br />
As an assist here, I have created a few '''8GB''' SDcard images for Android on the Cubieboard A10 ('''Use at your own risk, they are to be considered developmental images'''):<br />
<br />
Images based on Android TV 1.0 NAND image:<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.512mb.8gbsd.img.7z For Cubieboard A10 w/ 512MB Ram - Image]<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.512mb.8gbsd.img.md5 For Cubieboard A10 w/ 512MB Ram - MD5 for Image]<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.1024mb.8gbsd.img.7z For Cubieboard A10 w/ 1024MB Ram - Image]<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.1024mb.8gbsd.img.md5 For Cubieboard A10 w/ 1024MB Ram - MD5 for Image]<br />
Image based on Android TV 2.2 (8192cu WiFi chipset) NAND image:<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.1024mb.8gbsd.TV.2.2.img.7z For Cubieboard A10 w/ 1024MB Ram - Image]<br />
* [http://dl.extremehosting.us/cubieboard/android.cubieboard.a10.1024mb.8gbsd.TV.2.2.img.md5 For Cubieboard A10 w/ 1024MB Ram - MD5 for Image]<br />
<br />
To install use 'dd' in Linux or Win32DiskImager in Windows to write the image to your SDcard.<br />
<br />
'''Notes about the above images:''' <br />
* The 512Mb image above is based on the A10-OLinuXino-LIME Android image located [https://www.olimex.com/wiki/A10-OLinuXino-LIME#Android here.] but uses the system, boot and recovery from the linux-sunxi Android TV 1.0 image and uses the Olimex u-boot image and kernel.<br />
* If you want, the Olimex image will run on the Cubieboard A10, however, as Olimex never released an A10 board with 1GB ram, the image's u-boot only supports up to 512Mb of memory. <br />
* If you boot and use the 512mb image you will be limited to 512Mb ram in Android (Keep in mind that the GPU gets assigned memory as well so with this image you have roughly 306Mb of usable memory). <br />
* All other images have a custom compiled u-boot that was compiled using the directions below on a Cubieboard A10 running Debian Server.<br />
* These images do have some apps already installed and do not come in a factory reset state. I took the liberty to install Bubbleupnp, Mxplayer, Chrome, Firefox and a few other goodies that you may find useful.<br />
* If you do not care for the already installed apps, simply do a factory reset your self on first boot.<br />
* Since you will be booting from the SDcard, you will obviously not have an SDcard available to leverage for downloads. Some apps will give errors when trying to download files as there is no 'SDcard' present. <br />
* To help with not having an SDcard available, I have left you quite a large internal storage partition, so you shouldn't have issues with installing any needed apps.<br />
* Some wifi adapters may be compatible with these images, but I am not sure which are included in the Olimex kernel. The TV 2.2 images includes the chipsets noted.<br />
* Some SDcards are really slow! The slower your card the longer it will take to boot and the more laggy things will seem. I recommend a Class 10 card for best performance (Class 4 will work, but will be slow).<br />
<br />
'''<big>For those who wish to create their own Android SDcard, continue on:</big>'''<br />
<br />
First extract needed files from an android image , You will need awutils and [http://www.coolmuster.com/android/recover-deleted-files-from-android.html android tools].<br />
$ wget http://dl.linux-sunxi.org/users/arete74/tools.tar.gz<br />
$ tar -zxvf tools.tar.gz<br />
<br />
[[Awutils|AWUtils]]<br />
$ git clone https://github.com/Ithamar/awutils.git<br />
$ cd awutils<br />
$ make<br />
<br />
=== Extract file from Android Image ===<br />
<br />
Resources for Cubieboard A10:<br />
http://docs.cubieboard.org/tutorials/cb1/installation/cubieboard_android-4.0.x_release<br />
http://dl.cubieboard.org/model/cubieboard1/Image/android/<br />
<br />
In this guide the name of the Android Image is android.img<br />
$ awimage -u android.img<br />
<br />
This command creates a folder called android.dump which will contain many files.<br />
The three following files are the ones we are interested in:<br />
<br />
'''RFSFAT16_BOOT_00000000000''' (the boot partition) <br />
<br />
'''RFSFAT16_RECOVERY_0000000''' (the recovery partition)<br />
<br />
'''RFSFAT16_SYSTEM_000000000''' (the system partition, ext4 sparse)<br />
<br />
'''RFSFAT16_BOOTLOADER_00000''' (the bootloader partition)<br />
<br />
For simplicity rename:<br />
cp android.img.dump/RFSFAT16_BOOT_00000000000 ../boot.img<br />
cp android.img.dump/RFSFAT16_RECOVERY_0000000 ../recovery.img<br />
cp android.img.dump/RFSFAT16_SYSTEM_000000000 ../system.img<br />
cp android.img.dump/RFSFAT16_BOOTLOADER_00000 ../bootloader.img<br />
cd ..<br />
<br />
==== Extract Kernel and Ramdisk ====<br />
Extract the kernel and boot RAM disk as follows:<br />
<br />
$ ./tools/split_bootimg.pl boot.img<br />
Page size: 2048 (0x00000800)<br />
Kernel size: 4215036 (0x004050fc)<br />
Ramdisk size: 974998 (0x000ee096)<br />
Second size: 0 (0x00000000)<br />
Board name:<br />
Command line: console=ttyS0,115200 rw init=/init loglevel=5<br />
Writing boot.img-kernel ... complete.<br />
Writing boot.img-ramdisk.gz ... complete.<br />
<br />
Decompress the ramdisk data:<br />
$ mkdir boot<br />
$ cd boot <br />
$ gunzip -c ../boot.img-ramdisk.gz | cpio -i<br />
$ tar -cpvf ../boot.tar *<br />
$ cd ..<br />
<br />
Convert '''kernel''' to '''uImage''':<br />
$ mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n "Linux 2.6" -d boot.img-kernel uImage<br />
<br />
==== Extract system image: ====<br />
<br />
$ ./tools/simg2img system.img system1.img<br />
$ mkdir system<br />
$ mount -o loop system1.img system<br />
$ cd system<br />
$ tar -cpvf ../system.tar *<br />
$ cd ..<br />
$ umount system<br />
<br />
==== Extract recovery image: ====<br />
<br />
$ ./tools/split_bootimg.pl recovery.img<br />
Page size: 2048 (0x00000800)<br />
Kernel size: 4215036 (0x004050fc)<br />
Ramdisk size: 974998 (0x000ee096)<br />
Second size: 0 (0x00000000)<br />
Board name:<br />
Command line: console=ttyS0,115200 rw init=/init loglevel=5<br />
Writing recovery.img-kernel ... complete.<br />
Writing recovery.img-ramdisk.gz ... complete.<br />
<br />
==== Decompress the ramdisk data: ====<br />
$ mkdir recovery<br />
$ cd recovery<br />
$ gunzip -c ../recovery.img-ramdisk.gz | cpio -i<br />
$ tar -cpvf ../recovery.tar *<br />
$ cd ..<br />
<br />
=== SD card Partition ===<br />
Partitions description:<br />
<br />
WARNING: At the start we need a 17 MB unallocated partition, required for flash sunxi-spl and u-boot.bin without corrupting the SD.<br />
<br />
{| class="wikitable" |<br />
! partition<br />
! Size<br />
! Name<br />
! Fs<br />
! Description<br />
|-<br />
| /dev/sdc1<br />
| 16MiB<br />
| bootloader<br />
| VFAT<br />
| Files to assist the bootloader.<br />
|-<br />
| /dev/sdc2<br />
| 36MiB<br />
| boot<br />
| EXT4<br />
| ramdisk<br />
|-<br />
| /dev/sdc3<br />
| 500 MiB<br />
| system<br />
| EXT4<br />
| Android's /system partition<br />
|-<br />
| /dev/sdc4<br />
| Fill all space<br />
| extend<br />
| Extend Partition <br />
|-<br />
| /dev/sdc5<br />
| 300MiB<br />
| data<br />
| EXT4<br />
| <br />
|-<br />
| /dev/sdc6<br />
| 16 MiB<br />
| misc<br />
| EXT4<br />
|<br />
|-<br />
| /dev/sdc7<br />
| 36 Mib<br />
| recovery<br />
| EXT4<br />
| Android's recovery partition<br />
|-<br />
| /dev/sdc8<br />
| 125 MiB<br />
| cache<br />
| EXT4<br />
| <br />
|-<br />
| /dev/sdc9<br />
| 16 MiB<br />
| private<br />
| EXT4<br />
| <br />
|-<br />
| /dev/sdc10<br />
| 1-2 GiB<br />
| UDISK<br />
| VFAT<br />
| <br />
|-<br />
|}<br />
<br />
<br />
Now, identify the device of the card and export it as <tt>$card</tt>:<br />
<br />
$card=/dev/sdX (sdX should be replaced with the name of your device)<br />
<br />
dd if=/dev/zero of=$card bs=1M count=1<br />
sfdisk -R $card<br />
<br />
cat <<EOT | sfdisk --in-order -uM $card<br />
17,16,c<br />
,36,83<br />
,500,83<br />
,,5<br />
,300,83<br />
,16,83<br />
,36,83<br />
,125,83<br />
,16,83<br />
,,83<br />
EOT<br />
<br />
==== Format ====<br />
<br />
mkfs.vfat -n bootloader ${card}1<br />
mkfs.ext4 -L boot ${card}2<br />
mkfs.ext4 -L system ${card}3<br />
mkfs.ext4 -L data ${card}5<br />
mkfs.ext4 -L misc ${card}6<br />
mkfs.ext4 -L recovery ${card}7<br />
mkfs.ext4 -L cache ${card}8<br />
mkfs.ext4 -L private ${card}9<br />
mkfs.vfat -n UDISK ${card}10<br />
<br />
remove huge_file option from EXT4 fs (android kernel not have this option!!!)<br />
<br />
tune2fs -O ^huge_file ${card}2<br />
tune2fs -O ^huge_file ${card}3<br />
tune2fs -O ^huge_file ${card}5<br />
tune2fs -O ^huge_file ${card}6<br />
tune2fs -O ^huge_file ${card}7<br />
tune2fs -O ^huge_file ${card}8<br />
tune2fs -O ^huge_file ${card}9<br />
<br />
=== BootLoader ===<br />
<br />
For SD card booting you can try one of these pair of files from [[Miniand Hackberry|Hackberry]]:<br />
* '''1GB:''' [http://dl.miniand.com/jas-hacks/uboot/1gb/sunxi-spl.bin sunxi-spl.bin] [http://dl.miniand.com/jas-hacks/uboot/1gb/u-boot.bin u-boot.bin]<br />
* '''512MB:''' [http://dl.miniand.com/jas-hacks/uboot/512mb/sunxi-spl.bin sunxi-spl.bin] [http://dl.miniand.com/jas-hacks/uboot/512mb/u-boot.bin u-boot.bin]<br />
<br />
dd if=spl/sunxi-spl.bin of=$card bs=1024 seek=8<br />
dd if=u-boot.bin of=$card bs=1024 seek=32<br />
<br />
'''Note:''' The above will not work for the Cubieboard A10, you can try the images below or compile u-boot your self.<br />
<br />
<br />
<big>'''For Cubieboard A10:'''</big><br />
<br />
If you are in a pinch, you can try the files below, but it is recommended if you can that you compile them your self:<br />
* [http://dl.extremehosting.us/cubieboard/u-boot.img u-boot.img]<br />
* [http://dl.extremehosting.us/cubieboard/sunxi-spl.bin sunxi-spl.bin]<br />
* [http://dl.extremehosting.us/cubieboard/u-boot-sunxi-with-spl.bin u-boot-sunxi-with-spl.bin]<br />
<br />
git clone https://github.com/linux-sunxi/u-boot-sunxi.wiki.git<br />
make cubieboard_config<br />
make<br />
<br />
'''Note:''' It is recommended for best results that you compile it if you can on the device you plan to use it on.<br />
<br />
For cross compilation:<br />
<br />
git clone https://github.com/linux-sunxi/u-boot-sunxi.wiki.git<br />
make cubieboard_config CROSS_COMPILE=arm-linux-gnueabihf-<br />
<br />
Next, install your new u-boot on your sdcard:<br />
<br />
dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8<br />
<br />
or if you prefer to install the components separately:<br />
<br />
dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8<br />
dd if=u-boot.img of=/dev/sdX bs=1024 seek=40<br />
<br />
If you have issues at boot time you will find that setting up debug serial console will help a lot to find your issue.<br />
<br />
'''Reference:''' https://github.com/linux-sunxi/u-boot-sunxi/wiki<br />
<br />
=== Copy to SD card ===<br />
mkdir bootloader<br />
mount -o loop bootloader.img bootloader<br />
<br />
Copy files to bootloader partition:<br />
<br />
mount ${card}1 /mnt/<br />
cp uImage /mnt<br />
cp bootloader/script.bin /mnt<br />
<br />
cat >/mnt/uEnv.txt << EOT<br />
fexfile=script.bin<br />
kernel=uImage<br />
extraargs=root=/dev/mmcblk0p2 loglevel=8 rootwait console=ttyS0,115200 rw init=/init mac_addr=00:AE:99:A3:E4:AF<br />
boot_mmc=fatload mmc 0 0x43000000 ${fexfile}; fatload mmc 0 0x48000000 ${kernel}; bootm 0x48000000<br />
EOT<br />
<br />
Recovery uEnv.txt<br />
<br />
cat >/mnt/uEnv_recovery.txt << EOT<br />
fexfile=script.bin<br />
kernel=uImage<br />
extraargs=root=/dev/mmcblk0p7 loglevel=8 rootwait console=ttyS0,115200 rw init=/init mac_addr=00:AE:99:A3:E4:AF<br />
boot_mmc=fatload mmc 0 0x43000000 ${fexfile}; fatload mmc 0 0x48000000 ${kernel}; bootm 0x48000000<br />
EOT<br />
<br />
umount /mnt<br />
umount bootloader<br />
<br />
Copy data to Ramdisk partition:<br />
mount ${card}2 /mnt<br />
tar -xpvf boot.tar -C /mnt<br />
<br />
'''Note:''' If you would like to add additional Wifi drivers, you can actually do that here. <br />
[http://taqlim.blogspot.com/2013/06/belkin-f7d1101-wireless-usb-on-android.html This] reference will help you get the idea of what needs to be done to include additional Wifi modules for android.<br />
This page also includes the kernel modules for r8712u and directions on how to compile and add your own Wifi modules.<br />
<br />
Modify the name partition in init.sun4i.rc<br />
<br />
sed -i "s/nandd/mmcblk0p3/g" /mnt/init.sun4i.rc<br />
sed -i "s/nande/mmcblk0p5/g" /mnt/init.sun4i.rc<br />
sed -i "s/nandh/mmcblk0p8/g" /mnt/init.sun4i.rc<br />
sed -i "s/nandi/mmcblk0p10/g" /mnt/init.sun4i.rc<br />
umount /mnt<br />
<br />
Copy data to system partition:<br />
mount ${card}3 /mnt<br />
tar -xpvf system.tar -C /mnt<br />
umount /mnt<br />
<br />
Copy data to recovery partition:<br />
mount ${card}7 /mnt<br />
tar -xpvf recovery.tar -C /mnt<br />
sed -i "s/nandf/mmcblk0p6/g" /mnt/ueventd.sun4i.rc<br />
umount /mnt<br />
sync<br />
<br />
Now you can boot Android from SD card.<br />
<br />
== Automated Flash Kitchen ==<br />
<br />
Thierry Merle has assembled a Flash Kitchen originally for the Mele A2000 but it also works for other A10 devices.<br />
<br />
Download v2 from here: http://tmerle.blogspot.fr/2012/09/mele-a2000-my-own-linux-flash-kitchen.html<br />
<br />
After having put the original.img file (PhoenixCard source image), run "make build_sdcard" as root and it should create everything needed to generate the SD card boot files in sdcard/.<br />
<br />
Then, you will have to 'cd sdcard/', then run 'make DEV=/dev/sdX' (where X is the device letter of your SD card).<br />
<br />
=== Requirements ===<br />
<br />
Wine - in order to extract/build the flash image (look below for enhancements).<br />
<br />
Root access for scripts other than img_1extract.sh/img_2build.sh.<br />
<br />
The script will create /system in your root directory. This is necessary if you make symbolic links in "system" filesystem.<br />
<br />
Of course, you need an original image (that you will rename as original.img) to start hacking.<br />
<br />
=== Enhancements ===<br />
<br />
* If you don't have Wine you can use Ithamar's awutils [https://github.com/Ithamar/awutils] in img_1extract.sh instead of unimg.exe. You can find more info in [[Awutils]].<br />
<br />
* Here's abootimg statically linked and stripped for i386 and amd64: https://www.dropbox.com/s/xbe2u7ai6aqaob1/abootimg_i386+amd64_statically_linked+stripped.tar.xz<br />
<br />
i386 is untested natively so to be sure also included are the static libraries libblkid.a and libuuid.a and you might need blkid.h<br />
<br />
Change the LDLIBS line in the Makefile as follows:<br />
<br />
LDLIBS=-static -lblkid -luuid -L.<br />
<br />
* #!/bin/bash and function function_name() work better together in mkA10card.sh<br />
<br />
* "partition ends on cylinder 1023, beyond the end of the disk"<br />
<br />
You have to make some adjustments to partitions.txt. It's for a 16 GB [http://www.android-mobile-manager.com/android-mobile-recovery.html SD card] and so [http://www.androidphonesoft.com/resources/recover-deleted-files-from-android-sd-card.html Disk Utility] will show something like Capacity: 18446744 TB (-8,198,815,744 bytes). So you have to calculate partitions.txt yourself.<br />
<br />
=== General information ===<br />
<br />
* When make fails and you want to run it again:<br />
<pre><br />
tar: .: Cannot change ownership to uid 1000, gid 1000: Operation not permitted"<br />
</pre><br />
FAT does not allow UID, GID and symlinks. You have to [http://www.samsung-messages-backup.com/resources/astro-file-manager-alternative.html copy the files] manually.<br />
<br />
[[Category:Tutorial]]<br />
[[Category:Android]]</div>Jkpage