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.
faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

BaseFlash simulation driver

Postby faisal » Mon Oct 31, 2022 4:42 pm

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 225 times

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: BaseFlash simulation driver

Postby faisal » Mon Oct 31, 2022 5:18 pm

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 220 times

User avatar
Giovanni
Site Admin
Posts: 14463
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1080 times
Been thanked: 922 times
Contact:

Re: BaseFlash simulation driver

Postby Giovanni » Mon Oct 31, 2022 6:49 pm

Moving to change request.

Giovanni


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 2 guests