jorgenkraghjakobsen / snapclient

WIP snapclient on ESP32
245 stars 52 forks source link

SPI Ram initialisation #3

Open Thenicolaibulow opened 4 years ago

Thenicolaibulow commented 4 years ago

Hej Jørgen - Tak for sidst. Hatten af for at du siden vi sidst snakkedes, har formået at bakse en client sammen. Det er jeg så glad for at se! :)

~

I've managed to compile your project, thanks to the new readme, and the previous issues where you mentioned the temporary fix for the opus library. However, it seems as though we might have different ESP-modules, as i'm having trouble getting the code to run properly. From what i can tell, it seems that my module cannot initialise the spi ram properly. Wether this has to do your code, or my lack of understanding with regards to configuring the module properly, i cannot tell. However i figured i'd post the issue here regardless.:

With the default sdk-config (although with my MA-board pinouts) my module keeps rebooting, after logging:

I (504) boot: Loaded app from partition at offset 0x10000 I (504) boot: Disabling RNG early entropy source... I (504) psram: This chip is ESP32-D0WD E (510) cpu_start: Failed to init external RAM! abort() was called at PC 0x400817ad on core 0 0x400817ad: call_start_cpu0 at /Users/nicolaidyre/esp/esp-idf/components/esp32/cpu_start.c:175 (discriminator 1)

ELF file SHA256: f7777f23a26a0adec4315393d23d446494b3fb284b10b858ced0cb764e72fc08

Backtrace: 0x40097021:0x3ffe3bb0 0x400973c9:0x3ffe3bd0 0x400817ad:0x3ffe3bf0 0x40079707:0x3ffe3c30 |<-CORRUPTED 0x40097021: invoke_abort at /Users/nicolaidyre/esp/esp-idf/components/esp32/panic.c:157

0x400973c9: abort at /Users/nicolaidyre/esp/esp-idf/components/esp32/panic.c:174

0x400817ad: call_start_cpu0 at /Users/nicolaidyre/esp/esp-idf/components/esp32/cpu_start.c:175 (discriminator 1)

Re-enable cpu cache. Rebooting...

Based off the lines:

I (504) psram: This chip is ESP32-D0WD E (510) cpu_start: Failed to init external RAM!

I would assume that this is to do with 'incompatible' hardware. As you can see, i'm using the D0WD variation, with a 16M flash. I noticed that if i, in the menuconfig, tick:

Component config -> ESP32-Specific -> Support for external, SPI-connected RAM -> SPI RAM config -> "Ignore Psram when not found"

I'm able to get beyond the initial error, but still receive the error (after an otherwise, seemingly successful boot):

I (2261) SNAPCAST: got ip:192.168.blab I (2261) SNAPCAST: connected to ap SSID:blab password:blab Settime from sntp I (7271) SNAPCAST: Initializing SNTP Called I (7271) I2S: queue free spaces: 7 I (7271) I2S: DMA Malloc info, datalen=blocksize=3840, dma_buf_count=8 I (7291) I2S: APLL: Req RATE: 48000, real rate: 47999.992, BITS: 32, CLKM: 1, BCK_M: 8, MCLK: 24575996.000, SCLK: 3071999.500000, diva: 1, divb: 0 Buffer_struct ok Buffer_stoarge ok /Users/blab/esp/esp-idf/components/esp_ringbuf/ringbuf.c:902 (xRingbufferCreateStatic)- assert failed! abort() was called at PC 0x40089e32 on core 0 0x40089e32: xRingbufferCreateStatic at /Users/blab/esp/esp-idf/components/esp_ringbuf/ringbuf.c:902 (discriminator 1)

Any clue as to what might have to be done, in order for it to work?

Huge thanks for the great work so far! :)

jorgenkraghjakobsen commented 4 years ago

Hi Nicolai Thanks for the feedback - Let us get your hardware up running as well - This is my first attempt with psram and i am not fully sure what config handles I pulled in menuconfig to get it running Here is my boot log : I (477) boot: Loaded app from partition at offset 0x10000 I (477) boot: Disabling RNG early entropy source... I (478) psram: This chip is ESP32-D0WD I (483) spiram: Found 64MBit SPI RAM device I (487) spiram: SPI RAM mode: flash 40m sram 40m I (492) spiram: PSRAM initialized, cache is in low/high (2-core) mode.

jorgenkraghjakobsen commented 4 years ago

And later I (8622) I2S: queue free spaces: 7 I (8622) I2S: DMA Malloc info, datalen=blocksize=3840, dma_buf_count=8 I (8642) I2S: APLL: Req RATE: 48000, real rate: 47999.992, BITS: 32, CLKM: 1, BCK_M: 8, MCLK: 24575996.000, SCLK: 3071999.500000, diva: 1, divb: 0 Buffer_struct ok Buffer_stoarge ok Ringbuf ok Ringbuffer ok I (8652) SNAPCAST: Connected to AP I (8652) SNAPCAST: Enable mdns I (8662) SNAPCAST: Lookup snapcast service on netowork I (8772) SNAPCAST: SNTP time set from server number :1 wait ... buffer : 0 wait ... buffer : 0

jorgenkraghjakobsen commented 4 years ago

menu config:

image

jorgenkraghjakobsen commented 4 years ago

I have added a menuconfig option to use PSRAM or not, in the dsp_processor component under the menu item "ESP32 audio buffer and I2S pin config" Ignorring the warning "Ignore PSRAM when not found" will just hit you hard when trying to allocate the buffer. My very fast conclusion. Just uncheck USE_PSRAM and you will be rocking. :-)

/Jakobsen

Thenicolaibulow commented 4 years ago

Hi Jørgen,

Thanks for the fast response. I've been rocking the past couple of days! - It's awesome. Currently it's running on several of my amplifiers boards. I can't wait to see time-syncing work at some point!

I think i've figured out what my problem has been. - As i'm using a WROOM module, rather than i WROVER, i don't have any psram. - That's probably why i haven't been able to init the spi ram on boot...

Thanks for the commit!

karimSad commented 4 years ago

Hi Nicolai,

short question. Are you using Audio Framework esp-adf or just the esp-idf?

Thenicolaibulow commented 4 years ago

Well, to be honest - i'm not quite sure. I'm building the project using "make flash monitor -j4" which, from my understanding indicates that i've been building the project using the esp-adf (despite Jørgens' suggestion).

Can we agree that if i were to be building the project using "idf.py build" i'd be building using the esp-idf (As Jørgen suggested)?

karimSad commented 4 years ago

Thanks a lot for your fast response. No, I think that you are not using esp-adf. Because you need to install it extra and explicit run it on your macine.

You are using esp-idf in all cases, even when you are building your project with make. ESP-IDF supports make and cmake (ninja) build systems

Thenicolaibulow commented 4 years ago

I know for a fact, that i have both the adf and idf installed on my system. - Which is the root of my confusion hehe.

From what i understand; doesn't the adf 'include' a earlier version of the idf? I would assume that's why my ~/esp, has both: ~/esp/esp-idf, and ~/esp/esp-adf/esp-idf

Right?

Best regards,

karimSad commented 4 years ago

Currently esp-adf supports the new esp-idf 4.0 and 4.1. Well, when esp-adf works fine on your machine, that means you have extra components which can you use for your audio applications instead of doing this yourself

jorgenkraghjakobsen commented 4 years ago

Hi N and K I had a closer look into the ADF to see if there would be an easy to way to enable 1 My code to run on Lyra hardware 2 Compile under ADF enviroment And as I understand the ADF now are upto speed with the IDF releases. But has not fully successed to compile under ADF jet. Karim - can you compile the code under ADF - If so I thing we only needed to change the last part of the audio chain from 32 to 16 bits or setup the 8388 for 32 bits. /j

karimSad commented 4 years ago

Hi Jorgen,

i will try what you said, and give my feedback here.

karimSad commented 4 years ago

Hi Jorgen,

please tell me where you are stucked regarding running esp-adf successfully on your machine. I got this running on my system before. And I am using esp-adf currently with esp-idf 4.1

karimSad commented 4 years ago

Hi N and K I had a closer look into the ADF to see if there would be an easy to way to enable 1 My code to run on Lyra hardware 2 Compile under ADF enviroment And as I understand the ADF now are upto speed with the IDF releases. But has not fully successed to compile under ADF jet. Karim - can you compile the code under ADF - If so I thing we only needed to change the last part of the audio chain from 32 to 16 bits or setup the 8388 for 32 bits. /j

Hi Jorgen,

I agree. But it would be easier to change the rate to 16 bit in snapclient to keep default settings in esp-adf.

If you can define the audio bit length (32bit/16bit) as a parameter, I would give a fast feedback if it is working in Lyra or not. Though I think this is not enough. I think, The ringbuffer from snapclient should be added to a pipeline as in esp-adf examples. Then the pipeline should "hopefully" work without problems.

According to esp-adf, please consider to use esp-idf inside the esp-adf. Also, checkout from esp-idf the branch "release/v4.1". Then, the esp-adf should work with your esp-idf without any problems.

Regards,

jorgenkraghjakobsen commented 4 years ago

Hi Karim - I have the ADF up running needed to add include($ENV{ADF_PATH}/CMakeLists.txt) to the project root CMakeLists.txt I can easily patch the code to conditionally only do 16 bit to the i2s driver and still keep away from the pipeline stuff for now at least. /j