How to make openwrt mount a different rootfs partition depending on the bootflag

Hi all,

As the title suggest, the device that I have has dual image. The boot loader happens to check each kernel and rootfs partiton for a correct checksum. This is a test when it fails for the first one for example and switches to the second one. It also changes the the MTD3 with the new bootflag (in here Sercomm1)

Boot Flag : Sercomm0�
*************************************
Fw header Magic check error!
Fw header check fail !
Update boot flag to Sercomm1�
ranand_erase: start:300000, len:20000 
.
*************************************
Boot Flag : Sercomm1�
*************************************
Fw header Magic check OK!
FW header checksum should: 0xc16aee0e, crc32 result: 0xc16aee0e, Fw header CRC check OK!
kernel : real offset: 0x00a00100, data length: 0x003b5891,checksum :0x7ee0514e
kernel result: 0x7ee0514e, kernel check sum ok!
rootfs:  real offset: 0x03000000, data length: 0x00d60000, checksum :0xc9164958
rootfs result: 0xc9164958, rootfs check sum ok!
Kernel Addr : 0xbca00100
## Booting image at bca00100 ...
   Image Name:   Linux Kernel Image
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    3889233 Bytes =  3.7 MB
   Load Address: 81001000
   Entry Point:  8171d420
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
kernel addr :0xBCA00100 
No initrd
## Transferring control to Linux (at address 8171d420) ...
## Giving linux memsize in MB, 256

Starting kernel ...

One thing to notice compared to other devices with dual image is that the rootfs of each image does not follow the kernel and since the bootloader checks the corrct locations (MTD4+MTD6) or (MTD5+MTD7) they have to stay this way.

I am trying to see if it is possible to have a single DTS (rather than 2 separate depending on the bootflag value) which would check the bootflag and mounts the correct UBI partition just like stock

The following is from the same console output

command line first

Kernel command line: console=ttyS1,57600n8 root=/dev/mtdblock5 rootfstype=squashfs
Creating 10 MTD partitions on "MT7621-NAND":
0x000000000000-0x000000100000 : "Boot Loader"
0x000000100000-0x000000200000 : "dynamic partition map"
0x000000200000-0x000000300000 : "Factory"
0x000000300000-0x000000400000 : "Boot Flag"
0x000000400000-0x000000a00000 : "Kernel 1"
0x000000a00000-0x000001000000 : "Kernel 2"
0x000001000000-0x000003000000 : "File System 1"
0x000003000000-0x000005000000 : "File System 2"
0x000005000000-0x000006400000 : "Configuration/log"
0x000006400000-0x000007f80000 : "Debug (Ftool)"

And then this the log on where it happens

Sercomm dual images: bootflag=Sercomm1, choose /dev/mtdblock7 as rootfs
VFS: Mounted root (squashfs filesystem) readonly on device 31:7.

With openwrt and my limited experience (and knowlegde) it seems the dts defines where the rootfs is (rootfs=jffs2, ubi=ubifs or mtdsplit with all the different ones).

If someone knows or can point me somehwere with examples I can try please do.

are those lines consecutive? is there an initrd? runtime / init toggling is not a typical openwrt ballgame...

otherwise checkout the advanced-reboot source... for pointers...

typically the bootloader will augment the rootfs bootarg with it's own logic... and openwrt will either facilitate or override this(bootargs)... or in rare cases... provide some uboot scripting augmentations...

Thanks @anon50098793 This is the full log. I did have a look already but will look again. I must admit I must have reached the limit here (due to limited knowledge).

===================================================================
                MT7621   stage1 code 10:33:11 (ASIC)
                CPU=50000000 HZ BUS=16666666 HZ
==================================================================
Change MPLL source from XTAL to CR...
do MEMPLL setting..
MEMPLL Config : 0x11100000
3PLL mode + External loopback
=== XTAL-40Mhz === DDR-1200Mhz ===
PLL2 FB_DL: 0xb, 1/0 = 543/481 2D000000
PLL3 FB_DL: 0x15, 1/0 = 548/476 55000000
PLL4 FB_DL: 0x17, 1/0 = 546/478 5D000000
do DDR setting..[00320381]
Apply DDR3 Setting...(use customer AC)
          0    8   16   24   32   40   48   56   64   72   80   88   96  104  112  120
      --------------------------------------------------------------------------------
0000:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0001:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0002:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0003:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0004:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0005:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0006:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0007:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0008:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0009:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
000A:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
000B:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
000C:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
000D:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    1
000E:|    0    0    0    0    0    0    0    0    0    1    1    1    1    1    1    1
000F:|    0    0    0    0    1    1    1    1    1    1    1    1    1    1    0    0
0010:|    1    1    1    1    1    1    1    1    1    0    0    0    0    0    0    0
0011:|    1    1    1    1    0    0    0    0    0    0    0    0    0    0    0    0
0012:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0013:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0014:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0015:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0016:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0017:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0018:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
0019:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
001A:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
001B:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
001C:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
001D:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
001E:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
001F:|    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
rank 0 coarse = 15
rank 0 fine = 72
B:|    0    0    0    0    0    0    0    0    1    1    1    0    0    0    0    0
opt_dle value:9
DRAMC_R0DELDLY[018]=00001E1E
==================================================================
                RX      DQS perbit delay software calibration 
==================================================================
1.0-15 bit dq delay value
==================================================================
bit|     0  1  2  3  4  5  6  7  8  9
--------------------------------------
0 |    9 6 9 7 9 4 8 1 2 6 
10 |    4 10 6 7 3 7 
--------------------------------------

==================================================================
2.dqs window
x=pass dqs delay value (min~max)center 
y=0-7bit DQ of every group
input delay:DQS0 =30 DQS1 = 30
==================================================================
bit     DQS0     bit      DQS1
0  (1~56)28  8  (1~54)27
1  (1~55)28  9  (1~56)28
2  (0~58)29  10  (1~57)29
3  (1~56)28  11  (1~55)28
4  (1~56)28  12  (2~56)29
5  (1~56)28  13  (1~55)28
6  (0~60)30  14  (2~58)30
7  (1~59)30  15  (1~56)28
==================================================================
3.dq delay value last
==================================================================
bit|    0  1  2  3  4  5  6  7  8   9
--------------------------------------
0 |    11 8 10 9 11 6 8 1 5 8 
10 |    5 12 7 9 3 9 
==================================================================
==================================================================
     TX  perbyte calibration 
==================================================================
DQS loop = 15, cmp_err_1 = ffff0000 
dqs_perbyte_dly.last_dqsdly_pass[0]=15,  finish count=1 
dqs_perbyte_dly.last_dqsdly_pass[1]=15,  finish count=2 
DQ loop=15, cmp_err_1 = ffff0000
dqs_perbyte_dly.last_dqdly_pass[0]=15,  finish count=1 
dqs_perbyte_dly.last_dqdly_pass[1]=15,  finish count=2 
byte:0, (DQS,DQ)=(8,8)
byte:1, (DQS,DQ)=(8,8)
20,data:88
[EMI] DRAMC calibration passed

===================================================================
                MT7621   stage1 code done 
                CPU=50000000 HZ BUS=16666666 HZ
===================================================================


U-Boot 1.1.3 (Mar  4 2020 - 17:12:16)

Board: Ralink APSoC DRAM:  256 MB
rt2880 uboot v0.00e04 05/25/2006
SERIAL_CLOCK_DIVISOR =16 
kaiker,,CONFIG_BAUDRATE =57600 
SDRAM SIZE:10000000
Top of RAM usable for U-Boot at: 90000000
Reserving 425k for U-Boot at: 8ff94000
Reserving 1028k for malloc() at: 8fe93000
Reserving 44 Bytes for Board Info at: 8fe92fd4
Reserving 36 Bytes for Global Data at: 8fe92fb0
Reserving 128k for boot params() at: 8fe72fb0
Stack Pointer at: 8fe72f98
relocate_code Pointer at: 8ff94000

Config XHCI 40M PLL 
******************************
Software System Reset Occurred
******************************
Now running in RAM - U-Boot at: 8ff94000

 monitor_flash_len =116812 
Command "mdio": 0xa0206984 => 0x8ff9a984
Command "nand": 0xa020c2bc => 0x8ffa02bc
Command "reset": 0xa0215cec => 0x8ffa9cec
Command "go": 0xa020dc68 => 0x8ffa1c68
Command "bootm": 0xa020e4c4 => 0x8ffa24c4
Command "loadb": 0xa020f184 => 0x8ffa3184
Command "tftpboot": 0xa020f7b4 => 0x8ffa37b4
Command "nm": 0xa020fe40 => 0x8ffa3e40
Command "mm": 0xa020fea4 => 0x8ffa3ea4
Command "md": 0xa020ff08 => 0x8ffa3f08
Command "saveenv": 0xa0210480 => 0x8ffa4480
Command "setenv": 0xa0210df0 => 0x8ffa4df0
Command "printenv": 0xa02104d0 => 0x8ffa44d0
Command "?": 0xa02110c4 => 0x8ffa50c4
Command "help": 0xa02110c4 => 0x8ffa50c4
Command "version": 0xa0210f84 => 0x8ffa4f84
Command "sc_boot": 0xa0213d30 => 0x8ffa7d30
Command "sc_nand": 0xa0213d68 => 0x8ffa7d68
Command "sc_eth_test": 0xa0213da4 => 0x8ffa7da4
Command "sc_phy": 0xa0213de0 => 0x8ffa7de0
Command "sc_time": 0xa0213e1c => 0x8ffa7e1c
Command "sc_btver": 0xa0213e54 => 0x8ffa7e54
Command "sc_fl_map": 0xa0213e90 => 0x8ffa7e90
Command "sc_endian": 0xa0213ecc => 0x8ffa7ecc
Command "sc_gpio": 0xa0213f08 => 0x8ffa7f08
Command "sc_led": 0xa0213f44 => 0x8ffa7f44
Command "sc_dl": 0xa0213f80 => 0x8ffa7f80
Allocate 16 byte aligned buffer: 8ffca410
Enable NFI Clock
# MTK NAND # : Use HW ECC
NAND ID [C2 F1 80 95 02]
Device found in MTK table, ID: c2f1, EXT_ID: 809502
Support this Device in MTK table! c2f1 
select_chip
[NAND]select ecc bit:4, sparesize :64 spare_per_sector=16
Signature matched and data read!
load_fact_bbt success 1023
load fact bbt success
[mtk_nand] probe successfully!
mtd->writesize=2048 mtd->oobsize=64,    mtd->erasesize=131072  devinfo.iowidth=8
*** Warning - bad CRC, using default environment

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 =256 Mbytes
#Reset_MT7530
set LAN/WAN WLLLL

