Alexander Gromnitsky's Blog

OpenWrt 18.06.1 on D-Link DIR-320 A1

Latest update:

OpenWrt was supporting Dir320 A1 up until the infamous LEDE split. Somewhere during the great divide the support has been lost: today, even if you manage to squeeze a custom OpenWrt build into a contemptible 3.7MB, the petty device isn't going to work as it always did w/ 15.05 or earlier--after the 1st boot the switch config will be incorrect.

The modern OpenWrt employs a plain boardtype/boardnum/model heuristics to determine the initial network config. The current dir320 model detection scheme yields to a disappointment:

# cat /tmp/sysinfo/model
Unknown Board

But OpenWrt doesn't give up & uses the values from the nvram for an additional hardware identification:

# nvram show | grep board
boardnum=
boardflags=0x750
boardtype=0x048e
boardrev=0x35

Unluckily, despite that WL-500gP device has a very similar hardware to dir320, it has a diff boardtype id, thence, from the OpenWrt standpoint, doesn't qualify as a suitable clone.

As the only path of having 18.06.1 on dir320 lies through a custom build process, we can easily provide a patched version of etc/board.d/01_network file to the Image Builder. Here, I've shoved the patch into a small makefile that also contains the default target for the image building.

out := _patch.d-link-dir-320-a1

.PHONY: image
image: $(out).target
    make image FILES=$(out) PROFILE=Broadcom-b43 PACKAGES='kmod-usb2 kmod-usb-ohci kmod-usb-storage kmod-fs-ext4 block-mount kmod-scsi-core -b43legacy-firmware -kmod-b43legacy -kmod-b43 -kmod-cfg80211 -kmod-mac80211 -hostapd-common -iw -wireless-regdb -wpad-mini'

$(out).target:
    $(shell mkdir -p $(out)/etc/board.d)
    cp target/linux/brcm47xx/base-files/etc/board.d/01_network $(out)/etc/board.d
    $(file > $(out)/etc/board.d/1,$(subst \\,\,$(p)))
    cd $(out)/etc/board.d && patch -lp0 < 1 && rm 1
    touch $@

define p :=
--- 01_network.orig     2018-10-02 10:50:16.477811644 +0300
+++ 01_network  2018-10-01 12:50:19.461816123 +0300
@@ -75,6 +75,11 @@
                        "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5@eth0"
                ;;

+       "0x048e") # d-link dir-320 a1
+               ucidef_add_switch "switch0" \\
+                       "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "5@eth0"
+               ;;
+
        "0x042f" | \\
        "0x0472")
                # WL-500gP
endef

It expunges all the wireless staff, for the firmware size must be < 3.7MB. (I've tried to put a 4MB ver but OpenWrt was throwing out all my /etc customisations on each reboot.) Do an extroot procedure & install the req pkgs via opkg if you need the wireless.

Save the makefile somewhere & run:

$ wget https://downloads.openwrt.org/releases/18.06.1/targets/brcm47xx/legacy/openwrt-imagebuilder-18.06.1-brcm47xx-legacy.Linux-x86_64.tar.xz
$ tar xfJ openwrt*
$ cd openwrt*64
$ make -f ../d-link-dir-320-a1.mk

Your new firmware will be in bin/targets/brcm47xx/legacy/openwrt-18.06.1-brcm47xx-legacy-asus-wl-500gp-v2-squashfs.trx file.


Tags: ойті
Authors: ag