Hello Felipe,
Thanks for the answer. I was not able to find the support tickets, so I had created this topic first. But since you are handling both of them, we can close the case and continue from here.
My flash secure function call was done after my flash read function call (read calibration data). So after reading your answer, I changed the order and put the flash secure function call at the very beginning of my initializations. I also added a dummy delay at device startup to wait for things to get ready.
Now I realized that if I put the flash secure operation at the beginning of my initializations, I can not read the calibration data even once. Now I'm not sure if it is because I can not write my calibration data to flash after the flash secure operation or because I can not read it. How do I know what cause the problem? If I disable flash secure operation, I can read and write to flash successfully without any problem on device resets. I can also double check it by reading the flash hex (since there is not security). But I don't know how to know the cause of the problem when the device is secured.
If there is something wrong with my flash secure operation, can you please give me a routine to prevent others to read our hex firmware from outside? We don't want to limit the flash read/write operations which are requested by the firmware itself. Our hardware and firmware are ready except this flash security operation. We have completed the firmware test, then I added the flash security function and finish the development process and get to the production stage. But I realized that this function affects the test of the application.
Sorry for the long post.
Thanks.