Added /rescueOS

这个提交包含在:
NIN101 2013-03-23 21:56:55 +01:00
当前提交 cd735064de
共有 13 个文件被更改,包括 512 次插入0 次删除

1
rescueOS/README 普通文件
查看文件

@ -0,0 +1 @@
Apparently most scripts here are not completed, dumb and based on assumptations. Use them if you know what you are doing...

236
rescueOS/charge21.bash 可执行文件
查看文件

@ -0,0 +1,236 @@
#/bin/bash
#Original by ShadowJK. http://enivax.net/jk/n900/
if [ -e /run/charger-runned ] ; then
echo "Script already started. Delete run/charger-runned if you are sure no other instance is running"
exit
fi
touch /run/charger-runned
echo "Charger: " $(cat /sys/devices/platform/musb_hdrc/charger)
I2CGET=/usr/bin/i2cget
I2CSET=/usr/bin/i2cset
if pgrep bme_RX-51; then
echo "BME is running. Exiting."
exit
fi
configure()
{
echo -n "Pre-Config Status: " $($I2CGET -y 2 0x6b 0x00)
echo -n ", " $($I2CSET -y 2 0x6b 0x00) "."
# Disable charger for configuration:
# $I2CSET -y 2 0x6b 0x01 0xcc # No limit, 3.4V weak threshold, enable term, charger disable
# Register 0x04
# 8: reset
# 4: 27.2mV # charge current
# 2: 13.6mV
# 1: 6.8mV
# 8: N/A
# 4: 13.6mV # termination current
# 2: 6.8mV
# 1: 3.4mV
# 7-1250 6-1150 5-1050 4-950 3-850 2-750 1-650 0-550
# 7-400 6-350 5-300 4-250 3-200 2-150 1-100 0-50
$I2CSET -y -m 0xFF 2 0x6b 0x04 0x42;
# Register 0x02
# 8: .640 V
# 4: .320 V
# 2: .160 V
# 1: .080
# 8: .040
# 4: .020 (+ 3.5)
# 2: otg pin active at high (default 1)
# 1: enable otg pin
$I2CSET -y -m 0xfc 2 0x6b 0x02 0x8c;
REGV=4200
# 4.24 = 3.5 + .640 + .08 + .02 = 94
# 4.22 = 3.5 + ,640 + .08 = 90
# 4.2 = 3.5 + .640 + .040 + .02 = 8c
# 4.16 = 3.5 + .640V + .020 = 84
# 4.1 = 3.5 + .320 + .160 + .08 + .04 = 78
# 4.0 = 3.5 + .320 + .160 + .02 = 64
# 3.9 = 3.5 + .320 + .080 = 50
# Register 0x1
# 8: 00 = 100, 01 = 500, 10 = 800mA
# 4: 11 = no limit
# 2: 200mV weak threshold default 1
# 1: 100mV weak treshold defsult 1 (3.4 - 3.7)
# 8: enable termination
# 4: charger disable
# 2: high imp mode
# 1: boost
$I2CSET -y 2 0x6b 0x01 0x08;
#hotswap: c0
#normal: c8
# Register 0x00
# 8: Read: OTG Pin Status
# Write: Timer Reset
# 4: Enable Stat Pin
# 2: Stat : 00 Ready 01 In Progress
# 1: : 10 Done 11 Fault
# 8: Boost Mode
# 4: Fault: 000 Normal 001 VBUS OVP 010 Sleep Mode
# 2: 011 Poor input or Vbus < UVLO
# 1: 100 Battery OVP 101 Thermal Shutdown
# 110 Timer Fault 111 NA
$I2CSET -y 2 0x6b 0x00 0x00;
# Softstart
$I2CSET -y 2 0x6b 0x01 0xc8;
sleep 1
#echo " Unlimited: " $($I2CGET -y 2 0x6b 0x00)
#$I2CSET -y 2 0x6b 0x00 0x80 # timer reset
cat /sys/devices/platform/musb_hdrc/charger >/dev/null
}
configure
# Initialize variables
FULL=0
MODE="STANDBY"
WALLCHARGER=0
# Assuming a nice round number 20mOhm for bq27200 sense resistor
RS=21
# Assuming this much resistance between charger and battery
CR=131
BQPATH="/sys/class/power_supply/bq27200-0"
get_nac ()
{
NAC=$(cat $BQPATH/charge_now)
NAC=$((NAC/1000))
}
get_rsoc ()
{
RSOC=$(cat $BQPATH/capacity)
}
get_volt ()
{
VOLT=$(cat $BQPATH/voltage_now)
VOLT=$((VOLT/1000))
}
get_rate ()
{
RATE=$(cat $BQPATH/current_now)
RATE=$((RATE/1000))
RATE=$((-RATE))
}
calculate_system_use ()
{
SYSTEM_USE=$(( ($REGV *1000 - $VOLT*1000) / $CR - $RATE ))
if [ $(($SYSTEM_USE+$RATE)) -gt 950 ] ; then
SYSTEM_USE=$((950-RATE))
fi
}
decode_status()
{
S=$1
SOTG=$((S/128))
S=$((S-SOTG*128))
SSPIN=$((S/64))
S=$((S-SSPIN*64))
SSTAT=$((S/16))
S=$((S-SSTAT*16))
SBOOST=$((S/8))
S=$((S-SBOOST*8))
SFAULT=$((S))
# if [ $SSTAT -eq 0 ] ; then
# echo charger status: Ready
# fi
# if [ $SSTAT -eq 1 ] ; then
# echo charger status: InProgress
# fi
# if [ $SSTAT -eq 2 ] ; then
# echo charger status: Done
# fi
if [ $SSTAT -eq 3 ] || [ $SFAULT -ne 0 ]; then
echo -n $(date) charger status: Fault:
case $SFAULT in
0 )
echo NoFault ;;
1 )
echo VbusOVP ;;
2 )
echo SleepMode ;;
3 )
echo Poor Input or VBus UnderVoltage ;;
4 )
echo Battery Overvoltage Protection ;;
5 )
echo Thermal Shutdown ;;
6 )
echo TimerFault ;;
7 )
echo Unknown ;;
esac
fi
}
SLEEPTIME=15
while true ; do
STATUS=$($I2CGET -y 2 0x6b 0x00)
#echo $STATUS
$I2CSET -y -m 0x80 2 0x6b 0x00 0x80; # timer reset
get_nac
get_rsoc
get_volt
get_rate
# Sanity
if [ $VOLT -gt 4200 ] ; then
echo "***CRITICAL*** Battery voltage $VOLT exceeds 4.2V!!!"
exit 2
fi
if [ $MODE == "STANDBY" ] ; then
if [ $STATUS == 0x10 ] || [ $STATUS == 0x90 ] ; then
MODE="CHARGING" ; SLEEPTIME=5
echo $(date) "standby -> CHARGING. Current available capacity: " $NAC "mAh, " $RSOC " percent."
WALLCHARGER=$(cat /sys/devices/platform/musb_hdrc/charger)
fi
fi
if [ $MODE == "CHARGING" ] ; then
if [ $STATUS == 0x00 ] ; then
MODE="STANDBY" ; SLEEPTIME=15
echo $(date) "charging -> STANDBY. Current available capacity: " $NAC "mAh, " $RSOC " percent."
WALLCHARGER=0
# This will stop USB from eating power as long as you haven't plugged it into a PC
# #### echo 0 > /sys/devices/platform/musb_hdrc/connect
fi
fi
if [ $STATUS == 0x20 ] && [ $FULL == 0 ] ; then
echo "Charge done"
#echo $(date) "FULL: " $NAC "mAh" >> /home/user/MyDocs/charger.log
FULL=1
fi
if [ $STATUS == 0x00 ] && [ $FULL == 1 ] ; then
FULL=0
fi
calculate_system_use
decode_status $STATUS
echo Status: $STATUS Mode: $MODE Full: $FULL Wall: $WALLCHARGER Voltage: $VOLT NAC: $NAC level: $RSOC % Rate: $RATE System: "-"$SYSTEM_USE Ch: $(($SYSTEM_USE+$RATE))
sleep $SLEEPTIME
done

183
rescueOS/fix-maemo-devnodes.sh 可执行文件
查看文件

@ -0,0 +1,183 @@
#!/bin/sh
#might fix some devices nodes if they have been messed up.
#atm we don't care whether they exist already or not...
#mknod parts by Pali
sh /rescueOS/mount-maemo-root.sh
if [ ! -e /run/maemo-root-mounted ] ; then
echo "mount of maemo root failed, giving up."
exit
fi
mknod /mnt/maemo/dev/console c 5 1
mknod /mnt/maemo/dev/fb0 c 29 0
mknod /mnt/maemo/dev/fb1 c 29 1
mknod /mnt/maemo/dev/fb2 c 29 2
mknod /mnt/maemo/dev/full c 1 7
mknod /mnt/maemo/dev/kmem c 1 2
mknod /mnt/maemo/dev/mem c 1 1
mknod /mnt/maemo/dev/mtd0 c 90 0
mknod /mnt/maemo/dev/mtd0ro c 90 1
mknod /mnt/maemo/dev/mtd1 c 90 2
mknod /mnt/maemo/dev/mtd1ro c 90 3
mknod /mnt/maemo/dev/mtd2 c 90 4
mknod /mnt/maemo/dev/mtd2ro c 90 5
mknod /mnt/maemo/dev/mtd3 c 90 6
mknod /mnt/maemo/dev/mtd3ro c 90 7
mknod /mnt/maemo/dev/mtd4 c 90 8
mknod /mnt/maemo/dev/mtd4ro c 90 9
mknod /mnt/maemo/dev/mtd5 c 90 10
mknod /mnt/maemo/dev/mtd5ro c 90 11
mknod /mnt/maemo/dev/null c 1 3
mknod /mnt/maemo/dev/port c 1 4
mknod /mnt/maemo/dev/random c 1 8
mknod /mnt/maemo/dev/tty c 5 0
mknod /mnt/maemo/dev/ttyS0 c 4 64
mknod /mnt/maemo/dev/ttyS1 c 4 65
mknod /mnt/maemo/dev/ttyS2 c 4 66
mknod /mnt/maemo/dev/tty0 c 4 0
mknod /mnt/maemo/dev/urandom c 1 9
mknod /mnt/maemo/dev/zero c 1 5
mknod /mnt/maemo/dev/loop0 b 7 0
mknod /mnt/maemo/dev/loop1 b 7 1
mknod /mnt/maemo/dev/loop2 b 7 2
mknod /mnt/maemo/dev/loop3 b 7 3
mknod /mnt/maemo/dev/loop4 b 7 4
mknod /mnt/maemo/dev/loop5 b 7 5
mknod /mnt/maemo/dev/loop6 b 7 6
mknod /mnt/maemo/dev/loop7 b 7 7
mknod /mnt/maemo/dev/ram0 b 1 0
mknod /mnt/maemo/dev/ram1 b 1 1
mknod /mnt/maemo/dev/ram10 b 1 10
mknod /mnt/maemo/dev/ram11 b 1 11
mknod /mnt/maemo/dev/ram12 b 1 12
mknod /mnt/maemo/dev/ram13 b 1 13
mknod /mnt/maemo/dev/ram14 b 1 14
mknod /mnt/maemo/dev/ram15 b 1 15
mknod /mnt/maemo/dev/ram16 b 1 16
mknod /mnt/maemo/dev/ram2 b 1 2
mknod /mnt/maemo/dev/ram3 b 1 3
mknod /mnt/maemo/dev/ram4 b 1 4
mknod /mnt/maemo/dev/ram5 b 1 5
mknod /mnt/maemo/dev/ram6 b 1 6
mknod /mnt/maemo/dev/ram7 b 1 7
mknod /mnt/maemo/dev/ram8 b 1 8
mknod /mnt/maemo/dev/ram9 b 1 9
ln -s /proc/kcore /mnt/maemo/dev/core
ln -s ram1 /mnt/maemo/dev/ram
mkdir /mnt/maemo/dev/pts
chmod 755 /mnt/maemo/dev/pts
chmod 600 /mnt/maemo/dev/console
chmod 660 /mnt/maemo/dev/fb0
chmod 660 /mnt/maemo/dev/fb1
chmod 660 /mnt/maemo/dev/fb2
chmod 666 /mnt/maemo/dev/full
chmod 640 /mnt/maemo/dev/kmem
chmod 660 /mnt/maemo/dev/loop0
chmod 660 /mnt/maemo/dev/loop1
chmod 660 /mnt/maemo/dev/loop2
chmod 660 /mnt/maemo/dev/loop3
chmod 660 /mnt/maemo/dev/loop4
chmod 660 /mnt/maemo/dev/loop5
chmod 660 /mnt/maemo/dev/loop6
chmod 660 /mnt/maemo/dev/loop7
chmod 640 /mnt/maemo/dev/mem
chmod 600 /mnt/maemo/dev/mtd0
chmod 600 /mnt/maemo/dev/mtd0ro
chmod 600 /mnt/maemo/dev/mtd1
chmod 600 /mnt/maemo/dev/mtd1ro
chmod 600 /mnt/maemo/dev/mtd2
chmod 600 /mnt/maemo/dev/mtd2ro
chmod 600 /mnt/maemo/dev/mtd3
chmod 600 /mnt/maemo/dev/mtd3ro
chmod 600 /mnt/maemo/dev/mtd4
chmod 600 /mnt/maemo/dev/mtd4ro
chmod 600 /mnt/maemo/dev/mtd5
chmod 600 /mnt/maemo/dev/mtd5ro
chmod 666 /mnt/maemo/dev/null
chmod 640 /mnt/maemo/dev/port
chmod 660 /mnt/maemo/dev/ram0
chmod 660 /mnt/maemo/dev/ram1
chmod 660 /mnt/maemo/dev/ram10
chmod 660 /mnt/maemo/dev/ram11
chmod 660 /mnt/maemo/dev/ram12
chmod 660 /mnt/maemo/dev/ram13
chmod 660 /mnt/maemo/dev/ram14
chmod 660 /mnt/maemo/dev/ram15
chmod 660 /mnt/maemo/dev/ram16
chmod 660 /mnt/maemo/dev/ram2
chmod 660 /mnt/maemo/dev/ram3
chmod 660 /mnt/maemo/dev/ram4
chmod 660 /mnt/maemo/dev/ram5
chmod 660 /mnt/maemo/dev/ram6
chmod 660 /mnt/maemo/dev/ram7
chmod 660 /mnt/maemo/dev/ram8
chmod 660 /mnt/maemo/dev/ram9
chmod 666 /mnt/maemo/dev/random
chmod 666 /mnt/maemo/dev/tty
chmod 660 /mnt/maemo/dev/ttyS0
chmod 660 /mnt/maemo/dev/ttyS1
chmod 660 /mnt/maemo/dev/ttyS2
chmod 600 /mnt/maemo/dev/tty0
chmod 444 /mnt/maemo/dev/urandom
chmod 666 /mnt/maemo/dev/zero
chown root:tty /mnt/maemo/dev/console
chown root:video /mnt/maemo/dev/fb0
chown root:video /mnt/maemo/dev/fb1
chown root:video /mnt/maemo/dev/fb2
chown root:root /mnt/maemo/dev/full
chown root:kmem /mnt/maemo/dev/kmem
chown root:disk /mnt/maemo/dev/loop0
chown root:disk /mnt/maemo/dev/loop1
chown root:disk /mnt/maemo/dev/loop2
chown root:disk /mnt/maemo/dev/loop3
chown root:disk /mnt/maemo/dev/loop4
chown root:disk /mnt/maemo/dev/loop5
chown root:disk /mnt/maemo/dev/loop6
chown root:disk /mnt/maemo/dev/loop7
chown root:kmem /mnt/maemo/dev/mem
chown root:root /mnt/maemo/dev/mtd0
chown root:root /mnt/maemo/dev/mtd0ro
chown root:root /mnt/maemo/dev/mtd1
chown root:root /mnt/maemo/dev/mtd1ro
chown root:root /mnt/maemo/dev/mtd2
chown root:root /mnt/maemo/dev/mtd2ro
chown root:root /mnt/maemo/dev/mtd3
chown root:root /mnt/maemo/dev/mtd3ro
chown root:root /mnt/maemo/dev/mtd4
chown root:root /mnt/maemo/dev/mtd4ro
chown root:root /mnt/maemo/dev/mtd5
chown root:root /mnt/maemo/dev/mtd5ro
chown root:root /mnt/maemo/dev/null
chown root:kmem /mnt/maemo/dev/port
chown root:disk /mnt/maemo/dev/ram0
chown root:disk /mnt/maemo/dev/ram1
chown root:disk /mnt/maemo/dev/ram10
chown root:disk /mnt/maemo/dev/ram11
chown root:disk /mnt/maemo/dev/ram12
chown root:disk /mnt/maemo/dev/ram13
chown root:disk /mnt/maemo/dev/ram14
chown root:disk /mnt/maemo/dev/ram15
chown root:disk /mnt/maemo/dev/ram16
chown root:disk /mnt/maemo/dev/ram2
chown root:disk /mnt/maemo/dev/ram3
chown root:disk /mnt/maemo/dev/ram4
chown root:disk /mnt/maemo/dev/ram5
chown root:disk /mnt/maemo/dev/ram6
chown root:disk /mnt/maemo/dev/ram7
chown root:disk /mnt/maemo/dev/ram8
chown root:disk /mnt/maemo/dev/ram9
chown root:root /mnt/maemo/dev/random
chown root:tty /mnt/maemo/dev/tty
chown root:dialout /mnt/maemo/dev/ttyS0
chown root:dialout /mnt/maemo/dev/ttyS1
chown root:dialout /mnt/maemo/dev/ttyS2
chown root:tty /mnt/maemo/dev/tty0
chown root:root /mnt/maemo/dev/urandom
chown root:root /mnt/maemo/dev/zero

