diff options
Diffstat (limited to 'target/linux/cns3xxx/base-files')
12 files changed, 589 insertions, 0 deletions
diff --git a/target/linux/cns3xxx/base-files/.svn/entries b/target/linux/cns3xxx/base-files/.svn/entries new file mode 100644 index 0000000..1331adf --- /dev/null +++ b/target/linux/cns3xxx/base-files/.svn/entries @@ -0,0 +1,34 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/target/linux/cns3xxx/base-files +svn://svn.openwrt.org/openwrt + + + +2013-03-10T01:01:51.045091Z +35915 +nbd + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +lib +dir + +etc +dir + diff --git a/target/linux/cns3xxx/base-files/etc/.svn/entries b/target/linux/cns3xxx/base-files/etc/.svn/entries new file mode 100644 index 0000000..d027e81 --- /dev/null +++ b/target/linux/cns3xxx/base-files/etc/.svn/entries @@ -0,0 +1,31 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/target/linux/cns3xxx/base-files/etc +svn://svn.openwrt.org/openwrt + + + +2013-03-10T01:01:51.045091Z +35915 +nbd + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +init.d +dir + diff --git a/target/linux/cns3xxx/base-files/etc/init.d/.svn/entries b/target/linux/cns3xxx/base-files/etc/init.d/.svn/entries new file mode 100644 index 0000000..c530324 --- /dev/null +++ b/target/linux/cns3xxx/base-files/etc/init.d/.svn/entries @@ -0,0 +1,62 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/target/linux/cns3xxx/base-files/etc/init.d +svn://svn.openwrt.org/openwrt + + + +2013-03-10T01:01:51.045091Z +35915 +nbd + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +netdev-cpu +file + + + + +2013-03-17T12:13:04.000000Z +efe6b0b935a6e7dc0f87acfe5ab6cb9b +2013-03-10T01:01:51.045091Z +35915 +nbd +has-props + + + + + + + + + + + + + + + + + + + + +364 + diff --git a/target/linux/cns3xxx/base-files/etc/init.d/.svn/prop-base/netdev-cpu.svn-base b/target/linux/cns3xxx/base-files/etc/init.d/.svn/prop-base/netdev-cpu.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/target/linux/cns3xxx/base-files/etc/init.d/.svn/prop-base/netdev-cpu.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/target/linux/cns3xxx/base-files/etc/init.d/.svn/text-base/netdev-cpu.svn-base b/target/linux/cns3xxx/base-files/etc/init.d/.svn/text-base/netdev-cpu.svn-base new file mode 100644 index 0000000..3a2a57b --- /dev/null +++ b/target/linux/cns3xxx/base-files/etc/init.d/.svn/text-base/netdev-cpu.svn-base @@ -0,0 +1,21 @@ +#!/bin/sh /etc/rc.common + +START=99 + +get_irq() { + local name="$1" + grep -m 1 "$name" /proc/interrupts | cut -d: -f1 | sed 's, *,,' +} + +set_irq_affinity() { + local name="$1" + local val="$2" + local irq="$(get_irq "$name")" + [ -n "$irq" ] || return + echo "$val" > "/proc/irq/$irq/smp_affinity" +} + +start() { + set_irq_affinity gig_switch 2 + set_irq_affinity gig_stat 2 +} diff --git a/target/linux/cns3xxx/base-files/etc/init.d/netdev-cpu b/target/linux/cns3xxx/base-files/etc/init.d/netdev-cpu new file mode 100755 index 0000000..3a2a57b --- /dev/null +++ b/target/linux/cns3xxx/base-files/etc/init.d/netdev-cpu @@ -0,0 +1,21 @@ +#!/bin/sh /etc/rc.common + +START=99 + +get_irq() { + local name="$1" + grep -m 1 "$name" /proc/interrupts | cut -d: -f1 | sed 's, *,,' +} + +set_irq_affinity() { + local name="$1" + local val="$2" + local irq="$(get_irq "$name")" + [ -n "$irq" ] || return + echo "$val" > "/proc/irq/$irq/smp_affinity" +} + +start() { + set_irq_affinity gig_switch 2 + set_irq_affinity gig_stat 2 +} diff --git a/target/linux/cns3xxx/base-files/lib/.svn/entries b/target/linux/cns3xxx/base-files/lib/.svn/entries new file mode 100644 index 0000000..c18383c --- /dev/null +++ b/target/linux/cns3xxx/base-files/lib/.svn/entries @@ -0,0 +1,65 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/target/linux/cns3xxx/base-files/lib +svn://svn.openwrt.org/openwrt + + + +2012-11-07T23:12:06.522923Z +34113 +luka + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +upgrade +dir + +cns3xxx.sh +file + + + + +2013-03-17T12:13:04.000000Z +f41265a6e5e36f07eb78725277815095 +2012-11-07T23:12:06.522923Z +34113 +luka + + + + + + + + + + + + + + + + + + + + + +309 + diff --git a/target/linux/cns3xxx/base-files/lib/.svn/text-base/cns3xxx.sh.svn-base b/target/linux/cns3xxx/base-files/lib/.svn/text-base/cns3xxx.sh.svn-base new file mode 100644 index 0000000..476f9be --- /dev/null +++ b/target/linux/cns3xxx/base-files/lib/.svn/text-base/cns3xxx.sh.svn-base @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Copyright (C) 2012 OpenWrt.org +# + +cns3xxx_board_name() { + local machine + local name + + machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /Hardware/ {print $2}' /proc/cpuinfo) + + case "$machine" in + "Gateworks Corporation Laguna"*) + name="laguna" + ;; + *) + name="generic"; + ;; + esac + + echo $name +} diff --git a/target/linux/cns3xxx/base-files/lib/cns3xxx.sh b/target/linux/cns3xxx/base-files/lib/cns3xxx.sh new file mode 100644 index 0000000..476f9be --- /dev/null +++ b/target/linux/cns3xxx/base-files/lib/cns3xxx.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Copyright (C) 2012 OpenWrt.org +# + +cns3xxx_board_name() { + local machine + local name + + machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /Hardware/ {print $2}' /proc/cpuinfo) + + case "$machine" in + "Gateworks Corporation Laguna"*) + name="laguna" + ;; + *) + name="generic"; + ;; + esac + + echo $name +} diff --git a/target/linux/cns3xxx/base-files/lib/upgrade/.svn/entries b/target/linux/cns3xxx/base-files/lib/upgrade/.svn/entries new file mode 100644 index 0000000..1b76e6e --- /dev/null +++ b/target/linux/cns3xxx/base-files/lib/upgrade/.svn/entries @@ -0,0 +1,62 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/target/linux/cns3xxx/base-files/lib/upgrade +svn://svn.openwrt.org/openwrt + + + +2012-10-07T23:24:02.760166Z +33650 +nbd + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +platform.sh +file + + + + +2013-03-17T12:13:04.000000Z +37d55efab05b61fcdb376e8ccfa5a31d +2012-10-07T23:24:02.760166Z +33650 +nbd + + + + + + + + + + + + + + + + + + + + + +2970 + diff --git a/target/linux/cns3xxx/base-files/lib/upgrade/.svn/text-base/platform.sh.svn-base b/target/linux/cns3xxx/base-files/lib/upgrade/.svn/text-base/platform.sh.svn-base new file mode 100644 index 0000000..5990991 --- /dev/null +++ b/target/linux/cns3xxx/base-files/lib/upgrade/.svn/text-base/platform.sh.svn-base @@ -0,0 +1,122 @@ +. /lib/cns3xxx.sh + +RAMFS_COPY_DATA="/lib/cns3xxx.sh" + +CI_BLKSZ=65536 + +platform_find_partitions() { + local first dev size erasesize name + while read dev size erasesize name; do + name=${name#'"'}; name=${name%'"'} + case "$name" in + vmlinux.bin.l7|kernel|linux|rootfs) + if [ -z "$first" ]; then + first="$name" + else + echo "$erasesize:$first:$name" + break + fi + ;; + esac + done < /proc/mtd +} + +platform_find_kernelpart() { + local part + for part in "${1%:*}" "${1#*:}"; do + case "$part" in + vmlinux.bin.l7|kernel|linux) + echo "$part" + break + ;; + esac + done +} + +platform_do_upgrade_combined() { + local partitions=$(platform_find_partitions) + local kernelpart=$(platform_find_kernelpart "${partitions#*:}") + local erase_size=$((0x${partitions%%:*})); partitions="${partitions#*:}" + local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null) + local kern_blocks=$(($kern_length / $CI_BLKSZ)) + local root_blocks=$((0x$(dd if="$1" bs=2 skip=5 count=4 2>/dev/null) / $CI_BLKSZ)) + + v "platform_do_upgrade_combined" + v "partitions=$partitions" + v "kernelpart=$kernelpart" + v "erase_size=$erase_size" + v "kern_blocks=$kern_blocks" + v "root_blocks=$root_blocks" + + if [ -n "$partitions" ] && [ -n "$kernelpart" ] && \ + [ ${kern_blocks:-0} -gt 0 ] && \ + [ ${root_blocks:-0} -gt 0 ] && \ + [ ${erase_size:-0} -gt 0 ]; + then + local append="" + [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR" + + dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null | mtd write - kernel + dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null | \ + mtd -r $append write - rootfs + else + echo "invalid image" + fi +} + +platform_check_image() { + local board=$(cns3xxx_board_name) + local magic="$(get_magic_word "$1")" + local magic_long="$(get_magic_long "$1")" + + [ "$ARGC" -gt 1 ] && return 1 + + case "$board" in + laguna) + [ "$magic" != "4349" ] && { + echo "Invalid image. Use *-sysupgrade.bin files on this board" + return 1 + } + + local md5_img=$(dd if="$1" bs=2 skip=9 count=16 2>/dev/null) + local md5_chk=$(dd if="$1" bs=$CI_BLKSZ skip=1 2>/dev/null | md5sum -); md5_chk="${md5_chk%% *}" + + if [ -n "$md5_img" -a -n "$md5_chk" ] && [ "$md5_img" = "$md5_chk" ]; then + return 0 + else + echo "Invalid image. Contents do not match checksum (image:$md5_img calculated:$md5_chk)" + return 1 + fi + return 0 + ;; + esac + + echo "Sysupgrade is not yet supported on $board." + return 1 +} + +platform_do_upgrade() { + local board=$(cns3xxx_board_name) + + v "board=$board" + case "$board" in + laguna) + platform_do_upgrade_combined "$ARGV" + ;; + *) + default_do_upgrade "$ARGV" + ;; + esac +} + +disable_watchdog() { + v "killing watchdog" + killall watchdog + ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && { + echo 'Could not disable watchdog' + return 1 + } +} + +# CONFIG_WATCHDOG_NOWAYOUT=y - can't kill watchdog unless kernel cmdline has a mpcore_wdt.nowayout=0 +#append sysupgrade_pre_upgrade disable_watchdog diff --git a/target/linux/cns3xxx/base-files/lib/upgrade/platform.sh b/target/linux/cns3xxx/base-files/lib/upgrade/platform.sh new file mode 100644 index 0000000..5990991 --- /dev/null +++ b/target/linux/cns3xxx/base-files/lib/upgrade/platform.sh @@ -0,0 +1,122 @@ +. /lib/cns3xxx.sh + +RAMFS_COPY_DATA="/lib/cns3xxx.sh" + +CI_BLKSZ=65536 + +platform_find_partitions() { + local first dev size erasesize name + while read dev size erasesize name; do + name=${name#'"'}; name=${name%'"'} + case "$name" in + vmlinux.bin.l7|kernel|linux|rootfs) + if [ -z "$first" ]; then + first="$name" + else + echo "$erasesize:$first:$name" + break + fi + ;; + esac + done < /proc/mtd +} + +platform_find_kernelpart() { + local part + for part in "${1%:*}" "${1#*:}"; do + case "$part" in + vmlinux.bin.l7|kernel|linux) + echo "$part" + break + ;; + esac + done +} + +platform_do_upgrade_combined() { + local partitions=$(platform_find_partitions) + local kernelpart=$(platform_find_kernelpart "${partitions#*:}") + local erase_size=$((0x${partitions%%:*})); partitions="${partitions#*:}" + local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null) + local kern_blocks=$(($kern_length / $CI_BLKSZ)) + local root_blocks=$((0x$(dd if="$1" bs=2 skip=5 count=4 2>/dev/null) / $CI_BLKSZ)) + + v "platform_do_upgrade_combined" + v "partitions=$partitions" + v "kernelpart=$kernelpart" + v "erase_size=$erase_size" + v "kern_blocks=$kern_blocks" + v "root_blocks=$root_blocks" + + if [ -n "$partitions" ] && [ -n "$kernelpart" ] && \ + [ ${kern_blocks:-0} -gt 0 ] && \ + [ ${root_blocks:-0} -gt 0 ] && \ + [ ${erase_size:-0} -gt 0 ]; + then + local append="" + [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR" + + dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null | mtd write - kernel + dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null | \ + mtd -r $append write - rootfs + else + echo "invalid image" + fi +} + +platform_check_image() { + local board=$(cns3xxx_board_name) + local magic="$(get_magic_word "$1")" + local magic_long="$(get_magic_long "$1")" + + [ "$ARGC" -gt 1 ] && return 1 + + case "$board" in + laguna) + [ "$magic" != "4349" ] && { + echo "Invalid image. Use *-sysupgrade.bin files on this board" + return 1 + } + + local md5_img=$(dd if="$1" bs=2 skip=9 count=16 2>/dev/null) + local md5_chk=$(dd if="$1" bs=$CI_BLKSZ skip=1 2>/dev/null | md5sum -); md5_chk="${md5_chk%% *}" + + if [ -n "$md5_img" -a -n "$md5_chk" ] && [ "$md5_img" = "$md5_chk" ]; then + return 0 + else + echo "Invalid image. Contents do not match checksum (image:$md5_img calculated:$md5_chk)" + return 1 + fi + return 0 + ;; + esac + + echo "Sysupgrade is not yet supported on $board." + return 1 +} + +platform_do_upgrade() { + local board=$(cns3xxx_board_name) + + v "board=$board" + case "$board" in + laguna) + platform_do_upgrade_combined "$ARGV" + ;; + *) + default_do_upgrade "$ARGV" + ;; + esac +} + +disable_watchdog() { + v "killing watchdog" + killall watchdog + ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && { + echo 'Could not disable watchdog' + return 1 + } +} + +# CONFIG_WATCHDOG_NOWAYOUT=y - can't kill watchdog unless kernel cmdline has a mpcore_wdt.nowayout=0 +#append sysupgrade_pre_upgrade disable_watchdog |