From 3f7841a70a87b280103a2c51ac49fd1d90d42949 Mon Sep 17 00:00:00 2001 From: Thibaut VARENE Date: Wed, 4 Jan 2017 22:44:54 +0100 Subject: ar71xx: add support for RB-941-2nD Add full support for Mikrotik RB-941-2nD (hAP lite) Original patch by Sergey Sergeev and more information is available here: https://wiki.openwrt.org/toh/mikrotik/rb941_2nd I updated and adapted the patch to apply cleanly to LEDE trunk and added proper numbering for the switch ports (matching case labels). Tested working on actual hardware with the information provided in the above webpage. Sysupgrade works. Signed-off-by: Thibaut VARENE Signed-off-by: Felix Fietkau --- target/linux/ar71xx/base-files/etc/board.d/01_leds | 3 +++ .../linux/ar71xx/base-files/etc/board.d/02_network | 4 +++ target/linux/ar71xx/base-files/etc/diag.sh | 2 +- target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 +++ .../ar71xx/base-files/lib/upgrade/platform.sh | 29 +++++++++++++++++++--- 5 files changed, 37 insertions(+), 4 deletions(-) (limited to 'target/linux/ar71xx/base-files') diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds index 5a2bf0cfc4..84cfb1e616 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -201,6 +201,9 @@ rb-750) ucidef_set_led_switch "port4" "port4" "rb750:green:port4" "switch0" "0x04" ucidef_set_led_switch "port5" "port5" "rb750:green:port5" "switch0" "0x02" ;; +rb-941-2nd) + ucidef_set_led_timer "act" "act" "rb:green:act" "1000" "1000" + ;; rb-2011l|\ rb-2011uas|\ rb-2011uias|\ diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network index 66274db15f..d46266aa43 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -239,6 +239,10 @@ ar71xx_setup_interfaces() dap-2695-a1) ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1" ;; + rb-941-2nd) + ucidef_add_switch "switch0" \ + "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1" + ;; db120|\ rb-2011l|\ rb-2011uas|\ diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index d060ccf6e2..75c6c9acba 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -288,7 +288,7 @@ get_status_led() { rb-912uag-5hpnd) status_led="rb:green:user" ;; - rb-951ui-2hnd) + rb-951ui-2hnd | rb-941-2nd) status_led="rb:green:act" ;; rb-sxt2n|\ diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 1b30f4d827..7f27f45635 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -835,6 +835,9 @@ ar71xx_board_detect() { *"RouterBOARD 912UAG-5HPnD") name="rb-912uag-5hpnd" ;; + *"RouterBOARD 941-2nD") + name="rb-941-2nd" + ;; *"RouterBOARD 951G-2HnD") name="rb-951g-2hnd" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 82ed041d66..80da9131c7 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -12,6 +12,8 @@ RAMFS_COPY_DATA=/lib/ar71xx.sh CI_BLKSZ=65536 CI_LDADR=0x80060000 +PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD=0 + platform_find_partitions() { local first dev size erasesize name while read dev size erasesize name; do @@ -41,6 +43,13 @@ platform_find_kernelpart() { done } +platform_find_rootfspart() { + local part + for part in "${1%:*}" "${1#*:}"; do + [ "$part" != "$2" ] && echo "$part"; break + done +} + platform_do_upgrade_combined() { local partitions=$(platform_find_partitions) local kernelpart=$(platform_find_kernelpart "${partitions#*:}") @@ -54,13 +63,22 @@ platform_do_upgrade_combined() { [ ${root_blocks:-0} -gt 0 ] && \ [ ${erase_size:-0} -gt 0 ]; then + local rootfspart=$(platform_find_rootfspart "$partitions" "$kernelpart") 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; \ - dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null ) | \ - mtd -r $append -F$kernelpart:$kern_length:$CI_LDADR,rootfs write - $partitions + if [ "$PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD" -ne 1 ]; then + ( dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null; \ + dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null ) | \ + mtd -r $append -F$kernelpart:$kern_length:$CI_LDADR,rootfs write - $partitions + elif [ -n "$rootfspart" ]; then + dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null | \ + mtd write - $kernelpart + dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null | \ + mtd -r $append write - $rootfspart + fi fi + PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD=0 } tplink_get_image_hwid() { @@ -318,6 +336,7 @@ platform_check_image() { ls-sr71|\ pb42|\ pb44|\ + rb-941-2nd|\ routerstation-pro|\ routerstation|\ wp543|\ @@ -618,6 +637,10 @@ platform_do_upgrade() { local board=$(ar71xx_board_name) case "$board" in + rb-941-2nd) + PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD=1 + platform_do_upgrade_combined "$ARGV" + ;; all0258n) platform_do_upgrade_allnet "0x9f050000" "$ARGV" ;; -- cgit v1.2.3