The Cortex M3 board
Contents
The Cortex M3 board
Manufacturer: Olimex --> (http://olimex.com/dev/stm32-p103.html)
CPU: Cortex M3 (STM32F103RBT6 @ 72MHz, 20k RAM, 128k ROM)
Flashing the board
A cheap and easy way is using the ARM USB TINY JTAG adaptor by Olimex.
For flashing, you require OpenOCD (version 0.2.0 or higher) and some config files. In our SVN you can find all that you need.
Compiling OpenOCD
Compiling openOCD is only necessary if you don't want to use the executable from our SVN. Otherwise skip this step and stick with openocd-0.2.0-win32.exe which just works.
Get openocd-0.2.0, libusb-win32-device-bin-0.12.2, FTDI D2XX drivers 2.04.16 (or higher versions).
The cygwin gcc compiler is used, but for cygwin-independent target. MinGW should work as well.
Enabled programmers are the usbProg and the ARM-USB-TINY.
Compile this way:
> ./configure --enable-usbprog --enable-ft2232_ftd2xx \ --with-ftd2xx-win32-zipdir=<path_to_ftd2xx_driver> \ CC="gcc -mno-cygwin" \ CFLAGS="-I<path_to_libusb-win32-device-bin>/include/"\ LDFLAGS="-L<path_to_libusb-win32-device-bin>/lib/" > make
After that, the executable openocd.exe is in the src folder. It should be identical to the openocd-0.2.0-win32.exe from SVN.
Flashing a new firmware (using ARM-USB-TINY)
The SVN contains a file main.bin which is a very simple blinking lights demo for the board.
- Open a console (cygwin bash or DOS shell) and enter the directory with the following files:
- openocd-0.2.0-win32.exe
- olimex_stm32_h103_ft2232.cfg
- The binary file (in this case the main.bin demo)
- Run the command:
> openocd-0.2.0-win32 -f olimex_stm32_h103_ft2232.cfg
- The console should show this output:
Open On-Chip Debugger 0.2.0 (2009-10-13-12:05) Release $URL: http://svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.2.0/src/openocd.c $ For bug reports, read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS jtag_speed: 0 jtag_nsrst_delay: 100 jtag_ntrst_delay: 100 Info : device: 4 Info : deviceID: 364511236 Info : SerialNumber: FTS92Y5TA Info : Description: Olimex OpenOCD JTAG TINY A Info : JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3) Info : JTAG Tap/device matched Info : JTAG tap: stm32.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1) Info : JTAG Tap/device matched
- Open a secondary console (no need to change the path)
- Launch a telnet session:
> telnet localhost 4444
- Execute the following commands to write the image to the flash. Note: The path to the flash image is relative to the location the openocd executable has been launched at.
> halt > flash write_image erase main.bin 0x08000000
- Your console prompt should be showing something like this:
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Open On-Chip Debugger > reset JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3) JTAG Tap/device matched JTAG tap: stm32.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1) JTAG Tap/device matched > halt target state: halted target halted due to debug-request, current mode: Thread xPSR: 0x21000000 pc: 0x000000c2 > flash write_image erase main.bin 0x08000000 auto erase enabled device id = 0x20036410 flash size = 128kbytes wrote 4052 byte from file main.bin in 0.375000s (10.552083 kb/s)
- Congratulations! Your new firmware is flashed. You can start it by resetting the MCU or by issuing another command in the telnet session:
> resume 0
If you flashed the blinking demo, the LED is blinking right now ...
Flashing a new firmware (using usbProg)
Here is a description of how to flash the Cortex M3 with an usbProg and level shifter (converts the 5V from the usbProg to the 3.3V of the development board). You can buy them at http://shop.embedded-projects.net
Note: The usbProg is slow, really painfully slow. Flashing speed is around 70-80 Bytes/s.
Note: The openOCD firmware in usbProg's online pool does not work, since TDI and TDO wires are switched. You need to upload a modified firmware image (usbprog_hacked_openocd_fw.bin) to the usbProg. Or you build your own level shifter that corrects this error.
Note: The jumpers need to be set up in the following way:
- usbProg: Only jumper 2 is set, to supply the level shifter board with power.
- level shifter: Setting the jumper supplies the development board with power, so if it has an external power supply, better use that instead and leave the jumper open.
The process is quite the same like with the ARM-USB-TINY, in windows you need to install the drivers from libusb-win32-device-bin-0.12.2. The config file for the usbProg is olimex_stm32_h103_usbprog.cfg.
While the flash image is being written, you get no feedback. Considering the slow speed, be patient ...
Remarks
- Flashing speed is quite high with the ARM USB TINY, > 10kBytes/s, so the whole process takes only seconds.
- The usbProg is more than 100 times slower, and usbProg + level shifter are more costly than the ARM-USB-TINY.
Concerning Mac OS X
Under OSX Snow Leopard things work, too.
- Install the latest version of the FTDI driver (>=2.2.14)
- Install openOCD with macports. This uses the libftdi driver, so the FTDI driver seems to be obsolete. But due to some misconfiguration in Snow Leopard's default FTDI driver, the original driver is needed to allow libftdi/libusb access to the raw device.
- The AMR-USB-TINY's USB PID is 0x0004, change the openOCD config file.
- Libftdi is a bit slower, around 1.5kB/s. Still acceptable.