OpenWrt on a old D-Link DSL2640B E1 HW

Hi,
as the title says I have an old D-Link DSL-2640B (E1 H/W Version, generic, not Infostrada) laying around.
I know it is old, unsafe, with ridicolous (for today) specs and so on, but I would like to play a bit with it (not exposing it to Internet) to become more familiar with OpenWRT.
Is there any old version of OpenWRT compatible with it? In case, where can I found it (maybe with instructions)?
Thanks

Consult the wiki:

It's not completely useless, as the memory is 8/64 MB, which is large enough for current versions.

There is a DSL2640B build in the 19.07.6/brcm63xx directory, but it may not be exactly for the E1 version.

I had read it, it has no useful information, because it is "under construction". While digging on the forum I found some archived discussions (Support for DSL-2640B E1) ( Experiences with D-Link DSL-2640B (ADSL2+ Router) (new to OpenWRT)) and "new" ones (D-link DSL 2640b as a repeater) (D-Link DSL-2640B rev.E1) about it, but I wasn't able to figure out if they are all about the E1 rev and in case what version could I use

Thanks, how could I know if it is for the E1 version?

Hi there! I'm here messing around with a HW: T1 version of the DSL-2640B. As far as I know, it was mainly present in Brazil... Should I create a new topic, specifically for the T1 version, or can we continue here, as - I think - the requirements are basically the same?

Just to give some information in advance, what I was able to do up to now was to connect it via the internal serial port and compile + flash the firmware released by D-Link under the GPL. I was not able to flash OpenWRT yet. The last message was something like "your firmware is too big for the device" so now I'm in the process of reducing it using the tips I found here: https://openwrt.org/docs/guide-user/additional-software/saving_space

Regarding the device specs, this is what I got from the serial port:

CFE version 1.0.37-10.3 for BCM96338 (32bit,SP,BE)
Build Date: Fri Jul  3 19:16:30 CST 2009 (root@localhost.localdomain)
Copyright (C) 2000-2006 Broadcom Corporation.

Boot Address 0xbfc00000

Initializing Arena.
Initializing Devices.
Serial flash device: name NX25P32, id 0xef15, size 4096KB
Flash Layout: Boot[63,0xbfff0000] Kern[1,0xbfc10000]
              AuxFS[61,0xbffd0000] Misc[61,0xbffd0000] PSI[63,0xbfff0000]
Flash RootFS Partition Length: 3932160
100 MB Full-Duplex (auto-neg)
CPU type 0x29010: 240MHz
Total memory: 16777216 bytes (16MB)

Total memory used by CFE:  0x80401000 - 0x80528970 (1210736)
Initialized Data:          0x8041E050 - 0x80420170 (8480)
BSS Area:                  0x80420170 - 0x80426970 (26624)
Local Heap:                0x80426970 - 0x80526970 (1048576)
Stack Area:                0x80526970 - 0x80528970 (8192)
Text (code) segment:       0x80401000 - 0x8041E044 (118852)
Boot area (physical):      0x00529000 - 0x00569000
Relocation Factor:         I:00000000 - D:00000000

Board IP address                  : 192.168.1.1:ffffff00  
Host IP address                   : 192.168.1.100  
Gateway IP address                :   
Run from flash/host (f/h)         : f  
Default host run file name        : vmlinux  
Default host flash file name      : bcm963xx_fs_kernel  
Boot delay (0-9 seconds)          : 1  
Board Id (0-9)                    : 96333W  
Number of MAC Addresses (1-32)    : 11  
Base MAC Address                  : 00:26:5a:54:8a:95  
PSI Size (1-64) KBytes            : 24  
Flash Block Size (1-128) in KBytes: 0  
Auxillary File System Size Percent: 0  

Best wishes, crew!

The fact that there is only 16 MB of RAM makes this project impossible. 32 is only barely enough for recent kernels. The minimum hardware now recommended for OpenWrt is 8 MB flash and 64 MB RAM.

I understand it's a very limited box and it won't have any fancy openwrt resources available, but all I want is to use it as a switch anyway, so not having many features is not a problem. Let me show you how far I got up to now:

Booting from only image (0xbfc10000) ...
Code Address: 0x80A00000, Entry Address: 0x80a00000
Decompression OK!
Entry at 0x80a00000
Closing network.
Starting program at 0x80a00000
[    0.000000] Linux version 5.4.117 (alexsmith@xps13) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r16708-e7249669d2)) #0 Wed May 12 16:32:03 2021
[    0.000000] Detected Broadcom 0x6338 CPU revision a2
[    0.000000] CPU frequency is 240 MHz
[    0.000000] 16MB of RAM installed
[    0.000000] board_bcm963xx: Boot address 0xbfc00000
[    0.000000] board_bcm963xx: CFE version: unknown
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00029010 (Broadcom BCM6338)
[    0.000000] board: board name: 96338W2_E7T
[    0.000000] MIPS: machine is D-Link DSL-2640U/BRU/C
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 16kB, VIPT, 2-way, linesize 16 bytes.
[    0.000000] Primary data cache 8kB, 2-way, VIPT, no aliases, linesize 16 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000000ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000000ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000000ffffff]
[    0.000000] Built 1 zonelists, mobility grouping off.  Total pages: 4060
[    0.000000] Kernel command line: rootfstype=squashfs,jffs2 noinitrd console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.000000] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 9896K/16384K available (4123K kernel code, 203K rwdata, 460K rodata, 1284K init, 194K bss, 6488K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=16, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 256
[    0.000000] random: get_random_bytes called from 0x804bfa20 with crng_init=0
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 15927170388 ns
[    0.000047] sched_clock: 32 bits at 120MHz, resolution 8ns, wraps every 17895697403ns
[    0.008397] Calibrating delay loop... 239.61 BogoMIPS (lpj=1198080)
[    0.085095] pid_max: default: 32768 minimum: 301
[    0.091352] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.099000] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.132657] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.143099] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.150837] pinctrl core: initialized pinctrl subsystem
[    0.159869] NET: Registered protocol family 16
[    0.328899] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    0.358365] clocksource: Switched to clocksource MIPS
[    0.373433] NET: Registered protocol family 2
[    0.382292] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.391471] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.399786] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.407179] TCP: Hash tables configured (established 1024 bind 1024)
[    0.415218] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.422415] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.431816] NET: Registered protocol family 1
[    0.436526] PCI: CLS 0 bytes, default 16
[    0.481377] workingset: timestamp_bits=14 max_order=12 bucket_order=0
[    0.537942] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.544221] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.695816] fffe0300.serial: ttyS0 at MMIO 0xfffe0300 (irq = 10, base_baud = 1562500) is a bcm63xx_uart
[    0.705899] printk: console [ttyS0] enabled
[    0.705899] printk: console [ttyS0] enabled
[    0.714723] printk: bootconsole [early0] disabled
[    0.714723] printk: bootconsole [early0] disabled
[    0.731194] physmap-flash bfc00000.nor: physmap platform flash device: [mem 0xbfc00000-0xbfffffff]
[    0.740866] physmap-flash bfc00000.nor: map_probe failed
[    0.789626] bcm63xx-spi fffe0c00.spi: at [mem 0xfffe0c00-0xfffe0c3f flags 0x200] (irq 9, FIFOs size 63)
[    0.805562] libphy: Fixed MDIO Bus: probed
[    0.847188] libphy: bcm63xx_enet MII bus: probed
[    0.852955] Generic PHY bcm63xx_enet-0:00: attached PHY driver [Generic PHY] (mii_bus:phy_addr=bcm63xx_enet-0:00, irq=POLL)
[    0.866564] bcm63xx-wdt bcm63xx-wdt:  started, timer margin: 30 sec
[    0.878781] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.886013] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.893493] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.900960] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.908170] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.917797] NET: Registered protocol family 17
[    0.923025] 8021q: 802.1Q VLAN Support v1.8
[    0.963492] /dev/root: Can't open blockdev
[    0.967772] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    0.975713] Please append a correct "root=" boot option; here are the available partitions:
[    0.984582] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    0.993106] Rebooting in 1 seconds..
�    1.995321] triggering watchdog soft-reset...

It seems like I have to tweak the dts file a bit for it to find the partitions...

If you're only using it as a switch, why even bother?

The last couple of days have been a huge learning curve for me. I went from zero knowledge on OpenWRT to being able to build it and hopefully to patch and port it. This alone is a great reason to keep going imo. Besides this DSL-2640B is the only box I have here to test. OpenWRT can also benefit from this quest, as one more person will be able to help porting to new/old devices. Don't you agree?

indeed, but right now you're trying to squeeze an intermodal container into a Beetle :wink:

1 Like

And surprisingly it appears like it will fit. :smiley:
I'm a bit lost on how to find out the partitions and set them up correctly... Do you think changing the DTS is the way to go?

Fit and work are two different things :wink:

But I wish you all the best.

Sorry, can't help you with the DTS.

1 Like

Hi @alexsmith. The partitions defined in your dts are OK, the problem is the flash chip, they're defined for a parallel NOR flash:

whereas in your device there is an SPI NOR flash:

Therefore this should be fixed using an SPI flash node. But it might not be enough, BCM6338 had a bug with serial flashes (an SPI FIFO size issue). There was a patch elsewhere that can be found in the old forum to fix this problem.

Regards

1 Like

Thank you so much, @danitool! That's certainly a very useful info. As you can see, I'm a newbie here so thanks again for shining some lights. By the way, do you know if it is possible to boot a new image directly from a host or if I have to flash it all the time? It's a pain (very time-consuming) to re-build and flash every time I change only one or two lines of code...

If the boot loader support memory booting, you could boot images (initramfs) stored on the TFTP server in memory.
But it's sub optimal based on the fact you only have 16MB RAM.

1 Like

This is the latest boot log:

CFE version 1.0.37-10.3 for BCM96338 (32bit,SP,BE)
Build Date: Tue May 31 14:36:37 EDT 2011 (root@localhost.localdomain)
Copyright (C) 2000-2006 Broadcom Corporation.

Boot Address 0xbfc00000

Initializing Arena.
Initializing Devices.
max_op_len=63
flash=W25X32 size=4MB id=0xef3016  sector=64k
st_reg1_3c|Serial flash device: name W25X32, id 0xef3016, size 4096KB
Flash Layout: Boot[63,0xbfff0000] Kern[1,0xbfc10000]
              AuxFS[61,0xbffd0000] Misc[61,0xbffd0000] PSI[63,0xbfff0000]
Flash RootFS Partition Length: 3932160
100 MB Full-Duplex (auto-neg)
CPU type 0x29010: 240MHz
Total memory: 16777216 bytes (16MB)

Total memory used by CFE:  0x80401000 - 0x80526390 (1201040)
Initialized Data:          0x8041DB60 - 0x8041FB90 (8240)
BSS Area:                  0x8041FB90 - 0x80424390 (18432)
Local Heap:                0x80424390 - 0x80524390 (1048576)
Stack Area:                0x80524390 - 0x80526390 (8192)
Text (code) segment:       0x80401000 - 0x8041DB5C (117596)
Boot area (physical):      0x00527000 - 0x00567000
Relocation Factor:         I:00000000 - D:00000000


Board IP address                  : 192.168.1.1:ffffff00  
Host IP address                   : 192.168.1.3  
Gateway IP address                :   
Run from flash/host (f/h)         : f  
Default host run file name        : vmlinux  
Default host flash file name      : bcm963xx_fs_kernel  
Boot delay (0-9 seconds)          : 1  
Board Id (0-9)                    : 96333W  
Number of MAC Addresses (1-32)    : 11  
Base MAC Address                  : 00:26:5a:54:8a:95  
PSI Size (1-64) KBytes            : 24  
Flash Block Size (1-128) in KBytes: 1  
Auxillary File System Size Percent: 0  