Load Standalone from 40000
SC_DEBUG: Nand Partition Table Magic Found at 100000.

******************************************
    Uboot StandAlone Entry
******************************************
GPIO init
*********************************************************
      Press any key to enter Boot Command Interface      
*********************************************************
 0 
SC_DEBUG: Nand Partition Table Magic Found at 100000.

******************************************
    Uboot StandAlone Entry
******************************************

***************************************************
     Boot Version 0.2.1.0, at Mar  4 2020, 17:12:13

***************************************************
SC_DEBUG: Nand Partition Table Magic Found at 100000.
Entering Firmware : Everything is OK.

*************************************
Boot Flag : Sercomm0�
*************************************
Fw header Magic check error!
Fw header check fail !
Update boot flag to Sercomm1�
ranand_erase: start:300000, len:20000 
.
*************************************
Boot Flag : Sercomm1�
*************************************
Fw header Magic check OK!
FW header checksum should: 0xc16aee0e, crc32 result: 0xc16aee0e, Fw header CRC check OK!
kernel : real offset: 0x00a00100, data length: 0x003b5891,checksum :0x7ee0514e
kernel result: 0x7ee0514e, kernel check sum ok!
rootfs:  real offset: 0x03000000, data length: 0x00d60000, checksum :0xc9164958
rootfs result: 0xc9164958, rootfs check sum ok!
Kernel Addr : 0xbca00100
## Booting image at bca00100 ...
   Image Name:   Linux Kernel Image
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    3889233 Bytes =  3.7 MB
   Load Address: 81001000
   Entry Point:  8171d420
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
kernel addr :0xBCA00100 
No initrd
## Transferring control to Linux (at address 8171d420) ...
## Giving linux memsize in MB, 256

Starting kernel ...


LINUX started...

 THIS IS ASIC

SDK 5.0.S.0
Linux version 3.10.14 (scof@ubuntu) (gcc version 4.6.3 (Buildroot 2012.11.1) ) #1 SMP Fri Apr 10 23:05:30 MSK 2020

 The CPU feqenuce set to 880 MHz
GCMP present
CPU0 revision is: 0001992f (MIPS 1004Kc)
Software DMA cache coherency
Determined physical RAM map:
 memory: 0fffc000 @ 00000000 (usable)
 memory: 00004000 @ 0fffc000 (reserved)
Zone ranges:
  DMA      [mem 0x00000000-0x00ffffff]
  Normal   [mem 0x01000000-0x0fffbfff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x00000000-0x0fffbfff]
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 @81cb6000 s6720 r8192 d13760 u32768
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 65020
Kernel command line: console=ttyS1,57600n8 root=/dev/mtdblock5 rootfstype=squashfs
PID hash table entries: 1024 (order: 0, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Writing ErrCtl register=00002e40
Readback ErrCtl register=00002e40
Memory: 248792k/262128k available (7323k kernel code, 13336k reserved, 3130k data, 228k init, 0k highmem)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:128
console [ttyS1] enabled
Calibrating delay loop... 577.53 BogoMIPS (lpj=1155072)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
launch: starting cpu1
launch: cpu1 gone!
CPU1 revision is: 0001992f (MIPS 1004Kc)
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.
Synchronize counters for CPU 1: done.
launch: starting cpu2
launch: cpu2 gone!
CPU2 revision is: 0001992f (MIPS 1004Kc)
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.
Synchronize counters for CPU 2: done.
launch: starting cpu3
launch: cpu3 gone!
CPU3 revision is: 0001992f (MIPS 1004Kc)
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.
Synchronize counters for CPU 3: done.
Brought up 4 CPUs
devtmpfs: initialized
NET: Registered protocol family 16
release PCIe RST: RALINK_RSTCTRL = 7000000
PCIE PHY initialize
***** Xtal 40MHz *****
start MT7621 PCIe register access
RALINK_RSTCTRL = 7000000
RALINK_CLKCFG1 = 77ffeff8

*************** MT7621 PCIe RC mode *************
PCIE2 no card, disable it(RST&CLK)
pcie_link status = 0x3
RALINK_RSTCTRL= 3000000
*** Configure Device number setting of Virtual PCI-PCI bridge ***
RALINK_PCI_PCICFG_ADDR = 21007f2 -> 21007f2
PCIE0 enabled
PCIE1 enabled
interrupt enable status: 300000
Port 1 N_FTS = 1b105000
Port 0 N_FTS = 1b105000
config reg done
init_rt2880pci done
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [mem 0x60000000-0x6fffffff]
pci_bus 0000:00: root bus resource [io  0x1e160000-0x1e16ffff]
pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
pci 0000:00:00.0: BAR 0: can't assign mem (size 0x80000000)
pci 0000:00:01.0: BAR 0: can't assign mem (size 0x80000000)
pci 0000:00:00.0: BAR 8: assigned [mem 0x60000000-0x600fffff]
pci 0000:00:01.0: BAR 8: assigned [mem 0x60100000-0x601fffff]
pci 0000:00:00.0: BAR 1: assigned [mem 0x60200000-0x6020ffff]
pci 0000:00:01.0: BAR 1: assigned [mem 0x60210000-0x6021ffff]
pci 0000:01:00.0: BAR 0: assigned [mem 0x60000000-0x600fffff 64bit]
pci 0000:00:00.0: PCI bridge to [bus 01]
pci 0000:00:00.0:   bridge window [mem 0x60000000-0x600fffff]
pci 0000:02:00.0: BAR 0: assigned [mem 0x60100000-0x601fffff]
pci 0000:00:01.0: PCI bridge to [bus 02]
pci 0000:00:01.0:   bridge window [mem 0x60100000-0x601fffff]
BAR0 at slot 0 = 0
bus=0x0, slot = 0x0
res[0]->start = 0
res[0]->end = 0
res[1]->start = 60200000
res[1]->end = 6020ffff
res[2]->start = 0
res[2]->end = 0
res[3]->start = 0
res[3]->end = 0
res[4]->start = 0
res[4]->end = 0
res[5]->start = 0
res[5]->end = 0
BAR0 at slot 1 = 0
bus=0x0, slot = 0x1
res[0]->start = 0
res[0]->end = 0
res[1]->start = 60210000
res[1]->end = 6021ffff
res[2]->start = 0
res[2]->end = 0
res[3]->start = 0
res[3]->end = 0
res[4]->start = 0
res[4]->end = 0
res[5]->start = 0
res[5]->end = 0
bus=0x1, slot = 0x0, irq=0x4
res[0]->start = 60000000
res[0]->end = 600fffff
res[1]->start = 0
res[1]->end = 0
res[2]->start = 0
res[2]->end = 0
res[3]->start = 0
res[3]->end = 0
res[4]->start = 0
res[4]->end = 0
res[5]->start = 0
res[5]->end = 0
bus=0x2, slot = 0x1, irq=0x18
res[0]->start = 60100000
res[0]->end = 601fffff
res[1]->start = 0
res[1]->end = 0
res[2]->start = 0
res[2]->end = 0
res[3]->start = 0
res[3]->end = 0
res[4]->start = 0
res[4]->end = 0
res[5]->start = 0
res[5]->end = 0
Switching to clocksource MIPS
NET: Registered protocol family 2
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP: reno registered
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
4 CPUs re-calibrate udelay(lpj = 1167360)
squashfs: version 4.0 (2009/01/31) Phillip Lougher
NTFS driver 2.1.30 [Flags: R/W].
fuse init (API version 7.22)
msgmni has been set to 485
io scheduler noop registered (default)
reg_int_mask=0, INT_MASK= 0 
HSDMA_init

 hsdma_phy_tx_ring0 = 0x00c00000, hsdma_tx_ring0 = 0xa0c00000

 hsdma_phy_rx_ring0 = 0x00c04000, hsdma_rx_ring0 = 0xa0c04000
TX_CTX_IDX0 = 0
TX_DTX_IDX0 = 0
RX_CRX_IDX0 = 3ff
RX_DRX_IDX0 = 0
set_fe_HSDMA_glo_cfg
HSDMA_GLO_CFG = 465
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
serial8250: ttyS0 at MMIO 0x1e000d00 (irq = 27) is a 16550A
serial8250: ttyS1 at MMIO 0x1e000c00 (irq = 26) is a 16550A
serial8250: ttyS2 at MMIO 0x1e000e00 (irq = 28) is a 16550A
brd: module loaded
MediaTek Nand driver init, version v2.1 Fix AHB virt2phys error
Allocate 16 byte aligned buffer: 81a87e00
Enable NFI Clock
# MTK NAND # : Use HW ECC
NAND ID [C2 F1 80 95 02, 00809502]
Device found in MTK table, ID: c2f1, EXT_ID: 809502
alloctare : (mtd->writesize + mtd->oobsize) * page_per_block is 135168
Support this Device in MTK table! c2f1 
NAND device: Manufacturer ID: 0xc2, Chip ID: 0xf1 (Macronix NAND 128MiB 3,3V 8-bit), 128MiB, page size: 2048, OOB size: 64
[NAND]select ecc bit:4, sparesize :64 spare_per_sector=16
Scanning device for bad blocks
Signature matched and data read!
load_fact_bbt success 1023
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
page: 200
Found dynamic partition map at 100000:
page: 201
        <0> offset: 00000000, length: 00100000
page: 201
        <1> offset: 00100000, length: 00100000
page: 201
        <2> offset: 00200000, length: 00100000
page: 201
        <3> offset: 00300000, length: 00100000
page: 201
        <4> offset: 00400000, length: 00600000
page: 201
        <5> offset: 00A00000, length: 00600000
page: 201
        <6> offset: 01000000, length: 02000000
page: 201
        <7> offset: 03000000, length: 02000000
page: 201
        <8> offset: 05000000, length: 01400000
page: 201
        <9> offset: 06400000, length: 01B80000
Creating 10 MTD partitions on "MT7621-NAND":
0x000000000000-0x000000100000 : "Boot Loader"
0x000000100000-0x000000200000 : "dynamic partition map"
0x000000200000-0x000000300000 : "Factory"
0x000000300000-0x000000400000 : "Boot Flag"
0x000000400000-0x000000a00000 : "Kernel 1"
0x000000a00000-0x000001000000 : "Kernel 2"
0x000001000000-0x000003000000 : "File System 1"
0x000003000000-0x000005000000 : "File System 2"
0x000005000000-0x000006400000 : "Configuration/log"
0x000006400000-0x000007f80000 : "Debug (Ftool)"
[mtk_nand] probe successfully!
PPP generic driver version 2.4.2
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
PPTP driver version 0.8.5
register mt_drv

== pAd = c0181000, size = 5762112, Status=0 ==
pAd->PciHif.CSRBaseAddress =0xc0080000, csr_addr=0xc0080000!
RTMPInitPCIeDevice():device_id=0x7615
mt_pci_chip_cfg(): HWVer=0x8a10, FWVer=0x8a10, pAd->ChipID=0x7615
mt_pci_chip_cfg(): HIF_SYS_REV=0x76150001
AP Driver version-5.0.4.0
RtmpChipOpsHook(223): Not support for HIF_MT yet! MACVersion=0x0
mt7615_init()-->
Use 1st iPAiLNA default bin.
Use 0st /etc_ro/wlan/MT7615E_EEPROM1.bin default bin.
<--mt7615_init()
<-- RTMPAllocTxRxRingMemory, Status=0
rdm_major = 253
set CLK_CFG_0 = 0x40a00020!!!!!!!!!!!!!!!!!!1
GMAC1_MAC_ADRH -- : 0x0000000c
GMAC1_MAC_ADRL -- : 0x43288071
Ralink APSoC Ethernet Driver Initilization. v3.1  4096 rx/tx descriptors allocated, mtu = 1500!
set CLK_CFG_0 = 0x40a00020!!!!!!!!!!!!!!!!!!1
GMAC1_MAC_ADRH -- : 0x0000000c
GMAC1_MAC_ADRL -- : 0x43288091
<0>  !! create link_status PROC !!!!!
PROC INIT OK!
usbcore: registered new interface driver catc
usbcore: registered new interface driver kaweth
pegasus: v0.9.3 (2013/04/25), Pegasus/Pegasus II USB Ethernet driver
usbcore: registered new interface driver pegasus
usbcore: registered new interface driver rtl8150
usbcore: registered new interface driver r8152
usbcore: registered new interface driver asix
usbcore: registered new interface driver ax88179_178a
usbcore: registered new interface driver cdc_ether
usbcore: registered new interface driver cdc_eem
usbcore: registered new interface driver dm9601
usbcore: registered new interface driver smsc75xx
usbcore: registered new interface driver smsc95xx
usbcore: registered new interface driver gl620a
usbcore: registered new interface driver net1080
usbcore: registered new interface driver plusb
usbcore: registered new interface driver rndis_host
usbcore: registered new interface driver cdc_subset
usbcore: registered new interface driver zaurus
usbcore: registered new interface driver MOSCHIP usb-ethernet driver
usbcore: registered new interface driver int51x1
usbcore: registered new interface driver kalmia
usbcore: registered new interface driver ipheth
usbcore: registered new interface driver sierra_net
usbcore: registered new interface driver cx82310_eth
usbcore: registered new interface driver cdc_ncm
usbcore: registered new interface driver lg-vl600
usbcore: registered new interface driver qmi_wwan
usbcore: registered new interface driver cdc_mbim
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
uhci_hcd: USB Universal Host Controller Interface driver
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new interface driver usblp
usbcore: registered new interface driver cdc_wdm
usbcore: registered new interface driver usb-storage
Ralink APSoC Hardware Watchdog Timer
Init Ingress Classify module ...
GACT probability on
Mirror/redirect action on
Failed to load ipt action
u32 classifier
    Performance counters on
    Actions configured
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (3887 buckets, 15548 max)
ctnetlink v0.93: registering with nfnetlink.
NF_TPROXY: Transparent proxy support initialized, version 4.1.0
NF_TPROXY: Copyright (c) 2006-2007 BalaBit IT Ltd.
gre: GRE over IPv4 demultiplexor driver
ip_tables: (C) 2000-2006 Netfilter Core Team
Type=Linux
arp_tables: (C) 2002 David S. Miller
TCP: cubic registered
NET: Registered protocol family 10
ip6_tables: (C) 2000-2006 Netfilter Core Team
NET: Registered protocol family 17
l2tp_core: L2TP core driver, V2.0
l2tp_ppp: PPPoL2TP kernel driver, V2.0
8021q: 802.1Q VLAN Support v1.8
Sercomm dual images: bootflag=Sercomm1, choose /dev/mtdblock7 as rootfs
VFS: Mounted root (squashfs filesystem) readonly on device 31:7.
devtmpfs: mounted
Freeing unused kernel memory: 228K (81a37000 - 81a70000)
init started: BusyBox v1.15.3 ()
starting pid 52, tty '': '/etc/rcS'
mount: mounting usbfs on /proc/bus/usb failed: No such file or directory
register rlt_drv


=== pAd = c0d81000, size = 2223688 ===

<-- RTMPAllocTxRxRingMemory, Status=0, ErrorValue=0x
<-- RTMPAllocAdapterBlock, Status=0
pAd->CSRBaseAddress =0xc0c80000, csr_addr=0xc0c80000!
device_id =0x7603
RtmpChipOpsHook(474): Not support for HIF_MT yet!
mt7603_init()-->
mt_bcn_buf_init(224): Not support for HIF_MT yet!
<--mt7603_init()
load_dev_l1profile()-->
match_index_by_chipname() MT7603 found as INDEX0
l1set_profile_path() profile remain /etc/Wireless/RT2860/RT2860.dat
l1set_eeprom_offset() eeprom offset remain 0x0
l1set_eeprom_size() eeprom size remain 0x200
l1set_ifname() ifname rename from ra0 to ra
l1set_ifname() ifname remain ra
l1set_ifname() ifname remain ra
l1set_ifname() ifname remain apcli
hal_wd: module license 'sercomm' taints kernel.
Disabling lock debugging due to kernel taint
Init system monitor...
Sercomm HWIO Driver: loaded successfully
nUBI: attaching mtd8 to ubi8
UBI: scanning is finished
UBI: attached mtd8 (name "Configuration/log", size 20 MiB) to ubi8
UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
UBI: good PEBs: 160, bad PEBs: 0, corrupted PEBs: 0
UBI: user volume: 1, internal volumes: 1, max. volumes count: 128
UBI: max/mean erase counter: 4/1, WL threshold: 4096, image sequence number: 1912166438
UBI: available PEBs: 0, total reserved PEBs: 160, PEBs reserved for bad PEB handling: 20
UBI: background thread "ubi_bgt8d" started, PID 99
UBI device number 8, total 160 LEBs (20316160 bytes, 19.4 MiB), UBIFS: background thread "ubifs_bgt8_0" started, PID 101
available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
UBIFS: recovery needed
UBIFS: recovery completed
UBIFS: mounted UBI device 8, volume 0, name "rootfs_data"
UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
UBIFS: FS size: 15872000 bytes (15 MiB, 125 LEBs), journal size 9023488 bytes (8 MiB, 72 LEBs)
UBIFS: reserved for root: 0 bytes (0 KiB)
UBIFS: media format: w4/r0 (latest is w4/r0), UUID CA762117-2F99-4644-8A63-08B10E4CD8B8, small LPT model
net/nat/hw_nat/get_mem.c InitMod:40: Ralink HW NAT allocate DMA memory area
net/nat/hw_nat/get_mem.c InitMod:46: The DMA memory area has been allocated a0e00000 00e00000
Started WatchDog Timer.
switch register base addr to 0xb0100a00
write offset 0x80, value 0x5d805d80
write offset 0x84, value 0x1d801d80
SERIAL NUMBER:
FFFFFFFF:FFFFFFFF:FFFFFFFF:FFFFFFFF:FFFFFFFF:FFFFFFFF

Raeth v3.1 (Tasklet)
phy_free_head is 0xc92000!!!
phy_free_tail_phy is 0xc93ff0!!!
txd_pool=a0c98000 phy_txd_pool=00C98000
ei_local->skb_free start address is 0x8ee026cc.
free_txd: 00c98010, ei_local->cpu_ptr: 00C98000
 POOL  HEAD_PTR | DMA_PTR | CPU_PTR 
----------------+---------+--------
     0xa0c98000 0x00C98000 0x00C98000

phy_qrx_ring = 0x00c94000, qrx_ring = 0xa0c94000

phy_rx_ring0 = 0x00ca0000, rx_ring[0] = 0xa0ca0000
MT7530 Reset Completed!!
change HW-TRAP to 0x117c8f
set LAN/WAN WLLLL
GMAC1_MAC_ADRH -- : 0x00007c8f
GMAC1_MAC_ADRL -- : 0xdeacc120
GDMA2_MAC_ADRH -- : 0x0000000c
GDMA2_MAC_ADRL -- : 0x4328808e
eth3: ===> VirtualIF_open
MT7621 GE2 link rate to 1G
CDMA_CSG_CFG = 81000000
GDMA1_FWD_CFG = 20710000
GDMA2_FWD_CFG = 20710000
sc_lan_vlan_id = 1
sc_wan_vlan_id = 2
sc_special_vlan_id = 3
sc_host_queue = 3
rc_cmd=/usr/sbin/rc syslogd start 
rc_cmd=/usr/sbin/rc wan_switch start 
rc_cmd=/usr/sbin/rc lan_switch start 
rc_cmd=/usr/sbin/rc dnrd start 
rc_cmd=/usr/sbin/rc wlan start 
Interface doesn't accept private ioctl...
set (8BE2): Invalid argument
Interface doesn't accept private ioctl...
set (8BE2): Invalid argument
============guest<2> is disabled============
============guest<3> is disabled============
============guest<4> is disabled============
============guest<6> is disabled============
============guest<7> is disabled============
============guest<8> is disabled============
rc_cmd=/usr/sbin/rc lanip start init 
rc_cmd=/usr/sbin/rc firewall start 
ScDrvDev_ioctl: CMD: (20) is not supported
rc_cmd=rc radvd restart 
[Jan 01 00:00:37] radvd: no linklocal address configured for br0
[Jan 01 00:00:37] radvd: can't join ipv6-allrouters on br0
iptables: Bad rule (does a matching rule exist in that chain?).
rc_cmd=/usr/sbin/rc networkmap start init 
modprobe: module networkmap not found in modules.dep
rc_cmd=/usr/sbin/rc qos start 
rc_cmd=/usr/sbin/rc cpm start init 
Fri Apr 10 23:52:54 UTC 2020
cpm_1: stop=1, start=1
rc_cmd=/usr/sbin/rc httpd start 
rc_cmd=/usr/sbin/rc wanip stop 1 
rc_cmd=/usr/sbin/rc hw_nat stop 1 
rc_cmd=/usr/sbin/rc coredump start 
rc_cmd=/usr/sbin/rc qtbl stop 1 
rc_cmd=/usr/sbin/rc ieee_802_1x start 
rc_cmd=/usr/sbin/rc srt restart 
bind: Address already in use
bind: Address already in use
rc_cmd=/usr/sbin/rc rp start 
rc_cmd=/usr/sbin/rc hw_nat stop 1 
rc_cmd=/usr/sbin/rc qtbl stop 1 
rc_cmd=rc igmp_proxy stop 
rc_cmd=/usr/sbin/rc wanip start 1 
rc_cmd=/usr/sbin/rc udpecho start 
Apr/10/2020 23:52:55: dhcp6_ctl_authinit: failed to open /tmp/dhcp6sctlkey: No such file or directory
rc_cmd=/usr/sbin/rc ingress_qos start 
rc_cmd=/usr/sbin/rc ingress_classify start 
rc_cmd=/usr/sbin/rc qos_remark start 
rc_cmd=/usr/sbin/rc ipv6wd start 
rc_cmd=/usr/sbin/rc pppoe_relay start 
rc_cmd=/usr/sbin/rc telnetd start 
rc_cmd=/usr/sbin/rc sshd start 
rc_cmd=/usr/sbin/rc igd_upnp start 
rc_cmd=/usr/sbin/rc dnsr start 
rc_cmd=/usr/sbin/rc cron start 
RTNETLINK answers: Permission denied
Could not load host key: /etc/ssh/ssh_host_ed25519_key
rc_cmd=/usr/sbin/rc dnrd restart wid 1 no-service 
rc_cmd=/usr/sbin/rc wanip_service restart 1 
killall: sc_gw_watch_dog_1: no process killed
sc_gw_watch_dog INFO: X_RTK_IPArpEnable is disabled in config, wan_id=1, exit 0
rc_cmd=/usr/sbin/rc hw_nat stop 1 
rc_cmd=/usr/sbin/rc qtbl stop 1 
rc_cmd=/usr/sbin/rc cups start 
rc_cmd=/usr/sbin/rc umtsd start 
rc_cmd=/usr/sbin/rc dnrd restart wid 1 
rc_cmd=/usr/sbin/rc cwmp_stun start 
DualImage Sync: images are different, start sync
rc_cmd=/usr/sbin/rc dnsr restart 
rc_cmd=/usr/sbin/rc fw_wan restart 1 dmz 
Erasing 128 Kibyte @ 20000 -- 100 % complete 
starting pid 813, rc_cmd=/usr/sbin/rc fw_wan restart 1 port_map 
rc_cmd=/usr/sbin/rc fw_wan restart mgnt_acl_wan 
rc_cmd=/usr/sbin/rc ntp restart 1 
rc_cmd=/usr/sbin/rc srt restart 
rc_cmd=/usr/sbin/rc rp restart 1 

ETISALAT-S3 login: rc_cmd=/usr/sbin/rc hw_nat start 1 
rc_cmd=/usr/sbin/rc qtbl restart 1 
rc_cmd=/usr/sbin/rc ddns start 1 
rc_cmd=/usr/sbin/rc cron restart wlan_scheduler 
rc_cmd=/usr/sbin/rc cron restart pctrl 
rc_cmd=/usr/sbin/rc igd_upnp restart 
rc_cmd=/usr/sbin/rc ftpd restart 
rc_cmd=/usr/sbin/rc syslogd start 
rc_cmd=rc igmp_proxy start 
rc_cmd=rc igmp_proxy start 
cpm_1: restart: 1622759979
config_ipv6_default_gw set wan1
rc_cmd=/usr/sbin/rc dnrd restart wid 1 
rc_cmd=/usr/sbin/rc radvd restart 
rc_cmd=/usr/sbin/rc dnsr restart 
rc_cmd=/usr/sbin/rc wanip_service restart 1 
rc_cmd=/usr/sbin/rc ntp restart 1 
rc_cmd=/usr/sbin/rc hw_nat stop 1 
rc_cmd=/usr/sbin/rc cron restart wlan_scheduler 
rc_cmd=/usr/sbin/rc cron restart pctrl 
rc_cmd=/usr/sbin/rc qtbl stop 1 
rc_cmd=/usr/sbin/rc dnrd restart wid 1 
rc_cmd=/usr/sbin/rc dnsr restart 
rc_cmd=/usr/sbin/rc fw_wan restart 1 dmz 
rc_cmd=/usr/sbin/rc fw_wan restart 1 port_map 
rc_cmd=/usr/sbin/rc fw_wan restart mgnt_acl_wan 
rc_cmd=/usr/sbin/rc ntp restart 1 
rc_cmd=/usr/sbin/rc srt restart 
rc_cmd=/usr/sbin/rc cron restart wlan_scheduler 
rc_cmd=/usr/sbin/rc cron restart pctrl 
rc_cmd=/usr/sbin/rc rp restart 1 
rc_cmd=/usr/sbin/rc hw_nat start 1 
done
rc_cmd=/usr/sbin/rc qtbl restart 1 
rc_cmd=/usr/sbin/rc ddns start 1 
correct_header header_crc = eb087576
rc_cmd=/usr/sbin/rc igd_upnp restart 
crc = 0x7ee0514e
rc_cmd=/usr/sbin/rc ftpd restart 
rc_cmd=/usr/sbin/rc syslogd start 
rc_cmd=/usr/sbin/rc tr069 restart 
killall: cwmp: no process killed
killall: cwmp_ft: no process killed
crc = 0xc9164958
crc = 0x7ee0514e
crc = 0xc9164958
crc = 0x8b2866aa

ledit: apology forgot you already mentioned checksum method and did not read your post properly ignore most of what i've said other than general typical boot behavior...

I think it might be better to use slot 2 only for Openwrt and squash these mtds into the single and relatively large ubi partition. Stock ("Kernel 1" and "File System 1") can be used for emergency boot. What do you think about that?

1 Like

I just read the comments on github. That is one way to do it actually. I saw it on another device (I cannot recall which one).

Basically if you can check from the stock firmware which partition it is booting (which you can I believe on the Turbo+ device through ssh) you can flash the same stock firmware to make it boot from the other image (if need be).

Then create an image that is suitable for the new flash.

Ex: I am assuming the upgrade process flashes the opposite parittion (if active is mtd4/6 it will flash mtd5/7).

  • first confirm you are booting from mtd5/7
  • flash openwrt making sure mtd4/6 are used in the dts file as kernel/ubi
  • make sure the openwrt upgrade always upgrade mtd4/6.
  • one last thing I did not try is to split in the dts the sercomm header header from the kernel file. Since you will be using the same sercomm header there is no need to have it added everytime (just something I thought about but I didn't try)