mediatek: split base-files into subtargets
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Mon, 11 Nov 2019 15:27:50 +0000 (16:27 +0100)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Tue, 14 Jan 2020 12:34:34 +0000 (13:34 +0100)
This splits some base-files across subtargets, as done previously
on ath79 and ramips and also introduced for mt7629 subtarget here
already. Most of the existing base-files content is specific to
mt7623.

While at it, apply the following fixes:
- Remove lots of trailing whitespaces
- Remove wildcard on unielec,u7623-02-emmc-512m
- Remove inconsistent quotation marks in cases

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Acked-by: John Crispin <john@phrozen.org>
target/linux/mediatek/base-files/etc/board.d/02_network [deleted file]
target/linux/mediatek/base-files/lib/preinit/07_set_iface_mac [deleted file]
target/linux/mediatek/base-files/lib/preinit/79_move_config [deleted file]
target/linux/mediatek/base-files/lib/upgrade/platform.sh [deleted file]
target/linux/mediatek/mt7622/base-files/etc/board.d/02_network [new file with mode: 0755]
target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh [new file with mode: 0755]
target/linux/mediatek/mt7623/base-files/etc/board.d/02_network [new file with mode: 0755]
target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac [new file with mode: 0644]
target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config [new file with mode: 0644]
target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh [new file with mode: 0755]

diff --git a/target/linux/mediatek/base-files/etc/board.d/02_network b/target/linux/mediatek/base-files/etc/board.d/02_network
deleted file mode 100755 (executable)
index faa2434..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-
-. /lib/functions.sh
-. /lib/functions/uci-defaults.sh
-. /lib/functions/system.sh
-
-mediatek_setup_interfaces()
-{
-       local board="$1"
-
-       case $board in
-       'mediatek,mt7623a-rfb-emmc')
-               ucidef_set_interface_lan "lan0 lan1 lan2 lan3"
-               ucidef_set_interface_wan eth1
-               ;;
-       'bananapi,bpi-r2'|\
-       "unielec,u7623"*)
-               ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" "wan"
-               ;;
-       esac
-}
-
-mediatek_setup_macs()
-{
-       local board="$1"
-
-       case $board in
-       "unielec,u7623"*)
-               mac=$(cat /sys/class/net/wan/address)
-               ucidef_set_interface_macaddr "wan" $mac
-               ;;
-       esac
-}
-
-board_config_update
-board=$(board_name)
-mediatek_setup_interfaces $board
-mediatek_setup_macs $board
-board_config_flush
-
-exit 0
diff --git a/target/linux/mediatek/base-files/lib/preinit/07_set_iface_mac b/target/linux/mediatek/base-files/lib/preinit/07_set_iface_mac
deleted file mode 100644 (file)
index 3d04000..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2018 OpenWrt.org
-
-RECOVERY_PART=/dev/mmcblk0p1
-
-preinit_set_mac_address() {
-       local mac
-
-       . /lib/functions.sh
-       . /lib/functions/system.sh
-
-       case $(board_name) in
-       "unielec,u7623"*)
-               if [ -b $RECOVERY_PART ]; then
-                       insmod nls_cp437
-                       insmod nls_iso8859-1
-                       insmod fat
-                       insmod vfat
-                       mkdir -p /tmp/recovery
-                       mount -o rw,noatime $RECOVERY_PART /tmp/recovery
-
-                       if [ -f "/tmp/recovery/mac_addr" ];
-                       then
-                               mac=$(cat /tmp/recovery/mac_addr)
-                       else
-                               mac=$(cat /sys/class/net/eth0/address)
-                               echo "$mac" > /tmp/recovery/mac_addr
-                       fi
-
-                       sync
-                       umount /tmp/recovery
-                       rm -rf /tmp/recovery
-               fi
-
-               ip link set dev wan address $mac 2> /dev/null
-
-               mac=$(macaddr_add $mac 1)
-
-               ip link set dev lan0 address $mac 2>/dev/null
-               ip link set dev lan1 address $mac 2>/dev/null
-               ip link set dev lan2 address $mac 2>/dev/null
-               ip link set dev lan3 address $mac 2>/dev/null
-               ;;
-       esac
-}
-
-boot_hook_add preinit_main preinit_set_mac_address
diff --git a/target/linux/mediatek/base-files/lib/preinit/79_move_config b/target/linux/mediatek/base-files/lib/preinit/79_move_config
deleted file mode 100644 (file)
index 6173365..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2015 OpenWrt.org
-
-. /lib/upgrade/common.sh
-
-RECOVERY_PART=/dev/mmcblk0p1
-
-move_config() {
-       if [ -b $RECOVERY_PART ]; then
-               insmod nls_cp437
-               insmod nls_iso8859-1
-               insmod fat
-               insmod vfat
-               mkdir -p /recovery
-               mount -o rw,noatime $RECOVERY_PART /recovery
-               [ -f "/recovery/$BACKUP_FILE" ] && mv -f "/recovery/$BACKUP_FILE" /
-               umount /recovery
-       fi
-}
-
-boot_hook_add preinit_mount_root move_config
diff --git a/target/linux/mediatek/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/base-files/lib/upgrade/platform.sh
deleted file mode 100755 (executable)
index 9c99ee1..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-platform_do_upgrade() {                 
-       local board=$(board_name)
-       case "$board" in
-       "unielec,u7623"*)
-               #Keep the persisten random mac address (if it exists)
-               mkdir -p /tmp/recovery
-               mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery
-               [ -f "/tmp/recovery/mac_addr" ] && \
-                       mv -f /tmp/recovery/mac_addr /tmp/
-               umount /tmp/recovery
-
-               #1310720 is the offset in bytes from the start of eMMC and to
-               #the location of the kernel (2560 512 byte sectors)
-               get_image "$1" | dd of=/dev/mmcblk0 bs=1310720 seek=1 conv=fsync
-
-               mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery
-               [ -f "/tmp/mac_addr" ] && mv -f /tmp/mac_addr /tmp/recovery
-               sync
-               umount /tmp/recovery
-               ;;
-       *)
-               default_do_upgrade "$1"
-               ;;
-       esac
-}
-
-PART_NAME=firmware
-
-platform_check_image() {                                                         
-       local board=$(board_name)                                                
-       local magic="$(get_magic_long "$1")"                                     
-
-       [ "$#" -gt 1 ] && return 1                                               
-
-       case "$board" in                                                       
-       bananapi,bpi-r2|\
-       "unielec,u7623"*)
-               [ "$magic" != "27051956" ] && {   
-                       echo "Invalid image type."
-                       return 1                                     
-               }                                                    
-               return 0                                             
-               ;;                                                   
-
-       *)                                                           
-               echo "Sysupgrade is not supported on your board yet."
-               return 1                                             
-               ;;                                
-       esac                                      
-
-       return 0                                                                                         
-}
-
-platform_copy_config_emmc() {
-       mkdir -p /recovery
-       mount -o rw,noatime /dev/mmcblk0p1 /recovery
-       cp -af "$UPGRADE_BACKUP" "/recovery/$BACKUP_FILE"
-       sync
-       umount /recovery
-}
-
-platform_copy_config() {
-       case "$(board_name)" in
-       "unielec,u7623"*)
-               platform_copy_config_emmc
-               ;;
-       esac
-}
diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
new file mode 100755 (executable)
index 0000000..d719a35
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/uci-defaults.sh
+. /lib/functions/system.sh
+
+mediatek_setup_interfaces()
+{
+       local board="$1"
+
+       case $board in
+       esac
+}
+
+mediatek_setup_macs()
+{
+       local board="$1"
+
+       case $board in
+       esac
+}
+
+board_config_update
+board=$(board_name)
+mediatek_setup_interfaces $board
+mediatek_setup_macs $board
+board_config_flush
+
+exit 0
diff --git a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
new file mode 100755 (executable)
index 0000000..f226459
--- /dev/null
@@ -0,0 +1,26 @@
+platform_do_upgrade() {
+       local board=$(board_name)
+
+       case "$board" in
+       *)
+               default_do_upgrade "$1"
+               ;;
+       esac
+}
+
+PART_NAME=firmware
+
+platform_check_image() {
+       local board=$(board_name)
+
+       [ "$#" -gt 1 ] && return 1
+
+       case "$board" in
+       *)
+               echo "Sysupgrade is not supported on your board yet."
+               return 1
+               ;;
+       esac
+
+       return 0
+}
diff --git a/target/linux/mediatek/mt7623/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7623/base-files/etc/board.d/02_network
new file mode 100755 (executable)
index 0000000..07fd63f
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/uci-defaults.sh
+. /lib/functions/system.sh
+
+mediatek_setup_interfaces()
+{
+       local board="$1"
+
+       case $board in
+       mediatek,mt7623a-rfb-emmc)
+               ucidef_set_interface_lan "lan0 lan1 lan2 lan3"
+               ucidef_set_interface_wan eth1
+               ;;
+       bananapi,bpi-r2|\
+       unielec,u7623-02-emmc-512m)
+               ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" "wan"
+               ;;
+       esac
+}
+
+mediatek_setup_macs()
+{
+       local board="$1"
+
+       case $board in
+       unielec,u7623-02-emmc-512m)
+               ucidef_set_interface_macaddr "wan" "$(cat /sys/class/net/wan/address)"
+               ;;
+       esac
+}
+
+board_config_update
+board=$(board_name)
+mediatek_setup_interfaces $board
+mediatek_setup_macs $board
+board_config_flush
+
+exit 0
diff --git a/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac b/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac
new file mode 100644 (file)
index 0000000..7a73a2d
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+# Copyright (C) 2018 OpenWrt.org
+
+RECOVERY_PART=/dev/mmcblk0p1
+
+preinit_set_mac_address() {
+       local mac
+
+       . /lib/functions.sh
+       . /lib/functions/system.sh
+
+       case $(board_name) in
+       unielec,u7623-02-emmc-512m)
+               if [ -b $RECOVERY_PART ]; then
+                       insmod nls_cp437
+                       insmod nls_iso8859-1
+                       insmod fat
+                       insmod vfat
+                       mkdir -p /tmp/recovery
+                       mount -o rw,noatime $RECOVERY_PART /tmp/recovery
+
+                       if [ -f "/tmp/recovery/mac_addr" ];
+                       then
+                               mac=$(cat /tmp/recovery/mac_addr)
+                       else
+                               mac=$(cat /sys/class/net/eth0/address)
+                               echo "$mac" > /tmp/recovery/mac_addr
+                       fi
+
+                       sync
+                       umount /tmp/recovery
+                       rm -rf /tmp/recovery
+               fi
+
+               ip link set dev wan address $mac 2> /dev/null
+
+               mac=$(macaddr_add $mac 1)
+
+               ip link set dev lan0 address $mac 2>/dev/null
+               ip link set dev lan1 address $mac 2>/dev/null
+               ip link set dev lan2 address $mac 2>/dev/null
+               ip link set dev lan3 address $mac 2>/dev/null
+               ;;
+       esac
+}
+
+boot_hook_add preinit_main preinit_set_mac_address
diff --git a/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config b/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config
new file mode 100644 (file)
index 0000000..6173365
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Copyright (C) 2015 OpenWrt.org
+
+. /lib/upgrade/common.sh
+
+RECOVERY_PART=/dev/mmcblk0p1
+
+move_config() {
+       if [ -b $RECOVERY_PART ]; then
+               insmod nls_cp437
+               insmod nls_iso8859-1
+               insmod fat
+               insmod vfat
+               mkdir -p /recovery
+               mount -o rw,noatime $RECOVERY_PART /recovery
+               [ -f "/recovery/$BACKUP_FILE" ] && mv -f "/recovery/$BACKUP_FILE" /
+               umount /recovery
+       fi
+}
+
+boot_hook_add preinit_mount_root move_config
diff --git a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh
new file mode 100755 (executable)
index 0000000..225fec0
--- /dev/null
@@ -0,0 +1,68 @@
+platform_do_upgrade() {
+       local board=$(board_name)
+
+       case "$board" in
+       unielec,u7623-02-emmc-512m)
+               #Keep the persisten random mac address (if it exists)
+               mkdir -p /tmp/recovery
+               mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery
+               [ -f "/tmp/recovery/mac_addr" ] && \
+                       mv -f /tmp/recovery/mac_addr /tmp/
+               umount /tmp/recovery
+
+               #1310720 is the offset in bytes from the start of eMMC and to
+               #the location of the kernel (2560 512 byte sectors)
+               get_image "$1" | dd of=/dev/mmcblk0 bs=1310720 seek=1 conv=fsync
+
+               mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery
+               [ -f "/tmp/mac_addr" ] && mv -f /tmp/mac_addr /tmp/recovery
+               sync
+               umount /tmp/recovery
+               ;;
+       *)
+               default_do_upgrade "$1"
+               ;;
+       esac
+}
+
+PART_NAME=firmware
+
+platform_check_image() {
+       local board=$(board_name)
+       local magic="$(get_magic_long "$1")"
+
+       [ "$#" -gt 1 ] && return 1
+
+       case "$board" in
+       bananapi,bpi-r2|\
+       unielec,u7623-02-emmc-512m)
+               [ "$magic" != "27051956" ] && {
+                       echo "Invalid image type."
+                       return 1
+               }
+               return 0
+               ;;
+       *)
+               echo "Sysupgrade is not supported on your board yet."
+               return 1
+               ;;
+       esac
+
+       return 0
+}
+
+platform_copy_config_emmc() {
+       mkdir -p /recovery
+       mount -o rw,noatime /dev/mmcblk0p1 /recovery
+       cp -af "$UPGRADE_BACKUP" "/recovery/$BACKUP_FILE"
+       sync
+       umount /recovery
+}
+
+platform_copy_config() {
+       case "$(board_name)" in
+       unielec,u7623-02-emmc-512m)
+               platform_copy_config_emmc
+               ;;
+       esac
+}