4 4
Stefan Huus Gregersen

Orange Pi Zero I2S

Recommended Posts

Hello folks,
 

Been working on making I2S dacs work on the Orange Pi Zero, after reading on a few pages i got crazy and almost gave up and then i did some playaround and managed to make it work! And this is how i did!
I am using examples from the topic here, as it was well written until i had to figure things out myself because of that stupid wifi_enable on PA20 which also is the data out on the OPI zero
Thread: https://forum.armbian.com/topic/759-i2s-on-orange-pi-h3/


First up it requires a bit of soldering, removing the R69 and adding a small wire is required to access the DIN(data in) or so called PA20. What i did was just simply adding a header so i can just connect it there as shown
IMG_20171225_002009.jpg20171225_001649.jpg
 

After you have added the resistor it is time to wire up the device.  For my example im using the PCM5102 board as example. You can buy it really cheap on Aliexpress and ebay!

pinout.png

Afterwards it is time to configure the device. Start by entering the script file

cd /boot
sudo bin2fex script.bin script.fex
sudo nano script.fex

Then we'll have to change the following
 

[twi1]
twi_used = 1

to
 

[twi1]
twi_used = 0

and 

[pcm0]
daudio_used = 0

to 

[pcm0]
daudio_used = 1

Then the part that i have discovered 
Because of the PA20 is used to enable the wifi it would not work with the sound card unless you change the PA20 to another pin so now we'll have to do the following
Find the following and change it:

[smc_para]
smc_used =
smc_rst = port:PA09<2><default><default><default>
smc_vppen = port:PA20<3><default><default><default>

Change it to

smc_vppen = port:PA02<3><default><default><default>

Find 
 

[module_para]
module_power0 = port:PA20<1><default><default><0>

Change it to 
 

[module_para]
module_power0 = port:PA02<1><default><default><0>

Then there is another SMC_Para hidden, the only difference is that it is SMC_USED = 0 where the other is SMC_used = 
 

[smc_para]
smc_used = 0
smc_rst = port:PA09<2><default><default><default>
smc_vppen = port:PA20<3><default><default><default>

And to
 

[smc_para]
smc_used = 0
smc_rst = port:PA09<2><default><default><default>
smc_vppen = port:PA02<3><default><default><default>



That should be it! Save your file and run the last command needed!

sudo fex2bin script.fex script.bin

You can test the audio by using the following command

speaker-test -twav -c2 -Dhw:1

I am still working on figuring out how to change the default audio device to the I2S. I am a noob in Linux, i am more a hardware man than a software man :P
I hope you guys manage to make it work! 
 

Share this post


Link to post
Share on other sites

And to change the default output device:
Do the following open asound
 

nano /etc/asound.conf

Add the following code
 

pcm.!default {
        type hw
        card 1
}

and save, no need to restart
You have now a full functional DAC to your OPI Zero

Share this post


Link to post
Share on other sites

Still working on increasing the frequency to 192KHz and 32 sample resolution as the Datasheet of the H3 says it support. I might need to get my hands on some audio files that support the maximum output to test it. I am currently using mpg123 to play the audio but not sure about it it has limits.. 

Share this post


Link to post
Share on other sites
(edited)

Excellent article! Although I think this may only work with the earlier revision of the board. Take a gander at my v1.4; seems the manufacturers *really* don't want DA20/i2c PA20/i2s being accessed on the newer OPi zero :(

 

IMG_0347.jpg

Edited by Jeremy Lake
typos

Share this post


Link to post
Share on other sites
2 hours ago, Jeremy Lake said:

Excellent article! Although I think this may only work with the earlier revision of the board. Take a gander at my v1.4; seems the manufacturers *really* don't want DA20/i2c being accessed on the OPi zero :(

 

IMG_0347.jpg

Oh.. I see, i will look into that for you :) 
Edit:
Oh man.. hey completely removed that resistor and the access to the PA20 after version 1.1. What you can do tho is modifying the USB_detect for CN1(The micro usb). It has a 1K resistor but as the Schematics for version 1.4 is not available unless hidden somewhere. I will have to look into that mod and have a look at it!

Share this post


Link to post
Share on other sites
7 minutes ago, Stefan Huus Gregersen said:

Oh.. I see, i will look into that for you :) 
Edit:
Oh man.. hey completely removed that resistor and the access to the PA20 after version 1.1. What you can do tho is modifying the USB_detect for CN1(The micro usb). It has a 1K resistor but as the Schematics for version 1.4 is not available unless hidden somewhere. I will have to look into that mod and have a look at it!

Can you do me a favor and take another picture of the backside? 

Share this post


Link to post
Share on other sites
On 09/01/2018 at 11:28 PM, Stefan Huus Gregersen said:

Can you do me a favor and take another picture of the backside? 

IMG_0370.jpg

Thanks for taking the time to look at this.

 

I went hunting for the schematics, but the signup page to download them is currently throwing 500 errors.

Share this post


Link to post
Share on other sites
On 11/1/2018 at 2:52 PM, Jeremy Lake said:

Thanks for that. I think earlier in this post I meant PA20 and I2S (in case someone else reads this text and gets confused).

Hmm.. Not alot to work with sadly, if i had it here i would be able to find the resistor but it is a bit hard. It is called R157 and is a part of the other data bus so you could use that instead 

Share this post


Link to post
Share on other sites
On 16/01/2018 at 8:18 AM, Stefan Huus Gregersen said:

Hmm.. Not alot to work with sadly, if i had it here i would be able to find the resistor but it is a bit hard. It is called R157 and is a part of the other data bus so you could use that instead 

Thanks all the same.

Share this post


Link to post
Share on other sites
On 12/25/2017 at 12:29 AM, Stefan Huus Gregersen said:

Hello folks,
 

Been working on making I2S dacs work on the Orange Pi Zero, after reading on a few pages i got crazy and almost gave up and then i did some playaround and managed to make it work! And this is how i did!
I am using examples from the topic here, as it was well written until i had to figure things out myself because of that stupid wifi_enable on PA20 which also is the data out on the OPI zero
Thread: https://forum.armbian.com/topic/759-i2s-on-orange-pi-h3/


First up it requires a bit of soldering, removing the R69 and adding a small wire is required to access the DIN(data in) or so called PA20. What i did was just simply adding a header so i can just connect it there as shown
IMG_20171225_002009.jpg20171225_001649.jpg
 

After you have added the resistor it is time to wire up the device.  For my example im using the PCM5102 board as example. You can buy it really cheap on Aliexpress and ebay!

pinout.png

Afterwards it is time to configure the device. Start by entering the script file


cd /boot
sudo bin2fex script.bin script.fex
sudo nano script.fex

Then we'll have to change the following
 


[twi1]
twi_used = 1

to
 


[twi1]
twi_used = 0

and 


[pcm0]
daudio_used = 0

to 


[pcm0]
daudio_used = 1

Then the part that i have discovered 
Because of the PA20 is used to enable the wifi it would not work with the sound card unless you change the PA20 to another pin so now we'll have to do the following
Find the following and change it:


[smc_para]
smc_used =
smc_rst = port:PA09<2><default><default><default>
smc_vppen = port:PA20<3><default><default><default>

Change it to


smc_vppen = port:PA02<3><default><default><default>

Find 
 


[module_para]
module_power0 = port:PA20<1><default><default><0>

Change it to 
 


[module_para]
module_power0 = port:PA02<1><default><default><0>

Then there is another SMC_Para hidden, the only difference is that it is SMC_USED = 0 where the other is SMC_used = 
 


[smc_para]
smc_used = 0
smc_rst = port:PA09<2><default><default><default>
smc_vppen = port:PA20<3><default><default><default>

And to
 


[smc_para]
smc_used = 0
smc_rst = port:PA09<2><default><default><default>
smc_vppen = port:PA02<3><default><default><default>



That should be it! Save your file and run the last command needed!


sudo fex2bin script.fex script.bin

You can test the audio by using the following command


speaker-test -twav -c2 -Dhw:1

I am still working on figuring out how to change the default audio device to the I2S. I am a noob in Linux, i am more a hardware man than a software man :P
I hope you guys manage to make it work! 
 

 

Stefan kindly share link for the i2s dac aliexpress. I think i had 1 of these

 

Share this post


Link to post
Share on other sites
On 15.01.2018 at 10:18 PM, Stefan Huus Gregersen said:

Hmm.. Not alot to work with sadly, if i had it here i would be able to find the resistor but it is a bit hard. It is called R157 and is a part of the other data bus so you could use that instead 

I have correctly understood to connect DAC I need to remove R157 and on his place to solder a wire?

 

pcb.png

Share this post


Link to post
Share on other sites
9 hours ago, leonidy-85 said:

I have correctly understood to connect DAC I need to remove R157 and on his place to solder a wire?

 

pcb.png

Good job mate! Now it is just about finding out where things are connected, it sadly requires a multimeter next step.
Above R157 there is a resistor called R40, to find out which leg we'll use as data out for the DAC you'll have to measure which pad of the two resistors have a connection, as seen on the USB plug R40 puts R157 to 3.3v. When you know which pad is 3.3v please inform me and next step would be to remove R157 and solder a wire to it so you can connect it to your DAC.. Man i wish i had a newer board so i could try it out..
image.thumb.png.e335e7067da96db7b45445098820e697.png

Share this post


Link to post
Share on other sites

Got it, I'll call and take a picture of macro. Do I understand correctly that i need to the right (under the scheme) point R157 connect and desolder the resistor? R40 desoldering it is desirable to not have voltage on contact from?

Share this post


Link to post
Share on other sites
On 22/2/2018 at 1:27 PM, andrikll said:

Got it, I'll call and take a picture of macro. Do I understand correctly that i need to the right (under the scheme) point R157 connect and desolder the resistor? R40 desoldering it is desirable to not have voltage on contact from?

Exactly! The reason is for not having a connection to the USB plug :) 

Share this post


Link to post
Share on other sites

Just the difficulty of understanding the translation.

1519470531000700323333.thumb.jpg.03d0744a4baa51de93a5726304fe633d.jpg

I'm not sure those are the resistance. I am attaching the measurements, as well isvery top point r65 r68 Inn on the diagram are not soldered) here there is 12.2 K and 1.3 K to 3.3v point. May indicate the source of the schemes and there are different generations at version1.4 Board?

Share this post


Link to post
Share on other sites
11 hours ago, andrikll said:

Just the difficulty of understanding the translation.

1519470531000700323333.thumb.jpg.03d0744a4baa51de93a5726304fe633d.jpg

I'm not sure those are the resistance. I am attaching the measurements, as well isvery top point r65 r68 Inn on the diagram are not soldered) here there is 12.2 K and 1.3 K to 3.3v point. May indicate the source of the schemes and there are different generations at version1.4 Board?

Can you measure which leg at R157 is connected to 3v3?; Leg A or B? 

Share this post


Link to post
Share on other sites
11 hours ago, leonidy-85 said:

you about it?
 

photo_2018-02-25_12-06-18.jpg

I know i know, it is written in the diagram, but i wanna know which exact leg is connected to R40 and which exact is connected to the GPIO so i can make some documentation about 
If you look at the picture where you wrote a,b,c,d and so on each pad, can you tell me which pad is NOT connected to R40, that leg is the GPIO which you need to solder a wire to 

Share this post


Link to post
Share on other sites

And i just realized the resistor is on my own, currently just creating an Armbian from the start to make sure everything goes simple for me
Removed the resistor and the leg on the resistor where the GPIO is placed is "B" if i refer back to your drawing; 
 IMG_9832.JPG.8212d8a2adb6a707746500c89bb30c88.JPG

Share this post


Link to post
Share on other sites

So time for a sad update.. About I2s on the newer boards

I thought that the I2s was placed on a single bus with more outputs but they are on seperate buses so that means to use PCM1 we'll have to have access to 2 other GPIO's where one of them is unused so we cannot access it, that GPIO is PG11 aka CSI_EN and it is not descriped where it goes anywhere in the diagram so i cannot rework anything.. GODAMMIT WE WERE SO CLOSE... 
MAN i swear the designers of the Orange pi's really kills the idea of overruling Reaspberry PI.. They really need some proper designers to tell them what could make their boards awesome
Oh well it is 1000 times simpler to do on a Orange pi One, it is almost plug and play! 

Share this post


Link to post
Share on other sites

No questions. Maybe I'll try to still connect there led desolder resistor and adding1Kom from led? Just blinking, suddenly working? 

A few hours later. In General, I guess what I do not so the house was measured or tester battery hooked. Soldered to contact USB (4-point-plus and 2 from GND) in my work.  All true as on the picture leonidy-85.  Then can I continue?

Share this post


Link to post
Share on other sites
11 hours ago, andrikll said:

No questions. Maybe I'll try to still connect there led desolder resistor and adding1Kom from led? Just blinking, suddenly working? 

A few hours later. In General, I guess what I do not so the house was measured or tester battery hooked. Soldered to contact USB (4-point-plus and 2 from GND) in my work.  All true as on the picture leonidy-85.  Then can I continue?

As mentioned in my last comment it is not possible to get I2S to work on the newer boards

Share this post


Link to post
Share on other sites

I thought it was because I didn't find the right resistors... could you tell me where to read about it?

.....read the message again, I understand you saw a diagram where not divorced this contact?

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
4 4