查看文件

@ -0,0 +1,2 @@
#!/bin/sh
rmmod g_file_storage

10
rescueOS/mass-storage-enable.sh 可执行文件
查看文件

@ -0,0 +1,10 @@
#!/bin/bash
rmmod g_nokia
#stuff changes when sd card is inserted
if [ -e /sys/block/mmcblk0 ] && [ -e /sys/block/mmcblk1 ] ; then
modprobe g_file_storage file=/dev/mmcblk1p2,/dev/mmcblk1p1 stall=0 removable=1
else
modprobe g_file_storage file=/dev/mmcblk0p2,/dev/mmcblk0p1 stall=0 removable=1
fi

8
rescueOS/mount-maemo-root.sh 可执行文件
查看文件

@ -0,0 +1,8 @@
#!/bin/sh
[ -d /mnt/maemo ] || mkdir /mnt/maemo/
if [ -e /run/maemo-root-mounted ] ; then
echo "A system script already mounted the rootfs of maemo to /mnt/maemo" ;
exit ;
fi
ubiattach /dev/ubi_ctrl -m 5
mount -t ubifs -o rw,bulk_read,no_chk_data_crc ubi0:rootfs /mnt/maemo && touch /run/maemo-root-mounted

二进制
rescueOS/nokia-n900.kmap 普通文件

