Thursday, February 14, 2013

Geeky Post: STM32F4-BB Ethernet Projects

Welcome Hackaday readers!  Please click here to see my latest posts when you're done!  Thanks!
Chinese embedded tool supplier EmBest (now owned by Element 14) has come up with a new baseboard, the DM-STF4BB, for ST Microelectronics' wildly-popular (in geek circles) STM32F4 DISCOVERY board.  On the box, Embest labels the baseboard the "Discover MO", and indeed, you do discover more about the STM32F4 processor with this board.  

The board can be purchased on Element 14 for US$35.  There is also a companion LCD (with touchscreen) and camera module that can be purchased separately, at the same link.

Ol' Backwoods posted a few weeks ago about this board, and I wanted to update you on my work with it to date.

The Baseboard Itself

To the left is a picture of the baseboard with a DISCOVERY board plugged into it, the box the baseboard comes in, and the little card that tells you how to start up with the board, and where to download the firmware.  The website says that a CD comes with the baseboard; I ordered two of these, and there was no CD in either one.  Nor were there any cables of any kind.

In the picture of the baseboard to the left, you can see an RJ-45 Ethernet (100baseT) jack on the upper left, and next to it, an RS232 serial port (configured DTE).  Just below that is the SMSC LAN8720 PHY chip for the Ethernet port, connected to the STM32F405 microcontroller on the DISCOVERY board via the pin-saving RMII interface.  There is even a 50 MHz clock generated for use by the microcontroller (required for RMII).

At the bottom edge of the board is a TransFlash (Micro SD) card slot (right), and a camera interface slot.  Since the STM32F4 microcontroller has a hardware interface for a digital camera module, I look forward to playing with that in the future.  On the edges of the board are headers, breaking out the remaining microcontroller I/O pins; the header on the left is primarily for the LCD, although it can be used for other purposes.
The board is powered from the voltage regulators on the DISCOVERY board, via the STLINK USB debugger interface, or an external 5VDC power supply.

Firmware and Compilers

It is immensely frustrating to have a new piece of hackable hardware with very little code that is ready to run on the hardware.  The DISCOVERY board itself fell victim to this in the early days, although there is more for it now.  Embest has taken the firmware from ST Microelectronics and modified it so that it will work "out of the box" with the combination of the DISCOVERY and the DM-STF4BB baseboard.   This helps us get up and running very quickly with the board combo.  The firmware can be downloaded from Element 14's site here:

Here is a list of examples included:

Unfortunately, the example firmware is designed for the IAR Embedded Workbench C Compiler and development environment for ARM (V6.40 or above).  (Some of the projects also work on Keil's MDK.) I say unfortunately, because at a list price of $3543.99, very few developers are going to be using it.  I've used it at work, and it is excellent.  But, very few hobbyists and hackers are going to plunk down the price of two AR-15 rifles just for a compiler.

Fortunately, IAR allows a 30-day evaluation version of their IAR Embedded Workbench that runs on Windows.  (Linux geeks--read the next paragraph.)  You can download that here; you will acquire an evaluation license over the internet during install.  BE SURE TO SELECT the 30-day, NOT the memory-limited 32K version.  Most of the Embest firmware examples, including the USB and Ethernet demos, will not compile under the memory-limited version.  (The UART demo will, but that doesn't do much.)

Once I get the demo software modified to do what I want it to do, I plan to convert over to ARM's free gcc compiler for the Cortex-M4.  To do that will require fixing up dependencies, make files, library references and other details that I don't want to mess with while I am trying to get the code to do what I want it to do.   Linux power users will probably scoff at this; I would encourage them to port the Embest example and give away their Makefiles and libraries.

A Simple UDP Transfer Demo

At right is a picture of the two board pairs I purchased, being powered through the USB ports of my laptop, and having their Ethernet ports connected with a straight-through 100baseT (CAT6) cable.  (The  LAN8720 PHY has auto-crossover, so a cross over cable isn't necessary.)  

The two board pairs are continuously sending UDP datagrams over the Ethernet cable, in a one-way transfer.  The leftmost board pair is programmed with UDP sender firmware (derived from Embest's udp_echo_client demo) , and the rightmost board pair is flashed with UDP 'sink' firmware (derived from the udp_echo_server demo).  In the picture, the
UDP sinnk board pair has its RS232 port connected through a null modem and a gender changer to an RS232 port on my laptop, so I can view its report of transferred data.  The UDP sender firmware has a similar capability, although the RS232 port is not shown connected in the picture.

I used the printf() redirector functions from the USART demo, and combined them with my firmware.  Source is here:  udpblaster udpsink

One of my favorite dumb terminal emulators for Windows is RealTerm, but as far as I can tell, it is no longer being actively developed.   It does have a few bugs, but I like it nonetheless.  RealTerm is used to show the RS232 serial output of the two ends of the UDP link.
Here is the RS232 output from the UDP data sender:

And here is the RS232 output on the UDP receiver:

The receiver is promiscuous, and will accept packets from any sender on any port.

You can download my firmware, created from the EmBest demo firmware, here: udpblaster udpsink

More posts on this fine development platform to come...

 Please click here to see my latest posts!  Thanks!


  1. This i a VERY interesting project. Great work!
    I guess I should consider doing this using an RTOS like ChibiOS/RT. It comes with a library to drive displays and touchscreens so you could build up something really cool :D

  2. This comment has been removed by a blog administrator.

  3. This comment has been removed by a blog administrator.

  4. This comment has been removed by a blog administrator.

  5. This comment has been removed by a blog administrator.