bluetooth-init: verify if BT firmware was loaded successfully

Rarely the bluetooth firmware is not loaded properly and causes
errors in the configuration steps. This verification makes sure
the firmware was loaded and is functional, if not we start the
retry mechanism with the default baudrate to avoid the firmware
corruption in the upload process.

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

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
This commit is contained in:
Arturo Buzarra 2018-02-20 14:25:57 +01:00
parent c48e9cace7
commit 7c34990c01
2 changed files with 18 additions and 2 deletions

View File

@ -73,9 +73,17 @@ bluetooth_init() {
killproc hciattach
powercycle_gpio "${BT_EN_QCA_GPIO_NR}"
if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then
return
# hciattach performs a reset to load the new firmware and needs some time to be ready
sleep 1
# Verify if firmware was loaded successfully
bdaddr >/dev/null 2>&1 && return
fi
sleep 1
if [ $RETRY -ge 3 ]; then
# Retry at default firmware baudrate
BT_RATE="115200"
fi
done
BT_ERROR="FAIL (hciattach)"
}

View File

@ -73,9 +73,17 @@ bluetooth_init() {
killproc hciattach
powercycle_gpio "${BT_EN_QCA_GPIO_NR}"
if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then
return
# hciattach performs a reset to load the new firmware and needs some time to be ready
sleep 1
# Verify if firmware was loaded successfully
bdaddr >/dev/null 2>&1 && return
fi
sleep 1
if [ $RETRY -ge 3 ]; then
# Retry at default firmware baudrate
BT_RATE="115200"
fi
done
BT_ERROR="FAIL (hciattach)"
}