[Android Software/Hacking General [Developers Only]] yuweng:
Trouble-shooting

Trouble-shooting the mount USB storage

Huge credits to suhas.holla, the fstab v2 AKA unified fstab has been demystified for MTK devices & mount both sdcard at PhilZ Touch is working perfecty now. . . :laugh:

i don't own every MediaTek devices out there so most probably some will not mount USB storage for both of the storage while at recovery b'cos of different voldmanaged path.

Updates

- Built-in to porting tool

Refer to below on how to identify it & correct this problem.

Open a new Notepad & save the below to MTK_PhilZ folder for unpack/ repack of ported PhilZ Touch recovery.img.

MTK_unpack.bat

@echo off
cd %~dp0
chcp 1251
if (%1)==() (
echo Select image
goto end
)

setlocal enabledelayedexpansion
COLOR 0A
mode con:cols=65 lines=31
bin\sfk166.exe hexfind %1 -pat -bin /88168858/ -case >bin\offset.txt
bin\sfk166.exe hexfind %1 -pat -bin /FFFFFFFF1F8B08/ -case >>bin\offset.txt
bin\sfk166.exe find bin\offset.txt -pat offset>bin\off2.txt
bin\sfk166.exe replace bin\off2.txt -binary /20/0A/ -yes

if exist %~N1 rd /s /q %~N1 >nul

set /A N=0
:loop
FOR /F %%G IN (bin\off2.txt) DO (
if !N!==1 (
set /A ofs1=%%G
set /A N+=1
)
if !N!==3 (
set /A ofs2=%%G
set /A N+=1
)
if !N!==5 (
set /A ofs3=%%G+4
set /A N+=1
)
if `%%G` EQU `offset` (
set /A N+=1
)
)
FOR %%i IN (%1) DO ( set /A boot_size=%%~Zi )
echo.
echo - size of %1 %boot_size% byte
echo - kernel offset - %ofs1%
echo - ram_header offset - %ofs2%
echo - ram_disk offset - %ofs3%
echo.

del bin\offset.txt
del bin\off2.txt
md %~N1
echo - extracting kernel_header...
bin\sfk166.exe partcopy %1 -fromto 0x0 %ofs1% %~N1\kernel_header -yes
echo - extracting kernel...
bin\sfk166.exe partcopy %1 -fromto %ofs1% %ofs2% %~N1\kernel -yes
echo - extracting ram_header...
bin\sfk166.exe partcopy %1 -fromto %ofs2% %ofs3% %~N1\ram_header -yes
echo - extracting ram_disk...
bin\sfk166.exe partcopy %1 -fromto %ofs3% %boot_size% %~N1\ram_disk.gz -yes

echo - unpack ram_disk.gz...

bin\7za.exe -tgzip x -y %~N1\ram_disk.gz -o%~N1 >nul
echo - unpack ram_disk.cpio...

md %~N1\rmdisk
cd %~N1
cd rmdisk
%~dp0bin\cpio.exe -i <../ram_disk
cd ..
cd ..

copy %1 %~N1
echo.
echo - Done ^^!
echo.
pause
:end

MTK_pack.bat

@echo off
cd %~dp0
chcp 1251
if (%1)==() (
echo Select folder
goto end
)
setlocal enabledelayedexpansion
COLOR 0A
mode con:cols=60 lines=39
set pt=%~N1%~X1
echo %pt%
copy %pt%\ram_header %~N1\new_ram_with_header >nul
cd %pt%
%~dp0bin\chmod og=xr rmdisk
cd rmdisk

echo - pack rmdisk to cpio...
%~dp0bin\find . | %~dp0bin\cpio.exe -o -H newc -F ../new_ram_disk.cpio >nul
move ..\ram_disk ..\ram_disk_old >nul
copy ..\new_ram_disk.cpio ..\ram_disk
echo - pack rmdisk to gzip...
%~dp0bin\gzip -n -f ../ram_disk
echo - add header...
%~dp0bin\dd if=../ram_disk.gz >> ../new_ram_with_header
FOR %%i IN (../ram_disk.gz) DO ( set /A size=%%~Zi )
echo - new ramdisk %size% byte
%~dp0bin\sfk166 hex %size% -digits=8 >../../size.txt
FOR %%i IN (../../size.txt) DO ( set /A size=%%~Zi )
%~dp0bin\sfk166 split 1 ../../size.txt ../../1 >nul
FOR /F %%i IN (../../1.part7) DO (set a1=%%i)
FOR /F %%i IN (../../1.part8) DO (set a2=%%i)

FOR /F %%i IN (../../1.part5) DO (set a3=%%i)
FOR /F %%i IN (../../1.part6) DO (set a4=%%i)

