Ubuntu avahi-daemon 移植 imxrt1064(arm-v7-linux-uclibceabi)

前言

真香注意

由於此板子需要遵守廠商規則必須 build 成-static 的程式,但是 avahi-daemon 本身會 build 成 -shard 的程式,所以我們必須修改相關的 makefile,所以單純的./configure 已經沒辦法滿足,看不懂我在工三小就直接往下看。

avahi-daemon 移植 imxrt1064(arm-v7-linux-uclibceabi)

以下請自行準備相關 toolchain,並遵照廠商提供的編譯方法。

1.下載 4 個 tar 包

自行解壓縮到指定資料夾,本文示範如下

$ tree -L 1 ~/Desktop/avahi-daemon-imxrt1064/
/home/yuyan/Desktop/avahi-daemon-imxrt1064/
├── avahi-0.7
├── expat-2.2.9
├── libdaemon-0.14
└── attr-2.5.1

4 directories, 0 files

2.編譯 libdaemon

#因為產生再/opt底下,所以切至root權限
$sudo -s

#設置
$./configure --host=arm-v7-linux-uclibceabi --prefix=/opt/imxrt1064/libdaemon CC=arm-v7-linux-uclibceabi-gcc \
--config-cache

#錯誤訊息:
configure: error: cannot check setpgrp when cross compiling
#訂正方法:
$echo "ac_cv_func_setpgrp_void=yes" > config.cache

# 再次執行
$./configure --host=arm-v7-linux-uclibceabi --prefix=/opt/imxrt1064/libdaemon CC=arm-v7-linux-uclibceabi-gcc \
--config-cache

$make

