OpenWrt support for Xiaomi AX3000T

That looks like you’ve installed a uboot image that doesn’t support the flash chip.
You need to revert to the factory uboot.
There should be the process earlier in the thread.

More generally make sure your device doesn’t have the an88 switch chip or it is not supported

flash memory vendor is Winbond

Take a look at this patch by @Ser9ei

He just implemented your patch into 23.05: https://github.com/Ser9ei/xiaomi_ax3000t-openwrt23_patch/blob/23.05.5/xiaomi_ax3000t-dts.patch

He didn't backport anything else from snapshot or kernel 6.6.

EDIT: Comparing https://elixir.bootlin.com/linux/v6.6.52/source/drivers/mtd/nand/spi/winbond.c to https://elixir.bootlin.com/linux/v5.15.167/source/drivers/mtd/nand/spi/winbond.c to your patch https://github.com/openwrt/openwrt/blob/main/target/linux/generic/pending-6.6/489-mtd-spinand-winbond-add-support-for-W25N01KV.patch, I think this is the 6.6 code that needs to be backported in addition to your patch:

static int w25n01kv_ooblayout_ecc(struct mtd_info *mtd, int section,
				  struct mtd_oob_region *region)
{
	if (section > 3)
		return -ERANGE;

	region->offset = 64 + (8 * section);
	region->length = 7;

	return 0;
}

static int w25n02kv_ooblayout_ecc(struct mtd_info *mtd, int section,
				  struct mtd_oob_region *region)
{
	if (section > 3)
		return -ERANGE;

	region->offset = 64 + (16 * section);
	region->length = 13;

	return 0;
}

static int w25n02kv_ooblayout_free(struct mtd_info *mtd, int section,
				   struct mtd_oob_region *region)
{
	if (section > 3)
		return -ERANGE;

	region->offset = (16 * section) + 2;
	region->length = 14;

	return 0;
}

static const struct mtd_ooblayout_ops w25n01kv_ooblayout = {
	.ecc = w25n01kv_ooblayout_ecc,
	.free = w25n02kv_ooblayout_free,
};

static const struct mtd_ooblayout_ops w25n02kv_ooblayout = {
	.ecc = w25n02kv_ooblayout_ecc,
	.free = w25n02kv_ooblayout_free,
};

static int w25n02kv_ecc_get_status(struct spinand_device *spinand,
				   u8 status)
{
	struct nand_device *nand = spinand_to_nand(spinand);
	u8 mbf = 0;
	struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, spinand->scratchbuf);

	switch (status & STATUS_ECC_MASK) {
	case STATUS_ECC_NO_BITFLIPS:
		return 0;

	case STATUS_ECC_UNCOR_ERROR:
		return -EBADMSG;

	case STATUS_ECC_HAS_BITFLIPS:
		/*
		 * Let's try to retrieve the real maximum number of bitflips
		 * in order to avoid forcing the wear-leveling layer to move
		 * data around if it's not necessary.
		 */
		if (spi_mem_exec_op(spinand->spimem, &op))
			return nanddev_get_ecc_conf(nand)->strength;

		mbf = *(spinand->scratchbuf) >> 4;

		if (WARN_ON(mbf > nanddev_get_ecc_conf(nand)->strength || !mbf))
			return nanddev_get_ecc_conf(nand)->strength;

		return mbf;

	default:
		break;
	}

	return -EINVAL;
}

	SPINAND_INFO("W25N01KV",
		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xae, 0x21),
		     NAND_MEMORG(1, 2048, 96, 64, 1024, 20, 1, 1, 1),
		     NAND_ECCREQ(4, 512),
		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
					      &write_cache_variants,
					      &update_cache_variants),
		     0,
		     SPINAND_ECCINFO(&w25n01kv_ooblayout, w25n02kv_ecc_get_status)),

	SPINAND_INFO("W25N02KV",
		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xaa, 0x22),
		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
		     NAND_ECCREQ(8, 512),
		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
					      &write_cache_variants,
					      &update_cache_variants),
		     0,
		     SPINAND_ECCINFO(&w25n02kv_ooblayout, w25n02kv_ecc_get_status)),

If I get it compiled and provide you with the diff patch, would you be willing to commit it? Even though n02 support isn't required for AX3000T, I just added support to it in the code above because we need to backport w25n02kv_ecc_get_status and w25n02kv_ooblayout_free anyway.

@Ser9ei Take a look at my edit above. How did you manage to compile with the missing functions?

That nand chip is not supported by the openwrt uboot.
Recover the factory uboot from your back up

not sure, but by my info, @MAMBA restored his router and reinstalled OpenWrt 23.05.5 (+spi W25N01KV).
Let's take a pause and waitting him feedback tomorrow (?).

It's MediaTek hardware, so it's likely going to appear in the Linux kernel sooner than later.

MAC addresses are stored in the Bdata partition. See /etc/board.d/02_network -> mediatek_setup_macs() -> xiaomi,mi-router-ax3000t.

root@router1:~# grep Bdata /proc/mtd
mtd2: 00040000 00020000 "Bdata"
root@router1:~# strings /dev/mtdblock2 | grep addr
ethaddr_wan=XX:XX:XX:XX:XX:XX
ethaddr=XX:XX:XX:XX:XX:XX
ethaddr_wan2=XX:XX:XX:XX:XX:XX

As for the other question: OpenWrt + OpenWrt U-Boot only modify the BL2, FIP and ubi partitions, all the others are left unchanged (some parameters are changed in Nvram, but they are not required to be restored in order to restore stock firmware and/or bootloader).

And in the factory too (twice), see offset 0x4 and 0x9 from top of the factory partition

As mentioned, you've flashed the stable bootloader, which doesn't support the Winbond chip.

spi-nand: spi_nand spi_nand@0: unknown raw ID ef ae 21 00

ID ef ae 21 00 is W25N01KV: SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xae, 0x21)

You will need to install the snapshot bootloader or the stock bootloader through UART: OpenWrt support for Xiaomi AX3000T - #860 by andi-at-1

EDIT: The likely reason for your TFTP recovery to be failing is due to the stable xiaomi_mi-router-ax3000t-ubootmod-initramfs-recovery.itb in ubi0_2. Try replacing it with the one from snapshot via UART, although at this point, it's probably simpler to just format and recreate ubi from scratch.

1 Like

So, that means it only has the advantage of being faster. There are no disadvantages, so I'll keep it.

thanks

Can you give me some context here? Are you asking for the title “Staff” to be changed? Or for the current staff to be replaced by devs? Or for more devs to join the staff roles? Or something else?

I put the last stable firmware and asked to keep the configs, but now my wireless is not working for some reason. checking the file, it seems like not good. Could somebody tell me how to adjust to keep my previous configs?

config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/soc/18000000.wifi'
        option country 'BR'
        option cell_density '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'VipperNet'
        option encryption 'psk-mixed'
        option dtim_period '3'
        option key 'Vieiras.26278963'
        option ieee80211r '1'
        option mobility_domain '123F'
        option ft_over_ds '0'
        option ft_psk_generate_local '1'
        option bss_transition '1'
        option ieee80211k '1'
        option time_zone '<-03>3'

config wifi-device 'radio1'
        option type 'mac80211'
        option path 'platform/soc/18000000.wifi+1'
        option channel '40'
        option band '5g'
        option htmode 'HE80'
        option cell_density '0'
        option country 'BR'

config wifi-iface 'default_radio1'
        option device 'radio1'
        option network 'lan'
        option mode 'ap'
        option ssid 'VipperNet'
        option encryption 'psk-mixed'
        option dtim_period '3'
        option key 'Vieiras.26278963'
        option ieee80211r '1'
        option mobility_domain '123F'
        option ft_over_ds '0'
        option ft_psk_generate_local '1'
        option bss_transition '1'
        option ieee80211k '1'

config wifi-iface 'wifinet2'
        option device 'radio0'
        option mode 'ap'
        option ssid 'VipperHome'
        option encryption 'psk-mixed'
        option key 'Vieiras.26278963@'
        option ieee80211r '1'
        option mobility_domain '123E'
        option ft_over_ds '0'
        option ft_psk_generate_local '1'
        option network 'iot'
        option bss_transition '1'
        option ieee80211k '1'

