radxa-pkg / radxa-otgutils

Enable USB gadget on OTG port
GNU General Public License v3.0
9 stars 8 forks source link

feat: add udc to options #12

Open CodeChenL opened 1 month ago

CodeChenL commented 1 month ago

关联 #11

CodeChenL commented 3 weeks ago

看上去没什么问题,有测试实际使用的效果么? 另外也要验证如果之前开启了radxa-usbnet服务,升级后能否保持开启

需要加个postinst来重新enable otg服务

RadxaYuntian commented 3 weeks ago

看上去没什么问题,有测试实际使用的效果么? 另外也要验证如果之前开启了radxa-usbnet服务,升级后能否保持开启

需要加个postinst来重新enable otg服务

要在这里安装:https://github.com/radxa-pkg/radxa-otgutils/blob/main/debian/rules#L13-L14

CodeChenL commented 3 weeks ago

看上去没什么问题,有测试实际使用的效果么? 另外也要验证如果之前开启了radxa-usbnet服务,升级后能否保持开启

需要加个postinst来重新enable otg服务

要在这里安装:https://github.com/radxa-pkg/radxa-otgutils/blob/main/debian/rules#L13-L14

试了没效果

CodeChenL commented 3 weeks ago

看上去没什么问题,有测试实际使用的效果么? 另外也要验证如果之前开启了radxa-usbnet服务,升级后能否保持开启

需要加个postinst来重新enable otg服务

要在这里安装:https://github.com/radxa-pkg/radxa-otgutils/blob/main/debian/rules#L13-L14

试了没效果

失效的软链接

ock@rock-2a:/$ ls -l /etc/systemd/system/multi-user.target.wants/radxa-usbnet@fe500000.dwc3.service
lrwxrwxrwx 1 root root 41 Jun 21 08:26 /etc/systemd/system/multi-user.target.wants/radxa-usbnet@fe500000.dwc3.service -> /lib/systemd/system/radxa-usbnet@.service
rock@rock-2a:/$
CodeChenL commented 3 weeks ago

只能enable ecm 然后才能 restart usbnet,手动也enbale不了(忽略e20c的串口回显错误)

rock@rock-2a:/$ sdo systemctl enable radxa-usbnet@fe500000.dwc3
Failed to enable unit: Refusing to operate on alias name or linked unit file: radxa-usbnet@fe500000.dwc3.service
rock@rock-2a:/$
RadxaYuntian commented 3 weeks ago

这是两个问题:

  1. 需要将systemd unit在rules里面添加,否则不会被打包
  2. 可能要分析一下为什么bind9就可以重命名他们的服务:https://salsa.debian.org/dns-team/bind9/-/commit/6fd962a36bb54e0106e001aff6cce056d54e2526#befe0c97e7c2864a71511033f5078fad6c97cfc1

有可能只能把usbnet恢复,然后加一个ecm的alias

CodeChenL commented 3 weeks ago

这是两个问题:

  1. 需要将systemd unit在rules里面添加,否则不会被打包
  2. 可能要分析一下为什么bind9就可以重命名他们的服务:https://salsa.debian.org/dns-team/bind9/-/commit/6fd962a36bb54e0106e001aff6cce056d54e2526#befe0c97e7c2864a71511033f5078fad6c97cfc1

有可能只能把usbnet恢复,然后加一个ecm的alias

  1. 尝试过在rule install usbnet但是没效果,实际的软件包里没有
RadxaYuntian commented 3 weeks ago

你现在没有usbnet这个文件所以不行啊

CodeChenL commented 3 weeks ago

你现在没有usbnet这个文件所以不行啊

替换之后,升级前先enable usbnet,升级之后udc不会自动enbale

CodeChenL commented 3 weeks ago

可能还是得加个postinst?

RadxaYuntian commented 3 weeks ago

Requires= & Before=

RadxaYuntian commented 3 weeks ago

Also=可能是不需要的

RadxaYuntian commented 2 weeks ago

现在可以更新后正常启动cdc服务么?

CodeChenL commented 2 weeks ago

现在可以更新后正常启动cdc服务么?

可以

CodeChenL commented 2 weeks ago

这是先开启adbd与usbnet,更新以后的各个服务状态:

rock@rock-5b:~$ sudo systemctl status radxa-*
● radxa-adbd@fc000000.usb.service - Enable adbd on fc000000.usb
     Loaded: loaded (/lib/systemd/system/radxa-adbd@.service; enabled; preset: enabled)
     Active: active (exited) since Wed 2024-06-26 06:40:00 UTC; 9min ago
       Docs: https://github.com/radxa-pkg/radxa-otgutils/
    Process: 1296 ExecStart=/usr/sbin/radxa-otgutils adbd fc000000.usb start (code=exited, status=0/SUCCESS)
   Main PID: 1296 (code=exited, status=0/SUCCESS)
      Tasks: 4 (limit: 9193)
     Memory: 2.5M
        CPU: 47ms
     CGroup: /system.slice/system-radxa\x2dadbd.slice/radxa-adbd@fc000000.usb.service
             └─1334 /usr/bin/adbd

Jun 26 06:40:00 rock-5b systemd[1]: Started radxa-adbd@fc000000.usb.service - Enable adbd on fc000000.usb.
Jun 26 06:40:00 rock-5b radxa-otgutils[1296]: /sys/kernel/config/usb_gadget/fc000000.usb /
Jun 26 06:40:00 rock-5b radxa-otgutils[1296]: /

● radxa-ecm@fc000000.usb.service - Enable USB CDC Ethernet Control Model on fc000000.usb
     Loaded: loaded (/lib/systemd/system/radxa-ecm@.service; disabled; preset: enabled)
     Active: active (exited) since Wed 2024-06-26 06:40:00 UTC; 9min ago
       Docs: https://github.com/radxa-pkg/radxa-otgutils/
    Process: 1298 ExecStart=/usr/sbin/radxa-otgutils ecm fc000000.usb start (code=exited, status=0/SUCCESS)
   Main PID: 1298 (code=exited, status=0/SUCCESS)
        CPU: 28ms

Jun 26 06:40:00 rock-5b systemd[1]: Started radxa-ecm@fc000000.usb.service - Enable USB CDC Ethernet Control Model on fc000000.usb.
Jun 26 06:40:00 rock-5b radxa-otgutils[1298]: /sys/kernel/config/usb_gadget/fc000000.usb /
Jun 26 06:40:00 rock-5b radxa-otgutils[1298]: /

● radxa-udc@fc000000.usb.service - Enable UDC on fc000000.usb
     Loaded: loaded (/lib/systemd/system/radxa-udc@.service; disabled; preset: enabled)
     Active: active (exited) since Wed 2024-06-26 06:40:00 UTC; 9min ago
       Docs: https://github.com/radxa-pkg/radxa-otgutils/
    Process: 1299 ExecStart=/usr/sbin/radxa-otgutils udc fc000000.usb start (code=exited, status=0/SUCCESS)
   Main PID: 1299 (code=exited, status=0/SUCCESS)
        CPU: 29ms

Jun 26 06:40:00 rock-5b systemd[1]: Started radxa-udc@fc000000.usb.service - Enable UDC on fc000000.usb.
Jun 26 06:40:00 rock-5b radxa-otgutils[1299]: /sys/kernel/config/usb_gadget/fc000000.usb /
Jun 26 06:40:00 rock-5b radxa-otgutils[1299]: /

● radxa-usbnet@fc000000.usb.service - Enable USB CDC Ethernet Control Model on fc000000.usb
     Loaded: loaded (/lib/systemd/system/radxa-usbnet@.service; enabled; preset: enabled)
     Active: active (exited) since Wed 2024-06-26 06:40:00 UTC; 9min ago
       Docs: https://github.com/radxa-pkg/radxa-otgutils/
    Process: 1297 ExecStart=/usr/bin/echo radxa-usbnet@fc000000.usb.service will be discarded, please use radxa-ecm@fc000000.usb.service instead (code=exited, status=0/SUCCESS)
   Main PID: 1297 (code=exited, status=0/SUCCESS)
        CPU: 2ms

Jun 26 06:40:00 rock-5b systemd[1]: Started radxa-usbnet@fc000000.usb.service - Enable USB CDC Ethernet Control Model on fc000000.usb.
Jun 26 06:40:00 rock-5b echo[1297]: radxa-usbnet@fc000000.usb.service will be discarded, please use radxa-ecm@fc000000.usb.service instead
rock@rock-5b:~$ 
RadxaYuntian commented 1 week ago

我现在在处理更新后服务迁移的问题,但服务本身有一个不受支持的属性:

 /lib/systemd/system/radxa-ecm@.service:6: Unknown key name 'PropagatesStopTo' >

可能要测试一下stop,然后看看这个怎么处理

CodeChenL commented 1 week ago

我现在在处理更新后服务迁移的问题,但服务本身有一个不受支持的属性:

 /lib/systemd/system/radxa-ecm@.service:6: Unknown key name 'PropagatesStopTo' >

可能要测试一下stop,然后看看这个怎么处理

应该是bullseye的systemd的版本247太低了https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#PropagatesStopTo=

CodeChenL commented 1 week ago

我现在在处理更新后服务迁移的问题,但服务本身有一个不受支持的属性:

 /lib/systemd/system/radxa-ecm@.service:6: Unknown key name 'PropagatesStopTo' >

可能要测试一下stop,然后看看这个怎么处理

应该是bullseye的systemd的版本247太低了https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#PropagatesStopTo=

我在bookworm测试可用

RadxaYuntian commented 1 week ago

那先不处理这个问题

RadxaYuntian commented 1 week ago

添加了升级迁移的脚本。在debian 12上再试试

CodeChenL commented 5 days ago

添加了升级迁移的脚本。在debian 12上再试试

可正常升级

rock@rock-5b:/$ cat ~/log 
● radxa-ecm@fc000000.usb.service - Enable USB CDC Ethernet Control Model on fc000000.usb
     Loaded: loaded (/lib/systemd/system/radxa-ecm@.service; disabled; preset: enabled)
     Active: active (exited) since Thu 2024-07-11 02:54:37 UTC; 2min 5s ago
       Docs: https://github.com/radxa-pkg/radxa-otgutils/
    Process: 746 ExecStart=/usr/sbin/radxa-otgutils ecm fc000000.usb start (code=exited, status=0/SUCCESS)
   Main PID: 746 (code=exited, status=0/SUCCESS)
        CPU: 28ms

Jul 11 02:54:37 rock-5b systemd[1]: Started radxa-ecm@fc000000.usb.service - Enable USB CDC Ethernet Control Model on fc000000.usb.
Jul 11 02:54:37 rock-5b radxa-otgutils[746]: /sys/kernel/config/usb_gadget/fc000000.usb /
Jul 11 02:54:37 rock-5b radxa-otgutils[746]: /

● radxa-adbd@fc000000.usb.service - Enable adbd on fc000000.usb
     Loaded: loaded (/lib/systemd/system/radxa-adbd@.service; enabled; preset: enabled)
     Active: active (exited) since Thu 2024-07-11 02:54:37 UTC; 2min 5s ago
       Docs: https://github.com/radxa-pkg/radxa-otgutils/
    Process: 745 ExecStart=/usr/sbin/radxa-otgutils adbd fc000000.usb start (code=exited, status=0/SUCCESS)
   Main PID: 745 (code=exited, status=0/SUCCESS)
      Tasks: 4 (limit: 9192)
     Memory: 2.4M
        CPU: 57ms
     CGroup: /system.slice/system-radxa\x2dadbd.slice/radxa-adbd@fc000000.usb.service
             └─782 /usr/bin/adbd

Jul 11 02:54:37 rock-5b systemd[1]: Started radxa-adbd@fc000000.usb.service - Enable adbd on fc000000.usb.
Jul 11 02:54:37 rock-5b radxa-otgutils[745]: /sys/kernel/config/usb_gadget/fc000000.usb /
Jul 11 02:54:37 rock-5b radxa-otgutils[745]: /

