Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for lyrat mini v1.2 and es8311 #165

Open
wants to merge 1 commit into
base: master-cmake
Choose a base branch
from

Conversation

naguirre
Copy link

This PR add initial support for es8311 via the dac_external component.
It also add informations in Readme about support for LyraT Mini v1.2 : https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/get-started-esp32-lyrat-mini.html

Working features for this board :

  • LEDs (Green and Blue)
  • Audio out via Jack and HP

@sle118 sle118 requested a review from philippe44 August 17, 2022 12:56
@sle118
Copy link
Owner

sle118 commented Aug 17, 2022

I have requested @philippe44 to have a look, since he wrote that layer.

Note that in the 4.3 branch, I have included a new mechanism to provision known configurations via a JSON file that is pulled out of a gist.

I will add the lyrat configuration there as well in case you want to give it a try. I chose this path in order to keep the code lean going forward; we're running low on storage with the current partition scheme, which was created to accommodate the widely available 4mb flash boards.

@sle118 sle118 added the enhancement New feature or request label Aug 17, 2022
@naguirre
Copy link
Author

Just for my information, will 4.3 branch be merged into master soon ? On which branch should I propose my PR in the future (if any) ?
I will give 4.3 branch a try, but last time i tried it, I got a lot of issues, board was resetting in loop, and only sometimes I got a working command line. Is this branch suppose to be stable ?

@sle118
Copy link
Owner

sle118 commented Aug 19, 2022

Just for my information, will 4.3 branch be merged into master soon ? On which branch should I propose my PR in the future (if any) ? I will give 4.3 branch a try, but last time i tried it, I got a lot of issues, board was resetting in loop, and only sometimes I got a working command line. Is this branch suppose to be stable ?

That branch is the future master and eventually release, but development has slowed down in the past few months due to personal circumstances for both Philippe and myself. I did, however, try to keep it as much as possible in a stable state last time I committed stuff so you are welcome to try it.

If you encounter issues during your testing, let me know and I'll do my best to help in a reasonable amount of time. The more official users on that branch, the more I'll be able to stabilize the new network manager and additional features.

Thank you!

@philippe44
Copy link
Collaborator

Looks good to me but if you can see the latest commit I've made, there is a tweak needed for 32 bits mode on ES8388. Maybe the same would be needed here?

@naguirre
Copy link
Author

Eventually, this register do the same job ? : https://github.com/espressif/esp-adf/blob/master/components/audio_hal/driver/es8311/es8311.c#L531
Currently I put 0xC in this register, i could add a define as you did, and put 0x10 in the value for BYTES_PER_FRAME == 8
I have no idea how to test that though.

@philippe44
Copy link
Collaborator

philippe44 commented Aug 31, 2022

You can compile the 32 bits version by doing "idf.py build -DDEPTH=32"

@CherAlban
Copy link

Hi,

I tried to get a LyraT mini v1.2 to work using the dac settings above with I2S-4MFlash.16.2.1290.master-v4, but with no success, the audio output stays silent.

I can see the I2S and I2C signals coming to the DAC, but there is no analog signal coming out of the DAC.

PA pin1 of NS4150 power CTRL is set to high, and it is amplifying.

My settings:
nvs_config_LYRAT MINI_1681154327549json.txt

Any idea/hint what I am doing wrong?

@CherAlban
Copy link

CherAlban commented Apr 11, 2023

When checking register settings in your PR, it seems odd to me that some registers are written twice with the same or also different values, is that correct?

dac_external.c

@naguirre
Copy link
Author

@CherAlban yes it looks odd, for sure, but I dumped the registers as is, directly from the working software version running on the Lyra Mini T.
Today, I rebased my PR on to of master-cmake but it looks like it's not the default branch anymore. I will try to use master-v4.3 and gist that @sle118 was mentionning.

@naguirre
Copy link
Author

I upgrade to latest release, the version Installed is fw: I2S-4MFlash.16.2.1299.master-v4, mode: Squeezelite-ESP32 Unfortunately, it's not working with the parameters given in this MR.
I dig a little bit more, and Here the UART logs output :

I (3443) DAC core: DAC uses I2C port:0, sda:18, scl:25
I (3453) DAC external: DAC on I2C @24
W (3453) DAC core: I2C write failed
W (3463) DAC core: I2C write failed
W (3463) DAC core: I2C write failed
W (3463) DAC core: I2C write failed
W (3473) DAC core: I2C write failed

It can't write i2c register as the I2C port for the DAC is 0, and Lyrat mini uses port 1.
Those two lines let me think that the i2c port for DAC is hardcoded to 1 :
https://github.com/sle118/squeezelite-esp32/blob/master-v4.3/components/squeezelite/output_i2s.c#L120
https://github.com/sle118/squeezelite-esp32/blob/master-v4.3/components/squeezelite/output_i2s.c#L307

One solution would be to read the i2c port from the dac_config. Let me know if I'm on the right path or not.

@marcolinux46
Copy link

@naguirre are you still in test?
I can help with tests having the same board

@CherAlban
Copy link

Bringing this topic up again: We would really like to use the LyraT Mini board for our this year's "Girl's Day" project (April 25).

I just tested again with the latest fw: I2S-4MFlash-1670, but with no success, no audio. My settings file:
nvs_config_squeezelite-d0b9c_1710602634877json.txt

I tried both I2C ports: using port 0, I am getting the following error on the serial interface:
I (3111) DAC core: DAC uses I2C port:0, sda:18, scl:23
E (3121) i2c: i2c driver install error
I (3121) DAC external: DAC on I2C @24

when using port 1, there is no I2C error reported, but still I2S MCK complains:
I (3111) DAC core: DAC uses I2C port:0, sda:18, scl:23
I (3121) DAC external: DAC on I2C @24
[01:08:46.904] output_init_i2s:347 configuring MCLK on GPIO -1
[01:08:46.905] output_init_i2s:359 invalid MCK gpio -1

It would be really great to finally sort this out.

@philippe44
Copy link
Collaborator

  • I don't remember well what I did or not for the es8311 but obviously it needs a MCK gpio set (master clock, some DAC are a real pain and can't work without one). Have you configure one?

@CherAlban
Copy link

CherAlban commented Mar 16, 2024

I configured it according to @naguirre original PR:

"dac_config": "model=I2S,bck=5,ws=25,do=26,sda=18,scl=23,i2c=24"

"i2c_config": "scl=25,sda=18,speed=400000,port=1"

"dac_controlset": "{ "init": [ {"reg":1, "val":48}, {"reg":2, "val":0}, {"reg":3, "val":16}, {"reg":22, "val":36}, {"reg":4, "val":16}, {"reg":5, "val":0}, {"reg":11, "val":0}, {"reg":12, "val":0}, {"reg":16, "val":31}, {"reg":17, "val":127}, {"reg":0, "val":128}, {"reg":0, "val":128}, {"reg":1, "val":63}, {"reg":1, "val":63}, {"reg":2, "val":0}, {"reg":5, "val":0}, {"reg":3, "val":16}, {"reg":4, "val":16}, {"reg":7, "val":0}, {"reg":8, "val":255}, {"reg":6, "val":3}, {"reg":1, "val":63}, {"reg":6, "val":3}, {"reg":19, "val":16}, {"reg":27, "val":10}, {"reg":28, "val":106}, {"reg":9, "val":12}, {"reg":10, "val":12}, {"reg":9, "val":12}, {"reg":10, "val":12}, {"reg":50, "val":178}, {"reg":9, "val":12}, {"reg":10, "val":12}, {"reg":23, "val":191}, {"reg":14, "val":2}, {"reg":18, "val":0}, {"reg":20, "val":26}, {"reg":20, "val":26}, {"reg":13, "val":1}, {"reg":21, "val":64}, {"reg":55, "val":72}, {"reg":69, "val":0}, {"reg":50, "val":200}]}"

https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/board-esp32-lyrat-mini-v1.2.html

image

@philippe44
Copy link
Collaborator

So you have to add MCK to gpio 0. I'm not in from of a computer now but look at my README and it says how to set MCK for a DAC

@CherAlban
Copy link

mck=0 did the trick, I can hear audio!

  • loudness control is also working ok
  • frequency response on the headphone jack is pretty lousy, almost no lows, will have to check the speaker output

@naguirre
If you want to adapt your PR, my working setup is:
model=I2S,bck=5,ws=25,do=26,mck=0,sda=18,scl=23,i2c=24
scl=23,sda=18,speed=400000,port=1
dac register values as in the original PR

Many thanks!

@philippe44
Copy link
Collaborator

Cool - so tell me, what is "girl's day", if you do t mind me asking?

@CherAlban
Copy link

It started as Girl's Day https://www.girls-day.de/

Now it has become Girls and Boys Zukunftstag

@CherAlban
Copy link

Unfortunately I am still having trouble with the Lyrat-Mini board:

  • The board seems to only boot, if there is an active terminal session on the serial (USB UART) port. It actually waits for an active putty terminal connection before it starts to boot.

  • In order to activate (unmute) the PA for a speaker, I extended the dac_config (model=I2S,bck=5,ws=25,do=26,mute=21:0,sda=18,scl=23,i2c=24) This works fine after the initial setup, but after power cycling the board, no audio at all is coming (both on headphones and speaker output)

I have two LyraT-Mini boards and checked with both of them, with the same results.

@CherAlban
Copy link

The board seems to only boot, if there is an active terminal session on the serial (USB UART) port. It actually waits for an active putty terminal connection before it starts to boot.

The first problem is known for the LyraT-Mini and based on hardware:
https://www.reddit.com/r/esp32/comments/pooiv7/esp32_lyratmini_code_doesnt_start_unless_the/

@skiphansen
Copy link

I have requested @philippe44 to have a look, since he wrote that layer.

Note that in the 4.3 branch, I have included a new mechanism to provision known configurations via a JSON file that is pulled out of a gist.

I will add the lyrat configuration there as well in case you want to give it a try. I chose this path in order to keep the code lean going forward; we're running low on storage with the current partition scheme, which was created to accommodate the widely available 4mb flash boards.

@sle118 I just installed SqueezeAmp.32.1681.master-v4.3 on my Lyrat v4.3 board. Where do I find the gist you mentioned or how can I use the new provisioning feature?

@skiphansen
Copy link

I finally got it working, here's a full tested and working nvs file for the Lyrat v4.3 board to save the next guy some time.

nvs_config_lyrat_v43.txt

@CherAlban
Copy link

@skiphansen Did you manage to solve the hardware issue with this board? I could either make it boot in stand-alone-mode, or let it accept serial flash, but not both with the same hardware tweak.

@skiphansen
Copy link

skiphansen commented Feb 2, 2025

@CherAlban I had no hardware issues at all.

Make sure you are powering the board properly but either using two USB cables or with a battery.

I've never used the battery myself only two USB cables which is quite odd. Also note that there are multiple versions of the Lyrat board, mine is v4.3

I used the web installer to flash it, again no issues.

@CherAlban
Copy link

I only saw v4.3 so far. My understanding is that one USB is for power, the other is the USB/serial connection. If only USB power is connected, my board does not boot:
https://www.reddit.com/r/esp32/comments/pooiv7/esp32_lyratmini_code_doesnt_start_unless_the/

@skiphansen
Copy link

I only saw v4.3 so far. My understanding is that one USB is for power, the other is the USB/serial connection. If only USB power is connected, my board does not boot: https://www.reddit.com/r/esp32/comments/pooiv7/esp32_lyratmini_code_doesnt_start_unless_the/

The reddit link refers to a "ESP32 LyraT-Mini", that's a different board. There's also a v4.2 version of the Lyrat.

I just power cycled my board w/o the serial USB and it booted and played audio.

Maybe you have bad board? We used at least 4 Lyrat board on my last project, they all worked without any issues.

@CherAlban
Copy link

@skiphansen Sorry for answering too quickly without thorough reading. The thread originally deals with the LyraT Mini v1.2 board, not with the standard LyraT v4.3, which works flawlessly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants