I think I can build a bootable image with the embedded version as installed through fpcupdeluxe.
I checked the device and cpu configuration files, and they look pretty good, but they're only available for the common STM32F controllers. The ones I had weren't available.
I installed Arduino and the STM32 support, the devices I had were available and the simple program (flash the led) worked right away. But Arduino isn't a real development platform, it's for light hobby usage only.
I installed the (brand new) official STM32 development platform. At the start you have to run the STM32CubeMX tool, which generates the startup and initialization code. This is a mess of lots of .h files, with either a HAL (the default) or a Low Level interface. And I am talking about the LL interface, the HAL one is a maze. This generates a project with a lot of source files with in total about 20 lines of C code to initialize the clock sources. To enable the USB you have to use the HAL.
I hated that, so I installed the Open Source STM32 development platform, which allows you to program to the bare metal. When you create a project, it basically generates a single file with the startup code in assembly. I hunted down, translated and added the configuration of the clock sources from the CubeMX project.
This does work, and the debugging is flawless. But getting the USB to work like this is far too complex.
Next up, as I knew what I needed, I looked closer at the free pascal / Lazarus interface. It was not complete. For starters, all the FPUs are defined as: "fputype:fpu_soft". And while the larger controllers can have multiple banks of RAM and Flash (with different starting addresses), only continuous chunks seem to be supported. Fortunately, all the register names and addresses are there.
The FPU should work if you fill in the right value, the startup code is there, and the supplied device files look like they are from before ST chopped them up and packaged them into LL and HAL chunks. But I would have to make my own for the devices I had.
I bought some new, supported devices and when they finally arrived, I could start programming them. Well, after generating and translating the CubeMX code that configures the clock sources. And activating the USB...
Ok, let me put it like this: a quarter of the Reference Manual for the STM32F401 is about the USB. It's complex. DIY is going to take a lot of time. Especially because the ST Virtual COM Port Driver has to recognize and understand it.
What would be the simplest way to get this to work? I'm going to try to generate the CubeMX project and see if I can get the IDE to compile it to assembly, and import that, but that will still be very time-consuming.