x86/x64下安装打印机驱动,model name输入为:HL-2260D
wget https://d.brother-movie.com/driver/1480/linux-brprinter-installer-2.2.3-1.gz
gunzip linux-brprinter-installer-2.2.3-1.gz
bash linux-brprinter-installer-2.2.3-1
安装程序内包含二进制x86程序,在arm下安装会提示错误:
/opt/brother/Printers/HL2260D/inf/braddprinter: Exec format error
可以在一台空闲x86上安装cups,然后通过usbip将n1下usb打印机桥接x86上管理。
n1内核为5.3,已编译usbip模块,下载linux-tool提取usbip管理工具:
apt download linux-raspi-tools-5.4.0-1035_5.4.0-1035.38_arm64.deb
dpkg -X linux-raspi-tools-5.4.0-1035_5.4.0-1035.38_arm64.deb linux-tools
cp linux-tools/usr/lib/linux-raspi-tools-5.4.0-1035/usbipd /usr/local/bin/
cp linux-tools/usr/lib/linux-raspi-tools-5.4.0-1035/usbip /usr/local/bin/
apt install usb.ids
mkdir /usr/share/hwdata/
ln -s /var/lib/usbutils/usb.ids /usr/share/hwdata//usb.ids
服务端使用:
modprobe usbip-core
modprobe usbip-host
modprobe vhci-hcd
/usr/local/bin/usbipd -D
/usr/local/bin/usbip list --local
/usr/local/bin/usbip bind --busid=1-2
service:
[Unit]
Description=usbip server
After=network.target
[Service]
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/usbipd
ExecStartPost=/usr/local/bin/usbip bind --busid=1-2
[Install]
WantedBy=multi-user.target
udev规则当usb插入时自动bind到usbip:
ACTION=="add" SUBSYSTEM=="usb" ATTRS{idVendor}=="04f9" ATTRS{idProduct}=="006d" RUN+="/usr/local/bin/usbip bind --busid=1-2"
如果内核无usbip支持,可通过第三方程序配置usbip服务端:
apt install libusb-1.0-0-dev
git clone https://github.com/raydudu/usbipd-libusb.git
cd
mkdir usbipd-libusb/build
cd usbipd-libusb/build
cmake .. && make
./usbip_libusb -D
x86 debian下挂载远程usb:
apt install usbip
modprobe vhci_hcd
usbip list -r 192.168.1.1
usbip attach -r 192.168.1.1 -b 1-2
自动usbip attach:
#!/bin/bash
set -x
while true; do
if /usr/sbin/usbip port|grep -q "Brother" > /dev/null 2>&1; then
else
if /usr/sbin/usbip list -r 192.168.1.1|grep -q "Brother" &> /dev/null; then
echo `date` 'start connect' >> /tmp/usbipd_log.txt
/usr/sbin/usbip attach -r 192.168.1.1 -b 1-2
else
echo 'no exportable'
fi
fi
sleep 10
done
客户端关闭时需detach,不然重接连接时需在服务端unbind:
usbip detach --port 00
usbip unbind --busid=1-2
service:
[Unit]
Description=usbip client
[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/usr/sbin/usbip detach --port 00
[Install]
WantedBy=multi-user.target
在使用过程中如果出现以下错误:
usblp0: removed
usblp 1-2: usblp0: USB Bidirectional printer dev
禁用usblp并重启:
echo 'blacklist usblp' >> /etc/modprobe.d/usblp-blacklist.conf
apt源也有第三方兄弟打印机驱动,但是无hl-2260d版,不过使用其它型号也能正常使用。
apt install foomatic-db
#或者
apt install printer-driver-brlaser