[DEV Idea] Magldr/CLK detection & Install Integration

Search This thread
J

jianC

Guest
CLK/MAGLDR Detection
Link to original thread: Neopeek

My old thread about this idea from july of last year was a fail, and that did not work at all. This is a completely different version tested and working by me and others.

Here is a very simple script (can this even be considered scripting?) to detect magldr/clk (for rom devs) and flash the correct boot type (boot.img or /boot) so end-users won't have to flash another kernel patch afterwards.

Background info:
CLK 1.4.0.1 (version and up) has an extra clk=1.4.0.1 (or cLK=x.x.x.x) at the end of cmdline (and magldr does not), so because of that, we can use this to find which bootloader is in use.

This is what the cmdline is when clk 1.4.0.1 is installed...
Code:
no_console_suspend=1 wire.search_count=5 clk=1.4.0.1

To detect CLK bootloader or MAGLDR bootloader, just run a shell script within updater-script and use grep to find clk anywhere in cmdline, and if it detects it, it will write "clk=true" to /tmp/nfo.prop and if not, it will write clk=null (we have to write something because if nothing is written, file_getprop will exit with error)

In Shell Script:
Code:
#!/sbin/sh
# checksys.sh 

output=`grep -i "clk" /proc/cmdline`

if [ -n "$output" ]; then
echo "clk=true" > /tmp/nfo.prop; else
echo "clk=null" > /tmp/nfo.prop; fi

in Updater-script:
Code:
#check the system information of the system we are installing on
package_extract_file("checksys.sh","/tmp/checksys.sh");
set_perm(0,0,755,"/tmp/checksys.sh");
run_program("/tmp/checksys.sh");
if file_getprop("/tmp/nfo.prop","clk") == "true"
then
    ui_print("CLK Detected... Enabling PPP...");
    run_program("/sbin/sh","-c","
    echo \"p\" > /system/ppp
    else
    ui_print("Magldr detected... Defaulting to RMNET...");
endif;

Other files you need to include such as libhtc_ril_wrapper.so/init.d scripts and modifications to build.prop or default.prop, you can figure out by yourself

Rom devs need only included boot.img! Please read this post.

However, users will need to modify their flash.cfg a bit. Please read complete info from this post
EXT detection script
Code:
#!/sbin/sh
# Check for mmcblk0p2 partition type
# e334 <[email protected]>

tp=$(parted /dev/block/mmcblk0p2 print | egrep -i 'ext[2-4]|linux-swap' | awk '{ print $5 }')
pr1=`echo "type=$tp" | cut -c -8` 
echo $pr1 >> /tmp/nfo.prop

in updater-script
Code:
# Sample
if file_getprop("/tmp/nfo.prop","type") == "ext"
then
    ui_print("Second Partition is Ext!"
else
    ui_print("Second Partition is Linuxswap!"
endif;

If you change the name of "part=" to something else, make sure to change the cut deliminator also..

You can figure out the rest :)

Old Scripts (for historic purposes):
http://pastebin.com/b5YWvj3B


I want to say thanks to the work of Tytung, Koush, EZterry, Cedesmith, arif-ali, cmhtcleo, tytung, and Cotulla (feel free to donate to them) because I learned a lot looking from their work.

Any questions, please ask, thanks for looking!
 
Last edited:

Rick_1995

Inactive Recognized Developer
Sep 3, 2009
1,118
3,016
Santa Clara
Code:
output=`df | grep /data | cut -d " " -f5`

if [ $output -gt 455680 ]
then
  installeu=`df | grep /sd-ext | cut -d " " -f5` 
  if [ $installeu -gt (size_of_ext_in_mb*1024) ]
  then
    echo "tmous=false" >> /tmp/device.prop
  else    
    echo "tmous=true" >> /tmp/device.prop
else
  echo "tmous=false" >> /tmp/device.prop
fi

This script will also let automate eu or tmous install,
if /data size is greater than 445 mb ( higher than what eu can have ) then it checks if /sd-ext size is also big (if user wants eu install on tmous device) otherwise it continues with normal tmous install.

Sorry if i can't interpret exactly what the script does because I'm not a native english speaker.

I wrote this yesterday for dunc001 when he needed automation in tbd rom.
 
Last edited:

Marvlesz

Senior Member
Jun 28, 2010
2,318
740
Saudi Arabia
And then we would be able to implement automatic partitioning. Where a certain ROM would repartition system, boot and cache partitions automatically upon installation. (I don't think that's going to happen, or probably will, but in the long run :D)

Anyway, great to see those two ideas put into work. The more automatic installation becomes, the easier it is for newbies :D.

Appreciated.
 
J

jianC

Guest
I updated it to make it less "clunky", we can now run everything in updater-script :)
 
Last edited:

Dunc001

Inactive Recognized Developer
Apr 6, 2010
2,705
1,462
Hiding out south of the border...
We've now got an auto install working for TBD which uses the /data size check to detect EU or TMOUS, then runs a check for existence of mmcblk0p2 (sd-ext) whether TMO or EU. If TMO is detected with no ext then TMO ROM configuration is installed. If TMO or EU with ext partition is detected then EU ROM configuration is installed. And if EU with no ext is detected then a warning message is displayed, /system is reformatted and installation is aborted. cLK detection is also incorporated for kernel installation. So now we have a fully automated install process regardless of bootloader, phone model and ext partition :)

The only thing we haven't checked is if someone has a TMO phone with no ext partition but with a Swap partition whether the swap partition would become 0p2, in which case we'd just need to add in an fschk to see if it is swap or not.

Anyway, the ROM is uploading now so I'm sure we'll hear soon enough if there is an issue LOL

Thank you so much for the inspiration for this and for the original idea :cool:
 
Last edited:
  • Like
Reactions: carl1961 and Phhere
J

jianC

Guest
You can check the partition type with "parted /dev/block/mmcblk0p2 print" and use grep or sed to read.. I'm currently working on a script for that

EDIT: I reverted to old version because the updated version did not seem to be working consistently with the "test" command..
 
Last edited:

kylew1212

Senior Member
Dec 1, 2011
485
281
Alabama
www.memoryx2.com
So if I add all the files needed for magldr & clk and put this in my updater script it will automatically detect what files to install or do I need a different script for that??

Also would I need to include both a boot.img and boot folder??


Another thing, when building my rom, I added the ril wrapper and a few other things in the build.prop file.. I don't know if thats correct or not but it worked and booted.
 
J

jianC

Guest
So if I add all the files needed for magldr & clk and put this in my updater script it will automatically detect what files to install or do I need a different script for that??

Also would I need to include both a boot.img and boot folder??


Another thing, when building my rom, I added the ril wrapper and a few other things in the build.prop file.. I don't know if thats correct or not but it worked and booted.

Yes. You should add all the files needed for clk into the rom also
 
J

jianC

Guest
The only thing we haven't checked is if someone has a TMO phone with no ext partition but with a Swap partition whether the swap partition would become 0p2, in which case we'd just need to add in an fschk to see if it is swap or not.

I finally got around to writing it.. I don't know if anyone else has already done so but this is completely based on my research and work..

I am sure there is a way to make the code less 'lengthy' but it works for now...

in script (or add to checksys.sh or wherever)
Code:
#!/sbin/sh
# Check for mmcblk0p2 partition type
# e334 <[email protected]>

tp=$(parted /dev/block/mmcblk0p2 print | egrep -i 'ext[2-4]|linux-swap' | awk '{ print $5 }')
pr1=`echo "type=$tp" | cut -c -8` 
echo $pr1 >> /tmp/nfo.prop

in updater-script
Code:
# Sample
if file_getprop("/tmp/nfo.prop","type") == "ext"
then
    ui_print("Second Partition is Ext!"
else
    ui_print("Second Partition is Linuxswap!"
endif;

If you change the name of "part=" to something else, make sure to change the cut deliminator also..

You can figure out the rest :)

I hope this benefits the community even though I'm not that good at scripting and I don't have my HD2 anymore.
 
Last edited:

iamcxa

Senior Member
Sep 21, 2008
421
153
Taiwan
iamcxa.org
I finally got around to writing it.. I don't know if anyone else has already done so but this is completely based on my research and work..

I am sure there is a way to make the code less 'lengthy' but it works for now...

in script (or add to checksys.sh or wherever)
Code:
#!/sbin/sh
# Check for mmcblk0p2 partition type
# e334 <[email protected]>

tp=$(parted /dev/block/mmcblk0p2 print | egrep -iw 'ext[2-4]|linux-swap' | awk '{ print $5 }')
pr1=`echo "type=$tp" | cut -c -8` 
echo $pr1 >> /tmp/nfo.prop

in updater-script
Code:
# Sample
if file_getprop("/tmp/nfo.prop","type") == "ext"
then
    ui_print("Second Partition is Ext!"
else
    ui_print("Second Partition is Linuxswap!"
endif;

If you change the name of "part=" to something else, make sure to change the cut deliminator also..

You can figure out the rest :)

I hope this benefits the community even though I'm not that good at scripting and I don't have my HD2 anymore.

Hey you don't have hd2 anymore? So where is your hd2? It's sadly to heard about this.(last time when I pressed the thanks button, I didn't notice the line.:eek:)

Sent from my HTC Sensation XL with Beats Audio X315e using XDA
 
J

jianC

Guest
Hey you don't have hd2 anymore? So where is your hd2? It's sadly to heard about this.(last time when I pressed the thanks button, I didn't notice the line.:eek:)

Sent from my HTC Sensation XL with Beats Audio X315e using XDA

I don't anymore.. I replace the digitizer 3 times already since may 2010 and I traded hd2 motherboard for mytouch 3g slide.. Maybe in the future I will get another one since it is such a great phone (when the touchscreen worked haha) I will still be around to offer help
 
Last edited:

Nightwolf117

Senior Member
Oct 11, 2011
4,613
109
27
Brisbane, Queensland
I don't anymore.. I replace the digitizer 3 times already since may 2010 and I traded hd2 motherboard for mytouch 3g slide.. Maybe in the future I will get another one since it is such a great phone (when the touchscreen worked haha) I will still be around to offer help

:D My MyTouch that I'll be shipping in the next week and a half ^_^

Sent via XDA for Windows Phone (HTC HD2 running Windows Phone 7.5)
 
J

jianC

Guest
Thanks to cmhtcleo (from this post in the cm10 thread) and tytung (from this post), devs will not need to include both unpacked initrd.gz/zImage and boot.img if they want to simplify things and encourage transition to boot.img only.

Only boot.img is required and some modification to flash.cfg in magldr 1.13

I have also removed unnecessary lines from script posted in OP.

Just a notice for devs who haven't discovered this.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 11
    Code:
    output=`df | grep /data | cut -d " " -f5`
    
    if [ $output -gt 455680 ]
    then
      installeu=`df | grep /sd-ext | cut -d " " -f5` 
      if [ $installeu -gt (size_of_ext_in_mb*1024) ]
      then
        echo "tmous=false" >> /tmp/device.prop
      else    
        echo "tmous=true" >> /tmp/device.prop
    else
      echo "tmous=false" >> /tmp/device.prop
    fi

    This script will also let automate eu or tmous install,
    if /data size is greater than 445 mb ( higher than what eu can have ) then it checks if /sd-ext size is also big (if user wants eu install on tmous device) otherwise it continues with normal tmous install.

    Sorry if i can't interpret exactly what the script does because I'm not a native english speaker.

    I wrote this yesterday for dunc001 when he needed automation in tbd rom.
    2
    We've now got an auto install working for TBD which uses the /data size check to detect EU or TMOUS, then runs a check for existence of mmcblk0p2 (sd-ext) whether TMO or EU. If TMO is detected with no ext then TMO ROM configuration is installed. If TMO or EU with ext partition is detected then EU ROM configuration is installed. And if EU with no ext is detected then a warning message is displayed, /system is reformatted and installation is aborted. cLK detection is also incorporated for kernel installation. So now we have a fully automated install process regardless of bootloader, phone model and ext partition :)

    The only thing we haven't checked is if someone has a TMO phone with no ext partition but with a Swap partition whether the swap partition would become 0p2, in which case we'd just need to add in an fschk to see if it is swap or not.

    Anyway, the ROM is uploading now so I'm sure we'll hear soon enough if there is an issue LOL

    Thank you so much for the inspiration for this and for the original idea :cool: