Build Xiaomi R3G (v1 ) with 32M spi flash

i have the original flash memory destroyed

I simply cut the legs of the memory and cleaned the circuit prints
I soldered the new 8-pin spi memory 32M spi-nor MX25L25635E to the available location and put the two jumpers J10 and J11

i can use luci-app-samba4 with 32M flash & OpenWrt 21.02

for build openwrt 21.02.rc3 release

1 - add a section in mt7621.mk with this:

define Device/xiaomi-mi-router-3g_32M
  $(Device/dsa-migration)
  $(Device/uimage-lzma-loader)
  IMAGE_SIZE := 32132k
  DEVICE_VENDOR := XIAOMI
  DEVICE_MODEL := R3G-32M
  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
	kmod-usb-ledtrig-usbport
endef
TARGET_DEVICES += xiaomi-mi-router-3g_32M

2 - add a file mt7621_xiaomi-mi-router-3g_32M.dts with this content:

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
	compatible = "xiaomi,r3g-32M", "mediatek,mt7621-soc";
	model = "XIAOMI R3G-32M";

	aliases {
		led-boot = &led_status_yellow;
		led-failsafe = &led_status_red;
		led-running = &led_status_blue;
		led-upgrade = &led_status_yellow;
		label-mac-device = &gmac0;
	};

	chosen {
		bootargs = "console=ttyS0,115200";
	};

	leds {
		compatible = "gpio-leds";

		led_status_red: status_red {
			label = "red:status";
			gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
		};

		led_status_blue: status_blue {
			label = "blue:status";
			gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
		};

		led_status_yellow: status_yellow {
			label = "yellow:status";
			gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
		};

		wan_amber {
			label = "amber:wan";
			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "dsa-0.0:01:1Gbps";
		};

		lan1_amber {
			label = "amber:lan1";
			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "dsa-0.0:03:1Gbps";
		};

		lan2_amber {
			label = "amber:lan2";
			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "dsa-0.0:02:1Gbps";
		};
	};

reg_usb_vbus: regulator {
		compatible = "regulator-fixed";
		regulator-name = "usb_vbus";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		gpio = <&gpio 12 GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};
};

&xhci {
	vbus-supply = <&reg_usb_vbus>;
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <10000000>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x0 0x30000>;
				read-only;
			};

			partition@30000 {
				label = "u-boot-env";
				reg = <0x30000 0x10000>;
				read-only;
			};

			factory: partition@40000 {
				label = "factory";
				reg = <0x40000 0x10000>;
				read-only;
			};

			partition@50000 {
				compatible = "denx,uimage";
				label = "firmware";
				reg = <0x50000 0x1fb0000>;
			};
		};
	};
};

&pcie {
	status = "okay";
};

&pcie0 {
	wifi@0,0 {
		compatible = "pci14c3,7603";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x0000>;
		ieee80211-freq-limit = <2400000 2500000>;
		led {
			led-active-low;
		};
	};
};

&pcie1 {
	wifi@0,0 {
		compatible = "pci14c3,7662";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x8000>;
		ieee80211-freq-limit = <5000000 6000000>;
		led {
			led-sources = <2>;
			led-active-low;
		};
	};
};

&gmac0 {
	mtd-mac-address = <&factory 0xe000>;
};

&switch0 {
	ports {
		port@2 {
			status = "okay";
			label = "lan1";
		};

		port@3 {
			status = "okay";
			label = "lan2";
		};

		wan: port@1 {
			status = "okay";
			label = "wan";
			mtd-mac-address = <&factory 0xe006>;
		};
	};
};

&state_default {
	gpio {
		groups = "jtag", "uart2", "uart3", "wdt";
		function = "gpio";
	};
};


everything seems to be working fine except for the automount with ntfs-3g where I had to launch:

ln -f -s $(readlink -f $(type -p ntfs-3g)) /sbin/mount.ntfs

1 Like

Thanks for sharing.

Which bootloader are you using?

Hi there,
Great work!
I have the same device with the same problem. The u-boot partition got corrupted while flashing the breed bootloader. Then I modified it with 16 MB spi flash and now it works fine. (with a tutorial from a Russian website)
Now I am using x-wrt firmware on it. To be honest vanilla openwrt is much better in my opinion but I don't know how to create a new profile that supports 16MB spi flash. Can you please help with this? Thanks.
ulpian