[FEATURE REQUEST] avr: typed constants (including string constants) residing in ROM
Original Reporter info from Mantis: georghieber
-
Reporter name: Georg Hieber
Original Reporter info from Mantis: georghieber
- Reporter name: Georg Hieber
Description:
Today, typed constants (and this includes all string constants, even if not declared as a typed consant) are transferred from flash ROM into RAM at startup. This facilitates their access (exactly as variables), and is in accordance with the documented behaviour that their value can be changed at run time.
This implementation has a serious drawback: it uses up a lot of, especially in the smaller AVR's, precious RAM. For that reason, an implementation that leaves typed constants in ROM and only accesses what is necessary (maybe copies on demand into a buffer) would be highly desirable. The behaviour of typed constants could either be controlled by the J compiler directive - {
J+} enables the present situation that constants are copied into RAM and writeable at run time, {$J-} leaves them in ROM, or by a qualifier to the constant declaration like
const greeting = 'welcome to my latest gadget'; progmem;
The latter would imply J- for the so qualified constant.
Additional information:
Presently it is not even possible to implement something similar in Assembler (if there is, I did not find it.). There is no way to insert anything that is not code into the ROM. Constants, Strings are copied, and the inline assembler does not accept the .byte, .ascii …. directives.
Just to demonstrate the importance: An application might have 50 short messages that can be shown on a LCD display, of an average length of 10 characters. Together these strings occupy 550 bytes. The user can select between English, German, French, Spanish and Italian. The program shall run on an atmega324, which has 1k of RAM...
Mantis conversion info:
- Mantis ID: 32074
- OS: embedded
- Platform: avr
- Version: 3.1.1
- Monitored by: » @SAmeis (Simon Ameis), » kupferstecher (kupferstecher), » @d.ioannidis (Dimitrios Chr. Ioannidis), » @ccrause (Christo Crause)