## Copyright (C) 2009 OpenWrt.org#SUBTARGET:=mt7620BOARDNAME:=MT7620 based boardsARCH_PACKAGES:=ramips_24kecFEATURES+=usb nand ubifsCPU_TYPE:=24kecCPU_SUBTYPE:=dspDEFAULT_PACKAGES += kmod-rt2800-pci kmod-rt2800-socdefine Target/DescriptionBuild firmware images for Ralink MT7620 based boards.endef
define Profile/DEMONAME:=DEMO routerendefdefine Profile/DEMO/DescriptionDefault package set compatible with DEMOendefDEMO_UBIFS_OPTS:="-m 2048 -e 124KiB -c 1024"DEMO_UBI_OPTS:="-m 2048 -p 128KiB -s 2048"$(eval $(call Profile,DEMO))
compatible = "LYNXUS, ZGW", "ralink,mt7620a-soc";model = "LYNXUS ZGW";chosen {bootargs = "console=ttyS1,57600";};nand {#address-cells = <1>;#size-cells = <1>;compatible = "mtk,mt7620-nand";partition@0 {label = "u-boot";reg = <0x00000000 0x00080000>;read-only;};partition@80000 {label = "u-boot-env";reg = <0x00080000 0x00080000>;};factory: partition@100000 {label = "factory";reg = <0x00100000 0x00040000>;read-only;};partition@140000 {label = "secure";reg = <0x00140000 0x00040000>;};partition@180000 {label = "reserved";reg = <0x00180000 0x00080000>;};partition@200000 {label = "firmware";reg = <0x00200000 0x08000000>;};partition@8200000 {label = "data1";reg = <0x08200000 0x04000000>;};partition@C200000 {label = "data2";reg = <0x0C200000 0x08000000>;};partition@14200000 {label = "data3";reg = <0x14200000 0x08000000>;};partition@1C200000 {label = "data4";reg = <0x1C200000 0x23E00000>;};};
ubinize.cfg:
[rootfs]
# Volume mode (other option is static)mode=ubi# Source imageimage=root.ubifs# Volume ID in UBI imagevol_id=0# Allow for dynamic resizevol_type=dynamic# Volume namevol_name=rootfs# Autoresize volume at first mountvol_flags=autoresizeubinize-overlay.cfg:
[rootfs]# Volume mode (other option is static)mode=ubi
# Source imageimage=root.squashfs# Volume ID in UBI imagevol_id=0# Allow for dynamic resizevol_type=dynamic# Volume namevol_name=rootfs[rootfs_data]# Volume mode (other option is static)mode=ubi# Volume ID in UBI imagevol_id=1# Allow for dynamic resizevol_type=dynamic# Volume namevol_name=rootfs_datavol_size=8MiB# Autoresize volume at first mountvol_flags=autoresize
define BuildFirmware/Demo/ubifs$(call MkImageLzmaDtb,$(2),$(3),$(4))dd if=$(KDIR)/vmlinux-$(2).uImage of=$(KDIR)/vmlinux-$(2).uImage.align.128k bs=128k conv=syncendefdefine BuildFirmware/Demo/ubi$(eval output_name=$(IMG_PREFIX)-$(2)-squashfs-sysupgrade.ubi)( \dd if=$(KDIR)/vmlinux-$(2).uImage.align.128k; \dd if=$(KDIR)/root-overlay.ubi \) > $(KDIR)/$(output_name)$(CP) $(KDIR)/$(output_name) $(BIN_DIR)/$(output_name)endef...Image/Build/Profile/DEMO=$(call BuildFirmware/Demo/$(1),$(1),demo,DEMO)ifeq ($(SUBTARGET),mt7620)define Image/Build/Profile/Default....$(call Image/Build/Profile/XIAOMI-MIWIFI-MINI,$(1))$(call Image/Build/Profile/ZTE-Q7,$(1))$(call Image/Build/Profile/ZBT-WA05,$(1))$(call Image/Build/Profile/ArcherC20i,$(1))$(call Image/Build/Profile/MicroWRT,$(1))$(call Image/Build/Profile/DEMO,$(1))endefendif
UBIFS error (pid 1): ubifs_mount: cannot open "ubi0:rootfs", error -19VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6Please append a correct "root=" boot option; here are the available partitions:1f00 512 mtdblock0 (driver?)1f01 512 mtdblock1 (driver?)1f02 256 mtdblock2 (driver?)1f03 256 mtdblock3 (driver?)
原因:mtdsplit驱动无法识别ubi,参考3.7合并最新mtdsplit驱动
2.bad write buffer szie,导致rootfs无法识别,错误如下
UBI: auto-attach mtd7
UBI: attaching mtd7 to ubi0
UBI error: io_init: bad write buffer size 0 for 2048 min. I/O unit
UBI error: ubi_auto_attach: cannot attach mtd7
UBIFS error (pid 1): ubifs_mount: cannot open "ubi0:rootfs", error -19
VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
1f00 512 mtdblock0 (driver?)
1f01 512 mtdblock1 (driver?)
1f02 256 mtdblock2 (driver?)
1f03 256 mtdblock3 (driver?)
原因:writebuffersize未被正确设置,参考3.6做修改
3.无法识别rootfs,代码都正确,错误如下
UBI: auto-attach mtd7
UBI: attaching mtd7 to ubi0
UBI: scanning is finished
UBI: attached mtd7 (name "ubi", size 126 MiB) to ubi0
UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
UBI: good PEBs: 1013, bad PEBs: 0, corrupted PEBs: 0
UBI: user volume: 2, internal volumes: 1, max. volumes count: 128
UBI: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 2143562307
UBI: available PEBs: 745, total reserved PEBs: 268, PEBs reserved for bad PEB handling: 160
UBI: background thread "ubi_bgt0d" started, PID 235
VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
1f00 512 mtdblock0 (driver?)
1f01 512 mtdblock1 (driver?)
1f02 256 mtdblock2 (driver?)
1f03 256 mtdblock3 (driver?)
1f04 512 mtdblock4 (driver?)
原因:我们使用的根文件系统仍然是squashfs,只不过是承载与ubi之上,必须选中Read-only block devices on top of UBI volumes才能识别squashfs,参考3.8.
4.overlay未被正确挂载,为只读,错误如下
UBIFS: read-only UBI device
UBIFS error (pid 365): mount_ubifs: can't format empty UBI volume: read-only UBI volume
mount_root: failed to mount -t ubifs /dev/ubi0_1 /tmp/overlay: Read-only file system
mount_root: overlay filesystem has not been fully initialized yet
mount_root: switching to jffs2 overlay
mount_root: switching to jffs2 failed - fallback to ramoverlay
root@OpenWrt:/# mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
tmpfs on /tmp/root type tmpfs (rw,noatime,mode=755)
overlayfs:/tmp/root on / type overlay (rw,noatime,lowerdir=/,upperdir=/tmp/root/upper,workdir=/tmp/root/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
原因:uimage未对齐就与ubi合并成sysupgrade文件,参考3.5中dd if=$(KDIR)/vmlinux-$(2).uImage of=$(KDIR)/vmlinux-$(2).uImage.align.128k bs=128k conv=sync
128K为nand flash的eraseblock的大小。
1.UBIFS_OPTS和UBI_OPTS
这两个配置的参数需要注意,可能与nand flash参数不匹配而导致异常。