mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
base-file: Add mmc support (#8329)
This commit is contained in:
parent
31fc43272d
commit
010702bc1a
@ -313,6 +313,25 @@ find_mtd_part() {
|
|||||||
echo "${INDEX:+$PREFIX$INDEX}"
|
echo "${INDEX:+$PREFIX$INDEX}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
find_mmc_part() {
|
||||||
|
local DEVNAME PARTNAME ROOTDEV
|
||||||
|
|
||||||
|
if grep -q "$1" /proc/mtd; then
|
||||||
|
echo "" && return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
ROOTDEV="$2"
|
||||||
|
else
|
||||||
|
ROOTDEV="mmcblk*"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for DEVNAME in /sys/block/$ROOTDEV/mmcblk*p*; do
|
||||||
|
PARTNAME="$(grep PARTNAME ${DEVNAME}/uevent | cut -f2 -d'=')"
|
||||||
|
[ "$PARTNAME" = "$1" ] && echo "/dev/$(basename $DEVNAME)" && return 0
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
group_add() {
|
group_add() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local gid="$2"
|
local gid="$2"
|
||||||
|
@ -48,6 +48,19 @@ caldata_extract_ubi() {
|
|||||||
caldata_die "failed to extract calibration data from $ubi"
|
caldata_die "failed to extract calibration data from $ubi"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
caldata_extract_mmc() {
|
||||||
|
local part=$1
|
||||||
|
local offset=$(($2))
|
||||||
|
local count=$(($3))
|
||||||
|
local mmc_part
|
||||||
|
|
||||||
|
mmc_part=$(find_mmc_part $part)
|
||||||
|
[ -n "$mmc_part" ] || caldata_die "no mmc partition found for partition $part"
|
||||||
|
|
||||||
|
caldata_dd $mmc_part /lib/firmware/$FIRMWARE $count $offset || \
|
||||||
|
caldata_die "failed to extract calibration data from $mmc_part"
|
||||||
|
}
|
||||||
|
|
||||||
caldata_extract_reverse() {
|
caldata_extract_reverse() {
|
||||||
local part=$1
|
local part=$1
|
||||||
local offset=$2
|
local offset=$2
|
||||||
@ -168,4 +181,4 @@ ath10k_patch_mac() {
|
|||||||
local target=$2
|
local target=$2
|
||||||
|
|
||||||
caldata_patch_mac "$mac" 0x6 0x2 "$target"
|
caldata_patch_mac "$mac" 0x6 0x2 "$target"
|
||||||
}
|
}
|
@ -79,6 +79,24 @@ mtd_get_mac_ascii() {
|
|||||||
[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
|
[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mtd_get_mac_ascii_mmc() {
|
||||||
|
local mtdname="$1"
|
||||||
|
local key="$2"
|
||||||
|
local part
|
||||||
|
local mac_dirty
|
||||||
|
|
||||||
|
part=$(find_mmc_part "$mtdname")
|
||||||
|
if [ -z "$part" ]; then
|
||||||
|
echo "mtd_get_mac_ascii: partition $mtdname not found!" >&2
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
|
||||||
|
|
||||||
|
# "canonicalize" mac
|
||||||
|
[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
|
||||||
|
}
|
||||||
|
|
||||||
mtd_get_mac_text() {
|
mtd_get_mac_text() {
|
||||||
local mtdname=$1
|
local mtdname=$1
|
||||||
local offset=$(($2))
|
local offset=$(($2))
|
||||||
@ -123,6 +141,15 @@ mtd_get_mac_binary_ubi() {
|
|||||||
get_mac_binary "/dev/$part" "$offset"
|
get_mac_binary "/dev/$part" "$offset"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mtd_get_mac_binary_mmc() {
|
||||||
|
local mtdname="$1"
|
||||||
|
local offset="$2"
|
||||||
|
local part
|
||||||
|
|
||||||
|
part=$(find_mmc_part "$mtdname")
|
||||||
|
get_mac_binary "$part" "$offset"
|
||||||
|
}
|
||||||
|
|
||||||
mtd_get_part_size() {
|
mtd_get_part_size() {
|
||||||
local part_name=$1
|
local part_name=$1
|
||||||
local first dev size erasesize name
|
local first dev size erasesize name
|
||||||
@ -223,4 +250,4 @@ macaddr_canonicalize() {
|
|||||||
[ ${#canon} -ne 17 ] && return
|
[ ${#canon} -ne 17 ] && return
|
||||||
|
|
||||||
printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${canon// / 0x} 2>/dev/null
|
printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${canon// / 0x} 2>/dev/null
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user