8000 sys/flash_utils: helpers to store data in flash by maribu · Pull Request #18148 · RIOT-OS/RIOT · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 9 commits into from
Feb 27, 2023

Conversation

maribu
Copy link
Member
@maribu maribu commented May 30, 2022

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

@maribu maribu added the Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR label May 30, 2022
@maribu maribu requested a review from kYc0o as a code owner May 30, 2022 19:25
@github-actions github-actions bot added Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: SAUL Area: Sensor/Actuator Uber Layer Area: sys Area: System Platform: AVR Platform: This PR/issue effects AVR-based platforms labels May 30, 2022
@maribu maribu changed the title [PoS] sys/flash_utils: helpers to store data in flash [PoC] sys/flash_utils: helpers to store data in flash May 30, 2022
Copy link
Contributor
@kaspar030 kaspar030 left a 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 wrapping puts() and printf()? please no! PRIsflash is also way too special for my taste.

@maribu maribu force-pushed the sys/flash_utils branch from c676e7b to 6f91e43 Compare June 1, 2022 21:00
@github-actions github-actions bot added Area: BLE Area: Bluetooth Low Energy support Area: doc Area: Documentation Area: examples Area: Example Applications Area: pkg Area: External package ports Area: tests Area: tests and testing framework labels Jun 1, 2022
@maribu maribu force-pushed the sys/flash_utils branch from 6f91e43 to 2a45961 Compare June 28, 2022 12:25
@maribu maribu changed the title [PoC] sys/flash_utils: helpers to store data in flash sys/flash_utils: helpers to store data in flash Jun 28, 2022
@github-actions github-actions bot removed Area: BLE Area: Bluetooth Low Energy support Area: pkg Area: External package ports Area: doc Area: Documentation Area: examples Area: Example Applications labels Jun 28, 2022
@maribu maribu removed CI: full build disable CI build filter CI: no fast fail don't abort PR build after first error labels Feb 23, 2023
@maribu
Copy link
Member Author
maribu commented Feb 23, 2023

🎉 This now passes a full Murdock run :)

@benpicco
Copy link
Contributor

This needs a rebase

@github-actions github-actions bot removed the Area: tools Area: Supplementary tools label Feb 27, 2023
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`).
@benpicco
Copy link
Contributor

Bors merge

@bors
Copy link
Contributor
bors bot commented Feb 27, 2023

Build succeeded:

@bors bors bot merged commit f0b60d5 into RIOT-OS:master Feb 27, 2023
@maribu maribu deleted the sys/flash_utils branch February 27, 2023 13:48
@maribu
Copy link
Member Author
maribu commented Feb 27, 2023

🎉 💃 🕺 🎊

@bors
Copy link
Contributor
bors bot commented Feb 28, 2023

try

Merge conflict.

@maribu
Copy link
Member Author
maribu commented Feb 28, 2023

bors wtf?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: pkg Area: External package ports Area: SAUL Area: Sensor/Actuator Uber Layer Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: AVR Platform: This PR/issue effects AVR-based platforms Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
0