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

Move some constant arrays from data to text section #9187

Merged
merged 2 commits into from
Mar 29, 2018
Merged

Conversation

bkueng
Copy link
Member

@bkueng bkueng commented Mar 29, 2018

2 Arrays with constant data in uORB and the tunes library were marked as 'const T *' array, which means the data of the array was not actually const and thus landed in the data section (so in RAM instead of FLASH).

Reduces RAM usage by ~500 bytes.

@potaito fyi

_default_tunes was marked as 'const char *' array, which means the data
of the array was not actually const and thus landed in the data section
(so in RAM instead of FLASH).
The size of the array is 64 bytes.
_uorb_topics_list was marked as 'const char *' array, which means the data
of the array was not actually const and thus landed in the data section
(so in RAM instead of FLASH).
The size of the array is 436 bytes.
@potaito
Copy link
Contributor

potaito commented Mar 29, 2018

@bkueng Awesome, thank you very much. How did you find it? :)

@@ -56,7 +56,7 @@ msgs_count_all = len(msg_names_all)
@[end for]

const size_t _uorb_topics_count = @(msgs_count_all);
const struct orb_metadata* _uorb_topics_list[_uorb_topics_count] = {
const constexpr struct orb_metadata* const _uorb_topics_list[_uorb_topics_count] = {
Copy link
Contributor

@potaito potaito Mar 29, 2018

Choose a reason for hiding this comment

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

Wouldn't constexpr alone instead of const constexpr suffice?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case yes. But more is more :D

@bkueng
Copy link
Member Author

bkueng commented Mar 29, 2018

How did you find it? :)

I was looking at what needs how much space in the different ELF sections. For example you can look at the largest consumers in the data section with:

nm -C --print-size --size-sort --radix=d nuttx_px4fmu-v2_default.elf |grep -i ' d '

@potaito
Copy link
Contributor

potaito commented Mar 29, 2018

Thanks, I did not know that

@dagar dagar merged commit 0038a5e into master Mar 29, 2018
@dagar dagar deleted the const_fixes branch March 29, 2018 14:06
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.

4 participants