Retasking a 2nd Gen Echo

Thanks for your reply!

I’ve soldered a wire from a large ground test point to connect to the ESP. Do you think that’s sufficient? I tried to clamp it onto the spring pins, but they’re quite fragile and I didn’t want to damage them.

I perform a reset before configuring the TLVs, and after writing the registers I also verify that they’re set correctly.

Make sure any TLV you are not using are not writing anything onto the data bus (made that mistake more than once).

I assumed that should be handled by setting TDM mode on the TLVs. However, I also disabled one of the TLVs as a test and I’m still experiencing the same issue.

If you are setting a D-VAL (Page 0 registers 7 and 8) make sure you do the MSB immediately followed by the LSB. The linux driver does it the wrong way around. This won’t cause a problem if your DVAL is zero.

Enable 3-stating for DOUT (Page 0 register 27)

Finally, with a Pi and a 2nd Gen I’ve found that with the Pi as Bit and Word clock master I don’t get distortion but I do when the TLV is set as Bit and Word clock master. I suspect I have something wrong with my hardware setup rather than it being a TLV problem.

Thanks for these tips—I need to investigate your suggestions more thoroughly and I’m going to test them. In the meantime, I’ve experimented with various settings and now instead of distorted audio I’m getting a “Mickey Mouse” pitch-shifted effect so I’m not sure if I’m on the right track.

Do you get good/perfect audio from your setup?

“Mickey Mouse” sound is something I am familiar with.

I get that when I’m using a level shifter for the MCLK signal. The reason for it is I’m getting interference on the level shifted signal. As a result the TLV’s are not getting a stable MCLK signal and it results all the timing being off.
So far I haven’t been able to get a level shifter working correctly for the I2S signals so I’m actually running the I2S at Pi logic levels which isn’t ideal and will shorten the life of the TLVs.

You may find the following tables useful. It is how the TLV is set up when the driver is loaded and I record. At the moment I’m using the Pi as master and the TLV as slave.
The arecord command line is:

arecord -D <device> -r 16000 -c 2 -f S16_LE

It occurs in two stages. The first stage is when the driver is loaded and ALSA then sets up the defaults.

First Stage (ALSA setup)

Address Page # Register Value Comment
0x18 0 0x00 0x01 Set Page 1
0x18 1 0x3b 0xd0 Left PGA muted, gain = 40.0 dB
0x18 1 0x3c 0xd0 Right PGA muted, gain = 40.0 dB
0x18 1 0x00 0x00 Set Page 0
0x18 0 0x52 0x00 Left ADC not muted, Left fine gain = 0.0 dB, Right ADC not muted, Right fine gain = 0.0 dB
0x18 0 0x58 0x50 Left AGC max gain = 40.0
0x18 0 0x60 0x50 Right AGC max gain = 40.0
0x18 0 0x5d 0x28 Left AGC Gain Value = 20 dB
0x18 0 0x51 0x02 ADC LCHAN down, RCHAN down, soft step disabled
0x18 0 0x00 0x01 Set Page 1
0x18 1 0x34 0xbf L: SEL4 2L+ & 3L- NC,SEL3 3L- NC,SEL2 2L+ NC,SEL1 1L+ NC
0x18 1 0x37 0xbf R: SEL4 2R+ & 3R- NC,SEL3 3R- NC,SEL2 2R+ NC,SEL1 1R- NC
0x18 1 0x00 0x04 Set Page 4
0x18 4 0x08 0x7f Set coefficient N0(15:8) for Left ADC
0x18 4 0x09 0xff Set coefficient N0(7:0) for Left ADC
0x18 4 0x0a 0x00 Set coefficient N1(15:8) for Left ADC
0x18 4 0x0b 0x00 Set coefficient N1(7:0) for Left ADC
0x18 4 0x0c 0x00 Set coefficient D1(15:8) for Left ADC
0x18 4 0x0d 0x00 Set coefficient D1(7:0) for Left ADC
0x18 4 0x48 0x7f Set coefficient N0(15:8) for Right ADC
0x18 4 0x49 0xff Set coefficient N0(7:0) for Right ADC
0x18 4 0x4a 0x02 Set coefficient N1(15:8) for Right ADC
0x18 4 0x4b 0x90 Set coefficient N1(7:0) for Right ADC
0x18 4 0x4c 0x00 Set coefficient D1(15:8) for Right ADC
0x18 4 0x4d 0x00 Set coefficient D1(7:0) for Right ADC
0x18 4 0x00 0x01 Set Page 1
0x18 1 0x34 0x3f L: SEL4 2L+ & 3L- 0 dB,SEL3 3L- NC,SEL2 2L+ NC,SEL1 1L+ NC
0x18 1 0x37 0x3f R: SEL4 2R+ & 3R- 0 dB,SEL3 3R- NC,SEL2 2R+ NC,SEL1 1R- NC

Second Stage (Recording)

Address Page # Register Value Comment
0x18 1 0x00 0x00 Set Page 0
0x18 0 0x05 0x11 PLL: Powered down, div P = 1, mul R = 1
0x18 0 0x06 0x07 PLL mul J = 7
0x18 0 0x08 0x90 PLL mul D lsb = 0x90(144)
0x18 0 0x07 0x06 PLL mul D msb = 0x0600(1536)
0x18 0 0x04 0x03 PLL_CLKIN = MCLK, CODEC_CLKIN = PLL_CLKIN
0x18 0 0x12 0x15 NADC: Div Powered down, div = 21
0x18 0 0x13 0x02 NADC: Mul Powered down, mul = 2
0x18 0 0x1e 0x08 BCLK N div Powered down, CLKOUT div N = 8
0x18 0 0x05 0x91 PLL: Powered up, div P = 9, mul R = 1
0x18 0 0x12 0x95 NADC: Div Powered up, div = 21
0x18 0 0x13 0x82 NADC: Mul Powered up, mul = 2
0x18 0 0x00 0x01 Set Page 1
0x18 1 0x3b 0x50 Left PGA not muted, gain = 40.0 dB
0x18 1 0x3c 0x50 Right PGA not muted, gain = 40.0 dB
0x18 1 0x00 0x00 Set Page 0
0x18 0 0x51 0xc2 ADC LCHAN up, RCHAN up, soft step disabled
1 Like

Wow, thank you for your response, that’s a big help!

I think the 3rd Gen Echo Dot is a little bit different in that regard, since it uses PLL instead of MCLK. I have a 2nd Gen Dot also laying around somewhere - maybe I’m gonna try it with that one.

Did you try out the TXB0104PWR? Currently I’m using the TXS0108E breakout boards because of convenience, but the TXB should be better for I2S though.

I’m gonna hook up a logic analyzer to see how the MCU on the Echo Dot sets the registers at startup.

Maybe I’m gonna try an nRF52840 instead of the ESP32. It runs natively on 1.8V so I don’t have any issues with logic levels. Also has full duplex I2S. It doesn’t have TDM, but I’m still not sure if the MCU needs to support TDM or the TLV320s.

However, after researching quite a bit, I’m thinking about whether it would be easier to just design a new top PCB and replace the complete hardware (except the speaker) of the Echo Dot. Even if we get the microphones working perfectly, there is still the problem with the whole beamforming algorithms, which are the big advantage of the Echo Dot. Without getting beamforming working, it’s kind of unnecessary to use the original Echo Dot PCBs anyway, and getting that all to work properly is a big project. Also, I’m not sure if there is enough space for the second PCB in the Echo Dot for all the components, the ESP32 is probably too slow for beamforming, wakeword detection etc.

The hardware costs for a PCB with an ESP32-S3 and 4x SPK0838HT4H microphones in PDM mode would be minimal (the microphones cost like 0.7€ each). There are some Espressif libraries for the beamforming, so that would be a start. Without the original hardware in the Echo Dot, there would be enough space for a custom PCB with the microphones and LEDs.

Probably the best approach and my current favourite one would be to use a microphone array like the AC108 AliX. It’s around 10 bucks and can be used with a Pi Zero. I think it’s a little too big for the original housing though, but there’s also a smaller 2-mic version ReSpeaker which already has an amplifier and DAC built in.

So I think I’m gonna go with that approach and use the Echo Dot’s housing and speaker, put a RPi Zero and the ReSpeaker board inside, and maybe design a custom 3D-printed top shell with some buttons and LEDs. Should look quite nice. The speaker is quite good on the Echo Dot and it also has a nice design so it would be nice to use them.

EDIT: After further consideration, the simplest solution would be to use the ReSpeaker Lite. It fits perfectly into the Dot housing and comes equipped with a dedicated chip for audio processing, an ESP32-S3, and even a speaker output. I’m likely going to go with this option, as I doubt I could create a custom PCB board for a lower cost.

The TLVs don’t have an independent clock source. The PLL needs a reference clock in order to divide/multiply it to generate the output WCLK and BCLK. If it is acting as the I2S master it has to use the MCLK input as the reference clock. It then applies the the P, R, K (J.D), NADC, MADC, and AOSR values that have bet set via I2C to produce the WCLK and BCLK signals. At least one of the TLV’s must have the MCLK pin connected. If the TLV is acting as an I2S slave then it doesn’t need the MCLK and the PLL can use the BCLK input as a reference clock to set up oversampling rates and use processing blocks in the onboard DSP (never used by Alexa).

I did and I still got interference. I suspect I need to use some pull-up or pull-down resisters in order to get a clean signal. At some point I’ll experiment with this to see if I can get a cleaner signal.

I’m going keep on going with this. I only spend a couple days every few months on it so its just a little hobby project for me.