SamEureka / balenaPhono

balenaPhono is a project for Raspberry Pi that takes the audio output from a turntable or any other audio device and creates a shoutcast/icecast network stream. This project is great for anyone looking for a cheap and simple way to play vinyl on Sonos speakers.
23 stars 1 forks source link

Another question about booting... #5

Closed Richardrsb closed 9 months ago

Richardrsb commented 1 year ago

I use this repo for streaming a radio station to Symphonisk speakers at my office. This way i don't have the increasing lag during the day which can increase to an hour or longer. The internet stream inserts commercials while pausing the stream.

I got a cheap DAB+ receiver from Ali, and stream this to my local network using balenaphono, so it is working 16 hours/day.

Now the systems boots every day which is ok, but i would prefer it boots at a fixed time. Say 04:00 every night. Is this possible? I am not sure the Pi "knows" the current time. I am not to familiar with coding the Pi.... If this is not possible, i will use hardware to get the Pi re-booting at a certain time.

Thanks for this outstanding code. I love it!

Richard

SamEureka commented 1 year ago

Hello Richard!

Glad you found balenaPhono useful and I apologize for the delay. I haven't been on github in a couple weeks.

About the balenaBooter code... it isn't very good and I've been thinking about rewriting the whole thing for a while. The way it works now is that you set the REBOOT_SLEEP_TIME variable and it will sleep for that duration. Then it will send the 'restart' signal to the balena supervisor. It might be better if I used the cron instead. Then you could set a specific time for the reboot.

One way to make it reboot at a specific time of day is to power it on at the desired reboot time. Then it will reboot 24 hours from that time.

I will also look at rewriting the booter. I'll let you know in this issue when I have something for you to test.

Regards, //Sam

Richardrsb commented 1 year ago

Thanks. Meanwhile i will cut the power @ 04:00AM for a minute. It runs for two weeks now. I increased the reboot time to 2 day's, but it seems to get unreliable if you let it running for more than 24 hrs. Using it the way i use it is a breeze. No lagging, no inserted commercials, and no cutoffs if the internet is interrupted.

SamEureka commented 1 year ago

@Richardrsb I've updated the main branch with a couple changes. The rebooter uses the cron now and with a new variable named REBOOT_TIME you can specify the time you want it to reboot. It will default to 4am PST without any changes.

Let me know if this works for you!

Regards, //Sam

Richardrsb commented 1 year ago

Hi Sam, Thanks. I'll try it, let it run for a week or so and let you know how it goes!

Richardrsb commented 1 year ago

Hi Sam, It runs fine, but i found the Pi ZeroW is use is very unreliable. I got an OrangePi one H3 and another sound card. I got a Ezcap216 based sound capture device, but the software on the Orange does not recognize it. It keeps telling me: "Waiting for USB sound device". Is there any chance we can get this to work with this audio card?

I noticed the Orange does not recognize ANY sound card, but the Raspberry does recognize both...

Meanwhile it runs like a charm, besides the ZeroW crashing at higher temperatures. (Its a hardware issue...)

Thanks,

Richard

SamEureka commented 1 year ago

Hmm... I'm not sure what audio devices the OrangePi has or supports I've never used one. There are a couple things we can try though.

Add a 'device variable' in balena-cloud dashboard called DARKICE_DEVICE and for the value try each of these until something works!

