LPC1114FN28/102 programming on macOS

I am currently tutoring on a microprocessors module in TU Dublin where students have the opportunity to learn about hardware and software aspects of microprocessors and microcontroller systems development. The microprocessor we are currently using is the LPC1114FN28/102 processor, an ARM Cortex M0 microporcessor in a 28 pin dual inline package format. A pinout is shown here.

/media/uploads/asagin/mbedlpc1114fn28-01.png
Image source

Currently, we are programming these using a hardware debug tool that supports Serial Wire Debug, and a USB to serial converter, which is setup initially for Windows devices. Although, some students do prefer to use their own devices and in certain cases these are Mac operating systems so I’ve decided to outline the steps I have taken to allow for the programming of the LPC1114FN28/102 processor on a macOS.

Homebrew package manager

I typically use Homebrew where possible to maintain a list of any packages I download and install on my own macOS. Homebrew is a package manager that allows users to download and install packages using the Terminal program on a macOS.

Screenshot 2020-02-15 at 17.47.31.png

There is a brilliant tutorial on the Homebrew website about how to use their tool via Terminal and I will try to talk you through the relevant steps here. First, to install Homebrew open a new terminal and run the following command.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This will allow you to use brew commands now, for example I used “brew” to “search” for installation files for “inkscape”.

Screenshot 2020-02-15 at 17.49.42.png

Once Homebrew is installed we can move onto the next part, installing the GNU toolchain which will have the compiler used for converting the source files.

GNU toolchain installation

The GNU toolchain can be installed manually by downloading the require libraries,  extracting the correct location, and by setting the required path, or we cal let Homebrew do all the hard work for us. A set of users on GitHub have provided the required commands to use brew to install the GNU toolchain, and these commands are,

brew tap ArmMbed/homebrew-formulae
brew install arm-none-eabi-gcc

If installed successfully, Homebrew will tell you with a terminal screen similar to this (notice I reinstalled for demonstration purposes).

Screenshot 2020-02-15 at 18.00.28.png

You can test at this point to see if the compiler can be run from the terminal screen by using the following command.

arm-none-eabi-gcc

Without specifying a source file and arguments you should get an error, see my terminal scree for example.

Screenshot 2020-02-15 at 18.02.04.png

lpc21isp downloader installation

To download the code via the USB to serial converter, an in-circuit programming (ISP) tool is required. This is used to download the machine code produced with the GNU toolchain via a specified serial port. This link provides an explanation on how to do this with Homebrew! The commands are shown below.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"  /dev/null
brew install lpc21isp

With the lpc21isp installed we can begin programming our microprocessors!

An example of the code used to compile a source file and download the .hex to the microprocessor could be as follows.

arm-none-eabi-gcc -static -mthumb -g -mcpu=cortex-m0 *.c -T linker_script.ld -o main.elf -nostartfiles
arm-none-eabi-objcopy -g -O ihex main.elf main.hex
lpc21isp main.hex /dev/ttyUSB0 9600 12000000

I ran these commands in my own terminal with the appropriate files in my current directory. The result is shown in the screenshot below.

Screenshot 2020-02-15 at 18.29.58.png

Some additional info

Two more points that I think will be useful if you decide to program your LPC1114FN28/102 with this method.

First, the view the open com ports on a macOS, use the following command.

 ls /dev/tty.*

Screenshot 2020-02-16 at 09.04.33.png
Second, you may need to install the drivers for your own USB to serial converter, which can be down via Homebrew too!