USER_APP Flash start address=0x08006000, but STLINK erases the internal flash from 0x08004000
I'm using STM32F401RB, which has an internal 128KB flash.
IAP bootloader is using about 20KB. So, I set USER_APP's flash address to 0x08006000 (24KB)
When I download the USER_APP hex file with STLINK UTIL or STM32CubeProgrammer, they erase the flash from 0x08004000 (16KB).
So, it erases a part of IAP bootloader.
What should I do to fix this ?
Additional Info :
When I change USER_APP's flash address to 0x08008000 (32KB), the download tools erase from 0x08008000 (32KB).
Then, IAP bootloader and USER APP work fine.
Thanks...
---------------------------------------------------------------------------------------------
Self-answer
In RM0368, I found that STM32F401RB's 128KB eflash is divided into
- 4 sectors of 16KB
- 1 sector of 64KB
Since the eflash erasing will have a boundary as the sector sizes,
the erasing from 24KB is not possible.
* I had worked with other MCU which has 1KB page or something else.
So, I'm get confused.
