If you would like to debug&run program without flashing the device you can follow this procedure:
1. Create a project in Keil manually or using CubeMX
2. Project->Options for Target STM32...->Target
-the amount of RAM to split between IROM and IRAM can be taken from the IRAM size field
and set new IROM/IRAM values, e.g. in this case the 0x40000 was split in two halves and IROM and IRAM fields were set accordingly (notice that the IROM starts at 0x20000000, exactly where the RAM starts, the IRAM starts at 0x20000000 plus the half of the available RAM memory).
3. Project->Options for Target STM32...->C/C++
-add the VECT_TAB_SRAM to the define field
-optionally you can change the Optimization to O0 or O1 when you want to avoid optimization at O3 level (this helps debugging code)
4. Project->Options for Target STM32...->Debug
-Copy the Dbg_RAM.ini file to the project folder (e.g. C:\Users\abg015\Desktop\STM32\STM32F412-LCD-TS\MDK-ARM)
-select the Dbg_RAM.ini as initialization file
-you can remove the programming algorithm from Project->Options for Target STM32...->Debug->Settings->Flash Download to be sure that the board cannot be programmed
5. Project->Options for Target STM32...->Utilities
-uncheck the Update TArget Before Debugging to avoid flashing the board
6. Run debugger: Debug->Start/Stop Debug Session. You can set Breakpoints earlier.