[Galaxy Ace S5830 Android Development] ketut.kumajaya:
fix-system.sh script, not perfect but work :D

#!/bin/sh

rm -f bin/cat
rm -f bin/chmod
rm -f bin/chown
rm -f bin/cmp
rm -f bin/date
rm -f bin/dd
rm -f bin/df
rm -f bin/dmesg
rm -f bin/getevent
rm -f bin/getprop
rm -f bin/hd
rm -f bin/id
rm -f bin/ifconfig
rm -f bin/iftop
rm -f bin/insmod
rm -f bin/ioctl
rm -f bin/ionice
rm -f bin/kill
rm -f bin/ln
rm -f bin/log
rm -f bin/ls
rm -f bin/lsmod
rm -f bin/lsof
rm -f bin/mkdir
rm -f bin/mount
rm -f bin/mv
rm -f bin/nandread
rm -f bin/netstat
rm -f bin/newfs_msdos
rm -f bin/notify
rm -f bin/printenv
rm -f bin/ps
rm -f bin/reboot
rm -f bin/renice
rm -f bin/rm
rm -f bin/rmdir
rm -f bin/rmmod
rm -f bin/route
rm -f bin/schedtop
rm -f bin/sendevent
rm -f bin/setconsole
rm -f bin/setprop
rm -f bin/sleep
rm -f bin/smd
rm -f bin/start
rm -f bin/stop
rm -f bin/sync
rm -f bin/top
rm -f bin/umount
rm -f bin/uptime
rm -f bin/vmstat
rm -f bin/watchprops
rm -f bin/wipe
rm -f bin/dumpmesg

mkdir -p etc/init.d
mkdir -p sd

chown -R 0:0 .
for i in $( find . ); do
if [ -d $i ]; then
chmod 755 $i
else
chmod 644 $i
fi
done

chown -R 0:0 etc/init.d
chmod -R 777 etc/init.d

chown -R 0:2000 bin
chmod -R 755 bin

chown 0:3003 bin/ip
chmod 6755 bin/ip

chown 0:3003 bin/netcfg
chmod 2750 bin/netcfg

chown 0:3004 bin/ping
chmod 2755 bin/ping

chown 0:2000 bin/run-as
chmod 6750 bin/run-as

chown -R 1002:1002 etc/bluetooth
chmod -R 440 etc/bluetooth
chown 0:0 etc/bluetooth
chmod 755 etc/bluetooth

chown 1000:1000 etc/bluetooth/auto_pairing.conf
chmod 640 etc/bluetooth/auto_pairing.conf

chown 3002:3002 etc/bluetooth/blacklist.conf
chmod 444 etc/bluetooth/blacklist.conf

chown 1002:1002 etc/dbus.conf
chmod 440 etc/dbus.conf

chown 1014:2000 etc/dhcpcd/dhcpcd-run-hooks
chmod 550 etc/dhcpcd/dhcpcd-run-hooks

chown 0:2000 etc/init.goldfish.sh
chmod 550 etc/init.goldfish.sh

chown -R 0:0 etc/ppp
chmod -R 555 etc/ppp
chmod 0755 etc/ppp

chown -R 0:2000 xbin
chmod -R 755 xbin

# For pre-rooted firmware
if [ -f xbin/su ]; then
chmod 4755 xbin/su
fi

if [ -f xbin/sqlite3 ]; then
chmod 4755 xbin/sqlite3
fi

if [ -f bin/su ]; then
chmod 4755 bin/su
fi

if [ -f bin/sqlite3 ]; then
chmod 4755 bin/sqlite3
fi

cd bin
ln -s toolbox cat
ln -s toolbox chmod
ln -s toolbox chown
ln -s toolbox cmp
ln -s toolbox date
ln -s toolbox dd
ln -s toolbox df
ln -s toolbox dmesg
ln -s toolbox getevent
ln -s toolbox getprop
ln -s toolbox hd
ln -s toolbox id
ln -s toolbox ifconfig
ln -s toolbox iftop
ln -s toolbox insmod
ln -s toolbox ioctl
ln -s toolbox ionice
ln -s toolbox kill
ln -s toolbox ln
ln -s toolbox log
ln -s toolbox ls
ln -s toolbox lsmod
ln -s toolbox lsof
ln -s toolbox mkdir
ln -s toolbox mount
ln -s toolbox mv
ln -s toolbox nandread
ln -s toolbox netstat
ln -s toolbox newfs_msdos
ln -s toolbox notify
ln -s toolbox printenv
ln -s toolbox ps
ln -s toolbox reboot
ln -s toolbox renice
ln -s toolbox rm
ln -s toolbox rmdir
ln -s toolbox rmmod
ln -s toolbox route
ln -s toolbox schedtop
ln -s toolbox sendevent
ln -s toolbox setconsole
ln -s toolbox setprop
ln -s toolbox sleep
ln -s toolbox smd
ln -s toolbox start
ln -s toolbox stop
ln -s toolbox sync
ln -s toolbox top
ln -s toolbox umount
ln -s toolbox uptime
ln -s toolbox vmstat
ln -s toolbox watchprops
ln -s toolbox wipe
ln -s dumpstate dumpmesg
cd ../

fix-data.sh script:

#!/bin/sh

if [ -d data_test ]; then
rm -rf data_test
fi

if [ -d kernel-tests ]; then
rm -rf kernel-tests
fi

if [ -d local ]; then
rm -rf local
fi

if [ -d qmi_test ]; then
rm -rf qmi_test
fi

chown -R 1013:1000 .
chmod -R 777 .

fix-csc.sh script:

#!/bin/sh

chown -R 0:0 .
for i in $( find . ); do
if [ -d $i ]; then
chmod 755 $i
else
chmod 644 $i
fi
done

chown 1000:2001 recovery

CSC updater script:

#!/sbin/busybox sh

usage="usage: sec_csc <sales code>"

if [ "$(id | grep -c root)" != "1" ]; then
echo "You have no permission to run sec_csc."
exit 1;
fi

if ! [ "$1" = "" ]; then
if [ -d /system/csc/$1 ]; then
echo -n "Apply $1 sales code? y/N: "
read answer
if [ "$answer" = "y" ]; then
/sbin/busybox mount -o rw,remount /system
cp -f /system/csc/$1/system/CSCFiles.txt /system/
cp -f /system/csc/$1/system/CSCVersion.txt /system/
cp -f /system/csc/$1/system/csc/* /system/csc/
rm -f /data/property/persist.sys.country
rm -f /data/property/persist.sys.language
rm -f /data/property/persist.sys.localevar
echo -n $1 > /proc/LinuStoreIII/efs_info
setprop ril.sales_code $1
/sbin/busybox mount -o ro,remount /system
echo "Turn off and then turn on your phone"
echo "using the dedicated power button to"
echo "apply the new CSC."
fi
else
echo "$1 sales code not found."
fi
else
echo $usage
fi

Q: What's really above scripts do?

A: I do not directly use system.rfs (in rfs format) but making a new system.rfs in ext4 format. Copying the whole contents of the old system.rfs (rfs) into the new system.rfs (ext4), make modifications in the system.rfs (ext4) mount point, and then fix the access rights. Using ext3 format is also not problems as long as you use boot and recovery image that support ext3 and ext4 filesystems. After all the modifications, do not forget to umount both image.

Q: Why?

A: RFS filesystem in linux read as FAT filesystem. FAT filesystem permissions can not be set correctly according to the needs of the operating system (in this case Android). You're lucky if you modify the firmware and do not occur bootloop ;)

Q: Is Odin support *.rfs formatted in ext4?

A: Odin raw writes the filesystem partition, no matter the form as long as *.rfs no larger than the physical partition.

Q: Does this really work?

A: You can try :D If you want to take the risk why not try XWKPN firmware already formatted to ext4 in ODIN package as follows:

S5830XWKPN_S5830XWKP6_S5830OXXKP7_blackhawk.rar (137.59 MB)

Password: ketut.kumajaya

Inside the package:

CF-Root-S5830 v3.7 b81 candidate

deodexed and zipaligned /system/app and /system/framework, thanks to dsixda

cifs (Samba/Windows share) and tun (openVPN) kernel modules included

BLN service support, modified services.jar. Thanks to neldar

Android Scribble 2.0 boot animation from here, thanks to GLa'DOS

multi CSC taken from XWKPN (Europe?) and DXKC1 (Asia?), XSE sales code (Indonesia as default country)

csc.rfs, data.rfs and system.rfs in ext4 format, no need to convert filesystem manually using ext4 Manager

keep application and themes as a plain XWPKN

DT apps2sd included, a modified version special for CF-Root-S5830. You can find the original Darktremor apps2sd here, thanks to tkirton.

ODIN fullpack, the safest way to flash Samsung firmware

Instructions:

Follow these instructions to the letter. Do not touch any buttons or checkboxes that are not listed below to touch!

Decompress S5830XWKPN_S5830XWKP6_S5830OXXKP7_blackhawk.rar

(USB) Disconnect your phone from your computer

Start ODIN v4.38

Click the OPS button, and select Cooper_v1.0.ops

Click the BOOT button, and select APBOOT_S5830XWKPN_CL375596_REV03.tar.md5

Click the Phone button, and select MODEM_S5830XWKP6_CL375596_REV03.tar.md5

Click the PDA button, and select CODE_S5830XWKPN_CL375596_REV03_blackhawk.tar.md5

Click the CSC button, and select CSC_S5830OXXKP7_CL375596_REV03_blackhawk.tar.md5

Put your phone in download mode

(USB) Connect the phone to your computer

Click the START button

Wait for the phone to reboot

No need to wipe the /data and /cache partitions, has been automatically when flashing.

Done

If you expect a better benchmark results. Enable "Media: Stagefright" on "Tweak Manager" and make sure you do not select "CPU: Conservative gov.".

UPDATE:

- Samsung keyboard have more language

- A new script to apply your CSC, run it over "adb shell" or Terminal Emulator or ConnectBot. For example to apply SER (Russia?) sales code:

sec_csc SER

To activate your new sales code, you must power off and then power on your phone using the dedicated power button.

Apply this update over CWM or CWM Manager app.