Changeset 47881


Ignore:
Timestamp:
2015-12-12T08:38:06+01:00 (2 years ago)
Author:
blogic
Message:

ramips: add support for Ubiquiti EdgeRouter X (UBNT-ERX)

This router is based on MT7621 SoC, no wifi, no usb, nand.

Works:

  • Boots.
  • Ethernet.
  • Switch.
  • Button (reset).
  • Flashing OpenWrt from stock firmware.
  • Upgrading OpenWrt.

Doesn't work:

  • No GPIO leds. All leds are controlled by switch, but stock firmware was able to control them.
  • SoC has crypto engine but no open driver.
  • SoC has nat acceleration, but no open driver.
  • This router has 2MB spi flash soldered in but MT nand/spi drivers do not support pin sharing, so it is not accessable and disabled. Stock firmware could read it and it was empty.
  • PoE out.

Router has serial pins populated. If looking at the top
of the router, then counting from Eth sockets pins go as:
'GND, RX, TX, GND'. 3.3v, 57600.

U-boot bootloader supports tftpboot, controlled from serial.
This router has two kernel partitions: 'live' and 'backup'.
They are swapped during flashing (on both stock and OpenWrt).
Active partition is controlled by a flag in a factory partition.
U-boot has custom command to switch active kernel partition.
Kernel partitions are 'bare flash' 3MB. Stock bootloader has
no UBI support. Stock rootfs is UBIFS.

Flashing procedure.
Stock firmware uses custom kernel patch to mount squashfs
from a file that is located on UBIFS volume. This makes wiping
out this volume from within stock firmware difficult.
Instead this patch builds image that is flashable by stock firmware
and contains initrams image (with minimal set of packages
to fit into kernel partition). Once this is flashed one can reboot
into initramfs OpenWrt and use sysupgrade to flash OpenWrt including
rootfs into nand.
Note: factory image is only built if initramfs image is enabled.

Signed-off-by: Nikolay Martynov <mar.kolya@…>

Location:
trunk/target/linux/ramips
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/ramips/base-files/etc/board.d/02_network

    r47867 r47881  
    115115        hg255d|\ 
    116116        rt-n14u|\ 
     117        ubnt-erx|\ 
    117118        ur-326n4g|\ 
    118119        wrtnode|\ 
  • trunk/target/linux/ramips/base-files/lib/ramips.sh

    r47845 r47881  
    350350                name="tew-692gr" 
    351351                ;; 
     352        *"UBNT-ERX") 
     353                name="ubnt-erx" 
     354                ;; 
    352355        *"UR-326N4G") 
    353356                name="ur-326n4g" 
     
    400403        *"WizFi630A") 
    401404                name="wizfi630a" 
    402                 ;;                 
     405                ;; 
    403406        *"WL-330N") 
    404407                name="wl-330n" 
  • trunk/target/linux/ramips/base-files/lib/upgrade/platform.sh

    r47845 r47881  
    183183                return 0 
    184184                ;; 
     185        ubnt-erx) 
     186                nand_do_platform_check "$board" "$1" 
     187                return $?; 
     188                ;; 
    185189        esac 
    186190 
    187191        echo "Sysupgrade is not yet supported on $board." 
    188192        return 1 
     193} 
     194 
     195platform_nand_pre_upgrade() { 
     196        local board=$(ramips_board_name) 
     197 
     198        case "$board" in 
     199        ubnt-erx) 
     200                platform_upgrade_ubnt_erx "$ARGV" 
     201                ;; 
     202        esac 
     203} 
     204 
     205platform_pre_upgrade() { 
     206        local board=$(ramips_board_name) 
     207 
     208        case "$board" in 
     209        ubnt-erx) 
     210                nand_do_upgrade "$ARGV" 
     211                ;; 
     212        esac 
    189213} 
    190214 
  • trunk/target/linux/ramips/image/Makefile

    r47845 r47881  
    6868        ) > $@.new 
    6969        mv $@.new $@ 
     70endef 
     71 
     72define Build/ubnt-erx-factory-compat 
     73        echo '21001:6' > $@.compat 
     74        $(TAR) -cf $@ --transform='s/^.*/compat/' $@.compat 
     75        $(RM) $@.compat 
     76endef 
     77 
     78define Build/ubnt-erx-factory-kernel 
     79        if [ -e $(BIN_DIR)/$(KERNEL_INITRAMFS_IMAGE) ]; then \ 
     80                $(TAR) -rf $@ --transform='s/^.*/vmlinux.tmp/' $(BIN_DIR)/$(KERNEL_INITRAMFS_IMAGE); \ 
     81                \ 
     82                md5sum --binary $(BIN_DIR)/$(KERNEL_INITRAMFS_IMAGE) | awk '{print $$1}'> $@.md5; \ 
     83                $(TAR) -rf $@ --transform='s/^.*/vmlinux.tmp.md5/' $@.md5; \ 
     84                $(RM) $@.md5; \ 
     85        fi 
     86endef 
     87 
     88define Build/ubnt-erx-factory-rootfs 
     89        echo "dummy" > $@.rootfs 
     90        $(TAR) -rf $@ --transform='s/^.*/squashfs.tmp/' $@.rootfs 
     91 
     92        md5sum --binary $@.rootfs | awk '{print $$1}'> $@.md5 
     93        $(TAR) -rf $@ --transform='s/^.*/squashfs.tmp.md5/' $@.md5 
     94        $(RM) $@.md5 
     95        $(RM) $@.rootfs 
     96endef 
     97 
     98define Build/ubnt-erx-factory-version 
     99        echo '$(BOARD) $(VERSION_CODE) $(VERSION_NUMBER)' > $@.version 
     100        $(TAR) -rf $@ --transform='s/^.*/version.tmp/' $@.version 
     101        $(RM) $@.version 
     102endef 
     103 
     104#We need kernel+initrams fit into kernel partition 
     105define Build/ubnt-erx-factory-check-size 
     106        @[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$($(TAR) -xf $@ vmlinux.tmp -O | wc -c)" ] || { \ 
     107                echo "WARNING: Initramfs kernel for image $@ is too big (kernel size: $$($(TAR) -xf $@ vmlinux.tmp -O | wc -c), max size $(1))" >&2; \ 
     108                $(RM) -f $@; \ 
     109        } 
     110 
     111        @[ "$$($(TAR) -xf $@ vmlinux.tmp -O | wc -c)" -gt 0 ] || { \ 
     112                echo "WARNING: Kernel for image $@ not found" >&2; \ 
     113                $(RM) -f $@; \ 
     114        } 
    70115endef 
    71116 
     
    9551000 
    9561001ifeq ($(SUBTARGET),mt7621) 
    957   TARGET_DEVICES += mt7621 wsr-600 wsr-1166 dir-860l-b1 firewrt pbr-m1 re6500 sap-g3200u3 witi wf-2881 zbt-wg2626 
     1002  TARGET_DEVICES += mt7621 wsr-600 wsr-1166 dir-860l-b1 firewrt pbr-m1 re6500 sap-g3200u3 ubnt-erx witi wf-2881 zbt-wg2626 
    9581003endif 
    9591004 
     
    10241069endef 
    10251070 
     1071define Device/ubnt-erx 
     1072  DTS := UBNT-ERX 
     1073  FILESYSTEMS := squashfs 
     1074  KERNEL_SIZE := 3145728 
     1075  KERNEL := $(KERNEL_DTB) | uImage lzma 
     1076  IMAGES := sysupgrade.tar factory-initramfs.tar 
     1077  IMAGE/factory-initramfs.tar := ubnt-erx-factory-compat | \ 
     1078                                 ubnt-erx-factory-kernel | \ 
     1079                                 ubnt-erx-factory-rootfs | \ 
     1080                                 ubnt-erx-factory-version | \ 
     1081                                 ubnt-erx-factory-check-size $$$$(KERNEL_SIZE) 
     1082  IMAGE/sysupgrade.tar := sysupgrade-nand 
     1083endef 
     1084 
    10261085# 
    10271086# MT7628 Profiles 
Note: See TracChangeset for help on using the changeset viewer.