Skip to content

Getting Started with HydraBus and STM32CubeIDE

Benjamin Vernoux edited this page May 13, 2022 · 18 revisions

Getting Started with HydraBus and STM32CubeIDE

The aim of this page is to explain How to Build / Flash and Debug HydraBus firmware with STM32CubeIDE on Windows & Linux.

1) Hardware requirements

  • HydraBus v1
  • HydraNFC Shield v2
  • STLINK-V3SET (Programmer/Debugger)
  • 10x high quality Dupont Wire 2.54mm female to female with min length 8cm (do not exceed 10cm if possible especially to reach maximum speed with SWD 24MHz...)
    • Only 9x "Dupont Wire 2.54mm female to female" are required but it is always better to have more/spare ...

2) Connect STLINK-V3SET (Programmer/Debugger) to HydraBus v1 / HydraNFC Shield v2

2-1) Connect STLINK-V3SET SWD to HydraBus v1 SWD (for basic debugging):

Connect STLINK-V3SET SWD to HydraBus v1 SWD

2-2) Connect STLINK-V3SET SWD / SWO & USART1(TX/RX) to HydraBus v1 (for advanced debugging/traces):

Connect STLINK-V3SET SWD/SWO/USART to HydraBus v1

3) Software requirements

3-1) Install STM32CubeIDE v1.4 or more (tested with v1.9.0 too)

3-2) Install developer tools and clone project repository

3-2-1) For Windows

3-2-1-1) Prerequisites for Windows
git clone https://github.com/hydrabus/hydrafw_hydranfc_shield_v2.git hydrafw_hydranfc_shield_v2 --recursive
cd hydrafw_hydranfc_shield_v2/
cd ./scripts
python get-pip.py
python -m pip install GitPython --upgrade
python -m pip install intelhex --upgrade

Note: For get-pip.py if you need a proxy for internet access set following variables before to launch python get-pip.py:

set http_proxy=http://proxy.myproxy.com
set https_proxy=https://proxy.myproxy.com

3-2-1) For Linux

3-2-1-1) Prerequisites for Linux
cd ~
sudo apt-get install git dfu-util python putty
git clone https://github.com/hydrabus/hydrafw_hydranfc_shield_v2.git hydrafw_hydranfc_shield_v2 --recursive
cd ~/hydrafw_hydranfc_shield_v2
cd ./scripts
sudo python get-pip.py
sudo python -m pip install GitPython --upgrade
sudo python -m pip install intelhex --allow-external intelhex --allow-unverified intelhex
cd ..
  • For Debian / Ubuntu on 64bits/amd64 system see https://wiki.debian.org/Multiarch/HOWTO in order to enable multi architecture for i386 support.
  • When multiarch is enabled you shall also install libc6-i686:i386 (Debian) or libc6:i386 (Ubuntu)

Note: For get-pip.py if you need a proxy for internet access set following variables before to launch python get-pip.py:

export http_proxy=http://proxy.myproxy.com
export https_proxy=https://proxy.myproxy.com
sudo -E python get-pip.py

4) Start STM32CubeIDE v1.4 and Import project

4-1) Start STM32CubeIDE v1.4

Start STM32CubeIDE

4-2) Import the project

  • Select menu File -> Import...
    • Select General -> Existing Projects into Workspace

    • Click on Next Import ExistingProjects

    • Click on Deselet All

    • Select only hydrafw_hydranfc_shield_v2 project

    • Click on Finish Import Project hydrafw_hydranfc_shield_v2

5) Clean the project

  • Select hydrafw_hydranfc_shield_v2 project (click on project with right mouse button)
    • A contextual menu appears, select Clean Project Clean Project Contextual Menu

    • Clean shall display in Console Build Finished. 0 errors, 0 warnings. Clean Project OK

6) Build the project

  • To Enable Debug build (with symbols) you shall change Makefile

    • export HYDRAFW_DEBUG ?= 0 to export HYDRAFW_DEBUG ?= 1 Project Enable Debug Build
  • Select hydrafw_hydranfc_shield_v2 project (click on project with right mouse button)

    • A contextual menu appears, select Build Project
    • Build shall display in Console Build Finished. 0 errors Build Project OK

7) Flash & Debug the project

  • Select hydrafw_hydranfc_shield_v2 project (click on project with right mouse button)
    • A contextual menu appears, select Debug As -> Debug Configurations... Debug As Debug Configurations Contextual Menu
    • Debug Configuration view appears, double click on STM32 Cortex-M C/C++ Application
      • The entry hydrafw_hydranfc_shield_v2 Debug is automatically created Debug hydrafw_hydranfc_shield_v2 entry
  • Select Debugger Tab and configure it like in picture
    • When all is configured click on Debug button Debug hydrafw_hydranfc_shield_v2 Debugger
  • Debug session is started and program is stopped in start of main() code (you can click on Resume (F8) to resume execution of code) Debug hydrafw_hydranfc_shield_v2 start session

8) Advanced debugging with SWO and STM32CubeIDE Serial Wire Viewer(SWV)

  • Select menu Window -> Show View -> SVW to add all different Serial Wire Viewer features Debug Advanced SWO Serial_Wire_Viewer menu
    • Add SWV TraceLog, SWV ITM Data Console and SWV Data Trace Timeline Graph
    • Then select SWV TraceLog and click on Configure trace icon to configure SWV Debug Advanced SWO Serial_Wire_Viewer config
    • Interesting things to configure are mainly to enable Timestamps and ITM Sitmulus Ports 0 (for SWO/SWV ITM Data Console especially for debug trace and crash/exception details) Debug Advanced SWO Serial_Wire_Viewer configure ITM
    • Then click on OK button
    • Last step is to start the Trace(using Serial Wire Viewer settings) by clicking on Start Trace button and finally click on Resume (F8) button to see the trace and data in live Debug Advanced SWO Serial_Wire_Viewer Start Trace / Resume execution

We can see in real-time the different trace and console data during execution of code Debug Advanced SWO Serial_Wire_Viewer Trace Console

Clone this wiki locally