Assembly Language Blinky README

Aim

This document hopes to show how that Cortex-M0 Assembly Language programming can be fun when used with certain aids.

These aids include: * GDB-TUI, the GNU Debugger * SVD2equ include file for memory mapping * A BlackMagic Pill with a MCU target or a STM32 Discovery

Target Audience

Existing knowledge of Cortex-M0, familiarity with the documentation

Mcu

The Target MCU can be any MCU supported by GDB and in this instance a STM32F051 is used.

Hardware

  1. A Black Magic Pill (BMP) to use with an external mcu, please see: <URL> -OR-

  2. Otherwise a STM32F0 Discovery board can be used.

Note

different .gdbinit files will be required for either hardware choice above but they are given below.

The Assembly Language Program

An Assembly Language program to blink a LED will be used in this example because it’s short and provides visual feedback that everything is working.

Hardware Notes

The LED is connected to GPIOB-8 because the port pin used on the STM32F0 Discovery board isn’t available on the external MCU I used in choice 1, above.

If you’re using a F0 Disco, just connect a LED to PB-8 to use with the program sourcecode below, or better still, change it to suit the LED on the Discovery Board at PC-8 ? It’s much easier than it looks thanks to the use of the svd2forth STM32F0xx-tp1.svd.equates.s file used in a .include directive.

Useful References

ARM-ASM-Tutorial

By Niklas Gürtler. This is a fantastic Assembly turorial written for the ARMv7-M, Cortex-M3 STM32F103 MCU which is a lot more advanced than the Cortex-M0 I’m using in this tutorial, but all the important parts of the process such as the Linker usage are the same.

https://www.mikrocontroller.net/articles/ARM-ASM-Tutorial

Useful-GDB-commands

https://github.com/blacksphere/blackmagic/wiki/Useful-GDB-commands

Debugging with GDB

https://sourceware.org/gdb/current/onlinedocs/gdb/