treewide: use only board_name function to get name
Do not parse /tmp/sysinfo/board_name, /proc/cpuinfo or the device tree compatible string directly. Always use the board_name function to get the board name. The admswconfig package still reads /proc/cpuinfo directly. The code looks somehow broken and the whole adm5120 which uses this package looks unmaintained. Leave it as it is for now. Signed-off-by: Mathias Kresin <dev@kresin.me>
This commit is contained in:
parent
e0b9ec8e96
commit
e4e984f2a0
20 changed files with 35 additions and 38 deletions
|
@ -3,7 +3,9 @@
|
||||||
BOOTPART=/dev/sda1
|
BOOTPART=/dev/sda1
|
||||||
|
|
||||||
move_config() {
|
move_config() {
|
||||||
grep -q 'MyBook Live' /proc/cpuinfo || return
|
. /lib/functions.sh
|
||||||
|
|
||||||
|
[ "$(board_name)" = "mbl" ] || return
|
||||||
if [ -b $BOOTPART ]; then
|
if [ -b $BOOTPART ]; then
|
||||||
mkdir -p /boot
|
mkdir -p /boot
|
||||||
mount -t ext4 -o rw,noatime $BOOTPART /boot
|
mount -t ext4 -o rw,noatime $BOOTPART /boot
|
||||||
|
|
|
@ -52,7 +52,7 @@ merakinand_do_platform_check() {
|
||||||
|
|
||||||
merakinand_do_upgrade() {
|
merakinand_do_upgrade() {
|
||||||
local tar_file="$1"
|
local tar_file="$1"
|
||||||
local board_name="$(cat /tmp/sysinfo/board_name)"
|
local board_name="$(board_name)"
|
||||||
|
|
||||||
# Do we need to do any platform tweaks?
|
# Do we need to do any platform tweaks?
|
||||||
case "$board_name" in
|
case "$board_name" in
|
||||||
|
|
|
@ -51,7 +51,7 @@ merakinand_copy_caldata() {
|
||||||
local cal_src=$1
|
local cal_src=$1
|
||||||
local cal_dst=$2
|
local cal_dst=$2
|
||||||
local ubidev="$(nand_find_ubi $CI_UBIPART)"
|
local ubidev="$(nand_find_ubi $CI_UBIPART)"
|
||||||
local board_name="$(cat /tmp/sysinfo/board_name)"
|
local board_name="$(board_name)"
|
||||||
local rootfs_size="$(ubinfo /dev/ubi0 -N rootfs_data | grep "Size" | awk '{ print $6 }')"
|
local rootfs_size="$(ubinfo /dev/ubi0 -N rootfs_data | grep "Size" | awk '{ print $6 }')"
|
||||||
|
|
||||||
# Setup partitions using board name, in case of future platforms
|
# Setup partitions using board name, in case of future platforms
|
||||||
|
@ -143,7 +143,7 @@ merakinand_do_platform_check() {
|
||||||
|
|
||||||
merakinand_do_upgrade() {
|
merakinand_do_upgrade() {
|
||||||
local tar_file="$1"
|
local tar_file="$1"
|
||||||
local board_name="$(cat /tmp/sysinfo/board_name)"
|
local board_name="$(board_name)"
|
||||||
|
|
||||||
# Do we need to do any platform tweaks?
|
# Do we need to do any platform tweaks?
|
||||||
case "$board_name" in
|
case "$board_name" in
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
|
|
||||||
board_config_update
|
board_config_update
|
||||||
|
|
||||||
board=$(cat /proc/device-tree/compatible | tr '\0' '\t' | cut -f 1)
|
case "$(board_name)" in
|
||||||
|
|
||||||
case "$board" in
|
|
||||||
netgear,r8000)
|
netgear,r8000)
|
||||||
ucidef_set_led_usbport "usb2" "USB 2.0" "bcm53xx:white:usb2" "usb1-port2" "usb2-port2"
|
ucidef_set_led_usbport "usb2" "USB 2.0" "bcm53xx:white:usb2" "usb1-port2" "usb2-port2"
|
||||||
ucidef_set_led_usbport "usb3" "USB 3.0" "bcm53xx:white:usb3" "usb1-port1" "usb2-port1" "usb4-port1"
|
ucidef_set_led_usbport "usb3" "USB 3.0" "bcm53xx:white:usb3" "usb1-port1" "usb2-port1" "usb4-port1"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
board_config_update
|
board_config_update
|
||||||
|
|
||||||
board=$(cat /proc/device-tree/compatible | tr '\0' '\t' | cut -f 1)
|
board=$(board_name)
|
||||||
|
|
||||||
case "$board" in
|
case "$board" in
|
||||||
tenda,ac9)
|
tenda,ac9)
|
||||||
|
|
|
@ -175,7 +175,7 @@ detect_by_model() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
model="$(sed -ne 's/^machine[ \t]*: //p' /proc/cpuinfo)"
|
model="$(board_name)"
|
||||||
boardtype="$(nvram get boardtype)"
|
boardtype="$(nvram get boardtype)"
|
||||||
boardnum="$(nvram get boardnum)"
|
boardnum="$(nvram get boardnum)"
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ zyxel_do_flash() {
|
||||||
|
|
||||||
zyxel_do_upgrade() {
|
zyxel_do_upgrade() {
|
||||||
local tar_file="$1"
|
local tar_file="$1"
|
||||||
local board=$(cat /tmp/sysinfo/board_name)
|
local board=$(board_name)
|
||||||
local rootfs="$(zyxel_get_rootfs)"
|
local rootfs="$(zyxel_get_rootfs)"
|
||||||
local kernel=
|
local kernel=
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
platform_do_upgrade() {
|
platform_do_upgrade() {
|
||||||
local tar_file="$1"
|
local tar_file="$1"
|
||||||
local board="$(cat /tmp/sysinfo/board_name)"
|
local board="$(board_name)"
|
||||||
|
|
||||||
echo "flashing kernel"
|
echo "flashing kernel"
|
||||||
tar xf $tar_file sysupgrade-$board/kernel -O | mtd write - kernel
|
tar xf $tar_file sysupgrade-$board/kernel -O | mtd write - kernel
|
||||||
|
@ -17,7 +17,7 @@ platform_do_upgrade() {
|
||||||
|
|
||||||
platform_check_image() {
|
platform_check_image() {
|
||||||
local tar_file="$1"
|
local tar_file="$1"
|
||||||
local board=$(cat /tmp/sysinfo/board_name)
|
local board=$(board_name)
|
||||||
|
|
||||||
case "$board" in
|
case "$board" in
|
||||||
mediatek,mt7623-rfb-nand-ephy |\
|
mediatek,mt7623-rfb-nand-ephy |\
|
||||||
|
@ -45,8 +45,7 @@ platform_check_image() {
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_pre_upgrade() {
|
platform_pre_upgrade() {
|
||||||
local board=$(cat /tmp/sysinfo/board_name)
|
case "$(board_name)" in
|
||||||
case "$board" in
|
|
||||||
mediatek,mt7623-rfb-nand-ephy |\
|
mediatek,mt7623-rfb-nand-ephy |\
|
||||||
mediatek,mt7623-rfb-nand)
|
mediatek,mt7623-rfb-nand)
|
||||||
nand_do_upgrade $1
|
nand_do_upgrade $1
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
board_config_update
|
board_config_update
|
||||||
|
|
||||||
case "$(cat /tmp/sysinfo/board_name)" in
|
case "$(board_name)" in
|
||||||
erlite)
|
erlite)
|
||||||
ucidef_set_interfaces_lan_wan "eth0" "eth1"
|
ucidef_set_interfaces_lan_wan "eth0" "eth1"
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
# Copyright (C) 2014 OpenWrt.org
|
# Copyright (C) 2014 OpenWrt.org
|
||||||
|
|
||||||
move_config() {
|
move_config() {
|
||||||
case "$(cat /tmp/sysinfo/board_name)" in
|
. /lib/functions.sh
|
||||||
|
|
||||||
|
case "$(board_name)" in
|
||||||
erlite)
|
erlite)
|
||||||
mount -t vfat /dev/sda1 /mnt
|
mount -t vfat /dev/sda1 /mnt
|
||||||
[ -f /mnt/sysupgrade.tgz ] && mv -f /mnt/sysupgrade.tgz /
|
[ -f /mnt/sysupgrade.tgz ] && mv -f /mnt/sysupgrade.tgz /
|
||||||
|
|
|
@ -22,9 +22,7 @@ platform_get_rootfs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_copy_config() {
|
platform_copy_config() {
|
||||||
local board="$(cat /tmp/sysinfo/board_name)"
|
case "$(board_name)" in
|
||||||
|
|
||||||
case "$board" in
|
|
||||||
erlite)
|
erlite)
|
||||||
mount -t vfat /dev/sda1 /mnt
|
mount -t vfat /dev/sda1 /mnt
|
||||||
cp -af "$CONF_TAR" /mnt/
|
cp -af "$CONF_TAR" /mnt/
|
||||||
|
@ -58,7 +56,7 @@ platform_do_flash() {
|
||||||
|
|
||||||
platform_do_upgrade() {
|
platform_do_upgrade() {
|
||||||
local tar_file="$1"
|
local tar_file="$1"
|
||||||
local board=$(cat /tmp/sysinfo/board_name)
|
local board=$(board_name)
|
||||||
local rootfs="$(platform_get_rootfs)"
|
local rootfs="$(platform_get_rootfs)"
|
||||||
local kernel=
|
local kernel=
|
||||||
|
|
||||||
|
@ -81,7 +79,7 @@ platform_do_upgrade() {
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_check_image() {
|
platform_check_image() {
|
||||||
local board=$(cat /tmp/sysinfo/board_name)
|
local board=$(board_name)
|
||||||
|
|
||||||
case "$board" in
|
case "$board" in
|
||||||
erlite | \
|
erlite | \
|
||||||
|
|
|
@ -7,8 +7,10 @@ n810_cal_bme_pmm_extract() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
. /lib/functions.sh
|
||||||
|
|
||||||
[ "$FIRMWARE" = "n810-cal-bme-pmm.fw" ] && {
|
[ "$FIRMWARE" = "n810-cal-bme-pmm.fw" ] && {
|
||||||
[ -z "$(grep -e 'Nokia N810' /proc/cpuinfo)" ] || {
|
[ "$(board_name)" != "nokia,n810" ] || {
|
||||||
[ -e /lib/firmware/n810-cal-bme-pmm.fw ] ||\
|
[ -e /lib/firmware/n810-cal-bme-pmm.fw ] ||\
|
||||||
n810_cal_bme_pmm_extract
|
n810_cal_bme_pmm_extract
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,10 @@ p54spi_eeprom_extract() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
. /lib/functions.sh
|
||||||
|
|
||||||
[ "$FIRMWARE" = "3826.eeprom" ] && {
|
[ "$FIRMWARE" = "3826.eeprom" ] && {
|
||||||
[ -z "$(grep -e 'Nokia N810' /proc/cpuinfo)" ] || {
|
[ "$(board_name)" != "nokia,n810" ] || {
|
||||||
[ -e /lib/firmware/3826.eeprom ] ||\
|
[ -e /lib/firmware/3826.eeprom ] ||\
|
||||||
p54spi_eeprom_extract
|
p54spi_eeprom_extract
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,9 @@ usb_led_off() {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_usb_led() {
|
get_usb_led() {
|
||||||
local hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo`
|
. /lib/functions.sh
|
||||||
|
|
||||||
case "${hardware}" in
|
case "$(board_name)" in
|
||||||
'Linksys WRT350N v2')
|
'Linksys WRT350N v2')
|
||||||
usb_led='wrt350nv2:green:usb'
|
usb_led='wrt350nv2:green:usb'
|
||||||
usb_device='1-1:1.0'
|
usb_device='1-1:1.0'
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# This script sets system defaults for the hardware on firstboot
|
# This script sets system defaults for the hardware on firstboot
|
||||||
#
|
#
|
||||||
|
|
||||||
hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo`
|
. /lib/functions.sh
|
||||||
|
|
||||||
wrt350nv2_default() {
|
wrt350nv2_default() {
|
||||||
# leds
|
# leds
|
||||||
|
@ -47,7 +47,7 @@ __EOF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${hardware}" in
|
case "$(board_name)" in
|
||||||
'Linksys WRT350N v2')
|
'Linksys WRT350N v2')
|
||||||
wrt350nv2_default
|
wrt350nv2_default
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
platform_check_image() {
|
platform_check_image() {
|
||||||
[ "${ARGC}" -gt 1 ] && { echo 'Too many arguments. Only flash file expected.'; return 1; }
|
[ "${ARGC}" -gt 1 ] && { echo 'Too many arguments. Only flash file expected.'; return 1; }
|
||||||
|
|
||||||
local hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo`
|
local hardware="$(board_name)"
|
||||||
local magic="$(get_magic_word "$1")"
|
local magic="$(get_magic_word "$1")"
|
||||||
local magic_long="$(get_magic_long "$1")"
|
local magic_long="$(get_magic_long "$1")"
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,8 @@ platform_pre_upgrade() {
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_nand_pre_upgrade() {
|
platform_nand_pre_upgrade() {
|
||||||
local board_name="$(cat /tmp/sysinfo/board_name)"
|
|
||||||
|
|
||||||
mtd erase kernel
|
mtd erase kernel
|
||||||
tar xf "$1" sysupgrade-$board_name/kernel -O | nandwrite -o /dev/mtd0 -
|
tar xf "$1" "sysupgrade-$(board_name)/kernel" -O | nandwrite -o /dev/mtd0 -
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_do_upgrade() {
|
platform_do_upgrade() {
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
|
|
||||||
board_config_update
|
board_config_update
|
||||||
|
|
||||||
board=$(cat /tmp/sysinfo/board_name) 2>/dev/null
|
case "$(board_name)" in
|
||||||
|
|
||||||
case "$board" in
|
|
||||||
pc-engines-apu|pc-engines-apu2)
|
pc-engines-apu|pc-engines-apu2)
|
||||||
ucidef_set_led_netdev "wan" "WAN" "apu2:green:led3" "eth0"
|
ucidef_set_led_netdev "wan" "WAN" "apu2:green:led3" "eth0"
|
||||||
ucidef_set_led_netdev "lan" "LAN" "apu2:green:led2" "br-lan"
|
ucidef_set_led_netdev "lan" "LAN" "apu2:green:led2" "br-lan"
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
|
|
||||||
board_config_update
|
board_config_update
|
||||||
|
|
||||||
board="$(cat /tmp/sysinfo/board_name)" 2>/dev/null
|
case "$(board_name)" in
|
||||||
|
|
||||||
case "$board" in
|
|
||||||
pc-engines-apu|pc-engines-apu2)
|
pc-engines-apu|pc-engines-apu2)
|
||||||
ucidef_set_interfaces_lan_wan "eth1 eth2" "eth0"
|
ucidef_set_interfaces_lan_wan "eth1 eth2" "eth0"
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
board_config_update
|
board_config_update
|
||||||
|
|
||||||
case "$(cat /tmp/sysinfo/board_name)" in
|
case "$(board_name)" in
|
||||||
xlnx,zynq-zc702|xlnx,zynq-zed|xlnx,zynq-zybo)
|
xlnx,zynq-zc702|xlnx,zynq-zed|xlnx,zynq-zybo)
|
||||||
ucidef_set_interface_lan 'eth0'
|
ucidef_set_interface_lan 'eth0'
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue