Developing on ARM – Everything you need to know

Developing on ARM

There is no doubt about the popularity of ARM’s range of microprocessor designs. From small microcontrollers to its multi-core 64-bit processors, ARM is responsible for the design and intellectual property in everything from white goods to server farms. The use of ARM based processors in smartphones and tablets means that both Android and iOS users rely on these chips every day.

The ubiquity of the ARM architecture means that there is a high demand for ARM savvy developers. These developers are needed to create the next generation of software that will run on ARM processors. So, if you want to write software that will run on ARM processors, what do you need to know?

ARM has ensured that all the tools needed to develop for ARM processors are available, under both commercial and open-source licenses.

The first thing you need to know, before we get into the specifics, is that it isn’t hard. ARM has ensured that all the tools needed to develop for ARM processors are available, under both commercial and open-source licenses. The next question is, what type of device do you want to develop on? ARM’s range of processors starts with its Cortex-M microcontrollers. These small processors run at low clock speeds (from around 16Mhz to around 120Mhz) and have a small amount of system RAM (between 4K and 256K). At the other end of the scale are multi-core 64-bit processors which run at GHz speed and have access to gigabytes of memory. In between you have single board computers, Chromebooks and smartphones.

arm-arch-evolution

The easiest way to describe the different development environments is to look at them one at a time. However it is important to keep one thing in mind, all these different categories are essentially using the same processor architecture. If done right, and with some caveats, it is possible to take a binary built for a Cortex-M processor and link it into a program designed for a 64-bit Cortex-A57 processor!

Cortex-M

ARM’s range of Cortex-M designs are becoming increasingly important as the new wearables and Internet-of-Things (IoT) markets start to explode. Since these types of devices are low-cost and designed to be ubiquitous, the potential number of chips that will ship over the next few years could be ten times greater than the number of ARM chips that are shipping in smartphones and tablets. This is a potentially lucrative market just waiting to be explored.

Microcontrollers are very bare-metal. When you write a program for one you need to do all the heavy lifting yourself, there isn’t necessarily a fancy operating system like Linux to provide memory management, file systems, locks, queues and so on. This style of programming is known as “embedded” programming. This doesn’t mean that developers are left to re-invent the wheel every time they write a program, but the mindset needs to be different. Embedded developers can optionally use what is known as a Real-Time Operating System (RTOS). An RTOS is small, fast, deterministic and provides a valuable set of core operating system functions. And as you can imagine there are lots of RTOSes available for ARM processors.

freescale-kinetis

If you want to get started with embedded programming with ARMs Cortex-M range then probably the best place to start is at mbed.org. The mbed project is developed by ARM and it provides all the free software libraries, hardware designs and online tools needed to create rapid prototypes based on ARM microcontrollers.

Mbed compatible boards start at just $12.95 each.

Mbed compatible boards start at just $12.95 each. That will get you a FRDM-KL25Z board with a 48MHz Cortex-M0 processor, 16K of RAM, and 128K of flash memory to store the software. It also includes a 3-axis accelerometer, some LEDs and a capacitive touch sensor. The Mbed project provides an online C compiler and access to ARM’s RTOS called RTX. That means that for under $15 and with access to a web browser you can start programming a Cortex-M0 board.

On the website there are lots of examples along with full documentation. There is also lots of information about how to connect sensors and communication components to the different boards.

Mbed.org isn’t the only solution to programming for the Cortex-M processors. A lot of the board makers provide their own tools. For example, TI has a range of boards (called LaunchPad) and it also provides its own tools for developing with those boards. Other examples include the Arduino Due, which uses a Cortex-M3 processor; and the Arduino Zero, which uses a Cortex-M0+ processor.

There are also commercial solutions from ARM (Keil and ARM Development Studio) and other companies like IAR, AtollicRowley Associates, and Keolabs. These tools support multiple boards from multiple manufacturers. There are also open-source solutions specifically the GNU compiler tool chain and tools like emIDE, CoIDE and Em::Blocks.

Raspberry Pi

Another low-cost entry point into the world of ARM is the Raspberry Pi. At its heart is the Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZF-S running at 700 MHz. The cheapest Pi is just $25 and comes with 256MB of RAM, but has no Ethernet port. The $35 version has Ethernet and an additional 256MB of memory.

raspberry-pi-aa

The board runs a specially built version of Debian Linux called Raspbian. Since the device has Linux it means that many of the common Linux development tools are immediately available including the GNU compiler (for C and C++) and Java. There are also scripting languages like Python, Perl and Lua available, plus Google’s Golang has also been ported to ARM and runs excellently on the Raspberry Pi.

The University of Cambridge has a free online tutorial which shows you how to write a very basic operating system on the Raspberry Pi in assembly language!

Almost any program you write for the Pi in a high level compiled language, or using a interpreted language, will work unchanged on a PC running Linux, there is also a degree of compatibility with Windows and Mac OS X, especially if you write the code in a portable manner.

To take full advantage of the Pi you need a TV or monitor with a HDMI port and you need to add a mouse and keyboard. You also need an SD card for booting Raspbian and for local storage. So the actual cost is probably around $50 to $60 (excluding the TV), however that is still a very cheap way to get into developing for ARM.

If you want to go deeper than just writing programs in a Linux environment then the University of Cambridge has a free online tutorial which shows you how to write a very basic operating system on the Raspberry Pi in assembly language!

It is also worth mentioning the BeagleBone Black which uses a Cortex-A8 processor. The Cortex-A series from ARM uses the ARMv7 architecture, rather than the ARMv6 architecture used by the Broadcom chip in the Raspberry Pi. Prices for the BeagleBone Black start at around $55.

If the Cortex-A8 doesn’t provide the performance you need then there is a range of Single Board Computers from Hardkernel. The ODROID-U3 uses a 1.7GHz quad-core Cortex-A9 based processor from Samsung, and comes with 2GB of RAM. It costs just $65. For top-end performance there is the ODROID-XU3. It uses a Samsung Exynos 5422 processor. The 5422 uses ARM’s big.LITTLE technology and contains four Cortex-A15 cores and four Cortex-A7 cores.

Android

If you already have an Android smartphone or tablet then you can write software for it. The official way to write Android software is with Java using the Android SDK. If you are unfamiliar with programming or with Java then this might not be the best way to start learning. But if you are determined to learn then Google provides lots of Android programming tutorials.

Nexus 4 to get Android Lollipop

However using Java isn’t the only way to develop for Android. One possible alternative is the Corona SDK. It uses the Lua programming language and Corona’s compilers produce the final Android .apk without you needing to know any Java, or any Android specific APIs. Other alternatives include Xamarin (which uses C#), Marmalade (which uses C++, Objective-C, Lua, or HTML5), and Unity. If you know HTML, CSS, and JavaScript then you should take a look at PhoneGapPhoneGap is a free and open source SDK that allows you to create Android apps using standardized web APIs. PhoneGap isn’t the only HTML5 solution, others worth exploring include jQuery mobile and Sencha Touch. The list given above isn’t complete, but it does give you a taste of what is possible.

64-bit servers

At the other end of the scale is the new breed of 64-bit Cortex-A50 based processors. Several different chip makers are producing ARMv8 compatible processors, many for the server market. Probably the best known ARM server chip maker is AMD. The company plans to use the high-energy efficiency of the ARM design in the server room to reduce the overall energy costs needed to run massive server farms. Since the ARM chips don’t need big heat sinks then server manufacturers can get multiple servers into a single blade, and multiple blades into one unit. Overall that means more processors per square foot.

The GNU compiler collection already supports the ARMv8 architecture and programs written on a 32-bit ARM Linux platform should run on 64-bit processors without modification.

Since these systems will likely run Linux then developing for 64-bit ARM is just like developing for any other 64-bit operating system, including 64-bit Linux on Intel. The GNU compiler collection already supports the ARMv8 architecture and programs written on a 32-bit ARM Linux platform should run on 64-bit ARM processors without modification. Assuming the code doesn’t rely on any 32-bit trickery (like bit operations that assume a 32-bit word), then moving to 64-bits will be easy. The Linux kernel is already fully 64-bit aware, as are the various tools and system services.

Conclusion

Whatever your area of interest from wearables to server farms, from single board computers to smartphones, there is ample opportunity to write software that runs on devices using ARM based processors. The tools are available, the hardware is plentiful, what is stopping you?

By | 2014-10-22T15:00:06+00:00 October 22nd, 2014|Android Related, Just the Tablets|0 Comments

About the Author:

Vancouver, Canada