Chumby Rootdisk - RFS1 (analyzed)
From Chumby Wiki
Contents
- 1 Boot Script: /etc/init.d/rcS from Chumby Classic
Boot Script: /etc/init.d/rcS from Chumby Classic
Start
#! /bin/sh # ken@chumby.com echo "Chumby Rootdisk - RFS1 (ken@chumby.com)" # /proc and /sys get mounted by /linuxrc mount -t tmpfs none /dev -o mode=755 /usr/chumby/scripts/mkdevs /dev mount -t devpts pts /dev/pts export LD_LIBRARY_PATH=/lib export PATH=${PATH}:/usr/chumby/scripts # mount temp partitions mount -t tmpfs -o size=32m none /tmp mount -t tmpfs -o size=32m none /var mount -t tmpfs -o size=32m none /mnt # mount psp partition mount -t jffs2 /dev/mtdblock1 /psp # create some required dirs mkdir -p /var/lock/subsystem mkdir -p /var/run mkdir -p /var/log mkdir -p /var/empty mkdir -p /var/spool/cron/crontabs mkdir -p /tmp/chumby # start syslogd /sbin/syslogd -C200 # set chumby alarm to 118 years from now /usr/chumby/scripts/cpi.sh -a 2147483647
First custom boot Injection point
If the file /psp/rfs1/rcS exists then at this point in the script it will be loaded and nothing else of the original boot script will be run.
Warning: Create this file at your own peril
if [ -x /psp/rfs1/rcS ]; then /psp/rfs1/rcS exit fi
Loading of System Continues
echo "Starting udevd as daemon" /sbin/udevd --daemon # wait for USB subsystem to finish loading /usr/chumby/scripts/wait_for_usb mkdir -p /mnt/usb mount /mnt/usb || rmdir /mnt/usb
Insertion point for userhook0
userhook0 can be placed on usb stick and on internal psp mount
# run any scripts for debug configuration of chumby from a USB thumb drive if [ -x /mnt/usb/userhook0 ]; then # Run in context of current script so it can change PATH and other # environment variables. . /mnt/usb/userhook0 fi # run any scripts for debug configuration of chumby from /psp if [ -x /psp/rfs1/userhook0 ]; then # Run in context of current script so it can change PATH and other # environment variables. . /psp/rfs1/userhook0 fi
Loading of system continues
# Display the chumby logo unzip -p /bitmap/chumby_logo.zip >/dev/fb # Start mountmon echo "Starting mountmon as daemon" mountmon --daemon # link crontabs ln -s /etc/cron/crontabs/root /var/spool/cron/crontabs/root hwversion=`/usr/chumby/scripts/chumby_version -h` if [ "$hwversion" == "3.8" ]; then # touch screen insmod /drivers/chumby-tsc2100.ko version038=1 # chumby sensor driver insmod /drivers/chumby_sense1.ko version038=1 else # touch screen insmod /drivers/chumby-tsc2100.ko # chumby sensor driver insmod /drivers/chumby_sense1.ko fi # check if this is the first time that chumby has been run and set # touch screen settings if [ -f /psp/firsttime ]; then FIRSTTIME=`cat /psp/firsttime` if [ "$FIRSTTIME" -eq "1" ]; then if [ "$hwversion" == "3.8" ]; then echo -n "101,3909,3984,-3815" >/psp/ts_settings else echo -n "136,3768,3835,-3540" >/psp/ts_settings fi fi fi # restore touch screen settings from /psp if present if [ -e /psp/ts_settings_backup ]; then cp /psp/ts_settings_backup /psp/ts_settings rm /psp/ts_settings_backup fi # restore touch screen settings from USB if present if [ -e /mnt/usb/ts_settings ]; then cp /mnt/usb/ts_settings /psp fi # chumby udma driver insmod /drivers/chumby_udma.ko echo 0 > /proc/sys/sense1/spkmute usleep 500000 echo 1 > /dev/dsp echo 1 > /proc/sys/sense1/spkmute usleep 500000 # Initially disable touch click echo 0 > /proc/chumby/touchscreen/touchclick # sound drivers insmod /drivers/snd-rawmidi.ko insmod /drivers/snd-seq-midi.ko insmod /drivers/snd-usb-lib.ko insmod /drivers/snd-hwdep.ko insmod /drivers/snd-usb-audio.ko insmod /drivers/usbhid.ko # set the speaker mute based on previous speaker settings if [ -e /psp/mute ]; then echo -n "Restoring mute setting: " chumby_set_volume --master_mute `cat /psp/mute` fi # set the volume if [ -e /psp/volume ]; then echo -n "Restoring volume setting: " chumby_set_volume --master_volume `cat /psp/volume` fi # set the speaker panning if [ -e /psp/pan ]; then echo -n "Restoring speaker pan setting: " chumby_set_volume --master_panning `cat /psp/pan` fi # chumby aux timer insmod /drivers/chumby_timer.ko mknod /dev/timerx c `cat /proc/devices |awk '/timer/ {print $1}'` 0 mknod /dev/timerm c `cat /proc/devices |awk '/timer/ {print $1}'` 1 # chumby accelerometer insmod /drivers/chumby_accel.ko mknod /dev/accel c `cat /proc/devices |awk '/accel/ {print $1}'` 0 # chumby switch mknod /dev/switch c `cat /proc/devices |awk '/switch/ {print $1}'` 0 # chumby daughter card id mknod /dev/dcid c `cat /proc/devices |awk '/dcid/ {print $1}'` 0 # chumby udma mknod /dev/udma c `cat /proc/devices |awk '/udma/ {print $1}'` 1 # After kernel modules have been loaded, trigger events for usb hotplug devices echo "Triggering udevd events for usb devices" udevtrigger --subsystem-match=usb_device --subsystem-match=block # start multi-purpose monitor (headphone jack, battery level, network status) headphone_mgr & # start and fork opening animation if [ ! -f /psp/UPDATE1 ]; then /usr/chumby/scripts/start_opening_anim & fi ifconfig lo 127.0.0.1 # load wired Ethernet drivers insmod /drivers/usbnet.ko insmod /drivers/asix.ko # load wifi driver insmod /drivers/rt73.ko # # start the network # if [ -e /mnt/usb/network_config ]; then cp /mnt/usb/network_config /psp /usr/chumby/scripts/start_network else if [ -e /psp/network_config ]; then /usr/chumby/scripts/start_network else ifconfig rausb0 up fi fi
Insertion point for userhook1
# run any scripts for debug configuration of chumby from a USB thumb drive if [ -x /mnt/usb/userhook1 ]; then /mnt/usb/userhook1 fi # run any scripts for debug configuration of chumby from /psp if [ -x /psp/rfs1/userhook1 ]; then /psp/rfs1/userhook1 fi
After userhook1 has completed
# run any scripts for debug configuration of chumby from a USB thumb drive if [ -x /mnt/usb/debugchumbyearly ]; then /mnt/usb/debugchumbyearly fi # attempt to restore time based on the crypto processor's uptime counter /usr/chumby/scripts/restore_time # sync time if the network is running running=`ifconfig rausb0 |grep RUNNING` if [ -z "$running" ]; then echo "Network is down. Network time not updated." else /usr/chumby/scripts/sync_time.sh -b & fi
Built-in Web Server Starts Up
- If we'd run our own server before this point, then this should fail (silently?) to start the builtin.
- If we need to start our own server afterwards we should `killall httpd`
# webserver /usr/sbin/httpd -h /www
more stuff runs
# Check for hostname HOSTNAME="$(hostname)" if [ "${HOSTNAME}" = "chumby" ] then echo "Creating default hostname: " HOSTNAME="$(default_hostname)" [ "${HOSTNAME}" ] && echo "${HOSTNAME}" >/psp/hostname echo "New hostname: ${HOSTNAME}" fi #zeroconf - howl echo "Starting zeroconf service" PATH=/usr/chumby/scripts:/usr/sbin:${PATH} service_control zeroconf start # Start howl daemon echo "Starting chumbhowld service" PATH=/usr/chumby/scripts:${PATH} service_control chumbhowld start # start crond /usr/sbin/crond -c /etc/cron/crontabs # make sure that the opening animation has completed before proceeding if [ ! -f /psp/UPDATE1 ]; then /usr/chumby/scripts/wait_for_opening fi # check to see if an update of RFS2 is needed if [ -f /psp/UPDATE1 ]; then UPDATE_URL=`cat /psp/UPDATE1` # check to see if there was a problem connecting to the network if [ ! -e /tmp/chumby/network_status.xml ]; then network_errors=`/usr/chumby/scripts/network_status.sh |grep error` else network_errors=`cat /tmp/chumby/network_status.xml |grep error` fi if [ -z "$network_errors" -o "$UPDATE_URL" == "update1" ]; then # update if there are no network errors or updating via USB echo "Updating RFS2.." if [ -e /psp/UPDATE1_MD5 ]; then /usr/chumby/scripts/update.sh `cat /psp/UPDATE1` NETWORK `cat /psp/UPDATE1_MD5` >/tmp/update1.log 2>&1 if [ "$?" -eq "0" ]; then # RFS2 update succeeded, remove flags rm -f /psp/UPDATE1 if [ -e /psp/save_update1 ]; then rm -f /psp/save_update1 fi fi else /usr/chumby/scripts/update.sh `cat /psp/UPDATE1` >/tmp/update1.log 2>&1 if [ "$?" -eq "0" ]; then # RFS2 update succeeded, remove flags rm -f /psp/UPDATE1 if [ -e /psp/save_update1 ]; then rm -f /psp/save_update1 fi fi fi else # set save_update1 to ensure that /psp/UPDATE1 is not removed when setting to factory defaults touch /psp/save_update1 fi fi # set paranoid boot flag/semaphore echo "Clearing paranoid boot flag" flash_eraseall /dev/mtd7 nandwrite /dev/mtd7 /usr/chumby/msp_00_64k_no_oob.bin 0x70000 # start resident portion of btplay echo "Starting btplay daemon" /usr/sbin/btplayd >/dev/null 2>&1 &
Insertion point for userhook2
# run any scripts for debug configuration of chumby from a USB thumb drive if [ -x /mnt/usb/userhook2 ]; then /mnt/usb/userhook2 fi # run any scripts for debug configuration of chumby from /psp if [ -x /psp/rfs1/userhook2 ]; then /psp/rfs1/userhook2 fi
Debug Chumby
# run any scripts for debug configuration of chumby from a USB thumb drive if [ -x /mnt/usb/debugchumby ]; then /mnt/usb/debugchumby fi
Remaining script runs
/usr/chumby/scripts/start_intro # start chumby backup alarm daemon /bin/chumbalarmd if [ -e /psp/missed_alarm ]; then # chumbalarmd has detected that an alarm was missed, allow chumbalarmd to fire the backup alarm # start_control_panel will be called automatically from chumbalarmd rm /psp/missed_alarm sync else # henry - enable logins /usr/chumby/scripts/start_control_panel >/dev/null 2>&1 & fi