diff --git a/san b/san index 3fb98da..4c0f95c 100644 --- a/san +++ b/san @@ -56,7 +56,8 @@ factory_reset() # Firmware flash. # ACRAMFS=/tmp/acramfs.bin -MMC_UP_DEV=/dev/mmc_Update +MMC_ACTIVE_DEV=/dev/mmc_Active +MMC_UPDATE_DEV=/dev/mmc_Update SWUP_DEV=/dev/swupdev SWUP_PROC=/proc/swupdev @@ -75,14 +76,22 @@ set_image_dir() esac } +download_from_main_buildarea() +{ + set_image_dir + ACRAMFS_URL="main/${IMAGE_DIR}/dist/image/acramfs/acramfs.bin" + download_firmware "${ACRAMFS_URL}" +} + download_firmware() { - BRANCH_DIR="roku/main" - set_image_dir - ACRAMFS_URL="http://$SERVER_IP/${BRANCH_DIR}/${IMAGE_DIR}/dist/image/acramfs/acramfs.bin" + ACRAMFS_URL="http://$SERVER_IP/roku/$1" echo "Downloading ${ACRAMFS_URL}" wget -O ${ACRAMFS} ${ACRAMFS_URL} - [ $? -eq 0 ] || exit + if [ $? -ne 0 ]; then + echo "Download failed." + return 1 + fi } update_firmware() @@ -92,8 +101,15 @@ update_firmware() echo -n memlock >$SWUP_PROC echo -n writeswupmagic >$SWUP_PROC echo -n commit >$SWUP_PROC - elif [ -b $MMC_UP_DEV ]; then - dd if=${ACRAMFS} of=$MMC_UP_DEV bs=65536 + elif [ -b $MMC_UPDATE_DEV ]; then + if [ "$1" == "active" -o "$1" == "both" ]; then + echo "Flashing $MMC_ACTIVE_DEV" + [ -b "$MMC_ACTIVE_DEV" ] && dd if=${ACRAMFS} of=$MMC_ACTIVE_DEV bs=65536 + fi + if [ "$1" == "update" -o "$1" == "both" ]; then + echo "Flashing $MMC_UPDATE_DEV" + dd if=${ACRAMFS} of=$MMC_UPDATE_DEV bs=65536 + fi else rm -f ${ACRAMFS} echo 'Cannot update this platform' >&2 @@ -101,25 +117,36 @@ update_firmware() fi } -descr " rokuflash - " +descr " rokuflash [active|both] [acramfs path] - empty flashes from build area" rokuflash() { - download_firmware - update_firmware + if [ "$1" = "active" -o "$1" = "both" ]; then + UPDATE_PARTITION="$1" + shift + else + UPDATE_PARTITION="update" + fi + + if [ -z "$1" ]; then + download_from_main_buildarea + else + download_firmware $1 + fi + + [ $? -eq 0 ] && update_firmware $UPDATE_PARTITION + [ $? -eq 0 ] && fastboot_reset } descr " rokuflashgold - " rokuflashgold() { - ACRAMFS_URL="http://$SERVER_IP/roku/golden/acramfs.${ROKU_PLATFORM}.bin" - echo "Downloading ${ACRAMFS_URL}" - wget -O ${ACRAMFS} ${ACRAMFS_URL} - update_firmware + download_firmware "golden/acramfs.${ROKU_PLATFORM}.bin" + [ $? -eq 0 ] && update_firmware "update" + [ $? -eq 0 ] && fastboot_reset } ###############################################################################v - # Ddd to the start of the script # export APP_GDBSERVER="/nvram/tools/gdbserver :5555"ebug Server # @@ -142,7 +169,7 @@ setup_gdb() cat > /nvram/launch_gdb.sh << EOF #!/bin/sh cp -r /nvram/tools /tmp/tools2 -#export APIB_GDBSERVER="/tmp/tools2/strac -f" +#export APIB_GDBSERVER="/tmp/tools2/strace -f" #export APIB_GDBSERVER="/tmp/tools2/gdbserver :5555" export APP_GDBSERVER="/tmp/tools2/gdbserver :5555" #no watch dog @@ -167,6 +194,56 @@ disable_gdb() mv /tmp/autostart /nvram/ } +################################################################################ +# +# Log +# +LOG_CONF="/nvram/logapi.conf" +descr " log_reset - reset log configuration" +log_reset() +{ + [ -f $LOG_CONF ] && rm $LOG_CONF +} + +descr " log_all - log everything" +log_all() +{ + echo "+c *" >> $LOG_CONF +} + +################################################################################ +# +# Config +# +descr " config_reset - erase configuration" +config_reset() +{ + su app -c "ConfigService -ro" +} + +descr " config_list - " +config_list() +{ + su app -c "ConfigService -lo" +} + +config_enable() +{ + su app -c "ConfigService -so $1=true" +} + +config_disable() +{ + su app -c "ConfigService -so $1=true" +} + + +descr " disable_failsafe - " +disable_failsafe() +{ + config_enable "fw.apibroker.failsafe-disable" +} + ################################################################################ # # Fastboot related @@ -184,18 +261,13 @@ descr " disable_fastboot - " disable_fastboot() { su app -c "ConfigService -so fw.fastboot.capture.snapshot=false" + fastboot_reset } -descr " config_reset - " -config_reset() +descr " fastboot_reset - " +fastboot_reset() { - su app -c "ConfigService -ro" -} - -descr " config_list - " -config_list() -{ - su app -c "ConfigService -lo" + [ -e /dev/mapper/snapshotree ] && mkswap /dev/mapper/snapshotree } ################################################################################ @@ -216,12 +288,6 @@ set_office_network() PSK="ahovwxy@.0" } -set_home_network() -{ - SSID="vodafone399827" - PSK="v98AkhachA+1Vika33831294215495" -} - descr " setup_wifi - " setup_wifi() @@ -234,8 +300,6 @@ setup_wifi() sleep 3 set_office_network wpa scan_result | grep $SSID - [ $? == 0 ] || set_home_network - wpa scan_result | grep $SSID [ $? == 0 ] || return 2 NETWORK=$(wpa add_network) @@ -252,6 +316,12 @@ setup_wifi() ip a add $IP/22 dev $IFACE } +descr " setup_network - " +setup_network() +{ + /sbin/udhcpc -i eth0 -s /etc/udhcpc.sh +} + alias ll='ls -la' ################################################################################