volumio / Build

Buildscripts for Volumio System
GNU General Public License v2.0
113 stars 103 forks source link

Introduce kernel module for WaveShare WM8960 Audio HAT #512

Closed hftsai256 closed 3 years ago

hftsai256 commented 3 years ago

WaveShare didn't provide pre-built binaries for raspberry pi and therefore I took their source code and patch it up to build required kernel modules under device_chroot_tweaks_post().

I wonder running full volumio kernelsource command is an overkill because I only need headers to build dkms modules. Also, this is a quick-and-dirty hack for demonstration purpose, so please advice if there's a better place for it.

My magic line to /volumio/app/plugins/system_controller/i2s_dacs/dacs.json is:

{"id":"wm8960-soundcard","name":"Waveshare - WM8960","overlay":"wm8960-soundcard,i2s-mmap","alsanum":"1","mixer":"","modules":"","script":"","i2c_address":"1a","needsreboot":"yes"},

Thanks, Halley

hftsai256 commented 3 years ago

After several tries this script can build modules, but is having trouble to install it properly. The HAT is not enabled on a freshly built image:

volumio@voluzero:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
volumio@voluzero:~$ sudo dkms status
[sudo] password for volumio: 
wm8960-soundcard, 1.0: added

However, follow the flow and re-run the install.sh script again will stage those files properly. Is this a QEMU thing? I'm not quite familiar with it.

ashthespy commented 3 years ago

Thanks for this PR @hftsai256 -- but normally we don't build kernel modules/DAC firmware in the image builder.

Ideally firmware is compiled once for each kernel version, and then just fetched by the image builder on each run.. See here how other repos are structured to get an idea: https://github.com/volumio/Build/blob/bc89b476e25e385d3cf4c9155471e47f5934028e/recipes/devices/pi.sh#L164-L170

And then the firmware tarballs are just fetched and added to the image: https://github.com/volumio/Build/blob/bc89b476e25e385d3cf4c9155471e47f5934028e/recipes/devices/pi.sh#L229-L238