Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
inbox:toh:d-link:covr-p2500_a1 [2023/11/10 17:59] – [Specific Configuration] jokujossaiinbox:toh:d-link:covr-p2500_a1 [2023/11/23 17:12] – [D-Link COVR-P2500 A1] jokujossai
Line 1: Line 1:
 ====== D-Link COVR-P2500 A1====== ====== D-Link COVR-P2500 A1======
 ~~NOTOC~~ ~~NOTOC~~
- 
-/* This template is intended to be used via https://openwrt.org/meta/create_new_device_page . */ 
- 
-{{page>meta:infobox:construction&noheader&nofooter&noeditbtn}} 
  
 The D-Link COVR-P2500 A1 is a AC1200 dual band wireless access point with wired Ethernet, Wi-Fi and PowerLine interfaces. It is basically a standard router with a Homeplug AV2 Powerline Communication (PLC) interface connected internally to one of the Ethernet switch ports.  The D-Link COVR-P2500 A1 is a AC1200 dual band wireless access point with wired Ethernet, Wi-Fi and PowerLine interfaces. It is basically a standard router with a Homeplug AV2 Powerline Communication (PLC) interface connected internally to one of the Ethernet switch ports. 
Line 602: Line 598:
 | PLC               | 4           | | PLC               | 4           |
  
 +==== Powerline configuration ====
 +
 +Powerline interface needs ''plchost'' daemon to work. PLC packages are installed by default but ''plchost'' requires also ''.nvm'' and ''.pib'' files to work. These files can be extracted from [[http://pmdap.dlink.com.tw/PMD/GetAgileFile?itemNumber=FIR1800225&fileName=COVRP2500A1_FW101b08_decrypted.bin&fileSize=1.5990457E7;1.5992229E7;65141.0;|original decrypted firmware]] and [[#etcinitdplc|/etc/init.d/plc]] service handles running ''plchost'' automatically.
 +
 +''plchost'' does not work if PLC device is added to ''br-lan'' bridge before connection is established. ''plc'' service bypasses this limitation by waiting PLC connection to be established before adding ''eth0.3'' to ''br-lan''.
 +
 +=== Powerline Quick Setup ===
 +
 +1. Add file [[#etcinitdplc|/etc/init.d/plc]] to device and make executable ''chmod +x /etc/init.d/plc''
 +
 +2. Make plc configuration kept on sysupgrade by creating file ''/lib/upgrade/keep.d/plc'' with following contents
 +
 +  /etc/plc
 +  /etc/init.d/plc
 +  /lib/upgrade/keep.d/plc
 +
 +3. Install ''unsquashfs'' tool for extracting files from original firmware ''opkg install squashfs-tools-unsquashfs''
 +
 +4. Install open-plc packages ''opkg install open-plc-utils open-plc-utils-hpavkey open-plc-utils-modpib open-plc-utils-plchost open-plc-utils-plctool''
 +
 +5. (Optional) Download ''QCA75XX-2.10.0.0032_modules_5-6_stripped.nvm'' (https://community.tp-link.com/us/home/forum/topic/204234) to /etc/plc directory
 +
 +6. Run setup tool ''/etc/init.d/plc setup''
 +
 +<hidden Setup example>
 +<code>
 +root@covrp2500_1:/# /etc/init.d/plc setup
 +Download original firmware and extract files from /lib/plc to /etc/plc [y|n] y
 +Downloading 'http://pmdap.dlink.com.tw/PMD/GetAgileFile?itemNumber=FIR1800225&fileName=COVRP2500A1_FW101b08_decrypted.bin&fileSize=1.5990457E7;1.5992229E7;65141.0;'
 +Connecting to 60.248.210.49:80
 +Writing to 'COVRP2500A1_FW101b08_decrypted.bin'
 +COVRP2500A1_FW101b08 15460k --:--:-- ETA
 +Download completed (15990457 bytes)
 +Parallel unsquashfs: Using 1 processor
 +4 inodes (6 blocks) to write
 +
 +[===================================================================|] 6/6 100%
 +
 +created 4 files
 +created 3 directories
 +created 0 symlinks
 +created 0 devices
 +created 0 fifos
 +created 0 sockets
 +1) /etc/plc/COVRP2500AVA1_PIB100EU_WM.pib
 +2) /etc/plc/COVRP2500AVA1_PIB100NA_WM.pib
 +3) /etc/plc/COVRP2500AVA1_PIB100SG_WM.pib
 +Select PibPath [1-3]: 1
 +1) /etc/plc/MAC-7500-v2.2.2-03-X-CS.nvm
 +2) /etc/plc/QCA7500-2.10.0032_modules_5-6_stripped.nvm
 +Select NvmPath [1-2]: 2
 +NetworkPasswd (leave empty to use default plc_networkpwd): SomePassword
 +Enable plc [0-1]: 1
 +Automatically add to br-lan bridge [0-1]: 1
 +root@covrp2500_1:/# /etc/init.d/plc start
 +root@covrp2500_1:/# brctl show br-lan
 +bridge name     bridge id               STP enabled     interfaces
 +br-lan          7fff.xxxxxxxxxxxx       no              eth0.3
 +                                                        eth0.1
 +root@covrp2500_1:/# plctool -i br-lan -m
 +br-lan 00:B0:52:00:00:01 Fetch Network Information
 +br-lan XX:XX:XX:XX:XX:XX Found 1 Network(s)
 +
 +source address = XX:XX:XX:XX:XX:XX
 +
 + network->NID = XX:XX:XX:XX:XX:XX:XX
 + network->SNID = 14
 + network->TEI = 1
 + network->ROLE = 0x00 (STA)
 + network->CCO_DA = XX:XX:XX:XX:XX:XX
 + network->CCO_TEI = 3
 + network->STATIONS = 1
 +
 + station->MAC = XX:XX:XX:XX:XX:XX
 + station->TEI = 3
 + station->BDA = 28:3B:82:2A:AB:7A
 + station->AvgPHYDR_TX = 154 mbps Alternate
 + station->AvgPHYDR_RX = 233 mbps Alternate
 +
 +
 +</code>
 +</hidden>
 +
 +6. Start plc service with ''/etc/init.d/plc start''
 +
 +=== /etc/init.d/plc ===
 +<hidden /etc/init.d/plc>
 +<code - /etc/init.d/plc>
 +#!/bin/sh /etc/rc.common
 +
 +USE_PROCD=1
 +
 +START=60
 +STOP=80
 +
 +EXTRA_COMMANDS="setup"
 +EXTRA_HELP=" setup PLC configuration setup helper"
 +
 +mtd_get_key() {
 + local mtdname="$1"
 + local key="$2"
 + local part
 + local value_dirty
 +
 + part=$(find_mtd_part "$mtdname")
 + if [ -z "$part" ]; then
 + echo "mtd_get_key: partition $mtdname not found!" >&2
 + return
 + fi
 +
 + value_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
 +
 + echo "$value_dirty"
 +}
 +
 +board=$(board_name)
 +
 +start_service() {
 + if [ ! -f /etc/config/plc ] || [ "$(uci show plc 2>/dev/null)" = "" ]; then
 + touch /etc/config/plc
 + uci set plc.config=config
 + uci commit plc
 + fi
 +
 + local NvmPath
 + local PibPath
 + local Mac
 + local device
 + local NmkSelected
 + local NetworkPasswd
 + local Nmk
 + local Dek
 + local Dak
 + local AdapterName
 + local Enabled
 + local Network
 + local pibpath_tmp
 +
 + config_load plc
 + config_get NvmPath config NvmPath
 + config_get PibPath config PibPath
 + config_get Mac config Mac
 + config_get NmkSelected config NmkSelected
 + config_get NetworkPasswd config NetworkPasswd
 + config_get Nmk config Nmk
 + config_get Dek config Dek
 + config_get Dak config Dak
 + config_get AdapterName config AdapterName
 + config_get Enabled config Enabled
 + config_get Network config Network
 + config_load network
 + config_get device plc device
 +
 + if [ -z "$NvmPath" ]; then
 + echo "plc.config.NvmPath not defined" >&2
 + exit 1
 + fi
 + if [ ! -f "$NvmPath" ]; then
 + echo "plc.config.NvmPath does not exist" >&2
 + exit 1
 + fi
 +
 + if [ -z "$PibPath" ]; then
 + echo "plc.config.PibPath not defined" >&2
 + exit 1
 + fi
 + if [ ! -f "$PibPath" ]; then
 + echo "plc.config.PibPath file does not exist" >&2
 + exit 1
 + fi
 + if [ -z "$Mac" ]; then
 + Mac="$(mtd_get_mac_ascii art protest_plc_mac)"
 + fi
 + if [ -z "$device" ]; then
 + echo "network.plc.device not defined" >&2
 + exit 1
 + fi
 +
 + # Create modded pib
 + pibpath_tmp="${PibPath}.tmp"
 + rm -f "$pibpath_tmp"
 + cp "$PibPath" "$pibpath_tmp"
 +
 + # Patch MAC into pib
 + if [ ! -z "$Mac" ]; then
 + modpib -M "$Mac" "$pibpath_tmp"
 + fi
 +
 + # Patch NMK
 + if [ 'true' != "$NmkSelected" ]; then
 + if [ -z "$NetworkPwd" ]; then
 + NetworkPwd="$(nmk_get_key art plc_networkpwd)"
 + fi
 + Nmk="$(hpavkey -M "$NetworkPwd")"
 + fi
 + if [ ! -z "$Nmk" ]; then
 + modpib -N "$Nmk" "$pibpath_tmp"
 + fi
 +
 + # Patch DAK
 + if [ -z "$Dek" ]; then
 + if [ -z "$Dak" ]; then
 + Dek="$(mtd_get_key art plc_dek)"
 +
 + if [ ! -z "$Dek" ]; then
 + Dak="$(hpavkey -D "$Dek")"
 + fi
 + fi
 + else
 + Dak="$(hpavkey -D "$Dek")"
 + fi
 + if [ ! -z "$Dak" ]; then
 + modpib -D "$Dak" "$pibpath_tmp"
 + fi
 +
 + # Patch USR
 + if [ -z "$AdapterName" ]; then
 + AdapterName="$(uci get system.@system[0].hostname)"
 + fi
 + modpib -U "$AdapterName" -S "D-Link COVR-P2500" -T "$NetworkPwd" "$pibpath_tmp"
 +
 + if [ -z "$Enabled" ]; then
 + echo "plc.config.Enabled not defined" >&2
 + exit 1
 + fi
 + if [ "$Enabled" -ne 1 ]; then
 + echo "plc.config.Enabled is not 1" >&2
 + exit 1
 + fi
 +
 + cd /tmp
 +
 + for i in $(seq 1 30); do
 + if [ -d /sys/class/net/$device ]; then
 + break
 + fi
 + sleep 1s
 + done
 +
 + procd_open_instance
 + if [ -z "$Network" ]; then
 + procd_set_param command /usr/bin/plchost -i "$device" -N "$NvmPath" -P "$pibpath_tmp"
 + else
 + [ ! -e /dev/fd ] && ln -s /proc/self/fd /dev/fd
 + procd_set_param command sh -c '/usr/bin/plchost -i '"$device"' -N '"$NvmPath"' -P '"$pibpath_tmp"' 2> >(\
 + while read line; do \
 + echo "$line" >&2; \
 + if [ $(expr match "$line" ".*'$device'.*is running.*") -gt 0 ]; then \
 + echo "Adding '$device' to br-'$Network'"; \
 + brctl addif "br-'$Network'" "'$device'"; \
 + fi; \
 + done)'
 + fi
 + procd_set_param file /etc/config/plc
 + procd_set_param stdout 1
 + procd_set_param stderr 1
 + procd_set_param netdev "$device"
 + procd_close_instance
 +}
 +
 +service_triggers() {
 + procd_add_reload_trigger "plc" "network"
 +}
 +
 +reload_service() {
 + stop
 + start
 +}
 +
 +stop_service() {
 + local device
 + local Network
 +
 + config_load plc
 + config_get Network config Network
 + config_load network
 + config_get device plc device
 +
 + if [ ! -z "$Network" ]; then
 + brctl delif "br-$Network" "$device"
 + fi
 +}
 +
 +service_stopped() {
 + local PibPath
 + local Mac
 + local device
 +
 + config_load plc
 + config_get PibPath config PibPath
 + config_get Mac config Mac
 + config_load network
 + config_get device plc device
 +
 + if [ ! -z "$PibPath" ] && [ -f "${PibPath}.tmp" ]; then
 + rm "${PibPath}.tmp"
 + fi
 +
 + if [ -z "$Mac" ]; then
 + Mac="$(mtd_get_mac_ascii art protest_plc_mac)"
 + fi
 +
 + plctool -i "$device" -R "$Mac"
 +}
 +
 +setup() {
 + if [ ! -f /etc/config/plc ] || [ "$(uci show plc 2>/dev/null)" = "" ]; then
 + touch /etc/config/plc
 + uci set plc.config=config
 + uci commit plc
 + fi
 +
 + echo -n "Download original firmware and extract files from /lib/plc to /etc/plc [y|n] "
 + read i
 + if [ "$i" = "y" ] || [ "$i" = "Y" ]; then
 + if [ -z "$(which unsquashfs)" ]; then
 + echo "unsquashfs missing. Install squashfs-tools-unsquashfs package" >&2
 + exit 1
 + fi
 +
 + cd /tmp
 + FW="COVRP2500A1_FW101b08_decrypted.bin"
 + rm -f "$FW"
 + wget -O "$FW" "http://pmdap.dlink.com.tw/PMD/GetAgileFile?itemNumber=FIR1800225&fileName=COVRP2500A1_FW101b08_decrypted.bin&fileSize=1.5990457E7;1.5992229E7;65141.0;"
 + if [ ! -f "$FW" ]; then
 + echo "Download failed. Check network" >&2
 + exit 1
 + fi
 + unsquashfs -lls "$FW" /lib/plc | grep -q '\.pib$'
 + if [ $? -ne 0 ]; then
 + echo "$FW does not contain any /lib/plc/*.pib files" >&2
 + exit 1
 + fi
 +
 + unsquashfs "$FW" /lib/plc
 + mkdir -p /etc/plc/
 + cp squashfs-root/lib/plc/* /etc/plc/
 + rm -rf squashfs-root
 + rm "$FW"
 + fi
 +
 + options=$(echo /etc/plc/*.pib)
 + if [ "$options" = "/etc/plc/*.pib" ]; then
 + echo "No files matching /etc/plc/*.pib" >&2
 + exit 1
 + fi
 + count=$(echo $options | wc -w)
 + i=""
 + while [ -z "$i" ] || [ $i -lt 1 ] || [ $i -gt $count ]; do
 + i=1
 + for f in $options; do
 + echo "${i}) $f"
 + i=$((i+1))
 + done
 + echo -n "Select PibPath [1-${count}]: "
 + read i
 + done
 + pibpath=$(echo $options | awk '{print$'$i'}')
 + uci set plc.config.PibPath=$pibpath
 +
 + options=$(echo /etc/plc/*.nvm)
 + if [ "$options" = "/etc/plc/*.nvm" ]; then
 + echo "No files matching /etc/plc/*.nvm" >&2
 + exit 1
 + fi
 + count=$(echo $options | wc -w)
 + if [ $count -gt 1 ]; then
 + i=""
 + while [ -z "$i" ] || [ $i -lt 1 ] || [ $i -gt $count ]; do
 + i=1
 + for f in $options; do
 + echo "${i}) $f"
 + i=$((i+1))
 + done
 + echo -n "Select NvmPath [1-${count}]: "
 + read i
 + done
 + nvmpath=$(echo $options | awk '{print$'$i'}')
 + else
 + nvmpath=$options
 + fi
 + uci set plc.config.NvmPath=$nvmpath
 +
 + echo -n "NetworkPasswd (leave empty to use default plc_networkpwd): "
 + read networkpwd
 + if [ -z "$networkpwd" ]; then
 + networkpwd="$(mtd_get_key art plc_networkpwd)"
 + fi
 + uci set plc.config.NetworkPasswd="$networkpwd"
 + uci set plc.config.Nmk="$(hpavkey -M "$networkpwd")"
 + uci set plc.config.NmkSelected='true'
 +
 + uci set plc.config.Mac="$(mtd_get_key art protest_plc_mac)"
 +
 + dek="$(mtd_get_key art plc_dek)"
 + uci set plc.config.Dek="$dek"
 + uci set plc.config.Dak="$(hpavkey -D "$dek")"
 +
 + uci set plc.config.AdapterName="$(uci get system.@system[0].hostname)"
 +
 + echo -n "Enable plc [0-1]: "
 + read i
 + if [ ! -z "$i" ] && [ $i -eq 1 ]; then
 + uci set plc.config.Enabled=1
 + enable
 + else
 + uci set plc.config.Enabled=0
 + disable
 + fi
 +
 + echo -n "Automatically add to br-lan bridge [0-1]: "
 + read i
 + if [ ! -z "$i" ] && [ $i -eq 1 ]; then
 + uci set plc.config.Network="lan"
 + else
 + uci set plc.config.Network=""
 + fi
 +
 + # Commit changes
 + if [ ! -z "$(uci changes plc)" ]; then
 + uci commit plc
 + fi
 +}
 +</code>
 +</hidden>
  
 ===== Hardware ===== ===== Hardware =====
  • Last modified: 2024/08/29 18:27
  • by jokujossai