Bootloader Cracking : Devs only

Status
Not open for further replies.
Search This thread

goroh_kun

Senior Member
Apr 24, 2010
85
162
Tokyo,Japan or HongKong
current usbloader

Hi, I uploaded current test version usbloader.

usbloader0 can boot directly from linux kernel.
Code:
cat usbloader0 > /proc/splboot/image
echo > /proc/splboot/boot

usbloader is mapped in physical address 0x0000,
this binary is included in usbloader0.
I tried to copy to 0x00 and automatic boot it.but it doesn't seems work well.
I'll debugging this problem.
but you can memcpy this image to 0x00 by fastboot, you can boot it.

on the screen after booting the usbloader0,
we can see where usbloader binary loaded.
Code:
input_data=300057cc
input_data_end=3000f73c

we can re-copy to 0, like this command from your PC command prompt.
Code:
fastboot getvar memcpy0,300057cc,9f70
fastboot getvar go0
here, 9f70 = 3000f73c-300057cc

you can boot your spl
Code:
fastboot flash mem0 /path/to/spl
fastboot getvar go0
here, mem0 means upload image to 0, if you want to upload different addrees,
you can use mem02b00000, mem01000000, etc.


I added many command to check how the CPU internal memory works.
Code:
fastboot getvar memcmp0,300057cc,9f70
- to check memcpy correct.

fastboot getvar memcpy0,300057cc,9f70
- memcpy from 0x300057cc to 0x00, size 9f70

fastboot getvar dump0,20
- show memory dump from 0x0000, 0x20(32) unsigned integers

fastboot getvar go0
- call function from 0x00,
  if you want boot usbloader0, just call "fastboot getvar go30000000".

fastboot reboot
- clear screen

fastboot flash mem0 testbin
- upload testbin to 0x00

fastboot getvar mem0,4
- get memory through  from 0x00-0x10.
I use this command for dump memory.
I attached a script named dump2mem.sh help you to get mem.

http://hotfile.com/dl/56074792/6f8edc4/usbloader_20100718.zip.html
 
Last edited:

goroh_kun

Senior Member
Apr 24, 2010
85
162
Tokyo,Japan or HongKong
current works

Hi, just Yesterday night in Japan Local time,
I success to boot my own linux kernel, built fron source code, e-Sheep from SE.
but I have to disable many things like oncrpc, proc_com.. etc.
It's just because of Modem cpu crashed.
It seems when I boot SPL from original kernel. it goes crash.
from usbloader, I tried to use proc_com but I couldn't to use.
proc_com is used to ask something to modem cpu, like rebooting, turn off, play music,..etc).
so now I'm analizing whe modem crashed when usbloader bootup.

one idea is I have to notify restart Application CPU to Modem CPU.
There is interface to notify the reboot event to Modem CPU.
I can send this event, by this command.

Code:
mount -t debugfs debugfs /sys/kernel/debug
chmod 666 /sys/kernel/debug/modem_notifier/reboot_start
echo > /sys/kernel/debug/modem_notifier/reboot_start

I tried this, and we can see kernel log the event is reached to kernel driver.
after then, I tried to use proc_comm interface from usbloader.
but it's not work..
it seems more things I have to do before boot the usbloader.

see you next report.
 

irkkso

Senior Member
Mar 14, 2008
224
65
great work!

great work! I've been watching each new post in this topic ...
 

biktor_gj

Senior Member
Jan 25, 2008
1,408
7,008
About the baseband, you have to reboot armv6 cpu, then boot qualcomm's bootloader in there to make it boot again. Proc comm won't reply until the OS inside the baseband is loaded, and it won't boot until you tell it to. Also, we trash smem when booting the spl (we cut the kernel "the hard way" when we boot it), so unless we reboot it and let it write again and don't overlap the memory segment it will crash again.

Also mmu doesn't seem to be turned off before booting, and the cache doesn't seem to be stopped, so that will trash it all too. Resetting all the hardware on usbloader init.S would be a good idea...

Hi, just Yesterday night in Japan Local time,
I success to boot my own linux kernel, built fron source code, e-Sheep from SE.
but I have to disable many things like oncrpc, proc_com.. etc.
It's just because of Modem cpu crashed.
It seems when I boot SPL from original kernel. it goes crash.
from usbloader, I tried to use proc_com but I couldn't to use.
proc_com is used to ask something to modem cpu, like rebooting, turn off, play music,..etc).
so now I'm analizing whe modem crashed when usbloader bootup.

one idea is I have to notify restart Application CPU to Modem CPU.
There is interface to notify the reboot event to Modem CPU.
I can send this event, by this command.

Code:
mount -t debugfs debugfs /sys/kernel/debug
chmod 666 /sys/kernel/debug/modem_notifier/reboot_start
echo > /sys/kernel/debug/modem_notifier/reboot_start

I tried this, and we can see kernel log the event is reached to kernel driver.
after then, I tried to use proc_comm interface from usbloader.
but it's not work..
it seems more things I have to do before boot the usbloader.

see you next report.
 

goroh_kun

Senior Member
Apr 24, 2010
85
162
Tokyo,Japan or HongKong
how to disable smd_rpcrouter

Hi, I'm analizing how smd(shared memory driver) works,
MCPU & ACPU use smd channel 2(ch2) as rpc channel.

Code:
#cat /sys/kernel/debug/smd/ch
  ch02:   OPENED(5928/5928) DCCiwrs <->   OPENED(7980/7980) DRCiwrs
#cat /sys/kernel/debug/smd/tbl
ch00:   CLOSED(0000/0000) dcciwrs <->  CLOSING(0000/0000) DRCiwrS
ch01:   OPENED(0000/0000) DCCiwrs <->   OPENED(0000/0000) dRciwrs
ch02:   OPENED(5928/5928) DCCiwrs <->   OPENED(7980/7980) DRCiwrs
ch07:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) DRCiwrS
ch08:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) DRCiwrS
ch09:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) DRCiwrS
ch10:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) DRCiwrS
ch11:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) dRciwrS
ch12:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) dRciwrS
ch13:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) dRciwrS
ch17:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) DRCiwrS
ch39:   OPENED(0000/0000) DCCiwrs <->   OPENED(0000/0000) dRciwrs
ch40:   OPENED(0000/0000) DCCiwrs <->   OPENED(0000/0000) dRciwrs
ch42:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) DRCiwrS
ch43:   OPENED(0284/0284) DCCiwrs <->   OPENED(0232/0232) DRCiwrs
ch44:   OPENED(0000/0000) DCCiwrs <->   OPENED(0000/0000) DRCiwrs
ch45:   OPENED(0000/0000) DCCiwrs <->   OPENED(0000/0000) DRCiwrs
ch46:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) DRCiwrS
ch48:   OPENED(0232/0232) DCCiwrs <->   OPENED(0168/0168) DRCiwrs
ch49:   CLOSED(0000/0000) dcciwrs <->  OPENING(0000/0000) DRCiwrS
ch50:   CLOSED(0000/0000) dcciwrs <->  CLOSING(0000/0000) DRCiwrS
ch51:   CLOSED(0000/0000) dcciwrs <->  CLOSING(0000/0000) DRCiwrS
ch52:   CLOSED(0000/0000) dcciwrs <->  CLOSING(0000/0000) DRCiwrS

Other channels are used as modem, gps, etc.
RPC channel has a watchdog function.
We can see how it works from a source code in Kernel where
arch/arm/mach-msm/rpc_server_dog_keepalive.c

DOG_KEEPALIVE service program code = 0x30000015,
we can see transaction like this.

Code:
# cat /sys/kernel/debug/smem_log/dump_sym | grep 30000015
MODM:    2595523    ONCRPC: STD_CALL_ASYNC: 00000008 30000015 00000002 00000000 00000000 00000000
MODM:    2926645    ONCRPC: STD_CALL_ASYNC: 00000009 30000015 00000002 00000000 00000000 00000000
MODM:    3257785    ONCRPC: STD_CALL_ASYNC: 0000000a 30000015 00000002 00000000 00000000 00000000
MODM:    3588909    ONCRPC: STD_CALL_ASYNC: 0000000b 30000015 00000002 00000000 00000000 00000000
...

If we can stop this rpc calling from MCPU, it seems not going to crash.
or, I have to implement rpc replying function into usbloader..

see you next report.
 
Last edited:

biktor_gj

Senior Member
Jan 25, 2008
1,408
7,008
Maybe this comes handy (extracted from the code). Though I'm not completely sure that if it notifies a system_reboot to the amss the complete chipset will be resetted, but maybe worth a try ;)
Code:
/* SEMC: Add functions to communicate with AMSS - start */
void smsm_wait_for_modem(void)
{
	uint32_t *smsm = NULL;
	unsigned long flags;

	printk(KERN_INFO "Waiting for Modem...\n");
	for (;;) {
		spin_lock_irqsave(&smem_lock, flags);
		if (smsm == NULL) {
			smsm = smem_alloc(ID_SHARED_STATE,
						SMSM_NUM_ENTRIES * sizeof(uint32_t));
		} else {
			if ((smsm[SMSM_MODEM_STATE] & SMSM_OSENTERED) != 0) {
				spin_unlock_irqrestore(&smem_lock, flags);
				break;
			}
		}
		spin_unlock_irqrestore(&smem_lock, flags);
		schedule();
	}

	return;
}

/* SEMC:CE: DMS00760180: Linux freezes when the phone crash during smd spin lock - start */
void smsm_notify_apps_crash(void)
{
	uint32_t *smsm;
	unsigned long flags;
	uint32_t old_state;

	/* smem_lock is already held and all instances of acquiring
	 * smem_lock use spin_lock_irqsave, so no need to acquire the
	 * lock again, as we are not in any critical section ...
	 *  
	 * Then why do we need the lock ? ... 
	 * Hmm If it is not already held , better to get the lock to 
	 * disable interrupts and prevent any further modificaiton of smsm[]
	 *
	 */ 
	if(!spin_is_locked(&smem_lock)) {
		spin_lock_irqsave(&smem_lock, flags);
		smsm = smem_alloc(ID_SHARED_STATE,
				SMSM_NUM_ENTRIES * sizeof(uint32_t));
		if (smsm != NULL) {
			old_state = smsm[SMSM_APPS_STATE];
			smsm[SMSM_APPS_STATE] |= SMSM_APPS_CRASHDUMP;
			notify_other_smsm(SMSM_APPS_STATE, old_state, smsm[SMSM_APPS_STATE]);
		}
		spin_unlock_irqrestore(&smem_lock, flags);
	}
	else {
		smsm = smem_alloc(ID_SHARED_STATE,
				SMSM_NUM_ENTRIES * sizeof(uint32_t));
		if (smsm != NULL) {
			old_state = smsm[SMSM_APPS_STATE];
			smsm[SMSM_APPS_STATE] |= SMSM_APPS_CRASHDUMP;
			notify_other_smsm(SMSM_APPS_STATE, old_state, smsm[SMSM_APPS_STATE]);
		}
	}
	return;
}

/* Acknowledge AMMS crash by setting SMSM_APPS_CRASHDUMP*/
void smsm_ack_amss_crash(void)
{
	uint32_t *smsm;

	smsm = smem_alloc(ID_SHARED_STATE,
				SMSM_NUM_ENTRIES * sizeof(uint32_t));
	if (smsm != NULL) {
		smsm[SMSM_APPS_STATE] |= SMSM_APPS_CRASHDUMP;
	}

	return;
}
/* SEMC:CE: DMS00760180: Linux freezes when the phone crash during smd spin lock - end */

