Building the STM32F4 DISCOVERY Toolchain For Mac OS X

The STM32F4 DISCOVERY is a very neat development board for the STM32 F4 series microcontroller. Not only is it neat, but also cheap. As in $14.55. Here’s the link to buy one from Mouser.

I have some radio related projects that I plan on implementing with this unit. But first I had to get the Open Source development tools installed. And while there are numerous webpages that describe how to do this, none of them actually worked. Such is the world of Open Sores.

With a bit of help, I was able to get things up and running. To save others grief, I’m documenting what I did to get things working. First, a brief description of what goodies you get with this development board.

Here’s a datasheet for the development board.

Some of the Features:
■ STM32F407VGT6 microcontroller featuring 32-bit ARM Cortex-M4F core, 1 MB Flash, 192 KB RAM in an LQFP100 package
■ On-board ST-LINK/V2 with selection mode switch to use the kit as a standalone ST- LINK/V2 (with SWD connector for programming and debugging)
■ Board power supply: through USB bus or from an external 5 V supply voltage
■ External application power supply: 3 V and 5 V
■ LIS302DL, ST MEMS motion sensor, 3-axis digital output accelerometer
■ MP45DT02, ST MEMS audio sensor, omni-directional digital microphone
■ CS43L22, audio DAC with integrated class D speaker driver
■ Eight LEDs:
– LD1 (red/green) for USB communication
– LD2 (red) for 3.3 V power on
– Four user LEDs, LD3 (orange), LD4 (green), LD5 (red) and LD6 (blue)
– 2 USB OTG LEDs LD7 (green) VBus and LD8 (red) over-current
■ Two push buttons (user and reset)
■ USB OTG FS with micro-AB connector
■ Extension header for all LQFP100 I/Os for quick connection to prototyping board and easy probing

Now for the gory details of actually getting all this to work:

First, my system:

I installed this on a Mac Book Pro running Mac OS X 10.6.8. I wanted it on a laptop so I could take it to my basement workshop to do the actual development work. You can do this under linux and Windows as well. I don’t have any information on doing that, you’re on your own. Good luck.

I installed Xcode 4.2, which is the latest version that will run on 10.6 Snow Leopard. I understand that Xcode 4 is required to get the development stuff up and running, I do not know that for a fact, however.

First you need to install a bunch of stuff:
brew install mpfr gmp libmpc texinfo libusb-compat libftdi wget

This uses Homebrew, which you must install if you don’t already have it.

This toolchain script was used as the base: https://github.com/ehntoo/summon-arm-toolchain

As I said earlier, it does not quite work out of the box.

A big thanks to Gwynne who came up with a patch.

So all you need to do is:

cd && git clone git://github.com/ehntoo/summon-arm-toolchain.git && cd summon-arm-toolchain && wget -O - http://darkrainfall.org/build-openocd.patch | patch -p1 && ./summon-arm-toolchain

Then… wait. A while. It takes 20-30 minutes to build everything. Go have lunch.

All of the dev tools are put into ~/sat so make sure that is in your $PATH variable:
export PATH="$HOME/sat:$PATH"

Plug in the dev board and connect to it with the On Chip Debugger:
openocd -f board/stm32f4discovery.cfg

if all goes well, a bunch of text is spit out into the terminal window, ending with:
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints

Then open up another terminal window and connect to the On Chip Debugger:
telnet localhost 4444

Next I grabbed the STM32 Discovery firmware files, to get some sample code:
git clone https://github.com/nabilt/STM32F4-Discovery-Firmware.git

I decided to try the IO_Toggle project first, which turns some digital outputs, connected to LEDs on the board, on and off. Toggling LEDs is the microcontroller version of a Hello World program.

Building the project did not go completely smoothly. I needed to change a line in the Makefile dealing with floating point:
MCFLAGS = -mcpu=$(MCU) -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork
to
MCFLAGS = -mcpu=$(MCU) -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mthumb-interwork

I don’t yet have a good explanation as to the need to make the change, but I saw it mentioned on many websites while searching for a solution to the problem.

The result is a demo.elf file which gets downloaded to the dev board.

Open up yet another terminal window (while in the directory containing demo.elf) and run gdb via:
arm-none-eabi-gdb

In the OCD telnet window, stop the program currently running on the microcontroller:
reset halt

Then in the window running gdb:
target extended localhost:3333
load demo.elf

Then in the OCD telnet window run the program:
reset run

I was rewarded with blinking LEDs. I then edited the main.c source code to change their toggle rate, and re-built the project, as a test, which all worked.

Next step, some radio related programming!

Homeopathic Radio Engineering

Mainstream radio engineering principles hold that the received signal strength of a transmission is proportional to the radiated power. Doubling the transmitter power produces twice the received power, quadrupling the transmitter power produces four times the received power, twice the received voltage, which is 6 dB or one S unit. This has been accepted for over a century.

However, recent experimental results, first reported on the FRN and later in The Journal of Irreproducible Results cast doubt in this basic radio engineering theory.

These results claim that as the transmitter power is reduced to very low levels, the received signal strength actually goes up, not down.

A transmitter location on the east coast of the USA was used. The tests were conducted on HF radio frequencies on and around 6925 kHz, using a state of the art solid state transmitter with a standard off the shelf MOSFET as the RF final amp:

Each monitoring post was equipped with the highest quality HF receiving gear and highly sensitive monopole receiving antennas.

During the trials, it was found that placing a non-conductive fabric, such as a sock, over the receiver produced the strongest signals. While the exact mechanism for this effect is not yet known, it is presumed to be due to the high dielectric constant of the fabric.

The results of the experiment clearly speak for themselves, as transmitter power went down, the signal strength went up:

One way to explain the results is to return to the luminiferous ether theory of radio propagation. Radio waves are propagated by vibrations in the ether. Fewer radio waves means that there is more ether per radio wave, so the vibrations are larger, producing a stronger signal at the receiving site.

There were even reports of radio propagation that cannot be explained by any known laws of physics, such as signals in the daytime traversing from Montana to New Zealand on 6955 khz with a completely sunlit path, even though D layer absorption would make this completely impossible. Yet this was reported many times by longtime radio physicist Dr. Winston: “The signals were always received with as SIO of 555. Even the audio quality was perfect, why it sounded like I was listening to it live in the studio!”.

Several times signals were actually received and logged on the FRN before the transmission began. This suggests that superluminal neutrinos may be involved.

Further research into this new phenomena is required. If homeopathic radio is ever perfected, it would allow listeners to report hearing transmissions that used little, or theoretically even no power. Indeed, reducing the output power to zero watts might produce the best results of all for this type of station.