Showing posts with label toolchain. Show all posts
Showing posts with label toolchain. Show all posts

Saturday, September 8, 2012

STM32F0 discovery + GCC + Eclipse + OpenOCD + Ubuntu - Part II

  Hello!
  As promissed in last post, I'll show you how to setup eclipse to work with the our STM32F0 discovery board + open source toolchain.

1) Open eclipse. First of all we need to install (if not already installed) two new software. So go to menu Help/Install New Software. In work with, type "http://download.eclipse.org/tools/cdt/releases/juno" and in the list below choose CDT Optional Features/ C/C++ GDB Hardware Debugging". Next in http://gnuarmeclipse.sourceforge.net/updates, select "GNU ARM C/C++ Development Support".
  2) Create a new C Project. Go to menu File/New Project and select C/C++ - C Project. Click next.
  3) In next window Choose under ARM Cross Target Application - Empty project. Select your toolchain (Sourcery G++ Lite) or (GNUARM).

  4) Go to menu Project/Properties. In C/C++ Build / Settings select Tool settings. In Target Processor change "Processor" to cortex-m0.


  5) Now in the same Tool Settings tab go to ARM Sourcery Linux GCC C Compiler / Preprocessor and add the following values:
USE_STDPERIPH_DRIVER
USE_STM32F0_DISCOVERY
STM32F0XX


  6) Still in Tool Settings tab go to ARM Sourcery Linux GCC C Linker / General and  uncheck "Do not use standard start file (-nostartfiles) and check "Remove unused sections (-Xlinker --gc-sections). In Script file (-T) set path: /home/stm32/workspace/Template/src/stm32f0.ld



  7) In C/C++ General, select Path and Symbols and add the following paths (in both Assembly and GNU C): 
/Template/Libraries/CMSIS/ST/STM32F0xx/Include
/Template/Libraries/
/Template/src
/Template/Libraries/STM32F0xx_StdPeriph_Driver/inc
/Template/Libraries/CMSIS/Include



  8) Configure GDB by clicking in the small arrow in the right of the bug. Select "Debug Configurations... ". Select "GDB Hardware Debugging" right click and select new. Change name to GDB-OpenOCD and in the bottom of the window click in "Select other..." and select "GDB (DSF) Hardware Debugging Launcher".

 9) Under tab Debugger, uncheck everything and set the path of your gdb from your toolchain:  /home/user/stm32/gcc-arm-none-eabi/bin/arm-none-eabi-gdb

  10) Under tab Start Up, uncheck everything and in "Run commands" add:
target remote localhost:3333
monitor reset init 
monitor stm_flash /home/user/stm32/workspace/Template/Debug/Template.elf 
load /home/user/stm32/workspace/Template/Debug/Template.elf 
symbol-file /home/user/stm32/workspace/Template/Debug/Template.elf 
cont

  11) Now configure OpenOCD by clicking in the small arrow in the right of the play with toolbox (external tools). Select "External Tool Configurations... ". Select "Program" right click and select new. Change name to OpenOCD. Set openocd path: /usr/bin/openocd and working directory: /home/user/stm32/openocd-0.6.0-rc1/tcl
  In "Arguments" write: -f /home/user/stm32/workspace/Template/extra/stm32f0discovery.cfg -f /home/user/stm32/workspace/Template/extra/stm32f0-openocd.cfg

  If everything is OK, compile your hello world program. Go to "External Tools" and select "OpenOCD". It should show de following message in Console:

Open On-Chip Debugger 0.6.0-rc1 (2012-09-03-20:37)
Licensed under GNU GPL v2
[...]


  Now, the great moment, put a breakpoint in your main and select the bug icon "GDB - OpenOCD". It should stop your code like this:



  That's all for today!

  Marcelo

Read more ►

Saturday, August 18, 2012

STM32F0 discovery + GCC + Eclipse + OpenOCD + Ubuntu - Part I

Hello there!

