FORUMS
Remove All Ads from XDA

[DEV][TEMPLATE] AnyKernel3 - Easily Mod ROM Ramdisk + Pack Image.gz [Flashable Zip]

13,860 posts
Thanks Meter: 30,735
 
By osm0sis, Recognized Developer / Recognized Contributor on 5th March 2014, 03:32 AM
Post Reply Email Thread
1st October 2014, 12:20 AM |#41  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,735
 
Donate to Me
More
Quote:
Originally Posted by Captain_Throwback

I know in the case of M8, the ROM-included dtb may be device(variant)-specific, but the custom dtb may be universal, so the dtb has to be replaced. The dtb stores some important changes like the overclock values. Is it possible to have an easier way to replace dtb, much like with zImage? I just found this thread and would like to try and use it, but the dtb replacement is essential for these newer HTC devices, for all of the custom kernel to work as intended.

EDIT: Is there a way to check the package for a custom dtb, and if present, use it when repacking, but if not, use the original dtb?

Thanks for the info!

zImages are universal but dtb isn't; luckily copying the file like I explain in the post you quoted is extremely straightforward.

I guess you could check to see if it matches known stock dtb sha1sums, but if it contains the overclock frequencies like you say then it sounds like it'd be necessary to force your custom one regardless.
1st October 2014, 12:35 AM |#42  
Captain_Throwback's Avatar
Senior Member
Flag The Nothing
Thanks Meter: 22,615
 
10
Donate to Me
More
Quote:
Originally Posted by osm0sis

Thanks for the info!

zImages are universal but dtb isn't; luckily copying the file like I explain in the post you quoted is extremely straightforward.

I guess you could check to see if it matches known stock dtb sha1sums, but if it contains the overclock frequencies like you say then it sounds like it'd be necessary to force your custom one regardless.

Where does that line go? I was looking in the script and getting confused.
1st October 2014, 01:20 AM |#43  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,735
 
Donate to Me
More
Quote:
Originally Posted by Captain_Throwback

Where does that line go? I was looking in the script and getting confused.

Anywhere after the current image gets dumped/extracted. I'd tend to put it at the end since all the middle stuff is technically labeled "ramdisk changes".
2nd October 2014, 07:40 PM |#44  
Captain_Throwback's Avatar
Senior Member
Flag The Nothing
Thanks Meter: 22,615
 
10
Donate to Me
More
Alright, so I'm giving this a shot on my M8, and am coming across some errors. This is what the recovery.log says:
Code:
Installing '/sdcard/Download/ElementalX_M8_Sense_AnyKernel_CPTB.zip'...
Checking for MD5 file...
Skipping MD5 check: no MD5 file found
I:Zip does not contain SELinux file_contexts file in its root.
I:Legacy property environment initialized.
 
minzip: Extracted file "/tmp/anykernel/META-INF/com/google/android/update-binary"
minzip: Extracted file "/tmp/anykernel/META-INF/com/google/android/updater-script"
minzip: Extracted file "/tmp/anykernel/anykernel.sh"
minzip: Extracted file "/tmp/anykernel/dtb"
minzip: Extracted file "/tmp/anykernel/tools/mkbootimg"
minzip: Extracted file "/tmp/anykernel/tools/unpackbootimg"
minzip: Extracted file "/tmp/anykernel/zImage"
ElementalX by flar2 @ xda-developers
 
AnyKernel2 by osm0sis @ xda-developers
 
about to run program [/sbin/busybox] with 3 args
about to run program [/sbin/sh] with 2 args
Installing kernel...
/tmp/anykernel/anykernel.sh: line 6: kernel.string=ElementalX: not found
/tmp/anykernel/anykernel.sh: line 7: do.devicecheck=0: not found
/tmp/anykernel/anykernel.sh: line 8: do.initd=0: not found
/tmp/anykernel/anykernel.sh: line 9: do.modules=0: not found
/tmp/anykernel/anykernel.sh: line 10: do.cleanup=1: not found
/tmp/anykernel/anykernel.sh: line 11: device.name1=m8: not found
/tmp/anykernel/anykernel.sh: line 12: device.name2=m8dugl: not found
/tmp/anykernel/anykernel.sh: line 13: device.name3=m8whl: not found
/tmp/anykernel/anykernel.sh: line 14: device.name4=m8wl: not found
/tmp/anykernel/anykernel.sh: cd: line 29: can't cd to /tmp/anykernel/ramdisk
32768+0 records in
32768+0 records out
16777216 bytes (16.0MB) copied, 0.277314 seconds, 57.7MB/s
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 ehci-hcd.park=3 vdd_uv=1 cpu_oc=2572800
BOARD_KERNEL_BASE 00008000
BOARD_NAME 
BOARD_PAGE_SIZE 2048
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02008000
BOARD_TAGS_OFFSET 01df8000
BOARD_DT_SIZE 1298432
cpio: file_contexts not created: newer or same age file exists
cpio: init not created: newer or same age file exists
cpio: property_contexts not created: newer or same age file exists
cpio: default.prop not created: newer or same age file exists
cpio: sepolicy not created: newer or same age file exists
cpio: ueventd.qcom.rc not created: newer or same age file exists
cpio: sbin/healthd not created: newer or same age file exists
cpio: sbin/adbd not created: newer or same age file exists
cpio: ueventd.rc not created: newer or same age file exists
cpio: seapp_contexts not created: newer or same age file exists
cpio: init.rc not created: newer or same age file exists
cpio: fstab.qcom not created: newer or same age file exists
4368 blocks
/tmp/anykernel/anykernel.sh: cd: line 158: can't cd to /tmp/anykernel/ramdisk
 
Repacking image failed. Aborting...
about to run program [/sbin/sh] with 3 args
script aborted: called abort()
called abort()
I:Legacy property environment disabled.
E:Error executing updater binary in zip '/sdcard/Download/ElementalX_M8_Sense_AnyKernel_CPTB.zip'
Error flashing zip '/sdcard/Download/ElementalX_M8_Sense_AnyKernel_CPTB.zip'

It seems to be throwing quite a few 'not found' messages, and then it dies after something with the ramdisk. I removed all of the additional stuff from the anykernel script (hopefully I didn't remove too much) and I'll list it below:
Code:
# AnyKernel 2.0 Ramdisk Mod Script 
# osm0sis @ xda-developers

## AnyKernel setup
# EDIFY properties
kernel.string=ElementalX by flar2 @ xda-developers
do.devicecheck=0
do.initd=0
do.modules=0
do.cleanup=1
device.name1=m8
device.name2=m8dugl
device.name3=m8whl
device.name4=m8wl

# shell variables
block=/dev/block/platform/msm_sdcc.1/by-name/boot;

## end setup


## AnyKernel methods (DO NOT CHANGE)
# set up extracted files and directories
ramdisk=/tmp/anykernel/ramdisk;
bin=/tmp/anykernel/tools;
split_img=/tmp/anykernel/split_img;
patch=/tmp/anykernel/patch;

cd $ramdisk;
chmod -R 755 $bin;
mkdir -p $split_img;

OUTFD=`ps | grep -v "grep" | grep -oE "update(.*)" | cut -d" " -f3`;
ui_print() { echo "ui_print $1" >&$OUTFD; echo "ui_print" >&$OUTFD; }

# dump boot and extract ramdisk
dump_boot() {
  dd if=$block of=/tmp/anykernel/boot.img;
  $bin/unpackbootimg -i /tmp/anykernel/boot.img -o $split_img;
  if [ $? != 0 ]; then
    ui_print " "; ui_print "Dumping/unpacking image failed. Aborting...";
    echo 1 > /tmp/anykernel/exitcode; exit;
  fi;
  gunzip -c $split_img/boot.img-ramdisk.gz | cpio -i;
}

# repack ramdisk then build and write image
write_boot() {
  cd $split_img;
  cmdline=`cat *-cmdline`;
  board=`cat *-board`;
  base=`cat *-base`;
  pagesize=`cat *-pagesize`;
  kerneloff=`cat *-kerneloff`;
  ramdiskoff=`cat *-ramdiskoff`;
  tagsoff=`cat *-tagsoff`;
  if [ -f *-second ]; then
    second=`ls *-second`;
    second="--second $split_img/$second";
    secondoff=`cat *-secondoff`;
    secondoff="--second_offset $secondoff";
  fi;
  if [ -f *-dtb ]; then
    dtb=`ls *-dtb`;
    dtb="--dt $split_img/$dtb";
  fi;
  cd $ramdisk;
  find . | cpio -H newc -o | gzip > /tmp/anykernel/ramdisk-new.cpio.gz;
  $bin/mkbootimg --kernel /tmp/anykernel/zImage --ramdisk /tmp/anykernel/ramdisk-new.cpio.gz $second --cmdline "$cmdline" --board "$board" --base $base --pagesize $pagesize --kernel_offset $kerneloff --ramdisk_offset $ramdiskoff $secondoff --tags_offset $tagsoff $dtb --output /tmp/anykernel/boot-new.img;
  if [ $? != 0 -o `wc -c < /tmp/anykernel/boot-new.img` -gt `wc -c < /tmp/anykernel/boot.img` ]; then
    ui_print " "; ui_print "Repacking image failed. Aborting...";
    echo 1 > /tmp/anykernel/exitcode; exit;
  fi;
  dd if=/tmp/anykernel/boot-new.img of=$block;
}

# backup_file <file>
backup_file() { cp $1 $1~; }

# replace_string <file> <if search string> <original string> <replacement string>
replace_string() {
  if [ -z "$(grep "$2" $1)" ]; then
      sed -i "s;${3};${4};" $1;
  fi;
}

# insert_line <file> <if search string> <before/after> <line match string> <inserted line>
insert_line() {
  if [ -z "$(grep "$2" $1)" ]; then
    case $3 in
      before) offset=0;;
      after) offset=1;;
    esac;
    line=$((`grep -n "$4" $1 | cut -d: -f1` + offset));
    sed -i "${line}s;^;${5};" $1;
  fi;
}

# replace_line <file> <line replace string> <replacement line>
replace_line() {
  if [ ! -z "$(grep "$2" $1)" ]; then
    line=`grep -n "$2" $1 | cut -d: -f1`;
    sed -i "${line}s;.*;${3};" $1;
  fi;
}

# remove_line <file> <line match string>
remove_line() {
  if [ ! -z "$(grep "$2" $1)" ]; then
    line=`grep -n "$2" $1 | cut -d: -f1`;
    sed -i "${line}d" $1;
  fi;
}

# prepend_file <file> <if search string> <patch file>
prepend_file() {
  if [ -z "$(grep "$2" $1)" ]; then
    echo "$(cat $patch/$3 $1)" > $1;
  fi;
}

# append_file <file> <if search string> <patch file>
append_file() {
  if [ -z "$(grep "$2" $1)" ]; then
    echo -ne "\n" >> $1;
    cat $patch/$3 >> $1;
    echo -ne "\n" >> $1;
  fi;
}

# replace_file <file> <permissions> <patch file>
replace_file() {
  cp -fp $patch/$3 $1;
  chmod $2 $1;
}

## end methods


## AnyKernel permissions
# set permissions for included files
#chmod -R 755 $ramdisk


## AnyKernel install
dump_boot;

# begin ramdisk changes

# init.rc



# end ramdisk changes

# replace extracted dtb with modified dtb
cp -f /tmp/anykernel/dtb $split_img/boot.img-dtb

write_boot;

## end install

Can you tell what's going wrong?
2nd October 2014, 08:05 PM |#45  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,735
 
Donate to Me
More
Quote:
Originally Posted by Captain_Throwback

Alright, so I'm giving this a shot on my M8, and am coming across some errors. This is what the recovery.log says:

Code:
Installing '/sdcard/Download/ElementalX_M8_Sense_AnyKernel_CPTB.zip'...
Checking for MD5 file...
Skipping MD5 check: no MD5 file found
I:Zip does not contain SELinux file_contexts file in its root.
I:Legacy property environment initialized.
 
minzip: Extracted file "/tmp/anykernel/META-INF/com/google/android/update-binary"
minzip: Extracted file "/tmp/anykernel/META-INF/com/google/android/updater-script"
minzip: Extracted file "/tmp/anykernel/anykernel.sh"
minzip: Extracted file "/tmp/anykernel/dtb"
minzip: Extracted file "/tmp/anykernel/tools/mkbootimg"
minzip: Extracted file "/tmp/anykernel/tools/unpackbootimg"
minzip: Extracted file "/tmp/anykernel/zImage"
ElementalX by flar2 @ xda-developers
 
AnyKernel2 by osm0sis @ xda-developers
 
about to run program [/sbin/busybox] with 3 args
about to run program [/sbin/sh] with 2 args
Installing kernel...
/tmp/anykernel/anykernel.sh: line 6: kernel.string=ElementalX: not found
/tmp/anykernel/anykernel.sh: line 7: do.devicecheck=0: not found
/tmp/anykernel/anykernel.sh: line 8: do.initd=0: not found
/tmp/anykernel/anykernel.sh: line 9: do.modules=0: not found
/tmp/anykernel/anykernel.sh: line 10: do.cleanup=1: not found
/tmp/anykernel/anykernel.sh: line 11: device.name1=m8: not found
/tmp/anykernel/anykernel.sh: line 12: device.name2=m8dugl: not found
/tmp/anykernel/anykernel.sh: line 13: device.name3=m8whl: not found
/tmp/anykernel/anykernel.sh: line 14: device.name4=m8wl: not found
/tmp/anykernel/anykernel.sh: cd: line 29: can't cd to /tmp/anykernel/ramdisk
32768+0 records in
32768+0 records out
16777216 bytes (16.0MB) copied, 0.277314 seconds, 57.7MB/s
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 ehci-hcd.park=3 vdd_uv=1 cpu_oc=2572800
BOARD_KERNEL_BASE 00008000
BOARD_NAME 
BOARD_PAGE_SIZE 2048
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02008000
BOARD_TAGS_OFFSET 01df8000
BOARD_DT_SIZE 1298432
cpio: file_contexts not created: newer or same age file exists
cpio: init not created: newer or same age file exists
cpio: property_contexts not created: newer or same age file exists
cpio: default.prop not created: newer or same age file exists
cpio: sepolicy not created: newer or same age file exists
cpio: ueventd.qcom.rc not created: newer or same age file exists
cpio: sbin/healthd not created: newer or same age file exists
cpio: sbin/adbd not created: newer or same age file exists
cpio: ueventd.rc not created: newer or same age file exists
cpio: seapp_contexts not created: newer or same age file exists
cpio: init.rc not created: newer or same age file exists
cpio: fstab.qcom not created: newer or same age file exists
4368 blocks
/tmp/anykernel/anykernel.sh: cd: line 158: can't cd to /tmp/anykernel/ramdisk
 
Repacking image failed. Aborting...
about to run program [/sbin/sh] with 3 args
script aborted: called abort()
called abort()
I:Legacy property environment disabled.
E:Error executing updater binary in zip '/sdcard/Download/ElementalX_M8_Sense_AnyKernel_CPTB.zip'
Error flashing zip '/sdcard/Download/ElementalX_M8_Sense_AnyKernel_CPTB.zip'

It seems to be throwing quite a few 'not found' messages, and then it dies after something with the ramdisk. I removed all of the additional stuff from the anykernel script (hopefully I didn't remove too much) and I'll list it below:
Code:
# AnyKernel 2.0 Ramdisk Mod Script 
# osm0sis @ xda-developers

## AnyKernel setup
# EDIFY properties
kernel.string=ElementalX by flar2 @ xda-developers
do.devicecheck=0
do.initd=0
do.modules=0
do.cleanup=1
device.name1=m8
device.name2=m8dugl
device.name3=m8whl
device.name4=m8wl

# shell variables
block=/dev/block/platform/msm_sdcc.1/by-name/boot;

## end setup


## AnyKernel methods (DO NOT CHANGE)
# set up extracted files and directories
ramdisk=/tmp/anykernel/ramdisk;
bin=/tmp/anykernel/tools;
split_img=/tmp/anykernel/split_img;
patch=/tmp/anykernel/patch;

cd $ramdisk;
chmod -R 755 $bin;
mkdir -p $split_img;

OUTFD=`ps | grep -v "grep" | grep -oE "update(.*)" | cut -d" " -f3`;
ui_print() { echo "ui_print $1" >&$OUTFD; echo "ui_print" >&$OUTFD; }

# dump boot and extract ramdisk
dump_boot() {
  dd if=$block of=/tmp/anykernel/boot.img;
  $bin/unpackbootimg -i /tmp/anykernel/boot.img -o $split_img;
  if [ $? != 0 ]; then
    ui_print " "; ui_print "Dumping/unpacking image failed. Aborting...";
    echo 1 > /tmp/anykernel/exitcode; exit;
  fi;
  gunzip -c $split_img/boot.img-ramdisk.gz | cpio -i;
}

# repack ramdisk then build and write image
write_boot() {
  cd $split_img;
  cmdline=`cat *-cmdline`;
  board=`cat *-board`;
  base=`cat *-base`;
  pagesize=`cat *-pagesize`;
  kerneloff=`cat *-kerneloff`;
  ramdiskoff=`cat *-ramdiskoff`;
  tagsoff=`cat *-tagsoff`;
  if [ -f *-second ]; then
    second=`ls *-second`;
    second="--second $split_img/$second";
    secondoff=`cat *-secondoff`;
    secondoff="--second_offset $secondoff";
  fi;
  if [ -f *-dtb ]; then
    dtb=`ls *-dtb`;
    dtb="--dt $split_img/$dtb";
  fi;
  cd $ramdisk;
  find . | cpio -H newc -o | gzip > /tmp/anykernel/ramdisk-new.cpio.gz;
  $bin/mkbootimg --kernel /tmp/anykernel/zImage --ramdisk /tmp/anykernel/ramdisk-new.cpio.gz $second --cmdline "$cmdline" --board "$board" --base $base --pagesize $pagesize --kernel_offset $kerneloff --ramdisk_offset $ramdiskoff $secondoff --tags_offset $tagsoff $dtb --output /tmp/anykernel/boot-new.img;
  if [ $? != 0 -o `wc -c < /tmp/anykernel/boot-new.img` -gt `wc -c < /tmp/anykernel/boot.img` ]; then
    ui_print " "; ui_print "Repacking image failed. Aborting...";
    echo 1 > /tmp/anykernel/exitcode; exit;
  fi;
  dd if=/tmp/anykernel/boot-new.img of=$block;
}

# backup_file <file>
backup_file() { cp $1 $1~; }

# replace_string <file> <if search string> <original string> <replacement string>
replace_string() {
  if [ -z "$(grep "$2" $1)" ]; then
      sed -i "s;${3};${4};" $1;
  fi;
}

# insert_line <file> <if search string> <before/after> <line match string> <inserted line>
insert_line() {
  if [ -z "$(grep "$2" $1)" ]; then
    case $3 in
      before) offset=0;;
      after) offset=1;;
    esac;
    line=$((`grep -n "$4" $1 | cut -d: -f1` + offset));
    sed -i "${line}s;^;${5};" $1;
  fi;
}

# replace_line <file> <line replace string> <replacement line>
replace_line() {
  if [ ! -z "$(grep "$2" $1)" ]; then
    line=`grep -n "$2" $1 | cut -d: -f1`;
    sed -i "${line}s;.*;${3};" $1;
  fi;
}

# remove_line <file> <line match string>
remove_line() {
  if [ ! -z "$(grep "$2" $1)" ]; then
    line=`grep -n "$2" $1 | cut -d: -f1`;
    sed -i "${line}d" $1;
  fi;
}

# prepend_file <file> <if search string> <patch file>
prepend_file() {
  if [ -z "$(grep "$2" $1)" ]; then
    echo "$(cat $patch/$3 $1)" > $1;
  fi;
}

# append_file <file> <if search string> <patch file>
append_file() {
  if [ -z "$(grep "$2" $1)" ]; then
    echo -ne "\n" >> $1;
    cat $patch/$3 >> $1;
    echo -ne "\n" >> $1;
  fi;
}

# replace_file <file> <permissions> <patch file>
replace_file() {
  cp -fp $patch/$3 $1;
  chmod $2 $1;
}

## end methods


## AnyKernel permissions
# set permissions for included files
#chmod -R 755 $ramdisk


## AnyKernel install
dump_boot;

# begin ramdisk changes

# init.rc



# end ramdisk changes

# replace extracted dtb with modified dtb
cp -f /tmp/anykernel/dtb $split_img/boot.img-dtb

write_boot;

## end install

Can you tell what's going wrong?

not found is fine, it's just a harmless side-effect of how I'm abusing the shell script to act as a prop file for EDIFY to check. I also see you're just directly replacing a lot of files whole (hence the cpio warnings), which isn't really best practice for AnyKernel2.

That aside, if you look at the repack function there are only a couple reasons it could fail, either because mkbootimg returns a failure or because the resulting boot.img is larger than the dump of the boot partition (hence too large to safely flash).

To figure out which, the best way to debug AnyKernel2 zips is to set do.cleanup=0, and then adb shell in and see how far it got. Check out the contents of the /tmp/anykernel/ directories and even run anykernel.sh manually to get the direct shell output.

Oh, the device check only supports 3 variants right now too, do you need a 4th? I'll see about adding up to 5 in a future update.
2nd October 2014, 08:12 PM |#46  
Captain_Throwback's Avatar
Senior Member
Flag The Nothing
Thanks Meter: 22,615
 
10
Donate to Me
More
Quote:
Originally Posted by osm0sis

not found is fine, it's just a harmless side-effect of how I'm abusing the shell script to act as a prop file for EDIFY to check. I also see you're just directly replacing a lot of files whole (hence the cpio warnings), which isn't really best practice for AnyKernel2.

That aside, if you look at the repack function there are only a couple reasons it could fail, either because mkbootimg returns a failure or because the resulting boot.img is larger than the dump of the boot partition (hence too large to safely flash).

To figure out which, the best way to debug AnyKernel2 zips is to set do.cleanup=0, and then adb shell in and see how far it got. Check out the contents of the /tmp/anykernel/ directories and even run anykernel.sh manually to get the direct shell output.

I'm actually not replacing any files - I believe those were just left over from failed flashes. It seems to be failing because the ramdisk folder isn't being created - are you saying that's not an actual issue? It states that twice in there.

Unfortunately I'm not testing this on my own device, which is bricked, so it may be difficult to get the additional feedback you mentioned. I did, on a whim, add a mkdir -p $ramdisk and it seems to have gotten further:
[hide]
Code:
Installing kernel...
/tmp/anykernel/anykernel.sh: line 6: kernel.string=ElementalX: not found
/tmp/anykernel/anykernel.sh: line 7: do.devicecheck=0: not found
/tmp/anykernel/anykernel.sh: line 8: do.initd=0: not found
/tmp/anykernel/anykernel.sh: line 9: do.modules=0: not found
/tmp/anykernel/anykernel.sh: line 10: do.cleanup=1: not found
/tmp/anykernel/anykernel.sh: line 11: device.name1=m8: not found
/tmp/anykernel/anykernel.sh: line 12: device.name2=m8dugl: not found
/tmp/anykernel/anykernel.sh: line 13: device.name3=m8whl: not found
/tmp/anykernel/anykernel.sh: line 14: device.name4=m8wl: not found
32768+0 records in
32768+0 records out
16777216 bytes (16.0MB) copied, 0.278854 seconds, 57.4MB/s
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 ehci-hcd.park=3 vdd_uv=1 cpu_oc=2572800
BOARD_KERNEL_BASE 00008000
BOARD_NAME 
BOARD_PAGE_SIZE 2048
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02008000
BOARD_TAGS_OFFSET 01df8000
BOARD_DT_SIZE 1298432
4368 blocks
about to run program [/sbin/sh] with 3 args
cat: can't open '/tmp/anykernel/exitcode': No such file or directory
sh: 1: unknown operand
run_program: child exited with status 2
I can confirm that it didn't repack the image as the resulting file doesn't exist for it to flash. I think the ramdisk isn't extracting now.
The Following User Says Thank You to Captain_Throwback For This Useful Post: [ View ] Gift Captain_Throwback Ad-Free
2nd October 2014, 08:29 PM |#47  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,735
 
Donate to Me
More
Quote:
Originally Posted by Captain_Throwback

I'm actually not replacing any files - I believe those were just left over from failed flashes. It seems to be failing because the ramdisk folder isn't being created - are you saying that's not an actual issue? It states that twice in there.

Unfortunately I'm not testing this on my own device, which is bricked, so it may be difficult to get the additional feedback you mentioned. I did, on a whim, add a mkdir -p $ramdisk and it seems to have gotten further:
[hide]

Code:
Installing kernel...
/tmp/anykernel/anykernel.sh: line 6: kernel.string=ElementalX: not found
/tmp/anykernel/anykernel.sh: line 7: do.devicecheck=0: not found
/tmp/anykernel/anykernel.sh: line 8: do.initd=0: not found
/tmp/anykernel/anykernel.sh: line 9: do.modules=0: not found
/tmp/anykernel/anykernel.sh: line 10: do.cleanup=1: not found
/tmp/anykernel/anykernel.sh: line 11: device.name1=m8: not found
/tmp/anykernel/anykernel.sh: line 12: device.name2=m8dugl: not found
/tmp/anykernel/anykernel.sh: line 13: device.name3=m8whl: not found
/tmp/anykernel/anykernel.sh: line 14: device.name4=m8wl: not found
32768+0 records in
32768+0 records out
16777216 bytes (16.0MB) copied, 0.278854 seconds, 57.4MB/s
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 ehci-hcd.park=3 vdd_uv=1 cpu_oc=2572800
BOARD_KERNEL_BASE 00008000
BOARD_NAME 
BOARD_PAGE_SIZE 2048
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02008000
BOARD_TAGS_OFFSET 01df8000
BOARD_DT_SIZE 1298432
4368 blocks
about to run program [/sbin/sh] with 3 args
cat: can't open '/tmp/anykernel/exitcode': No such file or directory
sh: 1: unknown operand
run_program: child exited with status 2
I can confirm that it didn't repack the image as the resulting file doesn't exist for it to flash. I think the ramdisk isn't extracting now.

Right! The leftovers are there because it failed; regardless of do.cleanup that's how it works so you can review what went wrong. You could delete /tmp/anykernel/ or just reboot recovery to reset.

But, ah! Very fair point! You've actually stripped everything out of the ramdisk directory in the zip, something I hadn't accounted for, so the directory doesn't get created by unzip like it normally would!

Try this change (up in the methods section) after you reset the directory:
Code:
mkdir -p $ramdisk $split_img;
chmod -R 755 $bin;
cd $ramdisk;
2nd October 2014, 08:35 PM |#48  
Captain_Throwback's Avatar
Senior Member
Flag The Nothing
Thanks Meter: 22,615
 
10
Donate to Me
More
Quote:
Originally Posted by osm0sis

Right! The leftovers are there because it failed; regardless of do.cleanup that's how it works so you can review what went wrong. You could delete /tmp/anykernel/ or just reboot recovery to reset.

But, ah! Very fair point! You've actually stripped everything out of the ramdisk directory in the zip, something I hadn't accounted for, so the directory doesn't get created by unzip like it normally would!

Try this change (up in the methods section) after you reset the directory:

Code:
mkdir -p $ramdisk $split_img;
chmod -R 755 $bin;
cd $ramdisk;

That's essentially what I tried before my last post. The only difference is I set permissions to 777 to give it the best shot at working, but it's still erroring out at the exitcode (I believe for the ramdisk). Any other ideas? Anything else I can post to help troubleshoot?
Code:
cat: can't open '/tmp/anykernel/exitcode': No such file or directory
sh: 1: unknown operand
run_program: child exited with status 2
'exitcode' isn't supposed to be a file, is it? It can't seem to be able to create/write to it - where/when doesn't that file get created? Are there other permissions missing?
2nd October 2014, 08:48 PM |#49  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,735
 
