Nice work KR and great Documentation! Kudos BTW, I added a comment about using AVR_BOARD_HAS_FLMAP vs ARCH_HAVE_FLMAP.
BR, Alan On Mon, Jul 7, 2025 at 7:23 AM <kr....@kerogit.eu> wrote: > Hello, > > I would like to submit patches which change handling of const variables > in AVR architecture, DA/DB family. > > AVR is a Harvard architecture with separate address spaces for program > and data memory. Unless the compiler is instructed otherwise, C pointers > are always referring to the data memory. Variables declared with const > must therefore be copied to RAM to be accessible - which is undesirable > since RAM is a limited resource on these chips. There are other > approaches that can be taken but they are either not supported in NuttX > or the support is quite limited. (These approaches are described in the > document added in patch 0002 and adding full support for them would > require fairly disruptive changes so that is unlikely to happen.) > > Newer chips offer an alternative solution - part of the program memory > (a 32kB window) is mapped into data memory address space. Const > variables can be placed into this window, making them accessible while > using standard (data memory) pointers. This patch series adds support > for this into both AVR architecture code and Breadxavr board. > > Series was tested by verifying string addresses - parameters in printf > call in a custom application - in disassembly (and also by running the > application and verifying its output.) Documentation was tested by HTML > build. > > Short summary of the patches: > > 0001 - fixes Ctrl-C error in a comment, unrelated otherwise > 0002 - adds a document that describes previously existing options of > avoiding copying const variables into RAM > 0003 - patch that makes use of the memory-mapped flash > 0004 - ops structure in serial driver is marked as const > > This patch series should not affect older AVR chips which do not have > the memory-mapping. > > All patches are attached to this message and also available in a git > repository nuttx.git at git.kerogit.eu accessible through HTTP/S. > (Trying to prevent bot traffic by not posting the URL in > machine-readable form.) The relevant branch is called avrdx_flmap_v1. If > the patches are acceptable, I would like to ask someone with GitHub > account to open a PR (I don't have a GH account.) Any comments or > suggestions are welcome. >