chautranthanh
Well-Known Member
Cấp nguồn cho adapter lightning to hdmi bằng em này nghe thua cả Bluetooth !
em chào bác ạ, em muốn vào download mà ko được ạ, bác xem giúp em ạ. thanks bác ạ.Settup lại Ropi rất lâu, tốn time. Vậy nên em làm đồ chơi này cho tiện dùng.
Anh Phước và các bác trữ đồ chơi này về, muốn xài cái nào thì copy file bên trong vào /root rồi chạy dòng lệnh ghi trong đó (bỏ qua các dòng wget ... và dòng có dấu#). https://drive.google.com/file/d/1mTUhwlhEvDd11dgLduti5oCUcravwg7A/view?usp=sharing
Gồm có TC, Aprenderer, Asset, BubbleUpnp, MiniDLNA.
Bản TC này có chỉnh tách thư viện để tránh bị tình trạng update mất UPnP như anh Phước.
Làm 1 bản Ropi update full, rồi ghi ra IMG lưu backup. Sau đó cài các thứ trên sau.
Update#1: Phần bung Java đề chạy BubbleUpnp, cần có lệnh tạo folder trước khi bung java.
mkdir /opt/jvm
Hix mấy cái aplay-rt, rtalsa, xsink khó quá đi. Không biết ông @paparius dùng source code gì nữa. Symphonic-mpd 1.0.10 ổng bỏ bớt xsink rồi. Em suy đoán aplay-rt có thể là cái alsa aplay rồi ổng chế cháo thành aplay-rt; cái rtalsa thì chưa rõ.Hi anh @TuanQuynhAudio @quatmo và cả nhà.
Vậy anh em mình sẽ tìm hiểu thêm về aplay-rt / rtalsa / xsink để áp dụng vào MPD và các loại renderer khác ạ
Trong smpd 0.96 đường đi của output em thấy như sau:
asound.conf:
Mã:pcm.!default{ type plug slave.pcm{ @func getenv vars [ DEFAULT_SAMPLE_FORMAT ] default "PIPE" } } pcm.S16{ type plug slave{ pcm "PIPE" } } pcm.S24{ type plug slave{ pcm "PIPE" format S24 } } pcm.S32{ type plug slave{ pcm "PIPE" format S32 } } pcm.PIPE{ type file slave.pcm null file "|exec /home/pi/misc/pcminfo.sh %f %r %c DEFAULT" format raw }
mpd.conf:
Mã:audio_output { dop "yes" type "pipe" name "pipe" command "exec /home/pi/misc/pcminfo.sh"
pcminfo.sh:
Mã:#!/bin/sh sync pcminfo=/run/pcminfo pipeout=/dev/xsink APP=MPD if [ ! "$4" = "" ];then APP=$4 fi if [ ! "`cat $pcminfo`" = "$1 $2 $3 $APP" ];then echo "$1 $2 $3 $APP"> $pcminfo sudo systemctl restart pipe fi exec cat - > $pipeout exit
pipe.service:
Mã:[Unit] Description=symphonic-mpd pipe service Wants=network-online.target After=sound.target After=network.target network-online.target [Service] EnvironmentFile=/etc/environment Type=simple CPUAffinity=1 CPUSchedulingPolicy=fifo CPUSchedulingPriority=99 LimitRTPRIO=99 LimitMEMLOCK=infinity StartLimitBurst=0 User=root Group=root # none, realtime, best-effort, idle IOSchedulingClass=realtime # 0(highest) - 7(lowest) IOSchedulingPriority=0 ExecStart=/home/pi/configs/pipe.sh exec Restart=always StartLimitInterval=5 [Install] WantedBy=multi-user.target
pipe.sh:
Mã:#!/bin/bash device="hw:0,0" pcminfo=/run/pcminfo opt_aplay="--device=${device} -i ${pcminfo}" case "$1" in exec) if [ ! -e $pcminfo ]; then touch $pcminfo chmod 666 $pcminfo echo "$DEFAULT_SAMPLE_FORMAT 44100 2 DEFAULT" > $pcminfo fi read format rate ch < $pcminfo gravity='$GRAVITY_'$rate eval echo "$gravity" > /proc/xenomai/clock/coreclk exec /usr/local/bin/aplay-rt $opt_aplay ;; esac
Settup lại Ropi rất lâu, tốn time. Vậy nên em làm đồ chơi này cho tiện dùng.
Gồm có TC, Aprenderer, Asset, BubbleUpnp, MiniDLNA.
...
Update#1: Phần cài bung Java đề chạy BubbleUpnp, cần có lệnh tạo folder trước khi bung java.
Mã:mkdir /opt/jvm
Update#2: Trong file aprenderer.service cần thêm dòng này vào để restart lại nó không bị stop.
Mã:ExecStartPre=/bin/sleep 30
mkdir /opt/jvm
ExecStartPre=/bin/sleep 30
Hifiberry OS có phải là thuần Linux ko bác, mình check thì nó ra như vầy:HifiberryOS TC Pi 2 đã hot, âm thanh Ok, các bác download test thử.
- Pi 2, Pi 3 nghe Ok
- Pi 4 nghe Ok (Pi 4 cài thêm Asset, BubbleUpnp, Aprenderer).
https://drive.google.com/drive/folders/1TfxiSkOYkOrCUu5NdG6IVdLSsQArFaPJ?usp=sharing
---
HAT DAC Taobao, âm thanh OK.
driver HifiBerry DAC HiFi pcm5102a-hifi
Pi 4 đang dùng DAC: RPi-DAC HiFi pcm1794a-codec-0 nhưng nó tự nhận thành HifiBerry DAC, mà nghe TC cũng Ok luôn.
Copy từ diyaudio:
1/ fully-directly compatible:
- all HifiBerry cards
- IQaudIO Digi+ (recognised as HB digi)
- Audiophonics Digipi+ AES
Most of the cards with WM8804 or PCM5122 onboard chip should work with HBOS
------------------------------------------------------------------------
Tích hợp TC vào docker HiFiBerry OS - HBOS
#1. Bung IMG HiFiBerryOS vào thẻ, SSH user:root, pass: hifiberry
#2. Làm theo hướng dẫn: bước 1 và 3 bỏ qua bước 2.
#3. Điều chỉnh: đường dẫn WorkingDirectory
File này: /root/tidal-connect-docker/install-hifiberry/systemd/tidal.service
Cho khớp với thư mục giải nén ở bước 1
VD: WorkingDirectory=/root/tidal-connect-docker-master/Docker/
#4 Start TC:
Mã:cd /root/tidal-connect-docker-master/install-hifiberry ./install.sh
Vậy là xong.
PS: Mình nghe sơ sơ âm thanh chưa có vấn đề gì. Với Docker có vẻ ổn. Các bác test chất âm xem sao.
Mình test DAC dùng driver khác xem sao.
login as: root
[email protected]'s password:
# uname -a
Linux hifi4 5.4.83-v7l #1 SMP Wed Feb 3 11:58:50 UTC 2021 armv7l GNU/Linux
# hostnamectl
Static hostname: hifi4
Icon name: computer
Machine ID: bac98229b3b14ac2954
Boot ID: 86afe219261245d5ae13d
Operating System: Buildroot 2020.11
Kernel: Linux 5.4.83-v7l
Architecture: arm
#
# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.36).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/mmcblk0: 29.72 GiB, 31914983424 bytes, 62333952 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc4ab85d9
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 1 131072 131072 64M c W95 FAT32 (LBA)
/dev/mmcblk0p2 131073 6129663 5998591 2.9G 83 Linux
/dev/mmcblk0p4 6131712 15523839 9392128 4.5G 83 Linux
Command (m for help):
Em build librespot hơn 4 tiếng trên pi2. Nhưng vẫn không chạy được với smpd 0.9.6 alsa. Chưa nói gì tới aplay-rt.Hix mấy cái aplay-rt, rtalsa, xsink khó quá đi. Không biết ông @paparius dùng source code gì nữa. Symphonic-mpd 1.0.10 ổng bỏ bớt xsink rồi. Em suy đoán aplay-rt có thể là cái alsa aplay rồi ổng chế cháo thành aplay-rt; cái rtalsa thì chưa rõ.
pi@smpd:~ $ uname -a
Linux smpd 4.14.52-smpd #41 SMP PREEMPT Thu Aug 16 07:48:07 JST 2018 armv7l GNU/Linux
pi@smpd:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
[Unit]
Description=Spotify Connect
After=network-online.target
[Service]
Type=idle
ExecStart=/usr/local/bin/librespot --name symphonic-mpd --initial-volume 100 --onevent /home/pi/configs/spotify_event.sh --cache /run --bitrate 320 --zeroconf-port 4000 --backend pipe --device /run/pipeout &
Restart=always
RestartSec=10
StartLimitInterval=30
StartLimitBurst=20
LimitRTPRIO=99
LimitMEMLOCK=infinity
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=99
CPUAffinity=2
# none, realtime, best-effort, idle
IOSchedulingClass=realtime
# 0(highest) - 7(lowest)
IOSchedulingPriority=0
[Install]
WantedBy=multi-user.target
[Unit]
Description=symphonic-mpd pipe service
Wants=network-online.target
After=sound.target
After=network.target network-online.target
[Service]
Type=simple
#PIDFile=/run/pipe.pid
LimitRTPRIO=99
LimitMEMLOCK=infinity
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=99
CPUAffinity=1
KillMode=mixed
KillSignal=SIGHUP
User=root
Group=root
# none, realtime, best-effort, idle
IOSchedulingClass=realtime
# 0(highest) - 7(lowest)
IOSchedulingPriority=0
#ExecStartPre=/home/pi/configs/pipe.sh pre
ExecStart=/home/pi/configs/pipe.sh exec
#ExecStartPost=/home/pi/configs/pipe.sh post
Restart=always
StartLimitInterval=5
[Install]
WantedBy=multi-user.target
#!/bin/bash
device="hw:0,0" # default
# for Sabreberry32 (DAC MASTER)
if [ $(aplay -l|grep "SabreBerry32 DAC sabre9018q2c"|wc -l) = 1 ];then
device="APLAY_S32_LE"
fi
#prealloc=512
prealloc=1024
period_time=5772
buffer_time=1486940
pipeout=/run/pipeout
pcminfo=/run/pcminfo
timer_calibration="/home/pi/configs/timer_calibration.sh"
opt_aplay="--device=${device} -q -M -F ${period_time} -B ${buffer_time} -p ${pcminfo}"
case "$1" in
exec)
if [ ! -e $pipeout ]; then
mkfifo --mode=666 $pipeout
fi
if [ ! -e $pcminfo ]; then
touch $pcminfo
chmod 666 $pcminfo
echo "S16_LE 44100 2" > $pcminfo
fi
echo $prealloc > /proc/asound/card0/pcm0p/sub0/prealloc
$timer_calibration
exec /usr/local/bin/aplay-rt $opt_aplay $pipeout
;;
esac
Em mò chuyển librespot từ smpd 0.6 sang 0.9.6 xem sao! Hix anh build librespot trên pi2 sao mà lâu thế. Em nghĩ sẽ nhanh thôi mà. Thường build cùng hệ arm 32 bit sẽ chạy được anh à. Vì thế anh build trên pi 2 rồi instal sang pi 2 sẽ nhanh hơn. Lưu ý cùng version raspbian/debian thì độ tương thíc sẽ cao, khác version raspbian/debian có caí vẫn chạy bình thường anh à.Em build librespot hơn 4 tiếng trên pi2. Nhưng vẫn không chạy được với smpd 0.9.6 alsa. Chưa nói gì tới aplay-rt.
Buồn quá em mò lại đống đồ cổ, may quá thấy bản smpd 0.6GA đã có sẵn librespot output pipe aplay-rt.
Test thử SC chạy luôn, không cần phải khai báo user password.
SC out ra pipe aplay-rt tiếng hay hết hồn các anh ạ. Em sẽ úp bản này cho các anh nghiên kiú.
Mã:pi@smpd:~ $ uname -a Linux smpd 4.14.52-smpd #41 SMP PREEMPT Thu Aug 16 07:48:07 JST 2018 armv7l GNU/Linux pi@smpd:~ $ cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
spotify-connect.service
Mã:[Unit] Description=Spotify Connect After=network-online.target [Service] Type=idle ExecStart=/usr/local/bin/librespot --name symphonic-mpd --initial-volume 100 --onevent /home/pi/configs/spotify_event.sh --cache /run --bitrate 320 --zeroconf-port 4000 --backend pipe --device /run/pipeout & Restart=always RestartSec=10 StartLimitInterval=30 StartLimitBurst=20 LimitRTPRIO=99 LimitMEMLOCK=infinity CPUSchedulingPolicy=fifo CPUSchedulingPriority=99 CPUAffinity=2 # none, realtime, best-effort, idle IOSchedulingClass=realtime # 0(highest) - 7(lowest) IOSchedulingPriority=0 [Install] WantedBy=multi-user.target
pipe.service
Mã:[Unit] Description=symphonic-mpd pipe service Wants=network-online.target After=sound.target After=network.target network-online.target [Service] Type=simple #PIDFile=/run/pipe.pid LimitRTPRIO=99 LimitMEMLOCK=infinity CPUSchedulingPolicy=fifo CPUSchedulingPriority=99 CPUAffinity=1 KillMode=mixed KillSignal=SIGHUP User=root Group=root # none, realtime, best-effort, idle IOSchedulingClass=realtime # 0(highest) - 7(lowest) IOSchedulingPriority=0 #ExecStartPre=/home/pi/configs/pipe.sh pre ExecStart=/home/pi/configs/pipe.sh exec #ExecStartPost=/home/pi/configs/pipe.sh post Restart=always StartLimitInterval=5 [Install] WantedBy=multi-user.target
pipe.sh
Mã:#!/bin/bash device="hw:0,0" # default # for Sabreberry32 (DAC MASTER) if [ $(aplay -l|grep "SabreBerry32 DAC sabre9018q2c"|wc -l) = 1 ];then device="APLAY_S32_LE" fi #prealloc=512 prealloc=1024 period_time=5772 buffer_time=1486940 pipeout=/run/pipeout pcminfo=/run/pcminfo timer_calibration="/home/pi/configs/timer_calibration.sh" opt_aplay="--device=${device} -q -M -F ${period_time} -B ${buffer_time} -p ${pcminfo}" case "$1" in exec) if [ ! -e $pipeout ]; then mkfifo --mode=666 $pipeout fi if [ ! -e $pcminfo ]; then touch $pcminfo chmod 666 $pcminfo echo "S16_LE 44100 2" > $pcminfo fi echo $prealloc > /proc/asound/card0/pcm0p/sub0/prealloc $timer_calibration exec /usr/local/bin/aplay-rt $opt_aplay $pipeout ;; esac
Em build bằng cargo anh ạ. Nó chạy gần 4h30pEm mò chuyển librespot từ smpd 0.6 sang 0.9.6 xem sao! Hix anh build librespot trên pi2 sao mà lâu thế. Em nghĩ sẽ nhanh thôi mà. Thường build cùng hệ arm 32 bit sẽ chạy được anh à. Vì thế anh build trên pi 2 rồi instal sang pi 2 sẽ nhanh hơn. Lưu ý cùng version raspbian/debian thì độ tương thíc sẽ cao, khác version raspbian/debian có caí vẫn chạy bình thường anh à.
Copy githubHifiberry OS có phải là thuần Linux ko bác, mình check thì nó ra như vầy:
Minh ko biết cách mở rộng thẻ nhớ có 3 phân vùng như thế này thẻ mình 32Gbs. Hồi truóc giờ chỉ quen mở rộng thẻ nhớ 2 phân vùng.Mã:login as: root [email protected]'s password: # uname -a Linux hifi4 5.4.83-v7l #1 SMP Wed Feb 3 11:58:50 UTC 2021 armv7l GNU/Linux # hostnamectl Static hostname: hifi4 Icon name: computer Machine ID: bac98229b3b14ac2954 Boot ID: 86afe219261245d5ae13d Operating System: Buildroot 2020.11 Kernel: Linux 5.4.83-v7l Architecture: arm #
Tidal coneect đã hót trên Pi4 rồi bác quạt ah.Mã:# fdisk /dev/mmcblk0 Welcome to fdisk (util-linux 2.36). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/mmcblk0: 29.72 GiB, 31914983424 bytes, 62333952 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xc4ab85d9 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 * 1 131072 131072 64M c W95 FAT32 (LBA) /dev/mmcblk0p2 131073 6129663 5998591 2.9G 83 Linux /dev/mmcblk0p4 6131712 15523839 9392128 4.5G 83 Linux Command (m for help):
Bản này quá trời món ăn chơi: Aprenderer, Bubble Upnp server, Openhome có sẵn với Upmpdcli, Roon Brigde, Asset UPNP...
Chỉ còn mở rộng thẻ nhớ, và mount NAS là thưởng thức thôi. (Mình chưa thấy chổ mount NAS vào Hifibery OS)
Many thanks bác đã dày công build OS nhiều món ăn chơi cho anh em.
Mình tìm được cách mount NAS trên web Hifiberry OS như sau:Copy github
HiFiBerryOS is our version of a minimal Linux distribution optimized for audio playback. The goal isn't to add as much functionality as possible, but to keep it small. Therefore, it is based on Buildroot and it's not possible to use package managers to add more software.
HBOS Resize-partitions, bác thử gõ rồi reboot hoặc xem packegae này:
cd ~
touch /resize-me
systemctl start resize-partitions.service
touch/resize-me.2
systemctl start resize-partitions.service
Những thứ còn lại AP, Asset, Bub, Java thì đơn giản là dùng trong gói Ropi Addon bung vào là chạy.
Asset trong bản Pi 4 chưa ke*, các bác bung file db.tar.gz trong gói Ropi addon vào.
@binna
Không có dày công đâu bác, với Pi 4 cần build TC bước 2 tuy nhiên Pi 4 chạy khá nhanh.
nano /etc/smbmounts.conf
name;share;username;password[;options]
NASLossless;//192.168.0.10/music;myuser;mypassword
NASLossless;//192.168.0.10/music;myuser;mypassword;vers=1.0
/opt/hifiberry/bin/mount-smb.sh
Mình tìm được cách mount NAS trên web Hifiberry OS như sau:
SMB SHARES
Mặc dù truy cập nhạc trên NAS thông qua Smaba đã được hỗ trợ, nhưng không thể cấu hình từ WebUI. Để mount NAS, đăng nhập SSH (user: root , pass: hifiberry) và tạo file /etc/smbmounts.conf:
có nội dung:Mã:nano /etc/smbmounts.conf
name: tuỳ mình chọn, ví dụ như sau:Mã:name;share;username;password[;options]
Có thể thêm các tùy chọn mount bổ sung:Mã:NASLossless;//192.168.0.10/music;myuser;mypassword
Lưu lại và thoát file /etc/smbmounts.conf.Mã:NASLossless;//192.168.0.10/music;myuser;mypassword;vers=1.0
Sau đó chạy lệnh:
Sau khi mount xong, HiFiBerryOS sẽ scan library. Tùy thuộc vào kích thước, quá trình này có thể mất từ vài phút đến vài giờ (đối với các thư viện rất lớn). Quá trình này là bắt buộc. Bạn cần phải có một số kiên nhẫn. Nếu quá trình này kết thúc, các bản cập nhật tiếp theo của cơ sở dữ liệu sẽ chỉ quét các tệp mới. Điều này sẽ nhanh hơn nhiều. (google dịch)Mã:/opt/hifiberry/bin/mount-smb.sh
Ko được bác ah,Bác add Nas vậy không add được hả?
time cargo build -j4 -q --no-default-features --features "alsa-backend"
real 6m30.538s
user 11m55.652s
sys 0m23.695s
time cargo build --release -j4 -q --no-default-features --features "alsa-backend"
real 12m39.111s
user 46m10.876s
sys 0m50.135s
Pin vào (+ -) tụ nguồn, bỏ qua phần chỉnh lưu AC trên bo, điện áp ổn định ngay.
Cảm ơn anh Minh @mtminh câu dây, còn nhiệt tình đi mua đồng hồ đo áp lắp vào giùm.
Em về chỉnh lại:
Pin đi ra cầu chì -> công tắc 6 chân (3 nấc) bật sang trái OFF/SẠC, bật giữa OFF, bật phải ON.
Công tắc đi ra 3 cặp dây:
- 1 cấp nguồn bo LT3045x2 1A vào HAT DAC
- 1 cấp nguồn bo LT1764 3A vào Pi, Pi bẻ cong 2 chân 5V ra ngoài không cho nguồn lên HAT DAC.
- 1 cấp nguồn bo LT3042 sang USB Wifi (chưa làm tới Wifi)
Pin mua Nhật Tảo là hàng mới loại không dùng vít, nghe vài hôm mới đánh giá được vụ dung lượng/chất lượng.
Lâu đài Pi 2 Pin LiFePO4 đã hót Ok, cảm ơn các bác nhiệt tình tư vấn và hỗ trợ!
Chúc mừng bác nhé , giờ mà mod clock cho bộ của bác nữa là hết bài !Sau nhiều ngày sử dụng với Pi 2 + HAT DAC + USB WIFI (nguồn rời 5v cho cả 3).
- Pin 32650 LiFePO4 6700mAh x4 sạc 4 tiếng ra 6.5v dung lượng tầm trên 10.000mAh.
- Chạy liên tục 12 tiếng hết pin, áp còn 5.5v. Tự tắt. (đã test qua 2 lượt dùng).
- Chạy Ropi, nhiệt độ CPU luôn bảo trì tầm 40 độ C, có lẽ rất khó đạt như vậy với xài điện thông thường.
Chất lượng/dung lượng Pin Ok đối với mình. Làm thêm một cục để sẵn thay thế là xài thoải mái.
bộ pin này dùng cho Pi 4 được không ta ??Sau nhiều ngày sử dụng với Pi 2 + HAT DAC + USB WIFI (nguồn rời 5v cho cả 3).
- Pin 32650 LiFePO4 6700mAh x4 sạc 4 tiếng ra 6.5v dung lượng tầm trên 10.000mAh.
- Chạy liên tục 12 tiếng hết pin, áp còn 5.5v. Tự tắt. (đã test qua 2 lượt dùng).
- Chạy Ropi, nhiệt độ CPU luôn bảo trì tầm 40 độ C, có lẽ rất khó đạt như vậy với xài điện thông thường.
Chất lượng/dung lượng Pin Ok đối với mình. Làm thêm một cục để sẵn thay thế là xài thoải mái.
Pi 4 ăn dòng lớn bác, chạy tầm 3 tiếng hết pin, chạy Volumio nhiệt độ CPU 58 độ VS Pi 2 Volumio 45 độ.bộ pin này dùng cho Pi 4 được không ta ??
thấy bác review ngon quá ....muốn đu theo ... hihi