Hello, and welcome to the forum.
This is a frequently addressed topic within this forum. A recent thread about the programming process is here. Maybe this will help. But use the forum search engine to find further threads on this topic. However, you will first need to become familiar with the flash erase and programming processes, as described in the datasheet or reference manual, within the "Memory" section.
The simplest situation is where the non-volatile data sector erase occurs sufficiently infrequently that flash "wear out" is not an issue. For more frequent update of the non-volatile data, much more complex "wear spreading" techniques neen to be adopted.
Regards,
Mac