Xiaomi mi wifi 3 support

Try this layout in mi3 dts and remove it from 7620.dtsi

But I haven't found a driver that parses it, so if it doesn't work, try copying and adjusting this patch

I have copied the patch but unfortunately it will require adjustments as it spews out errors.
Unfortunately,I have no idea where to start

according to this patch oobavail is in struct 'mtd' and not in 'ecclayout' anymore

But in ramips patch it points to ecclayout still

Seems like you need to make 1 more pointer to point to mtd->ooblayout, but that may require more work

In functions where you find 'ra->oob->oobavail'
Add the pointer 'struct mtd_info *mtd'

And then replace ''ra->oob->oobavail'' with 'mtd->oobavail'

Let's see how it goes

Or try just replacing it with 'ranfc_mtd->oobavail' without additional structs


Ok,I will try it.

I tried to follow your instructions but failed.
Any chance you are willing to make those changes.
You can make a PR or tell me your github email to grant you access.

Okay, let's go the way around. Revert all your changes and replace every 'ra->oob->oobavail' with 'RA_CHIP_OOB_AVAIL' throughout the patch

Tried that,unfortunately there are still errors.

Copy


To line 67 or somewhere near

Ok,copied.
Trying to build it now.

Don't forget to increment


Should be 2137 now

I think it will not change as I used empty line that was already added

Unfortunately,the same error is present

Also,kernel was bumped to 4.9 although lack of NAND support was known

It's 1 error less now, will see if I can workaround this one

In meantime I am trying to build using last code prior to kernel 4.9 being used.

I have managed to build version with 4.4 kernel.
@dgiese Can you try this image?
https://drive.google.com/drive/folders/0B1VOQQ-_EIXKbFIxY1UyT3FlUFk

Hi, i tried the image with initramfs because i am a little more careful now :wink:
I could boot it and saw the nand partitions (they are a little different as i tried out a different rom in the mean time).

root@LEDE:/# cat /proc/mtd
bin/      etc/      lib/      overlay/  rom/      sbin/     tmp/      var/
dev/      init      mnt/      proc/     root/     sys/      usr/      www/
root@LEDE:/# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "Bootloader"
mtd1: 00040000 00020000 "Config"
mtd2: 00040000 00020000 "Bdata"
mtd3: 00040000 00020000 "Factory"
mtd4: 00040000 00020000 "crash"
mtd5: 00040000 00020000 "crash_syslog"
mtd6: 00080000 00020000 "reserved0"
mtd7: 00400000 00020000 "kernel_erase"
mtd8: 00400000 00020000 "kernel"
mtd9: 07600000 00020000 "ubi"
root@LEDE:/# cat /dev/
bus/                mtd3ro              mtdblock1           ptmx
console             mtd4                mtdblock2           pts/
cpu_dma_latency     mtd4ro              mtdblock3           random
full                mtd5                mtdblock4           shm/
kmsg                mtd5ro              mtdblock5           tty
log                 mtd6                mtdblock6           ttyS0
memory_bandwidth    mtd6ro              mtdblock7           ttyS1
mtd0                mtd7                mtdblock8           urandom
mtd0ro              mtd7ro              mtdblock9           watchdog
mtd1                mtd8                network_latency     watchdog0
mtd1ro              mtd8ro              network_throughput  zero
mtd2                mtd9                null
mtd2ro              mtd9ro              port
mtd3                mtdblock0           ppp

Awesome,that confirms that current 4.9 kernel is missing NAND driver patch.
I will try tommorow on mine to see if ethernet ports are correct

Any idea how to restore the original nand layout? the original kernel had a device (mtd0) which mapped the whole nand storage.
I uploaded the original log here:
https://wiki.openwrt.org/toh/xiaomi/mir3

I think that USB recovery should work.
So copy stock firmware to usb and rename it to miwifi.bin,plug into router and hold reset while turning on.
When LED starts flashing it is flashing firmware

Hi,
so the reset key recovery did not work for me, however after i erased the content of the kernel1 partition and the root partiton, i got a prompt at the next boot and the original firmware was restored from the miwifi.bin-file on the usb stick.

One thing i noticed then i tried to start your image from nand (however with custom uboot and slightly different root partition names):

U-Boot 1.1.3 (VORTEX)

Board: Ralink APSoC DRAM:  128 MB
Power on memory test. Memory size= 128 MB...OK!
relocate_code Pointer at: 87fb8000
enable ephy clock...done. rf reg 29 = 5
SSC disabled.
******************************
Software System Reset Occurred
******************************
!!! nand page size = 2048, addr len=4
..============================================
Ralink UBoot Version: 4.2.S.1
--------------------------------------------
ASIC 7620_MP (Port5<->None)
DRAM_CONF_FROM: Auto-detection
DRAM_TYPE: DDR2
DRAM component: 1024 Mbits
DRAM bus: 16 bit
Total memory: 128 MBytes
Flash component: NAND Flash
Date:Apr 15 2016  Time:17:46:32
============================================
icache: sets:512, ways:4, linesz:32 ,total:65536
dcache: sets:256, ways:4, linesz:32 ,total:32768

 ##### The CPU freq = 580 MHZ ####
 estimate memory size =128 Mbytes

Please choose the operation:
   1: Load system code to SDRAM via TFTP.
   2: Load system code then write to Flash via TFTP.
   3: Boot system code via Flash (default).
   4: Entr boot command line interface.
   9: Load Boot Loader code then write to Flash via TFTP.                                                                                                  0

3: System Boot system code via Flash.
Booting System 2
..ranand_erase_write: offs:40000, count:20000
.Done!
done
## Booting image at bc600000 ...
   Image Name:   MIPS LEDE Linux-4.4.47
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    1261440 Bytes =  1.2 MB
   Load Address: 80000000
   Entry Point:  80000000
....................   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
commandline uart_en=1 factory_mode=0 mem=128m
No initrd
## Transferring control to Linux (at address 80000000) ...
## Giving linux memsize in MB, 128

Starting kernel ...

[    0.000000] Linux version 4.4.47 (robimarko@LEDE) (gcc version 5.4.0 (LEDE GCC 5.4.0 r3437-78d8e6e) ) #0 Mon Aug 21 12:55:55 2017
[    0.000000] Board has DDR2
[    0.000000] Analog PMU set to hw control
[    0.000000] Digital PMU set to hw control
[    0.000000] SoC Type: MediaTek MT7620A ver:2 eco:6
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019650 (MIPS 24KEc)
[    0.000000] MIPS: machine is Xiaomi MiWiFi R3
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 08000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
[    0.000000] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2
[    0.000000] PID hash table entries: 512 (order: -1, 2048 bytes)
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Writing ErrCtl register=0007e000
[    0.000000] Readback ErrCtl register=0007e000
[    0.000000] Memory: 125736K/131072K available (2898K kernel code, 142K rwdata, 696K rodata, 160K init, 203K bss, 5336K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:256
[    0.000000] CPU Clock: 580MHz
[    0.000000] clocksource: systick: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 583261500 ns
[    0.000000] systick: enable autosleep mode
[    0.000000] systick: running - mult: 214748, shift: 32
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 6590553264 ns
[    0.000011] sched_clock: 32 bits at 290MHz, resolution 3ns, wraps every 7405115902ns
[    0.007570] Calibrating delay loop... 385.84 BogoMIPS (lpj=1929216)
[    0.070068] pid_max: default: 32768 minimum: 301
[    0.074690] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.081060] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.094829] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.104551] pinctrl core: initialized pinctrl subsystem
[    0.110282] NET: Registered protocol family 16
[    0.377723] PCI host bridge /pcie@10140000 ranges:
[    0.382333]  MEM 0x0000000020000000..0x000000002fffffff
[    0.387398]   IO 0x0000000010160000..0x000000001016ffff
[    0.401128] rt2880_gpio 10000600.gpio: registering 24 gpios
[    0.406519] rt2880_gpio 10000600.gpio: registering 24 irq handlers
[    0.412739] rt2880_gpio 10000638.gpio: registering 16 gpios
[    0.418106] rt2880_gpio 10000638.gpio: registering 16 irq handlers
[    0.424309] rt2880_gpio 10000660.gpio: registering 32 gpios
[    0.429677] rt2880_gpio 10000660.gpio: registering 32 irq handlers
[    0.436549] PCI host bridge to bus 0000:00
[    0.440478] pci_bus 0000:00: root bus resource [mem 0x20000000-0x2fffffff]
[    0.447187] pci_bus 0000:00: root bus resource [io  0xffffffff]
[    0.452892] pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]
[    0.459496] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    0.467687] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    0.476244] pci 0000:00:00.0: BAR 0: no space for [mem size 0x80000000]
[    0.482608] pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x80000000]
[    0.489418] pci 0000:00:00.0: BAR 8: assigned [mem 0x20000000-0x200fffff]
[    0.495964] pci 0000:00:00.0: BAR 9: assigned [mem 0x20100000-0x201fffff pref]
[    0.502989] pci 0000:00:00.0: BAR 1: assigned [mem 0x20200000-0x2020ffff]
[    0.509580] pci 0000:01:00.0: BAR 0: assigned [mem 0x20000000-0x200fffff 64bit]
[    0.516702] pci 0000:01:00.0: BAR 6: assigned [mem 0x20100000-0x2010ffff pref]
[    0.523686] pci 0000:00:00.0: PCI bridge to [bus 01]
[    0.528519] pci 0000:00:00.0:   bridge window [mem 0x20000000-0x200fffff]
[    0.535098] pci 0000:00:00.0:   bridge window [mem 0x20100000-0x201fffff pref]
[    0.542138] pci 0000:00:00.0: card - bus=0x0, slot = 0x0 irq=0
[    0.547781] pci 0000:01:00.0: card - bus=0x1, slot = 0x0 irq=4
[    0.554488] clocksource: Switched to clocksource systick
[    0.561070] NET: Registered protocol family 2
[    0.566219] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.572946] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.579168] TCP: Hash tables configured (established 1024 bind 1024)
[    0.585397] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.591026] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.597432] NET: Registered protocol family 1
[    0.606416] rt-timer 10000100.timer: maximum frequency is 1220Hz
[    0.613173] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.619227] Crashlog allocated RAM at address 0x3f00000
[    0.639866] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.645548] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.657825] io scheduler noop registered
[    0.661581] io scheduler deadline registered (default)
[    0.666872] ralink-usb-phy usbphy: invalid resource
[    0.672267] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.679621] console [ttyS0] disabled
[    0.683071] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 20, base_baud = 2500000) is a Palmchip BK-3103
[    0.692755] console [ttyS0] enabled
[    0.692755] console [ttyS0] enabled
[    0.699785] bootconsole [early0] disabled
[    0.699785] bootconsole [early0] disabled
[    0.709286] !!! nand page size = 2048, addr len=4
[    0.716548] mtk_nand_probe: alloc 1388, at 87c86000 , btt(87c870c0, 100), ranfc_mtd:87c871c0
[    0.725297] 10 ofpart partitions found on MTD device ra_nfc
[    0.730982] Creating 10 MTD partitions on "ra_nfc":
[    0.735982] 0x000000000000-0x000000040000 : "Bootloader"
[    0.743112] 0x000000040000-0x000000080000 : "Config"
[    0.750142] 0x000000080000-0x0000000c0000 : "Bdata"
[    0.757068] 0x0000000c0000-0x000000100000 : "Factory"
[    0.764103] 0x000000100000-0x000000140000 : "crash"
[    0.771065] 0x000000140000-0x000000180000 : "crash_syslog"
[    0.778651] 0x000000180000-0x000000200000 : "reserved0"
[    0.786012] 0x000000200000-0x000000600000 : "kernel_erase"
[    0.794229] 0x000000600000-0x000000a00000 : "kernel"
[    0.802024] 0x000000a00000-0x000008000000 : "ubi"
[    0.838105] gsw: setting port4 to ephy mode
[    0.842427] mtk_soc_eth 10100000.ethernet eth0 (uninitialized): port 1 link up (100Mbps/Full duplex)
[    0.852242] mtk_soc_eth 10100000.ethernet: loaded mt7620 driver
[    0.859108] mtk_soc_eth 10100000.ethernet eth0: mediatek frame engine at 0xb0100000, irq 5
[    0.868152] rt2880_wdt 10000120.watchdog: Initialized
[    0.874969] NET: Registered protocol family 10
[    0.883166] NET: Registered protocol family 17
[    0.887877] bridge: automatic filtering via arp/ip/ip6tables has been deprecated. Update your scripts to load br_netfilter if you need this.
[    0.900777] 8021q: 802.1Q VLAN Support v1.8
[    0.908345] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    0.916082] Please append a correct "root=" boot option; here are the available partitions:
[    0.924626] 1f00             256 mtdblock0  (driver?)
[    0.929788] 1f01             256 mtdblock1  (driver?)
[    0.934961] 1f02             256 mtdblock2  (driver?)
[    0.940121] 1f03             256 mtdblock3  (driver?)
[    0.945294] 1f04             256 mtdblock4  (driver?)
[    0.950460] 1f05             256 mtdblock5  (driver?)
[    0.955631] 1f06             512 mtdblock6  (driver?)
[    0.960789] 1f07            4096 mtdblock7  (driver?)
[    0.965960] 1f08            4096 mtdblock8  (driver?)
[    0.971117] 1f09          120832 mtdblock9  (driver?)
[    0.976287] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    0.986143] Rebooting in 1 seconds..