WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Pi Zero PWM sound  (Read 1584 times)

Offline MikkelM

  • WikiUser
  • *
  • Posts: 6
Pi Zero PWM sound
« on: August 28, 2019, 06:10:22 AM »
I am trying to get audio to work over PWM pins, but without luck

I have followed the tricks described here, by setting GPIO pins.

http://forum.tinycorelinux.net/index.php?topic=20550.0

My image (the SDcard) works as intended on an Pi 3 model B

I get this error on the Pi Zero

Code: [Select]
tc@box:~$ aplay -l
aplay: device_list:268: no soundcards found...

Here is my config.txt

Code: [Select]
# For more options and information see
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
# Some settings may impact device functionality. See link above for details

[PI0]
initramfs 9.0.3.gz followkernel
kernel kernel4922.img
cmdline cmdline.txt

[PI1]
initramfs 9.0.3.gz followkernel
kernel kernel4922.img
cmdline cmdline.txt

[PI2]
initramfs 9.0.3v7.gz followkernel
kernel kernel4922v7.img
cmdline cmdline.txt

[PI3]
initramfs 9.0.3v7.gz followkernel
kernel kernel4922v7.img
cmdline cmdline3.txt

[ALL]

#----------------------------------------------------
# Enable peripheral buses

dtparam=i2c=on,spi=on,i2s=on

# Enable serial console

enable_uart=1

[PI3]
dtoverlay=pi3-disable-bt

[ALL]
 dtparam=audio=on
 dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
 gpu_mem=16

Cheers

Mikkel
« Last Edit: August 28, 2019, 06:20:40 AM by MikkelM »

Offline Paul_123

  • Sr. Member
  • ****
  • Posts: 484
Re: Pi Zero PWM sound
« Reply #1 on: August 28, 2019, 12:12:40 PM »
Did you add the appropriate kernel driver.  It is not included by default.

AFAIK, it is not included in any extension, but would be in the module tar package.

Offline MikkelM

  • WikiUser
  • *
  • Posts: 6
Re: Pi Zero PWM sound
« Reply #2 on: August 29, 2019, 06:13:20 AM »
Hi Paul.

Thank you. Can you hint me were to find modular tar package and how to add the right kernel driver.

Yes I am a newbie.

Cheers

Mikkel

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6769
Re: Pi Zero PWM sound
« Reply #3 on: August 29, 2019, 06:22:44 AM »

Offline MikkelM

  • WikiUser
  • *
  • Posts: 6
Re: Pi Zero PWM sound
« Reply #4 on: August 29, 2019, 09:06:46 AM »
Ok, and how do I do it? Do I need to compile a new kernel?
And what do I need to include from the modular package, I can see there is a folder called sound.

I have used the newest build from here http://tinycorelinux.net/9.x/armv6/releases/RPi/

As I mentioned above, it works perfectly with PWM sound on the RPI 3, which I started out to use.

The whole setup is for an art project where we are going to use Pi zeros.

Thanks

Mikkel

Offline Paul_123

  • Sr. Member
  • ****
  • Posts: 484
Re: Pi Zero PWM sound
« Reply #5 on: August 30, 2019, 11:59:06 AM »
I would compare drivers loaded using when everything is working on the Pi3, then again with the zero, and compare.

I have no experience with PWM audio.

Offline MikkelM

  • WikiUser
  • *
  • Posts: 6
Re: Pi Zero PWM sound
« Reply #6 on: September 02, 2019, 02:39:07 AM »
I can see I miss this on the Zero compared to the Pi3
Code: [Select]
snd_bcm2835            23123  0
snd_pcm                97468  1 snd_bcm2835
snd_timer              23881  1 snd_pcm
snd                    70476  3 snd_bcm2835,snd_pcm,snd_timer
I am just swapping the SDcard around on the two boards.

when I write this on the Zero
Code: [Select]
modprobe snd
modprobe: module snd not found in modules.dep
I get no failure on the Pi3.

But the PiZero and Pi3 is loading different kernels in the config.txt, and the lib/modules are way different.

Any ideas?

Cheers

Mikkel
« Last Edit: September 02, 2019, 03:06:33 AM by MikkelM »

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6769
Re: Pi Zero PWM sound
« Reply #7 on: September 02, 2019, 04:23:38 AM »
Hi MikkelM
If you unpack:
http://tinycorelinux.net/9.x/armv6/releases/RPi/src/kernel/4.9.22-piCore_modules.tar.xz
you'll find it contains:
Code: [Select]
lib/modules/4.9.22-piCore/kernel/sound/core/snd.ko
lib/modules/4.9.22-piCore/kernel/sound/core/snd-timer.ko
lib/modules/4.9.22-piCore/kernel/sound/core/snd-pcm.ko
lib/modules/4.9.22-piCore/kernel/sound/arm/snd-bcm2835.ko
You'll need to either copy them to  /lib  and back them up or create an extension out of them.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6769
Re: Pi Zero PWM sound
« Reply #8 on: September 02, 2019, 04:50:27 AM »
Hi MikkelM
I'm not certain, but you may also need to run:
Code: [Select]
sudo depmodafter adding the files to the file system.

Offline MikkelM

  • WikiUser
  • *
  • Posts: 6
Re: Pi Zero PWM sound
« Reply #9 on: September 02, 2019, 06:58:14 AM »
Hi Rich.

I have copied the files and ran the depmod command, but how do I get the files to stay in the /lib folder.

Or simply how do I add the needed modules to the Kernel package.

It seems I am getting closer.

Thanks.

Mikkel

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6769
Re: Pi Zero PWM sound
« Reply #10 on: September 02, 2019, 01:32:51 PM »
Hi MikkelM
After copying the files to  /lib  you could add the following lines to  /opt/.filetool.lst:
Code: [Select]
lib/modules/4.9.22-piCore/kernel/sound/core/snd.ko
lib/modules/4.9.22-piCore/kernel/sound/core/snd-timer.ko
lib/modules/4.9.22-piCore/kernel/sound/core/snd-pcm.ko
lib/modules/4.9.22-piCore/kernel/sound/arm/snd-bcm2835.ko
and then run a backup like this:
Code: [Select]
filetool.sh -b

Offline MikkelM

  • WikiUser
  • *
  • Posts: 6
Re: Pi Zero PWM sound
« Reply #11 on: September 03, 2019, 01:10:14 AM »
Yeah. It works.
My bootlocal is somehow a mess now
Code: [Select]
depmod
and then modprobe to the individual modules
amixer cset numid=3 1
gpio -g mode 18 ALT5
gpio -g mode 13 ALT0

Are there anyway to use dtoverlay when loading drivers?

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6769
Re: Pi Zero PWM sound
« Reply #12 on: September 03, 2019, 03:20:37 AM »
Hi MikkelM
You shouldn't need to  "modprobe the individual modules".  Try:
Code: [Select]
modprobe snd-bcm2835Since  snd-bcm2835  depends on the other 3 modules,  modprobe  should be loading the other 3 automatically.

Offline Paul_123

  • Sr. Member
  • ****
  • Posts: 484
Re: Pi Zero PWM sound
« Reply #13 on: September 03, 2019, 07:32:35 AM »
Are you sure you loaded the alsa-modules-KERNEL.tcz package.

When you download the sound stuff on your RPI 3, it would have only downloaded the package for the armv7 boards.