sys/flash_utils: helpers to store data in flash#18148
sys/flash_utils: helpers to store data in flash#18148bors[bot] merged 9 commits intoRIOT-OS:masterfrom
Conversation
kaspar030
left a comment
There was a problem hiding this comment.
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:
-
_flashet 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!PRIsflashis also way too special for my taste.
529afdd to
d438379
Compare
|
🎉 This now passes a full Murdock run :) |
|
This needs a rebase |
This allows using the __flash qualifier to store data into flash.
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`).
|
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/defaultagain 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/defaultshould run and work on ATmega boards (especially ATmega328P and ATmega32U4 based boards) as well on all other boards now.Issues/PRs references
None