From 0cf581ca3a2a692938003a7038d93f2e24d9125a Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Mon, 21 Nov 2016 08:46:48 +0100 Subject: ramips: use new image build code for more devices Signed-off-by: Mathias Kresin --- target/linux/ramips/base-files/lib/ramips.sh | 42 ++- target/linux/ramips/dts/ALL0256N-4M.dts | 2 +- target/linux/ramips/dts/ALL0256N-8M.dts | 2 +- target/linux/ramips/dts/AWM002-EVB-4M.dts | 2 +- target/linux/ramips/dts/AWM002-EVB-8M.dts | 2 +- target/linux/ramips/dts/M4-4M.dts | 2 +- target/linux/ramips/dts/M4-8M.dts | 2 +- target/linux/ramips/dts/PX-4885-4M.dts | 4 + target/linux/ramips/dts/PX-4885-8M.dts | 4 + target/linux/ramips/dts/PX-4885.dtsi | 1 - target/linux/ramips/dts/WR512-3GN-4M.dts | 2 +- target/linux/ramips/dts/WR512-3GN-8M.dts | 2 +- target/linux/ramips/dts/WT1520-4M.dts | 4 + target/linux/ramips/dts/WT1520-8M.dts | 4 + target/linux/ramips/dts/WT1520.dtsi | 1 - target/linux/ramips/image/Makefile | 59 +---- target/linux/ramips/image/mt7620.mk | 7 - target/linux/ramips/image/rt305x-legacy.mk | 330 ------------------------ target/linux/ramips/image/rt305x.mk | 372 +++++++++++++++++++++++++++ target/linux/ramips/image/rt3883.mk | 16 ++ 20 files changed, 447 insertions(+), 413 deletions(-) (limited to 'target/linux/ramips') diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh index 6b14d19feb..9b82b2a5c1 100755 --- a/target/linux/ramips/base-files/lib/ramips.sh +++ b/target/linux/ramips/base-files/lib/ramips.sh @@ -40,8 +40,11 @@ ramips_board_detect() { *"ALL0239-3G") name="all0239-3g" ;; - *"ALL0256N") - name="all0256n" + *"ALL0256N (4M)") + name="all0256n-4M" + ;; + *"ALL0256N (8M)") + name="all0256n-8M" ;; *"ALL5002") name="all5002" @@ -67,8 +70,11 @@ ramips_board_detect() { *"AWAPN2403") name="awapn2403" ;; - *"AWM002 EVB") - name="awm002-evb" + *"AWM002 EVB (4M)") + name="awm002-evb-4M" + ;; + *"AWM002 EVB (8M)") + name="awm002-evb-8M" ;; *"AWM003 EVB") name="awm003-evb" @@ -244,8 +250,11 @@ ramips_board_detect() { *"M3") name="m3" ;; - *"M4") - name="m4" + *"M4 (4M)") + name="m4-4M" + ;; + *"M4 (8M)") + name="m4-8M" ;; *"MediaTek LinkIt Smart 7688") linkit="$(dd bs=1 skip=1024 count=12 if=/dev/mtd2 2> /dev/null)" @@ -376,8 +385,11 @@ ramips_board_detect() { *"PWH2004") name="pwh2004" ;; - *"PX-4885") - name="px-4885" + *"PX-4885 (4M)") + name="px-4885-4M" + ;; + *"PX-4885 (8M)") + name="px-4885-8M" ;; *"Q7") name="zte-q7" @@ -538,8 +550,11 @@ ramips_board_detect() { *"WNDR3700v5") name="wndr3700v5" ;; - *"WR512-3GN-like"*) - name="wr512-3gn" + *"WR512-3GN (4M)") + name="wr512-3gn-4M" + ;; + *"WR512-3GN (8M)") + name="wr512-3gn-8M" ;; *"WR6202") name="wr6202" @@ -562,8 +577,11 @@ ramips_board_detect() { *"WSR-600DHP") name="wsr-600" ;; - *"WT1520") - name="wt1520" + *"WT1520 (4M)") + name="wt1520-4M" + ;; + *"WT1520 (8M)") + name="wt1520-8M" ;; *"WT3020 (4M)") name="wt3020-4M" diff --git a/target/linux/ramips/dts/ALL0256N-4M.dts b/target/linux/ramips/dts/ALL0256N-4M.dts index 19cef87cbd..abe43d124a 100644 --- a/target/linux/ramips/dts/ALL0256N-4M.dts +++ b/target/linux/ramips/dts/ALL0256N-4M.dts @@ -6,7 +6,7 @@ / { compatible = "ALL0256N", "ralink,rt3050-soc"; - model = "Allnet ALL0256N"; + model = "Allnet ALL0256N (4M)"; gpio-leds { compatible = "gpio-leds"; diff --git a/target/linux/ramips/dts/ALL0256N-8M.dts b/target/linux/ramips/dts/ALL0256N-8M.dts index a3fbeecb27..45c5d3376d 100644 --- a/target/linux/ramips/dts/ALL0256N-8M.dts +++ b/target/linux/ramips/dts/ALL0256N-8M.dts @@ -6,7 +6,7 @@ / { compatible = "ALL0256N", "ralink,rt3050-soc"; - model = "Allnet ALL0256N"; + model = "Allnet ALL0256N (8M)"; gpio-leds { compatible = "gpio-leds"; diff --git a/target/linux/ramips/dts/AWM002-EVB-4M.dts b/target/linux/ramips/dts/AWM002-EVB-4M.dts index 101ea54b45..a8afab80e4 100644 --- a/target/linux/ramips/dts/AWM002-EVB-4M.dts +++ b/target/linux/ramips/dts/AWM002-EVB-4M.dts @@ -5,7 +5,7 @@ #include / { - model = "AsiaRF AWM002 EVB"; + model = "AsiaRF AWM002 EVB (4M)"; gpio-leds { compatible = "gpio-leds"; diff --git a/target/linux/ramips/dts/AWM002-EVB-8M.dts b/target/linux/ramips/dts/AWM002-EVB-8M.dts index c9f1105dd2..19b78aab02 100644 --- a/target/linux/ramips/dts/AWM002-EVB-8M.dts +++ b/target/linux/ramips/dts/AWM002-EVB-8M.dts @@ -5,7 +5,7 @@ #include / { - model = "AsiaRF AWM002 EVB"; + model = "AsiaRF AWM002 EVB (8M)"; gpio-leds { compatible = "gpio-leds"; diff --git a/target/linux/ramips/dts/M4-4M.dts b/target/linux/ramips/dts/M4-4M.dts index 79bea1952e..c6ed683909 100644 --- a/target/linux/ramips/dts/M4-4M.dts +++ b/target/linux/ramips/dts/M4-4M.dts @@ -6,7 +6,7 @@ / { compatible = "M4", "ralink,rt5350-soc"; - model = "Poray M4"; + model = "Poray M4 (4M)"; gpio-leds { compatible = "gpio-leds"; diff --git a/target/linux/ramips/dts/M4-8M.dts b/target/linux/ramips/dts/M4-8M.dts index 8d6453b0d0..75c7e53388 100644 --- a/target/linux/ramips/dts/M4-8M.dts +++ b/target/linux/ramips/dts/M4-8M.dts @@ -6,7 +6,7 @@ / { compatible = "M4", "ralink,rt5350-soc"; - model = "Poray M4"; + model = "Poray M4 (8M)"; gpio-leds { compatible = "gpio-leds"; diff --git a/target/linux/ramips/dts/PX-4885-4M.dts b/target/linux/ramips/dts/PX-4885-4M.dts index fb2b14cdc1..398a4a90dc 100644 --- a/target/linux/ramips/dts/PX-4885-4M.dts +++ b/target/linux/ramips/dts/PX-4885-4M.dts @@ -2,6 +2,10 @@ #include "PX-4885.dtsi" +/ { + model = "7Links PX-4885 (4M)"; +}; + &spi0 { status = "okay"; diff --git a/target/linux/ramips/dts/PX-4885-8M.dts b/target/linux/ramips/dts/PX-4885-8M.dts index 6367a5eb2d..d6e694ed58 100644 --- a/target/linux/ramips/dts/PX-4885-8M.dts +++ b/target/linux/ramips/dts/PX-4885-8M.dts @@ -2,6 +2,10 @@ #include "PX-4885.dtsi" +/ { + model = "7Links PX-4885 (8M)"; +}; + &spi0 { status = "okay"; diff --git a/target/linux/ramips/dts/PX-4885.dtsi b/target/linux/ramips/dts/PX-4885.dtsi index 257a636412..cb9586d556 100644 --- a/target/linux/ramips/dts/PX-4885.dtsi +++ b/target/linux/ramips/dts/PX-4885.dtsi @@ -4,7 +4,6 @@ / { compatible = "PX-4885", "ralink,rt5350-soc"; - model = "7Links PX-4885"; gpio-keys-polled { compatible = "gpio-keys-polled"; diff --git a/target/linux/ramips/dts/WR512-3GN-4M.dts b/target/linux/ramips/dts/WR512-3GN-4M.dts index a9aa676849..966faf2fd5 100644 --- a/target/linux/ramips/dts/WR512-3GN-4M.dts +++ b/target/linux/ramips/dts/WR512-3GN-4M.dts @@ -6,7 +6,7 @@ / { compatible = "WR512-3GN", "ralink,rt3052-soc"; - model = "WR512-3GN-like router"; + model = "WR512-3GN (4M)"; cfi@1f000000 { compatible = "cfi-flash"; diff --git a/target/linux/ramips/dts/WR512-3GN-8M.dts b/target/linux/ramips/dts/WR512-3GN-8M.dts index 0ddc48f11f..b376a67b58 100644 --- a/target/linux/ramips/dts/WR512-3GN-8M.dts +++ b/target/linux/ramips/dts/WR512-3GN-8M.dts @@ -6,7 +6,7 @@ / { compatible = "WR512-3GN", "ralink,rt3052-soc"; - model = "WR512-3GN-like router"; + model = "WR512-3GN (8M)"; cfi@1f000000 { compatible = "cfi-flash"; diff --git a/target/linux/ramips/dts/WT1520-4M.dts b/target/linux/ramips/dts/WT1520-4M.dts index 9f3d6a7448..26e01f1043 100644 --- a/target/linux/ramips/dts/WT1520-4M.dts +++ b/target/linux/ramips/dts/WT1520-4M.dts @@ -2,6 +2,10 @@ #include "WT1520.dtsi" +/ { + model = "Nexx WT1520 (4M)"; +}; + &spi0 { status = "okay"; diff --git a/target/linux/ramips/dts/WT1520-8M.dts b/target/linux/ramips/dts/WT1520-8M.dts index 48b62bef4f..86c9297970 100644 --- a/target/linux/ramips/dts/WT1520-8M.dts +++ b/target/linux/ramips/dts/WT1520-8M.dts @@ -2,6 +2,10 @@ #include "WT1520.dtsi" +/ { + model = "Nexx WT1520 (8M)"; +}; + &spi0 { status = "okay"; diff --git a/target/linux/ramips/dts/WT1520.dtsi b/target/linux/ramips/dts/WT1520.dtsi index 8cbf99fde2..4c889d1d1d 100644 --- a/target/linux/ramips/dts/WT1520.dtsi +++ b/target/linux/ramips/dts/WT1520.dtsi @@ -2,7 +2,6 @@ / { compatible = "NEXXWT1520", "ralink,rt5350-soc"; - model = "Nexx WT1520"; memory@0 { device_type = "memory"; diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile index 25396f5984..255aa8c5e6 100644 --- a/target/linux/ramips/image/Makefile +++ b/target/linux/ramips/image/Makefile @@ -85,6 +85,11 @@ define Build/edimax-header @mv $@.new $@ endef +define Build/poray-header + $(STAGING_DIR_HOST)/bin/mkporayfw $(1) -f $@ -o $@.new + mv $@.new $@ +endef + define Build/senao-header $(STAGING_DIR_HOST)/bin/mksenaofw $(1) -e $@ -o $@.new mv $@.new $@ @@ -179,63 +184,9 @@ ralink_default_fw_size_4M=3866624 BuildFirmware/Default4M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_4M),$(4)) BuildFirmware/Default4M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(4)) -# Build images for default ralink layout for 8MB flash -# kernel + roots = 0x7b0000 -# $(1) = squashfs/initramfs -# $(2) = lowercase board name -# $(3) = dts file -# $(4) = uImage header name field ralink_default_fw_size_8M=8060928 -BuildFirmware/Default8M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_8M),$(4)) -BuildFirmware/Default8M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(4)) - ralink_default_fw_size_16M=16121856 -BuildFirmware/Default16M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_16M),$(4)) -BuildFirmware/Default16M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(4)) - ralink_default_fw_size_32
from __future__ import (absolute_import, print_function, division)
import re
import copy


def safe_subn(pattern, repl, target, *args, **kwargs):
    """
        There are Unicode conversion problems with re.subn. We try to smooth
        that over by casting the pattern and replacement to strings. We really
        need a better solution that is aware of the actual content ecoding.
    """
    return re.subn(str(pattern), str(repl), target, *args, **kwargs)


class ODict(object):

    """
        A dictionary-like object for managing ordered (key, value) data. Think
        about it as a convenient interface to a list of (key, value) tuples.
    """

    def __init__(self, lst=None):
        self.lst = lst or []

    def _kconv(self, s):
        return s

    def __eq__(self, other):
        return self.lst == other.lst

    def __ne__(self, other):
        return not self.__eq__(other)

    def __iter__(self):
        return self.lst.__iter__()

    def __getitem__(self, k):
        """
            Returns a list of values matching key.
        """
        ret = []
        k = self._kconv(k)
        for i in self.lst:
            if self._kconv(i[0]) == k:
                ret.append(i[1])
        return ret

    def keys(self):
        return list(set([self._kconv(i[0]) for i in self.lst]))

    def _filter_lst(self, k, lst):
        k = self._kconv(k)
        new = []
        for i in lst:
            if self._kconv(i[0]) != k:
                new.append(i)
        return new

    def __len__(self):
        """
            Total number of (key, value) pairs.
        """
        return len(self.lst)

    def __setitem__(self, k, valuelist):
        """
            Sets the values for key k. If there are existing values for this
            key, they are cleared.
        """
        if isinstance(valuelist, basestring):
            raise ValueError(
                "Expected list of values instead of string. "
                "Example: odict['Host'] = ['www.example.com']"
            )
        kc = self._kconv(k)
        new = []
        for i in self.lst:
            if self._kconv(i[0]) == kc:
                if valuelist:
                    new.append([k, valuelist.pop(0)])
            else:
                new.append(i)
        while valuelist:
            new.append([k, valuelist.pop(0)])
        self.lst = new

    def __delitem__(self, k):
        """
            Delete all items matching k.
        """
        self.lst = self._filter_lst(k, self.lst)

    def __contains__(self, k):
        for i in self.lst:
            if self._kconv(i[0]) == self._kconv(k):
                return True
        return False

    def add(self, key, value):
        self.lst.append([key, value])

    def get(self, k, d=None):
        if k in self:
            return self[k]
        else:
            return d

    def get_first(self, k, d=None):
        if k in self:
            return self[k][0]
        else:
            return d

    def items(self):
        return self.lst[:]

    def copy(self):
        """
            Returns a copy of this object.
        """
        lst = copy.deepcopy(self.lst)
        return self.__class__(lst)

    def extend(self, other):
        """
            Add the contents of other, preserving any duplicates.
        """
        self.lst.extend(other.lst)

    def __repr__(self):
        return repr(self.lst)

    def format(self):
        elements = []
        for itm in self.lst:
            elements.append(itm[0] + ": " + str(itm[1]))
        elements.append("")
        return "\r\n".join(elements)

    def in_any(self, key, value, caseless=False):
        """
            Do any of the values matching key contain value?

            If caseless is true, value comparison is case-insensitive.
        """
        if caseless:
            value = value.lower()
        for i in self[key]:
            if caseless:
                i = i.lower()
            if value in i:
                return True
        return False

    def match_re(self, expr):
        """
            Match the regular expression against each (key, value) pair. For
            each pair a string of the following format is matched against:

            "key: value"
        """
        for k, v in self.lst:
            s = "%s: %s" % (k, v)
            if re.search(expr, s):
                return True
        return False

    def replace(self, pattern, repl, *args, **kwargs):
        """
            Replaces a regular expression pattern with repl in both keys and
            values. Encoded content will be decoded before replacement, and
            re-encoded afterwards.

            Returns the number of replacements made.
        """
        nlst, count = [], 0
        for i in self.lst:
            k, c = safe_subn(pattern, repl, i[0], *args, **kwargs)
            count += c
            v, c = safe_subn(pattern, repl, i[1], *args, **kwargs)
            count += c
            nlst.append([k, v])
        self.lst = nlst
        return count

    # Implement the StateObject protocol from mitmproxy
    def get_state(self, short=False):
        return [tuple(i) for i in self.lst]

    def load_state(self, state):
        self.lst = [list(i) for i in state]

    @classmethod
    def from_state(klass, state):
        return klass([list(i) for i in state])


class ODictCaseless(ODict):

    """
        A variant of ODict with "caseless" keys. This version _preserves_ key
        case, but does not consider case when setting or getting items.
    """

    def _kconv(self, s):
        return s.lower()