Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

STM32F4 Discovery Board Getting started

Ashfaq edited this page Mar 24, 2015 · 1 revision

Here, you find the description how to start with the STM32F4 Discovery Board (STM32-DB)

The STM32-DB is an experimental board to do low level C-programming for reading sensors or controlling motors.

To start, you need to update your virtual machine with another cross-compiler:

  1. Start your virtual machine and go to your home folder

  2. Download the other cross-compiler (not necessary for the Ubuntu 14.04 virtual machine!):

    wget http://www.cse.chalmers.se/~bergerc/msv/gcc-arm-none-eabi-4_7-2013q1-20130313-linux.tar.bz2

  3. Unpack the file to /opt (not necessary for the Ubuntu 14.04 virtual machine!):

    sudo tar -xvjf gcc-arm-none-eabi-4_7-2013q1-20130313-linux.tar.bz2 -C /opt

  4. Update your GitHub working directory to get the ChibiOS realtime operating system.

  5. Build the STM32-DB host tools:

    cd <Your MSV-source tree>/sources/STM32F4/host-tools

    mkdir build

    cd build

    cmake -D CMAKE_INSTALL_PREFIX=/opt/msv/<Your group directory> ..

    make install

  6. Make sure that the USB rule file "49-stlinkv2.rules" has been installed to /etc/udev/rules.d. If not, copy the file from <Your MSV-source tree>/sources/STM32F4/host-tools/qstlink2/udev/ to /etc/udev/rules.d manually.

  7. Restart your virtual machine.

  8. Build the STM32-DB Software using your newly installed cross-compiler:

    cd <Your MSV-source tree>/sources/STM32F4/embedded/ChibiOS/DiscoveryBoard

    PATH=$PATH:/opt/gcc-arm-none-eabi-4_7-2013q1/bin && make

On the Ubuntu 14.04 virtual machine:

`make`
  1. If the build succeeded, you can flash the binary ch.bin in directory build to the STM32-DB. Therefore, you need to connect the STM32-DB with the USB-mini cable to your computer (the mini connector is the larger one on the STM32-DB). If you are using the virtual machine, you need to re-route the USB connection to the virtual machine by clicking on the blue USB button in the status bar of VirtualBox and select "STMicroelectronics STM32 STLink [100]" so it is checked. Now, the you should see the device file "/dev/stlinkv2_2".

  2. Now, you can open the flash utility:

/opt/msv/<Your group directory>/bin/qstlink2

  1. Click on "Connect" and you should get some messages like:

    ST Link V2 found!

    Status: Core Running

  2. Click on "Send" and select the file ch.bin from the directory <Your MSV-source tree>/sources/STM32F4/embedded/ChibiOS/DiscoveryBoard/build

  3. Confirm the flash process by clicking on "Yes". The flashing process takes some time and the LEDs show flash between red and green.

  4. Once the flashing process has completed, you should see four LEDs between the two buttons shining depending on the way you move the board around. These LEDs visualize the data from the accelerometer.

  5. To "log in" to your STM32-DB, connect a USB-micro cable to the other USB connector.

17.a If you are running on a native Linux installation, you should see now a device /dev/ttyACM0 showing up.

If the above doesn't work, disconnect the device from your computer, cd in to /dev/ and list the directory cd /dev/ && ls. Connect the device again and perform ls. Now you can see updated list. Go through the list to see newly added device address (Probably /dev/ttyACMx, x= 0,1,2,3,...)

17.b If you are running in the virtual machine, you need to re-route the new USB device in Virtual Box or connect from your host system to the board. On Mac, you simply start a terminal and run

screen /dev/tty.usbmodem251
  1. The device number on your machine might differ. Once you have connected successfully to the board, you should see the prompt "ChibiOS/RT Shell".

  2. You can now type commands like "info" to get information about the running software.

  3. If you type "pa" you see the values from the accelerometer that are used to dim the LEDs.

Hint: If you are using Mac OS X for your development, it will claim the USB Virtual COM Port automatically and thus, you won't be able to connect to it using the virtual machine. To prevent Mac OS X from claiming the device, do the following:

sudo kextunload -b com.apple.driver.AppleUSBCDC
sudo kextunload -b com.apple.driver.AppleUSBCDCACMControl
sudo kextunload -b com.apple.driver.AppleUSBCDCACMData
sudo kextunload -b com.apple.driver.AppleUSBCDCECMData

Then, you can redirect the USB Virtual COM Port into the virtual machine.

Clone this wiki locally