[Miscellaneous Android Development] :
Modify required ramdisk files -Jellybean.

At this point there are some differences between jellybean and kitkat versions.

For jellybean the files are: recovery.fstab in etc folder, default.prop, fstab and init.rc.

For kitkat, they are named the same except the fstab is named fstab.mt65xx (according to your phone platform), but the content is different. So for kitkat first rename fstab.mt6582 to fstab.mt65nn, where mt65nn is your phone platform (ex. mt6592).

Jellybean:

Open editor, then open in one window dumchar_info.txt (the one you've got earlier), the fstab file, init.usb.rc from boot ramdisk and default.prop from recovery ramdisk, and in another window recovery.fstab from carliv's ramdisk/etc folder, fstab, default.prop and init.rc also from carliv's ramdisk.

Focus on dumchar_info at one side and recovery.fstab on the other side.

Part_Name	Size	StartAddr	Type	MapTo
preloader 0x0000000000600000 0x0000000000000000 2 /dev/misc-sd
mbr 0x0000000000080000 0x0000000000000000 2 /dev/block/mmcblk0
ebr1 0x0000000000080000 0x0000000000080000 2 /dev/block/mmcblk0p1
pmt 0x0000000000400000 0x0000000000100000 2 /dev/block/mmcblk0
pro_info 0x0000000000300000 0x0000000000500000 2 /dev/block/mmcblk0
nvram 0x0000000000500000 0x0000000000800000 2 /dev/block/mmcblk0
protect_f 0x0000000000a00000 0x0000000000d00000 2 /dev/block/mmcblk0p2
protect_s 0x0000000000a00000 0x0000000001700000 2 /dev/block/mmcblk0p3
seccfg 0x0000000000020000 0x0000000002100000 2 /dev/block/mmcblk0
uboot 0x0000000000060000 0x0000000002120000 2 /dev/block/mmcblk0
bootimg 0x0000000000600000 0x0000000002180000 2 /dev/block/mmcblk0
recovery 0x0000000000600000 0x0000000002780000 2 /dev/block/mmcblk0
sec_ro 0x0000000000600000 0x0000000002d80000 2 /dev/block/mmcblk0p4
misc 0x0000000000080000 0x0000000003380000 2 /dev/block/mmcblk0
logo 0x0000000000300000 0x0000000003400000 2 /dev/block/mmcblk0
ebr2 0x0000000000080000 0x0000000003700000 2 /dev/block/mmcblk0
expdb 0x0000000000a00000 0x0000000003780000 2 /dev/block/mmcblk0
android 0x0000000038000000 0x0000000004180000 2 /dev/block/mmcblk0p[COLOR="Red"]5[/COLOR]
cache 0x0000000007e00000 0x000000003c180000 2 /dev/block/mmcblk0p[COLOR="Red"]6[/COLOR]
usrdata 0x0000000060000000 0x0000000043f80000 2 /dev/block/mmcblk0p[COLOR="Red"]7[/COLOR]
fat 0x0000000041b80000 0x00000000a3f80000 2 /dev/block/mmcblk0p[COLOR="Red"]8[/COLOR]
bmtpool 0x0000000001500000 0x00000000ff9f00a8 2 /dev/block/mmcblk0

# mount point	fstype device	[device2]

[COLOR="Blue"]/boot	emmc	/dev/bootimg
/misc	emmc	/dev/misc
/nvram	emmc	/dev/nvram
/recovery	emmc	/dev/recovery
/uboot	emmc	/dev/uboot[/COLOR]
/system	ext4	/dev/block/mmcblk0p[COLOR="Red"]5[/COLOR]
/cache	ext4	/dev/block/mmcblk0p[COLOR="Red"]6[/COLOR]
/data	ext4	/dev/block/mmcblk0p[COLOR="Red"]7[/COLOR]
/emmc	vfat	/dev/block/mmcblk0p[COLOR="Red"]8[/COLOR]
/sdcard	vfat	/dev/block/mmcblk1p1	/dev/block/mmcblk1

Check the paths for partitions and correct them as in dumchar file. Note that in dumchar /system is "android" and /data is "usrdata". Also, in CWM from cm 10.1, the internal sdcard is "/emmc" or "/sdcard". Use "sdcard" if you have only internal sdcard on your phone, or if you want to use the internal sdcard as main sdcard (and in this case, name the external sdcard as "/external_sd"). If the phone is emmc type and has block type memory (dev/block/mmcblkxpx), you don't need to modify the paths for boot, recovery, nvram, misc or other emmc partition. If the phone is with an extra partition (custpack), you have to check few more entries on recovery.fstab.

Part_Name Size StartAddr T MapTo
preloader 0x0000000000040000 0x0000000000000000 2 /dev/misc-sd
dsp_bl 0x0000000000ec0000 0x0000000000040000 2 /dev/misc-sd
mbr 0x0000000000004000 0x0000000000000000 2 /dev/block/mmcblk0
ebr1 0x0000000000004000 0x0000000000004000 2 /dev/block/mmcblk0p1
ebr2 0x0000000000004000 0x0000000000008000 2 /dev/block/mmcblk0
pmt 0x0000000000400000 0x000000000000c000 2 /dev/block/mmcblk0
nvram 0x0000000000300000 0x000000000040c000 2 /dev/block/mmcblk0
seccfg 0x0000000000020000 0x000000000070c000 2 /dev/block/mmcblk0
uboot 0x0000000000060000 0x000000000072c000 2 /dev/block/mmcblk0
bootimg 0x0000000000600000 0x000000000078c000 2 /dev/block/mmcblk0
recovery 0x0000000000600000 0x0000000000d8c000 2 /dev/block/mmcblk0
sec_ro 0x0000000000600000 0x000000000138c000 2 /dev/block/mmcblk0p2
misc 0x0000000000060000 0x000000000198c000 2 /dev/block/mmcblk0
logo 0x0000000000300000 0x00000000019ec000 2 /dev/block/mmcblk0
expdb 0x00000000000f4000 0x0000000001cec000 2 /dev/block/mmcblk0
pro_info 0x0000000000080000 0x0000000001de0000 2 /dev/block/mmcblk0
[COLOR="Red"]custpack [/COLOR] 0x0000000019d00000 0x0000000001e60000 2 /dev/block/mmcblk0p[COLOR="Red"]3[/COLOR]
mobile_info 0x0000000000800000 0x000000001bb60000 2 /dev/block/mmcblk0p[COLOR="Red"]4[/COLOR]
android 0x0000000019d00000 0x000000001c360000 2 /dev/block/mmcblk0p[COLOR="Red"]5[/COLOR]
cache 0x0000000013900000 0x0000000036060000 2 /dev/block/mmcblk0p[COLOR="Red"]6[/COLOR]
usrdata 0x0000000059200000 0x0000000049960000 2 /dev/block/mmcblk0p[COLOR="Red"]7[/COLOR]
fat 0x000000005c590200 0x00000000a2b60000 2 /dev/block/mmcblk0p[COLOR="Red"]8[/COLOR]
otp 0xffffffffe87efe00 0x00000000ff0f0200 2 /dev/block/mmcblk0
bmtpool 0x0000000001500000 0x00000000ff0f00a8 2 /dev/block/mmcblk0

# mount point	fstype	device	[device2]
[COLOR="Blue"]/boot emmc	/dev/bootimg
/misc	emmc	/dev/misc
/recovery	emmc	/dev/recovery
/nvram	emmc	/dev/nvram
/uboot	emmc	/dev/uboot[/COLOR]
/system	ext4	/dev/block/mmcblk0p[COLOR="Red"]5[/COLOR]
/data	ext4	/dev/block/mmcblk0p[COLOR="Red"]7[/COLOR]
/cache	ext4 /dev/block/mmcblk0p[COLOR="Red"]6[/COLOR]
/custpack ext4 /dev/block/mmcblk0p[COLOR="Red"]3[/COLOR]
/mobile_info ext4 /dev/block/mmcblk0p[COLOR="Red"]4[/COLOR]
/emmc vfat	/dev/block/mmcblk0p[COLOR="Red"]8[/COLOR]
/sdcard	vfat	/dev/block/mmcblk1p1 /dev/block/mmcblk1

For "custpack" phones the recovery.fstab from porting builds is wrong (sent by someone before), and you have to make it to look like this one above.

If the phone has Ubifs file system, the memory is flash type (dev/mtd/mtdx), and in dumchar_info you will find separate paths for every partition: you have to check every one's number and correct if is different (even for boot, recovery, etc).

preloader 0x0000000001000000 0x00000000 1 /dev/mtd/mtd0 USER
pro_info 0x0000000000400000 0x00000001 1 /dev/mtd/mtd1 USER
nvram 0x0000000000c00000 0x00000002 1 /dev/mtd/mtd2 USER
protect_f 0x0000000000c00000 0x00000003 1 /dev/mtd/mtd3 USER
seccfg 0x0000000000400000 0x00000004 1 /dev/mtd/mtd4 USER
uboot 0x0000000000400000 0x00000005 1 /dev/mtd/mtd5 USER
bootimg 0x0000000000800000 0x00000006 1 /dev/mtd/mtd6 USER
recovery 0x0000000000800000 0x00000007 1 /dev/mtd/mtd7 USER
sec_ro 0x0000000000400000 0x00000008 1 /dev/mtd/mtd8 USER
misc 0x0000000000c00000 0x00000009 1 /dev/mtd/mtd9 USER
logo 0x0000000000400000 0x0000000a 1 /dev/mtd/mtd10 USER
expdb 0x0000000000c00000 0x0000000b 1 /dev/mtd/mtd11 USER
tee1 0x0000000000800000 0x0000000c 1 /dev/mtd/mtd12 USER
tee2 0x0000000000800000 0x0000000d 1 /dev/mtd/mtd13 USER
kb 0x0000000000400000 0x0000000e 1 /dev/mtd/mtd14 USER
dkb 0x0000000000400000 0x0000000f 1 /dev/mtd/mtd15 USER
android 0x000000001f400000 0x00000010 1 /dev/mtd/mtd16 USER
cache 0x0000000008000000 0x00000011 1 /dev/mtd/mtd17 USER
usrdata 0x00000001bf000000 0x00000012 1 /dev/mtd/mtd18 USER
bmtpool 0x0000000000000000 0x00000000 1 USER

# mount point	fstype	device	[device2]

/boot	mtd	/dev/mtd/mtd6
/misc	mtd	/dev/mtd/mtd9
/nvram	mtd	/dev/mtd/mtd2
/recovery	mtd	/dev/mtd/mtd7
/uboot	mtd	/dev/mtd/mtd5
/system	ubifs	/dev/mtd/mtd16
/cache	ubifs	/dev/mtd/mtd17
/data	ubifs	/dev/mtd/mtd18
/emmc vfat	/dev/block/mmcblk0p1	/dev/block/mmcblk0
/sdcard	vfat	/dev/block/mmcblk1p1 /dev/block/mmcblk1

Next focus on both fstab, from boot and carliv ramdisk. Replace the content of carliv fstab with the content of boot fstab. Usualy it looks like this:

# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK

/emmc@android /system ext4 ro,noatime wait
/emmc@cache /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
/emmc@usrdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer

Then focus on default.prop from recovery stock and carliv. Change in carliv default prop all relevant data regarding your phone, platform and producer or brand (this is for assert errors). See lines in blue - need to focus on those, and values in red - need to be replaced. First default.prop is from stock recovery, second is from porting carliv recovery. Replace from stock to carliv (for example instead of "new" will be "P780", instead of "mtk" will be "Lenovo" and so on.

Stock:

#
# ADDITIONAL_DEFAULT_PROPERTIES
#
ro.secure=0
ro.allow.mock.location=1
persist.mtk.aee.aed=on
ro.debuggable=1
persist.service.acm.enable=0
persist.sys.usb.config=mass_storage,adb
ro.bootloader.mode=download
ro.mount.fs=EXT4
# begin build properties
# autogenerated by buildinfo.sh
ro.build.id=JOP40D
ro.build.display.id=P780_S129_130710
[COLOR="Blue"]ro.product.model[/COLOR]=[COLOR="Red"]Lenovo P780[/COLOR]
ro.product.sw.internal.version=Lenovo P780_S129_130710
ro.product.hw.version=9001
ro.product.particular.version=LENOVO_FUJIAN
ro.build.version.incremental=P780_S129_130710
ro.custom.build.version=1373441469
ro.build.version.sdk=17
ro.build.version.codename=REL
ro.build.version.release=4.2.1
ro.build.date=Fri Jul 4 13:51:39 EEST 2014
ro.build.date.utc=1373441534
ro.build.type=user
ro.build.user=carliv
ro.build.host=max
ro.build.tags=release-keys
[COLOR="Blue"]ro.product.brand[/COLOR]=[COLOR="Red"]Lenovo[/COLOR]
[COLOR="Blue"]ro.product.name[/COLOR]=[COLOR="Red"]P780[/COLOR]
[COLOR="Blue"]ro.product.device[/COLOR]=[COLOR="Red"]prada[/COLOR]
[COLOR="Blue"]ro.product.board[/COLOR]=[COLOR="Red"]prada[/COLOR]
ro.product.cpu.abi=armeabi-v7a
ro.product.cpu.abi2=armeabi
[COLOR="Blue"]ro.product.manufacturer[/COLOR]=[COLOR="Red"]LENOVO[/COLOR]
ro.product.locale.language=en
ro.product.locale.region=US
ro.wifi.channels=
[COLOR="Blue"]ro.board.platform[/COLOR]=
# ro.build.product is obsolete; use ro.product.device
[COLOR="Blue"]ro.build.product[/COLOR]=[COLOR="Red"]P780[/COLOR]
# Do not try to parse ro.build.description or .fingerprint
ro.build.description=[COLOR="Red"]P780[/COLOR]-user 4.2.1 JOP40D [COLOR="Red"]P780[/COLOR]_S129_130710 release-keys
ro.build.fingerprint=[COLOR="Red"]Lenovo[/COLOR]/[COLOR="Red"]P780[/COLOR]/[COLOR="Red"]P780[/COLOR]:4.2.1/JOP40D/P780_S129_130710:user/release-keys
ro.build.flavor=
ro.build.characteristics=default
# end build properties

# begin mediatek build properties
ro.mediatek.version.release=ALPS.JB2.MP.V1
ro.mediatek.platform=MT6589
ro.mediatek.chip_ver=S01
ro.mediatek.version.branch=ALPS.JB2.MP
ro.mediatek.version.sdk=1
# end mediatek build properties
#
# system.prop for generic sdk
#

and Carliv:

#
# ADDITIONAL_DEFAULT_PROPERTIES
#
ro.secure=0
ro.allow.mock.location=1
persist.mtk.aee.aed=on
ro.debuggable=1
persist.service.acm.enable=0
persist.sys.usb.config=mass_storage,adb
ro.bootloader.mode=download
ro.mount.fs=EXT4
# begin build properties
# autogenerated by buildinfo.sh
ro.build.id=JDQ39E
ro.build.display.id=cm_[COLOR="Red"]new[/COLOR]-eng 4.2.2 JDQ39E 4c1705071f test-keys
ro.build.version.incremental=4c1705071f
ro.build.version.sdk=17
ro.build.version.codename=REL
ro.build.version.release=4.2.2
ro.build.date=Sat Dec 6 21:02:58 EET 2014
ro.build.date.utc=0
ro.build.type=eng
ro.build.user=carliv
ro.build.host=max
ro.build.tags=test-keys
[COLOR="Blue"]ro.product.model[/COLOR]=[COLOR="Red"]new[/COLOR]
[COLOR="Blue"]ro.product.brand[/COLOR]=[COLOR="Red"]mtk[/COLOR]
[COLOR="Blue"]ro.product.name[/COLOR]=cm_[COLOR="Red"]new[/COLOR]
[COLOR="Blue"]ro.product.device[/COLOR]=[COLOR="Red"]new[/COLOR]
[COLOR="Blue"]ro.product.board[/COLOR]=
ro.product.cpu.abi=armeabi-v7a
ro.product.cpu.abi2=armeabi
[COLOR="Blue"]ro.product.manufacturer[/COLOR]=[COLOR="Red"]mtk[/COLOR]
ro.product.locale.language=en
ro.product.locale.region=US
ro.wifi.channels=
[COLOR="Blue"]ro.board.platform[/COLOR]=[COLOR="Red"]mt6582[/COLOR]
# ro.build.product is obsolete; use ro.product.device
[COLOR="Blue"]ro.build.product[/COLOR]=[COLOR="Red"]new[/COLOR]
# Do not try to parse ro.build.description or .fingerprint
ro.build.description=cm_[COLOR="Red"]new[/COLOR]-eng 4.2.2 JDQ39E 4c1705071f test-keys
ro.build.fingerprint=[COLOR="Red"]mtk[/COLOR]/cm_[COLOR="Red"]new[/COLOR]/[COLOR="Red"]new[/COLOR]:4.2.2/JDQ39E/4c1705071f:eng/test-keys
ro.build.characteristics=default
[COLOR="Blue"]ro.cm.device[/COLOR]=[COLOR="Red"]new[/COLOR]
# end build properties
#
# system.prop for new
#

#
# ADDITIONAL_BUILD_PROPERTIES
#
ro.rommanager.developerid=cyanogenmod
keyguard.no_require_sim=true
ro.url.legal=http://www.google.com/intl/%s/mobile/android/basic/phone-legal.html
ro.url.legal.android_privacy=http://www.google.com/intl/%s/mobile/android/basic/privacy.html
ro.com.google.clientidbase=android-google
ro.com.android.wifi-watchlist=GoogleGuest
ro.setupwizard.enterprise_mode=1
ro.com.android.dateformat=MM-dd-yyyy
ro.com.android.dataroaming=false
persist.sys.root_access=1
ro.cm.version=10.1-20141206-UNOFFICIAL-[COLOR="Red"]new[/COLOR]
ro.modversion=10.1-20141206-UNOFFICIAL-[COLOR="Red"]new[/COLOR]
ro.config.ringtone=Orion.ogg
ro.config.notification_sound=Argon.ogg
ro.config.alarm_alert=Hassium.ogg
ro.carrier=unknown
ro.ril.hsxpa=1
ro.ril.gprsclass=10
ro.adb.qemud=1
ro.kernel.android.checkjni=1
net.bt.name=Android
dalvik.vm.stack-trace-file=/data/anr/traces.txt

Last step, focus on init.rc from carliv and init.usb.rc from boot. Check idVendor and idProduct for mass_storage,adb function. Replace them with data from init.usb.rc.

on init
# Workarunod for USB unknow device issue
# USB would switch correct function when set properity sys.usb.config
setprop sys.usb.vid [COLOR="Red"]17EF[/COLOR]
write /sys/class/android_usb/android0/iSerial $ro.serialno
write /sys/class/android_usb/android0/[COLOR="Blue"]idVendor[/COLOR] $sys.usb.vid
.............
#2.[COLOR="Blue"]adb[/COLOR]
on property:sys.usb.config=adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor $sys.usb.vid
write /sys/class/android_usb/android0/[COLOR="Blue"]idProduct[/COLOR] [COLOR="Red"]7495[/COLOR]
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config
........
#5.[COLOR="Blue"]mass_storage,adb[/COLOR]
on property:sys.usb.config=mass_storage,adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/[COLOR="Blue"]idVendor[/COLOR] $sys.usb.vid
write /sys/class/android_usb/android0/[COLOR="Blue"]idProduct[/COLOR] [COLOR="Red"]7435[/COLOR]
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config

#6.mtp

on early-init
start ueventd

on init
export PATH /sbin
export ANDROID_ROOT /system
export ANDROID_DATA /data
export EXTERNAL_STORAGE /sdcard

symlink /system/etc /etc

mkdir /boot
mkdir /misc
mkdir /storage
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
mkdir /datadata
mkdir /emmc
mkdir /system
mkdir /data
mkdir /cache
mount /tmp /tmp tmpfs

chown root shell /tmp
chmod 0775 /tmp

write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/iSerial "0123456789ABCDEF"
write /sys/class/android_usb/android0/[COLOR="Blue"]idVendor[/COLOR] [COLOR="Red"]0bb4[/COLOR] <- [COLOR="Red"]17EF[/COLOR]
write /sys/class/android_usb/android0/[COLOR="Blue"]idProduct[/COLOR] [COLOR="Red"]0c03[/COLOR] <- [COLOR="Red"]7435[/COLOR]
write /sys/class/android_usb/android0/functions mass_storage,adb
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/enable 1

on boot

ifup lo
hostname localhost
domainname localdomain

class_start default

on property:sys.powerctl=*
powerctl ${sys.powerctl}

service ueventd /sbin/ueventd
critical

service recovery /sbin/recovery

service setup_adbd /sbin/setup_adbd
oneshot

service adbd /sbin/adbd recovery
disabled

# Recovery will start adb once it has checked the keys

on property:ro.debuggable=1
#write /sys/class/android_usb/android0/enable 1
#start adbd
setprop service.adb.root 1

# Restart adbd so it can run as root
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1