# 會碰到這些錯誤
CCLD   libdaemon.la
.libs/dfork.o: In function `daemon_fork':
/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dfork.c:178: undefined reference to `fork'
/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dfork.c:245: undefined reference to `fork'
.libs/dexec.o: In function `daemon_execv':
/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dexec.c:62: undefined reference to `fork'
collect2: error: ld returned 1 exit status
Makefile:339: recipe for target 'libdaemon.la' failed
make[2]: *** [libdaemon.la] Error 1
make[2]: Leaving directory '/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon'
Makefile:382: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14'
Makefile:287: recipe for target 'all' failed
make: *** [all] Error 2

# 因為uclinux 沒有fork這東西所以全部用vfork 代替

---
# 將這2個文件內的 fork 全部替換成 vfork
$vim /home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dfork.c

$vim /home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dexec.c

$make
$make install

3.編譯 expat (如果 toolchain 沒有的話)

#解壓縮
$bzip2 -d expat-2.2.9.tar.bz2ls
$tar xvf expat-2.2.9.tar ./

#因為要產生在/opt底下,所以切至root權限
$sudo -s

$./configure --host=arm-v7-linux-uclibceabi --prefix=/opt/imxrt1064/expat-2.2.9 CC=arm-v7-linux-uclibceabi-gcc
$make
$make install

4.編譯 libattr (如果 toolchain 沒有的話)(可選)

(20220718 補充) 編譯流程跟expat差不多 <= 有需要調整請自行修正
我不確定這隻cross compiler 需不需要自己build這個 lib,如果avahi需要的話,在build好此lib 在CFLAGS 跟LDFLAGS 補上

#解壓縮
$tar zxvf attr-2.5.1.tar.gz

$sudo -s
$./configure --host=arm-v7-linux-uclibceabi --prefix=/opt/imxrt1064/attr CC=arm-v7-linux-uclibceabi-gcc

$make
$make install

5.編譯 avahi

這邊目的只在於編譯 avahi-daemon,所以其他的工具都會 disable。

Optional Features:

opertion description
–disable-option-checking ignore unrecognized –enable/–with options
–disable-FEATURE do not include FEATURE (same as –enable-FEATURE=no)
–enable-FEATURE[=ARG] include FEATURE [ARG=yes]
–enable-silent-rules less verbose build output (undo: “make V=1”)
–disable-silent-rules verbose build output (undo: “make V=0”)
–enable-dependency-tracking do not reject slow dependency extractors
–disable-dependency-tracking speeds up one-time build
–disable-stack-protector Disable GCC’s/libc’s stack-smashing protection
–enable-shared[=PKGS] build shared libraries [default=yes]
–enable-static[=PKGS] build static libraries [default=yes]
–enable-fast-install[=PKGS] optimize for fast installation [default=yes]
–disable-libtool-lock avoid locking (might break parallel builds)
–disable-nls do not use Native Language Support
–disable-rpath do not hardcode runtime library paths
–disable-glib Disable use of GLib
–disable-gobject Disable use of GLib GObject
–enable-introspection=[no/auto/yes] Enable introspection for this build
–disable-libevent Disable use of libevent
–enable-qt3 Enable building of Qt3 mainloop integration
–disable-qt4 Disable building of Qt4Core mainloop integration
–disable-qt5 Disable building of Qt5Core mainloop integration
–disable-gtk Disable use of GTK+ 2
–disable-gtk3 Disable use of GTK+ 3
–disable-dbus Disable use of D-Bus
–enable-dbm Enable use of DBM
–disable-gdbm Disable use of GDBM
–disable-libdaemon Disable use of libdaemon
–disable-python Disable scripts that depends on python
–disable-pygobject Disable use of Python GObject
–disable-python-dbus Disable use of D-Bus in Python
–disable-mono Disable mono bindings
–disable-monodoc Disable documentation for mono bindings
–disable-autoipd Disable building of avahi-autoipd
–disable-doxygen-doc don’t generate any doxygen documentation
–disable-doxygen-dot don’t generate graphics for doxygen documentation
–enable-doxygen-man generate doxygen manual pages
–enable-doxygen-rtf generate doxygen RTF documentation
–disable-doxygen-xml don’t generate doxygen XML documentation
–enable-doxygen-chm generate doxygen compressed HTML help documentation
–enable-doxygen-chi generate doxygen seperate compressed HTML help index file
–disable-doxygen-html don’t generate doxygen plain HTML documentation
–enable-doxygen-ps generate doxygen PostScript documentation
–enable-doxygen-pdf generate doxygen PDF documentation
–enable-core-docs Enable building of documentation for avahi-core
–disable-manpages Disable building and installation of man pages
–disable-xmltoman Disable rebuilding of man pages with xmltoman
–enable-tests Enable building of tests and examples
–enable-compat-libdns_sd Enable compatibility layer for libdns_sd
–enable-compat-howl Enable compatibility layer for HOWL

開始編譯:

#直接root編譯
$sudo -s

#因為我們要build static 的avahi 所以我們要通過他的-pthread驗證所以先動點手腳
$ vim ./configure

#切到17606行
:17060
#會看到
CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
#改成
CFLAGS="-static -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
#存檔離開
:wq

#build avahi
$./configure --host=arm-v7-linux-uclibceabi \
--prefix=/opt/imxrt1064/avahi/ \
--with-distro=none \
--sysconfdir=/etc \
--with-xml=expat \
--with-avahi-user="root" \
--with-avahi-group="root" \
--localstatedir=/var \
--enable-libdaemon \
--disable-glib \
--disable-gobject \
--disable-dbus \
--disable-gdbm \
--disable-autoipd \
--disable-qt3 \
--disable-qt4 \
--disable-gtk \
--disable-gtk3 \
--disable-python \
--disable-pygtk \
--disable-python-dbus \
-disable-mono \
-disable-monodoc \
-disable-doxygen-html \
-disable-xmltoman \
-disable-manpages \
CC=arm-v7-linux-uclibceabi-gcc \
CFLAGS="-I/opt/imxrt1064/avahi/include -I/opt/imxrt1064/expat-2.2.9/include -I/linux-cortexm-2.5.2/linux/tools/perf/util/ -I/home/allen/Desktop/nxp/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/sysroot/include " \
LDFLAGS="-L/opt/imxrt1064/avahi/lib -L/opt/imxrt1064/expat-2.2.9/lib" \
LIBS="-static" \
LIBDAEMON_CFLAGS="-I/opt/imxrt1064/libdaemon/include " \
LIBDAEMON_LIBS="/opt/imxrt1064/libdaemon/lib/libdaemon.a"

# 這邊開始動些手腳

$make

# 他會依序build folder ./avahi-common => ./avahi-core => ./avahi-daemon

#進入 avahi-daemon
$cd ./avahi-daemon
# 先清掉
$make clean

# 我們要竄改Makefile
$vim Makefile

#找到 -lssp這個東西(478行), 改成toolchain 底下的 libssp.a檔
#原為
LIBS = -static -lssp
#改成
LIBS = -static /home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib/libssp.a

#找到 --silent(235行)
#原為
am__v_lt_0 = --silent
#改成
am__v_lt_0 = #--silent
#這個的目的是他在最後用 libtool link的時候你就可以很清楚看到link的所有檔案

$make

---
libtool: warning: library '/home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib/libssp.la' was moved.
libtool: link:
#這段就是所有的link 可以看到有些檔案是.so檔
arm-v7-linux-uclibceabi-gcc -std=gnu99 -I.. "-DDEBUG_TRAP=__asm__(\"int \$3\")" -DAVAHI_DAEMON_RUNTIME_DIR=\"/run/avahi-daemon/\" -DAVAHI_SOCKET=\"/run/avahi-daemon/socket\" -DAVAHI_SERVICE_DIR=\"/etc/avahi/services\" -DAVAHI_CONFIG_FILE=\"/etc/avahi/avahi-daemon.conf\" -DAVAHI_HOSTS_FILE=\"/etc/avahi/hosts\" -DAVAHI_DBUS_INTROSPECTION_DIR=\"/opt/imxrt1064/avahi/share/dbus-1/interfaces\" -DAVAHI_CONFIG_DIR=\"/etc/avahi\" -I/opt/imxrt1064/libdaemon/include -DUSE_EXPAT_H -I/opt/imxrt1064/avahi/include -I/opt/imxrt1064/expat-2.2.9/include -I/linux-cortexm-2.5.2/linux/tools/perf/util/ -I/home/allen/Desktop/nxp/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/sysroot/include -Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -fdiagnostics-show-option -Wno-cast-qual -fno-strict-aliasing -o avahi-daemon avahi_daemon-main.o avahi_daemon-simple-protocol.o avahi_daemon-static-services.o avahi_daemon-static-hosts.o avahi_daemon-ini-file-parser.o avahi_daemon-setproctitle.o avahi_daemon-sd-daemon.o avahi_daemon-check-nss.o  -L/opt/imxrt1064/avahi/lib -L/opt/imxrt1064/expat-2.2.9/lib ../avahi-common/.libs/libavahi-common.a ../avahi-core/.libs/libavahi-core.a /home/yuyan/Desktop/avahi-daemon-imxrt1064/avahi-0.7/avahi-common/.libs/libavahi-common.a /home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib/libssp.so /opt/imxrt1064/libdaemon/lib/libdaemon.a /opt/imxrt1064/expat-2.2.9/lib/libexpat.so /home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib/libssp.a -pthread -Wl,-rpath -Wl,/home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib -Wl,-rpath -Wl,/opt/imxrt1064/expat-2.2.9/lib -Wl,-rpath -Wl,/home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib -Wl,-rpath -Wl,/opt/imxrt1064/expat-2.2.9/lib


/home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib/libssp.so: warning: the 'gets' function is dangerous and should not be used.

#會看到這些東西

#重新再連結一次,將連結的 .so 換掉,尾巴補上-static
$arm-v7-linux-uclibceabi-gcc -std=gnu99 -I.. "-DDEBUG_TRAP=__asm__(\"int \$3\")" -DAVAHI_DAEMON_RUNTIME_DIR=\"/run/avahi-daemon/\" -DAVAHI_SOCKET=\"/run/avahi-daemon/socket\" -DAVAHI_SERVICE_DIR=\"/etc/avahi/services\" -DAVAHI_CONFIG_FILE=\"/etc/avahi/avahi-daemon.conf\" -DAVAHI_HOSTS_FILE=\"/etc/avahi/hosts\" -DAVAHI_DBUS_INTROSPECTION_DIR=\"/opt/imxrt1064/avahi/share/dbus-1/interfaces\" -DAVAHI_CONFIG_DIR=\"/etc/avahi\" -I/opt/imxrt1064/libdaemon/include -DUSE_EXPAT_H -I/opt/imxrt1064/avahi/include -I/opt/imxrt1064/expat-2.2.9/include -I/linux-cortexm-2.5.2/linux/tools/perf/util/ -I/home/allen/Desktop/nxp/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/sysroot/include -Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -fdiagnostics-show-option -Wno-cast-qual -fno-strict-aliasing -o avahi-daemon avahi_daemon-main.o avahi_daemon-simple-protocol.o avahi_daemon-static-services.o avahi_daemon-static-hosts.o avahi_daemon-ini-file-parser.o avahi_daemon-setproctitle.o avahi_daemon-sd-daemon.o avahi_daemon-check-nss.o  -L/opt/imxrt1064/avahi/lib -L/opt/imxrt1064/expat-2.2.9/lib ../avahi-common/.libs/libavahi-common.a ../avahi-core/.libs/libavahi-core.a /home/yuyan/Desktop/avahi-daemon-imxrt1064/avahi-0.7/avahi-common/.libs/libavahi-common.a /home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib/libssp.a /opt/imxrt1064/libdaemon/lib/libdaemon.a /opt/imxrt1064/expat-2.2.9/lib/libexpat.a /home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib/libssp.a -pthread -Wl,-rpath -Wl,/home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib -Wl,-rpath -Wl,/opt/imxrt1064/expat-2.2.9/lib -Wl,-rpath -Wl,/home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib -Wl,-rpath -Wl,/opt/imxrt1064/expat-2.2.9/lib -static

#用 readlf -d 確認avahi-daemon沒有任何的動態連結
$arm-v7-linux-uclibceabi-readelf -d ./avahi-daemon

# 全部靜態的結果會是這樣
There is no dynamic section in this file.

# 如果沒加-static 就會變成
Dynamic section at offset 0x54598 contains 29 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libc.so.0]
 0x0000000f (RPATH)                      Library rpath: [/home/yuyan/Desktop/linux-cortexm-2.5.2/tools/arm-v7-linux-uclibceabi/arm-v7-linux-uclibceabi/lib:/opt/imxrt1064/expat-2.2.9/lib]
 (下略)

# 這時我們就已經把 avahi-daemon build 好了,可以直接丟到 機器上run

6.疑難排解

avahi error: ‘O_CLOEXEC’ undeclared

$gedit avahi-daemon/main.c
#define O_CLOEXEC 0 //<==add line
static char *get_machine_id(void) {
    int fd;
    char buf[32];
    fd = open("/etc/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY);
    if (fd == -1 && errno == ENOENT)
        fd = open("/var/lib/dbus/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY);
    if (fd == -1)
        return NULL;
//(略)
}

No package ‘gtk+-3.0’ found

$sudo apt-get install build-essential libgtk-3-dev
$cd /opt/avahi/etc/avahi/services
# write XXX.service (PS:XXX 自訂)
$vim lxi.service

No package ‘glib-2.0’ found

checking for GLIB20... no
configure: error: Package requirements ( glib-2.0 >= 2.4.0 ) were not met:

No package 'glib-2.0' found
$sudo apt-get install libglib2.0-dev

/libcap.so: undefined reference to XXXX

/opt/toolchains/ti335x/cortexa8t2hf-vfp-neon-linux-gnueabi/lib/libcap.so: undefined reference to `removexattr@ATTR_1.0'
/opt/toolchains/ti335x/cortexa8t2hf-vfp-neon-linux-gnueabi/lib/libcap.so: undefined reference to `fremovexattr@ATTR_1.0'
/opt/toolchains/ti335x/cortexa8t2hf-vfp-neon-linux-gnueabi/lib/libcap.so: undefined reference to `getxattr@ATTR_1.0'
/opt/toolchains/ti335x/cortexa8t2hf-vfp-neon-linux-gnueabi/lib/libcap.so: undefined reference to `setxattr@ATTR_1.0'
/opt/toolchains/ti335x/cortexa8t2hf-vfp-neon-linux-gnueabi/lib/libcap.so: undefined reference to `fsetxattr@ATTR_1.0'
/opt/toolchains/ti335x/cortexa8t2hf-vfp-neon-linux-gnueabi/lib/libcap.so: undefined reference to `fgetxattr@ATTR_1.0'

#./configure 時LDFLAGS 補上 -lattr,本文沒用到

undefined reference to `fork’

/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dfork.c:178: undefined reference to `fork'
/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dfork.c:245: undefined reference to `fork'
/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dexec.c:62: undefined reference to `fork'
collect2: error: ld returned 1 exit status
Makefile:270: recipe for target 'testd' failed
make[2]: *** [testd] Error 1
make[2]: Leaving directory '/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/examples'
Makefile:382: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14'
Makefile:287: recipe for target 'all' failed
make: *** [all] Error 2

將這三個文件內的 fork 全部替換成 vfork

$vim /home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dfork.c
$vim /home/yuyan/Desktop/avahi-daemon-imxrt1064/libdaemon-0.14/libdaemon/dexec.c

uclinux gdb 疑難排解

fatal error: curses.h: No such file or directory

In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory

sudo apt-get install libncurses5-dev libncursesw5-dev

遇到 undefined symbol: pyunicodeucs4_fromencodedobject

LD_PRELOAD=/usr/lib/libpython2.7.so arm-v7-linux-uclibceabi-gdb -ex ‘set environ LD_PRELOAD’ –args my-program-to-debug

target remote 172.16.28.129:10000

BASECFLAGS=-m32 LDFLAGS=-m32 CFLAGS=-m32 ./configure –prefix=/usr –enable-shared –enable-unicode=ucs4


運行環境底下

必需建置

Folder:

  1. mkdir -p /run/avahi/
  2. mkdir -p /etc/avahi/services/

File

  1. cp /mnt/nfs/avahi-daemon /sbin/avahi-daemon <= 執行檔
  2. vi /etc/avahi/avahi-daemon.conf
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# avahi is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with avahi; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.

# See avahi-daemon.conf(5) for more information on this configuration
# file!


[server]
#host-name=foo
#domain-name=local
#browse-domains=0pointer.de, zeroconf.org
use-ipv4=yes
use-ipv6=no
#allow-interfaces=eth0
#deny-interfaces=eth1
#check-response-ttl=no
#use-iff-running=no
#enable-dbus=yes
#disallow-other-stacks=no
#allow-point-to-point=no
#cache-entries-max=4096
#clients-max=4096
#objects-per-client-max=1024
#entries-per-entry-group-max=32
ratelimit-interval-usec=1000000
ratelimit-burst=1000

[wide-area]
enable-wide-area=yes

[publish]
#disable-publishing=no
#disable-user-service-publishing=no
#add-service-cookie=no
#publish-addresses=yes
publish-hinfo=no
publish-workstation=no
#publish-domain=yes
#publish-dns-servers=192.168.50.1, 192.168.50.2
#publish-resolv-conf-dns-servers=yes
#publish-aaaa-on-ipv4=yes
#publish-a-on-ipv6=no

[reflector]
#enable-reflector=no
#reflect-ipv=no

[rlimits]
#rlimit-as=
#rlimit-core=0
#rlimit-data=8388608
#rlimit-fsize=0
#rlimit-nofile=768
#rlimit-stack=8388608
#rlimit-nproc=3
  1. vi /etc/avahi/services/lxi.service <=lxi 服務設定檔
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
        <name replace-wildcards="yes">%h-yuyan123</name>
        <service protocol="ipv4">
                <type>_lxi._tcp</type>
                <port>80</port>
                <txt-record>txtvers=1</txt-record>
                <txt-record>Model=A-1234</txt-record>
                <txt-record>SerialNumber=GWT123456</txt-record>
                <txt-record>FirmwareVersion=V1.0.0.1.</txt-record>
                <txt-record>Manufacturer=GWINSTEK</txt-record>
        </service>
        <service>
                <type>_http._tcp</type>
                <port>80</port>
        </service>
        <service>
                <type>_scpi-raw._tcp</type>
                <port>5025</port>
        </service>
        <service>
                <type>_scpi-telnet._tcp</type>
                <port>5024</port>
        </service>
        <service>
                <type>_vxi-11._tcp</type>
                <port>111</port>
        </service>
        <service>
                <type>_hislip._tcp</type>
                <port>4880</port>
        </service>
</service-group>

簡易測試

在嵌入式系統端開啟服務 (root 帳號為例)

$avahi-daemon

在 PC 端使用 avahi-unitls 測試,Ubuntu 為例

# install
$sudo apt-get install avahi-untils

# test
$avahi-browse -a | grep _lxi._tcp

  目錄