In this post I'll show how to set up your IDE to debug the STM32F0 discovery board using open source tools.
The STM32F0 is a kit (very cheap) from ST micro to introduces the ARM Cortex - M0. This little boards has integrated a STM32F051R8T6 microcontroller with a button, leds and I/Os and also a st-linkV2 which is used to program and debug. That's why this little board is so amazing! We can use the st-linkV2 embedded to program and debug others microcontrollers, you need only to change two jumpers and we're ready!

I must say that everything I did here was based in what Mike Szczys did here. So THANK YOU Mike!!!
Ok, let's start! First of all, create a folder stm32 in your home. We'll use this folder to save all files.

mkdir /home/stm32

1) Installing basic tools
sudo apt-get install build-essential
sudo apt-get install git
sudo apt-get install libtool
sudo apt-get install libftdi1
sudo apt-get install texinfo

2) Installing toolchain
a) You can download toolchain from code sourcery (or if you prefer, you can use crosstool-ng and generate your own toolchain)
https://sourcery.mentor.com/sgpp/lite/arm/portal/subscription?@template=lite

b) Install toolchain
sh ./arm-2012.03-56-arm-none-eabi.bin

if you have the error "ERROR: DASH shell not supported as system shell", type
sudo dpkg-reconfigure -plow dash

c) Chose: Minimal installation, default folder, check "Modify path for user", check "Don't create links"

3) Installing OpenOCD
Get here the latest version of OpenOCD (I got openocd-0.6.0-rc1) and save

tar jxvf openocd-0.6.0-rc1.tar.bz2
cd openocd-0.6.0-rc1
./configure --prefix=/usr --enable-maintainer-mode --enable-stlink
make
sudo make install

4) Install udev rules
git clone git://github.com/texane/stlink.git
cd /home/stm32/stlink
sudo install -m 644 49-stlinkv2.rules /etc/udev/rules.d/49-stlinkv2.rules
sudo udevadm control --reload-rules

5) Install Eclipse
a)Get the latest version Eclipse C/C++ here. My version is Indigo.
b) Install plugins. Go to Help/Install New Software...
c) Work with: http://gnuarmeclipse.sourceforge.net/updates and chose GNU ARM C/C++ Developement Support. Install it.
d) Work with: http://download.eclipse.org/tools/cdt/releases/indigo and chose GDB hardware debugging. Install it.

6) Get templates and setting up file directory
a) Create a workspace, a Template and a src folder inside at /home/stm32 (or somewhere)
mkdir /home/stm32/workspace
mkdir /home/stm32/workspace/Template
mkdir /home/stm32/workspace/Template/src

b) Download the following templates:
STM32F0discovery_fw.zip
git clone https://github.com/szczys/stm32f0-discovery-basic-template.git

b) Unzip STM32F0discovery_fw.zip and copy the Libraries folder into /home/stm32/workspace/Template
c) Copy STM32F0-Discovery_FW_V1.0.0/Project/Demonstration/stm32f0xx_conf.h into src folder.
d) Copy and paste the files in stm32f0-discovery-basic-template/Device/ldscripts/ into src folder.
e) Edit stm32f0.ld in src folder. Change paths in both include:
INCLUDE "/home/stm32/workspace/Template/src/stm32f0discovery_def.ld"INCLUDE "/home/stm32/workspace/Template/src/sections_flash.ld"f) Copy stm32f0-discovery-basic-template/Device/startup_stm32f0xx.s into src folder. RENAME IT TO .S. It's an eclipse issue.
g) Copy folder stm32f0-discovery-basic-template/Extra to /home/stm32/workspace/Template/


This post is already too long. In next post I'll show how to start a new project and set up debugger and OpenOCD in Eclipse. I promise that it will be soon!

Bye

Marcelo
Read more ►

Tuesday, June 14, 2011

Compiling uClinux with kernel linux-2.6.21

Hello everybody!
Today I'll show you what I did to compile the kernel.. First of all I'm assuming that you
have already installed build-essentials and mtd-tools packages.
Now let's begin the hard work! =D









  1) Download all these packages:
  - uClinux-dist-20070130.tar.gz
  - ea-uClinux-081020.diff.gz
  - ea-v3_1_incr1.diff.gz
  - linux-2.6.21.tar.gz
  - arm-linux-tools-20061213.tar.gz
  - arm-elf-tools-20040427.sh
  - mkimage (used to generate uLinux.bin)

