Flashing Mercusys MR70X

Flashing my OpenWrt build through OpenWrt booted from tftpboot with bootm:

the message would be like 50k+ chars long which isn't supported hence the pastebin

@nicefile @khagaroth could you guys upload a full dump and hex dump of all the partitions but specifically the factory one?

Please also post the version of your uboots.

what do you mean by that isn't that in the boot logs already?

Didn't mean yours, but theirs.

okay I looked around a bit following paul's advice from the IRC regarding the nm_api_checkInteger stuff and I came across: TP-Link Archer C60 v2 stuck in HTTP upgrade - #9 by Fusseldieb

so I made backups from all the available partitions from OpenWrt being:
u-boot
firmware
factory

lets assume factory is equal to the tplink partition I personally don't know anything about this stuff but it appears to be mostly empty as far as I can tell, Wi-Fi and the MAC address are both still available indicating that the art partition should still be fine so all I'd need according to that post would be a back up of someone else's factory partition.

my factory bin: https://send.vis.ee/download/7346936802818aa6/#9BZFoCoYi3W1_qJbVcr2mA

I have fullflash of MR1800X but no MR70X . My bet is on broken bootloader or it's config (first 256kB aka mtd0). As You see begging of "OEM data" starts @0xfa0000 so in OEM rootfs partition. 64k ART is classic ralink factory but without mac address.

My oem bootlog look like below . Also added printenv

MT7621 # printenv
bootargs=console=ttyS1,115200 root=/dev/mtdblock2 rootfstype=squashfs init=/etc/preinit mtdparts=raspi:256k(uboot),4096k(uImage),11968k@0x440000(rootfs),64k@0xff0000(ART) mem=128M
bootcmd=tftp
bootdelay=0x1
baudrate=115200
ethaddr="00:AA:BB:CC:DD:10"
ipaddr=192.168.1.1
serverip=192.168.1.5
stdin=serial
stdout=serial
stderr=serial


U-Boot 1.1.3 (Apr  7 2021 - 17:57:20)

Board: Ralink APSoC DRAM:  128 MB
relocate_code Pointer at: 87f58000

Config XHCI 40M PLL
flash manufacture id: ef, device id 40 18
find flash: W25Q128BV
*** Warning - bad CRC, using default environment

============================================
Ralink UBoot Version: 5.0.0.0
--------------------------------------------
ASIC MT7621A DualCore (MAC to MT7530 Mode)
DRAM_CONF_FROM: Auto-Detection
DRAM_TYPE: DDR3
DRAM bus: 16 bit
Xtal Mode=3 OCP Ratio=1/3
Flash component: SPI Flash
Date:Apr  7 2021  Time:17:57:20
============================================
THIS IS uboot
icache: sets:256, ways:4, linesz:32 ,total:32768
dcache: sets:256, ways:4, linesz:32 ,total:32768

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

Press '4' or 't' to break the booting process

Press 'x' to enter recovery web server                                      0
#Reset_MT7530
set LAN/WAN WLLLL


4: System Enter Boot Command Line Interface.

U-Boot 1.1.3 (Apr  7 2021 - 17:57:20)
MT7621 # help
?       - alias for 'help'
bootm   - boot application image from memory
cp      - memory copy
erase   - erase SPI FLASH memory
ethon   - enable ethernet.
go      - start application at address 'addr'
help    - print online help
httpd -start www server for firmware recovery
loadb   - load binary file over serial line (kermit mode)
md      - memory display
mdio   - Ralink PHY register R/W command !!
mm      - memory modify (auto-incrementing)
mtest   - simple RAM test
nm      - memory modify (constant address)
printenv- print environment variables
reset   - Perform RESET of the CPU
rf      - read/write rf register
saveenv - save environment variables to persistent storage
setenv  - set environment variables
spi     - spi command
tftpboot- boot image via network using TFTP protocol
version - print monitor version
MT7621 #

U-Boot 1.1.3 (Apr  7 2021 - 17:57:20)

Board: Ralink APSoC DRAM:  128 MB
relocate_code Pointer at: 87f58000

Config XHCI 40M PLL
flash manufacture id: ef, device id 40 18
find flash: W25Q128BV
*** Warning - bad CRC, using default environment

============================================
Ralink UBoot Version: 5.0.0.0
--------------------------------------------
ASIC MT7621A DualCore (MAC to MT7530 Mode)
DRAM_CONF_FROM: Auto-Detection
DRAM_TYPE: DDR3
DRAM bus: 16 bit
Xtal Mode=3 OCP Ratio=1/3
Flash component: SPI Flash
Date:Apr  7 2021  Time:17:57:20
============================================
THIS IS uboot
icache: sets:256, ways:4, linesz:32 ,total:32768
dcache: sets:256, ways:4, linesz:32 ,total:32768

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

Press '4' or 't' to break the booting process

