2017-9-18-how to recover ubnt-erx image
2017-9-18-how to recover ubnt-erx image
Steps
- load initramfs image by uboot
- wget http://image.oakridge.vip:8000/images/ap/ubnterx/recover-ubnt-erx.tar.tar.gz
- tar xf recover-ubnt-erx.tar.tar.gz
- sysupgrade -n *.tar
- ubidetach -m 5
- ubiformat /dev/mtd5
- ubiattach -p /dev/mtd5
- ubimkvol /dev/ubi0 --vol_id=0 --lebs=1925 --name=troot
- mount -o sync -t ubifs ubi0:troot /mnt
- download ubnt image and untar it
- wget http://image.oakridge.vip:8000/images/ap/ubnterx/origin_ER-e50.v1.7.0.4783374.tar.tar.gz
- tar xf *.tar.gz
- tar xf *.tar
- you can find version.tmp, kernel.tmp, squashfs.tmp etc
- mtd write kernel.tmp kernel1
- mtd write kernel.tmp kernel2
- cp /tmp/version.tmp /mnt/version
- cp /tmp/squashfs.tmp /mnt/squashfs.img
- cp /tmp/squashfs.tmp.md5 /mnt/squashfs.img.md5
- reboot
Image Generator Analysis
assumpe PWD: osdk_repos/target/linux/ramips
- BOARDNAME:=MediaTek Ralink MIPS@Makefile
- SUBTARGETS:=mt7621
- SUBTARGET:=mt7621@mt7621/target.mk
- BOARDNAME:=MT7621 based boards
- FEATURES+=nand ramdisk rtc usb
- DEFAULT_PACKAGES+=kmod-mt76
- Profile/Default@mt7621/profiles/00-default.mk
- Device/ubnt-erx@image/mt7621.mk
- DTS:=UBNT-ERX
- KERNEL_INITRAMFS:=$$(KERNEL) | ubnt-erx-factory-image
- DEVICE_TITLE:=Ubiquiti EdgeRouter X
- Build/ubnt-erx-factory-image
- $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE)
- Profile/Default@mt7621/profiles/00-default.mk
- include mt7621.mk
- call BuildImage
- define BuildImage@include/image.mk
- $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))
- define Device@include/image.mk
- $(call Device/InitProfile,$(1))
- $(call Device/Init,$(1))
- $(call Device/Default,$(1))
- $(call Device/$(1),$(1))
- $(call Device/Check,$(1))
- $(call Device/$(if $(DUMP),Dump,Build),$(1))
- define Device/Build/image@include/image.mk
MTK Image
- $(eval $(call BuildImage))
- define BuildImage@include/image.mk
- $(call Image/BuildKernel)
- define Image/BuildKernel@target/linux/ramips/image/Makefile
- $(call Image/Build/Initramfs)
- define Image/Build/Initramfs
- $(call Image/Build/Profile/$(PROFILE),initramfs)
- $(call BuildFirmware/Default8M/$(1),$(1),mt7621,MT7621)
- $(call BuildFirmware/OF/Initramfs,$(1),$(2),$(3),$(4))
- $(call BuildFirmware/OF/initramfs,mt7621,MT762,null)
- $(call MkImageLzmaDtb,$(2),$(3),$(4),-initramfs)
- $(CP) $(KDIR)/vmlinux-$(2)-initramfs.uImage $(call imgname,$(1),$(2)-uImage.bin
- $(call BuildFirmware/Default8M/$(1),$(1),mt7621,MT7621)
- $(call Image/Build/Profile/$(PROFILE),initramfs)
- define Image/Build/Initramfs
- $(call Image/BuildKernel/Initramfs)
- Image/BuildKernel/Initramfs@include/Makefile
- $(call Image/Build/Initramfs)
- Image/BuildKernel/Initramfs@include/Makefile
- $(call Image/InstallKernel)
- $(call Image/mkfs/jffs2_nand)
- $(call Image/mkfs/squashfs)
- $(call Image/Build,squashfs)@target
- $(call Image/Build/squashfs)
- $(call Image/Build/Profile/UBNT-ERX,squashfs)
- $(call BuildFirmware/Defaul8M/squashfs)
- $(call BuildFirmware/OF,squashfs,mt7621,MT7621,$(ralink_default_fw_size_8M),null)
- $(call Image/Build/squashfs)
- $(call Image/Build,squashfs)@target
- $(call Image/mkfs/ubifs)
- $(call Image/Build,ubifs)
- $(call Image/Build/Profile/UBNT-ERX,$(1))
- $(call Image/Checksum)
- $(call Image/BuildKernel)
- Profile/Default@ubnt.mk
- define Image/Build/Profile/Default
- Image/Build/Profile/MT7621,$(1)
- BuildFirmware/Default8M/$(1),$(1),mt7621,MT7621)
lede build log
- 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
- Image Name: MIPS LEDE Linux-4.4.83
- Created: Tue Sep 19 02:31:37 2017
- Image Type: MIPS Linux Kernel Image (lzma compressed)
- Data Size: 1526852 Bytes = 1491.07 kB = 1.46 MB
- Load Address: 80001000
- Entry Point: 80001000
- [ -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 ]
- 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
- tar: Option --mtime: Treating date '@1505788297' as 2017-09-19 02:31:37
- sysupgrade-ubnt-erx/
- sysupgrade-ubnt-erx/kernel
- sysupgrade-ubnt-erx/CONTROL
- sysupgrade-ubnt-erx/root
- 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
- 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
- /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
-