config wifi-iface 'wifinet3'
        option device 'radio1'
        option mode 'ap'
        option ssid 'VipperHome'
        option encryption 'psk-mixed'
        option key 'Vieiras.26278963@'
        option ieee80211r '1'
        option mobility_domain '123E'
        option ft_over_ds '0'
        option ft_psk_generate_local '1'
        option network 'iot'
        option bss_transition '1'
        option ieee80211k '1'

config wifi-iface 'wifinet4'
        option device 'radio0'
        option mode 'ap'
        option ssid 'VipperGuest'
        option encryption 'psk-mixed'
        option dtim_period '3'
        option key 'Vieiras.Guest'
        option ieee80211r '1'
        option mobility_domain '123C'
        option ft_over_ds '0'
        option ft_psk_generate_local '1'
        option network 'guest'
        option bss_transition '1'
        option ieee80211k '1'

config wifi-iface 'wifinet5'
        option device 'radio1'
        option mode 'ap'
        option ssid 'VipperGuest'
        option encryption 'psk-mixed'
        option dtim_period '3'
        option key 'Vieiras.Guest'
        option ieee80211r '1'
        option mobility_domain '123C'
        option ft_over_ds '0'
        option ft_psk_generate_local '1'
        option network 'guest'
        option bss_transition '1'
        option ieee80211k '1'

config wifi-device 'radio2'
        option type 'mac80211'
        option path 'platform/18000000.wifi'
        option channel '1'
        option band '2g'
        option htmode 'HE20'
        option disabled '1'

config wifi-iface 'default_radio2'
        option device 'radio2'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'

config wifi-device 'radio3'
        option type 'mac80211'
        option path 'platform/18000000.wifi+1'
        option channel '36'
        option band '5g'
        option htmode 'HE80'
        option disabled '1'

config wifi-iface 'default_radio3'
        option device 'radio3'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'

Thanks.

There is one unmentioned advantage in security/privacy: the OpenWrt U-Boot is FOSS, the stock bootloader is a closed source fork.

Another one: OpenWrt support for Xiaomi AX3000T - #452 by alexq
You don't have to deal with this in OpenWrt U-Boot, although you can still read their values (as last set by the stock bootloader, before being replaced) from nvram, if you're curious.

root@router1:~# strings /dev/mtdblock1 | grep flag_try_sys
flag_try_sys1_failed=10
flag_try_sys2_failed=8
2 Likes

As I mentioned here, the biggest disadvantage for me (and associated with it risk) of using custom OpenWrt U-boot bottloader is that you CAN'T perform a simple restore to the stock firmware via MiWiFi Repair Tool if something goes wrong. When your router is bricked for any reason, the MiWiFi Repair Tool will not help in rolling back to stock.

Faster loading of the router. No faster router performance after that. How often do you need your router to just load quicker?

yes, it seems the only advantage for me is that there's no need to preserve the flag_try_sys1_failed flags.

Flash recovery in the instructions - 10 MB of flash memory and recovery is much faster and much easier than the standard Xiaomi utility and no addresses on the Ethernet card need to be changed.

It is designed to work this way and does in certain scenarios, but in reality there are many posts here where users encounter issues with custom bootloader recovery and get stuck..
In contrast to the MiWiFi Repair Tool with simplified UI (and chinese text :slightly_smiling_face:) which allows simply returning to the initial stock firmware in few clicks and starting all over again from scratch.

This is because it is not explicitly stated that for Winbond you need to flash ONLY U-Boot from the SNAPSHOT branch. And the Xiaomi utility is the same TFTP, only "automated). ))

So, indeed it seems now no advantage.
But, at least, in theory, U-boot also creates an easy recovery method. no? I think I've changed to that only because I saw that information and was afraid something went wrong.

Anyway, is there a way to get back to the original bootload?

Wow. I see now the next posts from @Lexeyko , that's the reason I've changed to U-boot.

Thanks.

1 Like

It seems the way requires flashing back the original BL2, FIP, and UBI partitions from a backup.