Press 'x' to enter recovery web server                                      0
nm_init:791
nm_initFwupPtnStruct:276
nm_lib_readPtnTable:738
[NM_Debug](nm_lib_readPtnTable) 00743: NM_PTN_TABLE_BASE = 0xfe0000
[NM_Debug](nm_lib_readPtnFromNvram) 00569: partition_used_len = 921, requried len = 8192
[NM_Debug](nm_lib_readPtnTable) 00751: Reading Partition Table from NVRAM ... OK

[NM_Debug](nm_lib_readPtnTable) 00759: Parsing Partition Table ... OK

[NM_Debug](nm_lib_readPtnFromNvram) 00569: partition_used_len = 2, requried len = 2
factory boot check integer ok.


3: System Boot system code via Flash.
## Booting image at bc040000 ...
   Image Name:   Linux Kernel Image
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    3108292 Bytes =  3 MB
   Load Address: 81001000
   Entry Point:  816e0af0
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
No initrd
## Transferring control to Linux (at address 816e0af0) ...
## Giving linux memsize in MB, 128

Starting kernel ...


LINUX started...

 THIS IS ASIC

SDK 5.0.S.0
Linux version 3.10.108 (ghr@ubuntu) (gcc version 4.6.3 (Buildroot 2012.11.1) ) #1 SMP Mon Mar 29 00:55:31 PDT 2021

 The CPU feqenuce set to 880 MHz
GCMP present
CPU0 revision is: 0001992f (MIPS 1004Kc)
Software DMA cache coherency
Determined physical RAM map:
 memory: 08000000 @ 00000000 (usable)
User-defined physical RAM map:
 memory: 08000000 @ 00000000 (usable)
Initrd not found or empty - disabling initrd
Zone ranges:
  DMA      [mem 0x00000000-0x00ffffff]
  Normal   [mem 0x01000000-0x07ffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x00000000-0x07ffffff]
Detected 3 available secondary CPU(s)
Primary instruction cache 32kB, 4-way, VIPT, linesize 32 bytes.
Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
MIPS secondary cache 256kB, 8-way, linesize 32 bytes.
PERCPU: Embedded 7 pages/cpu @81ba8000 s6144 r8192 d14336 u32768
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
Kernel command line: console=ttyS1,115200 root=/dev/mtdblock2 rootfstype=squashfs init=/etc/preinit mtdparts=raspi:256k(uboot),4096k(uImage),11968k@0x440000(rootfs),64k@0xff0000(ART) mem=128M
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Writing ErrCtl register=00050088
Readback ErrCtl register=00050088

we figured something out I'm currently just banging my head trying to configure it LMAO

If you are experiencing issues with your router, here are the steps you can follow to fix it:

  1. Modify the DTS to make the factory partition writable.
  2. Boot the OpenWrt kernel initramfs build using the "tftpboot" and "bootm" commands.
  3. Backup the factory image and modify it as described below.
  4. Flash the modified factory backup using the "mtd write factory.img factory" command.
  5. Use the "sysupgrade -n sysupgrade.img" command to complete the process.

To modify the factory image, follow these instructions provided by PaulFertser:

  1. Open the factory.bin file and locate the sub-partition "extra-para" at offset 0x43b00 from the start of the dump.
  2. Look for the flag (4 + 4 + 1 bytes into the partition header) and set it to 0x01.

By following these steps, you should be able to fix the issues with your router.

Note: Paul also said the following: I'd say it's not the issues but only one issue which manifests itself in [NM_Error](nm_api_checkInteger) 00331: factory boot check integer flag is not 1.

And it's not 9 bytes into partition header, it's 9 bytes from the beginning of the partition (partition header takes 8 bytes, then 1 byte for another flag, and then the flag we changed).

@Lyceris-chan Would you be so kind to share the ROM size and RAM size of this device? I'm just curious if I can build my project on this device.

check the git commit from the 1st post.

Got it. Thanks

SoC: MediaTek MT7621DAT (880Mhz)
RAM: DDR3 128MB (SoC)
Flash: Winbond W25Q128JV (SPI-NOR 16MB)
WiFi: MediaTek MT7915 DBDC
Ethernet: SoC (WAN x1, LAN x3, 1Gb)
UART: [GND, RX, TX, 3.3V] (115200 8N1, J1)

are you trying to build for the mr70x?

Yes that is the goal. But I'm still working on my app to work on OpenWRT (cross-compiled). Currently, I'm just looking for possible hardware prospects to deploy my app.

I hope you can get some use out of this as well :slight_smile:

Thanks. I will definitely make use of this.

I got a MR70x , can I flash factory image (https://firmware-selector.openwrt.org/?version=22.03.5&target=ramips%2Fmt7621&id=mercusys_mr70x-v1) from stock firmware upgrade menu ?

Didn't bother reading the whole thread, did you?

Yes I did , from that what I understood is @Lyceris-chan tried upgrade from stock firmware web interface and failed , later he able to flash it via UART using a custom image, So my question is, Since the new official image is available for MR70x Can I use that to flash it via stock firmware web interface ?

The git commit says you're *supposed" to do it via the web interface, but the vendor might have changed something, making Openwrt fail to flash.

Are you sure it's not the MR70X v2 you've got ?