Solved PC speaker won't beep properly.


I took a video.
First, you hear the speaker beep, like normal... A while later, when FreeBSD 13.2 is loaded, you heard clicking sounds, instead of a melody.
 
The mixer has nothing to do with the PC speaker.

% mixer speaker 20
Mixer speaker is currently set to 20:20
% echo abcdefg >/dev/speaker
(softer play)

% mixer speaker 100
Mixer speaker is currently set to 100:100
% echo abcdefg >/dev/speaker
(louder play)

mixer(8) speaker works fine here, only on mixer instances that include one of course. Also, speaker usually has only a few distinct volume steps (here about 4) between 0 and 100.
 
% mixer speaker 20
Mixer speaker is currently set to 20:20
% echo abcdefg >/dev/speaker
(softer play)

% mixer speaker 100
Mixer speaker is currently set to 100:100
% echo abcdefg >/dev/speaker
(louder play)

mixer(8) speaker works fine here, only on mixer instances that include one of course. Also, speaker usually has only a few distinct volume steps (here about 4) between 0 and 100.
The mixer has nothing to do with this.
 
I just tried doing the same using the live CD, and got the same thing.

Ok. As expected, but it does confirm that your install hasn't damaged the relevant files.

Running this command used to give me a nice melody:
/bin/echo "\msl16oldcd4mll8pcb-agf+4.g4" > /dev/speaker

Ok, so which FreeBSD version were you running on this same machine when /dev/speaker was working correctly?

Can you boot to LiveCD mode using the installer from that earlier working version, to confirm that with spkrtest?

If that works, you have all you need to submit a PR against the speaker driver, for that machine's particular hardware.
 
Ok. As expected, but it does confirm that your install hasn't damaged the relevant files.



Ok, so which FreeBSD version were you running on this same machine when /dev/speaker was working correctly?

Can you boot to LiveCD mode using the installer from that earlier working version, to confirm that with spkrtest?

If that works, you have all you need to submit a PR against the speaker driver, for that machine's particular hardware.

Now that you mention the hardware, I think I finally made out what the problem is.

This is the first time I have used this motherboard, an Asus TUF Gaming b560M-PLUS. It is also the very first time I have installed FreeBSD 13 on physical hardware. In my effort to to get to the bottom of the issue, I tried booting from a FreeBSD 12.4 USB disk. The loader would load, but later you'd see a black screen with a mouse pointer, and it would not get past that. Obviousky there is something about this motherboard that does not agree with FreeBSD. So my theory is that FreeBSD 13.2's speaker driver is no compatible with with motherboard.

Can I somehow connect the speaker to the internet audio port of the motherboard and make it play sounds?
 
As shown above, the mixer level for speaker does indeed matter. At least it must be set greater than zero, which should mute speaker output - it does here anyway.

Code:
# mixer
Mixer vol      is currently set to 100:100
Mixer pcm      is currently set to 100:100
Mixer speaker  is currently set to 100:100
Mixer line     is currently set to   1:1
Mixer mic      is currently set to  67:67
Mixer mix      is currently set to  74:74
Mixer rec      is currently set to  37:37
Mixer igain    is currently set to   0:0
Mixer ogain    is currently set to 100:100
Recording source: mic

FYI, that did not work.
 
