Audio ADC to I2S Data In, Odroid N2, is it possible?

Post Reply
stepy
Posts: 16
Joined: Tue Sep 10, 2019 11:12 pm
languages_spoken: english
ODROIDs: Odroid C2, N2, VU7
Has thanked: 8 times
Been thanked: 1 time
Contact:

Audio ADC to I2S Data In, Odroid N2, is it possible?

Unread post by stepy » Mon Jan 06, 2020 12:34 am

Hi,

The Odroid N2 has an external pin header (J7) that can be connected to an audio device that supports SPDIF or I2S.

see link,

https://wiki.odroid.com/odroid-n2/appli ... ector/7pin

If I am not mistaken, this sends out the three I2S clocks:

MCLK, LRCLK and SCLK.

and the I2S

Data Output.

My question,

Is it possible to use J7 - Pin 7, as a Data Input, instead of a Data Output?

If Yes, then how do you re-configure J7 - Pin 7, as an input?


The reason for the question, is that I wish to connect an Audio I2S ADC, for audio input and use the built in DAC for audio output. Do not wish to use a USB ADC.

Any help or suggestions would be very much appreciated, thanks.

User avatar
odroid
Site Admin
Posts: 33043
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 296 times
Been thanked: 418 times
Contact:

Re: Audio ADC to I2S Data In, Odroid N2, is it possible?

Unread post by odroid » Mon Jan 06, 2020 11:09 am

GPIOA_BIT4 pin seems to have the I2S_DATA_IN function.
Check our schematics and S922X datasheet carefully to modify the kernel sound drivers and devicetree intensively.
These users thanked the author odroid for the post:
stepy (Tue Jan 07, 2020 4:10 am)

stepy
Posts: 16
Joined: Tue Sep 10, 2019 11:12 pm
languages_spoken: english
ODROIDs: Odroid C2, N2, VU7
Has thanked: 8 times
Been thanked: 1 time
Contact:

Re: Audio ADC to I2S Data In, Odroid N2, is it possible?

Unread post by stepy » Tue Jan 07, 2020 4:10 am

Hi,

Thanks very much for your reply and valuable information.

Studied the schematics and S922X datasheet.

HARDWARE
If I understand it correctly, the four wire, I2S connections, for an I2S Audio DAC PCB, or for an Audio I2S ADC PCB, could be as follows:

Odroid N2, to I2S Audio DAC PCB

Odroid N2,

Connector J7
Pin 4 I2S MCLK ---------------> DAC
Pin 5 I2S LRCLK --------------> DAC
Pin 6 I2S SCLK ----------------> DAC
Pin 7 I2S DATA OUTPUT ----> DAC

I2S Audio ADC PCB, to Odroid N2

Odroid N2,

Connector J7
Pin 4 I2S MCLK ---------------> ADC
Pin 5 I2S LRCLK --------------> ADC
Pin 6 I2S SCLK ----------------> ADC
Pin 7 I2S DATA OUTPUT ----> not used

Connector J2
GPIOA 4 I2S_DIN <------------ ADC

Is this correct?

SOFTWARE
In the example above, Odroid N2 ---> I2S --->DAC, what is required to get the signals to appear on the J7 connector?

Using alsa utils, aplay -l gives
*** List of PLAYBACK Hardware Devices ****
card 0: AMLAUGESOUND [AML-AUGESOUND], device 0: SPDIF-B-dit-hifi dit-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: AMLAUGESOUND [AML-AUGESOUND], device 1: TDM-C-T9015-audio-hifi T9015-audio-hifi-1 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: AMLAUGESOUND [AML-AUGESOUND], device 2: SPDIF-dit-hifi dit-hifi-2 []
Subdevices: 1/1
Subdevice #0: subdevice #0

and this is described in this link

https://wiki.odroid.com/odroid-n2/appli ... note/sound

as follows:
card 0: device 0: s922X spdif_B – hdmitx audio – HDMI out
card 0: device 1: s922X I2S – Internal audio DAC – audio driver(DIO2133) – 3.5pi audio jack
card 0: device 2: s922X spdif – spdif out – spdif out (GPIOA_11, ext_con J7-pin2)

Only Connector J7-pin 2 is mentioned.

Also at the bottom of the page there is a link, Device tree example for enabling the I2S bus on 7-pin header

viewtopic.php?f=180&t=35886&p=265742#p265742

Had a look at the .diff file, also had a look at the source file, that it refers to, but found it too complicated to piece all the fragments of code together, in such a way that it is readable, so that I can attempt to understand it. In the source file one can see basically what is going on and how this relates to registers, etc., inside the S922X, but at this low level, am not sure exactly what I should be looking at, or where to find it, or dare I say it, what to edit.

As a first step shall focus on getting I2S out of the Odroid N2, J2 connector, to an oscilloscope. Then after that, attempt to get I2S into the Odroid N2.

How do you get I2S out of an Odroid N2 J2 connector?

I would be very great full for any help or suggestions, thanks.

stepy
Posts: 16
Joined: Tue Sep 10, 2019 11:12 pm
languages_spoken: english
ODROIDs: Odroid C2, N2, VU7
Has thanked: 8 times
Been thanked: 1 time
Contact:

Re: Audio ADC to I2S Data In, Odroid N2, is it possible?

Unread post by stepy » Sat Jan 11, 2020 3:22 am

Hi,

Since my last post, tried the following, in an attempt to get I2S signals out, from an Odroid-N2, J7 external pin header, (Typo correction to my previous post, J2 should have been J7), to an oscilloscope.

Downloaded the zip file, containing a .diff file, from the Device tree example, link above.

Extracted the .diff file.

Created my own Odroid test repo, on github, by making a fork from the Hardkernel repo.

Added the .diff file to the test repo.

Applied the changes, committed the changes.

Compiled a fresh new operating system, from the test repo.

Put the image onto an SD card, put it into an Odroid-N2.

Using alsa utils, aplay -l gives the same result as before:

*** List of PLAYBACK Hardware Devices ****
card 0: AMLAUGESOUND [AML-AUGESOUND], device 0: SPDIF-B-dit-hifi dit-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: AMLAUGESOUND [AML-AUGESOUND], device 1: TDM-C-T9015-audio-hifi T9015-audio-hifi-1 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: AMLAUGESOUND [AML-AUGESOUND], device 2: SPDIF-dit-hifi dit-hifi-2 []
Subdevices: 1/1
Subdevice #0: subdevice #0

Am not sure if putting the .diff file into the test repo and applying the changes, as in the steps above, is accurate or valid. My knowledge of the git version control mechanism is only basic. Anyway, inspecting the relevant source file in the test repo, found that it had been updated in the expected way, and seemed to compile ok.

The bottom line is, it appears, that am still unable to get I2S signals out. There did not seem to be much point in hooking up an oscilloscope to J7 yet, because still stuck on trying to understand the software side.

The question still remains:

How do you get I2S signals out from an Odroid-N2, J7 external pin header?

Any help or examples would be very much appreciated, am completly stuck at present. Thanks

User avatar
odroid
Site Admin
Posts: 33043
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 296 times
Been thanked: 418 times
Contact:

Re: Audio ADC to I2S Data In, Odroid N2, is it possible?

Unread post by odroid » Sat Jan 11, 2020 11:11 am

If the patch was correctly applied, you have to see 4 devices not 3 devices.
Check your updated mesong12_odroid_common.dtsi file carefully.
These users thanked the author odroid for the post:
stepy (Mon Jan 13, 2020 3:42 am)

stepy
Posts: 16
Joined: Tue Sep 10, 2019 11:12 pm
languages_spoken: english
ODROIDs: Odroid C2, N2, VU7
Has thanked: 8 times
Been thanked: 1 time
Contact:

Re: Audio ADC to I2S Data In, Odroid N2, is it possible?

Unread post by stepy » Mon Jan 13, 2020 2:13 am

Hi,

Thanks very much for your help.

You have pin pointed the invalid step, that I did, in the above description, for creating a fresh image onto an SD card.

The way the .dif file was applied above, does not work. Should have figured this out myself, sorry!

Anyway, created a clean new build. Used a different approach for applying the .dif file. This method was easier, because no need to create an Odroid test repo, as described above.

New method:

Added the patch as part of the compile script, built the image, put onto SD card and into Odroid N2.

This time the 4 devices are listed. Yippee!

Did some quick initial tests as follows:

Audio out through the built in DAC:

speaker-test -Dhw:0,1 -c 2 -t wav

This worked, was able to hear sound coming out of the audio out connector.

I2S out through J7 connector:

speaker-test -Dhw:0,3 -c 2 -t wav

Had nothing connected to J7, but the speaker test seemed to run and complete successfully.

So it is looking good up to this point.

Shall do some more detailed testing and post the results, shortly.

Thanks.

stepy
Posts: 16
Joined: Tue Sep 10, 2019 11:12 pm
languages_spoken: english
ODROIDs: Odroid C2, N2, VU7
Has thanked: 8 times
Been thanked: 1 time
Contact:

Re: Audio ADC to I2S Data In, Odroid N2, is it possible?

Unread post by stepy » Mon Jan 13, 2020 3:40 am

As a side note to the above, although have got the .dif file to work, am still a little confused about the .dif file. For example it's origin and version control.

I assume that a clever person, looked at the mesong12_odroid_common.dtsi source file and edited it, therefore creating a new version. Then generated a .dif file from a comparison of the original and the new edited version. Is it possible to find the new edited version?

If you only have the .diff file:

How do you find the original source file that the .dif file refers to? Is it the one in the Hardkernel repo?

How do you accurately generate the new edited version of the file, from the diff file, so that you can view the whole thing?

Where does the .diff file come from, apart from the .zip file on a forum, is it on github?

Also asking a similar question, but the other way around, if one wanted to edit the mesong12_odroid_common.dtsi source file or some other arbitrary source file, then generate a .dif file from it. What is the procedure?

Sorry if the above sounds a little pedantic, but just trying to understand the mechanisms and dependencies involved. There are many features of the Odroid N2 that are very useful, but some do not appear to be usable, straight out of the box, so to speak. So am interested in the recommended tweaking procedures, related to Odroid N2. On the one hand it is a quick and dirty tweak to the operating system, no problem, on the other hand integrity and version control are also important. I guess the version control would be less important if you create an os image that is never going to change after being created. In my case I need to use several different unrelated feature tweaks, it is not possible to anticipate if these will need to change in the future and also need to be able to easily update and rebuild the operating system image, periodically. Alternatively, wait and see if various features get updated and committed to the operating system, but I cannot wait that long.

These are a lot of questions, would be greatfull for any help, suggestions, alternative perspectives, thanks.

stepy
Posts: 16
Joined: Tue Sep 10, 2019 11:12 pm
languages_spoken: english
ODROIDs: Odroid C2, N2, VU7
Has thanked: 8 times
Been thanked: 1 time
Contact:

Re: Audio ADC to I2S Data In, Odroid N2, is it possible?

Unread post by stepy » Mon Jan 27, 2020 4:03 am

Initial Test Results

Play

Connected an oscilloscope to the Odroid N2, I2S pins, connector J7.

Used aplay to play a test.wav file out to I2S pins, connector J7.

The signals look ok. However, only did basic measurements. Do not have access to a logic analyzer at present.

Below is a diagram of the measurements:
odroid_n2_i2s_out_timming_diagram_test_01.png
odroid_n2_i2s_out_timming_diagram_test_01.png (64.53 KiB) Viewed 25 times

Record

Did a similar test with arecord and got similar result to the above.

The recorded_test.wav file, as expected, contained samples with value zero.

Next

Connected a 3.3v pin to the I2S DATA INPUT pin as shown below:

J2 - 2x20 PINS GPIO connector:

Pin 17 3.3V <---------> Pin 26 GPIOA.4 DATA INPUT

Recorded a new file. Would have expected all the samples to now have a value representing 1, or something other than all zeros.

However, all the samples still have a value of zero.

Although there is no ADC connected at present, would have thought that this is a valid test. Please correct me if am mistaken.

Next

Compiled and ran the Odroid N2, GPIO Status Check Program, link below:

https://wiki.odroid.com/odroid-n2/appli ... ck_program

This showed that Pin 26 DATA INPUT was correctly detecting when the pin was high or low. Also gives useful gpio information overview.

Also it shows the Pin 26 Mode as an IN, on the other hand the other I2S pins are all shown as ALT1 Mode. See below:

+------+----------+------+---+-------+--- J2 ---+-------+---+------+----------+------+
| GPIO | Name | Mode | V | PU/PD | Physical | PU/PD | V | Mode | Name | GPIO |
+------+----------+------+---+-------+----++----+-------+---+------+----------+------+
| - | 3.3V | - | - | - | 1 || 2 | - | - | - | 5.0V | - |
| 493 | I2C2_SDA | ALT1 | 1 | P/U | 3 || 4 | - | - | - | 5.0V | - |
| 494 | I2C2_SCL | ALT1 | 1 | P/U | 5 || 6 | - | - | - | GND | - |
| 473 | GPIOA.13 | IN | 0 | P/D | 7 || 8 | P/U | 1 | IN | UARTB_TX | 488 |
| - | GND | - | - | - | 9 || 10 | P/U | 1 | IN | UARTB_RX | 489 |
| 479 | GPIOX.3 | IN | 1 | P/U | 11 || 12 | P/U | 1 | IN | GPIOX_16 | 492 |
| 480 | GPIOX.4 | IN | 1 | P/U | 13 || 14 | - | - | - | GND | - |
| 483 | GPIOX.7 | IN | 1 | P/U | 15 || 16 | P/U | 1 | IN | GPIOX.0 | 476 |
| - | 3.3V | - | - | - | 17 || 18 | P/U | 1 | IN | GPIOX.1 | 477 |
| 484 | MOSI | IN | 1 | P/U | 19 || 20 | - | - | - | GND | - |
| 485 | MISO | IN | 1 | P/U | 21 || 22 | P/U | 1 | IN | GPIOX.2 | 478 |
| 487 | SCLK | IN | 1 | P/U | 23 || 24 | P/U | 1 | IN | SS0 | 486 |
| - | GND | - | - | - | 25 || 26 | P/D | 1 | IN | GPIOA.4 | 464 |
| 474 | I2C3_SDA | ALT2 | 1 | P/U | 27 || 28 | P/U | 1 | ALT2 | I2C3_SCL | 475 |
| 490 | GPIOX.14 | IN | 1 | P/U | 29 || 30 | - | - | - | GND | - |
| 491 | GPIOX.15 | IN | 1 | P/U | 31 || 32 | P/D | 0 | IN | GPIOA.12 | 472 |
| 481 | GPIOX.5 | IN | 1 | P/U | 33 || 34 | - | - | - | GND | - |
| 482 | GPIOX.6 | IN | 0 | P/D | 35 || 36 | - | 0 | IN | GPIOX.19 | 495 |
| - | ADC.AIN0 | - | - | - | 37 || 38 | - | - | - | 1.8V REF | - |
| - | GND | - | - | - | 39 || 40 | - | - | - | ADC.AIN1 | - |
+------+----------+------+---+-------+----++----+-------+---+------+----------+------+
+------+-----------+------+---+-------+--- J7 ---+
| GPIO | Name | Mode | V | PU/PD | Physical |
+------+-----------+------+---+-------+----------+
| - | GND | - | - | - | 1 |
| 471 | GPIOA.11 | ALT1 | 1 | P/D | 2 |
| - | 5.0V | - | - | - | 3 |
| 460 | GPIOA.0 | ALT1 | 0 | P/D | 4 |
| 462 | GPIOA.2 | ALT1 | 0 | P/D | 5 |
| 461 | GPIOA.1 | ALT1 | 0 | P/D | 6 |
| 463 | GPIOA.3 | ALT1 | 0 | P/D | 7 |
+------+-----------+------+---+-------+----------+

Everything seems to be working, but can only record zero, regardless of the state of the I2S data in pin.

How do you get data into this pin?

Would be very greatfull for any help or suggestions, thanks.

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 1 guest