tutorial S/PDIF output on NanoPI M1

1 post in this topic

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:
vip_used = 0
  • Search a S/PDIF section and enable it:
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:
  • Reboot system:
  • 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:




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




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:


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Support the project

    We need your help to stay focused on the project.

    Choose the amount and currency you would like to donate in below.