● radxa-udc@fc000000.usb.service - Enable UDC on fc000000.usb
     Loaded: loaded (/lib/systemd/system/radxa-udc@.service; disabled; preset: enabled)
     Active: active (exited) since Thu 2024-07-11 02:54:37 UTC; 2min 5s ago
       Docs: https://github.com/radxa-pkg/radxa-otgutils/
    Process: 750 ExecStart=/usr/sbin/radxa-otgutils udc fc000000.usb start (code=exited, status=0/SUCCESS)
   Main PID: 750 (code=exited, status=0/SUCCESS)
        CPU: 31ms

Jul 11 02:54:37 rock-5b systemd[1]: Started radxa-udc@fc000000.usb.service - Enable UDC on fc000000.usb.
Jul 11 02:54:37 rock-5b radxa-otgutils[750]: /sys/kernel/config/usb_gadget/fc000000.usb /
Jul 11 02:54:37 rock-5b radxa-otgutils[750]: /
RadxaYuntian commented 5 days ago

测试一下之前说的otg无法开启的问题是否还会复现,不会的话重写一下历史

CodeChenL commented 5 days ago

测试一下之前说的otg无法开启的问题是否还会复现,不会的话重写一下历史

其实这个问题,我之前添加失败重启就解决了 https://github.com/radxa-pkg/radxa-otgutils/commit/9dd8c0a16fbef97015a2f5cce5b0136d1df6f291

RadxaYuntian commented 5 days ago

那整理一下提交吧

RadxaYuntian commented 5 days ago

另外测试一下能不能在rsetup里面正常开关功能 debian 11 & 12

CodeChenL commented 5 days ago

rsetup

另外测试一下能不能在rsetup里面正常开关功能 debian 11 & 12

rsetup还得改这行https://github.com/radxa-pkg/rsetup/blob/09b336f68522c77019a3df187d8678bfc2fd8da3/src/usr/lib/rsetup/tui/hardware/hardware.sh#L393

RadxaYuntian commented 5 days ago

主要是看systemd sevice能不能正常传递重启信号,和rsetup自身关系不太大

CodeChenL commented 5 days ago

可以使用rsetup正常开关

RadxaYuntian commented 5 days ago

11 等下测试一下

CodeChenL commented 3 days ago

11 等下测试一下

debian 11正常

RadxaYuntian commented 3 days ago
  1. 检查一下为什么没有清除老的radxa-usbnet.service
  2. 看看如何在debian 11上stop start后能正常开启服务而不用手动restart udc服务
CodeChenL commented 1 day ago
  1. 检查一下为什么没有清除老的radxa-usbnet.service
  2. 看看如何在debian 11上stop start后能正常开启服务而不用手动restart udc服务

可以使用https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#ExecStartPre= 来替换https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#PropagatesStopTo= 来提高兼容性

CodeChenL commented 23 hours ago
  1. 检查一下为什么没有清除老的radxa-usbnet.service
  2. 看看如何在debian 11上stop start后能正常开启服务而不用手动restart udc服务

目前能做到第二点来,但是同时开启两个funciton时,暂停一个funciton,udc也会跟着暂停,导致另一个funciton用不了

CodeChenL commented 23 hours ago

另外看看为什么老的服务没有被uninstall掉

老服务可以正常uninstall

RadxaYuntian commented 23 hours ago

回头再一起测试一下,另外可以考虑使用StopWhenUnneeded=

CodeChenL commented 23 hours ago

如果ExecStartPost能正常用就好了,但是我用的时候启动超时了才会执行

RadxaYuntian commented 23 hours ago

尽量避免自己处理服务信号吧,让systemd统一调配,不然可能会在启动时反复启动udc服务多次

RadxaYuntian commented 23 hours ago

https://superuser.com/questions/849001/why-does-systemd-process-stop-as-soon-as-it-starts-for-foreman-server-process

看看是不是要加一个udc.target?

RadxaYuntian commented 23 hours ago

So the problem is with StopWhenUnneeded= in the main app.target unit. Since you start it manually, it never has any other units depending on it, therefore it will be stopped immediately.

不能手动启动udc服务