Repository navigation
CMake builds: MP3 decoder buffers from the heap, not static .bss - #299
Merged
Merged
Conversation
… heap micropython.cmake set the allocator macros on buffers.c with set_source_files_properties(), which belongs to the directory that sets it. The ESP32 build compiles each module source a second time from the project's directory, and that is the copy that gets linked, so it had the static fallback: 23.8 kB of .bss, internal RAM on an S3. Define the macros in src/audiomp3/mp3_buffers.c and include buffers.c from there, so every compile of it gets them. On an ESP32-S3 audiodsp's .bss goes from 25,296 to 1,480 bytes, and each MP3Decoder has buffers of its own.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On an ESP32-S3 the MP3 decoder's eight Helix buffers sat in internal RAM as static
.bss, 23.8 kB of the 25.3 kB audiodsp holds there.micropython.cmakealready asked for them from the heap, but the setting was aset_source_files_properties()onbuffers.c. That property belongs to the directory that sets it, and the ESP32 build compiles every module source again from the project's directory, which is the copy that gets linked. That copy used the static fallback.src/audiomp3/mp3_buffers.cnow defines the allocator macros and includesbuffers.c, so every compile of it gets them, in any directory.buffers.cand the other Helix sources are unchanged, and the Make build is as before.Measured on an ESP32-S3 (ESP32_GENERIC_S3, SPIRAM_OCT) with the whole module set:
.bss: 25,296 B before, 1,480 B after.MP3Decodernow takes about 35.5 kB from the GC heap (PSRAM here), where it took 11.6 kB before, because the buffers are no longer static, and two decoders no longer share buffers.