If it is an ALSA audio device we can narrow it down a little by opening a terminal in the balenaPhono service in the balena-cloud dashboard. Enter the command aplay -l it will return output that lists Playback devices. Look for card X: CODEC [USB AUDIO CODEC], device X: USB Audio [USB Audio] The 'X's will be numbers corresponding to the devices. Mine for example is 'card 0, device 0' so my plughw is 'plughw:0,0' My old capture card was 1,1. If you have more than one or are pluging into a different usb port... I think it can change. Not 100% sure though. I have not had to explore past getting mine working. 😉 (if these words are confusing or you are not sure what I'm referring to in the balena dashboard, I can post some screenshots to help illustrate the instructs. Let me know)

Regards, //Sam

SamEureka commented 1 year ago

Adding DARKICE_DEVICE variable:

device_variable

Output of aplay -l command:

aplay_-l

SamEureka commented 1 year ago

I was looking in the wrong area of the code. It's the code at line 19 in start.sh that is messing you up. Let me look at how we can do this better. My shell scripting skills have improved slightly since I wrote this code.

//Sam

Richardrsb commented 1 year ago

aplay -l returns me "no soundcards found" If i connect the soundcard, the LED blinks a few times, and then stays solid, suggesting it has a working data connection with the hardware.

Can i give you access to this device?

SamEureka commented 1 year ago

I think the only way to give me access would be to add me as a member of your balena organization. I know the balena people have a support mode but I don't have access to that function. If you want to do that my user name is sdennon. Then you would create a team and give me access to the specific fleet.

If you don't want to do all that I will help best I can through messages here 👍🏻

Also, Ezcap216 based capture cards are not sound devices so they won't show up in /proc/asound. It won't work with Darkice that I know of.

//Sam

Richardrsb commented 1 year ago

Sam,

I added you as admin to my organisation. Both units are online. The BalenaPhono is the Raspberry Pi Zero W, currently in use, and the Orange is on my desk connected to the Ezcap216 and Ethernet. The Ezcap216 is working on the Raspberry, although i need to test that again to be sure. I will report that sunday afternoon.

The raspberry is crashing randomly giving me 4 long flashes, which tells me there is a communication problem to the SD card. I cannot find any issue, that is why i got myself an Orange Pi.

I use this setup to stream Q-Music locally over my network to iKea symfonisks all over the place. I use a cheap DAB receiver from Ali with excellent stereo audio, and stream this. Advantage is i don’t have to use Tune-in who randomly inserts commercials, and giving me an increasing lag during the day. Q-music is running here from 07:00 till 23:00 as background music in my office, kitchen, and terrace.

Thanks for this excellent solution! I hop my setup helps to make it even better!

Let me know if i need to do something. Change audio cards or whatever. Use Whatsapp, iMessage, Telegram, or email. Whatever suits you. I will repond if possible, and help with this development. phone is +XX-XXXXXXXXX

Regards, Richard

Richardrsb commented 1 year ago

Ezcap216 is indeed not working. I'll get another stereo input device SS16295 based, which will work, and i report back later.

SamEureka commented 1 year ago

Nice, I can see your balenaPhono devices in my dashboard now. I can confirm there is a sound device on the raspberry but not on the orange. We can continue troubleshooting when you get the new sound device. Hopefully you will plug it in and it will just work! If not we can create a special build for your Orange-pi once we get it working.

I copied down your contact info and removed it from your comment.

//Sam

Richardrsb commented 1 year ago

Sam,

Thanks. I will remove the sound device from the W, and connect it to the orange now.

Consider it done. It should be there.

-- Richard Rosenberger

Mobile Techcenter vof Toepadweg 33 5301 KA Zaltbommel +31-418-511296 http://www.mobiletechcenter.nl @. @.>KvK: 30177799 BTW/VAT: NL8105.84.712.B01 EORI: NL810584712

On 8 May 2023, at 15:40, Sam Dennon @.***> wrote:

Nice, I can see your balenaPhono devices in my dashboard now. I can confirm there is a sound device on the raspberry but not on the orange. We can continue troubleshooting when you get the new sound device. Hopefully you will plug it in and it will just work! If not we can create a special build for your Orange-pi once we get it working.

I copied down your contact info and removed it from your comment.

//Sam

— Reply to this email directly, view it on GitHub https://github.com/SamEureka/balenaPhono/issues/5#issuecomment-1538380539, or unsubscribe https://github.com/notifications/unsubscribe-auth/A52WP5BUAULRNLDUD7CK2RLXFDZV7ANCNFSM6AAAAAAUYWRBTY. You are receiving this because you were mentioned.

SamEureka commented 1 year ago

Strange the orange doesn't see any USB devices plugged in. I'll do some digging into that also. Do you have any random usb device we can plug-in to see if USB is working at all?

root@853b875:/proc/asound# lsusb
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

//Sam

Richardrsb commented 1 year ago

I just inserted an FSC Pro + receiver stick. On the USB-A port though The soundcard from the W is still connected to the mini USB port. (which IS USB, not power).

-- Richard Rosenberger

Mobile Techcenter vof Toepadweg 33 5301 KA Zaltbommel +31-418-511296 http://www.mobiletechcenter.nl @. @.>KvK: 30177799 BTW/VAT: NL8105.84.712.B01 EORI: NL810584712

On 8 May 2023, at 16:22, Sam Dennon @.***> wrote:

Strange the orange doesn't see any USB devices plugged in. I'll do some digging into that also. Do you have any random usb device we can plug-in to see if USB is working at all?

@.***:/proc/asound# lsusb Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub //Sam

— Reply to this email directly, view it on GitHub https://github.com/SamEureka/balenaPhono/issues/5#issuecomment-1538448900, or unsubscribe https://github.com/notifications/unsubscribe-auth/A52WP5ARZJP6FG3YK6OLKRTXFD6TRANCNFSM6AAAAAAUYWRBTY. You are receiving this because you were mentioned.

SamEureka commented 1 year ago

Well... usb works. I wonder why it isn't seeing your sound device. ☹️

root@853b875:/proc/asound# lsusb
Bus 004 Device 003: ID 04d8:fb31 Microchip Technology, Inc. FUNcube Dongle V2.0  
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
SamEureka commented 1 year ago

I have had trouble with usb 2.0 OTG mini ports and software defined radio dongles before. Have you tried plugging into the A port? I see on the Orange Pi One spec that the OTG mini port is data only and should work...

Richardrsb commented 1 year ago

Sam,

Just hooked the sound card up to the A port. The micro USB is now free

-- Richard Rosenberger

Mobile Techcenter vof Toepadweg 33 5301 KA Zaltbommel +31-418-511296 http://www.mobiletechcenter.nl @. @.>KvK: 30177799 BTW/VAT: NL8105.84.712.B01 EORI: NL810584712

On 8 May 2023, at 17:13, Sam Dennon @.***> wrote:

I have had trouble with usb 2.0 OTG mini ports and software defined radio dongles before. Have you tried plugging into the A port? I see on the Orange Pi One spec that the OTG mini port is data only and should work...

— Reply to this email directly, view it on GitHub https://github.com/SamEureka/balenaPhono/issues/5#issuecomment-1538534804, or unsubscribe https://github.com/notifications/unsubscribe-auth/A52WP5CDN22FMJFJERPPZTDXFEEQBANCNFSM6AAAAAAUYWRBTY. You are receiving this because you were mentioned.

SamEureka commented 1 year ago

I can see the USB device now.

root@853b875:~# lsusb
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0d8c:0102 C-Media Electronics, Inc. CM106 Like Sound Device
...

But no sound cards 💣

root@853b875:/balenaPhono# cat /proc/asound/cards
--- no soundcards ---

If you don't mind leaving the sound card plugged into the A port, I'm going to try pushing a build that has pulseaudio installed. Some of the audio problem posts I've seen recommend installing it to fix issues. Some issues about hdmi audio taking over but I don't even see an hdmi audio device installed. So that might be an issue also. I'm wondering if the balena image for Orange Pi One is missing some audio components in the kernel. I have some free time today to spend on it. I'll update here. Kinda cool that I can work on your device from California. BalenaCloud makes it so easy!

//Sam

Richardrsb commented 1 year ago

Sam,

I leave it running until i hear form you. No Problem. There is a HDMI on the Orange. Not connected though.

Amazing times it sure is! I hope you can make this even more usable on more devices. I have another Orange device, so we can test that to! I believe it is an Orange Pi 4 LTS

But first things first!

Regards,

-- Richard Rosenberger

Mobile Techcenter vof Toepadweg 33 5301 KA Zaltbommel +31-418-511296 http://www.mobiletechcenter.nl @. @.>KvK: 30177799 BTW/VAT: NL8105.84.712.B01 EORI: NL810584712

On 8 May 2023, at 17:37, Sam Dennon @.***> wrote:

I can see the USB device now.

@.***:~# lsusb Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 002: ID 0d8c:0102 C-Media Electronics, Inc. CM106 Like Sound Device ... But no sound cards 💣

@.***:/balenaPhono# cat /proc/asound/cards --- no soundcards --- If you don't mind leaving the sound card plugged into the A port, I'm going to try pushing a build that has pulseaudio installed. Some of the audio problem posts I've seen recommend installing it to fix issues. Some issues about hdmi audio taking over but I don't even see an hdmi audio device installed. So that might be an issue also. I'm wondering if the balena image for Orange Pi One is missing some audio components in the kernel. I have some free time today to spend on it. I'll update here. Kinda cool that I can work on your device from California. BalenaCloud makes it so easy!

//Sam I'm going to push

— Reply to this email directly, view it on GitHub https://github.com/SamEureka/balenaPhono/issues/5#issuecomment-1538595815, or unsubscribe https://github.com/notifications/unsubscribe-auth/A52WP5HW4KOGDTTGBNWTSKDXFEHLDANCNFSM6AAAAAAUYWRBTY. You are receiving this because you were mentioned.

SamEureka commented 1 year ago

I think I may have found something significant. I noticed that none of the kernel modules related to sound were loaded and that the sound card was being assigned to /dev/hidraw0 since it doesn't know what to do with it.

Abbreviated output of dmesg:

[    1.521598] ALSA device list:
[    1.524559]   No soundcards found.
[    1.536436] Freeing unused kernel memory: 8192K
[    2.156809] usb 4-1: new full-speed USB device number 2 using ohci-platform
[    2.434920] input: USB Sound Device         as /devices/platform/soc/1c1b400.usb/usb4/4-1/4-1:1.3/0003:0D8C:0102.0001/input/input0
[    2.518461] hid-generic 0003:0D8C:0102.0001: input,hidraw0: USB HID v1.00 Device [USB Sound Device        ] on usb-1c1b400.usb-1/input3 

Here is lsmod (shows kernel modules/drivers loaded) on the orange-pi-one:

root@853b875:~# lsmod
Module                  Size  Used by
ip6t_REJECT            16384  1
nf_reject_ipv6         16384  1 ip6t_REJECT
ipt_REJECT             16384  1
nf_reject_ipv4         16384  1 ipt_REJECT
ip6table_filter        16384  1
ip6_tables             24576  1 ip6table_filter
ipt_MASQUERADE         16384  3
nf_nat_masquerade_ipv4    16384  1 ipt_MASQUERADE
nfnetlink              16384  1
br_netfilter           24576  0
xt_owner               16384  0

versus my balenaPhono pi-zero-w: (grep'd to show snd modules only)

root@cc258d0:~# lsmod |grep snd
snd_usb_audio         233472  1
snd_hwdep              16384  1 snd_usb_audio
snd_usbmidi_lib        32768  1 snd_usb_audio
snd_rawmidi            32768  1 snd_usbmidi_lib
snd_seq_device         16384  1 snd_rawmidi
snd_bcm2835            24576  0
snd_pcm               106496  3 snd_usb_audio,snd_bcm2835
snd_timer              32768  1 snd_pcm
snd                    77824  9 snd_hwdep,snd_usb_audio,snd_timer,snd_rawmidi,snd_usbmidi_lib,snd_seq_device,snd_bcm2835,snd_pcm
mc                     45056  7 bcm2835_isp,bcm2835_codec,snd_usb_audio,videobuf2_common,videodev,v4l2_mem2mem,videobuf2_v4l2

I'm not sure how to get the correct kernel modules loaded. They should be in /lib/modules/4.17.3/kernel/sound but this is what is in there:

root@853b875:~# ls /lib/modules/4.17.3/kernel/
crypto  drivers  lib  mm  net

We should see, at the very least, the onboard hdmi sound card in /proc/asound/. My guess is that they are not in the host image installed on the orange-pi. I am going to look for the repo the image is built from and see if I can find any clues to why there are no sound modules available.

For now I can't think of anything else... unless I can find what should be there and use curl to download them and then modprobe to install them on the fly. I'm not optimistic.

//Sam

Richardrsb commented 1 year ago

Sam,

Hmm, this a bit Chinese for me., although i see what you are referring to. We might conclude at the end that HDMI enabled devices are not compatible??

//Richard -- Richard Rosenberger

Mobile Techcenter vof Toepadweg 33 5301 KA Zaltbommel +31-418-511296 http://www.mobiletechcenter.nl @. @.>KvK: 30177799 BTW/VAT: NL8105.84.712.B01 EORI: NL810584712

On 8 May 2023, at 20:21, Sam Dennon @.***> wrote:

I think I may have found something significant. I noticed that none of the kernel modules related to sound were loaded and that the sound card was being assigned to /dev/hidraw0 since it doesn't know what to do with it.

Abbreviated output of dmesg:

[ 1.521598] ALSA device list: [ 1.524559] No soundcards found. [ 1.536436] Freeing unused kernel memory: 8192K [ 2.156809] usb 4-1: new full-speed USB device number 2 using ohci-platform [ 2.434920] input: USB Sound Device as /devices/platform/soc/1c1b400.usb/usb4/4-1/4-1:1.3/0003:0D8C:0102.0001/input/input0 [ 2.518461] hid-generic 0003:0D8C:0102.0001: input,hidraw0: USB HID v1.00 Device [USB Sound Device ] on usb-1c1b400.usb-1/input3 Here is lsmod on the orange-pi-one:

@.***:~# lsmod Module Size Used by ip6t_REJECT 16384 1 nf_reject_ipv6 16384 1 ip6t_REJECT ipt_REJECT 16384 1 nf_reject_ipv4 16384 1 ipt_REJECT ip6table_filter 16384 1 ip6_tables 24576 1 ip6table_filter ipt_MASQUERADE 16384 3 nf_nat_masquerade_ipv4 16384 1 ipt_MASQUERADE nfnetlink 16384 1 br_netfilter 24576 0 xt_owner 16384 0 versus my balenaPhono pi-zero-w: (grep'd to show snd modules only)

@.***:~# lsmod |grep snd snd_usb_audio 233472 1 snd_hwdep 16384 1 snd_usb_audio snd_usbmidi_lib 32768 1 snd_usb_audio snd_rawmidi 32768 1 snd_usbmidi_lib snd_seq_device 16384 1 snd_rawmidi snd_bcm2835 24576 0 snd_pcm 106496 3 snd_usb_audio,snd_bcm2835 snd_timer 32768 1 snd_pcm snd 77824 9 snd_hwdep,snd_usb_audio,snd_timer,snd_rawmidi,snd_usbmidi_lib,snd_seq_device,snd_bcm2835,snd_pcm mc 45056 7 bcm2835_isp,bcm2835_codec,snd_usb_audio,videobuf2_common,videodev,v4l2_mem2mem,videobuf2_v4l2 I'm not sure how to get the correct kernel modules loaded. They should be in /lib/modules/4.17.3/kernel/sound but this is what is in there:

@.***:~# ls /lib/modules/4.17.3/kernel/ crypto drivers lib mm net We should see, at the very least, the onboard hdmi sound card in /proc/asound/. My guess is that they are not in the host image installed on the orange-pi. I am going to look for the repo the image is built from and see if I can find any clues to why there are no sound modules available.

For now I can't think of anything else... unless I can find what should be there and use curl to download them and then modprobe to install them on the fly. I'm not optimistic.

//Sam

— Reply to this email directly, view it on GitHub https://github.com/SamEureka/balenaPhono/issues/5#issuecomment-1538835380, or unsubscribe https://github.com/notifications/unsubscribe-auth/A52WP5DOMDJYSG6QBT432RDXFE2SVANCNFSM6AAAAAAUYWRBTY. You are receiving this because you were mentioned.

SamEureka commented 1 year ago

I confirmed that the required modules for sound are not included in any of the OrangePi balena images. The OrangePi device support was contributed by community members and it looks like they got the GPIO and Networking working and called it good. It is way beyond my current skill to create a custom build for the OrangePi boards. I just returned some NanoPi devices because the version I bought aren't supported at all.

It seems the best support is offered for the Nvidia and Raspberry pi boards. The ones that you can't find anywhere of course! I've been using virtual devices running on my laptop to do all my development lately.

Sorry we couldn't get it going!

//Sam