First Steps in ARM Development

Caio Tavares
GPI/O
3 min readNov 2, 2020

--

Macro picture of a processor connector
Photo by Pok Rie on Pexels

Motivation

As a Software Engineer with an Electrical Engineering background, I've always liked bare-metal systems, but rarely have a chance to play with them in my day-to-day. So, naturally, I decided that it's time to build my own Gameboy Color with an ARM processor to fill this need.

To get started, I bought a MSP432P401R Launchpad from Texas Instruments, a development board with an ARM Cortex M4F at its core, 256KB of flash storage and 64KB of RAM. It's fairly cheap and has everything I need to start learning how to develop embedded applications (right now, LEDs and an onboard debugger are more than enough).

Now it's time to write some code.

Setting Up

So, how do we begin? If we follow the Quick Start guide provided by TI, we should download one of the supported IDEs in order to build our first application, but honestly, that sucks. Most of these IDEs have a terrible user experience and if you're a software engineer like me, chances are you already have a favorite editor with all your keyboard shortcuts configured.

So let's try something different.

First of all, we need to download the MSP432 SDK, which contains system configurations (such as setting clock speeds) and a hardware abstraction layer (HAL) that exposes C APIs for interacting with peripherals, as well as examples that we can use to write our first application. After installing it, export its install location to the environment variable ARM_SDK_HOME, this will help through the build step.

We also need a compiler and debugger client, GNU provides a good open alternative to the embedded IDE compilers in the GNU ARM Embedded Toolchain. To install it on macOS, simply run:

$ brew install armmbed/formulae/arm-none-eabi-gcc

For other platforms, follow the instructions on GNU download website. As before, export the install location to the GCC_ARMCOMPILER environment variable.

Finally, we need a way to connect to the onboard debugger XDS110, for that we can use OpenOCD. It establishes a connection to the physical debugger and starts a server listening for connections on TCP/3333 on which we can connect our GDB client installed with the GNU ARM Toolchain.

$ brew install openocd --HEAD

Make sure to install the latest commit (or at least newer than c9ebd4) which includes the MSP432 Launchpad configuration. You may also need to install openocd dependencies autoconf, automake and texinfo.

Now that we have all the necessary tools, we can compile and flash our first application, the Blink LED example provided by the SDK.

hello_world.c

The SDK provides a ton of application examples divided into RTOS and NoRTOS, since we're still taking our first steps in embedded development, we will go to the simplest NoRTOS example.

# Go to the demos directory
$ cd $ARM_SDK_HOME/examples/nortos/MSP_EXP432P401R/demos
# Open the BlinkLED GCC example
$ cd blinkled_msp432p401r/gcc
$ make

The build process will generate the blinkled_msp432p401r.out binary file.

To flash the application into the microcontroller, open a OpenOCD session in a terminal and leave it running:

$ openocd -f board/ti_msp432_launchpad.cfg

You should see something like this:

In a separate terminal, open the GDB client, connect it to the OpenOCD server and load the application:

$ arm-none-eabi-gdb
$ (gdb) target remote :3333
$ (gdb) load blinkled_msp432p401r.out

Thats it! Now you can either type continue in the GDB client terminal or press the physical reset button on the Launchpad and you should see a blinking red LED!

If you want a less cluttered project to kickstart your ARM development instead of using the SDK examples, make sure to checkout my arm-hello-world repository. It's a slightly modified BlinkLED with better output organisation and a .vscode configuration to handle code-completion and other IntelliSense magic tricks.

That's all folks!

--

--