Skip to content

Added platformio.ini file and few test configs#222

Open
anabolyc wants to merge 10 commits into
CarlosDerSeher:developfrom
anabolyc:features/platformio-build-system
Open

Added platformio.ini file and few test configs#222
anabolyc wants to merge 10 commits into
CarlosDerSeher:developfrom
anabolyc:features/platformio-build-system

Conversation

@anabolyc

Copy link
Copy Markdown
Contributor

Addressing #182

This change adds platformio.ini config file, that uses reduced sdkconfigs only:

  • sdkconfig.defaults - default settings for every board (around 50 lines)
  • sdkconfig.defaults_psram - psram configuration for ESP32 boards that have it (onky 6 lines)
  • sdkconfig.defaults.esp32s3 - ESP32-S3 specific settings (include psram settings by default, 13 lines)
  • sdkconfig.defaults.debug - to help debugging, adds debug symbols, more verbose default logging and halt on crash

and board-specific configs (only DAC settings and pinouts)

  • sdkconfig.defaults.hifi-esp32
  • sdkconfig.defaults.hifi-esp32s3
  • etc (I'm adding more, including those default ones in the repo root)

Most of the settings from the current sdkconfigs will be generated during build based on the idf defaults

@anabolyc anabolyc marked this pull request as draft May 22, 2026 14:03

@luar123 luar123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. The pio flow is specially useful for the pre-build hardware. I am still trying to see how to use it conveniently with custom configurations and without modifying platform.ini.

Comment thread .vscode/launch.json Outdated
Comment thread platformio.ini Outdated
Comment thread sdkconfig.defaults Outdated
Comment thread sdkconfig.defaults
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=10
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=1536
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=5
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the default now or do you want to prevent light sleep mode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I found these in most of the configs, not sure if that is not supposed to be set. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I did not update all the legacy files when enabling sleep mode. Please revert and test. Should work fine and reduce power to ~0.2W when idle.

Comment thread sdkconfig.defaults Outdated
Comment thread sdkconfig.defaults Outdated
Comment thread sdkconfig.defaults.esp32s3 Outdated
Comment thread sdkconfig.defaults.static-wifi Outdated
@anabolyc

Copy link
Copy Markdown
Contributor Author

@luar123 thanks for reviewing. I'll finish converting the exisitng boards configs and will do some cleanup.
S3 config is still problematic. I think it needs some good tuning by someone more experienced. Current builds are not usable, they stutter as hell

@luar123

luar123 commented May 23, 2026

Copy link
Copy Markdown
Contributor

Interesting, my louder-esp32s3 runs fine 24/7 for a few months now (but have not updated in a while). I will try to update to latest dev and test when I have time.

@anabolyc

Copy link
Copy Markdown
Contributor Author

Interesting, my louder-esp32s3 runs fine 24/7 for a few months now (but have not updated in a while). I will try to update to latest dev and test when I have time.

Oh, good to know, we can cross-check SDKCONFIGs then, when I'm ready for S3 tuning

@anabolyc

Copy link
Copy Markdown
Contributor Author

I'm done with sdkconfigs transformations, feel free to look into those. I'm planning to run the tests with every board I have. This would not cover all of it though.

@anabolyc

Copy link
Copy Markdown
Contributor Author

Hey @luar123 is there a chance you can find which commit and SDKCONFIG your Louder-ESP32-S3 is built from? I'm testing with ESP32 boards, it works flawlessly, but the ESP32-S3 is not working at all. Constant RESYNCING HARD, not responding to volume changes, etc.

@luar123

luar123 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Hey @luar123 is there a chance you can find which commit and SDKCONFIG your Louder-ESP32-S3 is built from? I'm testing with ESP32 boards, it works flawlessly, but the ESP32-S3 is not working at all. Constant RESYNCING HARD, not responding to volume changes, etc.

I hope I can look into this during the weekend.

@luar123

luar123 commented May 29, 2026

Copy link
Copy Markdown
Contributor

@anabolyc ran a short test with current develop branch, default settings, idf 5.5.4

SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig_louder_esp_my" idf.py build and then flashed with OTA.
sdkconfig_louder_esp_my:

CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_SNAPSERVER_USE_MDNS=n
CONFIG_SNAPSERVER_HOST="xxx"
CONFIG_SNAPCLIENT_NAME="louder-esp"
CONFIG_AUDIO_BOARD_CUSTOM=y
CONFIG_DAC_TAS5805M=y
CONFIG_DAC_I2C_SDA=8
CONFIG_DAC_I2C_SCL=9
CONFIG_MASTER_I2S_BCK_PIN=14
CONFIG_MASTER_I2S_LRCK_PIN=15
CONFIG_MASTER_I2S_DATAOUT_PIN=16
CONFIG_USE_DSP_PROCESSOR=n
CONFIG_WIFI_SSID="xxx"
CONFIG_WIFI_PASSWORD="xxx"
CONFIG_WIFI_MAXIMUM_RETRY=0

No re-syncs at all.
Should be noted that my wifi is strong and stable and I created the defaults based on my environment. So the settings might not be the best for weak or busy wifi environments. There are some more settings we could try. If you have issues with the defaults please provide a log. And if you have some old working sdkconfig, please also provide it.

@luar123

luar123 commented May 30, 2026

Copy link
Copy Markdown
Contributor

These are sdkconfig recommendations mostly from esphome (RAM/network heavy sendspin/voice assistant implementations) based on idf guides and experience. However, I did not test most of them:

On esp32s3 we should first add:
CONFIG_SPIRAM_SPEED_80M=y this doubles PSRAM speed.
And probably CONFIG_SPIRAM_RODATA=y (on all psram variants)

Additionally:
On all variants for lower RAM/better performance:

CONFIG_LWIP_DHCPS=n
CONFIG_LWIP_BRIDGEIF_MAX_PORTS=1
CONFIG_LWIP_TCPIP_CORE_LOCKING=y
CONFIG_LWIP_CHECK_THREAD_SAFETY=y
CONFIG_LIBC_LOCKS_PLACE_IN_IRAM=n
CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y
CONFIG_VFS_SUPPORT_TERMIOS=n
CONFIG_VFS_SUPPORT_SELECT=n
CONFIG_VFS_SUPPORT_DIR=n
CONFIG_VFS_INITIALIZE_DEV_NULL=n

On non esp32s3 psram variants:

CONFIG_ESP_WIFI_IRAM_OPT=y
CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y
CONFIG_LWIP_IRAM_OPTIMIZATION=y

on all psram variants for high performance network:

CONFIG_LWIP_WND_SCALE=y
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=512
CONFIG_ESP_WIFI_STATIC_TX_BUFFER=y
CONFIG_ESP_WIFI_TX_BUFFER_TYPE=0
CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=32
CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8
CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
CONFIG_ESP_WIFI_RX_BA_WIN=32
CONFIG_ESP_WIFI_TX_BA_WIN=16
CONFIG_LWIP_MAX_ACTIVE_TCP=16
CONFIG_LWIP_MAX_LISTENING_TCP=16
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=512
CONFIG_LWIP_TCP_MAXRTX=12
CONFIG_LWIP_TCP_MSS=1436
CONFIG_LWIP_TCP_MSL=60000
CONFIG_LWIP_TCP_OVERSIZE_MSS=y
CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
CONFIG_LWIP_TCP_RECVMBOX_SIZE=512
CONFIG_LWIP_TCP_RCV_SCALE=3
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534
CONFIG_LWIP_TCP_SYNMAXRTX=6
CONFIG_LWIP_TCP_WND_DEFAULT=512000
CONFIG_HTTPD_WS_SUPPORT=y

Comment thread sdkconfig.defaults
Comment thread sdkconfig.defaults.esp32s3
@anabolyc

anabolyc commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @luar123 I'm trying those now. But I already see a huge improvement, I forgot to include sdkconfig.defaults.esp32s3 into S3-based environments :)

@anabolyc

anabolyc commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

These are sdkconfig recommendations mostly from esphome (RAM/network heavy sendspin/voice assistant implementations) based on idf guides and experience. However, I did not test most of them:

On esp32s3 we should first add: CONFIG_SPIRAM_SPEED_80M=y this doubles PSRAM speed. And probably CONFIG_SPIRAM_RODATA=y (on all psram variants)

Additionally: On all variants for lower RAM/better performance:

CONFIG_LWIP_DHCPS=n
CONFIG_LWIP_BRIDGEIF_MAX_PORTS=1
CONFIG_LWIP_TCPIP_CORE_LOCKING=y
CONFIG_LWIP_CHECK_THREAD_SAFETY=y
CONFIG_LIBC_LOCKS_PLACE_IN_IRAM=n
CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y
CONFIG_VFS_SUPPORT_TERMIOS=n
CONFIG_VFS_SUPPORT_SELECT=n
CONFIG_VFS_SUPPORT_DIR=n
CONFIG_VFS_INITIALIZE_DEV_NULL=n

On non esp32s3 psram variants:

CONFIG_ESP_WIFI_IRAM_OPT=y
CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y
CONFIG_LWIP_IRAM_OPTIMIZATION=y

on all psram variants for high performance network:

CONFIG_LWIP_WND_SCALE=y
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=512
CONFIG_ESP_WIFI_STATIC_TX_BUFFER=y
CONFIG_ESP_WIFI_TX_BUFFER_TYPE=0
CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=32
CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8
CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
CONFIG_ESP_WIFI_RX_BA_WIN=32
CONFIG_ESP_WIFI_TX_BA_WIN=16
CONFIG_LWIP_MAX_ACTIVE_TCP=16
CONFIG_LWIP_MAX_LISTENING_TCP=16
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=512
CONFIG_LWIP_TCP_MAXRTX=12
CONFIG_LWIP_TCP_MSS=1436
CONFIG_LWIP_TCP_MSL=60000
CONFIG_LWIP_TCP_OVERSIZE_MSS=y
CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
CONFIG_LWIP_TCP_RECVMBOX_SIZE=512
CONFIG_LWIP_TCP_RCV_SCALE=3
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534
CONFIG_LWIP_TCP_SYNMAXRTX=6
CONFIG_LWIP_TCP_WND_DEFAULT=512000
CONFIG_HTTPD_WS_SUPPORT=y

Apart from the last block it is implemented. Last one actually make it worse for me, but maybe it is my weak network. This is how it looks on the S3:
image
I think rssi -70db is not a good number, right?

@anabolyc anabolyc marked this pull request as ready for review June 1, 2026 09:21
@luar123

luar123 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

It should not be necessary to load the target specific files explicitely: https://docs.espressif.com/projects/esp-idf/en/v5.5.4/esp32/api-guides/kconfig/configuration_structure.html#sdkconfig-defaults-and-sdkconfig-defaults-chip
But all the defaults files are ignored if there is already an existing sdkconfig file. Not sure how pio is handles this.

@anabolyc

anabolyc commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

It should not be necessary to load the target specific files explicitely: https://docs.espressif.com/projects/esp-idf/en/v5.5.4/esp32/api-guides/kconfig/configuration_structure.html#sdkconfig-defaults-and-sdkconfig-defaults-chip But all the defaults files are ignored if there is already an existing sdkconfig file. Not sure how pious handles this.

Ah, that was mentioned above already. Completely escaped my mind :)

@anabolyc

anabolyc commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Some envs have now issue with IRAM overflow.

/home/runner/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: .pio/build/ai-thinker-esp32-a1s-audiokit/firmware.elf section `.iram0.text' will not fit in region `iram0_0_seg'
/home/runner/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: IRAM0 segment data does not fit.
/home/runner/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: region `iram0_0_seg' overflowed by 480 bytes

Probably need to roll back some of the default settings. I guess these are caused by

CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y
CONFIG_LWIP_IRAM_OPTIMIZATION=y

@CarlosDerSeher

CarlosDerSeher commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Do not use most of the iram optimizations, at least nit on variants without psram. I make heavy use of IRAM for pcm buffer.

@anabolyc

anabolyc commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y
CONFIG_LWIP_IRAM_OPTIMIZATION=y

They are part of the PSRAM-enabled config. Would you suggest keeping them, or removing?

@CarlosDerSeher

CarlosDerSeher commented Jun 1, 2026

Copy link
Copy Markdown
Owner

adau1961 sdkconfig template is the one I used. It is probably outdated but you could compare with that one as it should be in the state when I did those memory optimizations. The IRAM options should be there.

@luar123

luar123 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

@CarlosDerSeher: From the settings I proposed only the first part is applied to all configs.

CONFIG_LIBC_LOCKS_PLACE_IN_IRAM=n
CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y

reduce IRAM usage further and should be save to use.

Settings that increase IRAM:

CONFIG_ESP_WIFI_IRAM_OPT=y
CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y
CONFIG_LWIP_IRAM_OPTIMIZATION=y

are only applied to configs with PSRAM. Still not sure if this gives a benefit.

@luar123

luar123 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

@anabolyc Is it working fine for you now on esp32 and esp32-s3?

Apart from the last block it is implemented. Last one actually make it worse for me, but maybe it is my weak network. This is how it looks on the S3

Is the log with or without the last block?

@anabolyc

Copy link
Copy Markdown
Contributor Author

Sorry for the delay, had a short holiday break.

It works very well on all esp32 boards, on the esp32-s3 it is still not very stable. As you can see from the log, it falls into hard resyncs every now and then. I didn't include the last network-related block, since it made the situation even worse, so the log I posted also captured without those changes

If you have a chance, can you try s3 config from this branch on your board. I'm wondering if maybe my network is causing my issues (or maybe my test board is too tired, i re-flashed it like 1000 times already).

@luar123

luar123 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Tested the settings from this PR on my louder-esp-s3 and it works fine (did not build with pio). I only kept light sleep on (#222 (comment)).

Differences could come from network or hardware. There are a few things you could try:

  • Reduce TX power (for less interference)
  • disable modem sleep: esp_wifi_set_ps(WIFI_PS_NONE)

Most development was done with very small buffers so maybe there are some systematic issues when having large buffers. When dealing with network congestion increasing the buffers can help but somehow that seems not work. The Resync 1 message suggests there are too old samples. @CarlosDerSeher Do you think we could discard late chunk messages early before decoding them, maybe comparing tx time stamps with server time taking the buffer length into account? Are out-of-order messages handled?

Another thought: Not sure if this could help but I think we should disable tcp nagle when sending time messages.

@CarlosDerSeher

Copy link
Copy Markdown
Owner

Do you think we could discard late chunk messages early before decoding them

We would need some kind of feedback from player task to http task. Not sure how to do this. We would have to evaluate this.

Are out-of-order messages handled?

This should be done by lwip, we use a TCP connection so shouldn't be a problem.

@anabolyc

Copy link
Copy Markdown
Contributor Author

I'm trying on a different wifi network and it seems to perform better, although hard resyncs are still happening. Will play with IRAM optimizations, see if it does any good

@anabolyc

Copy link
Copy Markdown
Contributor Author

here is my pings when hardsyncs are happening, I'm getting convinced it is wifi related
image

@luar123

luar123 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

We would need some kind of feedback from player task to http task. Not sure how to do this. We would have to evaluate this.

Yes, I think there are multiple options how to do it. Should not add much overhead and does not have to be super accurate. I am out for a few weeks, so won't look into it soon.

Will play with IRAM optimizations, see if it does any good

Does it help? Looking at your ping you should increase your buffer to 2000ms.

@anabolyc

anabolyc commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Does it help? Looking at your ping you should increase your buffer to 2000ms.

I just pushed the settings that work more-or-less stable. This block seems to made it better, but I think most of the issues are coming from my network setup. Not the first time i have issues with it.

#
# WiFi throughput optimization by placing code in IRAM
#
CONFIG_ESP_WIFI_IRAM_OPT=y
CONFIG_ESP_WIFI_RX_IRAM_OPT=y
CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y

Normally my ping is 5-50ms, but then it suddenly starts to go over the sky

@anabolyc

Copy link
Copy Markdown
Contributor Author

@CarlosDerSeher @luar123 I'm okay with the current state, unless you have some other ideas that I should implement, I'd do some cleanup, squashing, and merge preparations. How do you feel about that?

@CarlosDerSeher

Copy link
Copy Markdown
Owner

Honestly I'll have to try and compare the configs to what I currently use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants