Until now we used a really old STm32f4xx_DFP version 1.0.7. Now we change to the latest version 2.11.0.
In the older version it was possible to use the HASH driver functionality to write to/read from OTP. But in the latest version this doesn't work anymore. There will be just a small changed be necessary in HAL Flash driver to get it work.
// unlock flash access -> OK
// clear write protection flag -> OK
// write data to OTP -> FAILS
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, addr, data);
// lock flash access -> OK
The reason is the following check inside FLASH_Program_Word()
/* Check the parameters */
Because the OTP address (0x1FFF7800U - 0x1FFF7A0FU) doesn't match flash range (0x08000000U - 0x081FFFFFU).
Just expand IS_FLASH_ADDRESS() with the address range from OTP and it would run!!!
Or is there an other possibility to write to OTP? ( I'm not really interested to set the FLASH flags on my own....)