Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Would like to get beep to work in Debian 10

Need help with peripherals or devices?
Post Reply
Message
Author
sandwich
Posts: 16
Joined: 2018-12-03 18:18

Would like to get beep to work in Debian 10

#1 Post by sandwich »

I cannot get any beep sounds on my installation of Debian 10. Neither in a console session, nor under X.

The computer is a Lenovo l380 yoga laptop.
Keyboard beep is enabled in the firmware and it beeps fine when I enter the firmware setup.
All sounds, (except beep) work fine in tty and X.
Pulse is not installed.
echo -e '\a' does not work in tty nor X.
beep package is installed, but beep command does not work in tty nor X.
Programs with an enabled beep setting are not beeping, e.g. my x terminal emulator.
Alsamixer has no entry for a pc speaker, or beep, or anything similar. In any case, nothing is muted (except for mics).

Module pcspkr appears to be loaded:

Code: Select all

lsmod | grep pcspkr
returns:
pcspkr 16384 0

and:

Code: Select all

sudo dmesg | grep pcspkr
returns:
[ 3.747373] input: PC Speaker as /devices/platform/pcspkr/input/input18

Reloading the pcspkr module does not fix the problem.

pcspkr is not blacklisted:

Code: Select all

grep -r pcspkr /etc/modprobe.d/
returns nothing

I hope this means that --blength could not be 0:

Code: Select all

setterm --blength 1000
returns:
setterm: terminal xterm-256color does not support --blength

This doesn't seem to be imposing any restrictions:

Code: Select all

grep bell /etc/inputrc
returns only the commented out lines:
# do not bell on tab-completion
# set bell-style none
# set bell-style visible

Neither does this:

Code: Select all

xset q | grep bell
returns:
bell percent: 50 bell pitch: 400 bell duration: 100

Any pointers to figure this out will be greatly appreciated. For whatever it's worth, beep used to work in Debian 9 on the same laptop. I realize a lot of people hate the beep, but I rely on it.

Thx

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Would like to get beep to work in Debian 10

#2 Post by peter_irich »

Check is your beep suid.

Code: Select all

ls -l /usr/bin/beep
If no, enter command

Code: Select all

sudo chmod 4755 /usr/bin/beep
then run beep with "--verbose". On my desktop PC in Ubuntu beep works in xterm.

Peter.

sandwich
Posts: 16
Joined: 2018-12-03 18:18

Re: Would like to get beep to work in Debian 10

#3 Post by sandwich »

Thx

Code: Select all

ls -l /usr/bin/beep
returns:
-rwxr-xr-x 1 root root 28384 Feb 21 2019 /usr/bin/beep
So not suid.

After running

Code: Select all

sudo chmod 4755 /usr/bin/beep

Code: Select all

ls -l /usr/bin/beep
returns:
-rwsr-xr-x 1 root root 28384 Feb 21 2019 /usr/bin/beep
suid now

As per man page for my version of beep, I don't have a --verbose option, nonetheless:

Code: Select all

beep -f 500 -l 1000
returns:
beep: Error: Running setuid or setgid, which is not supported for security reasons.
beep: Error: Set up permissions for the pcspkr evdev device file instead.
Adding --verbose or running with sudo makes no difference: same output.

I don't know enough to interpret the output of suid beep. Does it tell you anything?
Again, thanks very much.

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Would like to get beep to work in Debian 10

#4 Post by peter_irich »

I can't help, but I think that it is need to set CAP_SETUID to /usr/bin/beep.
See man capabilities, man setcap/getcap, man setfattr/getfattr and Internet.
I have no experience with these utilities, but OS Ubuntu on my PC have no flags CONFIG_SECURITY_FILE_CAPABILITIES
in kernels's config in /boot. I did't can use make it on my PC.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Would like to get beep to work in Debian 10

#5 Post by Head_on_a_Stick »

sandwich wrote:

Code: Select all

Set up permissions for the pcspkr evdev device file
Tip: enter messages like this into a search engine. Here's what I found after less than 30 seconds of "research": https://wiki.archlinux.org/index.php/PC ... -root_user
deadbang

sandwich
Posts: 16
Joined: 2018-12-03 18:18

Re: Would like to get beep to work in Debian 10

#6 Post by sandwich »

@Head on Stick, thanks for the tip, (you're right, I should have thought of doing that search).

Unfortunately it didn't work. I created that file in /etc/udev/rules.d and re-booted, but I still get no beeps from any apps.

However this sentence from the same page (https://wiki.archlinux.org/index.php/PC ... stallation)

Code: Select all

You may also need to unmute the PC speaker in ALSA. 
seems to point at an alsa config problem. As mentioned earlier, my alsamixer has no entry for PC speaker (nor Beep, which is what alsamixer shows on Debian 9 on a different laptop).

I've been searching around on Google without much luck. Would anybody know how to troubleshoot the lack of the alsamixer entry, or maybe point me to some documentation?

Thanks very much

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Would like to get beep to work in Debian 10

#7 Post by peter_irich »

Check your udev rule in /etc/udev/rules.d, perhaps, in contains error.
Also try found the speaker in alsamixer. For this press F5 and then select all audio cards one after one.
In my PC not all devices shows speaker.

Peter.
Last edited by peter_irich on 2020-04-22 08:00, edited 1 time in total.

cuckooflew
Posts: 677
Joined: 2018-05-10 19:34
Location: Some where out west
Been thanked: 1 time

Re: Would like to get beep to work in Debian 10

#8 Post by cuckooflew »

I've been searching around on Google without much luck.
Hmm, I just did a search, and find all sorts of documentation, some looks promising.But it would take a lot of time to read it all and find that exact lines, with code, ---and off hand I really don't know,
so any way,
maybe point me to some documentation?
I will go ahead and "point" you to some of the urls that look the most promising, but it up to you read the documentation your self, I am sure you will find the answer if you actually do that.
Show us more error messages, exactly like they show in your terminal . For example:
From: https://forums.gentoo.org/viewtopic-t-1 ... art-0.html
i don't see any obvious errors anywhere, except when i run beep.

Code: Select all

$ beep
Could not open /dev/tty0 or /dev/vc/0 for writing
open: No such file or directory
Show us what it says when you run the beep command, like above. The thread is very long, you will need to read it all, try what is suggested, until you find the problem,..
If that url does not help you, another , much more extensive,:
https://wiki.archlinux.org/index.php/Ad ... leshooting
What happens if you run :

Code: Select all

$ speaker-test 
Keep in mind the $ is not part of the command, it only indicates that the command should be run as a normal user,..# means you must be root....
There is much more information in the documentation.
==========================================================
https://wiki.archlinux.org/index.php/Ad ... sound_card
================
There are more results, but now I have spent about 20 minuets on this, reading some of the documentation and writing this post,..
I've been searching around on Google without much luck
Either Google is broken, or you are lying , I will assume Google is broken, so that I am not acusing you of lying, but also I used :https://www.startpage.com/do/search and maybe was just lucky, or my choice of keywords was bettr, actually I don't think luck is a factor, ...but any way good luck and have fun, be happy, and keeptrying...
Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!

sandwich
Posts: 16
Joined: 2018-12-03 18:18

Re: Would like to get beep to work in Debian 10

#9 Post by sandwich »

@peter_irich - Thanks for following this thread so far.
In

Code: Select all

/etc/udev/rules.d/70-pcspkr-beep.rules
I have

Code: Select all

ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="PC Speaker", ENV{DEVNAME}!="", TAG+="uaccess"
which I think is correct, if I am wrong, please let me know. Nonetheless, neither beep nor any other apps can create a beep sound when this rule is present. All other sounds are ok.
I have a hunch that this is not a permissions problem. I would expect all apps attempting to issue beeps to produce permission errors, but:
1. I see no errors, with or without the udev rule (the exception of course is that I did see errors when I made beep suid as you suggested).
2. I cannot get any beep sounds (or errors) when logged in as root either.

sandwich
Posts: 16
Joined: 2018-12-03 18:18

Re: Would like to get beep to work in Debian 10

#10 Post by sandwich »

@cuckooflew - Thanks for your reply.
Hmm, I just did a search, and find all sorts of documentation, some looks promising.
Indeed, I found lots of stuff, but I just haven't had any luck so far finding anything that sheds light on this problem.
maybe point me to some documentation?
I will go ahead and "point" you to some of the urls that look the most promising, but it up to you read the documentation your self,
Of course, I hope you didn't think I wanted you to read it to me. In any case, I very much appreciate those urls you sent, although I'd already found and read some of them. If I find a solution in there, I will definitely post it and give you credit.

Code: Select all

$beep
returns nothing.

speaker-test worked fine

Code: Select all

$speaker-test -l 5

speaker-test 1.1.8

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 2048 to 16384
Period size range from 1024 to 1024
Using max buffer size 16384
Periods = 4
was set period_size = 1024
was set buffer_size = 16384
 0 - Front Left
Time per period = 2.667086
 0 - Front Left
Time per period = 2.986556
 0 - Front Left
Time per period = 2.986564
 0 - Front Left
Time per period = 2.986567
 0 - Front Left
Time per period = 2.986399
It plays white noise. In the original post I mentioned that all other sounds besides beeping worked fine. If you'd read the original post carefully you might have skipped this suggestion.
Either Google is broken, or you are lying , I will assume Google is broken, so that I am not acusing you of lying
Well, you are, or worse, but I wont begrudge you your opinion, you are entitled to it.

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Would like to get beep to work in Debian 10

#11 Post by peter_irich »

I use headphone, USB PnP Sound Device, it only shows Speaker, when selected it in alsamixer, HDA ATI not shows,
but I hear beep from PC Speaker not from headphone. PC Speaker exactly works?

sandwich
Posts: 16
Joined: 2018-12-03 18:18

Re: Would like to get beep to work in Debian 10

#12 Post by sandwich »

@peter_irich
I don't know very much, but I will tell you what I know.

On old computers there was a separate speaker dedicated to beeps, sometimes integrated to motherboard, sometimes separate attached to motherboard with cables. I think these worked separate from soundcard, there must have been a small sound-generator chip on the motherboard somewhere. I don't know any details of this setup because, on my computers it always worked.

Based on what I have read, new laptops do not have a separate speaker for beeps. In new laptops the OS and associated software take care of sending beep events to the soundcard.
In Debian 10 (and other distributions probably too) this is taken care of, as far as I can tell, by the pcspkr kernel module and ALSA. The kernel binary that came with my installation of Debian 10 already had the pcspkr module compiled into it. I know this because

Code: Select all

$ lsmod | grep pcspkr
pcspkr                 16384  0
The pcspkr module creates a device file /dev/input/event6 (this could be different on different computers) and a link to the device file /dev/input/by-path/platform-pcspkr-event-spkr . I know this because if I unload the pcspkr module

Code: Select all

modprobe -r pcspkr
both the device file and the link disappear. If I reaload pcspkr, both re-appear.

The beep command, and echo -e '\a' and many applications that make beeps write to this device file, I know this because if you monitor /dev/input/event6 (or the link) there is always binary content in there when a beep happens, but nothing otherwise.

I guess that ALSA is supposed to read /dev/input/by-path/platform-pcspkr-event-spkr (or maybe another process reads the file and passes the data to ALSA). ALSA then routes the sound information to the speakers, or the head-phones, or both, or somewhere else, or nowhere, all depending on ALSA's configuration. I am guessing that this is where my problem is.

Whether a device appears in alsamixer seems to also dependent on the ALSA configuration. It appears to be possible to configure ALSA so that a device works but does not show up in alsamixer; the opposite is also possible.

The problem is that configuring ALSA is not easy if you don't already know about soundcards in linux. In my opinion, the ALSA documentation is not very good, but maybe that is just me.

Also, the fact that different people report different beep behavior makes me wonder whether different versions of the Debian 10 installation iso where shipped with slightly different ALSA configurations. But it could also be differences in the soundcards.

Anyway, that is all I know so far.

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Would like to get beep to work in Debian 10

#13 Post by peter_irich »

Try for checking as root in xterm or set 666 permission to /dev/console:

Code: Select all

/bin/echo -e "\a" > /dev/console
must be beep.
Of course, /dev/console. must be exist.

Also from program it is possible use ioctl:

Code: Select all

fd=open("/dev/console", O_RDONLY);
ioctl(fd, KDMKTONE, (long) argument). 
or

Code: Select all

ioctl(fd, KIOCSOUND, (int) tone). 
Peter.
Last edited by peter_irich on 2020-04-28 04:17, edited 1 time in total.

sandwich
Posts: 16
Joined: 2018-12-03 18:18

Re: Would like to get beep to work in Debian 10

#14 Post by sandwich »

Code: Select all

#include <sys/ioctl.h> 
#include <stdlib.h>
#include <fcntl.h>
#include <linux/kd.h>

int main(int argc, char **argv)
{
   int fd;
   int ms = 1000;
   int freq = 700;  
   
   fd=open("/dev/console", O_RDONLY);
   ioctl(fd, KDMKTONE, (ms<<16 | 1193180/freq));
}
Makes no beep. but it sends binary output to /dev/input/by-path/platform-pcspkr-event-spkr

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Would like to get beep to work in Debian 10

#15 Post by peter_irich »

On my desktop PC this program works from root, because /dev/console has permissions 600. Beep is.
1st argument, if presents, is frequency, 2nd argument, if presents, is duration, without - 400Hz 500ms.
just enter as root

Code: Select all

/bin/echo -e "\a" > /dev/console
will be beep or not?

Code: Select all

#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/kd.h>
#include <string.h>
#include <errno.h>
int main( int argc, char **argv){
int fd,	nf=400,	nt=500,	ni;
unsigned long int na;
char dev[16]="/dev/console";
if(argc >=2)nf = atoi(argv[1]);
if(argc >=3)nt = atoi(argv[2]);
na = (nt << 16) + 1193180 / nf;
fd = open(dev, O_RDWR);
ni = ioctl(fd, KDMKTONE, na);
if(errno!=0)fprintf(stdout,"%s%5d%5d%9lx%9ld%3d%5d %s\n",
dev,nf,nt,na,na,ni,errno,strerror(errno));
close(fd);return 0;}


sandwich
Posts: 16
Joined: 2018-12-03 18:18

Re: Would like to get beep to work in Debian 10

#16 Post by sandwich »

For anyone who's followed this thread so far -

To determine whether the problem was with my hardware, I ran the lxde iso of Debian 9 live. In that environment, all different forms of beep work without any problems on my laptop. So it appears that the version of Debian 10 I had installed (debian-live-10.3.0-amd64-standard+nonfree.iso) is not configured to support beeping on my laptop.

Since I depend on that beep, I'll be reinstalling a different version of Debian 10. If it all works, I'll be marking this thread as solved.

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Would like to get beep to work in Debian 10

#17 Post by peter_irich »

There is output of the command

Code: Select all

grep BEEP /boot/config-5.3.0-28-generic 
on my PC:

Code: Select all

CONFIG_INPUT_GPIO_BEEPER=m
CONFIG_INPUT_PWM_BEEPER=m
CONFIG_SND_HDA_INPUT_BEEP=y
CONFIG_SND_HDA_INPUT_BEEP_MODE=0
sandwich, on your PC pcspkr is booted, if the speaker is really present, beep must be.
/dev/console must be open to writing in the program.

Peter.

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Would like to get beep to work in Debian 10

#18 Post by peter_irich »

For comparing, there is output of the command for kernel from Debian Buster:

Code: Select all

grep BEEP config-4.19.0-8-amd64

Code: Select all

# CONFIG_INPUT_GPIO_BEEPER is not set
# CONFIG_INPUT_PWM_BEEPER is not set
CONFIG_SND_HDA_INPUT_BEEP=y
CONFIG_SND_HDA_INPUT_BEEP_MODE=1
This kernel is from deb-package, I have not Debian installed.

Post Reply