The granularity of the erased section depends on the target device. The smallest size of Flash memory that can be erased is defined with the Flash sector size. This Technical Note describes how to erase a part of a Flash memory with a Python script.
A Python script example is attached to this document.
Sorry this article didn't answer your question, we'd love to hear how we can improve it.
Note: This form won't submit a case. We'll just use it to make this article better.