Donate to Me
More
Quote:
Originally Posted by Captain_Throwback

That's essentially what I tried before my last post. The only difference is I set permissions to 777 to give it the best shot at working, but it's still erroring out at the exitcode (I believe for the ramdisk). Any other ideas? Anything else I can post to help troubleshoot?

Code:
cat: can't open '/tmp/anykernel/exitcode': No such file or directory
sh: 1: unknown operand
run_program: child exited with status 2
'exitcode' isn't supposed to be a file, is it? It can't seem to be able to create/write to it - where/when doesn't that file get created? Are there other permissions missing?

That shouldn't matter either, it's just the EDIFY check for an error code failing because there was none (which is why there's no file). This commit should make this a bit more clear for you: https://github.com/osm0sis/AnyKernel...9fd89e41178553

It correctly halts when there's an issue, and doesn't make a difference otherwise, it's basically just a warning, so that's not the root of the problem either.

Do it exactly like I wrote above and see if it works. The cd command needed to be moved to the end to make sure the ramdisk was getting extracted to the new directory.
2nd October 2014, 08:52 PM |#50  
Captain_Throwback's Avatar
Senior Member
Flag The Nothing
Thanks Meter: 22,615
 
10
Donate to Me
More
Quote:
Originally Posted by osm0sis

That shouldn't matter either, it's just the EDIFY check for an error code failing because there was none (which is why there's no file). This commit should make this a bit more clear for your: https://github.com/osm0sis/AnyKernel...9fd89e41178553

It correctly halts when there's an issue, and doesn't make a difference otherwise, it's basically just a warning, so that's not why you're having issues.

Thanks. I'm having my tester pull the contents of /tmp/anykernel after the flash so I can see how far it's getting. Hopefully that'll offer some insight into where it's failing. I'd hoped the recovery.log would be more helpful.
14th October 2014, 09:25 PM |#51  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,735
 
Donate to Me
More
Quote:
Originally Posted by Captain_Throwback

I know in the case of M8, the ROM-included dtb may be device(variant)-specific, but the custom dtb may be universal, so the dtb has to be replaced. The dtb stores some important changes like the overclock values. Is it possible to have an easier way to replace dtb, much like with zImage? I just found this thread and would like to try and use it, but the dtb replacement is essential for these newer HTC devices, for all of the custom kernel to work as intended.

EDIT: Is there a way to check the package for a custom dtb, and if present, use it when repacking, but if not, use the original dtb?

Quote:
Originally Posted by osm0sis

Thanks for the info!

zImages are universal but dtb isn't; luckily copying the file like I explain in the post you quoted is extremely straightforward.

I guess you could check to see if it matches known stock dtb sha1sums, but if it contains the overclock frequencies like you say then it sounds like it'd be necessary to force your custom one regardless.

I've decided to add automatic dtb swapping after all! Great idea, really! It'll just simply check for a dtb file in the root of the zip (where you put your custom zImage) and if it exists, use it, if not fallback to the extracted one. I think this is what you were actually suggesting, but I was overthinking it until I reread it just now.

I'm also increasing the possible device check # to 5 and adding in the ramdisk directory creation fix.

Just touching up the README now then I'll push the commit in a few minutes.

https://github.com/osm0sis/AnyKernel...21b87c7d7c0dfd


Oh, I also wanted to address Pull Requests for non-standard device support - that'll include Samsung's old headerless images, Samsung's new broken-standard-headered images, Sony's ELF images, MTK devices, and any device that uses MTD instead of EMMC. Someone's already submitted one, and it occurred to me that what would be cool is to abuse the way the Pull Request system works and leave it open, so that way anyone wanting to fork the repo can go ahead and then pull in the request for the non-standard device they may want it for as well. So everyone feel free to fork for support and leave me those requests so we can indirectly support as many devices as possible without complicating the standards supporting devices.
The Following 3 Users Say Thank You to osm0sis For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
anykernel, flashable zip, kernel, scripting, template

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

Advanced Search
Display Modes