Search code examples
assemblyarmcortex-mstm32f4

cortex m4f havard (architecture) "programming itself" possible?


I have an STM32F446 processor (Cortex M4 with FPU, havard architecture) and I planned to build a "mini computer" (screen, keyboard) with it.

Is it possible to programm assembler on the device itself and let it programm/flash itself with that code or execute that code without the help of external hardware? And if so how can it be done?

Thank you for your answers.


Solution

  • Yes, it is possible.

    First, realize that the ARM Cortex-M parts are not a true Harvard architecture, but rather a sort of Harvard-ish optimization implementing a Von Neumann programming model.

    As for specially how you do it, the answer is that you read the applicable ST Application Note on writing to flash on that particular processor.

    Along the way you'll probably learn that it ships with a ROM bootloader capable of writing to flash, and also that "externally" writing flash via SWD/JTAG typically in actual practice amounts to uploading a buffer of data to RAM along with a small stub of code to do the actual writing, and triggering that code to execute on the processor before returning control the the SWD/JTAG adapter.