2024年4月17日 星期三
[RPi] 在 Bookworm 使用 ReSpeaker
現在升級到 Bookworm(2024-03-15 Bookworm 64),原本使用好心人 HinTak 的也不能用,但還好討論區裡面有講解法。
```
cd ~
sudo rpi-update 1440b3e0b52075a9ec244216cddcf56099c28dfa
git clone https://github.com/HinTak/seeed-voicecard
cd seeed-voicecard
git checkout v6.6
sudo ./install.sh
sudo sync; sudo reboot
wget https://raw.githubusercontent.com/ubopod/ubo-sdk/main/system/setup/install_wm8960.sh
sudo bash install_wm8960.sh
sudo sync; sudo reboot
```
https://github.com/HinTak/seeed-voicecard/issues/28
https://github.com/HinTak/seeed-voicecard/issues/31
> I don't know why...
2023年11月9日 星期四
[RPi] 在 Bullseye 和 Buster 使用 ReSpeaker
多年前 seeed 自己維護,但目前只有更新到 2021(Buster)
https://github.com/respeaker/seeed-voicecard
後來有人看不下去,修改了核心驅動,並且持續維護,然後就被 fork 了
https://github.com/seeed-studio-projects/seeed-voicecard
因此之前我在 Buster 可以修改預設的音效卡,在 Bullseye 不行了
PulseAudio Sound Server
$ pactl set-default-sink 1 # 1是3.5mm Audio Jack $ pactl set-default-sink 2 # 2是ReSpeaker
最後使用 HinTak 的,一切解決!https://github.com/HinTak/seeed-voicecard
2023年4月14日 星期五
[RPi] no authorized to perform operation
爬文後,發現是 udisks daemon security policy 造成的。步驟是修改 /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy。
===
<!-- Mounting filesystems -->
<action id="org.freedesktop.udisks2.filesystem-mount">
<description>Mount a filesystem</description>
...
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
===
改為
===
<!-- Mounting filesystems -->
<action id="org.freedesktop.udisks2.filesystem-mount">
<description>Mount a filesystem</description>
...
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
===
修改後不用重啟任何服務,直接再做一次就 OK 了
2023年4月12日 星期三
[RPi] cannot currently show the desktop
1. 設定桌面登入。sudo raspi-config > 1 System Options > S5 Boot / Auto Login > B4 Desktop Autologin
2. 重新安裝 LXsession 程式,sudo apt-get install --reinstall libgtk2.0-0 && sudo apt-get install --reinstall lxsession
3. 正確設對桌面解析度(例如 800x600)。/boot/config.txt
===
hdmi_force_hotplug=1
framebuffer_width=800
framebuffer_height=600
hdmi_group=2
hdmi_mode=9
===
4. 正確設對 VNC 解析度(例如 800x600)。sudo raspi-config > 2 Display Options > D5 VNC Resolution > 800x600
5. 設定正確螢幕解析度。sudo raspi-config > 2 Display Options > D1 Resolution > DMT Mode 9 800x600 60Hz 4:3 (2022-01 以後預設不出現/不適用)
最後找了半天,比較了正常的和不正常的設定,包括 /etc/vnc 和 /etc/X11 下面的所有檔案和目錄,看不出差異。
又參考這篇翻了 /var/log/vncserver-x11.log 和 sudo systemctl status vncserver-x11-serviced.service 服務狀態,發現雖然服務有啟動,但是出現 "AgentInitCheck: agent comms failure" 錯誤訊息,實際上 vncserver-x11 沒有正常啟動。
最後找到這篇,雖然解法不正確,但有提供方向 ==>
The "direct capture" option is not working when running VNC Server on Raspberry Pi OS with the KMS driver (vc4-kms-v3d). The Fake KMS driver (vc4-fkms-v3d) is not affected.
簡單說,把 /boot/config.txt 裡面的 dtoverlay=vc4-kms-v3d 註解掉,重開機後收工!
參考:
* How to Fix Raspberry Pi's 'Cannot Currently Show the Desktop' Error
* Disabling direct capture on Raspberry Pi using the command line
2021年12月29日 星期三
[RPi] 無中生有的 /dev/input/js0
今天在測試 Donkey Car 的搖桿,發現插上 2.4GHz 接收器竟然會變成 /dev/input/js1
因此 python3 manage.py drive --js 就讀不到搖桿資訊了,因為預設會使用 /dev/input/js0
還好這篇文章給了一些線索,可以使用 udevadm 指令去觀察這些裝置節點。
觀察結果如下。
$ sudo udevadm info /dev/input/js0
```
P: /devices/virtual/input/input4/js0
N: input/js0
L: 0
E: DEVPATH=/devices/virtual/input/input4/js0
E: DEVNAME=/dev/input/js0
E: MAJOR=13
E: MINOR=0
E: SUBSYSTEM=input
E: USEC_INITIALIZED=33222115
E: ID_INPUT=1
E: ID_INPUT_MOUSE=1
E: ID_SERIAL=noserial
```
$ sudo udevadm test-builtin input_id /class/input/js0
```
Load module index
Skipping empty file: /etc/systemd/network/99-default.link
Created link configuration context.
ID_INPUT=1
ID_INPUT_MOUSE=1
Unload module index
Unloaded link configuration context.
```
不過最有收穫的竟然還是使用 jstest 去測試
jstest /dev/input/js0
```
Driver version is 2.1.0.
Joystick (vnc-abspointer) has 2 axes (X, Y)
and 3 buttons (LeftBtn, RightBtn, MiddleBtn).
Testing ... (interrupt to exit)
Axes: 0:-32767 1:-32767 Buttons: 0:off 1:off 2:off
```
發現這 Joystick 是 vnc-abspointer,也就是因為啟動 VNC Server 之後跑出來的...
因此解決方法有三個。
1. 不要開啟 VNC Server。
2. 修改 donkeypart_ps3_controller/donkeypart_ps3_controller/part.py
把所有 /dev/input/js0 改為 /dev/input/js1 之後重新安裝。
3. 最簡單,把接收器插在 Pi 上以後重開機,HID 裝置會比 vnc-abspointer 早載入,因此會拿到 js0
2021年12月13日 星期一
[RPi] 控制伺服馬達
對於 Pi 控制伺服馬達,這兩篇寫的很清楚
* Raspberry Pi Servo Motor Control,範例 ==> 使用 RPi.GPIO
* Raspberry Pi PWM and Servo Motor Tutorial ==> RPi.GPIO 的 PWM 到 pigpio 範例
2021年9月15日 星期三
[RPi] sudo apt-get update 更新
今天拿到一張舊的 SD 卡,用的 image 是
```
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.97-v7+ #1294 SMP Thu Jan 30 13:15:58 GMT 2020 armv7l GNU/Linux
```
想要更新卻出現這樣的錯誤訊息
```
Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelease' changed its 'Suite' value from 'stable' to 'oldstable'
```
這樣更新之後就沒問題了
```
sudo apt-get update --allow-releaseinfo-change
```
2021年7月29日 星期四
[RPi] Pi 3 網路設定維修
最近拿到一片 Pi 3 網路有問題。設定 static ip 可以,但 dhcp 不行。
看到 ethtool 這指令,搭配這篇文章試了一下,原理可以參考這裡。
原本的設定
$ sudo ethtool eth0 Settings for eth0: Supported ports: [ TP MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Advertised pause frame use: Symmetric Receive-only Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Link partner advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Link partner advertised pause frame use: Symmetric Receive-only Link partner advertised auto-negotiation: Yes Link partner advertised FEC modes: Not reported Speed: 100Mb/s Duplex: Full Port: MII PHYAD: 1 Transceiver: internal Auto-negotiation: on Supports Wake-on: pumbag Wake-on: d Current message level: 0x00000007 (7) drv probe link Link detected: yes $ ifconfig eth0 eth0: flags=4163mtu 1500
改成 speed 10 之後,竟然可以 dhcp 了~
$ sudo ethtool -s eth0 autoneg on speed 10 duplex full測試結果
$ sudo ethtool eth0 Settings for eth0: Supported ports: [ TP MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: 10baseT/Full Advertised pause frame use: Symmetric Receive-only Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Link partner advertised link modes: 10baseT/Full Link partner advertised pause frame use: Symmetric Receive-only Link partner advertised auto-negotiation: Yes Link partner advertised FEC modes: Not reported Speed: 10Mb/s Duplex: Full Port: MII PHYAD: 1 Transceiver: internal Auto-negotiation: on Supports Wake-on: pumbag Wake-on: d Current message level: 0x00000007 (7) drv probe link Link detected: yes $ ifconfig eth0 eth0: flags=4163將 eth0 重新設定mtu 1500 inet 192.168.1.129 netmask 255.255.255.0 broadcast 192.168.1.255 ...
$ sudo ethtool -r eth0
2021年5月3日 星期一
2021年3月16日 星期二
2021年1月21日 星期四
[RPi] SpiDev Documentation
SpiDev Documentation
https://www.sigmdel.ca/michel/ha/rpi/dnld/draft_spidev_doc.pdf
2021年1月19日 星期二
[RPi] Serial Peripheral Interface on the Raspberry Pi
https://sigmdel.ca/michel/ha/rpi/spi_on_pi_en.html
[RPi] Modern Maker : 從那些 Maker 的大小事看 Linux 核心
2020年12月9日 星期三
[RPi] MTBF
但是有個測試小工具可以讓 CPU 的四核心跑到滿
wget https://raw.githubusercontent.com/ssvb/cpuburn-arm/master/cpuburn-a53.S gcc -o cpuburn-a53 cpuburn-a53.S ./cpuburn-a53
來源
2020年11月26日 星期四
[RPi] donkeypart_ps3_controller
最近在弄 Donkey Car 的搖桿按鍵,需要讀按鍵值。
作法大概是這樣。
1. 使用 evdev 讀取搖桿資訊。
>>> import evdev >>> device = evdev.InputDevice('/dev/input/event0') >>> print(device) >>> device.capabilities() >>> device.capabilities(verbose=True) {('EV_SYN', 0): [('SYN_REPORT', 0), ('SYN_CONFIG', 1), ('SYN_DROPPED', 3), ('?', 4)], ('EV_KEY', 1): [(['BTN_A', 'BTN_GAMEPAD', 'BTN_SOUTH'], 304), (['BTN_B', 'BTN_EAST'], 305), ('BTN_C', 306), (['BTN_NORTH', 'BTN_X'], 307), (['BTN_WEST', 'BTN_Y'], 308), ('BTN_Z', 309), ('BTN_TL', 310), ('BTN_TR', 311), ('BTN_TL2', 312), ('BTN_TR2', 313), ('BTN_SELECT', 314), ('BTN_START', 315), ('BTN_MODE', 316)], ('EV_ABS', 3): [(('ABS_X', 0), AbsInfo(value=128, min=0, max=255, fuzz=0, flat=15, resolution=0)), (('ABS_Y', 1), AbsInfo(value=128, min=0, max=255, fuzz=0, flat=15, resolution=0)), (('ABS_Z', 2), AbsInfo(value=128, min=0, max=255, fuzz=0, flat=15, resolution=0)), (('ABS_RZ', 5), AbsInfo(value=128, min=0, max=255, fuzz=0, flat=15, resolution=0)), (('ABS_HAT0X', 16), AbsInfo(value=0, min=-1, max=1, fuzz=0, flat=0, resolution=0)), (('ABS_HAT0Y', 17), AbsInfo(value=0, min=-1, max=1, fuzz=0, flat=0, resolution=0))], ('EV_MSC', 4): [('MSC_SCAN', 4)]}
2. 將讀出來的資訊轉成 16 進位。
self.button_names = { 0x13a: 'select', # 8 314 0x13b: 'start', # 9 315 0x13c: 'PS', # a 316 }
3. 修改 donkeypart_ps3_controller 裡面的 part 即可。
#import evdev from evdev import InputDevice, categorize, ecodes #cree un objet gamepad | creates object gamepad gamepad = InputDevice('/dev/input/event2') #affiche la liste des device connectes | prints out device info at start print(gamepad) #affiche les codes interceptes | display codes for event in gamepad.read_loop(): #Boutons | buttons if event.type == ecodes.EV_KEY: print(event) #Gamepad analogique | Analog gamepad elif event.type == ecodes.EV_ABS: absevent = categorize(event) print ecodes.bytype[absevent.event.type][absevent.event.code], absevent.event.value使用 evdev 更容易。
import evdev device = evdev.InputDevice('/dev/input/event1') print(device) for event in device.read_loop(): if event.type == evdev.ecodes.EV_KEY: print(evdev.categorize(event))找到一篇最棒的,可以直接使用 evtest 讀取搖桿資訊。
2020年11月5日 星期四
[RPI] config.txt
今天測試某螢幕,使用 hdmi_safe=1 可以顯示,但修改了其他就不顯示。
看了官方說明, 內容是這樣的。
===
hdmi_force_hotplug=1
hdmi_ignore_edid=0xa5000080
config_hdmi_boost=4
hdmi_group=2
hdmi_mode=4
disable_overscan=0
overscan_left=24
overscan_right=24
overscan_top=24
overscan_bottom=24
===
hdmi_ignore_edid=0xa5000080 這個參數之前沒用過,這篇是這樣說的。
hdmi_ignore_edid 如果你的顯示器是天朝產的垃圾貨, 允許系統忽略EDID顯示數據
2020年10月15日 星期四
[RPi] X11 connection rejected because of wrong authentication.
如果使用 X11 forwarding 出現這樣的錯誤。
```
X11 connection rejected because of wrong authentication.
option parsing failed: Cannot open display:
```
然後移除並重新安裝 openssh-server,或是移除 .Xauthority 也沒用。
並且也試過以下這招。
https://www.raspberrypi.org/forums/viewtopic.php?t=267344
有可能是磁碟空間滿了,寫不進去檔案了...