海运的博客

使用glibc编译的openwrt支持utf8中文显示和输入

发布时间:December 11, 2022 // 分类: // No Comments

将编译openwrt环境中的locale命令复制到路由上:

scp staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_glibc/bin/locale root@192.168.1.1:/usr/local/bin/

在任一linux机器上将生成的utf8编码复制到路由上:

scp /usr/lib/locale/locale-archive 192.168.1.1:/lib/locale/
scp -r /usr/lib/locale/C.UTF-8/  192.168.1.1:/lib/locale/

输入中文:

cat /root/.inputrc 

set meta-flag on
set convert-meta off
set input-meta on
set output-meta on

也可通过以下方法在openwrt路由上生成语言编码,占用内存大,小内存路由会kill。
https://github.com/openwrt/packages/issues/2900

360t7通过usb tll刷入不死uboot和openwrt系统

发布时间:December 5, 2022 // 分类: // No Comments

拆机连接ttl,从外到内依次为txd rxd gnd,也有人说rxd txd gnd。

用SRT连接或其它ssh管理软件:

启动时持续按f加回车键直到进入failsafe模模式:

#开启uboot控制台菜单(可选),开启后可通过uboot命令行更新固件。
#fw_setenv bootmenu_delay 3

# 挂载rootfs并开启telnet
mount_root
sed -i 's/.*local debug=.*/\tlocal debug=1/' /etc/init.d/telnet

# 修改root密码
passwd root
reboot

不开启telnet也可通过ttl配置网络备份系统和刷入uboot:

ifconfig eth0 0.0.0.0
brctl addbr br-lan
ifconfig br-lan 192.168.2.1 netmask 255.255.255.0 up
brctl addif br-lan eth0

重启后通过telnet登录,查看分区表:

cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 08000000 00020000 "spi0.0"
mtd1: 00100000 00020000 "bl2"
mtd2: 00080000 00020000 "u-boot-env"
mtd3: 00200000 00020000 "Factory"
mtd4: 00200000 00020000 "fip"
mtd5: 02400000 00020000 "ubi"
mtd6: 02400000 00020000 "firmware-1"
mtd7: 02400000 00020000 "plugin"
mtd8: 00100000 00020000 "config"
mtd9: 00080000 00020000 "factory"
mtd10: 00700000 00020000 "log"

备份整个路由固件:

nc -l -p 3333 > all.bin
cat /dev/mtd0 | nc 192.168.1.8 3333
#或
nc -l -p 3333 | dd of=all2.bin
dd if=/dev/mtd0 | nc 192.168.1.8 3333

刷入下载的uboot:

wget 192.168.1.8/mt7981_360t7-fip-fixed-parts.bin 
#验证文件是否正确,刷错路由会变砖。
md5sum mt7981_360t7-fip-fixed-parts.bin 
256977db5ca6a17b0f9e73b0ddfd3efd  mt7981_360t7-fip-fixed-parts.bin
mtd -r write mt7981_360t7-fip-fixed-parts.bin fip

关闭电源将电脑ip设置为192.168.1.2,按住reset键路由开机,然后访问192.168.1.1 web界面刷入openwrt固件,使用immortalwrt-mediatek-mt7981-mt7981-360-t7-108M-squashfs-factory.bin,通过openwrt更新可使用immortalwrt-mediatek-mt7981-mt7981-360-t7-108M-squashfs-sysupgrade.bin。

https://cmi.hanwckf.top/p/360t7-firmware/
https://github.com/hanwckf/bl-mt798x
https://github.com/hanwckf/immortalwrt-mt798x

N1盒子/arm64下cups使用兄弟打印机Brother HL-2260D的问题

发布时间:September 18, 2022 // 分类: // No Comments

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

pve减少对ssd硬盘的写入量

发布时间:July 28, 2022 // 分类: // No Comments

禁用pve-ha-crm和pve-ha-lrm服务:

systemctl stop pve-ha-lrm.service pve-ha-crm.service
systemctl disable pve-ha-lrm.service pve-ha-crm.service

修改/etc/default/rrdcached:

#添加
WRITE_TIMEOUT=3600
FLUSH_TIMEOUT=7200
#注释此行
##JOURNAL_PATH=/var/lib/rrdcached/journal/

修改/etc/init.d/rrdcached变量RRDCACHED_OPTIONS处添加:

${FLUSH_TIMEOUT:+-f ${FLUSH_TIMEOUT}} \

重启rrdcached:

systemctl daemon-reload 
systemctl restart rrdcached.service 

https://forum.proxmox.com/threads/reducing-rrdcached-writes.64473/
https://pastebin.com/437dN33v
https://forum.proxmox.com/threads/pmxcfs-writing-to-disk-all-the-time.35828/

使用PaddleOCR图片文字识别

发布时间:July 21, 2022 // 分类: // No Comments

安装paddleocr:

apt install python3-pip libgl1
pip3 install paddlepaddle paddleocr

paddleocr cli使用:

paddleocr --image_dir test.jpg --lang ch --show_log False --det_db_unclip_ratio 2.5

python使用:

from paddleocr import PaddleOCR

ocr = PaddleOCR(use_angle_cls=True, lang="ch", det_db_score_mode="slow", show_log=False, use_gpu=False, det_db_unclip_ratio=2.5) 

img_path = 'test.jpg'
result = ocr.ocr(img_path, cls=True)
txts = [line[1][0] for line in result]
print(*txts)

如遇到错:

AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)

安装指定版本opencv-python:

pip uninstall opencv-python
pip install opencv-python==4.5.5.64

https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/inference_args.md

分类
最新文章
最近回复
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
  • zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
归档