BaseFlash simulation driver

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
faisal
Posts: 382
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 45 times
Been thanked: 62 times

BaseFlash simulation driver

Post by faisal »

Here's a simulation driver for a BaseFlash. It uses a file on disk as the backing store.

One cool feature is that it supports a memory mapped mode as well - caching the file in RAM, and using the base address of the cache as the .address in the flash_descriptor. Downside is that it allocates enough memory to cache the entire simulated flash, and refreshes it on every erase/program operation. This is relatively cheap for small flash sizes, but can become prohibitive for large ones. An improvement would be to mmap() the file with PROT_READ (anyone wanna contribute this?)

I've tested this with the MFS test suite, and and other custom higher level libraries that use BaseFlash objects.
Attachments
sim_flash.zip
(4.11 KiB) Downloaded 937 times
faisal
Posts: 382
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 45 times
Been thanked: 62 times

Re: BaseFlash simulation driver

Post by faisal »

Here's one that specific for EFL - which can be added to os/hal/ports/simulator/posix. It's very similar. A notable difference is that this has a flash_descriptor_t that is defined in the LLD driver itself (configurable via preprocessor symbols) - as opposed to the generic driver above which expects a ptr to a flash_descriptor_t as part of the configuration.
Attachments
hal_efl_lld.zip
(4.4 KiB) Downloaded 857 times
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: BaseFlash simulation driver

Post by Giovanni »

Moving to change request.

Giovanni
Post Reply