• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root [Development] Unofficial TWRP - K2_CL

Yeah, now it's outputting not found errors in the recovery log

If it says not found then make sure /system is being mounted. For some reason /system has to be mounted in order for the binaries to be found and used. I find it strange to do that but it seems to be the only way for whatever the reason is.
 
Yeah, now it's outputting not found errors in the recovery log

Try,

gcc -static -Iinclude mkbootimg/mkbootimg.c libmincrypt/sha.c libmincrypt/rsa.c libmincrypt/sha256.c -o mkbootimg

And,

gcc -static -Iinclude mkbootimg/unmkbootimg.c -o unmkbootimg

Going off the top of my head while at work but hopefully that does the trick?


And possibly afterwards,

strip unmkbootimg mkbootimg
 
Try,

gcc -static -Iinclude mkbootimg/mkbootimg.c libmincrypt/sha.c libmincrypt/rsa.c libmincrypt/sha256.c -o mkbootimg

And,

gcc -static -Iinclude mkbootimg/unmkbootimg.c -o unmkbootimg

Going off the top of my head while at work but hopefully that does the trick?


And possibly afterwards,

strip unmkbootimg mkbootimg

Built using the above commands (except the strip command, I didn't see that until after I started flashing the zip)
 
Yeah, one of the lines in the recovery log was something about an "unexpected (" so I am trying after strip

Sweet, making progress. Send me those binaries so I can download them and run tests on my end :-) using my new script.
 
Sent you a PM

Did my tests, they were not compiled properly. Working on it now. But I can confirm that by statically linking these binaries will make the zip work. Been in contact with osm0sis over on xda in regards with his binaries and he was getting reports for the same issue. He sent me his binaries for testing and sure enough they worked ;-).

I just got home from work lol.
 
Did my tests, they were not compiled properly. Working on it now. But I can confirm that by statically linking these binaries will make the zip work. Been in contact with osm0sis over on xda in regards with his binaries and he was getting reports for the same issue. He sent me his binaries for testing and sure enough they worked ;-).

I just got home from work lol.

Gotcha, understand
 
Gotcha, understand

Well, let me rephrase that lol. You compiled them correctly but not for android lol. Works on pc but not the phone. I forgot to mention that gcc should be referenced to your toolchain. No biggy though. Should have my binaries working soon.
 
Well, let me rephrase that lol. You compiled them correctly but not for android lol. Works on pc but not the phone. I forgot to mention that gcc should be referenced to your toolchain. No biggy though. Should have my binaries working soon.

I did a "export PATH=/path/to/arm-eabi-4.6/bin:$PATH" before building. Maybe I needed to build using "arm-eabi-gcc" instead of the host gcc
 
Im syncing the CM repos, going to give CM another crack now that we have a jellybean supported kernel, Framebuffer was my issue when i started working on CM back when we had 4.0.4
 
I did a "export PATH=/path/to/arm-eabi-4.6/bin:$PATH" before building. Maybe I needed to build using "arm-eabi-gcc" instead of the host gcc

Tada :-)

hy6atapu.jpg
 
I have CM 10.2 building as i type this so wish me luck on getting it booted

Can you push your device tree, vendors, etc, etc to your github so I can take a look :-).

Edit: or zip it up and send it my way ;-)

Obviously don't need CM LOL. I already have synced CM.
 
same device tree simonsimons has on his github. Figured i would start with that. A better starting point would probably be the ville (One S).

On a side note, will probably be developing for the Samsung Galaxy Victory as well, should be getting one soon :)
 
same device tree simonsimons has on his github. Figured i would start with that. A better starting point would probably be the ville (One S).

On a side note, will probably be developing for the Samsung Galaxy Victory as well, should be getting one soon :)

Grabbed his also. Had to do a lot of work to it though so I could work on TWRP.
 
Got my binaries officially statically compiled. Plus, my flash zip works flawlessly, BUT, I want to make the zip do more. Now to get back to my kernel :-).
 
This gives me a headache looking at it over and over and over....

PHP:
 #!/sbin/sh

# automatically cd to directory where this script is running
cd "$(dirname "$0")"
# /tmp/MyMind

# Set Variables here
ACTIVE_PROJECT="/tmp"
BOOT_PARTITION="/dev/block/mmcblk0p20"

# Lets report back to the recovery to allow users to know what is taking place using "ui_print"
COMMUNICATION() {
OUTFD="$("$ACTIVE_PROJECT/binaries/busybox" ps | "$ACTIVE_PROJECT/binaries/busybox" grep -v "grep" | "$ACTIVE_PROJECT/binaries/busybox" grep -o -E "updater(.*)" | "$ACTIVE_PROJECT/binaries/busybox" cut -d " " -f 3)";
}

ui_print() {
  if [ $OUTFD != "" ]; then
    echo "ui_print ${1} " 1>&$OUTFD;
    echo "ui_print " 1>&$OUTFD;
  else
    echo "${1}";
  fi;
}


# Boot.img uses a magic header of ANDROID! so, lets check for strange boot.img headers
SIGNATURE_CHECK() {
check_header=`"$ACTIVE_PROJECT/TEMP/binaries/busybox" od -A n -h -j 0 -N 8 "$ACTIVE_PROJECT/TEMP/boot.img" | sed 's/ //g'`

if [ "$check_header" != "4e415244494f2144" ]
then
ui_print " ";
ui_print "Android magic header not found at start of boot.img";
ui_print " ";
ui_print "Checking if it exists elsewhere ...";
# Look for Header
hex_offset=`$ACTIVE_PROJECT/TEMP/binaries/busybox od -x -A x $ACTIVE_PROJECT/TEMP/boot.img | grep -m 1 "4e41 [ ]*5244 [ ]*494f [ ]*2144" | sed -e 's/ .*//'`

if [ "$hex_offset" != "" ]
then
# Remove leading bytes before the Android header 
dec_offset=`printf "%d" 0x$hex_offset`
ui_print " ";
ui_print "Android header found at offset $dec_offset";
ui_print " ";
ui_print "Removing extra stuff before it so boot.img can be read properly ..."
dd if="$ACTIVE_PROJECT/TEMP/boot.img" of="$ACTIVE_PROJECT/TEMP/modboot.img" bs=1 skip=$dec_offset
rm -f "$ACTIVE_PROJECT/TEMP/boot.img"
cp "$ACTIVE_PROJECT/TEMP/modboot.img" "$ACTIVE_PROJECT/TEMP/boot.img"
rm -f "$ACTIVE_PROJECT/TEMP/modboot.img"
ui_print " ";
else
ui_print "Warning: Android header not found in boot.img (unsupported format)";
fi
fi
}

# Remember the output to rebuild the boot image
UNMKBOOTIMG_INFO() {
KERNEL_INFO=$(echo $KERNEL_INFO_RAW | grep mkbootimg)
KERNEL_BASE=$(echo $KERNEL_INFO  | cut -d " " -f 25)
KERNEL_PAGESIZE=$(echo $KERNEL_INFO | cut -d " " -f 27)
KERNEL_OFFSET=$(echo $KERNEL_INFO | cut -d " " -f 29)
RAMDISK_OFFSET=$(echo $KERNEL_INFO | cut -d " " -f 31)
SECOND_OFFSET=$(echo $KERNEL_INFO | cut -d " " -f 33)
TAGS_OFFSET=$(echo $KERNEL_INFO | cut -d " " -f 35)
KERNEL_CMDLINE=$(echo $KERNEL_INFO | cut -d " " -f 37-38)
RAMDISK_NAME=$(echo $KERNEL_INFO | cut -d " " -f 42) # Not in use
}

# Extracts the kernel
KERNEL_EXTRACT() {
if [[ ! -e "$ACTIVE_PROJECT/kernel" ]]; then
mkdir -p "$ACTIVE_PROJECT/TEMP"
mv "$ACTIVE_PROJECT/binaries/" "$ACTIVE_PROJECT/TEMP/"
if [[ -e "$ACTIVE_PROJECT/TEMP/binaries/mkbootimg" || -e "$ACTIVE_PROJECT/TEMP/binaries/unmkbootimg" || -e "$ACTIVE_PROJECT/TEMP/binaries/mkbootfs" ]]; then
cd "$ACTIVE_PROJECT/TEMP/binaries"
if [[ ! -e mkbootimg || ! -e unmkbootimg || ! -e mkbootfs ]]; then
ui_print "ERROR! Something went wrong! Binaries are missing!";
return 1
fi
cd "$(dirname "$0")"
dd if="$BOOT_PARTITION" of="$ACTIVE_PROJECT/TEMP/boot.img"
SIGNATURE_CHECK
cd "$ACTIVE_PROJECT/TEMP"
fi
if [[ -e "$ACTIVE_PROJECT/TEMP/boot.img" ]]; then
 KERNEL_INFO_RAW=$("$ACTIVE_PROJECT/TEMP/binaries/unmkbootimg" -i "$ACTIVE_PROJECT/TEMP/boot.img")
mkdir -p "$ACTIVE_PROJECT/TEMP/ramdisk"
if [[ -e "$ACTIVE_PROJECT/TEMP/ramdisk.cpio.gz" ]]; then
cd "$ACTIVE_PROJECT/TEMP/ramdisk"
ui_print " ";
ui_print "Unpacking the ramdisk ...";
"$ACTIVE_PROJECT/TEMP/binaries/busybox" gunzip -c ../ramdisk.cpio.gz | "$ACTIVE_PROJECT/TEMP/binaries/busybox" cpio -i
cd "$(dirname "$0")"
ui_print " ";
ui_print "Will now modify init.rc and give you init.d support!";
INITD
fi
else
ui_print "No kernel found!";
return 1
fi
fi
}

# Repacks the kernel from the previously extracted one
KERNEL_REPACK() {
if [[ -d "$ACTIVE_PROJECT/TEMP" ]]; then
if [[ -d "$ACTIVE_PROJECT/TEMP/ramdisk" ]]; then
cd "$ACTIVE_PROJECT/TEMP"
ui_print " ";
ui_print "Repacking the ramdisk now.";
"$ACTIVE_PROJECT/TEMP/binaries/mkbootfs" ./ramdisk | gzip > NEWramdisk.cpio.gz
cd "$(dirname "$0")"
UNMKBOOTIMG_INFO
"$ACTIVE_PROJECT/TEMP/binaries/mkbootimg"  --base $KERNEL_BASE \
--pagesize $KERNEL_PAGESIZE \
--kernel_offset $KERNEL_OFFSET \
--ramdisk_offset $RAMDISK_OFFSET \
--second_offset $SECOND_OFFSET \
--tags_offset $TAGS_OFFSET \
--cmdline "$KERNEL_CMDLINE" \
--kernel "$ACTIVE_PROJECT/prebuilt/zImage" \
--ramdisk "$ACTIVE_PROJECT/TEMP/NEWramdisk.cpio.gz" \
-o "$ACTIVE_PROJECT/newboot.img"
ui_print " ";
ui_print "Have completed building your modified boot.img!";
FLASH
else
ui_print "Error, no ramdisk found?!";
fi
KERNEL_ABORT
fi
}

# Aborts kernel repacking - performs cleaning
KERNEL_ABORT() {
rm -rf "$ACTIVE_PROJECT/TEMP"
rm -f "$ACTIVE_PROJECT/newboot.img"
}

# Adds kernel's Init.d
INITD() {
if [[ -e "$ACTIVE_PROJECT/TEMP/ramdisk/init.rc" ]]; then
sed -i -e '0,/class_start /s//start sysinit\n\n    class_start /' "$ACTIVE_PROJECT/TEMP/ramdisk/init.rc"
sed -i -e 's/service media /service sysinit \/system\/bin\/logwrapper \/system\/xbin\/busybox run-parts \/system\/etc\/init.d\n    disabled\n    oneshot\n\nservice media /' "$ACTIVE_PROJECT/TEMP/ramdisk/init.rc"
cd "$(dirname "$0")"
cd ..
   MOUNT
   INSTALL_RECOVERY
   SYSINT
   PERMISSIONS
   KERNEL_REPACK
else
ui_print "ERROR, missing needed contents from the ramdisk?!";
rm -rf "$ACTIVE_PROJECT/TEMP"
return 1
fi
}

# Mount /system as read and write. No need to remount as read only as this will be fixed automatically upon reboot.
MOUNT() {
busybox mount -o remount,rw -t auto /system
}

# Build and write to install-recovery.sh
INSTALL_RECOVERY() {
if [ -e /system/etc/install-recovery.sh ] 
then
busybox echo "# init.d support" >> /system/etc/install-recovery.sh
busybox echo "busybox run-parts /system/etc/init.d/" >> /system/etc/install-recovery.sh
busybox echo "" >> /system/etc/install-recovery.sh
busybox awk '!x[$0]++' /system/etc/install-recovery.sh > /tmp/install-recovery.sh
busybox cat /tmp/install-recovery.sh > /system/etc/install-recovery.sh
busybox echo "" >> /system/etc/install-recovery.sh
else
cat > /system/etc/install-recovery.sh
busybox echo "#!/system/bin/sh" >> /system/etc/install-recovery.sh
busybox echo "# init.d support" >> /system/etc/install-recovery.sh
busybox echo "busybox run-parts /system/etc/init.d/" >> /system/etc/install-recovery.sh
busybox echo "" >> /system/etc/install-recovery.sh
fi
}

# Build and write to systint
SYSINT() {
if [ -e /system/bin/sysint ]
then
busybox echo "#!/system/bin/sh" >> /system/bin/sysint
busybox echo "# init.d support" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
busybox echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/sysint
busybox echo "/system/bin/logwrapper run-parts /system/etc/init.d" >> /system/bin/sysint 
busybox echo "" >> /system/bin/sysint
busybox awk '!x[$0]++' /system/bin/sysint > /tmp/sysint
busybox cat /tmp/sysint > /system/bin/sysint
busybox echo "" >> /system/bin/sysint
else
busybox echo "#!/system/bin/sh" > /system/bin/sysint
busybox echo "# init.d support" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
busybox echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/sysint
busybox echo "/system/bin/logwrapper run-parts /system/etc/init.d" >> /system/bin/sysint 
busybox echo "" >> /system/bin/sysint
fi
}

# Set permissions accordingly
PERMISSIONS() {
busybox chmod 755 /system/etc/install-recovery.sh
busybox chown 0.0 /system/etc/install-recovery.sh
busybox chmod 755 /system/bin/sysint
busybox chown 0.2000 /system/bin/sysint
}

# Install modified boot.img
FLASH() {
if [[ -e "$ACTIVE_PROJECT/newboot.img" ]]; then
dd if=$ACTIVE_PROJECT/newboot.img of=$BOOT_PARTITION
ui_print " ";
ui_print "Your new Boot Image is installed with added init.d support!";
else
ui_print " ";
ui_print "Your new boot image is missing in action!";
ui_print "CANNOT flash your new boot image!";
fi
}

# Start the process here
COMMUNICATION
KERNEL_EXTRACT
exit 0
 
My kernel works thus far. Will eventually revert everything on my master branch. Don't follow those commits lol, I was checking some things out from another individual because things were looking very shady but I plan to fix my repo by merging my other branch over to master.

Currently working on my source to allow building of the kernel without module support so this way the kernel will pretty much use the current modules already on your device thus eliminating possible breaks such as WiFi in the future (which is normally caused by different version builds between the kernel and modules).

Just makes it much more easier on EVERYBODY lol.

Unfortunately, I have to debug every build I make until it's complete for this task. Disabling module support causes confliction with other parts of the source so I must handle them one error at a time until finalized. Working on that now.
 
same device tree simonsimons has on his github. Figured i would start with that. A better starting point would probably be the ville (One S).

On a side note, will probably be developing for the Samsung Galaxy Victory as well, should be getting one soon :)

Hey bro, how is CM coming along? I'm sure it's been a headache lol.
 
Kernel source will now allow me to build without module support.

To make this more clearer for those who don't understand it... This basically means that whenever I build my kernel I am not required to build the external modules as well for such things as your working WiFi and such.

Instead the kernel will now accept and use your devices stock modules which will help to prevent WiFi breaks, BT breaks and so forth.

This is very useful, because on average when building a kernel the new modules are normally required to replace the old modules to insure everything works properly, but I have eliminated this need :-).

Hopefully, what I just said made sense to you guys :-P
 
Hey guys, I fixed up my repo regarding my kernel source. Did a hard reset back to a specific commit. Anyways, the source can easily be built from just about anyone at this moment.

All that is required for you to do is download the source to your pc and run the buildme.sh file from within the root of the source directory.

Just make sure you set the toolchain path, kernel path, strip path, and your output path from within the buildme.sh script. They are based on my system. Otherwise, it will build and once done you will find a zip within the /output directory ready to be flashed from your custom recovery using MyMinds Kernel Swap.

https://github.com/ModdingMyMind/android_kernel_htc_k2_cl_twrp

It isn't much. Really so far, the kernel source has Selinux support, complete removal of write protection, and module support disabled.

Now that I am a lot more situated I should be able to tackle it some more (just been wrapped up over here lol).
 
Back
Top Bottom