Skip to content

Put string literals in flash memory #72

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

Closed
jgfoster opened this issue Mar 31, 2021 · 4 comments
Closed

Put string literals in flash memory #72

jgfoster opened this issue Mar 31, 2021 · 4 comments

Comments

@jgfoster
Copy link
Member

See the discussion of the F() macro here.

@jgfoster jgfoster added the good first issue Good for newcomers label Apr 13, 2021
eucalvo pushed a commit to eucalvo/TankController that referenced this issue Apr 28, 2021
* docs: update README.md

* docs: update .all-contributorsrc

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
@jgfoster
Copy link
Member Author

jgfoster commented May 7, 2021

This may be a bit more complicated since these literals aren't C strings and can't be printed using printf() and friends.

@jgfoster jgfoster removed the good first issue Good for newcomers label Jun 3, 2021
@jgfoster
Copy link
Member Author

jgfoster commented Jul 9, 2021

According to this,

Classic AVR architecture is referred as modified Harward, because data and memory are in different address spaces (so address 0 could refer to ram or flash, and there are different functions to access them). New AVR (rebranded megaAVR) architecture is instead more conventional as flash and ram share the same address space (like ARM) so there's no need for special treatment if a variable is only in flash (adding const modifier is enough).

Therefore, "F() is useless in megaAVR architecture."

@jgfoster jgfoster closed this as completed Jul 9, 2021
@jgfoster
Copy link
Member Author

It appears that we can recover a substantial amount of memory by using the flash memory for strings. See #249 where we doubled free memory (from 1553 to 3113).

@jgfoster jgfoster reopened this Aug 26, 2021
@jgfoster
Copy link
Member Author

Fixed by #251. This gives us over 3000 bytes of free memory.

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

No branches or pull requests

1 participant