udp_send finished
No answer .auto boot ...
*** Press any key to stop auto run (1 seconds) ***
Auto run second count down: 0
Booting from only image (0xbfc10000) ...
Code Address: 0x80A00000, Entry Address: 0x80a00000
Decompression OK!
Entry at 0x80a00000
Closing network.
Starting program at 0x80a00000
[    0.000000] Linux version 5.4.117 (alexsmith@xps13) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r16708-e7249669d2)) #0 Wed May 12 16:32:03 2021
[    0.000000] Detected Broadcom 0x6338 CPU revision a2
[    0.000000] CPU frequency is 240 MHz
[    0.000000] 16MB of RAM installed
[    0.000000] board_bcm963xx: Boot address 0xbfc00000
[    0.000000] board_bcm963xx: CFE version: unknown
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00029010 (Broadcom BCM6338)
[    0.000000] board: board name: 96338W2_E7T
[    0.000000] MIPS: machine is D-Link DSL-2640U/BRU/C
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 16kB, VIPT, 2-way, linesize 16 bytes.
[    0.000000] Primary data cache 8kB, 2-way, VIPT, no aliases, linesize 16 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000000ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000000ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000000ffffff]
[    0.000000] Built 1 zonelists, mobility grouping off.  Total pages: 4060
[    0.000000] Kernel command line: rootfstype=squashfs,jffs2 noinitrd console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.000000] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 9896K/16384K available (4123K kernel code, 203K rwdata, 460K rodata, 1284K init, 194K bss, 6488K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=16, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 256
[    0.000000] random: get_random_bytes called from 0x804bfa20 with crng_init=0
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 15927170388 ns
[    0.000048] sched_clock: 32 bits at 120MHz, resolution 8ns, wraps every 17895697403ns
[    0.008398] Calibrating delay loop... 239.61 BogoMIPS (lpj=1198080)
[    0.085095] pid_max: default: 32768 minimum: 301
[    0.091349] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.098990] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.132645] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.143089] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.150826] pinctrl core: initialized pinctrl subsystem
[    0.159881] NET: Registered protocol family 16
[    0.328973] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    0.358323] clocksource: Switched to clocksource MIPS
[    0.373375] NET: Registered protocol family 2
[    0.382312] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.391488] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.399808] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.407206] TCP: Hash tables configured (established 1024 bind 1024)
[    0.415243] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.422437] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.431841] NET: Registered protocol family 1
[    0.436552] PCI: CLS 0 bytes, default 16
[    0.481425] workingset: timestamp_bits=14 max_order=12 bucket_order=0
[    0.538045] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.544328] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.696297] fffe0300.serial: ttyS0 at MMIO 0xfffe0300 (irq = 10, base_baud = 1562500) is a bcm63xx_uart
[    0.706384] printk: console [ttyS0] enabled
[    0.706384] printk: console [ttyS0] enabled
[    0.715208] printk: bootconsole [early0] disabled
[    0.715208] printk: bootconsole [early0] disabled
[    0.731243] physmap-flash physmap-flash.0: physmap platform flash device: [mem 0x1fc00000-0x1fffffff]
[    0.781180] physmap-flash physmap-flash.0: map_probe failed
[    0.795882] spi_master spi0: /ubus@fff00000/spi@fffe0c00/partitions has no valid 'reg' property (-22)
[    0.805790] spi_master spi0: Failed to create SPI device for /ubus@fff00000/spi@fffe0c00/partitions
[    0.815419] bcm63xx-spi fffe0c00.spi: at [mem 0xfffe0c00-0xfffe0c03 flags 0x200] (irq 9, FIFOs size 63)
[    0.831617] libphy: Fixed MDIO Bus: probed
[    0.873657] libphy: bcm63xx_enet MII bus: probed
[    0.879362] Generic PHY bcm63xx_enet-0:00: attached PHY driver [Generic PHY] (mii_bus:phy_addr=bcm63xx_enet-0:00, irq=POLL)
[    0.893047] bcm63xx-wdt bcm63xx-wdt:  started, timer margin: 30 sec
[    0.904975] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.912517] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.919986] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.927193] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.934644] leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 ((null))
[    0.944280] NET: Registered protocol family 17
[    0.949512] 8021q: 802.1Q VLAN Support v1.8
[    0.989878] /dev/root: Can't open blockdev
[    0.994156] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    1.002084] Please append a correct "root=" boot option; here are the available partitions:
[    1.010901] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    1.019421] Rebooting in 1 seconds..
�    2.021636] triggering watchdog soft-reset...

Specifically these lines:

[    0.731243] physmap-flash physmap-flash.0: physmap platform flash device: [mem 0x1fc00000-0x1fffffff]
[    0.781180] physmap-flash physmap-flash.0: map_probe failed
[    0.795882] spi_master spi0: /ubus@fff00000/spi@fffe0c00/partitions has no valid 'reg' property (-22)
[    0.805790] spi_master spi0: Failed to create SPI device for /ubus@fff00000/spi@fffe0c00/partitions

spi is being probed at spi@fffe0c00, but that address is certainly invalid. Any hints on what can I do to find the right address? I have full access to the console using the flash I compiled from the Broadcom sources, but it's a very old kernel and has no /sys...

Just to add the following from the Broadcom compiled (and working) firmware:

> sh -c "cat /proc/mtd"  
dev:    size   erasesize  name
mtd0: 002ec000 00004000 "Physically mapped flash"

Maybe 002ec000 ring some bells?

Thanks again!

@alexsmith you may also need to change this kernel line:
https://elixir.bootlin.com/linux/v5.4.119/source/arch/mips/bcm63xx/dev-flash.c#L73

and use BCM63XX_FLASH_TYPE_SERIAL instead

Did that. Now these two lines are gone:

[    0.731243] physmap-flash physmap-flash.0: physmap platform flash device: [mem 0x1fc00000-0x1fffffff]
[    0.781180] physmap-flash physmap-flash.0: map_probe failed

But I still need to find the correct address for spi (I guess). The default is fffe0c00, but I'll try to change it to c000... If you know an easier way (instead of guessing), you're very welcome to help me. :slight_smile:

You probably forgot to add the spi stuff to your flash subnode:

&lsspi {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <781000>;

		partitions {
			compatible = "fixed-partitions";

Next time post your dts file

1 Like