0
votes

I need to implement a dynamic allocation algorithm for a NOR flash memory.

The idea is to implement a memory management algorithm and an abstraction mechanism that allows you to dynamically allocate rewritable blocks that are smaller than the Erasable Block Size.

I would like to understand if there are already case studies and approaches to known algorithms, from which to take inspiration.

Thanks

1
Usually one erases the whole flash and then from the lowest address and upwards allocates data chunks with different identifiers for each data type. The chunk with the highest address is the relevant one, others are outdated. Repeat until reaching end of segment. This saves erase cycles but has pretty much no other benefits. Lookups are very slow. A more sensible approach is always to get a part with small data flash/eeprom segments, turning this all into a non-issue.Lundin

1 Answers

0
votes

Dynamic allocation is related to how you write your program: you want to allocate memory at runtime depending on the execution context and not once for all when your program boots. It requires pure software mechanisms, basically book a dedicated area of memory and implement allocation / free functions.

It is not really related to the kind of memory you are using.

I guess you could implement malloc / free functions to Flash memory. However Flash is not designed to do many cycles of erase/program.

If you really need that, you should have a look to the concept of Flash Translation Layer. It is some kind of library providing a virtual memory space on the Flash. It aims to reduce Flash wear and to improve write time.

But again, you should really question the real need to do dynamic allocation to Flash.