二进制文件未显示。

1
rescueOS/rcS 符号链接
查看文件

@ -0,0 +1 @@
/etc/init.d/rcS

14
rescueOS/setup-wpa-wifi.sh 可执行文件
查看文件

@ -0,0 +1,14 @@
#!/bin/sh
ermsg()
{
echo $1
exit
}
ls /lib/firmware/ | grep wl1251 > /dev/null || ermsg "Firmware not found. Copy wl1251-fw.bin, wl1251-nvs.bin from maemo.".
[ -e /run/wlan.conf ] || ermsg "Yeah, please run wpa_passphrase [essid] [password ] > /run/wlan.conf first."
modprobe wl1251_spi
#Works for my router, probably for yours too, if not, then not :-)
sleep 1;
wpa_supplicant -Dwext -iwlan0 -c/run/wlan.conf &

35
rescueOS/shutdown-cleanup 普通文件
查看文件

@ -0,0 +1,35 @@
umount_maemo()
{
sync
umount /mnt/maemo
ubidetach -m 5
}
cd /
echo "Sending all processes the TERM signal..."
kill -15 -1
umount_maemo
sleep 1
echo "Sending all processes the KILL signal..."
kill -9 -1
umount_maemo
echo "Unmounting filesystems..."
umount -a -r 2> /dev/null
sync
#reset timer.
sleep 3
i2cset -y -m 0x80 2 0x6b 0x04 0x80
sleep 1
echo
echo "RescueOS says good bye - have a good day."
sleep 3
poweroff -f

11
rescueOS/umount-maemo-root.sh 可执行文件
查看文件

@ -0,0 +1,11 @@
#!/bin/sh
ermsg()
{
echo "Couldn't unmount. Most likely your fault. Are you in /mnt/maemo?";
exit;
}
sync
umount /mnt/maemo || ermsg
ubidetach -m 5
rm /run/maemo-root-mounted

查看文件

@ -0,0 +1,3 @@
#!/bin/sh
#Yeah...
rmmod g_nokia

查看文件

@ -0,0 +1,8 @@
#!/bin/sh
sh /rescueOS/mass-storage-disable.sh
modprobe g_nokia
ifconfig usb0 down
ifconfig usb0 192.168.2.15 up
ifconfig usb0 netmask 255.255.255.0
#route add default gw 192.168.178.14
route add 192.168.2.14 usb0