Xiaomi Mi Router 4A Gigabit Edition (Gigaflash SPI models only) u-boot update

Hello, I have a different mtd id for u-boot & flash
Does it still work with u-boot mod?

root@OpenWrt:/tmp# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00010000 "flash"
mtd1: 00030000 00010000 "u-boot"
mtd2: 00010000 00010000 "u-boot-env"
mtd3: 00010000 00010000 "Bdata"
mtd4: 00010000 00010000 "factory"
mtd5: 00010000 00010000 "crash"
mtd6: 00010000 00010000 "cfg_bak"
mtd7: 00100000 00010000 "overlay"
mtd8: 00e80000 00010000 "firmware"
mtd9: 001cab0a 00010000 "kernel"
mtd10: 00cb54f6 00010000 "rootfs"
mtd11: 006d0000 00010000 "rootfs_data"

If you are using my openwrt firmware, then this looks as it should. OEM firmware would look different as well.
Im only interested if you have the breed bootloader and what flash chip you have.

You would be safe to use this. Just backup the

mtd0: 01000000 00010000 "flash"
mtd1: 00030000 00010000 "u-boot"

I can confirm it booting properly.

Somehow I can't login through SSH & Luci after flashing openwrt 21.02.0.rc1 with blank password, even if "password not set" warning was appear on Luci

Clear your browser cache or try incognito mode. Or remove files on the router in /tmp

I changed to other browser & I can login now, thanks btw.

I took 2 hours just to reconfigure everything

1 Like

What kind of repacking are you talking about?

You have to use their unpack tool as its encrypted

Then repack a new sysupgrade type image without the ssl sha added.

I upgaded the u-boot on the 4A gigabit edition global version with no issues! Bought from Germany with European languages at the back. Initially I had OpenWRT 21.02 RC2, but the u-boot partition was locked. Installed @db260179 firmware and installation of u-boot was a breeze. I haven't logged into u-boot, but firmware booted up normally, so I assume everything is spanky-good. Thank you so much for this!

2 Likes

Hi there @db260179
First of all I really appreciate you doing this. You are doing so many great things for this router. Keep up the good work!
And I have a question for you. Can we use your u-boot on global version router with vanilla openwrt now? (21.02.0 RC3 in this case)
Tbh I do not understand clearly. Maybe you could explain some of the terminology you use. I have an spi flash programmer and my full flash dump btw.

current flash layout and uboot mtd block

root@Xiaomi:/tmp# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00030000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00010000 00010000 "Bdata"
mtd3: 00010000 00010000 "factory"
mtd4: 00010000 00010000 "crash"
mtd5: 00010000 00010000 "cfg_bak"
mtd6: 00100000 00010000 "overlay"
mtd7: 00e80000 00010000 "firmware"
mtd8: 0023f8eb 00010000 "kernel"
mtd9: 00c40715 00010000 "rootfs"
mtd10: 00920000 00010000 "rootfs_data"

ulpian

Hi ulpian,

Yes my u-boot will work on international and global versions as long as its 16mb flash size.

For safety its best to have a full flash backup incase of any issues, but as you have a spi flash its easy to recovery incase of boot failure.

My custom firmware v19.07 can backup from web ui as well.

The new 21.02 will work fine as i submitted a patch before this release to fix a race condition, so you will be fine. Just follow my instructions.

That is great news I'll try it as soon as possible and I will keep you updated.

ulpian

Hi!

Last post here is long time ago.
Is there any news elsewhere?

I have a new global version which looks similar but without heat sinks and installed openwrt 21.02.0.

dev:    size   erasesize  name
mtd0: 00030000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00010000 00010000 "Bdata"
mtd3: 00010000 00010000 "factory"
mtd4: 00010000 00010000 "crash"
mtd5: 00010000 00010000 "cfg_bak"
mtd6: 00100000 00010000 "overlay"
mtd7: 00e80000 00010000 "firmware"
mtd8: 00241c95 00010000 "kernel"
mtd9: 00c3e36b 00010000 "rootfs"
mtd10: 00920000 00010000 "rootfs_data"

Unfortunately I can't backup the flash with test Clips because voltage drops to 1.2V.

Can I flash this u-boot on the router and if something goes wrong, merge the mtd-backups to a flashable image (to write it to the desolderd flash chip)?

Just follow the instructions to backup via my firmware in the web ui ^^. This will do a full flash dump.

or follow the generic backup

But you will need a spi programmer if you corrupt the u-boot part!

Thank you for your answer!

Sorry, my English is not so good.
I'v already done the mtd-backup, and my question was:

Can I assemble the 10 OpenWRT mtd-backup-partitions in one file to flash it with a programmer?
(Something like: cat mtd0 mtd1 ...> flashable_firmware.bin)

I have already tried with the programmer but:

So if something goes wrong, I have to desolder the chip and flash it with the backup.

Yes you can merge the images together, if you want a complete flash image, just install my openwrt v19.07.8 image and go to the webui and do a full flash backup and download to your local pc.

Yes, you will need to remove the flash chip and reprogram it.

Thank you!

Everything works perfect without soldering...

1 Like

Hi,
does this bootloader works with MI 3G V2 chinese version?
I have read that with the original 3G V2 revovery is difficult (no firmware available). That why i prefer to flash bootloader before openwrt firmware.

This is guaranteed to work with mi4ag router only, you can fork my repo - https://github.com/db260179/u-boot_mod/tree/master/profiles - and create a new profile for the 3G V2 model.

Just need to serial connect to your current router and see on boot what mem and frequency settings is set then add those to the new profile, just take mine as an example then adjust.

Just keep a backup of your current u-boot bootloader, other wise recovery is hard work!

Ok, thanks for the explanations. I'll try that.
I have already made a backup with the dd command as I don't have a programmer

Hi,
just tested on my 3GV2 chinese version and it's ok. It doesn't boot the original official firmware but i can flash the OpenWrt reease 21.02 and boot with OpenWrt now!

1 Like