简体   繁体   中英

Is an MCU typically programmed to leave some of its RAM unused?

It seems to me that MCU RAM holds linker values, globally scoped variables, heap, stack, and then some portion is unused.

As a result, do engineers tend to release firmware that leaves some chunk of MCU RAM unused as it is unneeded for the application to work?

It depends on the application. In some cases, you might design some unused RAM in order to allow for future patches and growth. In many cases, you would just take whatever is unused and use that to enlarge the heap or stack or some application specific buffers.

When the hardware is selected or designed, it is unlikely that the development team will know precisely how much RAM will be required - it depends on the application, algorithms, data structures used, changes in requirements during development, and what compiler and compiler options are used.

Moreover memory devices come in specific discrete sizes, if your application required 28Kb of RAM, it is likely that you will choose at least a 32Kb part, because you will probably not find a 28Kb part!

Also it would be short-sighted to believe that RAM requirements will not change during maintenance of a project with software updates, so you need some headroom for that. Your end users would not be impressed if you said they could have the bug-fix for the software, but to get it they need to change their hardware too! In addition, the same hardware may be reused on a different, larger project, and reuse of hardware is even more cost effective that reuse of software.

In some cases, the linker might automatically allocate the heap to use all available memory not allocated for other purposes. Where the heap is fixed however, it may be useful to leave some unused space, so that in maintenance, you may not have to re-size the heap every time non-heap memory usage increases.

It depends on the appplication and the controller. Some controllers reserve specific ranges of RAM locations for, say, bootloader workspace or USB/IP buffer space. Application segments placed in RAM also cover various ranges. Some code/data may be copied or mapped into RAM at startup, for example.

In all my embedded apps, all remaining spare space is just given over to the heap, (as suggested by @TJD).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM