FORUMS
Remove All Ads from XDA

Boot from SD-card | New Method [2.6.32]

64 posts
Thanks Meter: 7
 
By gr0gmint, Member on 27th May 2010, 04:23 PM
Post Reply Email Thread
To make the HTC Desire boot from a 1gb file on your SD-card:

Instead of having to partition the SD-card to make this work,there is another solution; that is to make a "virtual" EXT2 partition as a file on the FAT32 partition.

You can make this file as big as you want. 1gb is a fitting size though. .. you will probably need a linux box to make this work.... The file has to be called altboot.ext2 and lie at the root of the SD-card

NOTE: The initfiles and the modified kernel in this guide is 2.6.32 ONLY. I understood this may be an inconvenience for some. This kernel also disabled the "Android Paranoid Networking" feature, which is a useless pain-in-the-ass feature.


1. To make a 1GB empty file, issue dd if=/dev/zero of=altboot.ext2 bs=1M count=1000
2. Make a EXT2 filesystem on the file: mkfs.ext2 altboot.ext2
3. Mount the file as a loopdevice: mount -o loop -t ext2 altboot.ext2 <mountpoint>
4. Copy files from the attached initfiles.zip to <mountpoint>
5. Copy all files from a rom of your choice to <mountpoint>
6. Issue a chmod -R 0755 <mountpoint>
7. Issue umount <mountpoint>
8. Copy altboot.ext2 to the root of the SD-card
9. Flash my kernel image
10. Reboot your phone, and press the Home key repeatedly

Good luck


The source code changes for this kernel can be found at http://github.com/gr0gmint/kernel_msm
(Here is the source code for the two "special" init files)

executable in the ramdisk:
Code:
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <linux/loop.h>
#include <fcntl.h>

#define BB_LOOP_SET_STATUS LOOP_SET_STATUS64
#define BB_LOOP_GET_STATUS LOOP_GET_STATUS64
typedef struct loop_info64 loop_info;


int main (int argc, char * argv[]) {
    int dfd,ffd;
    loop_info loopinfo;

    mknod("/sd2" , S_IFBLK|S_IRUSR| S_IWUSR, makedev(179,1) );
    mknod("/lo5" , S_IFBLK|S_IRUSR| S_IWUSR, makedev(7,5) );


    mkdir("/sd", 0755);
    sleep(7);
    mount("/sd2","/sd", "vfat",0, NULL) ;
    
  
    ffd = open("/sd/altboot.ext2", O_RDWR);
    dfd = open("/lo5", O_RDWR);
    
	ioctl(dfd, LOOP_SET_FD, ffd);
	memset(&loopinfo, 0, sizeof(loopinfo));
	strcpy((char *)loopinfo.lo_file_name, "/sd/altboot.ext2");
	ioctl(dfd, BB_LOOP_SET_STATUS, &loopinfo);
    mkdir("/chrootenv", 0755);
    if (mount("/lo5", "/chrootenv","ext2", 0, NULL) != 0 ) {
	    execv("/init", argv);
	}
    execv("/chrootenv/altinit", argv);
}
executable on the SD-card:
Code:
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/mount.h>
int main (int argc, char * argv[]) {
	
	if (chroot("/chrootenv/") == 0) {
	chdir("/");

	execv ("/init", argv);
	}
		


}
Attached Files
File Type: zip initfiles.zip - [Click for QR Code] (163.3 KB, 514 views)
File Type: zip altboot-kernel.zip - [Click for QR Code] (2.32 MB, 536 views)
 
 
27th May 2010, 05:56 PM |#2  
Senior Member
Thanks Meter: 15
 
More
Any error on execution?
27th May 2010, 06:30 PM |#3  
OP Member
Thanks Meter: 7
 
More
Quote:
Originally Posted by shawe_ewahs

Any error on execution?

Yes it reboots, and resumes with a normal boot. I made some error checking, and it seems the init binary gets executed, but there's trouble with mounting the SD-card. I will try with manually mknod'ing in a moment.

EDIT: That didn't help either.
27th May 2010, 07:15 PM |#4  
Senior Member
Thanks Meter: 29
 
More
I'm not sure but when you do chroot you propably lost system folders. Maybe you can try this :

Code:
#include <unistd.h>
#include <sys/stat.h>
#include <sys/stat.h>

int main (int argc, char * argv[]) {

    mkdir("/dev", 0755);
    mkdir("/dev/block", 0755);
    mknod("/dev/block/mmcblk0p2" , S_IFBLK|S_IRUSR| S_IWUSR, makedev(179,2) );

    mkdir("/mnt", 0755);
    mkdir("/mnt/sdcard", 0755);
    mount("/dev/block/mmcblk0p2","/mnt/sdcard", "ext2",0, NULL);
    chroot("/mnt/sdcard");

    mkdir("/dev", 0755);
    mkdir("/proc", 0755);
    mkdir("/sys", 0755);
    mount("tmpfs", "/dev", "tmpfs", 0, "mode=0755");
    mkdir("/dev/pts", 0755);
    mkdir("/dev/socket", 0755);
    mount("devpts", "/dev/pts", "devpts", 0, NULL);
    mount("proc", "/proc", "proc", 0, NULL);
    mount("sysfs", "/sys", "sysfs", 0, NULL);
    execv("/init", argv);
}
Edit : of course you need to firstly create special file /dev/block/mmcblk0p2
Edit2 : tryed to add code for creating /dev/block/mmcblk0p2, not sure if it will works I didn't test that ;)
27th May 2010, 07:33 PM |#5  
OP Member
Thanks Meter: 7
 
More
Quote:
Originally Posted by kubino99

I'm not sure but when you do chroot you propably lost system folders. Maybe you can try this :

Code:
#include <unistd.h>


int main (int argc, char * argv[]) {

    mkdir("/dev", 0755);
    mkdir("/mnt", 0755);
    mkdir("/mnt/sdcard", 0755);
    mount("/dev/block/mmcblk0p2","/mnt/sdcard", "ext2",0, NULL);
    chroot("/mnt/sdcard");

    mkdir("/dev", 0755);
    mkdir("/proc", 0755);
    mkdir("/sys", 0755);
    mount("tmpfs", "/dev", "tmpfs", 0, "mode=0755");
    mkdir("/dev/pts", 0755);
    mkdir("/dev/socket", 0755);
    mount("devpts", "/dev/pts", "devpts", 0, NULL);
    mount("proc", "/proc", "proc", 0, NULL);
    mount("sysfs", "/sys", "sysfs", 0, NULL);
    execv("/init", argv);
}
Edit : of course you need to firstly create special file /dev/block/mmcblk0p2

Thanks for the input, but it still reboots
27th May 2010, 07:45 PM |#6  
Senior Member
Thanks Meter: 13
 
More
i read something like this here

http://forum.xda-developers.com/showthread.php?t=594077

you can try to contact the user
27th May 2010, 07:45 PM |#7  
Senior Member
Thanks Meter: 29
 
More
Quote:
Originally Posted by gr0gmint

Thanks for the input, but it still reboots

edited my previous post with code for creating special file. you can test it once more.
27th May 2010, 08:12 PM |#8  
OP Member
Thanks Meter: 7
 
More
Quote:
Originally Posted by kubino99

edited my previous post with code for creating special file. you can test it once more.

Thanks for the effort, but it still fails at the mounting.
I wonder if the mmc bus needs "activating"
27th May 2010, 08:26 PM |#9  
OP Member
Thanks Meter: 7
 
More
dmesg | grep -i 'mmc'

EDIT: I can see i probably need to sleep a few seconds before i mount. Will try later

Code:
[    4.355255] bravo_init_mmc()+
[    4.355438] bravo_init_mmc()-
[    5.939910] mmc0: MMC_BUSCLK_PWRSAVE is enabled
[    5.940185] mmc0: Qualcomm MSM SDCC at 0x00000000a0300000 irq 24,0 dma 8
[    5.940185] mmc0: Platform slot type: Not defined
[    5.940185] mmc0: 4 bit data mode enabled
[    5.940216] mmc0: MMC clock 144000 -> 50000000 Hz, PCLK 64000000 Hz
[    5.940216] mmc0: Slot eject status = 1
[    5.940216] mmc0: Power save feature enable = 1
[    5.940246] mmc0: DM non-cached buffer at ffa06000, dma_addr 0x3b331000
[    5.940246] mmc0: DM cmd busaddr 0x3b331000, cmdptr busaddr 0x3b331300
[    5.940704] mmc1: MMC_BUSCLK_PWRSAVE is enabled
[    5.941192] mmc1: Qualcomm MSM SDCC at 0x00000000a0400000 irq 26,0 dma 8
[    5.941192] mmc1: Platform slot type: SD
[    5.941192] mmc1: 4 bit data mode enabled
[    5.941223] mmc1: MMC clock 144000 -> 50000000 Hz, PCLK 64000000 Hz
[    5.941223] mmc1: Slot eject status = 0
[    5.941223] mmc1: Power save feature enable = 1
[    5.941223] mmc1: DM non-cached buffer at ffa07000, dma_addr 0x3b335000
[    5.941253] mmc1: DM cmd busaddr 0x3b335000, cmdptr busaddr 0x3b335300
[    6.173095] mmc1: Command timeout (cmd= 5 mci_st=00000004)
[    6.179077] mmc1: Command timeout (cmd= 5 mci_st=00000004)
[    6.185119] mmc1: Command timeout (cmd= 5 mci_st=00000004)
[    6.191101] mmc1: Command timeout (cmd= 5 mci_st=00000004)
[    6.711578] mmc1: host does not support reading read-only switch. assuming write-enable.
[    6.711791] mmc1: new high speed SDHC card at address 673b
[    6.712432] mmcblk0: mmc1:673b SD16G 14.9 GiB 
[    6.712921]  mmcblk0: p1 p2
27th May 2010, 09:28 PM |#10  
OP Member
Thanks Meter: 7
 
More
It boots now, but is stuck at the HTC logo, although adbd runs.
Some of the errors it loops constantly:
Code:
E/FramebufferNativeWindow(  484): Couldn't get gralloc module

E/libEGL  (  484): eglGetDisplay:632 error 300c (EGL_BAD_PARAMETER)
E/libEGL  (  484): eglInitialize:646 error 3008 (EGL_BAD_DISPLAY)


I/Zygote  (  483): Exit zygote because system server (484) has terminated
I/ServiceManager(   55): service 'media.audio_flinger' died
I/ServiceManager(   55): service 'media.player' died
I/ServiceManager(   55): service 'media.camera' died
I/ServiceManager(   55): service 'media.audio_policy' died
I/ServiceManager(   62): Waiting for sevice SurfaceFlinger...


E/AudioHardwareQSD(  507): Cannot open /dev/audience_a1026 -1
I/AudioHardwareQSD(  507): set_tpa2018d1_parameters() not present

E/Zygote  (  512): setreuid() failed. errno: 17
27th May 2010, 09:37 PM |#11  
Senior Member
Thanks Meter: 29
 
More
Quote:
Originally Posted by gr0gmint

It boots now, but is stuck at the HTC logo, although adbd runs.
Some of the errors it loops constantly:

Code:
E/FramebufferNativeWindow(  484): Couldn't get gralloc module

E/libEGL  (  484): eglGetDisplay:632 error 300c (EGL_BAD_PARAMETER)
E/libEGL  (  484): eglInitialize:646 error 3008 (EGL_BAD_DISPLAY)


I/Zygote  (  483): Exit zygote because system server (484) has terminated
I/ServiceManager(   55): service 'media.audio_flinger' died
I/ServiceManager(   55): service 'media.player' died
I/ServiceManager(   55): service 'media.camera' died
I/ServiceManager(   55): service 'media.audio_policy' died
I/ServiceManager(   62): Waiting for sevice SurfaceFlinger...


E/AudioHardwareQSD(  507): Cannot open /dev/audience_a1026 -1
I/AudioHardwareQSD(  507): set_tpa2018d1_parameters() not present

E/Zygote  (  512): setreuid() failed. errno: 17

seems like you need to create special files in /dev folder check via adb which files are present.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes