I ordered a Electron, I still struggle to understand how the writing, flashing, reading from the flash memory works. As far as I understand, the Electron is a ST microcontroller and I can use JTAG debug the device.
In most cases, users work at a higher level only updating their user firmware based on the Particle APIs and selected STM32 APIs which are sufficient for most uses.
It’s possible to program it as a raw STM32 device, but while possible, isn’t a supported use case and will involve some experimentation to get it to work.
You can read out the firmware binaries by USB (using dfu-util) or JTAG/SWD off-device.
On the device itself, the STM32 memory maps flash and uses XIP (execute-in-place) so you can read out the flash just by access it as memory. The memory maps are in the datasheet.
System firmware can be flashed by USB (–dfu or --serial), JTAG/SWD, or OTA. If you are taking the Particle system firmware, building locally and using the --program-dfu option is usually the easiest because it’s done right out of the makefiles.
Building a bootloader is also possible using the local toolchain. That can only be flashed in USB serial (–serial) mode, OTA, or JTAG/SWD. The reason is that DFU mode runs out of the bootloader, and since the STM32 does XIP, DFU mode cannot replace the bootloader because the code is running out of the bootloader.