Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another question about booting... #5

Closed
Richardrsb opened this issue Feb 11, 2023 · 24 comments · Fixed by #6
Closed

Another question about booting... #5

Richardrsb opened this issue Feb 11, 2023 · 24 comments · Fixed by #6
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Richardrsb
Copy link

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
Copy link
Owner

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

@SamEureka SamEureka added the enhancement New feature or request label Feb 25, 2023
@SamEureka SamEureka self-assigned this Feb 25, 2023
@Richardrsb
Copy link
Author

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 SamEureka added the good first issue Good for newcomers label Feb 28, 2023
@SamEureka SamEureka linked a pull request Feb 28, 2023 that will close this issue
@SamEureka SamEureka reopened this Mar 2, 2023
@SamEureka
Copy link
Owner

@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
Copy link
Author

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

@Richardrsb
Copy link
Author

Richardrsb commented May 2, 2023

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
Copy link
Owner

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!

  • plughw:1,0
  • plughw:1,1
  • hw:0,0
  • hw:1,0
  • hw:0,1
  • ...etc

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
Copy link
Owner

Adding DARKICE_DEVICE variable:

device_variable

Output of aplay -l command:

aplay_-l

@SamEureka
Copy link
Owner

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
Copy link
Author

Richardrsb commented May 5, 2023

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
Copy link
Owner

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
Copy link
Author

Richardrsb commented May 6, 2023 via email

@Richardrsb
Copy link
Author

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

@SamEureka
Copy link
Owner

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
Copy link
Author

Richardrsb commented May 8, 2023 via email

@SamEureka
Copy link
Owner

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
Copy link
Author

Richardrsb commented May 8, 2023 via email

@SamEureka
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

Richardrsb commented May 8, 2023 via email

@SamEureka
Copy link
Owner

SamEureka commented May 8, 2023

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
Copy link
Author

Richardrsb commented May 8, 2023 via email

@SamEureka
Copy link
Owner

SamEureka commented May 8, 2023

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
Copy link
Author

Richardrsb commented May 8, 2023 via email

@SamEureka
Copy link
Owner

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

@SamEureka SamEureka pinned this issue Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants