Problems with PWM Sound output on RPi Zero W

  • Hi to all of you!

    I'm just new to LibreELEC 8.0.1 official build (used OpenELEC before on a ITX PC Board) and wanted to set up a second system on an RPi Zero W.

    Everything is fine so far, but I'm having problems getting PWM Output working on the Zero.

    What I've done so far:

    Altered the config.txt with the following lines:

    Most likely the 'dtparam=audio=on' isn't needed at all, nevertheless I've tested a lot of stuff in the meanwhile.
    (Lirc is working as expected - Picture is fine on PAL TV)
    I've soldered my band-pass to the according pins.

    As I don't hear anything I've started to try to debug the system.

    So basically the drivers seems to be loaded.

    Therefor I've additionally checkedthe gpio assignment:

    Code
    LibreELEC:~ # cat /sys/kernel/debug/gpio
    gpiochip0: GPIOs 0-53, parent: platform/20200000.gpio, pinctrl-bcm2835:
     gpio-47  (                    |?                   ) out lo

    Mhh - wondering a little bit ..... the lirc is working ... but also not there .....

    Check available devices with aplay:

    Basically looks good .....

    Now I've tried to playback some sounds with aplay.

    Code
    LibreELEC:~ # aplay -Dhw:0,0 /usr/share/kodi/addons/resource.uisounds.kodi/resources/notify.wav
    Playing WAVE '/usr/share/kodi/addons/resource.uisounds.kodi/resources/notify.wav' : Signed 16 bit Little Endian, Rate 32000 Hz, Mono
    LibreELEC:~ #

    NOTHING TO HEAR - this thing is driving me crazy :@

    Maybe a bug / short in my filters?
    Written some small bash script ....

    Testing - I HEAR SOME NOISE .... so the HW seems to be fine.

    So I've NO idea how to ge further .....
    (For sake of completeness I've attached the dmesg)

    Basically I can set up a full distro and try some tests with that .....
    But this could easily cost me hours more ....

    So - does anybody has working PWM Sound with LibeELEC 8.0.1 on a Pi Zero?

    Thanks in advance for your help!!

    cu
    Thomas


  • Can you just confirm that you have selected analogue audio output (rather than hdmi) in system/audio settings?

    Yes - or most likely I'm pretty sure. I can test again.
    At the moment the selection is on HDMI & Analog.
    This definitely don't work.
    Nevertheless: Should I not be able to playback with aplay?
    At least the device is not blocked

    Cu
    Thomas

  • aplay will output to the default device, which will be hdmi if a hdmi display supporting audio is attached (is it?)
    You can force pwm output with:

    Code
    amixer cset numid=3 1

  • So - does anybody has working PWM Sound with LibeELEC 8.0.1 on a Pi Zero?

    Same problem here =(

    Tried to add

    "hdmi_ignore_edid_audio=1
    hdmi_force_edid_audio=0
    dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4"

    to my config.txt - no sound at all.

  • Same problem here =(

    Tried to add

    "hdmi_ignore_edid_audio=1
    hdmi_force_edid_audio=0
    dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4"

    to my config.txt - no sound at all.

    Good to hear that I'm not alone ....
    Bad to hear that it doesn't seems to be my fault.

    I've tried the different sound settings in Kodi in the meanwhile :

    Analog -> no sound
    HDMI & Analog -> no sound

    If any more logs are required I can provide.

    HDMI I've not tested till now (will not be able to do this before tomorrow (have 3.5 year old twins that are awake in the meanwhile) - hopefully tomorrow morning.

    Everything else woks fine in the meanwhile - except for sound (via PWM).

  • I've done some more tests in the meanwhile:

    1.) Sound via HDMI is working as expected.
    2.) Using 'dtoverlay=pwm,pin=13,func=4' (for mono output instead stereo) -> ALSO NO SOUND

    So it seems to be more a general pwm problem instead of something related to the stereo one.

  • My colleague Phil has testes the pwm-2chan overlay on a Pi0W and it is working.

    Can you try removing "audio_pwm_mode=2"?
    I don't think that is the problem, but it is a non-standard option that should be ruled out.

    Can you try running raspi-gpio. Here is version from raspbian that should work on LE
    uc?id=0B-6zmEDJwxZEY1RXb0ZpNi04VEU&export=download

    Report output of "./raspi-gpio get" with the pwm-2chan overlay present.


  • My colleague Phil has testes the pwm-2chan overlay on a Pi0W and it is working.

    Can you try removing "audio_pwm_mode=2"?
    I don't think that is the problem, but it is a non-standard option that should be ruled out.

    Can you try running raspi-gpio. Here is version from raspbian that should work on LE
    uc?id=0B-6zmEDJwxZEY1RXb0ZpNi04VEU&export=download

    Report output of "./raspi-gpio get" with the pwm-2chan overlay present.

    Hi popcornmix,

    thanks for reporting!
    Good to know that the problem is on my side :D

    I'm pretty sure that I've also tested without having the "audio_pwm_mode=2" in config.txt (put this in during my tests to solve the problem) ... but I'll test again.

    It might took till tomorrow morning (also the gpio test) .... (Pi is at home, I'm at work)

    Thanks a lot!

  • So I've done some more ...

    I've used raspi-gpio to get the status of the different gpios:

    Mhhh ---- the GPIO18 and 13 are not configured for PWM ....

    So I've give it a try:

    Code
    LibreELEC:~ # /flash/raspi-gpio set 18 a5
    LibreELEC:~ # /flash/raspi-gpio set 13 a0

    And ... I've been able to play sound with aplay (after amixer).....

    But it's not a real solution ... as the root is squashfs and ro I can not alter the filesystem .....
    I would have to do it by my own ....
    Will be overwritten by the next update .....

    Not a solution :@

    So I've looked for something different .... and found it:

    pwm-audio-pizero/pwm-audio-pi-zero-overlay.dtbo at master · ian57/pwm-audio-pizero · GitHub

    I've added the file to the overlay directory and used it by adding:

    Code
    dtoverlay=pwm-audio-pi-zero-overlay

    And now it works :D

    I've no real idea why the pwm-2chan.dtbo doesn't work, but this solution works and is update resistant.

    Thanks a lot for your help!

    Edited once, last by THaase (April 11, 2017 at 5:02 PM).