-
8000
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/flash_utils: helpers to store data in flash #18148
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is worth the maintenance overhead. It makes code more unique, less readable, less idiomatic, less understandable, for all platforms. All to save RAM on low-end boards like ATmega328P and ATmega32U4.
There was an understanding that RIOT does support Atmegas somewhat, but won't compromise too much for that support. This PR crosses that line.
There are many reasons:
-
_flash
et all, where do we use that? Are we gonna request new PRs to use that and flash_utils where appropriate? I guess we do agree that those at least decrease readability and increase the uniqueness of our codebase, which is rarely a good thing. And this forces a specific coding style just for the benefit of an obsolete architecture... -
the mapped functions (strlen, strcmp, ...) are difficult enough to get right with the combination of multiple libcs, multiple compilers, multiple intrinsics (libgcc, compiler-rt), multiple optimization levels. Adding another layer on top is opening a can of worms.
-
macros. they seem to creep in lately. but they suck. XFAs just doesn't work without, but are pretty contained, there's no other way, and they (potentially) provide huge benefits. In rare cases, macros increase readability, at a cost. There's "standard macros" (
ARRAY_SIZE
) which almost go by as idiomatic C. But wrappingputs()
andprintf()
? please no!PRIsflash
is also way too special for my taste.
🎉 This now passes a full Murdock run :) |
dist/tools/insufficient_memory/add_insufficient_memory_board.sh
Outdated
Show resolved
Hide resolved
This needs a rebase |
This allows using the __flash qualifier to store data into flash.
320731d
to
7a188ff
Compare
This adds a layer of convenience abstraction over classical Harvard architectures (like most AVRs) that do not map the flash memory into the data address space and modern Harvard architectures or von-Neumann architectures that do so. The motivation is to safe a lot of RAM for AVR by storing constant strings into flash.
This allows automatically moving format strings to flash, provided that code previously compiled fine with `-Wformat-nonliteral` (which in RIOT is the case due to `-Wformat=2`).
06377ff
to
7e58bea
Compare
Bors merge |
Build succeeded: |
🎉 💃 🕺 🎊 |
tryMerge conflict. |
bors wtf? |
Contribution description
This helpers that allow storing, accessing, and working with data in flash that works for both classical Harvard architectures (which do not map flash also into the address space) as well as modern Harvard architectures and von-Neumann architectures.
With this,
examples/default
again runs on the Arduino Uno / Nano. Since this board is still the "entry kit" for many people to embedded hardware, it would be nice to support it with our default example.Testing procedure
examples/default
should run and work on ATmega boards (especially ATmega328P and ATmega32U4 based boards) as well on all other boards now.Issues/PRs references
None