Merge remote-tracking branch 'origin/main' into v2.9.0

This commit is contained in:
Jaspreet Sachdev
2023-03-20 12:54:09 -04:00
11 changed files with 426 additions and 211 deletions

View File

@@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: ['actiontec_web7200', 'cig_wf188n', 'cig_wf194c4', 'cig_wf196-us', 'cig_wf196-ca', 'cig_wf610d', 'cig_wf808', 'cybertan_eww622-a1', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'liteon_wpx8324', 'edgecore_ecs4100-12ph', 'edgecore_ecw5211', 'edgecore_ecw5410', 'edgecore_oap100', 'edgecore_ssw2ac2600', 'edgecore_spw2ac1200', 'edgecore_spw2ac1200-lan-poe', 'hfcl_ion4', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'indio_um-305ac', 'indio_um-305ax', 'indio_um-325ac', 'indio_um-510ac-v3', 'indio_um-550ac', 'indio_um-310ax-v1', 'indio_um-510axp-v1', 'indio_um-510axm-v1', 'linksys_ea6350-v4', 'linksys_e8450-ubi', 'linksys_ea8300', 'meshpp_s618_cp03', 'meshpp_s618_cp01', 'udaya_a5-id2', 'wallys_dr40x9', 'wallys_dr6018', 'wallys_dr6018_v4', 'x64_vm', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650' ]
target: ['actiontec_web7200', 'cig_wf188n', 'cig_wf194c4', 'cig_wf196-us', 'cig_wf196-ca', 'cig_wf610d', 'cig_wf660a', 'cig_wf808', 'cybertan_eww622-a1', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'liteon_wpx8324', 'edgecore_ecs4100-12ph', 'edgecore_ecw5211', 'edgecore_ecw5410', 'edgecore_oap100', 'edgecore_ssw2ac2600', 'edgecore_spw2ac1200', 'edgecore_spw2ac1200-lan-poe', 'hfcl_ion4', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'indio_um-305ac', 'indio_um-305ax', 'indio_um-325ac', 'indio_um-510ac-v3', 'indio_um-550ac', 'indio_um-310ax-v1', 'indio_um-510axp-v1', 'indio_um-510axm-v1', 'linksys_ea6350-v4', 'linksys_e8450-ubi', 'linksys_ea8300', 'meshpp_s618_cp03', 'meshpp_s618_cp01', 'udaya_a5-id2', 'wallys_dr40x9', 'wallys_dr6018', 'wallys_dr6018_v4', 'x64_vm', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650' ]
steps:
- uses: actions/checkout@v3

View File

@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mcu-firmware
PKG_VERSION:=2023-03-05
PKG_VERSION:=2023-03-12
PKG_RELEASE:=1
PKG_MAINTAINER:=Piotr Dymacz <pepe2k@gmail.com>
@@ -28,10 +28,15 @@ endef
# version-name_git-sha_pipeline-id_sha256-of-package
ZEPHYR_VERSIONS := \
zephyr-v3.3.x_7055d10e538e_3877473859_321a0daf6328698a913c6504d19aa85a5170dfce6039b86d31d2e9162d34af7c \
zephyr-main_63d7f67d401d_3877472923_e44948759ad705f8a28449760ec3153f81d3620e0d3665e50490c7786dd2f8e2
zephyr-main_cf50a3c570bb_3912606668_10922f34cdde9e16cbee76a13a14fb935b9d1fe13eb9136cba31de27033a9c3e
ZEPHYR_FW_CI_URL := https://gitlab.com/pepe2k/zephyr/-/jobs/
ZEPHYR_FW_TYPES := \
hello_world \
hci_uart \
hci_usb
# Zephyr 'hello_world' targets
ZEPHYR_HELLO_WORLD_TARGETS := \
cig_wf196_nrf52833 \
@@ -59,6 +64,20 @@ define Download/zephyr-fw
endef
$(foreach FW,$(ZEPHYR_VERSIONS),$(eval $(call Download,zephyr-fw,$(FW))))
# $(1) firmware name (e.g. hci_usb)
define zephyr-fw-host-support
define Package/zephyr-$(1)-host-support
$(call Package/mcu-fw-default)
DEPENDS:=+mcu
TITLE:=Zephyr '$(1)' common host side support
HIDDEN:=1
endef
define Package/zephyr-$(1)-host-support/install
$(CP) ./files/$(1)/* $$(1)/
endef
endef
# $(1) version (e.g zephyr-v3.3.x)
# $(2) firmware name (e.g. hci_usb)
# $(3) target/board name (e.g. nrf52840dongle_nrf52840)
@@ -81,6 +100,7 @@ define zephyr-fw
endef
define zephyr-fw-deps
$(if $(wildcard ./files/$(1)/*),+zephyr-$(1)-host-support) \
$(if $(findstring hci_u,$1),+bluez-daemon +kmod-bluetooth +kmod-crypto-user)
endef
@@ -102,6 +122,15 @@ define Build/Compile
endef
# Generate host side support packages (per firmware type)
$(foreach FW,$(ZEPHYR_FW_TYPES),\
$(if $(wildcard ./files/$(FW)/*),$(eval $(call zephyr-fw-host-support,$(FW)))))
$(foreach FW,$(ZEPHYR_FW_TYPES),\
$(if $(wildcard ./files/$(FW)/*),$(eval $(call BuildPackage,zephyr-$(FW)-host-support))))
# Generate dedicated Zephyr firmware packages (per firmware version, type and board)
$(foreach VER,$(ZEPHYR_VERSIONS),\
$(foreach TARGET,$(ZEPHYR_HELLO_WORLD_TARGETS),\
$(eval $(call zephyr-fw,$(call word-underscore,$(VER),1),hello_world,$(TARGET)))))

View File

@@ -0,0 +1,79 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/mcu.sh
attach_hci_controller() {
local section="$1"
local sn
local pid
local interface
local uart_path
local uart_baud
local uart_flow
[ -n "$section" ] || return 1
command -v btattach > /dev/null 2>&1 || return 1
config_load mcu
config_get sn "$section" sn
config_get interface "$section" interface
config_get uart_path "$section" uart_path
config_get uart_baud "$section" uart_baud "115200"
config_get uart_flow "$section" uart_flow "0"
[ -n "$sn" ] || return 1
if [ "$interface" = "usb" ]; then
uart_baud="1000000"
uart_flow="1"
dev_found=""
usb_path="/sys/bus/usb/devices/*"
for dev_path in $usb_path; do
dev="$(basename "$dev_path")"
[[ $dev == *":"* ]] && continue
[ "$sn" = "$(cat "${dev_path}/serial" 2>/dev/null)" ] && {
dev_found="$dev"
break
}
done
[ -n "$dev_found" ] || return 1
usb_path="/sys/bus/usb/devices/${dev_found}*/tty/*"
for tty_path in $usb_path; do
tty="$(basename "$tty_path")"
[ -c "/dev/${tty}" ] && {
uart_path="/dev/${tty}"
break
}
done
fi
[ -c "$uart_path" ] || return 1
# Give MCU some time for BLE controller setup
sleep 1
if [ "$uart_flow" = "1" ]; then
btattach -B "$uart_path" -S "$uart_baud" > /dev/null 2>&1 &
else
btattach -B "$uart_path" -S "$uart_baud" -N > /dev/null 2>&1 &
fi
pid="$!"
kill -0 "$pid" > /dev/null 2>&1 && {
echo "$pid" > "/var/run/mcu.${sn}.pid"
return 0
}
return 1
}
attach_hci_controller "$1" || exit 1
exit 0

View File

@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mcu
PKG_VERSION:=2023-03-05
PKG_VERSION:=2023-03-12
PKG_RELEASE=1
PKG_LICENSE:=GPL-2.0

View File

@@ -8,6 +8,7 @@ MCU_CFG_FOUND="0"
mcu_hotplug_setup() {
local sn
local fw_type
local disabled
local sn_dev="$2"
@@ -15,6 +16,9 @@ mcu_hotplug_setup() {
SECT="$1"
MCU_SYSINFO_OUTPUT=""
MCU_IMGLIST_OUTPUT=""
[ "$MCU_CFG_FOUND" = "1" ] && return 0
config_get sn "$SECT" sn
@@ -32,11 +36,24 @@ mcu_hotplug_setup() {
return 0
}
# Stop related service
[ -f "/var/run/mcu.${sn}.pid" ] && {
kill "$(cat "/var/run/mcu.${sn}.pid" 2>/dev/null)" \
> /dev/null 2>&1
rm -f "/var/run/mcu.${sn}.pid" > /dev/null 2>&1
}
mcu_sn_check_and_update "$sn" "$uart"
[ $? -ne 0 ] && return 1
mcu_fw_check_and_update "$uart"
[ $? -ne 0 ] && return 1
fw_type="$(uci -q get "mcu.${SECT}.firmware" | awk -F '__' '{print $2}')"
[ -n "$fw_type" ] || return 0
[ -x "${MCU_HS_DIR}/${fw_type}.sh" ] && \
"${MCU_HS_DIR}/${fw_type}.sh" "$SECT"
}
# We are looking for ttyACM with specific product name and USB VID:PID
@@ -58,9 +75,6 @@ mcu_hotplug_setup() {
mcu_logi "found compatible MCU with S/N '$sn' at USB bus '$dev'"
MCU_SYSINFO_OUTPUT=""
MCU_IMGLIST_OUTPUT=""
# We expect just a single ttyACM interface
usb_path="/sys/bus/usb/devices/${dev}*/tty/*"
for tty in $usb_path; do

View File

@@ -14,6 +14,8 @@ mcu_setup_uart() {
local gpio_on="$5"
local sn="$6"
local fw_type
# Take out MCU out of reset and read basic info
mcu_enable_pin_set "$gpio_path" "$gpio_on"
sleep 1
@@ -23,6 +25,12 @@ mcu_setup_uart() {
mcu_fw_check_and_update "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
fw_type="$(uci -q get "mcu.${SECT}.firmware" | awk -F '__' '{print $2}')"
[ -n "$fw_type" ] || return 0
[ -x "${MCU_HS_DIR}/${fw_type}.sh" ] && \
"${MCU_HS_DIR}/${fw_type}.sh" "$SECT"
}
mcu_setup_usb() {
@@ -32,6 +40,7 @@ mcu_setup_usb() {
local gpio_off="0"
local uart
local fw_type
[ "$gpio_on" = "0" ] && gpio_off="1"
@@ -139,11 +148,19 @@ mcu_setup_usb() {
return 1
}
fw_type="$(uci -q get "mcu.${SECT}.firmware" | awk -F '__' '{print $2}')"
[ -n "$fw_type" ] || return 0
[ -x "${MCU_HS_DIR}/${fw_type}.sh" ] && \
"${MCU_HS_DIR}/${fw_type}.sh" "$SECT"
flock -u 9
}
mcu_setup() {
local sn
local action
local fw_type
local disabled
local uart_baud
local uart_flow
@@ -159,14 +176,18 @@ mcu_setup() {
SECT="$1"
MCU_SCRIPT_NAME="mcu-init.${SECT}"
action="$2"
MCU_SYSINFO_OUTPUT=""
MCU_IMGLIST_OUTPUT=""
# Section disabled?
config_get_bool disabled "$SECT" disabled "0"
[ "$disabled" = "1" ] && {
mcu_logw "section is disabled in config"
return 0
[ "$action" = "start" ] && {
config_get_bool disabled "$SECT" disabled "0"
[ "$disabled" = "1" ] && {
mcu_logw "section is disabled in config"
return 0
}
}
config_get sn "$SECT" sn
@@ -177,6 +198,15 @@ mcu_setup() {
config_get uart_baud "$SECT" uart_baud "115200"
config_get_bool uart_flow "$SECT" uart_flow "0"
# Stop related service
[ "$action" = "stop" ] && {
[ -n "$sn" -a -f "/var/run/mcu.${sn}.pid" ] && {
kill "$(cat "/var/run/mcu.${sn}.pid" 2>/dev/null)" \
> /dev/null 2>&1
rm -f "/var/run/mcu.${sn}.pid" > /dev/null 2>&1
}
}
# As for now, only 'mcuboot' bootloader is supported
case "$bootloader" in
"mcuboot")
@@ -219,12 +249,19 @@ mcu_setup() {
# TODO: should we maybe bail out here if the MCU was took out
# of reset already before, by something/someone else?
[ "$(cat "${gpio_path}/value")" = "$gpio_on" ] && {
mcu_logw "MCU already enabled, resetting"
if [ "$action" = "start" ]; then
mcu_logw "MCU already enabled, resetting"
else
mcu_logi "disabling MCU"
fi
mcu_enable_pin_set "$gpio_path" "$gpio_off"
sleep 1
}
fi
[ "$action" = "stop" ] && return 0
# For now only 'usb' and 'uart' interfaces are supported
case "$interface" in
"uart")
@@ -248,7 +285,14 @@ mcu_setup() {
start() {
config_load mcu
config_foreach mcu_setup mcu
config_foreach mcu_setup mcu "start"
return 0
}
stop() {
config_load mcu
config_foreach mcu_setup mcu "stop"
return 0
}

View File

@@ -6,7 +6,10 @@
MCUBOOT_USB_PRODUCT="MCUboot serial recovery"
MCUBOOT_USB_VID_PID="16c005e1"
MCU_FW_DIR="/lib/firmware/mcu/"
# Host support and firmware directories
MCU_HS_DIR="/etc/mcu.d"
MCU_FW_DIR="/lib/firmware/mcu"
MCU_FLOCK_FILE="/tmp/lock/mcu"
MCU_SYSINFO_OUTPUT=
@@ -43,7 +46,7 @@ mcu_logw() {
mcu_log "warn" "$1"
}
_mcu_get_fwlist() {
mcu_fetch_fwlist() {
local uart="$1"
local baud="$2"
local flow="$3"
@@ -56,36 +59,16 @@ _mcu_get_fwlist() {
[ -n "$baud" ] || baud="115200"
[ -n "$MCU_IMGLIST_OUTPUT" ] && return 0
MCU_IMGLIST_OUTPUT="$(umcumgr -s -d "$uart" -b "$baud$flow" list)"
[ $? -eq 0 ] || return 1
}
_mcu_get_fwmetadata() {
local slot="$1"
local uart="$2"
local baud="$3"
local flow="$4"
local value
[ -n "$MCU_IMGLIST_OUTPUT" ] || {
_mcu_get_fwlist "$uart" "$baud" "$flow" || {
mcu_loge "request 'list' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
[ $? -eq 0 ] || {
mcu_loge "request 'list' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
if [ "$slot" = "0" ]; then
slot="slot0_metadata"
else
slot="slot1_metadata"
fi
value="$(echo "$MCU_IMGLIST_OUTPUT" | grep "$slot=" | cut -d '=' -f 2)"
echo "$value"
}
_mcu_get_sysinfo() {
mcu_fetch_sysinfo() {
local uart="$1"
local baud="$2"
local flow="$3"
@@ -98,132 +81,83 @@ _mcu_get_sysinfo() {
[ -n "$baud" ] || baud="115200"
[ -n "$MCU_SYSINFO_OUTPUT" ] && return 0
MCU_SYSINFO_OUTPUT="$(umcumgr -s -d "$uart" -b "$baud$flow" sysinfo)"
[ $? -eq 0 ] || return 1
}
_mcu_get() {
local field="$1"
local uart="$2"
local baud="$3"
local flow="$4"
local value
[ -n "$MCU_SYSINFO_OUTPUT" ] || {
_mcu_get_sysinfo "$uart" "$baud" "$flow" || {
mcu_loge "request 'sysinfo' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
[ $? -eq 0 ] || {
mcu_loge "request 'sysinfo' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
value="$(echo "$MCU_SYSINFO_OUTPUT" | grep "$field=" | cut -d '=' -f 2)"
echo "$value"
}
mcu_get_sn() {
local uart="$1"
local baud="$2"
local flow="$3"
local value
value="$(_mcu_get "serial_num" "$uart" "$baud" "$flow")"
[ $? -eq 0 ] || return 1
[ -n "$value" ] && mcu_logd "MCU S/N: '$value'"
echo "$value"
}
mcu_get_board() {
local uart="$1"
local baud="$2"
local flow="$3"
local value
value="$(_mcu_get "board" "$uart" "$baud" "$flow")"
[ $? -eq 0 ] || return 1
[ -n "$value" ] && mcu_logd "MCU board: '$value'"
echo "$value"
}
mcu_get_slotsnum() {
local uart="$1"
local baud="$2"
local flow="$3"
local value
value="$(_mcu_get "single_slot" "$uart" "$baud" "$flow")"
[ $? -eq 0 ] || return 1
[ -n "$value" ] || value="1"
[ "$value" != "1" ] && value="2"
[ -n "$value" ] && mcu_logd "number of firmware slots: '$value'"
echo "$value"
}
mcu_get_softver() {
local uart="$1"
local baud="$2"
local flow="$3"
local value
value="$(_mcu_get "soft_ver" "$uart" "$baud" "$flow")"
[ $? -eq 0 ] || return 1
[ -n "$value" ] && mcu_logd "MCUboot version: '$value'"
echo "$value"
}
mcu_get_activeslot() {
local uart="$1"
local baud="$2"
local flow="$3"
local value
value="$(_mcu_get "active_slot" "$uart" "$baud" "$flow")"
[ $? -eq 0 ] || return 1
[ -n "$value" ] && mcu_logd "active firmware slot: '$value'"
echo "$value"
}
mcu_get_fwname() {
local slot="$1"
local uart="$2"
local baud="$3"
local flow="$4"
mcu_get() {
local param="$1"
local slot="$2"
local value
local metadata
local sysinfo_field
metadata="$(_mcu_get_fwmetadata "$slot" "$uart" "$baud" "$flow")"
[ $? -eq 0 ] || return 1
case "$param" in
"board"|\
"soft_ver"|\
"serial_num"|\
"active_slot")
sysinfo_field="$param"
;;
"slots_num")
sysinfo_field="single_slot"
;;
"fwname")
[ -n "$slot" ] || return 1
param="image list: slot${slot} fw_name"
[ -n "$metadata" ] && {
json_load "$metadata"
json_get_var value fw_name
metadata="$(echo "$MCU_IMGLIST_OUTPUT" | grep "slot${slot}_metadata=" | cut -d '=' -f 2)"
[ -n "$metadata" ] && {
json_load "$metadata"
json_get_var value fw_name
}
;;
"fwsha")
[ -n "$slot" ] || return 1
param="image list: slot${slot}_hash"
value="$(echo "$MCU_IMGLIST_OUTPUT" | grep "slot${slot}_hash=" | cut -d '=' -f 2)"
;;
*)
return 1
;;
esac
[ -n "$sysinfo_field" ] && {
value="$(echo "$MCU_SYSINFO_OUTPUT" | grep "${sysinfo_field}=" | cut -d '=' -f 2)"
[ "$sysinfo_field" = "single_slot" ] && {
[ -n "$value" ] || value="1"
[ "$value" != "1" ] && value="2"
}
param="sysinfo: $param"
}
if [ -n "$value" ]; then
mcu_logi "firmware installed in slot '$slot': '$value'"
else
mcu_logw "no firmware installed in slot '$slot'"
fi
[ -n "$value" ] && mcu_logd "$param: '$value'"
echo "$value"
}
mcu_req_boot() {
local uart="$1"
local baud="$2"
local flow="$3"
mcu_req() {
local cmd="$1"
local uart="$2"
local baud="$3"
local flow="$4"
case "$cmd" in
"boot"|\
"reset")
;;
*)
return 1
;;
esac
if [ "$flow" = "1" ]; then
flow=" -f"
@@ -233,34 +167,12 @@ mcu_req_boot() {
[ -n "$baud" ] || baud="115200"
umcumgr -s -d "$uart" -b "$baud$flow" boot || {
mcu_loge "request 'boot' failed"
umcumgr -s -d "$uart" -b "$baud$flow" "$cmd" || {
mcu_loge "request '$cmd' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
mcu_logi "MCU requested to boot the firmware"
}
mcu_req_reset() {
local uart="$1"
local baud="$2"
local flow="$3"
if [ "$flow" = "1" ]; then
flow=" -f"
else
flow=""
fi
[ -n "$baud" ] || baud="115200"
# Request warm reset of the MCU
umcumgr -s -d "$uart" -b "$baud$flow" reset || {
mcu_loge "request 'reset' failed"
return 1
}
mcu_logi "MCU requested to reset"
mcu_logi "MCU requested '$cmd'"
}
mcu_sel_slot() {
@@ -279,13 +191,26 @@ mcu_sel_slot() {
# Request firmware active slot change
umcumgr -s -d "$uart" -b "$baud$flow" select "$slot" || {
mcu_loge "request 'select slot' failed"
mcu_loge "request 'select slot' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
mcu_logi "active firmware slot changed to: '$slot'"
}
mcu_fwfile_sha() {
local path="$1"
local value
[ -f "$path" ] || return 1
value="$(umcumgr -s hash "$path" | grep "hash=" | cut -d '=' -f 2)"
[ -n "$value" ] || return 1
echo "$value"
}
mcu_fw_upload() {
local board="$1"
local slot="$2"
@@ -315,7 +240,7 @@ mcu_fw_upload() {
# Upload fw to selected slot (TODO: slots numbering Zephyr vs. MCUboot)
[ "$slot" = "1" ] && slot="2"
umcumgr -q -n "$slot" -d "$uart" -b "$baud$flow" upload "$fw_path" || {
mcu_loge "request 'upload' failed"
mcu_loge "request 'upload' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
@@ -338,15 +263,10 @@ mcu_sn_check_and_update() {
local sn_dev
if [ "$flow" = "1" ]; then
flow=" -f"
else
flow=""
fi
# Fetch sysinfo
mcu_fetch_sysinfo "$uart" "$baud" "$flow" || return 1
[ -n "$baud" ] || baud="115200"
sn_dev="$(mcu_get_sn "$uart" "$baud" "$flow")"
sn_dev="$(mcu_get "serial_num")"
[ -n "$sn_dev" ] || return 1
[ -n "$sn_dev" ] && {
@@ -377,24 +297,36 @@ mcu_fw_check_and_update() {
local active_slot
local fw_slots
local slot0_fw
local slot0_sha
local slot1_fw
local slot1_sha
local firmware
local fw0_sha
local fw1_sha
local board
local soft_ver
config_get firmware "$SECT" firmware
[ -n "$firmware" ] || mcu_logw "option 'firmware' unset"
# MCU board name
board="$(mcu_get_board "$uart" "$baud" "$flow")"
# Fetch sysinfo and firmware images list
mcu_fetch_sysinfo "$uart" "$baud" "$flow" || return 1
mcu_fetch_fwlist "$uart" "$baud" "$flow" || return 1
# MCU board name and software version
board="$(mcu_get "board")"
[ $? -eq 0 ] || return 1
soft_ver="$(mcu_get "soft_ver")"
[ $? -eq 0 ] || return 1
# Number of firmware slots and active slot
fw_slots="$(mcu_get_slotsnum "$uart" "$baud" "$flow")"
fw_slots="$(mcu_get "slots_num")"
[ $? -eq 0 ] || return 1
[ -n "$fw_slots" ] || fw_slots="1"
[ "$fw_slots" = "2" ] && {
active_slot="$(mcu_get_activeslot "$uart" "$baud" "$flow")"
active_slot="$(mcu_get "active_slot")"
[ $? -eq 0 ] || return 1
}
[ -n "$active_slot" ] || active_slot="0"
@@ -407,22 +339,36 @@ mcu_fw_check_and_update() {
mcu_loge "firmware '$firmware' doesn't exist"
return 1
}
fw1_sha="$(mcu_fwfile_sha "${MCU_FW_DIR}/${board}/${firmware}/slot1.bin")"
else
[ -f "${MCU_FW_DIR}/${board}/${firmware}/slot0.bin" ] || {
mcu_loge "firmware '$firmware' doesn't exist"
return 1
}
fi
fw0_sha="$(mcu_fwfile_sha "${MCU_FW_DIR}/${board}/${firmware}/slot0.bin")"
}
slot0_fw="$(mcu_get_fwname "0" "$uart" "$baud" "$flow")"
slot0_fw="$(mcu_get "fwname" "0")"
[ $? -eq 0 ] || return 1
[ "$fw_slots" = "2" ] && {
slot1_fw="$(mcu_get_fwname "1" "$uart" "$baud" "$flow")"
[ -n "$slot0_fw" ] && {
slot0_sha="$(mcu_get "fwsha" "0")"
[ $? -eq 0 ] || return 1
}
[ "$fw_slots" = "2" ] && {
slot1_fw="$(mcu_get "fwname" "1")"
[ $? -eq 0 ] || return 1
[ -n "$slot1_fw" ] && {
slot1_sha="$(mcu_get "fwsha" "1")"
[ $? -eq 0 ] || return 1
}
}
# No target firmware provided, check what's on device and update config
[ -n "$firmware" ] || {
firmware="$slot0_fw"
@@ -437,7 +383,7 @@ mcu_fw_check_and_update() {
uci -q set mcu.${SECT}.firmware="$firmware"
uci -q commit mcu
mcu_req_boot "$uart" "$baud" "$flow"
mcu_req "boot" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
}
@@ -445,54 +391,58 @@ mcu_fw_check_and_update() {
}
# Do we have target firmware installed in the first slot?
[ "$firmware" = "$slot0_fw" ] && {
mcu_logd "found matching firmware installed in slot '0'"
[ "$firmware" = "$slot0_fw" -a "$slot0_sha" = "$fw0_sha" ] && {
mcu_logi "found matching firmware installed in slot '0'"
if [ "$fw_slots" = "2" -a "$active_slot" != "0" ]; then
mcu_sel_slot "0" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
# Changing active slots requires MCU reset at the moment
mcu_req_reset "$uart" "$baud" "$flow"
mcu_req "reset" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
else
mcu_req_boot "$uart" "$baud" "$flow"
mcu_req "boot" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
fi
return 0
}
mcu_logi "no matching firmware found in slot '0'"
# Upload and boot firmware on single-slot device
[ "$fw_slots" = "1" ] && {
mcu_fw_upload "$board" "0" "$firmware" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
mcu_req_boot "$uart" "$baud" "$flow"
mcu_req "boot" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
return 0
}
# Do we have target firmware installed in the second slot?
[ "$firmware" = "$slot1_fw" ] && {
mcu_logd "found matching firmware installed in slot '1'"
[ "$firmware" = "$slot1_fw" -a "$slot1_sha" = "$fw1_sha" ] && {
mcu_logi "found matching firmware installed in slot '1'"
if [ "$active_slot" != "1" ]; then
mcu_sel_slot "1" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
# Changing active slots requires MCU reset at the moment
mcu_req_reset "$uart" "$baud" "$flow"
mcu_req "reset" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
else
mcu_req_boot "$uart" "$baud" "$flow"
mcu_req "boot" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
fi
return 0
}
mcu_logi "no matching firmware found in slot '1'"
# Upload and boot firmware on multi-slot device
# Always use inactive slot
if [ "$active_slot" = "0" ]; then
@@ -508,7 +458,7 @@ mcu_fw_check_and_update() {
[ $? -ne 0 ] && return 1
# Changing active slots requires MCU reset at the moment
mcu_req_reset "$uart" "$baud" "$flow"
mcu_req "reset" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
return 0

View File

@@ -84,7 +84,7 @@ let handlers = {
ssid: hapd.ssid,
bssid: hapd.bssid,
});
if (ratelimit) {
if (ratelimit && !wildcard(notify.data.phy, 'wlanc*')) {
let msg = {
device: hapd.ifname,
address: notify.data.address,

View File

@@ -4,10 +4,9 @@ PKG_NAME:=ucentral-schema
PKG_RELEASE:=1
PKG_SOURCE_URL=https://github.com/Telecominfraproject/wlan-ucentral-schema.git
PKG_MIRROR_HASH:=62d2b659d16dbdb467215da655259fcb6b239a635f43ee1e87c4d3a3db281d45
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2022-05-29
PKG_SOURCE_VERSION:=54453a6345519ead8edbf75475fd802a8af7a245
PKG_SOURCE_VERSION:=caac3f11f790d2819bf9e41189c3cf99a5d18a78
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
PKG_LICENSE:=BSD-3-Clause

View File

@@ -0,0 +1,100 @@
{
"uuid": 2,
"radios": [
{
"band": "5G",
"country": "CA",
"channel-mode": "HE",
"channel-width": 80,
"channel": 32
}
],
"interfaces": [
{
"name": "WAN",
"role": "upstream",
"ethernet": [
{
"select-ports": [
"WAN*"
]
}
],
"ipv4": {
"addressing": "dynamic"
},
"ssids": [
{
"name": "OpenWifi",
"wifi-bands": [
"5G"
],
"bss-mode": "ap",
"encryption": {
"proto": "wpa2",
"ieee80211w": "optional"
},
"radius": {
"authentication": {
"host": "192.168.178.192",
"port": 1812,
"secret": "secret",
"secondary": {
"host": "192.168.178.193",
"port": 1812,
"secret": "secret2"
}
},
"accounting": {
"host": "192.168.178.192",
"port": 1813,
"secret": "secret",
"secondary": {
"host": "192.168.178.193",
"port": 1813,
"secret": "secret2"
}
}
}
}
]
},
{
"name": "LAN",
"role": "downstream",
"services": [ "ssh" ],
"ethernet": [
{
"select-ports": [
"LAN*"
]
}
],
"ipv4": {
"addressing": "static",
"subnet": "192.168.1.1/24",
"dhcp": {
"lease-first": 10,
"lease-count": 100,
"lease-time": "6h"
}
}
}
],
"metrics": {
"statistics": {
"interval": 120,
"types": [ "ssids", "lldp", "clients" ]
},
"health": {
"interval": 120
}
},
"services": {
"ssh": {
"port": 22
}
}
}

View File

@@ -5,9 +5,9 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=https://github.com/blogic/udevmand.git
PKG_MIRROR_HASH:=51bcf59754ef87913c40f2f1c708c8d2d2eb0ad5fc128a5c891e54ea4b3b035e
PKG_MIRROR_HASH:=0c234de7e8aca07fcabb7685bd899f0c0c82303c2be61e89364abf1d28b089e7
PKG_SOURCE_DATE:=20220112
PKG_SOURCE_VERSION:=3d2b67b180679a6f5687e8d318a66a7cbad3fa7b
PKG_SOURCE_VERSION:=979aca4764c10312b62b4e34c7e9f58e22f86b76
CMAKE_INSTALL:=1
PKG_LICENSE:=LGPL-2.1