qualcomm.sh: generalize to select correct board data file

Generalize script to select the correct board data file to load into the
wireless chip depending on the Regulatory Domain configuration whether it
is a variation of 'bdwlan30.bin' or 'fakeboar.bin'.

If 'bdwlan30_US.bin' or 'bdwlan30_World.bin' files are found in the firmware
directory, the script will create two symlinks, 'bdwlan30.bin and 'utfbd30.bin',
pointing to either one of those files.

If no 'bdwlan30_*.bin' files are found, but 'fakeboar_US.bin' or
'fakeboar_World.bin' is, it will create a single symlink, 'fakeboar.bin',
pointing to either one of those files. In the case a QCA6574 community driver
is loaded, 'board.bin' symlink will be updated.

If no 'fakeboard_*.bin' files are found either, the script will exit.

https://jira.digi.com/browse/DEL-6773

Signed-off-by: Gonzalo Ruiz <Gonzalo.Ruiz@digi.com>
This commit is contained in:
Gonzalo Ruiz 2019-10-01 17:01:17 +02:00
parent c34dcb2c74
commit 440c3a953a
1 changed files with 31 additions and 8 deletions

View File

@ -80,14 +80,33 @@ esac
(
cd "${FIRMWARE_DIR}"
BDATA_SOURCE="bdwlan30_US.bin"
if [ -f "bdwlan30_US.bin" ] || [ -f "bdwlan30_World.bin" ]; then
BDATA_US="bdwlan30_US.bin"
BDATA_WW="bdwlan30_World.bin"
BDATA_LINK="bdwlan30.bin"
UTFBDATA_LINK="utfbd30.bin"
elif [ -f "fakeboar_US.bin" ] || [ -f "fakeboar_World.bin" ]; then
BDATA_US="fakeboar_US.bin"
BDATA_WW="fakeboar_World.bin"
# Use different links for propietary and community drivers
if [ -f "board.bin" ]; then
BDATA_LINK="board.bin"
else
BDATA_LINK="fakeboar.bin"
fi
else
log "5" "[ERROR] Could not locate board data files"
exit 1
fi
BDATA_SOURCE="${BDATA_US}"
case "${REGULATORY_DOMAIN}" in
${US_CODE})
log "5" "Setting US wireless region";;
${WW_CODE}|${JP_CODE})
if [ -f "bdwlan30_World.bin" ]; then
if [ -f "${BDATA_WW}" ]; then
log "5" "Setting WW (world wide) wireless region"
BDATA_SOURCE="bdwlan30_World.bin"
BDATA_SOURCE="${BDATA_WW}"
else
log "5" "[WARN] No WW (worldwide) board data file, using US"
fi
@ -98,12 +117,16 @@ esac
log "5" "[WARN] Invalid region code, using US";;
esac
# We don't want to rewrite NAND every time we boot so only
# change the links if they are wrong.
BDATA_LINK="bdwlan30.bin"
UTFBDATA_LINK="utfbd30.bin"
if [ ! -e "${BDATA_LINK}" ] || ! cmp -s "${BDATA_LINK}" "${BDATA_SOURCE}"; then
# When defined, update the links only if they are wrong so we don't
# rewrite the internal memory every time we boot
if [ -n "${BDATA_LINK}" ] &&
([ ! -f "${BDATA_LINK}" ] ||
! cmp -s "${BDATA_LINK}" "${BDATA_SOURCE}"); then
ln -sf "${BDATA_SOURCE}" "${BDATA_LINK}"
fi
if [ -n "${UTFBDATA_LINK}" ] &&
([ ! -f "${UTFBDATA_LINK}" ] ||
! cmp -s "${UTFBDATA_LINK}" "${BDATA_SOURCE}"); then
ln -sf "${BDATA_SOURCE}" "${UTFBDATA_LINK}"
fi
)