Jun 25

Fetching original flash contents from the STM32F4-Discovery

Before, reprogramming the flash memory with my own software, I want to fetch the original contents, for two purposes:

  • Disassembling and study
  • Backup

Connect to the board with openocd:

Connect to the openocd telnet server:

For some reason, I have to first use the flash info command in order for the other flash display commands to work correctly (otherwise they show zero addresses and sizes):

Now, we are ready to dump the whole flash to a binary image and to exit:

Perfect! Ready for disassembling! :-)

Jun 21

Discovering the STM32F4-Discovery

The official page is at STM32F4DISCOVERY. The board features:

  • An STM32F407VGT6 microcontroller featuring 32-bit ARM Cortex-M4F core, 1 MB Flash, 192 KB RAM, a frequency of up to 168 MHz, in an LQFP100 package.

That MCU has two boot pins that control where it boots from. For some strange reason, I was not able to find a complete specification of those pins in ST’s documentation. However, it looks like the information located at stm32-arm-cortex-bootloader is correct:

BOOT0 BOOT1 Boot Mode
0 X Boot from user flash
1 0 Boot from System Memory
1 1 Boot from embedded RAM

According to the STM32F407VG datasheet, system memory is apparently some kind of PROM, where a serial boot loader is located, that can be used to reprogram the flash. My intention is to rather boot from flash, and use the openocd over the ST-LINK/V2 interface, probably integrated in Eclipse at some point, to reprogram the flash.
According to the STM32F407 user manual, the standard BOOT0/BOOT1 configuration is 0/1, which is fine for me (booting from flash).

Jun 21

Starting talking to STM32F4-Discovery from Linux

Used host:

First, I add the udev rule corresponding to the ST-LINK/V2 interface in the newly created file /etc/udev/rules.d/99-stlink.rules (thanks PulkoMandy):

Then, I trigger the new udev rule:

Then I install openocd 0.8.0-2 from the Community repository, resulting in:

Then, I connect the board’s Mini-USB connector to my computer. It will both give power to the board, and make the ST-LINK/V2 interface accessible. The ST-LINK/V2 interface appears as a USB device:

Then, I say hello to my little board:

What more would a nerd require to be happy? :-)