I currently (Winter 2018) use Windows as my main development machine, however, I'm fairly certain all of the following steps can be similarly done using a typical Linux distro or possibly even MacOS.
- An STMF32F411 development board. Currently they can be ordered from the usual sites for around $15 USD plus shipping.
- Download and install the GNU Arm Embedded Toolchain
- Download and install GNU Make for Windows
- Download OpenOCD and uncompress it (preferably to c:\OpenOCD).
- Download and install the STM32 ST-Link Utility.
Compiling and Flashing the Program to the Dev Board
- Open a GCC Command Prompt. Note that a "GCC Command Prompt" option was installed when installing the GNU Arm Embedded Toolchain and should be available from Windows Start Menu.
- Change to the ArmCortexM4Analysis directory and run "make". This will compile the C program (main.c) and the startup assembly file (startup.s) and use the LinkerScript.ld file to create the ELF file which is then converted to out.bin - the actual binary that will run on the STM32F411.
- Open the STM32 ST-Link Utility and select "Program" from the "Target" pulldown menu.
- Navigate to the ArmCortexM4Analysis directory and select out.bin.
- Click "Start" to flash out.bin to the development board. After this is done you should see LEDs on the development board blinking (i.e. the program is running on the board).
Debugging from the Command Line
- Make sure to close the STM32 ST-Link Utility so OpenOCD will be able to connect to the dev board.
- Open another command prompt.
- Change directory to the ArmCortexM4Analysis directory.
- Run OpenOCD.bat. Note that if you did NOT uncompress OpenOCD to c:\OpenOCD you'll have to modify the first line of OpenOCD.bat to point to the directory that OpenOCD exists in.
- Switch to the original GCC command prompt you opened when compiling and run arm-none-eabi-gdb.
- After GDB starts up, at the prompt, type "target remote localhost:3333" and press enter. This will connect to OpenOCD.
- Next, type "monitor reset halt" at the GDB prompt to stop the currently running program.
- Then, load the ELF file into GDB by entering "file out.ELF". It'll ask you "Are you sure you want to change the file?", answer "y" for "yes".
- You can then use "si" to step through each instruction of the program.