Stm32f3-discovery board set up

Stm32f3-discovery board

Key Features

  • STM32F303VCT6 microcontroller featuring 256 KB Flash, 48 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 3 V or 5 V supply voltage
  • External application power supply: 3 V and 5 V
  • L3GD20, ST MEMS motion sensor, 3-axis digital output gyroscope
  • LSM303DLHC, ST MEMS system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor
  • Ten LEDs:LD1 (red) for 3.3 V power on LD2 (red/green) for USB communicationEight user LEDS, LD3/10 (red), LD4/9 (blue), LD5/8 (orange) and LD6/7 (green)
  • Two pushbuttons (user and reset)
  • USB USER with Mini-B connector
  • Extension header for all LQFP100 I/Os for quick connection to prototyping board and easy probing

Resources and references

stm32f3-discovery web site

STM32F3 Discovery kit firmware package

STM32 Firmware

STM32F3 resources

Programming it

Discovery boards come with an integrated stlink programmer. I’ve also another board from Texas Instruments that uses a ftdi chip. For this reason I build OpenOCD with support for both interfaces. Of course in order to program just the discovery board you can skip the steps for ftdi.

ftdi driver

Download ftdi driver from ftdichip.com.

Extract and:

sudo apt-get install libusb-dev

cd ~/libftd2xx1.1.12
sudo cp ftd2xx.h /usr/include
sudo cp WinTypes.h /usr/include
cd build/x86_64/
sudo cp libftd2xx.so.1.1.12 /usr/local/lib/
cd /usr/local/lib/
sudo ln -s libftd2xx.so.1.1.12 libftd2xx.so

Compile and install OpenOCD

Download OpenOCD from OpenOCD.

Extract and:

sudo apt-get install git zlib1g-dev libtool flex bison libgmp3-dev libmpfr-dev libncurses5-dev libmpc-dev autoconf texinfo build-essential libftdi-dev libusb-1.0.0-dev

cd /share/micro/openocd-0.7.0
./configure --enable-ft2232_ftd2xx --disable-werror --enable-stlink
make
sudo make install

Check that the two debug interfaces are available:

openocd -c "interface_list"
Open On-Chip Debugger 0.7.0 (2013-07-18-11:33)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
The following debug interfaces are available:
1: ft2232
2: hla
Error: Debug Adapter has to be specified, see "interface" command
in procedure 'init'

udev

The device must be added as new udev rule in order to be accessed without root privileges.

pezzino@samarcanda:~$ lsusb 
[...]
Bus 002 Device 017: ID 0483:3748 SGS Thomson Microelectronics ST-LINK/V2
$sudo vi /etc/udev/rules.d/99-stlink.rules
$sudo udevadm  control --reload-rules
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0666"

Test it

Check that the board can get programmed with a pre-built image:

openocd -f /usr/local/share/openocd/scripts/board/stm32f3discovery.cfg -c init -c"reset init" -c "flash write_image erase ~/stm32f3discovery/STM32F3-Discovery_FW_V1.1.0/Project/Demonstration/Binary/STM32F3_Discovery_Demo_V1.1.0.hex" -c reset -c shutdown

Set up Eclipse

Eclipse Kepler.

Makefile project

gnuarm cross project

We set up a basic environment similar to the last post: Eclipse CDT for arm development.

project right click -> properties -> c/c++ build -> environment -> add:

Name: PATH
value: /share/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin
add to all the configurations

Demo project

This project comes is the example that comes with this demo board.

Stm32f3-discovery demo tree:

├── Libraries
│   ├── CMSIS
│   │   ├── CMSIS END USER LICENCE AGREEMENT.pdf
│   │   ├── Device
│   │   │   └── ST
│   │   │       └── STM32F30x
│   │   │           ├── Include
│   │   │           │   ├── stm32f30x.h
│   │   │           │   └── system_stm32f30x.h
│   │   │           └── Release_Notes.html
│   │   ├── Include
│   │   │   ├── arm_common_tables.h
│   │   │   ├── arm_math.h
│   │   │   ├── core_cm0.h
│   │   │   ├── core_cm3.h
│   │   │   ├── core_cm4.h
│   │   │   ├── core_cm4_simd.h
│   │   │   ├── core_cmFunc.h
│   │   │   ├── core_cmInstr.h
│   │   │   ├── core_sc000.h
│   │   │   └── core_sc300.h
│   │   ├── index.html
│   │   └── README.txt
│   ├── STM32F30x_StdPeriph_Driver
│   │   ├── inc
│   │   │   ├── stm32f30x_adc.h
│   │   │   ├── [...]
│   │   │   └── stm32f30x_wwdg.h
│   │   ├── Release_Notes.html
│   │   └── src
│   │       ├── stm32f30x_adc.c
│   │       ├── [...]
│   │       └── stm32f30x_wwdg.c
│   └── STM32_USB-FS-Device_Driver
│       ├── inc
│       │   ├── usb_core.h
│       │   ├── [...]
│       │   └── usb_type.h
│       ├── Release_Notes.html
│       └── src
│           ├── usb_core.c
│           ├── [...]
│           └── usb_sil.c
├── OpenOCD.launch
├── OpenOCD program.launch
├── OpenOCD(restart).launch
├── script.sh
├── src
│   ├── hw_config.c
│   ├── hw_config.h
│   ├── main.c
│   ├── main.h
│   ├── platform_config.h
│   ├── readme.txt
│   ├── Release_Notes.html
│   ├── startup_stm32f30x.S
│   ├── stm32f30x_conf.h
│   ├── stm32f30x_it.c
│   ├── stm32f30x_it.h
│   ├── syscalls.c
│   ├── system_stm32f30x.c
│   ├── usb_conf.h
│   ├── usb_desc.c
│   ├── usb_desc.h
│   ├── usb_endp.c
│   ├── usb_istr.c
│   ├── usb_istr.h
│   ├── usb_prop.c
│   ├── usb_prop.h
│   ├── usb_pwr.c
│   └── usb_pwr.h
├── stm32f3-debug.launch
├── STM32_FLASH.ld
└── Utilities
    └── STM32F3_Discovery
        ├── Release_Notes.html
        ├── stm32f3_discovery.c
        ├── stm32f3_discovery.h
        ├── stm32f3_discovery_l3gd20.c
        ├── stm32f3_discovery_l3gd20.h
        ├── stm32f3_discovery_lsm303dlhc.c
        └── stm32f3_discovery_lsm303dlhc.h

Eclipse set up for this project

This setting should be added to all profiles (e.g. Debug and Release).

stm32-eclipse-settings

stm32-eclipse-settings2

stm32-eclipse-settings3

stm32-eclipse-settings4

OpenOCD configuration

-f /usr/local/share/openocd/scripts/board/stm32f3discovery.cfg -c init -c"reset init" -c "flash write_image erase ${project_loc}/Debug/${project_name}.elf" -c reset -c shutdown

Debugger configuration

We need c/c++ hardware debugging capabilities from Eclipse CDT plugin:
stm32-eclipse-debug1

stm32-eclipse-debug2

stm32-eclipse-debug3

trash

./configure –enable-maintainer-mode –enable-stlink

openocd -c “interface_list”

this works…

/share/micro/openocd-0.7.0-stlink/src/openocd -f /usr/local/share/openocd/scripts/board/stm32f3discovery.cfg -c init -c”reset init” -c “flash write_image erase /share/work/incubating/stm32f3discovery/STM32F3-Discovery_FW_V1.1.0/Project/Demonstration/Binary/STM32F3_Discovery_Demo_V1.1.0.hex” -c reset -c shutdown

from atollioc under wine too:

/share/micro/openocd-0.7.0-stlink/src/openocd -f /usr/local/share/openocd/scripts/board/stm32f3discovery.cfg -c init -c”reset init” -c “flash write_image erase /home/pezzino/.wine/drive_c/users/pezzino/Atollic/TrueSTUDIO/ARM_workspace/STM32F3_Discovery_Demonstration/Release/STM32F3_Discovery_Demonstration.elf” -c reset -c shutdown

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.