Ubuntu 16.04 Raspberry pi가 시작 시 USB 장치를 간헐적으로 연결했다가 영구적으로 연결 해제합니다.

Ubuntu 16.04 Raspberry pi가 시작 시 USB 장치를 간헐적으로 연결했다가 영구적으로 연결 해제합니다.

때때로(약 25%의 경우) Raspberry Pi를 부팅할 때 USB 장치가 작동하지 않습니다. 아래에서 dmesg 출력을 확인하세요. 내 장치가 연결되었다가 1~2초 후에 연결이 끊어진 다음 시스템에서 TTYUSB0, TTYUSB1 및 TTYUSB2 파일도 모두 손실되는 것 같습니다. 이후 부팅에서는 장치가 제대로 바인딩되고 모든 것이 100% 작동하므로 이 문제는 간헐적으로 발생합니다.

이 간헐적인 문제는 시스템 업데이트 및 업그레이드를 수행하고 다음 명령을 실행한 후에 발생하기 시작했습니다. 이 문제의 원인은 무엇입니까?

sudo -Es
systemctl daemon-reload
systemctl disable --now ifupdown dhcpcd dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog
apt --autoremove purge ifupdown dhcpcd dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog
rm -r /etc/network /etc/dhcp
systemctl disable --now avahi-daemon libnss-mdns
apt --autoremove purge avahi-daemon
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
apt install libnss-resolve
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
apt-mark hold avahi-daemon dhcpcd dhcpcd5 ifupdown isc-dhcp-client isc-dhcp-common libnss-mdns openresolv raspberrypi-net-mods rsyslog
systemctl enable systemd-networkd.service systemd-resolved.service
exit

[    4.004167] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    4.099090] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    4.108376] platform regulatory.0: Direct firmware load for regulatory.db failed with erro
[    4.108398] cfg80211: failed to load regulatory.db
[    4.158111] brcmfmac: F1 signature read @0x18000000=0x15264345
[    4.167330] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43455-sdio for chip BCM43
[    4.167769] usbcore: registered new interface driver brcmfmac
[    4.195837] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43455-sdio.raspber
[    4.376882] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43455-sdio for chip BCM43
[    4.396739] rtc-ds1307: probe of 1-006f failed with error -121
[    4.398437] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM4345/6 wl0: Mar  1 2015 07:29:38
[    4.554898] brcmfmac: brcmf_cfg80211_set_power_mgmt: power save enabled
[    4.662995] usbcore: registered new interface driver usbserial_generic
[    4.663037] usbserial: USB Serial support registered for generic
[    4.672106] usbcore: registered new interface driver ftdi_sio
[    4.672120] usbcore: registered new interface driver cp210x
[    4.672160] usbserial: USB Serial support registered for FTDI USB Serial Device
[    4.672206] usbserial: USB Serial support registered for cp210x
[    4.672316] ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected
[    4.672318] cp210x 1-1.3:1.0: cp210x converter detected
[    4.672428] usb 1-1.2: Detected FT232RL
[    4.679334] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
[    4.679537] ftdi_sio 1-1.4:1.0: FTDI USB Serial Device converter detected
[    4.679646] usb 1-1.4: Detected FT232RL
[    4.682651] usb 1-1.3: cp210x converter now attached to ttyUSB1
[    4.683305] usb 1-1.4: FTDI USB Serial Device converter now attached to ttyUSB2
[    4.697841] rpivid-mem feb00000.hevc-decoder: rpivid-hevcmem initialised: Registers at 0xf
[    4.698166] rpivid-mem feb10000.rpivid-local-intc: rpivid-intcmem initialised: Registers a
[    4.698387] rpivid-mem feb20000.h264-decoder: rpivid-h264mem initialised: Registers at 0xf
[    4.699574] rpivid-mem feb30000.vp9-decoder: rpivid-vp9mem initialised: Registers at 0xfeb
[    4.705043] bcmgenet: Skipping UMAC reset
[    4.706545] bcmgenet fd580000.ethernet: configuring instance for external RGMII
[    4.706747] bcmgenet fd580000.ethernet eth0: Link is Down
[    4.960922] random: crng init done
[    4.960936] random: 7 urandom warning(s) missed due to ratelimiting
[    6.113256] usb 1-1.1: USB disconnect, device number 3
[    6.113557] rp-usbdisp 1-1.1:1.0: waiting for all tickets to be finished...
[    6.113785] rp-usbdisp 1-1.1:1.0: RP USB Display (#1) now disconnected
[    6.115705] usb 1-1.2: USB disconnect, device number 4
[    6.116286] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUS
[    6.116345] ftdi_sio 1-1.2:1.0: device disconnected
[    6.117190] usb 1-1.3: USB disconnect, device number 5
[    6.117575] cp210x ttyUSB1: cp210x converter now disconnected from ttyUSB1
[    6.117633] cp210x 1-1.3:1.0: device disconnected
[    6.118441] usb 1-1.4: USB disconnect, device number 6
[    6.118994] ftdi_sio ttyUSB2: FTDI USB Serial Device converter now disconnected from ttyUS
[    6.119050] ftdi_sio 1-1.4:1.0: device disconnected
[    7.463926] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    9.930297] bcmgenet fd580000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[    9.930327] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   10.867743] bridge: filtering via arp/ip/ip6tables is no longer available by default. Upda
[   10.871278] Bridge firewalling registered
[   11.261788] ------------[ cut here ]------------
[   11.261933] WARNING: CPU: 1 PID: 65 at net/wireless/sme.c:756 __cfg80211_connect_result+0x
[   11.261938] Modules linked in: nf_conntrack_netlink nfnetlink xt_addrtype iptable_filter iashfs overlay binfmt_misc rpivid_mem cp210x ftdi_sio usbserial rtc_ds1307 regmap_i2c brcmfmac_midi snd_seq_midi_event bcm2835_codec(C) v4l2_mem2mem videobuf2_dma_contig snd_rawmidi raspbuio evdev joydev bcm2835_v4l2(C) bcm2835_mmal_vchiq(C) vc_sm_cma(C) videobuf2_vmalloc videobuysimgblt fb_sys_fops ipv6 nf_defrag_ipv6
[   11.262054] CPU: 1 PID: 65 Comm: kworker/u8:1 Tainted: G         C O      5.4.51-v7l+ #133
[   11.262057] Hardware name: BCM2711
[   11.262129] Workqueue: cfg80211 cfg80211_event_work [cfg80211]
[   11.262133] Backtrace:
[   11.262146] [<c020d46c>] (dump_backtrace) from [<c020d768>] (show_stack+0x20/0x24)
[   11.262151]  r6:ef294000 r5:00000000 r4:c129c8f8 r3:ad07bc4f
[   11.262160] [<c020d748>] (show_stack) from [<c0a39a44>] (dump_stack+0xe0/0x124)
[   11.262169] [<c0a39964>] (dump_stack) from [<c0221c70>] (__warn+0xec/0x104)
[   11.262174]  r8:000002f4 r7:00000009 r6:bf28c168 r5:00000000 r4:00000000 r3:ad07bc4f
[   11.262180] [<c0221b84>] (__warn) from [<c0221d40>] (warn_slowpath_fmt+0xb8/0xc0)
[   11.262185]  r9:bf28c168 r8:000002f4 r7:bf260d00 r6:00000009 r5:00000000 r4:c1204f88
[   11.262254] [<c0221c8c>] (warn_slowpath_fmt) from [<bf260d00>] (__cfg80211_connect_result+
[   11.262259]  r9:00000122 r8:ef295e54 r7:c1204f88 r6:00000000 r5:dffa840c r4:dffc5004
[   11.262389] [<bf2608c4>] (__cfg80211_connect_result [cfg80211]) from [<bf22cb0c>] (cfg8021
[   11.262394]  r8:dffc5090 r7:dffc5028 r6:dffc5098 r5:dffc5004 r4:dffa8400
[   11.262523] [<bf22ca08>] (cfg80211_process_wdev_events [cfg80211]) from [<bf22cba8>] (cfg8
[   11.262529]  r10:00000000 r9:00000100 r8:00000000 r7:dfe17600 r6:ef846400 r5:df60c470
[   11.262532]  r4:dffc5004
[   11.262659] [<bf22cb68>] (cfg80211_process_rdev_events [cfg80211]) from [<bf2261b8>] (cfg8
[   11.262663]  r5:ef977100 r4:df60c0e4
[   11.262732] [<bf226194>] (cfg80211_event_work [cfg80211]) from [<c023e244>] (process_one_w
[   11.262736]  r4:df60c0e4 r3:bf226194
[   11.262742] [<c023e0c8>] (process_one_work) from [<c023eaac>] (worker_thread+0x54/0x5b4)
[   11.262747]  r10:ef977100 r9:ef294038 r8:c1203d00 r7:ef846418 r6:00000088 r5:ef977114
[   11.262751]  r4:ef846400
[   11.262757] [<c023ea58>] (worker_thread) from [<c0244e90>] (kthread+0x13c/0x168)
[   11.262762]  r10:efa174dc r9:ef901e74 r8:c023ea58 r7:ef977100 r6:00000000 r5:ef974200
[   11.262765]  r4:efa174c0
[   11.262771] [<c0244d54>] (kthread) from [<c02010ac>] (ret_from_fork+0x14/0x28)
[   11.262775] Exception stack(0xef295fb0 to 0xef295ff8)
[   11.262779] 5fa0:                                     00000000 00000000 00000000 00000000
[   11.262784] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[   11.262789] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[   11.262793]  r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c0244d54
[   11.262797]  r4:ef974200 r3:c0204648
[   11.262814] ---[ end trace 18f9f282ca963cc4 ]---
[   11.483205] netlink: 'wpa_supplicant': attribute type 213 has an invalid length.
[   11.608570] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   30.602006] Bluetooth: Core ver 2.22
[   30.602064] NET: Registered protocol family 31
[   30.602072] Bluetooth: HCI device and connection manager initialized
[   30.602091] Bluetooth: HCI socket layer initialized
[   30.602103] Bluetooth: L2CAP socket layer initialized
[   30.602122] Bluetooth: SCO socket layer initialized
[   30.609018] Bluetooth: HCI UART driver ver 2.3
[   30.609029] Bluetooth: HCI UART protocol H4 registered
[   30.609088] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   30.609284] Bluetooth: HCI UART protocol Broadcom registered
[   30.694773] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   30.694783] Bluetooth: BNEP filters: protocol multicast
[   30.694800] Bluetooth: BNEP socket layer initialized
[  128.811552] TCP: request_sock_TCP: Possible SYN flooding on port 38663. Sending cookies.
[  268.653076] TCP: request_sock_TCP: Possible SYN flooding on port 39569. Sending cookies.
[  314.270766] ieee80211 phy0: brcmf_vif_set_mgmt_ie: vndr ie set error : -52
[  314.271326] ieee80211 phy0: brcmf_vif_set_mgmt_ie: vndr ie set error : -52
[  314.271935] ieee80211 phy0: brcmf_vif_set_mgmt_ie: vndr ie set error : -52
[  315.693723] TCP: request_sock_TCP: Possible SYN flooding on port 34855. Sending cookies.
[  501.855600] TCP: request_sock_TCP: Possible SYN flooding on port 45579. Sending cookies.
ubuntu@subaero-CYEG-002:~$ ^C
ubuntu@subaero-CYEG-002:~$ dmesg | grep wpa
[   11.262180] [<c0221b84>] (__warn) from [<c0221d40>] (warn_slowpath_fmt+0xb8/0xc0)
[   11.262254] [<c0221c8c>] (warn_slowpath_fmt) from [<bf260d00>] (__cfg80211_connect_result+0x43c/0x4e8 [cfg80211])
[   11.483205] netlink: 'wpa_supplicant': attribute type 213 has an invalid length.

답변1

업다운된 경우, 보다 구체적으로 network.service를 비활성화하면 부팅 후 USB 장치의 연결이 끊어지고(매번은 아니지만, 약 25-50%의 경우) udev 링크가 사라집니다. Networking.service는 시작 시 udevadm 세트를 실행하는 유일한 활성화된 서비스이기 때문에 이를 제거하면 시작 시 다른 프로세스에 의해 udev 인스턴스가 압축될 수 있습니다.

network.service를 비활성화하고 ifupdown 패키지를 제거/정리하려는 경우 시작 중에 활성화되고 올바른 시간에 실행되는 "한 번 수행" 서비스를 생성하면 문제를 해결할 수 있습니다.

/lib/systemd/system에 udevadm-settle-dummy.service라는 서비스를 만듭니다.

위 파일의 서비스는 다음과 같아야 합니다.

[Unit]
Description=run udevadm settle
DefaultDependencies=no
Wants=network.target
After=local-fs.target network-pre.target apparmor.service systemd-sysctl.servic$
Before=network.target shutdown.target network-online.target
Conflicts=shutdown.target

[Install]
WantedBy=multi-user.target
WantedBy=network-online.target

[Service]
Type=oneshot
ExecStartPre=/sbin/udevadm settle
ExecStart=/sbin/udevadm settle
RemainAfterExit=true
TimeoutStartSec=5min

/lib/systemd/system에서 다음 명령을 실행합니다.

sudo chmod 777 udevadm-settle-dummy.service
sudo systemctl daemon-reload
sudo systemctl enable udevadm-settle-dummy.service

관련 정보