Would like to get beep to work in Debian 10

Getting your soundcard to work, using Debian on non-i386 hardware, etc

Would like to get beep to work in Debian 10

Postby sandwich » 2020-04-17 23:40

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
sandwich
 
Posts: 16
Joined: 2018-12-03 18:18

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

Postby peter_irich » 2020-04-18 09:06

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.
peter_irich
 
Posts: 1292
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

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

Postby sandwich » 2020-04-19 20:16

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.
sandwich
 
Posts: 16
Joined: 2018-12-03 18:18

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

Postby peter_irich » 2020-04-20 08:07

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.
peter_irich
 
Posts: 1292
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

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

Postby Head_on_a_Stick » 2020-04-20 12:22

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
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12622
Joined: 2014-06-01 17:46
Location: /dev/chair

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

Postby sandwich » 2020-04-22 03:58

@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_speaker#Installation)
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
sandwich
 
Posts: 16
Joined: 2018-12-03 18:18

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

Postby peter_irich » 2020-04-22 05:23

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.
peter_irich
 
Posts: 1292
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

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

Postby cuckooflew » 2020-04-22 05:37

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-1051820-start-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/Advanced_Linux_Sound_Architecture/Troubleshooting
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/Advanced_Linux_Sound_Architecture#Set_the_default_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!
cuckooflew
 
Posts: 683
Joined: 2018-05-10 19:34
Location: Some where out west

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

Postby sandwich » 2020-04-22 22:44

@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

Postby sandwich » 2020-04-23 00:02

@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.
sandwich
 
Posts: 16
Joined: 2018-12-03 18:18

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

Postby peter_irich » 2020-04-23 05:21

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?
peter_irich
 
Posts: 1292
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

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

Postby sandwich » 2020-04-24 18:37

@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.
sandwich
 
Posts: 16
Joined: 2018-12-03 18:18

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

Postby peter_irich » 2020-04-25 05:00

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.
peter_irich
 
Posts: 1292
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

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

Postby sandwich » 2020-04-27 22:30

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
sandwich
 
Posts: 16
Joined: 2018-12-03 18:18

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

Postby peter_irich » 2020-04-28 05:02

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;}

peter_irich
 
Posts: 1292
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Next

Return to Hardware

Who is online

Users browsing this forum: No registered users and 12 guests

fashionable