As cracauer@ said /dev/speaker and mixer are two different things./dev/speaker being a device connected to 8254 PIT (if I recall correctly there were some hacks how to adjust volume on PC speaker ; it's in the same realm as how to play PCM on it).
You set a FQ on PIT (channel 2) and that's it. Then you mute it. There's no other magic going on, you can't do any fancy thing through mixer or otherwise.

Also as mentioned above one has to pay attention to beep in 13.x base and one from ports.

My 13.2 test machine doesn't have PC speaker unfortunatelly, only a "speaker"/"beeper" connected to a sound card.

I dug my old jig:
Code:
root@freebsd13:~ # dmesg |grep CPU
CPU: Pentium II/Pentium II Xeon/Celeron (501.15-MHz 686-class CPU)
root@freebsd13:~ # uname -a
FreeBSD freebsd13.2 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC i386
root@freebsd13:~ #

Had to go through my boxes of old cables/hw/junk to find a PC speaker, connected it to this board.. and voila, it works. I found some random video streaming service online where I can share the video for 2 days: pc speaker in action.

At a first glance of your video it seems like it's a timer issue -- the timer is just too quick.
 
As cracauer@ said /dev/speaker and mixer are two different things./dev/speaker being a device connected 8254 PIT (if I recall correctly there were some hacks how to do it ; in the same realm as how to play PCM on it).
You set a FQ on PIT (channel 2) and that's it. Then you mute it. There's no other magic going on, you can't do any fancy thing through mixer or otherwise.

Also as mentioned above one has to pay attention to beep in 13.x base and one from ports.

My 13.2 test machine doesn't have PC speaker unfortunatelly, only a "speaker"/"beeper" connected to sound card.

I dug my old jig:
Code:
root@freebsd13:~ # dmesg |grep CPU
CPU: Pentium II/Pentium II Xeon/Celeron (501.15-MHz 686-class CPU)
root@freebsd13:~ # uname -a
FreeBSD freebsd13.2 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC i386
root@freebsd13:~ #

Had to go through my boxes of old cables/hw/junk to find a PC speaker, connected it to this board.. and voila, it works. I found some random video streaming service online where I can share the video for 2 days: pc speaker in action.

At a first glance of your video it seems like it's a timer issue -- the timer is just too quick.
Can I do anything to fix it?
 
Can I do anything to fix it?
That's a good question. If I have to debug this I'd start diffing the tsleep() in 12 and 13 to see if there were any changes. Also we are working on assumption that your HW can 100% use PC speaker as intended on 12.x version (you could boot there just to verify this once again).

If you compile kernel with DEBUG accessing /dev/speaker will throw some debug messages about timings. Comparing 12 and 13 messages (yes, that means compile kernel with DEBUG on 12 and 13) could give you a hint what's happening too.
 
That's a good question. If I have to debug this I'd start diffing the tsleep() in 12 and 13 to see if there were any changes. Also we are working on assumption that your HW can 100% use PC speaker as intended on 12.x version (you could boot there just to verify this once again).

If you compile kernel with DEBUG accessing /dev/speaker will through some debug messages about timings. Comparing 12 and 13 messages (yes, that means compile kernel with DEBUG on 12 and 13) could give you a hint what's happening too.
Sorry, that is just too much work, and I wouldn't know where to find tsleep() anyway.
Instead I will just try with FreeBSD 14 RC1 install disk.

UPDATE:
FreeBSD 14 RC1 did the same thing.

UPDATE:
FreeBSD 15 CURRENT does the same.

My conclusion is that it is the motherboard.
 
That's why I asked to confirm it works under 12.x as you stated in your opening statement. If it worked before then something had to be changed that messed up your setup.
Can I still do something about it?

Could I somehow connect the buzzer to the motherboard internal front panel audio pins and make FreeBSD play sounds from console? That would be nice.
 
Can you confirm it was working before ? Just to say yes (and actually confirm), in 12.4 release I can use PC speaker just fine.

If PC speaker itself is not working it doesn't make sense to connect it anywhere else. E.g. In the past people where attaching PC speaker output to amplifier and better speakers to enjoy the FastTracker music.
 
I've wondered if the polarity on the speaker pin was attached correctly.

If it got any electrical signal, it would work, and perhaps if the polarity is attached by the wrong pin, it wouldn't work correctly with some software?
 
If it got any electrical signal, it would work, and perhaps if the polarity is attached by the wrong pin, it wouldn't work correctly with some software?
There's not much software do go by though. You set a fq on a PIT and enable the output, that's it. Then you disable it to mute. In FreeBSD all this is happening via that kernel module.

But OP said it's working under BIOS so we know it's working. Acknowledging it worked under 12.4 would gives as a reference point (diff of sys/kern/kern_synch between 12.4 and 13.2).
 
It has two pins, if any gets power, it beeps due to the BIOS. If the pins are reversed, maybe it only works under BIOS and not as wanted under a driver when the power flowing in the wrong direction. Which the software would be the FreeBSD driver for the frequency.
 
You don't have that kind of control over it though. Before it used to be separate chip (e.g. 8254), later it was embedded into south bridge. You can really just set the frequency on it and keep "an eye" on t (i.e. timer) when to disable it.
 
That's why I asked to confirm it works under 12.x as you stated in your opening statement. If it worked before then something had to be changed that messed up your setup.

Beg to differ. scilek didn't mention 12.x there, and has since confirmed that:

This is the first time I have used this motherboard, an Asus TUF Gaming b560M-PLUS. It is also the very first time I have installed FreeBSD 13 on physical hardware.

Please see my posts #29 and #31 seeking the same info, and post #33 containing the above. [edit] and also that 12.4 wouldn't boot on this hardware.
 
As cracauer@ said /dev/speaker and mixer are two different things.

They are, but as I demonstrate in #29, 'mixer speaker' controls the volume of the PC speaker, and so of all beeps. At least, on my thinkpads, other laptops and all desktops and servers with beepers since 1998.

/dev/speaker being a device connected to 8254 PIT (if I recall correctly there were some hacks how to adjust volume on PC speaker ; it's in the same realm as how to play PCM on it).

I'm unsure how mixer controls its volume, only that it does.

I'm in a hospital environment so must be conscious of not being noisy; without mixer I'd have to mute beeps entirely.

You set a FQ on PIT (channel 2) and that's it. Then you mute it.

What's an FQ?

There's no other magic going on, you can't do any fancy thing through mixer or otherwise.

Except control its volume :-)

I dug my old jig:
Code:
root@freebsd13:~ # dmesg |grep CPU
CPU: Pentium II/Pentium II Xeon/Celeron (501.15-MHz 686-class CPU)
root@freebsd13:~ # uname -a
FreeBSD freebsd13.2 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC i386
root@freebsd13:~ #

Had to go through my boxes of old cables/hw/junk to find a PC speaker, connected it to this board.. and voila, it works. I found some random video streaming service online where I can share the video for 2 days: pc speaker in action.

At a first glance of your video it seems like it's a timer issue -- the timer is just too quick.

I've suggested a PR, but there's more basic info missing so far.

Cheers
 
They are, but as I demonstrate in #29, 'mixer speaker' controls the volume of the PC speaker, and so of all beeps. At least, on my thinkpads, other laptops and all desktops and servers with beepers since 1998.
Then it's not an actual PC speaker (i8254 or alike) but a speaker connected to a sound card (or as I mention below). Something similar I have on my test board I mentioned above (HP ProDesk 600 G1).

Except control its volume :)
Not with old school PC speaker. :)

Now I understand that you have a HW where you can clearly a) control the volume with mixer b) write to /dev/speaker and get the sound. I'd bet HW manufacturer did something here on its own, maybe hooked IO ports. One can imagine there's no high demand for actual PC speaker these days.
 
Please see my posts #29 and #31 seeking the same info, and post #33 containing the above. [edit] and also that 12.4 wouldn't boot on this hardware.
You are correct, I did miss the post #33. It wouldn't hurt if OP mentioned that to me when I was asking.

But when I tried to get anything out it of using beep, it just gave me low-pitch clicking sounds. That did not use to happen with versions prior to 13.
I kept rereading his original statement, from there one can get impression that this prior versions of FreeBSD existed on this HW.

I went through the user manual of Asus TUF Gaming b560M-PLUS. On page 15, paragraph 16, point 3 there's "4-pin speaker". There is no other description of this IO port. Classic PC speaker had two pins (Gnd and Vcc).
 
[...] I went through the user manual of Asus TUF Gaming b560M-PLUS. On page 15, paragraph 16, point 3 there's "4-pin speaker". There is no other description of this IO port. Classic PC speaker had two pins (Gnd and Vcc).
Is my asumption correct that to resolve the issue, one needs to:
  • link & code /dev/speaker to the appropriate BIOS/firmware call(s)
  • or, translate user speaker manipulations to manipulations of the motherboard sound chip
Where the first solution might be limited because the motherboard BIOS implementation could be limited as to provide only one simple type of operation, for example activation of a beep with fixed parameters (sufficient for "boot-beeping"). OTOH, the second solution provides complete access to the sound chip, but all original speaker functionalities have to be translated/coded to the sound chip interface (hopefully using FreeBSD OS/driver calls) to its hardware.
 
Back
Top