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![]()
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: