NETMF for STM32
You can already use your C#, .NET and Visual Studio know-how to program a broad spectrum of devices - from smartphones and tablets to PCs, servers and all the way up to the cloud. Now you can even reach industry-standard low-cost microcontrollers, and thus the physical world!
Modern 32-bit microcontrollers
Most smartphones and tablets are powered by ARM-compatible microprocessors. These are relatively large devices that need additional memories and other support chips. In contrast, microcontrollers often don't require external memories and can therefore be put into smaller and less expensive packages with fewer pins.
While microcontrollers are not as powerful as high-end smartphone processors, they have nevertheless reached impressive performance levels. ARM-compatible microcontrollers support data buses that are 32 bit wide, making them much faster than the older 8-bit microcontrollers. They enable the use of modern, robust and productive software platforms for programming them.
What is the .NET Micro Framework?
Microsoft's .NET platform is preinstalled on every Windows PC and is well-known to hundreds of thousands of software developers worldwide. The .NET Micro Framework (NETMF) is an implementation of .NET specifically for microcontrollers. It allows writing embedded software in C#, using Microsoft’s ubiquitous Visual Studio tools. Yet it is about a hundred times smaller than the PC version of .NET!
With the .NET Micro Framework , the same developers can program the entire spectrum of devices from inexpensive 32-bit microcontrollers up to data centers in the cloud. Using the same programming language (C#), using similar libraries (.NET), and using the same tools (Visual Studio).
The hardware-independent .NET API of the .NET Micro Framework makes it possible to write application code that is fully portable across different microcontrollers, giving an unprecedented degree of protection from hardware obsolescence.
The .NET Micro Framework is designed so that it can run directly on the hardware, without underlying operating system. It is a "bootable .NET runtime".
The .NET Micro Framework is open source software, governed by the Apache 2.0 license: there are no "target royalties", and you may develop commercial software without being required to pass on your own improvements, and adaptations to different hardware are possible anytime.
The ARM architecture
ARM has created the most successful architecture for 32-bit microcontrollers. The current ARM archi-tecture (i.e., instruction set) for microcontrollers is called ARMv7M. It provides a carefully chosen subset of the instruction set of higher-end smartphone processors. ARM Ltd. defines the ARM architectures.
ARM Cortex-M cores
ARM Ltd. also designs cores. An ARM core is a specific implementation of an ARM architecture. There may exist multiple cores for the same architecture. Confusingly, an ARM7 core implements the ARMv3, ARMv4, or ARMv5 architec-ture. An ARM9 core implements the ARMv4 or ARMv5 architecture.
ARM Ltd. also designs cores. An ARM core is a specific implementation of an ARM architecture. There may exist multiple cores for the same architecture. Confusingly, an ARM7 core implements the ARMv3, ARMv4, or ARMv5 architecture. An ARM9 core implements the ARMv4 or ARMv5 architecture.
Cores that implement the current ARMv7M architecture have a more intuitive naming scheme. They are called Cortex-M, with a suffix that indicates relative performance and functionality. For example, Cortex-M3 is more powerful than Cortex-M0, but possibly more expensive and consuming more power. Cortex-M4 is basically Cortex-M3 with some additional instructions that are useful when implementing specialized signal processing algorithms.
There have been NETMF ports to various ARM7 and ARM9 cores for some time. We have ported NETMF to the newer Cortex-M3 and Cortex-M4 cores. This task involved mainly the core initializations: interrupts, reset, error handling, etc.
This was the most difficult part of porting NETMF, namely to a completely different core (and instruction set architecture as well), although it only affected a small number of source files. It has made life far easier for anyone who has later ported NETMF to a Cortex-M3 or Cortex-M4 product, regardless of the chosen manufacturer.
For more detailed information on Cortex-M, see this article.
The STM32 microcontroller family
ARM develops the cores, but doesn't manufacture them. Its semiconductor partners license one or more cores and develop complete microcontroller chips around them. To that purpose, they add on-chip RAM and Flash memories to the cores, plus a multitude of (proprietary) peripherals. STMicroelectronics is one of many ARM licensees that have built products around Cortex-M cores, in this case called STM32. This has become one of the most popular and cost-effective Cortex-M implementations on the market.
Today, there are almost 500 different STM32 variations. Some of their part numbers start with STM32F1, STM32F2, or STM32F4. These are three families with different performance characteristics. The STM32F4 family is the most powerful, using a Cortex-M4 core.
One example is the STM32F407. It runs at 168 MHz, has 1 MB of Flash and 192 KB of RAM. It sports a variety of on-chip peripherals, from digital I/O (GPIO) to USB and Ethernet support. It comes on a 14 mm by 14 mm package with 100 pins. There are larger package variants with more pins, allowing to add external memories, and also smaller packages, with fewer I/Os. At the time of this writing, a 100 pin variant of this chip is available for about $13 (one chip) to less than $7 (10,000 units).
NETMF for STM32
We have ported NETMF to the STM32F1, STM32F2 and STM32F4 families ("NETMF for STM32"). This involved writing drivers for the on-chip peripherals: GPIOs, analog inputs and outputs, I2C, SPI, UARTs, USB, internal Flash, power management, timers, etc. From the perspective of NETMF, STM32F2 and STM32F4 are almost identical. The older STM32F1 requires some different drivers, however, as it has more limited peripherals. We distinguish between NETMF for STM32 (F1 Edition) for the STM32F1 products, and NETMF for STM32 (F4 Edition) for the STM32F2 and STM32F4 products.
This part of porting NETMF was the most time-consuming, as it involved writing drivers for many different peripherals, and for two hardware generations (F1 versus F2/F4).
"Congratulations! Great to see this cooperation across different NETMF manufacturers, and your leadership. I’m particularly grateful since you’ve paved the way for a halving of the cost of Gadgeteer mainboards!"
James Scott, Microsoft Research, Cambridge
NETMF for STM32 (F1 Edition)
The STM32F1 edition of our NETMF port has been contained in Microsoft’s Porting Kit for NETMF 4.2 since October 2011. Once you have installed the porting kit, you can find the STM32 software in
The following documents provide more information on the F1 Edition of our NETMF port:
Technical notes regarding the supported STM32F1 boards (supported drivers, memory maps, etc.)
NETMF for STM32 - Technical Notes Releas
Adobe Acrobat Document [95.3 KB]
Which CPU pins are available on an STM32F1 microcontroller, and how can they be used from NETMF.
NETMF for STM32 - Standard IO Mapping fo
Adobe Acrobat Document [58.2 KB]
NETMF for STM32 (F4 Edition)
You can find NETMF for STM32 (F4 Edition), for NETMF 4.3, at this Codeplex site. Note that it can also be used for STM32F2 chips, you just need other project settings (compiler options), as the F2 chips have no floating-point units.
The following document provides an overview over NETMF porting in general, and the F4 Edition in particular:
Gives an overview over the STM32 hardware, the NETMF Porting Kit in general, and the files that need to be touched when adapting a port for your specific needs.
NETMF for STM32 - Tour d'Horizon V201401
Adobe Acrobat Document [852.5 KB]
More documentation is available on the Codeplex site.
You can download the binaries of the Mountaineer firmware in the Resources section of this Web site.
Boards with the STM32
We have adapted NETMF for STM32 to several off-the-shelf boards (not all peripherals may be supported):
STM32F103: the MCBSTM32E evaluation kit of Keil, an ARM subsidiary.
STM32F103: the ET-STM32-Stamp from Futurelec. At $25, this is an inexpensive board. To save memory, we use the boot loader built into the STM32 chips, instead of the NETMF boot loader.
STM32F207: the STM3230G-EVAL evaluation board from STMicroelectronics.
STM32F407: the STM3240G-EVAL evaluation board from STMicroelectronics.
STM32F407: the STM32F4DISCOVERY discovery kit from STMicroelectronics. This board has audio support and is somewhere between inexpensive and free.
STM32F429: the 32F429IDISCOVERY discovery kit from STMicroelectronics.
You could adapt NETMF for STM32 to any other board with a suitable STM32 microcontroller. Depending on your experience and knowledge of NETMF and the C/C++ tool chain that you use, this may take from about one day to several weeks. Additional work may be required depending on what additional hardware the board provides. For example, if the board has a GSM module, then a driver for this module must be developed.
The board shown to the right uses an STM32F103RE microcontroller and NETMF for STM32. It was custom-designed for Phonak (aka Unitron), the world’s largest provider of hearing aids. The board helps the Phonak engineers to test new hearing aids. It allows switching between several pairs of attached hearing aids. This switching is controlled by a PC via USB. For the PC, we provided a .NET library that sends control commands to the board. In this way, we were able to use .NET, C# and Visual Studio both for the PC application and for the embedded software, eliminating the need for special-purpose embedded tools.
The board shown to the left uses an STM32F4. It was designed for a German customer in the energy sector. The board is designed for industrial use, supporting a professional enclosure that can be mounted on a standard DIN rail. It provides large external memories, both RAM and Flash. The board uses an extended version of the Mountaineer firmware that supports a fast SD Card interface and USB Host functionality.
Some of the design assets that we have developed in earlier projects can be licensed as reference designs. These offerings, both hardware designs and extended firmware, are labeled as Mountaineer Prime designs.
We contribute NETMF for STM32 to Microsoft's NETMF code base, with integration and basic support done by Microsoft. The members of the Mountaineer Group can offer more specific support, albeit only in the context of substantial customer projects (contract volumes for our engineering services usually start at about $25,000).
If you find any issues with the code, please use the issue tracker on Codeplex to report them.