FOR /F %%i IN (../../1.part3) DO (set a5=%%i)
FOR /F %%i IN (../../1.part4) DO (set a6=%%i)

FOR /F %%i IN (../../1.part1) DO (set a7=%%i)
FOR /F %%i IN (../../1.part2) DO (set a8=%%i)
echo %a7%%a8%>size.txt
echo %a5%%a6%>>size.txt
echo %a3%%a4%>>size.txt
echo %a1%%a2%>>size.txt
echo - add new size in header 0x%a1%%a2% 0x%a3%%a4% 0x%a5%%a6% 0x%a7%%a8%
%~dp0bin\sfk166.exe echo %a1%%a2% %a3%%a4% %a5%%a6% %a7%%a8% +hextobin ../../tmp1.dat
%~dp0bin\sfk166.exe partcopy ../../tmp1.dat 0 4 ../new_ram_with_header 4 -yes>nul

echo - make image...
%~dp0bin\mkbootimg.exe --kernel ../kernel --ramdisk ../new_ram_with_header -o ../new_image.img
del size.txt >nul
copy ..\new_image.img %~dp0\new_image.img
move ..\ram_disk_old ..\ram_disk >nul
cd ..
cd ..
del size.txt >nul
del tmp1.dat>nul
del 1.part*>nul

echo.
echo - Done ^^!
echo.
pause
:end

Just Drag&Drop ported PhilZ Touch recovery.img to MTK_unpack.bat to unpack it & Drag&Drop unpack recovery folder to MTK_pack.bat to repack it back. Disable UAC first.

Or you can also download the original Boot/Recovery repack utils for WINDOWS to unpack/ repack the ported PhilZ Touch recovery. Basically it operates exactly the same except for this porting tool, it is using the standalone 7za.exe instead of 7z.exe that requires the 7z.dll to operate.

Huge Credits to Russian Master Shifu Michfood for sharing his unpack/ repack MTK boot/ recovery algorithm or this porting tool would not have exists & you will have do all this on a NIX box . . . :laugh:

recovery.fstab for MT65xx

# Android fstab file.
# 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

#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/dev/bootimg /bootimg emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
/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

# For MT6577
/devices/platform/mtk-sd.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:[COLOR="blue"][B][SIZE="4"]6[/SIZE][/B][/COLOR]
/devices/platform/mtk-sd.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto

# For MT65[B]xx[/B]
[COLOR="Blue"]/devices/platform/mtk-msdc.0/mmc_host/mmc0[/COLOR] auto auto defaults voldmanaged=sdcard0:[COLOR="blue"][B][SIZE="4"]6[/SIZE][/B][/COLOR]
[COLOR="blue"]/devices/platform/mtk-msdc.1/mmc_host/mmc1[/COLOR] auto auto defaults voldmanaged=sdcard1:auto

To identify your MTK voldmanaged path for sdcard -> adb shell find /sys -name mmc0. You don't need to include the first path /sys so it should start with /devices

To identify your internal sdcard partition no. -> adb shell cat /proc/dumchar_info & look at fat partition block /dev/block/mmcblk0p6 & update it accordingly . . .

Update it to fstab.${ro.hardware} too.

The correct way to check ${ro.hardware} -> adb shell getprop ro.hardware -> mt6577 then it should be rename to fstab.mt6577

------------------------------------------------

Updates

- Built-in to porting tool

Some MTK don't use fat mount points for Internal sdcard then this tool will fail to identify it & ported PhilZ Touch will not boot/ bootloop . . . :cowboy:

/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0: [COLOR="Red"]<- Empty[/COLOR]
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto

Solution - Put a # at the beginning of that line or just delete it & it'll boot . . .

[B][SIZE="3"][COLOR="Blue"]#[/COLOR][/SIZE][/B]/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0: [COLOR="Red"]<- Empty[/COLOR]
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto

------------------------------------------------

To identify USB voldmanaged mount points for Internal SD -> adb shell su -c "ls -R" > c:\users\YOUR USER NAME\desktop\usb.txt

Look for anything usb in it & try it at the fstab.${ro.hardware} & also update it to recovery.fstab too. Both must be identical or it will not work.

An example below, confirmed by shoxxy that can be view at PhilZ Touch -> Install Zip but doesn't mount it at mount USB storage.

/devices/platform/mt_usb/usb1 auto auto defaults voldmanaged=usbdisk:auto

Also look for various example here on voldmanaged for USB storage & hopefully someone will get it working one day.

if yours is a /data/media device then it would not work . . .

Refer to here credits to RD chrmhoffmann

As mentioned many times, i don't own all MTK devices out there so some features might not work. To fix it & to learn more about modding recovery refer to my Master Shifu thread here & here . . . :good:

When everything fails then try your hands on building one yourself with the optional build flags here for your MTK . . . :cool: