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

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.

Hi all! With the echo gen 2, the speaker/tweeter sound pretty decent, especially for an assistant. I got a ReSpeaker Lite and it would be great to resue the amp board for sound and power. Any thoughs on where to inject analog audio into the amp board/TPA3118?

I am currently waiting for some PCBs from PCBWay that turn the 2nd Gen Echo into a soundcard, accessible via Alsa and PulseAudio. The PCBs also have DC boost converters so that you can power something like a Pi Zero 2 W (maybe even a Pi 4 if throttled). Two of the seven microphones are also able to be used.

Once I have received the boards and tested them I will publish the drivers, circuit diagram, Gerber files, BOM and Centroid (Pick and Place) files so anybody can make some.

The DC boost converter can be turned off by removing a couple of jumpers so that you can power the Pi externally if you wish.

This is exciting news!

Will it replace the MB? Is it reusing the amp/power board? Where will the DAC be?

Unfortunately it wont fit into the echo case. It has the same footprint as a Pi Zero 2 W and is intended to connect directly onto its GPIO Header.

The echo amplifier/power board isn’t digital so I’m redirecting the headphone audio output to GPIO 12 and 13 and these are connected directly to the amplifier board.

If you look at J3 (FPC Connector) on the Amp board you will see Pin 1 and Pin 24 marked on the board.

Pin 1, 2, 16,17,18 and 19 are Grounds

Pin 3 Drive Lo for speaker output and Hi to disable speaker. Uses 1V8 signalling levels

Pin 4 DO CONNECT DIRECTLY to the Pi it has a pullup to the 3V8 so will damage any GPIO you connect directly to it. In normal operation drive low to disable speaker and Hi to enable it. Since it is pulled Hi already you can leave it floating.

Pin 5 Drive Hi to enable speaker and low to disable it. Only ever detected 3V3 on this line

Pin 6 Jack Sense, Normal at 1V8 and goes low when jack plugged in (or is it the other way around?)

Pin 7, 9, 11 and 13 need to be connected to ground to prevent sound pops and cracks.

Pin 8 and 10 are the audio inputs.

Pin 12 Is a 1V8 input supply. I suspect this is only used by the Jack sense (pin 6) so you should be able to ignore it.

Pin 14 and 15 are unknown. It is only speculation but it may be that they use these lines in the FPC strip as WiFi and Bluetooth antenna as I haven’t seen any antennas on the main board.

Pin 16,17,18,19 are all grounds.
Pin 20,21,22,23,24 are all 3V8 power supply

It has been a while since I’ve tested the amp board with pins 3,4 and 5 left floating but IIRC the speakers are switched on unless explicitly turned off. So if you want to just try the audio output then connect one of the grounds (Pin 16,17,18 or 19) to the PI, Connect Pins 7,9,11 and 13 to ground, and connect the headphone audio output to pins 8 and 10.

NOTE: Before connecting anything to the Pi make sure the pins you are connecting to do not have a voltage > 3V3.

I plan to abandon using the Pi for this in a futures iteration due to audio limitations. Instead I’m going to try and use an ESP32-S3 with maybe an XMOS XCORE processor for audio processing and fit it all onto a board that can go back into the Echo case. In other words I aim to use most of the Home Assistant Voice Preview circuitry and code (with appropriate credits and acknowledgements).

This is so flipping helpful! Thank you! I’ve been trying to figure out the analog audio pins without setting up the device on amazon.

I was also thinking we could use esp32 with XMOS for audio processing. I instead got a ReSpeaker lite and it works well. Wake word on device and I haven’t had any false wakes either. Works with esphome and HA. So it’s a happy medium for me if I can use the amp board. And it should be trivial controlling the i2c devices in the echo.

Do you remember if there were any test pads on the amp board for pin 8 & 10?

Pin Test Points Notes
1 TP 13,18,19 Ground
2 TP 13,18,19 Ground
3 TP 24
4 TP 31
5 TP 23
6
7 TP 5,8,29
8 TP 6,12 TP 6 label is hidden amongst a group of capacitor labels
9
10 TP 2,11
11
12 TP 22
13
14 TP 15
15 TP 14
16 TP 13,18,19 Ground
17 TP 13,18,19 Ground
18 TP 13,18,19 Ground
19 TP 13,18,19 Ground
20 TP 21 3V8
21 TP 21 3V8
22 TP 21 3V8
23 TP 21 3V8
24 TP 21 3V8

The thing I’ve been hoping for is someone to build a replacement for the electronics in the Echo. I’ve been avidly following the effort to produce a drop-in replacement PC board for the Google Mini, to turn it into an ESP32-based HA voice assistant satellite.
MiciMike Home Mini Drop-In PCB | Crowd Supply .
It would be so cool if someone did that for Echo devices. (Preferably Echo Dot gen-3)

As I mentioned in my previous comment, integrating all the necessary hardware onto a custom PCB is not cost-effective. The Echo Dot is quite sophisticated, featuring multiple antenna arrays and advanced beamforming algorithms. In my opinion, the best approach would be to use a ReSpeaker Lite, which costs around €25, and place it inside the housing of the Echo Dot. This solution should work effectively right out of the box, only requires a mounting adapter for proper fitment and maybe a custom top to have some button controls.

However, it raises the question of whether it might be simpler to just design an entirely new 3D-printed housing for the ReSpeaker Lite that accommodates an LED ring. Both the LED ring and the speaker are quite affordable on AliExpress, which could result in a solid alternative to the Echo Dot.

At the moment I’m testing this…


The board cost $25 to build and has a DC boost converter to power the Pi Zero 2 W and a DC Buck converter for the signalling power rail (1.8V) together with multiple Logic Level Shifters so everything can talk each other.

I’m having a couple of issues with the audio output at moment but once that is sorted I’ll get everything into a Github repo (including the gerber files) and make everything public.

I have had some success with this and have built a HAT for a Pi Zero 2 W. I've also been working on a version using an ESP32-S3.

The Github Repo has all of the files needed to build the HAT although I strongly recommend that you do NOT build it.

It has many issues that I am unlikely to fix because I am now concentrating my efforts on the ESP32-S3 and I have a working version that replicates all the functionality the Voice Assistant Preview Edition. There are still some hardware issues I have to resolve so I'll probably have to go through a couple more iterations of the development board.

Hello everyone, I followed this topic and I found it really interesting! So I started an hardware replacement for the echo dot 3rd gen and I have something working! I posted a video on reddit and I opened a new topic where I can document the development. So if you are interested I would be really interested in sharing opinions with you!

Darn it!, Now I’ll probably have to join Reddit!
Does the LED board use the Lumissil IS31FL3236A and the Texas Instruments TLV320ADC3101?

Here’s the latest stage of the 2nd Gen project.


The board on the left is my current iteration and the one on the right is the control board from the echo that it is going to replace.

Really cool! ApparentlyAmazon is used to give strange shapes these PCBs! We are in the middle of a rebellion​:joy: Apes together strong!

However yes, It exactly uses those IC’s