V22.03.0 release does not work on D-Link DIR-645

Just leaving this here for others:

I did a sysupgrade from v21.02.3 and the LAN is dead. I then tried a factory v22.03.0 image through the built-in D-Link recovery to eliminate a sysupgrade issue and the LAN is still dead.

I went back to v21.02.3 through recovery and the router is back up.

I opened an issue here: https://github.com/openwrt/openwrt/issues/10634 and left a note on the DIR-645 wiki

Might be the kernel has grown too big, but one would need serial output to determine what goes wrong exactly.

Thanks.. I thought that too so flashed a smaller image using the firmware selector. Both sysupgrade and factory. I again had to go back to 21.02.3 to regain control. An 8/64 device shouldn't be quite obsolete yet especially if there aren't any additional packages and really light routing.

You're confusing image and kernel size. It wouldn't be the first device exceeding the hardcoded kernel size the manufacturer set - which is what would make hardware obsolete, not the fact a modern Linux kernel exceeds that arbitrary limit. But until you get serial going, it's all conjecture.

Thank you for the clarification. I will investigate the serial connection on this device.

I was able to connect via serial and here is the output. The following just repeats over and over:

U-Boot 1.1.3 (Apr 15 2011 - 10:39:36) (ALPHA)
SVN revision: 516
Target board: WRG-N39

Board: Ralink APSoC DRAM:  64 MB
spi_wait_nsec: 30
spi device id: c2 20 17 c2 20 (2017c220)
find flash: MX25L6405D
raspi_read: from:30000 len:1000
.raspi_read: from:30000 len:1000
.============================================
Ralink UBoot Version: 3.3
--------------------------------------------
ASIC 3883_MP (MAC to REALTEK Mode)
DRAM component: 512 Mbits DDR, width 16
DRAM bus: 16 bit
Total memory: 64 MBytes
Flash component: SPI Flash
Date:Apr 15 2011  Time:10:39:36
============================================
icache: sets:512, ways:4, linesz:32 ,total:65536
dcache: sets:256, ways:4, linesz:32 ,total:32768
gpio_init: write 0x00001801
gpio_init: write 0x0000185d to GPIOMODE(0xb0000060)

 Initializing RTL8367 GbE switch ...
 Setting RTL8367RB RGMII Delay time tx:1,rx0

Please choose the operation:
   1: Load system code to SDRAM via TFTP.
   2: Load system code then write to Flash via TFTP.
   3: Boot system code via Flash (default).
   4: Entr boot command line interface.
   7: Load Boot Loader code then write to Flash via Serial.
   9: Load Boot Loader code then write to Flash via TFTP.                                                                                                                                  0

3: System Boot system code via Flash.
## Booting image at bc050000 ...
raspi_read: from:50000 len:40
.raspi_read: from:50000 len:c
.raspi_read: from:50000 len:5738a6
........................................................................................We have SEAMA, Image Size = 5716070
Verifying Checksum ...
Uncompressing SEAMA linux.lzma ... LZMA ERROR 1 - must RESET board to recover

I flashed back to 21.02.3 and the only difference I see is:

3: System Boot system code via Flash.
## Booting image at bc050000 ...
raspi_read: from:50000 len:40
.raspi_read: from:50000 len:c
.raspi_read: from:50000 len:4ea004
...............................................................................We have SEAMA, Image Size = 5152708
Verifying Checksum ...
Uncompressing SEAMA linux.lzma ... OK
## Transferring control to Linux (at address 80000000) ...
## Giving linux memsize in MB, 64

Starting kernel ...

That error really hints at the kernel being too big. That's often worked around by using an LZMA loader to relocate the kernel. See e.g.

Thanks @Borromini for your expertise.

I also found that LZMA ERROR 1 for others were due to just a wrong header version or loading at the wrong address: [Solved] Uboot - Not enough buffer for decompression LZMA ERROR 1 - #29 by numero53

Well, I'd reckon that memory addres hasn't changed between 21.02 and 22.03. Same about the header. Lots of stuff have changed and kernel size is (unfortunately) always a big one - from 5.4 to 5.10 in this case.

I have no experience with migrating devices to the LZMA loader, but it's certainly worth a try. That seems more likely to be the issue to me in this case.

@xabolcs Would you mind taking a peek?

Just did it today, but I don't have good news.

The dlink_dir-645 recipe has $(Device/uimage-lzma-loader) long ago:

It has a lzma -d10 too but that is now a dead code because of and that negates (?!) the commit above.

EDIT:
This is the first time when I see that uimage-lzma-loader is unable to fix the LZMA ERROR 1 problem. :confused:

1 Like

I could cook a few firmware with updated recipes, if you are willing to flash random community builds found on the internet to your router! :slight_smile:

Should I give it a spin?

1 Like

Absolutely... I'll be glad to dedicate a device for testing to help

I wrote a few patch, but I wasn't able to use ImageBuilder as a shortcut: need to build the whole stuff. :frowning:

Will post the binaries a few hours later ... :person_shrugging:

./dir-645-patch-dir-860l-style-uimage-none.patch:

--- target/linux/ramips/image/rt3883.mk.bak	2022-09-14 16:48:00.997749977 +0200
+++ target/linux/ramips/image/rt3883.mk	2022-09-14 16:54:16.656954661 +0200
@@ -28,21 +28,22 @@
   KERNEL := kernel-bin | append-dtb | lzma -d16 | uImage lzma
   # Stock firmware checks for this uImage image name during upload.
   UIMAGE_NAME := N750F9K1103VB
 endef
 TARGET_DEVICES += belkin_f9k1109v1
 
 define Device/dlink_dir-645
   $(Device/seama)
-  $(Device/uimage-lzma-loader)
   SOC := rt3662
   BLOCKSIZE := 4k
   IMAGE_SIZE := 7872k
-  KERNEL := kernel-bin | append-dtb | lzma -d10
+  LOADER_TYPE := bin
+  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | relocate-kernel | \
+	uImage none
   SEAMA_SIGNATURE := wrgn39_dlob.hans_dir645
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DIR-645
   DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2
   SUPPORTED_DEVICES += dir-645
 endef
 TARGET_DEVICES += dlink_dir-645

./dir-645-patch-dir-860l-style.patch:

--- target/linux/ramips/image/rt3883.mk.bak	2022-09-14 16:48:00.997749977 +0200
+++ target/linux/ramips/image/rt3883.mk	2022-09-14 16:49:26.050475557 +0200
@@ -28,21 +28,22 @@
   KERNEL := kernel-bin | append-dtb | lzma -d16 | uImage lzma
   # Stock firmware checks for this uImage image name during upload.
   UIMAGE_NAME := N750F9K1103VB
 endef
 TARGET_DEVICES += belkin_f9k1109v1
 
 define Device/dlink_dir-645
   $(Device/seama)
-  $(Device/uimage-lzma-loader)
   SOC := rt3662
   BLOCKSIZE := 4k
   IMAGE_SIZE := 7872k
-  KERNEL := kernel-bin | append-dtb | lzma -d10
+  LOADER_TYPE := bin
+  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | relocate-kernel | \
+	lzma -a0 | uImage lzma
   SEAMA_SIGNATURE := wrgn39_dlob.hans_dir645
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DIR-645
   DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2
   SUPPORTED_DEVICES += dir-645
 endef
 TARGET_DEVICES += dlink_dir-645

./dir-645-patch-dir-860l-style-lzma-d10-no-relocate.patch:

--- target/linux/ramips/image/rt3883.mk.bak	2022-09-14 16:48:00.997749977 +0200
+++ target/linux/ramips/image/rt3883.mk	2022-09-14 16:58:58.883421251 +0200
@@ -28,21 +28,22 @@
   KERNEL := kernel-bin | append-dtb | lzma -d16 | uImage lzma
   # Stock firmware checks for this uImage image name during upload.
   UIMAGE_NAME := N750F9K1103VB
 endef
 TARGET_DEVICES += belkin_f9k1109v1
 
 define Device/dlink_dir-645
   $(Device/seama)
-  $(Device/uimage-lzma-loader)
   SOC := rt3662
   BLOCKSIZE := 4k
   IMAGE_SIZE := 7872k
-  KERNEL := kernel-bin | append-dtb | lzma -d10
+  LOADER_TYPE := bin
+  KERNEL := kernel-bin | append-dtb | lzma -d10 | loader-kernel | \
+	lzma -a0 | uImage lzma
   SEAMA_SIGNATURE := wrgn39_dlob.hans_dir645
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DIR-645
   DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2
   SUPPORTED_DEVICES += dir-645
 endef
 TARGET_DEVICES += dlink_dir-645

./dir-645-patch-uimage-lzma-loader-style-lzma-d10.patch:

--- target/linux/ramips/image/rt3883.mk.bak	2022-09-14 16:48:00.997749977 +0200
+++ target/linux/ramips/image/rt3883.mk	2022-09-14 16:59:51.491881690 +0200
@@ -28,21 +28,21 @@
   KERNEL := kernel-bin | append-dtb | lzma -d16 | uImage lzma
   # Stock firmware checks for this uImage image name during upload.
   UIMAGE_NAME := N750F9K1103VB
 endef
 TARGET_DEVICES += belkin_f9k1109v1
 
 define Device/dlink_dir-645
   $(Device/seama)
-  $(Device/uimage-lzma-loader)
   SOC := rt3662
   BLOCKSIZE := 4k
   IMAGE_SIZE := 7872k
-  KERNEL := kernel-bin | append-dtb | lzma -d10
+  LOADER_TYPE := bin
+  KERNEL := kernel-bin | append-dtb | lzma -d10 | loader-kernel | uImage none
   SEAMA_SIGNATURE := wrgn39_dlob.hans_dir645
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DIR-645
   DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2
   SUPPORTED_DEVICES += dir-645
 endef
 TARGET_DEVICES += dlink_dir-645

./dir-645-patch-dir-860l-style-no-relocate.patch:

--- target/linux/ramips/image/rt3883.mk.bak	2022-09-14 16:48:00.997749977 +0200
+++ target/linux/ramips/image/rt3883.mk	2022-09-14 16:58:12.659016687 +0200
@@ -28,21 +28,22 @@
   KERNEL := kernel-bin | append-dtb | lzma -d16 | uImage lzma
   # Stock firmware checks for this uImage image name during upload.
   UIMAGE_NAME := N750F9K1103VB
 endef
 TARGET_DEVICES += belkin_f9k1109v1
 
 define Device/dlink_dir-645
   $(Device/seama)
-  $(Device/uimage-lzma-loader)
   SOC := rt3662
   BLOCKSIZE := 4k
   IMAGE_SIZE := 7872k
-  KERNEL := kernel-bin | append-dtb | lzma -d10
+  LOADER_TYPE := bin
+  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | \
+	lzma -a0 | uImage lzma
   SEAMA_SIGNATURE := wrgn39_dlob.hans_dir645
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DIR-645
   DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2
   SUPPORTED_DEVICES += dir-645
 endef
 TARGET_DEVICES += dlink_dir-645

dir-645-22.03-lzma-error-01.tar.xz

Please flash the factory.bin first! And if it boots, then reflash it with sysupgrade.bin!
I don't think either will work! :sweat_smile:

Thank you, unfortunately same error:

factory.bin flash:

mpfd_decode: UPLOADED, upsize = 5009460
SEAMA ==========================================
  magic      : 5ea3a417
  meta size  : 36 bytes
  meta data  : signature=wrgn39_dlob.hans_dir645
  meta data  :
  meta data  :
  image size : 0 bytes
================================================
SEAMA ==========================================
  magic      : 5ea3a417
  meta size  : 36 bytes
  meta data  : dev=/dev/mtdblock/2
  meta data  : type=firmware
  meta data  :
  meta data  :
  image size : 5009348 bytes
  checksum   : 81DB8C5E1FA97DE569606C9F35D2250E
  digest     : 81DB8C5E1FA97DE569606C9F35D2250E
  Selected !!!
================================================
Copy SEAMA with header (from 0x80100030).
raspi_erase_write: offs:50000, count:4c7004
raspi_erase: offs:50000 len:4c0000
............................................................................
raspi_write: to:50000 len:4c0000
............................................................................
raspi_read: from:510000 len:10000
.raspi_erase: offs:510000 len:10000
.
raspi_write: to:510000 len:10000
.
Done!

Boot:

U-Boot 1.1.3 (Apr 15 2011 - 10:39:36) (ALPHA)
SVN revision: 516
Target board: WRG-N39

Board: Ralink APSoC DRAM:  64 MB
spi_wait_nsec: 30
spi device id: c2 20 17 c2 20 (2017c220)
find flash: MX25L6405D
raspi_read: from:30000 len:1000
.raspi_read: from:30000 len:1000
.============================================
Ralink UBoot Version: 3.3
--------------------------------------------
ASIC 3883_MP (MAC to REALTEK Mode)
DRAM component: 512 Mbits DDR, width 16
DRAM bus: 16 bit
Total memory: 64 MBytes
Flash component: SPI Flash
Date:Apr 15 2011  Time:10:39:36
============================================
icache: sets:512, ways:4, linesz:32 ,total:65536
dcache: sets:256, ways:4, linesz:32 ,total:32768
gpio_init: write 0x00001801
gpio_init: write 0x0000185d to GPIOMODE(0xb0000060)

 Initializing RTL8367 GbE switch ...
 Setting RTL8367RB RGMII Delay time tx:1,rx0

Please choose the operation:
   1: Load system code to SDRAM via TFTP.
   2: Load system code then write to Flash via TFTP.
   3: Boot system code via Flash (default).
   4: Entr boot command line interface.
   7: Load Boot Loader code then write to Flash via Serial.
   9: Load Boot Loader code then write to Flash via TFTP.                                                                                                                                  0

3: System Boot system code via Flash.
## Booting image at bc050000 ...
raspi_read: from:50000 len:40
.raspi_read: from:50000 len:c
.raspi_read: from:50000 len:4c7004
.............................................................................We have SEAMA, Image Size = 5009348
Verifying Checksum ...
Uncompressing SEAMA linux.lzma ... LZMA ERROR 1 - must RESET board to recover

Do you want me to try the sysupgrade from 21.02.3?

Standby I didn't try the other 3...

@xabolcs Unfortunately all 5 stopped at the same error:

Verifying Checksum ...
Uncompressing SEAMA linux.lzma ... LZMA ERROR 1 - must RESET board to recover

:crossed_fingers: Was hoping one would have been the patch needed

1 Like

:roll_eyes:

One thing I could try is the OKLI Loader, e.g.:

It does work for mt7620 and mt7621, but not for rt305x. Hope it works for rt3883. :woman_shrugging:

No problem I'll try that one as well when ready

I noticed that for 21.02 release the LZMA dictionary size was reduced (https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=6fba88de1913301f11163aa05298e4fb488b3640).

Could it help to reduce it further?