Solved PC Speaker Not Working

Hello Group,
I've been silent lately because everything has been running well... until now. I had a hardware fault and put my disks into another old Desktop PC box. FreeBSD 14.2 booted up just fine. Except that it no longer "beeps" when it's ready for me to login (headless).
I don't know what to do, and have spent the last several hours going through various posts in the forum, all without success. Can someone please help me get some sound out of my PC speaker? Thanks.

Here are a few salient points:

Code:
mike@darkstar:~# inxi -A
Audio:
  Device-1: Intel 6 Series/C200 Series Family High Definition Audio driver: hdac
  Device-2: NVIDIA GF108 High Definition Audio driver: hdac
  Sound Server-1: OSS v: N/A running: yes

Code:
mike@darkstar:~# cat /dev/sndstat
Installed devices:
pcm0: <NVIDIA GT440 (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA GT440 (HDMI/DP 8ch)> (play)
pcm2: <NVIDIA GT440 (HDMI/DP 8ch)> (play)
pcm3: <NVIDIA GT440 (HDMI/DP 8ch)> (play)
pcm4: <Realtek ALC662 rev1 (Analog 2.0+HP/2.0)> (play/rec) default
pcm5: <Realtek ALC662 rev1 (Onboard Analog Speaker)> (play)
No devices installed from userspace.

Code:
mike@darkstar:~# mixer
pcm4:mixer: <Realtek ALC662 rev1 (Analog 2.0+HP/2.0)> on hdaa4 (play/rec) (default)
    vol       = 1.00:1.00     pbk
    pcm       = 1.00:1.00     pbk
    speaker   = 0.74:0.74     rec
    line      = 0.01:0.01     rec
    mic       = 0.67:0.67     rec src
    mix       = 0.74:0.74     rec
    rec       = 0.29:0.29     pbk
    igain     = 0.00:0.00     pbk
    ogain     = 1.00:1.00     pbk

Code:
mike@darkstar:~# kldstat
Id Refs Address                Size Name
 1   89 0xffffffff80200000  1f3c6c0 kernel
 2    1 0xffffffff8213d000     77d8 cryptodev.ko
 3    1 0xffffffff82145000   11d718 if_re.ko
 4    1 0xffffffff82263000     45c0 snd_driver.ko
 5    2 0xffffffff82268000    1b388 snd_uaudio.ko
 6    2 0xffffffff82284000     72c0 snd_vibes.ko
 7    2 0xffffffff8228c000     5c10 snd_via82c686.ko
 8    2 0xffffffff82292000     5cc0 snd_t4dwave.ko
 9    4 0xffffffff82298000     3238 snd_spicds.ko
10    2 0xffffffff8229c000     7650 snd_solo.ko
11    2 0xffffffff822a4000    12298 snd_neomagic.ko
12    2 0xffffffff822b7000     c048 snd_maestro3.ko
13    2 0xffffffff822c4000     a2e0 snd_hdspe.ko
14    2 0xffffffff822cf000     4808 snd_fm801.ko
15    2 0xffffffff822d4000     8cf8 snd_envy24ht.ko
16    2 0xffffffff822dd000     a078 snd_envy24.ko
17    2 0xffffffff822e8000     5ca8 snd_cs4281.ko
18    2 0xffffffff822ee000     7c98 snd_atiixp.ko
19    2 0xffffffff822f6000     61d0 snd_als4000.ko
20    1 0xffffffff822fe000     4440 speaker.ko
21    1 0xffffffff82303000   5da658 zfs.ko
22    1 0xffffffff833e5000     3390 acpi_wmi.ko
23    1 0xffffffff833e9000     4250 ichsmb.ko
24    1 0xffffffff833ee000     2178 smbus.ko
25    1 0xffffffff833f1000    27450 ipfw.ko

I'm getting no sound at all:

beep(1) does nothing.
spkrtest(8) gives me a selection of melodies, but doesn't play anything (no errors either) but only if run as root (using doas). Otherwise I get:
Code:
mike@darkstar:~# spkrtest
You have no write access to /dev/speaker or the speaker device is
not enabled in kernel. Cannot play any melody! See spkr(4)
 
I assume you have the thing that is called "PC speaker" that's connected to the motherboard of the computer. I have one but it only beeps if my computer passed the POST stage successfully. I don't think that FreeBSD, by default, makes a sound when login is available. But, I did it for a while ago but not still using it currently. You may do a chmod command on speaker device and/or may put the command to /etc/rc.local for automatic chmod on every boot. I think the beep command is for real speakers, so not working for the little PC speaker.
 
I assume you have the thing that is called "PC speaker" that's connected to the motherboard of the computer. I have one but it only beeps if my computer passed the POST stage successfully. I don't think that FreeBSD, by default, makes a sound when login is available. But, I did it for a while ago but not still using it currently. You may do a chmod command on speaker device and/or may put the command to /etc/rc.local for automatic chmod on every boot. I think the beep command is for real speakers, so not working for the little PC speaker.
Thank you for your reply. Yes, it's attached to the motherboard. I used startup_sound_enable="YES" in /etc/rc.conf and it worked. I had a file "startup_sound" in my /etc/rc.d folder:

#!/bin/sh
Code:
# PROVIDE: startup_sound
# REQUIRE: LOGIN
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
# kld_list="speaker"
# startup_sound_enable (bool):  Set to NO by default.
#                               Set it to YES to enable startup_sound.
#

. /etc/rc.subr

name=startup_sound
required_modules="speaker"
start_cmd="play_startup_sound"
notes="FGABC"

rcvar=startup_sound_enable

load_rc_config $name

: ${startup_sound_enable:="NO"}

play_startup_sound()
{
   echo ${notes} > /dev/speaker
}

run_rc_command "$1"

I'm pretty certain that I've got the speaker's hardware setup wrong.
 
This might also be useful:
mike@darkstar:~#dmesg dmesg | grep pcm
Code:
pcm0: <NVIDIA GT440 (HDMI/DP 8ch)> at nid 5 on hdaa0
pcm1: <NVIDIA GT440 (HDMI/DP 8ch)> at nid 5 on hdaa1
pcm2: <NVIDIA GT440 (HDMI/DP 8ch)> at nid 5 on hdaa2
pcm3: <NVIDIA GT440 (HDMI/DP 8ch)> at nid 5 on hdaa3
pcm4: <Realtek ALC662 rev1 (Analog 2.0+HP/2.0)> at nid 20,27 and 24,25 on hdaa4
pcm5: <Realtek ALC662 rev1 (Onboard Analog Speaker)> at nid 21 on hdaa4
pcm0: <NVIDIA GT440 (HDMI/DP 8ch)> at nid 5 on hdaa0
pcm1: <NVIDIA GT440 (HDMI/DP 8ch)> at nid 5 on hdaa1
pcm2: <NVIDIA GT440 (HDMI/DP 8ch)> at nid 5 on hdaa2
pcm3: <NVIDIA GT440 (HDMI/DP 8ch)> at nid 5 on hdaa3
pcm4: <Realtek ALC662 rev1 (Analog 2.0+HP/2.0)> at nid 20,27 and 24,25 on hdaa4
pcm5: <Realtek ALC662 rev1 (Onboard Analog Speaker)> at nid 21 on hdaa4

I'm pretty sure that my speaker settings are wrong. Assuming that the damn thing even works!
 
You are still mixing up the "PC speaker", which is the on-mainboard thing that can only beep, and a real soundcard that can play music and the like.

Does your mainboard have a speaker at all? Does it do beeps around the BIOS?
 
You are still mixing up the "PC speaker", which is the on-mainboard thing that can only beep
I'd argue it can technically only "click" 😏 (TTL 0->1 or vice versa). To beep, it needs a timer (for periodic clicking). I remember people in the 90s were pretty creative using the CPU to drive this thing instead of a timer ...
 
Back
Top