void smsm_notify_system_reboot(void)
{
	uint32_t *smsm;
	unsigned long flags;
	uint32_t old_state;

/* SEMC:CE: DMS00760180: Linux freezes when the phone crash during smd spin lock - start */
	/* smem_lock is already held and all instances of acquiring
	 * smem_lock use spin_lock_irqsave, so no need to acquire the
	 * lock again, as we are not in any critical section ...
	 *  
	 * Then why do we need the lock ? ... 
	 * Hmm If it is not already held , better to get the lock to 
	 * disable interrupts and prevent any further modificaiton of smsm[]
	 *
	 */ 
	if(!spin_is_locked(&smem_lock)) {
		spin_lock_irqsave(&smem_lock, flags);
		smsm = smem_alloc(ID_SHARED_STATE,
				SMSM_NUM_ENTRIES * sizeof(uint32_t));
		if (smsm != NULL) {
			old_state = smsm[SMSM_APPS_STATE];
			smsm[SMSM_APPS_STATE] |= SMSM_SYSTEM_REBOOT;
			notify_other_smsm(SMSM_APPS_STATE, old_state, smsm[SMSM_APPS_STATE]);
		}
		spin_unlock_irqrestore(&smem_lock, flags);
	}
	else {
		smsm = smem_alloc(ID_SHARED_STATE,
				SMSM_NUM_ENTRIES * sizeof(uint32_t));
		if (smsm != NULL) {
			old_state = smsm[SMSM_APPS_STATE];
			smsm[SMSM_APPS_STATE] |= SMSM_SYSTEM_REBOOT;
			notify_other_smsm(SMSM_APPS_STATE, old_state, smsm[SMSM_APPS_STATE]);
		}
	}
/* SEMC:CE: DMS00760180: Linux freezes when the phone crash during smd spin lock - end */
	return;
}
Regards
 

cvchetan

Retired Forum Moderator
May 24, 2009
699
59
Bhubaneswar
guys guys devs only..

if u want to discuss about this then open a thread for "other than devs"

ill sticky it if needed..

chetan
 

goroh_kun

Senior Member
Apr 24, 2010
85
162
Tokyo,Japan or HongKong
current works, RPC keepalive reply is implemented.

I succeed to avoid MCPU crach in SPL.
I added RPC event handler to reply the RPC keepalive call from MCPU.
I found that MCPU doesn't crash anymore.

Next, I try to patch kernel to avoid re-initialize smem area,
and I added fake new service RPC events from MCPU to ACPU.
so now, I can use new Linux kernel from usbloader :)

http://hotfile.com/dl/58316988/b219136/loader_kernel.zip.html

this is for developer, now I prepare a release version.

thanks. and please wait next report.
 

Bin4ry

Inactive Recognized Developer
Nov 14, 2008
2,007
5,907
Berlin
WWWWWWOOOOOOOOOOOOOOOOOOOOWWWWWWWWWWWWWWWWWWWW!!!!!!!!!!!!!
GOROH YOU ARE THE BEST :)))))

Regards
Andreas



I succeed to avoid MCPU crach in SPL.
I added RPC event handler to reply the RPC keepalive call from MCPU.
I found that MCPU doesn't crash anymore.

Next, I try to patch kernel to avoid re-initialize smem area,
and I added fake new service RPC events from MCPU to ACPU.
so now, I can use new Linux kernel from usbloader :)

http://hotfile.com/dl/58316988/b219136/loader_kernel.zip.html

this is for developer, now I prepare a release version.

thanks. and please wait next report.
 

jerpelea

Senior Recognized Developer
Nov 7, 2006
7,474
40,177
Lund
sites.google.com
thanks
for loader

smd_rpcrouter.c
is broken and will not compile
will try debugging


@.config -why do you use s1 loader
we can use qualcom loader (see configs folder)
 
Last edited:

Cablekevin

Senior Member
Jan 27, 2010
216
3
0172
www.cablekevin.nl
I succeed to avoid MCPU crach in SPL.
I added RPC event handler to reply the RPC keepalive call from MCPU.
I found that MCPU doesn't crash anymore.

Next, I try to patch kernel to avoid re-initialize smem area,
and I added fake new service RPC events from MCPU to ACPU.
so now, I can use new Linux kernel from usbloader :)

http://hotfile.com/dl/58316988/b219136/loader_kernel.zip.html

this is for developer, now I prepare a release version.

thanks. and please wait next report.
This was the thing that went wrong time after time? Or am i not getting the complete picture.
 

goroh_kun

Senior Member
Apr 24, 2010
85
162
Tokyo,Japan or HongKong
patchec kernel source code

Hi, I uploaded patched kernel source code.

http://hotfile.com/dl/58576670/b835c4a/X10_Donut_100325_01_patched.tgz.html

after build kernel image, I made the boot.img like this

Code:
cp arch/arm/boot/Image .
./mkbootimg --kernel Image --ramdisk ramdisk.gz --base 0x20000000 -o boot-new.img

I'm now working to update splboot and usbloader,
I think it's possible to boot kernel image directly from splboot module.
we have many results by analyzing using usbloader :)
 
Last edited:
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 161
    Bootloader is broken/bypassed!
    Big bad huge font to avoid confusion =)


    @Goroh_kun:

    Buddy, I know you're still reading this forums so... I just want you to know that you are absolutely BRILLIANT. You're a STAR.

    BIG thanks for all your contributions into this project! Nothing, and I mean NOTHING would happen without you.



    @devs:

    devicez.png
    device2o.png




    @SE: lads, it's your turn now - please unlock it already. I promise we won't brick our phones :)

    @all: DON'T ask for details. I will post here when I'm ready to do so. Today (I guess?) is the Arc release date and stuff, I don't want to mess around...


    Still busy working abroad,

    Cheers,
    z
    144
    Ok, here we go. It wasn't the April Fool thingy :)

    The bootloader has been bypassed using the kexec/miniloader method

    We are able to boot custom kernels now!


    I'll keep it short as I'm quite busy today... I haven't had much luck with disabling MPU nor resetting a MCPU - it failed no matter what I did. Same thing with porting shutdown procedures into miniloader. But when I found out that the custom kernel doesn't reboot on baseband 52, I switched to the .504 sources and restarted the work. Using the debugfs tips by Goroh, I realised some stuff I'd rather to keep in between the developers here... And then *poof* - the green USB led appeared and I knew I was getting there!

    Anyway... this is the first release of the fully working custom kernel (flashable via xRecovery). I haven't had much time to work on it so it's kind of proof-of-concept. Tested for 48h without any problem (not even a reboot).


    FreeKernel-alpha1:

    http://www.mediafire.com/?d8v914keiqsmc3n

    This is the alpha version of custom 2.6.29 kernel based on the SE sources. I do not plan to work on this release anymore - it is just for testing purpose. From today on I'll start to port SE stuff to the latest (GBread) kernel.


    Changes:

    - removed 32 fps cap
    - implemented netfilter (Droid wall, native USB/wifi tethering etc.)
    - undervolted to 0.950mV to save battery
    - don't remember what else I did, I bet something nasty :)
    - super ugly boot logo!


    Requirements:

    - baseband .52 + the relevant kernel
    - clean 2.1 ROM, compatibile with .52 baseband (e.g. .504)
    - working xRecovery


    Please note I am not responsible for any damage this software may cause to your device! Use it at your own risk!

    There is absolutely no support for this alpha release!


    Big thanks to (no particular order): Goroh_kun, Jerpelea, Bin4ry, Maxrfon, Biktor_gj and everybody else who contributed into X10 custom kernel development.


    At first the relevant kernel patches/sources will be delivered to the recognised X10 developers. Later on everything will be released as it's obviously Open Sourced.


    Please refrain from posting comments in this thread - it's for developers only. Spamming will only make our task harder to accomplish!


    Cheers,
    z
    88
    Great job!

    Hi, long time no see.
    It's goroh.

    > zdzihu.
    I'd like to say, Your strong effort and indefatigableness achieve this brilliant work!

    I have parted with my X10a, but I'm looking forward to see development goes on.
    :)
    35
    cm7 boots with custom kernel
    31
    Ok Thread Cleaned and j.Anderson banned