I am using FPC and Lazarus to do some STM32 programming. I found that the download speed in flash is slow, and the flash memory has a limited number of erase times, and I like running code with small changes.
So, I think running in the internal SRAM is better, with fast speed and unlimited read and write times.
In fpcupdeluxe (or build rtl by hand), add -dREMAP_VECTTAB to build options, this will enable some code in cortexm0_start.inc, cortexm3_start.inc and cortexm4_startf.inc which allow interrupts.
Switch the platform in Lazarus, and add -WpSTM32XX (which use) and -sT to compiler options, build and it would generate xxx_link.res and xxx_ppas.sh on the project directory, open the xxx_link.res, replace the code (depending on the chip, the LENGTH is different):
MEMORY
{
flash : ORIGIN = 0x08000000, LENGTH = 0x00100000
ram : ORIGIN = 0x20000000, LENGTH = 0x00020000
}
with
MEMORY
{
flash : ORIGIN = 0x20000000, LENGTH = 0x00010000
ram : ORIGIN = 0x20010000, LENGTH = 0x00010000
}
Note the SRAM size your chip has, My STM32F407ZG has 128KB SRAM from 0x20000000 to 0x2001FFFF.
Run the xxx_ppas.sh, use arm-none-eabi-gdb to load the elf, and can debug in command line (download is really fast).
I want to debug in Lazarus not the terminal, I don't know how to pass some parameters to let FPC set the flash and ram as I need. Or use -k to pass some parameters to gnu ld (I tried some, but failed), or it is impossible for the current version(trunk)? Maybe can make a feature request?
Does anyone know it?