Skip to content
Snippets Groups Projects
Commit 93201855 authored by Adam Wujek's avatar Adam Wujek
Browse files

[FEATURE: #314] userspace/host_tools: add dot-config converter from 6.x to 7.0


Converter script can be run:
- on WRS
- in the repo directory (userspace/host_tools/dot-config_converter_6_x_to_7_0.sh)
- in standalone mode (run "make converter_standalone" to prepare it)

Signed-off-by: default avatarAdam Wujek <dev_public@wujek.eu>
parent 30f9c8cc
Branches
Tags
No related merge requests found
...@@ -7,3 +7,4 @@ conf ...@@ -7,3 +7,4 @@ conf
mconf mconf
nconf nconf
wrs_release_defconfig wrs_release_defconfig
dot-config_converter_6_x_to_7_0_script.sh
...@@ -16,8 +16,9 @@ CFLAGS = -D KBUILD_NO_NLS ...@@ -16,8 +16,9 @@ CFLAGS = -D KBUILD_NO_NLS
# most of this is just copying stuff in # most of this is just copying stuff in
RFILES = Kconfig_sfp_fiber.in Kconfig_port_timing.in Kconfig Kconfig_vlans.in \ RFILES = Kconfig_sfp_fiber.in Kconfig_port_timing.in Kconfig Kconfig_vlans.in \
dot-config wrs_release_defconfig dot-config wrs_release_defconfig
XFILES = conf mconf nconf XFILES = conf mconf nconf \
dot-config_converter_6_x_to_7_0_script.sh
FILES = $(RFILES) $(XFILES) FILES = $(RFILES) $(XFILES)
all: $(FILES) all: $(FILES)
...@@ -46,6 +47,9 @@ Kconfig_sfp_fiber.in: $(WRS_BASE_DIR)/../Kconfig_sfp_fiber.in ...@@ -46,6 +47,9 @@ Kconfig_sfp_fiber.in: $(WRS_BASE_DIR)/../Kconfig_sfp_fiber.in
Kconfig_vlans.in: $(WRS_BASE_DIR)/../Kconfig_vlans.in Kconfig_vlans.in: $(WRS_BASE_DIR)/../Kconfig_vlans.in
cp $^ $@ cp $^ $@
dot-config_converter_6_x_to_7_0_script.sh: $(WRS_BASE_DIR)/../userspace/host_tools/dot-config_converter_6_x_to_7_0_script.sh
cp $^ $@
CONF_LOC=$(WRS_BASE_DIR)/../scripts/kconfig CONF_LOC=$(WRS_BASE_DIR)/../scripts/kconfig
conf: conf:
......
looper looper
oids_*.data oids_*.data
oids_*.txt oids_*.txt
dot-config_converter_standalone
# Author: Adam Wujek 2024
converter_standalone: ../../scripts/kconfig/conf
mkdir -p dot-config_converter_standalone/kconfigs/v7.0
mkdir -p dot-config_converter_standalone/bin
cp dot-config_converter_6_x_to_7_0_script.sh dot-config_converter_standalone/bin/
cp dot-config_converter_6_x_to_7_0_standalone.sh dot-config_converter_standalone/dot-config_converter_6_x_to_7_0.sh
cp ../../Kconfig dot-config_converter_standalone/kconfigs/v7.0
cp ../../Kconfig_port_timing.in dot-config_converter_standalone/kconfigs/v7.0
cp ../../Kconfig_sfp_fiber.in dot-config_converter_standalone/kconfigs/v7.0
cp ../../Kconfig_vlans.in dot-config_converter_standalone/kconfigs/v7.0
cp ../../scripts/kconfig/conf dot-config_converter_standalone/bin
git describe --dirty --always --tag > dot-config_converter_standalone/bin/version_info.txt
../../scripts/kconfig/conf:
# conf not available
@echo "scripts/kconfig/conf not available for host system."
@echo "Please trigger compilation of it with \"make listnewconfig\" in the root of wr-switch-sw repo."
@echo ""
@false
#!/bin/bash
# Author: Adam Wujek 2024
# This is a wrapper for the script that converts dot-config used in
# WRS firmware 6.x to WRS firmware 7.0
script_name=$0
SCRIPT_PATH=$(dirname "$0")
CONF_PATH=${SCRIPT_PATH}/../../scripts/kconfig/ KCONFIG_PATH=${SCRIPT_PATH}/../../ ${SCRIPT_PATH}/dot-config_converter_6_x_to_7_0_script.sh $@
#!/bin/bash
# Author: Adam Wujek 2024
# This script converts dot-config used in WRS firmware 6.x to WRS firmware 7.0
# Script flow:
# - source dot-config
# - check for old parameters to be replaced, add new parameters at the end of dot-config
# - pass the new dot-config via conf tool to place all parameters in the correct order and add still missing default values
#
# This scripts adds to CONFIG_DOTCONF_INFO the information that dot-config was converted
showHelp() {
cat << EOF
This script converts dot-config used with WRS firmware v6.x to dot-config for WRS firmware v7.0
Usage: $script_name -i <old_dot-config> -o <new_dot-config>
EOF
}
portCount=18
instCount=1
script_name=$0
V=false
if [ -z "$CONF_PATH" ] || [ -z "$KCONFIG_PATH" ]; then
echo "CONF_PATH or KCONFIG_PATH is not set. Please use a wrapper to run this script."
exit 1
fi
while true
do
case $1 in
-h|--help)
showHelp $script_name
exit 0
;;
-i|--input)
shift
input_file="$1"
;;
-o|--output)
shift
output_file="$1"
;;
-v|--verbose)
shift
V=true
;;
"")
break
;;
*)
echo "Unrecognized option $1"
exit 1
esac
shift
done
$V && echo "Input file is \"$input_file\""
$V && echo "Output file is \"$output_file\""
if [ x"$input_file" == x ] || ! [ -f "$input_file" ] || [ -d "$input_file" ]; then
echo "Please provide input file."
exit 1
fi
if [ x"$output_file" == x ]; then
echo "Please provide output file."
exit 1
fi
source "$input_file"
cp "$input_file" "$output_file"
# rm "$output_file"
$V && echo "Write new version of FW in dot-config (CONFIG_DOTCONF_FW_VERSION)"
echo "CONFIG_DOTCONF_FW_VERSION=\"7.0\"" >> "$output_file"
$V && echo "Add info about conversion from old ($CONFIG_DOTCONF_FW_VERSION) firmware"
if [ -n "$CONFIG_DOTCONF_INFO" ]; then
CONFIG_DOTCONF_INFO="$CONFIG_DOTCONF_INFO; "
fi
echo "CONFIG_DOTCONF_INFO=\"${CONFIG_DOTCONF_INFO}Dot-config converted from $CONFIG_DOTCONF_FW_VERSION\"" >> "$output_file"
# add Global profile as HA
$V && echo "Add CONFIG_GLOBAL_PROFILE_HA_WR=y"
echo "CONFIG_GLOBAL_PROFILE_HA_WR=y" >> "$output_file"
# Check BMCA
if [ "$CONFIG_PTP_OPT_EXT_PORT_CONFIG_ENABLED" == "y" ]; then
$V && echo "External port configuration enabled, add CONFIG_PTP_OPT_BMCA_EXT_PORT_CONFIG=y"
echo "CONFIG_PTP_OPT_BMCA_EXT_PORT_CONFIG=y" >> "$output_file"
else
$V && echo "External port configuration not enabled, add CONFIG_PTP_OPT_BMCA_STANDARD=y"
echo "CONFIG_PTP_OPT_BMCA_STANDARD=y" >> "$output_file"
fi
if [ -n "$CONFIG_PTP_OPT_DOMAIN_NUMBER" ] && [ "$CONFIG_PTP_OPT_DOMAIN_NUMBER" != 0 ]; then
$V && echo "Non default value for CONFIG_PTP_OPT_DOMAIN_NUMBER, add CONFIG_PTP_OPT_OVERWRITE_ATTRIBUTES=y"
set_PTP_OPT_OVERWRITE_ATTRIBUTES=y
fi
if [ -n "$CONFIG_PTP_OPT_PRIORITY1" ] && [ "$CONFIG_PTP_OPT_PRIORITY1" != 128 ]; then
$V && echo "Non default value for CONFIG_PTP_OPT_PRIORITY1, add CONFIG_PTP_OPT_OVERWRITE_ATTRIBUTES=y"
set_PTP_OPT_OVERWRITE_ATTRIBUTES=y
fi
if [ -n "$CONFIG_PTP_OPT_PRIORITY2" ] && [ "$CONFIG_PTP_OPT_PRIORITY2" != 128 ]; then
$V && echo "Non default value for CONFIG_PTP_OPT_PRIORITY2, add CONFIG_PTP_OPT_OVERWRITE_ATTRIBUTES=y"
set_PTP_OPT_OVERWRITE_ATTRIBUTES=y
fi
if [ "$set_PTP_OPT_OVERWRITE_ATTRIBUTES" = y ]; then
echo "CONFIG_PTP_OPT_OVERWRITE_ATTRIBUTES=y" >> "$output_file"
fi
# Per port per instance checks
for port in `seq 1 $portCount`; do
portStr=`printf "%02d" $port`
for inst in `seq 1 $instCount`; do
instStr=`printf "%02d" $inst`
# Add CONFIG_PORTXX_INSTYY_PROFILE_KEEP_GLOBAL=y
echo "CONFIG_PORT${portStr}_INST${instStr}_PROFILE_KEEP_GLOBAL=y" >> "$output_file"
# Check old profile
varname="CONFIG_PORT${portStr}_INST${instStr}_PROFILE_PTP"
if [ "${!varname}" = "y" ]; then
# Add extension none (CONFIG_PORTXX_INSTYY_EXTENSION_NONE=y)
echo "CONFIG_PORT${portStr}_INST${instStr}_EXTENSION_NONE=y" >> "$output_file"
else
# Add extension WR (CONFIG_PORTXX_INSTYY_EXTENSION_WR=y)
echo "CONFIG_PORT${portStr}_INST${instStr}_EXTENSION_WR=y" >> "$output_file"
fi
# Check if announce interval contains not default value
varname="CONFIG_PORT${portStr}_INST${instStr}_ANNOUNCE_INTERVAL"
if [ -n "${!varname}" ] && [ "${!varname}" != "1" ]; then
$V && echo "Non default value for ${varname} found(${!varname}), add ${varname}_OVERWRITE=y"
echo "${varname}_OVERWRITE=y" >> "$output_file"
fi
# Check if receipt timeout contains not default value
varname="CONFIG_PORT${portStr}_INST${instStr}_ANNOUNCE_RECEIPT_TIMEOUT"
if [ -n "${!varname}" ] && [ "${!varname}" != "3" ]; then
$V && echo "Non default value for ${varname} found(${!varname}), add ${varname}_OVERWRITE=y"
echo "${varname}_OVERWRITE=y" >> "$output_file"
fi
# Check if min delay request interval contains not default value
varname="CONFIG_PORT${portStr}_INST${instStr}_MIN_DELAY_REQ_INTERVAL"
if [ -n "${!varname}" ] && [ "${!varname}" != "0" ]; then
$V && echo "Non default value for ${varname} found(${!varname}), add ${varname}_OVERWRITE=y"
echo "${varname}_OVERWRITE=y" >> "$output_file"
fi
# Check if min pdelay request interval contains not default value
varname="CONFIG_PORT${portStr}_INST${instStr}_MIN_PDELAY_REQ_INTERVAL"
if [ -n "${!varname}" ] && [ "${!varname}" != "0" ]; then
$V && echo "Non default value for ${varname} found(${!varname}), add ${varname}_OVERWRITE=y"
echo "${varname}_OVERWRITE=y" >> "$output_file"
fi
# Check if sync interval contains not default value
varname="CONFIG_PORT${portStr}_INST${instStr}_SYNC_INTERVAL"
if [ -n "${!varname}" ] && [ "${!varname}" != "0" ]; then
$V && echo "Non default value for ${varname} found(${!varname}), add ${varname}_OVERWRITE=y"
echo "${varname}_OVERWRITE=y" >> "$output_file"
fi
done
echo "" >> "$output_file"
done
output_file="$(realpath $output_file)"
CONF_PATH="$(realpath $CONF_PATH)/"
# conf has to be called from the path where Kconfig files are placed.
# Otherwise include directive in Kconfig* is not able to find files.
cd "$KCONFIG_PATH"
$V && echo "New configuration items:"
$V && KCONFIG_CONFIG="$output_file" "${CONF_PATH}"conf --listnewconfig Kconfig
$V && echo "Overwriten configuration items:"
$V && KCONFIG_CONFIG="$output_file" "${CONF_PATH}"conf -s --olddefconfig Kconfig
$V || KCONFIG_CONFIG="$output_file" "${CONF_PATH}"conf -s --olddefconfig Kconfig &> /dev/null
#!/bin/bash
# Author: Adam Wujek 2024
# This is a wrapper for the script that converts dot-config used in
# WRS firmware 6.x to WRS firmware 7.0
script_name=$0
SCRIPT_PATH=$(dirname "$0")
CONF_PATH=${SCRIPT_PATH}/bin/ KCONFIG_PATH=${SCRIPT_PATH}/kconfigs/v7.0/ ${SCRIPT_PATH}/bin/dot-config_converter_6_x_to_7_0_script.sh $@
#!/bin/bash
# Author: Adam Wujek 2024
# This is a wrapper for the script that converts dot-config used in
# WRS firmware 6.x to WRS firmware 7.0
script_name=$0
SCRIPT_PATH=$(dirname "$0")
CONF_PATH=${SCRIPT_PATH}/../etc/ KCONFIG_PATH=${SCRIPT_PATH}/../etc/ ${SCRIPT_PATH}/../etc/dot-config_converter_6_x_to_7_0_script.sh $@
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment