Jump to content


Photo

S/PDIF output on NanoPI M1


  • Please log in to reply
No replies to this topic

#1 AndrewK

AndrewK

    Newbie

  • Senior Members
  • Pip
  • 1 posts

Posted 23 August 2016 - 10:09 PM

Here is a short instruction how to enable S/PDIF digital audio output on NanoPI M1 board running Debian Jessie with legacy kernel. 
This instruction can be applied to other H3 based boards but connect S/PDIF output hardware to GPIOA17 can be tricky (soldering miniature camera connector pins).
Operations can be done over serial console or ssh.
 
  • Login as root
  • Get a .fex file and open it in editor:
bin2fex /boot/script.bin /tmp/script.fex
nano /tmp/script.fex
  • Search a csi0 (camera) section an disable it:
[csi0]
vip_used = 0
  • Search a S/PDIF section and enable it:
[spdif0]
spdif_used = 1
  • Get the name of the file pointed by the /boot/script.bin link and convert modified .fex to it:
ls -la /boot/script.bin
----- /boot/script.bin -> bin/nanopim1.bin
fex2bin /tmp/script.fex /boot/bin/nanopim1.bin
  • Open /etc/modules to instruct Jessie to load S/PDIF modules at boot:
nano /etc/modules
  • Add module names near the end of file:
sunxi_spdif 
sunxi_spdma  
sndspdif  
sunxi_sndspdif
  • Reboot system:
sync
reboot
  • After reboot login as root again
  • Get the list of ALSA devices available:
aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sndcodec-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: sndspdif [sndspdif], device 0: SUNXI-SPDIF sndspdif-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0

 

To connect board S/PDIF output to my favorite DAC i use an optical S/PDIF module soldered out from dead DVD player:

 

module.jpg

 

There are 3 wires connected to board 40-pin connector: GND (pin 6), VDD_5V (pin 2) and SPDIF-OUT/GPIOA17 (pin 26)

 

wiring.jpg

 

Module pinout can be found in datasheet http://www.mouser.co...otx177(f,t).pdf

 

Modules come in 2 types: 6-MBit (up to 24 bit / 96KHz) and 15-MBit (up to 24 bit / 192KHz). Most likely from DVD or SAT receiver You get the 6-MBit module. 15-MBit modules can be purchased at Digikey, etc.

 

When listening to music, I faced with spontaneous fadings. This is due to some problem of the CPU speed switching. To this do not happen, I banned the clock frequency of 240 MHz in the /etc/default/cpufrequtils:

MIN_SPEED=480000

  • tkaiser, zador.blood.stained, Da Alchemist and 1 other like this