SDIN Boards
Contents
Base Environment
Install Compiler gcc-arm-none-eabi
Download last version of GCC ARM Embedded from: https://launchpad.net/gcc-arm-embedded/+download
Untar the compiler:
tar -xvjf gcc-arm-none-eabi-<VERSION>.tar.bz2
Copy it to a common place:
sudo cp -r gcc-arm-none-eabi-<VERSION> /opt/compilerSTM32
Important!! If in a 64 bits machine, you will need to install the following libs:
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
Install OpenOCD On-Chip Debugger
Install dependencies:
sudo apt-get install flex bison libgmp3-dev libmpfr-dev libncurses5-dev libmpc-dev autoconf texinfo build-essential \ libftdi-dev libusb-1.0-0-dev libexpat1-dev
Download last version of Openocd from: http://openocd.org/
Untar openocd:
tar -xvzf openocd-<VERSION>.tar.gz
Go into the directory:
cd openocd-<VERSION>
Configure openocd compilation:
./configure --prefix=/opt/openocd/ --enable-jlink --enable-amtjtagaccel --enable-ftdi --enable-buspirate --enable-stlink \ --enable-ftdi --enable-rlink
Compile it:
make
Install:
sudo make install
Prepare its use according to udev:
(old versions) sudo cp -r contrib/openocd.udev /etc/udev/rules.d/90-jtag.rules (new versions) sudo cp -r contrib/99-openocd.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules
Grant permits to user: user must be in plugdev:
sudo vi /etc/group
Basic Usage
Need to load environment. Create a env.sh file with:
export PATH=/opt/openocd/bin:/opt/compilerSTM32/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Load the environment:
source env.sh
Open ocd:
openocd -f openocd.cfg -c "init" -c "halt" -c "reset halt"
Eclipse Environment
It is mandatory to install the Base Environment first
Install Eclipse
(More info at: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Fgetting_started%2Fcdt_w_import.htm)
Download last version of Eclipse IDE for C/C++ Developers from: http://www.eclipse.org/downloads/
Untar eclipse:
tar -xvzf eclipse-cpp-<VERSION>-linux-gtk-x86_64.tar.gz
Go into directory and execute eclipse:
cd eclipse ./eclipse
Define workspace (e.g. /home/<USER>/stm32EclipseWorkspace)
Install C/C++ Developping tools
Go to Help -> Install New Sofware -> Choose from the drop-down list
- Name: CDT-<ECLIPSE VERSION>
- Location: http://download.eclipse.org/tools/cdt/releases/<VERSION>
For example:
- Name: CDT-Neon.2
- Location: http://download.eclipse.org/tools/cdt/releases/9.2
- Click Ok
- Select: CDT Optional Features -> C/C++ GDB Hardware Debugging
- Next, Next, Agree, Finish
- Restart
Install GNU ARM Plugins
Go to Help -> Install New Sofware -> add
- Name: GNU ARM Eclipse Plugins
- Location: http://gnuarmeclipse.sourceforge.net/updates
- Click Ok
- Select All
- Next, Next, Agree, Finish
- You will be asked to accept some specific not known content, do it
- Restart
Import Project
(More info at: http://gnuarmeclipse.github.io/plugins/install/)
Go to File -> New -> C Project
- Name: test
- Location: Select where the code is
- Project type -> Makefile project -> Empty Project -> Cross ARM GCC
- Next, Next
Toolchain:
- Name: GNU Tools for ARM Embedded Processors (arm-none-eabi-gcc)
- Path: /opt/compilerSTM32 (if installed as in previous section, if not check where did you do it!!)
- Finish
If everything ok, you are able to compile with the hammer.
Set OpenOCD
(More info at: https://balau82.wordpress.com/2014/02/23/stm32-p152-development-with-eclipse-on-linux/)
- Run -> External tools -> External Tools Configurations
- Program -> New
- Location: /opt/openocd/bin/openocd (if installed as in previous section, if not check where did you do it!!)
- Working Directory: A Dir where there is the openocd.cfg (typically where our porject is)
- Arguments: -f openocd.cfg -c "init" -c "halt" -c "reset halt"
- Apply
Set GDB
(More info at: https://pixhawk.org/dev/jtag/gdb_eclipse)
Go to Run -> Debug Configurations
Create a GDB Hardware Debugging
In Main:
- Application: The .elf file that will be generated by the project (e.g. sensedin.elf)
- Project: The project location
- Use workspace settings
- Select legacy GDB Hardware Debugging Launcher by clinking Select other
In Debugger:
- GDB Command: /opt/compilerSTM32/bin/arm-none-eabi-gdb
- Standard(Linux)
- Version: mi
- Use remote target
- JTag: TCP/IP
- IP: localhost
- Port: 3333
In Startup:
- Un-click Reset and Delay
- Un-click Halt
- In command box type:
- monitor reset halt
- Click Load Image
- Click Load symbols
- In Run Commands write:
- set $pc = Reset_Handler
- stepi
Finally click Apply