Jump to content
  • 0

Nanopi m4 audio I2S output on GPIO


xaled
 Share

Question

Hi,

 

I want to use the I2S GPIO output pins on Nanopi m4 to connect to multi channel DAC. Unfortunately I can not see it as a playback device:

 

user@nanopim4:/home$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: realtekrt5651co [realtek,rt5651-codec], device 0: ff890000.i2s-rt5651-aif1 rt5651-aif1-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: rockchiphdmi [rockchip,hdmi], device 0: ff8a0000.i2s-i2s-hifi i2s-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
 

Is there a way to enable I2S output on GPIO?

 

36 | I2S0_SDO0(1.8V)
37 | I2S0_SDI1SDO3(1.8V)
38 | I2S0_SDI2SDO2(1.8V)
39 | GND
40 | I2S0_SDI3SDO1(1.8V)

 

user@nanopim4:/home$ cat /etc/armbian-image-release 
# PLEASE DO NOT EDIT THIS FILE
BOARD=nanopim4
BOARD_NAME="NanoPi M4"
BOARDFAMILY=rk3399
BUILD_REPOSITORY_URL=https://github.com/armbian/build
BUILD_REPOSITORY_COMMIT=1221d592
VERSION=5.95
LINUXFAMILY=rk3399
BRANCH=default
ARCH=arm64
IMAGE_TYPE=stable
BOARD_TYPE=conf
INITRD_ARCH=arm64
KERNEL_IMAGE_TYPE=Image
IMAGE_UUID=aa7287f5-d3a9-444e-b198-e24e2ed8aa1f
 

Edited by xaled
Added system info
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi,

after some trials and errors, I was able to enable I2S0 interface and using the GPIO pins to record with a MEMs microphone.

 

I am using armbian OS image with current kernel (5.3.11+) and ubuntu 18.04, I built it using armbian documentation (https://docs.armbian.com/Developer-Guide_Using-Vagrant/). I am using SD card.

The board takes some time before booting  up with this image, but it works.

 

After getting the SD card ready, I went to the /boot directory and decompiled the device tree used by boot-loader (in my case, the file is rk3399-nanopi-m4.dtb).

 

dtc -I dtb -o <filename>.dts -<filename>.dtb

To check which device tree is loaded by the boot-loader, check the file armbianEnv.txt in the /boot directory (check the name of the fdtfile).

You need to modify the device tree as follows:

 

  • Go to I2S0 node and add the following two lines

  pinctrl-names = "default";
  pinctrl-0 = < 0x96 >;

  i2s@ff880000 {
        compatible = "rockchip,rk3399-i2s\0rockchip,rk3066-i2s";
        reg = < 0x00 0xff880000 0x00 0x1000 >;
        rockchip,grf = < 0x18 >;
        interrupts = < 0x00 0x27 0x04 0x00 >;
        dmas = < 0x5c 0x00 0x5c 0x01 >;
        dma-names = "tx\0rx";
        clock-names = "i2s_clk\0i2s_hclk";
        clocks = < 0x08 0x56 0x08 0x1d4 >;
        power-domains = < 0x17 0x1c >;
        #sound-dai-cells = < 0x00 >;
        pinctrl-names = "default";
        pinctrl-0 = < 0x96 >;
        rockchip,playback-channels = <8>;
        rockchip,capture-channels = <8>;
        status = "okay";
        phandle = < 0x10d >;

	};

Check that the status of  driver is "okay" and not disabled.

  • You have then to register a simple-sound-card and link it to the i2s driver by phandle (the device tree pointer)
rockchip-i2s-sound {
		compatible = "simple-audio-card";
		simple-audio-card,format = "i2s";
		simple-audio-card,name = "rk3399-i2s";
		simple-audio-card,mclk-fs = < 0x100 >;
		status = "okay";
		phandle = < 0x153 >;

		simple-audio-card,cpu {
			sound-dai = < 0x10d > ;
		};

		simple-audio-card,codec {
			sound-dai = < 0x10d >;
		};
		
	};
  • After you changed the devite tree, recompile it by running the command line
    dtc -I dts -o <filename>.dtb -<filename>.dts

    After that, reboot and check ALSA list of devices. You should see it listed as "rk3399-i2s".

 

Link to comment
Share on other sites

Armbian is a community driven open source project. Do you like to contribute your code?

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...