2) untar toolchain 1. (It will untar in the same directory where you download it. I add this path to the $PATH)
tar -zxvf arm-linux-tools-20061213.tar.gz
export PATH=$PATH:path-to-the-download-directory/usr/local/bin

Note: You can either move this directory to a directory in the PATH or add the path into the $PATH in your /home/user/.bashrc. In this way you don't have to export everytime you open a new console.

install toolchain 2.
./arm-elf-tools-20040427.sh
I had a problem when installing this toolchain. If you get an error too, edit this file and try changing:
tail +${SKIP} ${SCRIPT} | gunzip | tar xvf -
by
tail -n +43 ${SCRIPT} | gunzip | tar xvf -
Copy mkimage to /usr/local/bin and set it as executable
sudo chmod +x /usr/local/bin/mkimage

3) untar uClinux and then remove old kernel
tar -zxvf uClinux-dist-20070130.tar.gz
rm -r ./uClinux-dist/linux-2.*
4) untar linux-2.6.21 and move it to uClinux-dist
tar -zxvf linux-2.6.21
mv ./linux-2.6.21 ./uClinux-dist/linux-2.6.x
5) apply both patchs
cd ./uClinux-dist
gunzip -c ../ea-uClinux-081029.diff.gz | patch –p1
gunzip -c ../ea-v3_1_incr1.diff.gz | patch –p1
6) Configure & Compile.
a)Choose vendor Embedded Artists and board LPC2468
b)Disable i2c in device drivers > I2C support > <> I2C support
make menuconfig
make ARCH=arm CROSS_COMPILE=arm-elf-
After make, you will get an error. You must include <linux/limits.h>  in the file ./linux-2.6.x/scripts/mod/sumversion.c. Make again and go take a coffe.
The images will be in the folder ./images
-rw-r--r--  1 user user 1012K 2011-06-14 14:13 cramfs.img
-rw-r--r--  1 user user  4.2M 2011-06-14 14:13 image.bin
-rw-r--r--  1 user user     0 2011-06-14 14:13 jffs2.img
-rwxr-xr-x  1 user user  162K 2011-06-14 14:13 linux.data
-rw-r--r--  1 user user  1.1M 2011-06-14 14:13 linux.gz
-rwxr-xr-x  1 user user  2.1M 2011-06-14 14:13 linux.text
-rw-r--r--  1 user user  1.9M 2011-06-14 14:13 romfs.img
-rw-r--r--  1 user user  1.1M 2011-06-14 14:13 uLinux.bin

It's weird that we need 2 toolchain... I don't know why, but arm-linux- is used to compile the kernel (actually the kernel complains that the toolchain arm-elf is too old). It has been forced to, even if you set CROSS_COMPILE=arm-elf-. The rest is compiled with arm-elf-, so, be sure that both toolchain is in the path.

Until today, jffs2 file system can't be generated following these instructions. I'll check later! =D

Next post we'll update u-boot and boot the kernel! Wait and you'll see! =D
That's all

Marcelo Jo
Read more ►

Friday, June 10, 2011

Toolchain for ARM


  Hi people,
  I'm following some instructions from Embedded Artists to build my own toolchain, compile and upgrade board's u-boot. I'm working with Kubuntu 11.04 and using the followings packages:

  - u-boot 1.16 with 2 incremental patchs from EA.
  - uClinux-dist-20070130.tar.gz
  - kernel linux-2.6.21
  - arm-linux-tools-20061213.tar.gz
  - arm-elf-tools-20040427.sh

  It's strange that we need two toolchains, arm-linux and arm-elf. Actually I couldn't compile the kernel yet and than I downloaded the uLinux.bin and romfs.img from EA website.
  We can't compile the kernel with arm-elf because this toolchain is too old (according to error message). So we have to compile the kernel using arm-linux. I'm not sure yet why two toolchain.. anyway we move on... =D

  Marcelo Jo
Read more ►