No Beep on Startup and Shutdown

Started by pholt, June 26, 2024, 08:31:34 PM

Previous topic - Next topic
June 26, 2024, 08:31:34 PM Last Edit: June 26, 2024, 09:34:38 PM by pholt
I have two identical OPNsense machines at two different locations.  Sound is enabled in the BIOS of both machines and the beep is enabled in both OPNsense configurations. One plays the beep on startup and shutdown. The other one doesn't. I cannot figure out why. I have confirmed that the speaker works in both machines, but just in case, I replaced the one in the silent machine. Same thing. Maybe some other failure on the mainboard is probably the issue.

It's not the end of the world if it doesn't work on one of the machines, but I'm curious.

I'm not sure what hardware brand or version of OPNSense you're running, but this also happened to me. I was just tinkering with it today. I have a Lenovo M720q Tiny as well as a M715q Tiny. The beep can be heard on the M715q but not on the M720q. At first I thought it was the internal speaker but I swapped speakers and it was same result, so bad speaker was ruled-out. I checked BIOS next. Speaker was enabled. But then I hit a key by accident and the BIOS beeped its disapproval at me, so it wasn't the mobo or speaker.

Next I went into the console of OPNSense in search of the script that plays the little tones during start and shutdown. I'm running version 24.1. Interestingly I found two beep commands, one located in /usr/local/bin and the other under /usr/bin. The beep script can be located here: /usr/local/sbin/opnsense-beep. cat this file reveals that it calls /usr/local/bin/beep and not /usr/bin/beep. The one under /usr/bin/ has more switches than the other. One of them is -g. This switch controls the audio gain and takes a number from 50 to 100 with default of 75. The beep that opnsense-beep script calls does not have this switch. Still in the shell, I issued a test:
$ /usr/bin/beep -F440 -D100
Didn't hear any tone, so I added -g100:
$ /usr/bin/beep -F440 -D100 -g100
This time success, although a bit loud. Now, for me I decided to change the opnsense-beep script knowing that as soon as an update is installed it will get reverted to the distributed beep package that is part of OPNsense. The other thing to "note" was that these two beep commands have incompatible delay values. So I had to also adjust those values in the /usr/local/etc/opnsense-beep.d/start and /usr/local/etc/opnsense-beep.d/stop files. These files, along with two others, simply contain lines that correspond to the frequency and duration of each tone and are used as inputs to the /usr/local/sbin/opnsense-beep script. I just changed the duration to be compatible with what /usr/bin/beep requires.

Now I can hear those sweet jingles again!  :) What would be even better is if the official packaged beep command also had an option to control gain!

I followed your steps, and no result. Interestingly, I swapped out the old OPNsense machine for a new one--moved disk/memory/network card over--and tried again. Still no sound.

I'm stumped.

Today at 03:58:41 AM #3 Last Edit: Today at 05:14:12 AM by johnmcallister
Quote..I'm not sure what hardware brand or version of OPNSense you're running, but this also happened to me. I was just tinkering with it today. I have a Lenovo M720q Tiny as well as a M715q Tiny. The beep can be heard on the M715q but not on the M720q..

I'm running a Lenovo® M90n-1 Nano and encountered the same problem: No friendly OPNsense beeps on startup/shutdown. Definitely mission-critical, couldn't let it go unaddressed.

After some poking around I got it fixed. There were three separate problems:

  • Two different versions of the "beep" binary, one of which doesn't work on my system.
  • The opnsense-beep shell script calling the wrong (non-functional) version of "beep."
  • The opnsense start / stop beep sound definition files contain beep durations in bare integers that are interpreted as "centiseconds" by one version of beep, but as "milliseconds" in another version of beep.

There are for whatever reason multiple versions of the "beep" binary on my system. (25.7.8.) (As best I can tell it looks like one might use /dev/speaker and another version uses /dev/dsp instead? )

Each of these versions has different command-line options, and only one of them (/usr/bin/beep) actually makes sounds on my system.

root@router:~ # ls -al /usr/bin/beep
-rwsr-xr-x  1 root wheel 10088 Nov 24 23:26 /usr/bin/beep
# This version interprets tone-length integers as millisecond values, and it
# works (makes beep noises) on my system.

root@router:~ # ls -al /usr/local/bin/beep
-r-xr-xr-x  1 root wheel 7584 Jul 21 16:21 /usr/local/bin/beep
# This version interpretes tone-length integers as centi-second values, and it
# DOESN'T work (no sounds) on my system.


The /usr/local/sbin/opnsense-beep script, as-shipped, calls /usr/local/bin/beep.

So I altered the script it to call the other version of beep instead. I also altering the command-line flags as-required.

root@router:/usr/local/sbin # diff opnsense-beep opnsense-beep-ORIGINAL
69c69
<      /usr/bin/beep  -F "${NOTE}" -D "${DURATION}" -g 100
---
>         /usr/local/bin/beep -p "${NOTE}" "${DURATION}"

#  The -g 100 argument optionally boosts the output volume to 100%, which is necessary
#  for the tiny speaker in this system.


But after doing this, while I could type, say, /usr/bin/beep -F 1000 -D 100 from the command line and it would work fine, the opnsense-beep script still wasn't working.

I finally checked the beep-sound definition files in /usr/local/etc/opensense-beep.d/* and found them to have DURATION lengths of "25." Those lengths were meant for the (non-working, on my system)
/usr/local/bin/beep, which takes tone lengths in units of centi-seconds. (Hundredths of a second.)


But /usr/bin/beep  takes tone lengths in units of milliseconds, with 50 ms the lowest-valid value.  Once I changed the beep definitions in the /usr/local/etc/opensense-beep.d/* tune definition files from "25" to "250," my modified version of /usr/local/sbin/opnsense-beep started producing the usual friendly beep sounds.



FWIW, here are the audio devices as-reported on my system:

root@router:~ # cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC235 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Intel Kaby Lake (HDMI/DP 8ch)> (play)
No devices installed from userspace.