Store all message descriptor parts in program memory on AVR to save SRAM #947
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.
We were having some issues with our builds targeting AVR based MCUs as we only have 8KB SRAM available and the
*_msg
and*_submsg_info
constants were filling up our SRAM a decent amount. So I did some digging and expanded the PROGMEM support in nanopb to extend to the*_msg
and*_submsg_info
parts instead of just*_field_info
.This has resulted in very significant savings to our builds. Averaging a 11% reduction in our total static SRAM allocations.
In my testing, this appears to work correctly in our usage of nanopb. However, we do not make any use of extension fields and the code for that is a bit trickier. I did some digging and I hope that it should also be working normally as well.
This is not necessarily the limit to savings that can be made. When working on this I noticed that due to the
{msg}_DEFAULT
defines being strings, they also end up in SRAM allocations on AVR, although they are a bit more subtle as anonymous strings don't end up with symbols, so you have to inspect deeper to see them in an objdump. I wanted to implement the optimisation for those as well, but it was a bit trickier to get going and the savings we would get were far smaller overall.