26f14d6b5d
Use EDID when available to configure the frame buffer driver with good settings for the attached display. Change-Id: I69a78155a93e55ffa1ca3ff6621a879a56cdbceb
368 lines
8.4 KiB
Text
368 lines
8.4 KiB
Text
# /usr/etc/rc - continued system initialization.
|
|
|
|
RANDOM_FILE=/usr/adm/random.dat
|
|
LOCAL_FILE=/usr/etc/rc.local
|
|
|
|
ARCH="`sysenv arch`"
|
|
|
|
if [ ! "$ARCH" ]
|
|
then # Older kernels do not provide an arch sysenv variable.
|
|
# We assume we are on x86 then, as existing systems with
|
|
# kernel and userland (i.e. this script) unsynchronized
|
|
# will be x86.
|
|
ARCH=i386
|
|
fi
|
|
|
|
# Get $SERVICES_DIRS
|
|
. /etc/rc.conf
|
|
|
|
# Directories to find services in
|
|
if [ ! "$SERVICES_DIRS" ]
|
|
then SERVICES_DIRS=/usr/sbin
|
|
fi
|
|
|
|
# Booting from cd?
|
|
bootcd="`/bin/sysenv bootcd`"
|
|
|
|
case "$#:$1" in
|
|
1:start|1:stop|1:down)
|
|
action=$1
|
|
;;
|
|
*) echo >&2 "Usage: $0 start|stop|down"
|
|
exit 1
|
|
esac
|
|
|
|
if [ -f "$LOCAL_FILE" ]
|
|
then . "$LOCAL_FILE" $1
|
|
fi
|
|
|
|
disabled()
|
|
{
|
|
ifs="$IFS"; IFS=,
|
|
for skip in `sysenv disable`
|
|
do
|
|
if [ "$skip" = "$1" ]
|
|
then
|
|
IFS="$ifs"; unset ifs
|
|
return 0
|
|
fi
|
|
done
|
|
IFS="$ifs"; unset ifs
|
|
return 1
|
|
}
|
|
|
|
daemonize()
|
|
{
|
|
# Function to start a daemon, if it exists.
|
|
local IFS=':'
|
|
local name="$1"
|
|
test "$1" = tcpd && name="$2"
|
|
|
|
for dir in $PATH
|
|
do
|
|
if [ -f "$dir/$1" ]
|
|
then
|
|
|
|
# check if this service is disabled at the boot monitor.
|
|
if disabled $name; then return; fi
|
|
|
|
echo -n " $name"
|
|
"$@" &
|
|
return
|
|
fi
|
|
done
|
|
}
|
|
|
|
up()
|
|
{
|
|
# Function to dynamically start a system service
|
|
opt=""
|
|
prefix=$(expr "$1 " : '\(-\)')
|
|
if [ "$prefix" = "-" ];
|
|
then
|
|
opt=$1
|
|
shift
|
|
fi
|
|
service=$1
|
|
shift
|
|
|
|
# First check if this service is disabled at the boot monitor.
|
|
if disabled $service; then return; fi
|
|
|
|
# Service is not disabled. Try to bring it up.
|
|
found=""
|
|
for dir in $SERVICES_DIRS
|
|
do bin=$dir/$service
|
|
if [ -x $bin -a -z "$found" ]
|
|
then service $opt up $bin "$@"
|
|
echo -n " $service"
|
|
found=yes
|
|
fi
|
|
done
|
|
if [ -z "$found" ]
|
|
then echo " ($service not found in $SERVICES_DIRS)"
|
|
fi
|
|
}
|
|
|
|
get_eth_labels() {
|
|
# Filter out the non-vlan ethernet entries from inet.conf.
|
|
# Produce as output a list of "drivername_instancenr"-formatted labels.
|
|
sed 's/\008/ /g' /etc/inet.conf | \
|
|
sed -n 's/^ *eth[0-9][0-9]* *\([^ ][^ ]*\) *\([0-9][0-9]*\).*$/\1_\2/p' | \
|
|
grep -v '^vlan_'
|
|
}
|
|
|
|
DAEMONS=/etc/rc.daemons
|
|
|
|
case $action in
|
|
start)
|
|
# Select console font.
|
|
test -f /etc/font && loadfont /etc/font </dev/console
|
|
|
|
# Cleanup.
|
|
rm -rf /tmp/* /usr/run/* /usr/spool/lpd/* /usr/spool/locks/*
|
|
|
|
# Start servers and drivers set at the boot monitor.
|
|
echo -n "Starting services:"
|
|
up -n random -dev /dev/random -devstyle STYLE_DEVA -period 3HZ
|
|
|
|
# load random number generator
|
|
if [ -f $RANDOM_FILE ]
|
|
then
|
|
cat < $RANDOM_FILE >/dev/random
|
|
# overwrite $RANDOM_FILE. We don't want to use this data again
|
|
dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 2> /dev/null
|
|
fi
|
|
|
|
# start network driver instances for all configured ethernet devices
|
|
for label in $(get_eth_labels); do
|
|
driver=$(echo $label | sed 's/\(.*\)_.*/\1/')
|
|
instance=$(echo $label | sed 's/.*_//')
|
|
eval arg=\$${label}_arg
|
|
if [ ! -z "$arg" ]; then arg=" $arg"; fi
|
|
arg="-args \"instance=$instance$arg\""
|
|
eval up $driver -label $label $arg -period 5HZ
|
|
done
|
|
if [ X`/bin/sysenv lwip` = Xyes ]
|
|
then
|
|
up lwip -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE_A
|
|
else
|
|
up inet -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE
|
|
fi
|
|
|
|
up -n ipc
|
|
|
|
if [ $ARCH = i386 ]
|
|
then
|
|
up -n printer -dev /dev/lp -period 10HZ
|
|
# start VirtualBox time sync driver if the device is there
|
|
if grep '^[^ ]* [^ ]* 80EE:CAFE ' /proc/pci >/dev/null; then
|
|
up -n vbox -period 10HZ
|
|
fi
|
|
fi
|
|
|
|
echo .
|
|
|
|
# Network initialization.
|
|
(: </dev/tcp) 2>/dev/null && net=t # Is there a TCP/IP server?
|
|
|
|
echo -n "Starting daemons:"
|
|
daemonize update
|
|
|
|
# Ugly error message when starting cron from CD.
|
|
# (and cron unnecessary then so..)
|
|
if [ ! -f /CD ]
|
|
then daemonize cron
|
|
else mkdir /tmp/log
|
|
rm -f /var/log || true
|
|
ln -s /tmp/log /var/log || true
|
|
. /etc/rc.cd
|
|
fi
|
|
# syslogd has not been started yet
|
|
rm -f /var/run/syslogd.pid
|
|
daemonize syslogd
|
|
echo .
|
|
|
|
# i2c only supported on ARM at the moment
|
|
if [ $ARCH = earm ]
|
|
then
|
|
echo -n "Starting i2c subsystem: "
|
|
for bus in 1 2 3
|
|
do
|
|
test -e /dev/i2c-${bus} || (cd /dev && MAKEDEV i2c-${bus})
|
|
up i2c -dev /dev/i2c-${bus} -label i2c.${bus} \
|
|
-args instance=${bus}
|
|
done
|
|
echo .
|
|
|
|
BOARD_NAME=`eepromread -i | sed -n 's/^BOARD_NAME : \(.*\)$/\1/p'`
|
|
case "${BOARD_NAME}" in
|
|
|
|
A335BONE)
|
|
echo "Detected BeagleBone"
|
|
echo -n "Starting i2c device drivers: "
|
|
|
|
# start EEPROM driver for reading board info
|
|
test -e /dev/eepromb1s50 || \
|
|
(cd /dev && MAKEDEV eepromb1s50)
|
|
up cat24c256 -dev /dev/eepromb1s50 \
|
|
-label cat24c256.1.50 \
|
|
-args 'bus=1 address=0x50'
|
|
|
|
# Start TPS65217 driver for power management.
|
|
up tps65217 -label tps65217.1.24 \
|
|
-args 'bus=1 address=0x24'
|
|
|
|
# check for the presence of a display
|
|
eepromread -f /dev/i2c-2 -n > /dev/null 2>&1
|
|
RESULT=$?
|
|
if [ $RESULT -eq 0 ]
|
|
then
|
|
# start eeprom driver for reading EDID.
|
|
test -e /dev/eepromb2s50 || \
|
|
(cd /dev && MAKEDEV eepromb2s50)
|
|
up cat24c256 -dev /dev/eepromb2s50 \
|
|
-label cat24c256.2.50 \
|
|
-args 'bus=2 address=0x50'
|
|
|
|
# start frame buffer
|
|
#up fb -dev /dev/fb0 -args edid.0=cat24c256.2.50
|
|
# fb hasn't been ported to AM335X yet.
|
|
fi
|
|
|
|
;;
|
|
|
|
A335BNLT)
|
|
echo "Detected BeagleBone Black"
|
|
echo -n "Starting i2c device drivers: "
|
|
|
|
# start EEPROM driver for reading board info
|
|
test -e /dev/eepromb1s50 || \
|
|
(cd /dev && MAKEDEV eepromb1s50)
|
|
up cat24c256 -dev /dev/eepromb1s50 \
|
|
-label cat24c256.1.50 \
|
|
-args 'bus=1 address=0x50'
|
|
|
|
# Start TPS65217 driver for power management.
|
|
up tps65217 -label tps65217.1.24 \
|
|
-args 'bus=1 address=0x24'
|
|
|
|
# Start TDA19988 driver for reading EDID.
|
|
up tda19988 -label tda19988.1.3470 -args \
|
|
'cec_bus=1 cec_address=0x34 hdmi_bus=1 hdmi_address=0x70'
|
|
|
|
# start frame buffer
|
|
#up fb -dev /dev/fb0 -args edid.0=tda19988.1.3470
|
|
# fb hasn't been ported to AM335X yet.
|
|
|
|
;;
|
|
|
|
UNKNOWN)
|
|
echo "Unable to detect board -- assuming BeagleBoard-xM"
|
|
echo -n "Starting i2c device drivers: "
|
|
|
|
# Start TPS65950 driver for power management.
|
|
up tps65950 -label tps65950.1.48 \
|
|
-args 'bus=1 address=0x48'
|
|
|
|
# Set the system time to the time in the TPS65950's RTC
|
|
readclock
|
|
|
|
# check for the presence of a display
|
|
eepromread -f /dev/i2c-3 -n > /dev/null 2>&1
|
|
RESULT=$?
|
|
if [ $RESULT -eq 0 ]
|
|
then
|
|
# start eeprom driver for reading edid
|
|
test -e /dev/eepromb3s50 || \
|
|
(cd /dev && MAKEDEV eepromb3s50)
|
|
up cat24c256 -dev /dev/eepromb3s50 \
|
|
-label cat24c256.3.50 \
|
|
-args 'bus=3 address=0x50'
|
|
|
|
# start frame buffer
|
|
up fb -dev /dev/fb0 -args edid.0=cat24c256.3.50
|
|
fi
|
|
|
|
;;
|
|
esac
|
|
|
|
echo .
|
|
fi
|
|
|
|
if [ "$net" ]
|
|
then
|
|
if [ -f /etc/rc.net ]
|
|
then
|
|
# Let a customized TCP/IP initialization script figure it out.
|
|
. /etc/rc.net
|
|
else
|
|
# Standard network daemons.
|
|
echo -n "Starting networking:"
|
|
if grep -s 'psip0.*default' /etc/inet.conf >/dev/null
|
|
then ifconfig -h 10.0.0.1
|
|
else
|
|
if [ X`/bin/sysenv lwip` = Xyes ]
|
|
then
|
|
dhcpd --lwip &
|
|
echo -n " dhcpd"
|
|
else
|
|
daemonize dhcpd
|
|
fi
|
|
fi
|
|
daemonize nonamed -L
|
|
if [ -f "$DAEMONS" ]
|
|
then . "$DAEMONS"
|
|
fi
|
|
# The last daemon has been started, so close the list:
|
|
echo .
|
|
fi
|
|
fi
|
|
|
|
if [ "$net" ]
|
|
then
|
|
# Get the nodename from the DNS and set it.
|
|
trap '' 2
|
|
intr -t 20 hostaddr -h
|
|
trap 2
|
|
fi
|
|
|
|
# Recover files being edited when the system crashed.
|
|
test -f /usr/bin/elvprsv && elvprsv /usr/tmp/elv*
|
|
|
|
# Run the daily cleanup on systems that are not on at night.
|
|
test -f /usr/etc/daily && sh /usr/etc/daily boot &
|
|
;;
|
|
stop|down)
|
|
# Save random data, if /usr is mounted rw.
|
|
if grep ' \/usr .*rw.*' /etc/mtab >/dev/null
|
|
then
|
|
if dd if=/dev/random of=$RANDOM_FILE.new bs=1024 count=1 2>/dev/null
|
|
then
|
|
mv $RANDOM_FILE.new $RANDOM_FILE
|
|
else
|
|
echo 'Failed to save random data.'
|
|
fi
|
|
fi
|
|
esac
|
|
|
|
d=
|
|
# Let packages run their own scripts
|
|
for d in /usr/local/etc/rc.d /usr/pkg/etc/rc.d
|
|
do
|
|
if [ -d "$d" -a -z "$bootcd" ]
|
|
then ( if cd $d
|
|
then
|
|
echo -n "Local packages ($action): "
|
|
for f in *
|
|
do
|
|
if [ -x "$f" ]
|
|
then echo -n "$f "
|
|
sh "$f" "$action"
|
|
fi
|
|
done
|
|
echo " done."
|
|
fi
|
|
)
|
|
fi
|
|
done
|