Hello @Pkhot.1 and welcome to the STM32 Community =)
To disable DBANK and switch from DBANK=1 to DBANK=0 (from dual bank to single) it is recommended to execute the code from the SRAM or use the bootloader.
To avoid reading corrupted data from the Flash when the memory organization is changed, any access (either CPU or DMAs) to Flash memory should be avoided before reprogramming.
- If any secure Flash protection is enabled (watemark or block-based), all must be disabled.
- Disable the instruction cache if it is enabled
- Clear the DBANK option bit and all WRP write protection (follow user option modification and option bytes loader procedure).
- Once OBL is done with DBANK=0, perform a mass erase.
- Start a new programing of code in 128 bits mode with DBANK=0 memory mapping.
- Set the new secure protection if needed.
This is applicable when TZEN is disabled or enabled, with a small difference when TZEN = 1 being that the DBANK can only be modified when all secure protections are disabled : secure watermark (SEC WM) or block-based area (SECBB) .
For more details, you can refer to the RM0438 :
- De-activating dual-bank mode (switching from DBANK=1 to DBANK=0) (page 194)
- Rules for modifying specific option bytes (page 195)
Please mark my answer as best by clicking on the "Select as Best" button, if it answered your question :smiling_face_with_smiling_eyes: This will help other users find this solution more quickly.
Imen