2017-9-18-how to recover ubnt-erx image

2017-9-18-how to recover ubnt-erx image

Steps

  1. load initramfs image by uboot
  2. ubidetach -m 5
  3. ubiformat /dev/mtd5
  4. ubiattach -p /dev/mtd5
  5. ubimkvol /dev/ubi0 --vol_id=0 --lebs=1925 --name=troot
  6. mount -o sync -t ubifs ubi0:troot /mnt
  7. download ubnt image and untar it
  8. mtd write kernel.tmp kernel1
  9. mtd write kernel.tmp kernel2
  10. cp /tmp/version.tmp /mnt/version
  11. cp /tmp/squashfs.tmp /mnt/squashfs.img
  12. cp /tmp/squashfs.tmp.md5 /mnt/squashfs.img.md5
  13. reboot

Image Generator Analysis

assumpe PWD: osdk_repos/target/linux/ramips

  1. BOARDNAME:=MediaTek Ralink MIPS@Makefile
  2. SUBTARGETS:=mt7621
    1. SUBTARGET:=mt7621@mt7621/target.mk
    2. BOARDNAME:=MT7621 based boards
    3. FEATURES+=nand ramdisk rtc usb
    4. DEFAULT_PACKAGES+=kmod-mt76
      1. Profile/Default@mt7621/profiles/00-default.mk
        1. Device/ubnt-erx@image/mt7621.mk
        2. DTS:=UBNT-ERX
        3. KERNEL_INITRAMFS:=$$(KERNEL) | ubnt-erx-factory-image
        4. DEVICE_TITLE:=Ubiquiti EdgeRouter X
          1. Build/ubnt-erx-factory-image
          2. $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE)
  3. include mt7621.mk
  4. call BuildImage
    1. define BuildImage@include/image.mk
    2. $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))
    3. define Device@include/image.mk
      1. $(call Device/InitProfile,$(1))
      2. $(call Device/Init,$(1))
      3. $(call Device/Default,$(1))
      4. $(call Device/$(1),$(1))
      5. $(call Device/Check,$(1))
      6. $(call Device/$(if $(DUMP),Dump,Build),$(1))
        1. define Device/Build/image@include/image.mk

MTK Image

  1. $(eval $(call BuildImage))
  2. define BuildImage@include/image.mk
    1. $(call Image/BuildKernel)
      1. define Image/BuildKernel@target/linux/ramips/image/Makefile
      2. $(call Image/Build/Initramfs)
        1. define Image/Build/Initramfs
          1. $(call Image/Build/Profile/$(PROFILE),initramfs)
            1. $(call BuildFirmware/Default8M/$(1),$(1),mt7621,MT7621)
              1. $(call BuildFirmware/OF/Initramfs,$(1),$(2),$(3),$(4))
              2. $(call BuildFirmware/OF/initramfs,mt7621,MT762,null)
                1. $(call MkImageLzmaDtb,$(2),$(3),$(4),-initramfs)
                2. $(CP) $(KDIR)/vmlinux-$(2)-initramfs.uImage $(call imgname,$(1),$(2)-uImage.bin
    2. $(call Image/BuildKernel/Initramfs)
      1. Image/BuildKernel/Initramfs@include/Makefile
        1. $(call Image/Build/Initramfs)
    3. $(call Image/InstallKernel)
    4. $(call Image/mkfs/jffs2_nand)
    5. $(call Image/mkfs/squashfs)
      1. $(call Image/Build,squashfs)@target
        1. $(call Image/Build/squashfs)
          1. $(call Image/Build/Profile/UBNT-ERX,squashfs)
          2. $(call BuildFirmware/Defaul8M/squashfs)
            1. $(call BuildFirmware/OF,squashfs,mt7621,MT7621,$(ralink_default_fw_size_8M),null)
    6. $(call Image/mkfs/ubifs)
      1. $(call Image/Build,ubifs)
      2. $(call Image/Build/Profile/UBNT-ERX,$(1))
    7. $(call Image/Checksum)
  3. Profile/Default@ubnt.mk
  4. define Image/Build/Profile/Default
  5. Image/Build/Profile/MT7621,$(1)
  6. BuildFirmware/Default8M/$(1),$(1),mt7621,MT7621)

lede build log

  1. mkimage -A mips -O linux -T kernel -C lzma -a 0x80001000 -e 0x80001000 -n 'MIPS LEDE Linux-4.4.83' -d /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/ubnt-erx-kernel.bin /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/ubnt-erx-kernel.bin.new 
  2. Image Name: MIPS LEDE Linux-4.4.83 
  3. Created: Tue Sep 19 02:31:37 2017 
  4. Image Type: MIPS Linux Kernel Image (lzma compressed) 
  5. Data Size: 1526852 Bytes = 1491.07 kB = 1.46 MB 
  6. Load Address: 80001000 
  7. Entry Point: 80001000 
  8. [ -f /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/ubnt-erx-kernel.bin -a -f /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/root.squashfs ] 
  9. sh /home/llwang/repos/master_for_lede-17.07/osdk_repos/scripts/sysupgrade-tar.sh --board ubnt-erx --kernel /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/ubnt-erx-kernel.bin --rootfs /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/root.squashfs /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/tmp/lede-ramips-mt7621-ubnt-erx-squashfs-sysupgrade.tar 
  10. tar: Option --mtime: Treating date '@1505788297' as 2017-09-19 02:31:37 
  11. sysupgrade-ubnt-erx/ 
  12. sysupgrade-ubnt-erx/kernel 
  13. sysupgrade-ubnt-erx/CONTROL 
  14. sysupgrade-ubnt-erx/root 
  15. echo '{ "supported_devices":["ubnt-erx"], "version": { "dist": "LEDE", "version": "17.01-SNAPSHOT", "revision": "r40-ddccacd", "board": "ramips" } }' | fwtool -I - /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/tmp/lede-ramips-mt7621-ubnt-erx-squashfs-sysupgrade.tar 
  16. cp /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/tmp/lede-ramips-mt7621-ubnt-erx-squashfs-sysupgrade.tar /home/llwang/repos/master_for_lede-17.07/osdk_repos/bin/targets/ramips/mt7621/lede-ramips-mt7621-ubnt-erx-squashfs-sysupgrade.tar 
  17. /home/llwang/repos/master_for_lede-17.07/osdk_repos/staging_dir/host/bin/opkg --offline-root /home/llwang/repos/master_for_lede-17.07/osdk_repos/build_dir/target-mipsel_24kc_musl-1.1.16/root-ramips --add-arch all:100 --add-arch mipsel_24kc:200 list-installed > /home/llwang/repos/master_for_lede-17.07/osdk_repos/bin/targets/ramips/mt7621/lede-ramips-mt7621-device-ubnt-erx.manifest 
  18.  

nicephil@gmail.com

posted on 2017-09-18 15:09  nicephil  阅读(552)  评论(0编辑  收藏  举报

导航