Hi Nico,
Thanks for your suggestions. Please look at the modified diagram.

On Tue, Jun 14, 2022 at 3:45 AM Nico Huber <nico.h@gmx.de> wrote:
Hi Aarya,

On 10.06.22 15:59, Aarya Chaumal wrote:
> Over the last few weeks, my mentors and I worked on the algorithm to be
> implemented for erase function selection, and it's finally complete. Please
> look at this

the depicted strategy looks quite good, IMO :) I originally thought we
could solve the problem without a global view (building the list of
everything that needs to be erased). But having read your flow chart,
I believe it's a very good solution.

I have two remarks on the selection of later erase functions, i.e. the
step

  Are more than half the subsectors within
  the current sector also marked

You already mentioned at the beginning that we might have a problem if
the region is not erase-block aligned. If this is the case, we should
choose the smallest erase block to minimize the risk to hit any read/
write protection, e.g. check

  region start <= current sector start &&
  current sector end <= region end 

If not, skip the sector for the current erase function.
I have added this condition to the new flowchart.

And because we have to deal with a non-homogeneous sector selection
(marked subsectors of different sizes) eventually, we shouldn't count
"subsectors" but bytes, I guess.
Thanks for pointing this out. We shall use addresses (start and end address of a sector) to mark/recognize the sectors.

Aarya.

And many thanks for drawing the picture! its quite helpful. We should
definitely keep a final version in the documentation.

Nico