Jump to content

Recommended Posts

Posted
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:

 

post-2010-0-03341000-1471987781_thumb.jpg

 

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

 

post-2010-0-43496600-1471987981_thumb.jpg

 

Module pinout can be found in datasheet http://www.mouser.com/catalog/specsheets/totx177(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
Posted

Okay, mainline kernel is now version 4.11 and H3 S/PDIF driver marked as working. Below is a brief guide on how to enable it.

 

Unlike legacy kernel, in which to configure gpio and device drivers it was necessary to edit the .fex file, in mainline we need device tree overlays.

  • Login as root
  • First we need to find out which device tree is being used. To do this, you must execute:
    cat /proc/device-tree/model; echo

    In my NanoPI M1, for some reason, is used the device tree for OrangePI PC

  • In order to select the correct device tree and an overlay needed to enable the S/PDIF, we need to do some changes in /boot/armbianEnv.txt file.
    Open it in editor (root privilegs required) and add 2 lines:
    fdtfile=sun8i-h3-nanopi-m1.dtb
    overlays=spdif-out

    If you need the driver of the IR receiver and (or) an analog audio codec, you need to add the cir and (or) analog-codec to the overlay list via spaces

  • It's all. Save file, exit editor and execute:
    sync
    reboot

     

  • After reboot login as root again

  • Get the list of ALSA devices available:
    aplay -l
    
    **** List of PLAYBACK Hardware Devices ****
    card 0: SPDIF [On-board SPDIF], device 0: spdif-dit-hifi dit-hifi-0 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0

     


 

  • Igor unpinned this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines