2015年6月27日 星期六

Installing STM32F4 Development Environment for Linux and Mac OS


1.、Download Toolchain
Visit GNU Tools for ARM Embedded Processors or just use one of the links below to download it

2、Install automake

Mac OS:
$ brew install automake
Linux:
$ sudo apt get install automake

3、Make a New Directory and decompress the tar.bz2 file you download

Mac OS:
$ cd {Your workspace}
$ mkdir toolchain
$ mv {Your download} toolchain
$ cd toolchain
$ tar -jxvf gcc-arm-none-eabi-4_9-2015q2-20150609-mac.tar.bz2

Linux:
$ cd {Your workspace}
$ mkdir toolchain
$ mv {Your download} toolchain
$ cd toolchain
$ tar -jxvf gcc-arm-none-eabi-4_9-2015q2-20150609-linux.tar.bz2

4、Set environment variable
*If you close the terminal , the environment variable set by export command will disappear . 
You need to do those things again when you open a new terminal .    
( If you want to permanently export a variable --> google it  )
$ cd {Your workspace}
$ cd toolchain/gcc-arm-none-eabi-4_9-2015q2/bin
$ export PATH=$PATH:`pwd`

5、Get st-util tool (stlink tool)

$ cd {Your workspace}
$ mkdir sttool
$ cd sttool
$ git init
$ git pull https://github.com/texane/stlink
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

6、Download stm32f4 blink example
$ cd {Your workspace}
$ mkdir blink
$ cd blink
$ git init 

$ git pull https://github.com/SAM33/STM32F4Blink.git

7、Connect your stm32f4 to computer , and open a new terminal to run st-util

Mac OS:
$ st-util

Linux:
$ sudo st-util
You will get some message like this :
Remember the port which gdbserver running .

8、Go back to last terminal and make stm32f4 blink example
$ cd {Your workspace}
$ cd blink
$ make


9、Upload elf file to stm32f4
$ cd {Your workspace}
$ cd blink
$ arm-none-eabi-gdb
(gdb) tar ext localhost:4242
(gdb) load build/blink.elf
Loading section ..............
Loading section ..............
Loading section ..............
(gdb) run
The program being debugged has been started already.
Start it from beginning? (y or n) y
//now you will see stm32f4 board blinking !!
//stop : input ctrl^c twice
ctrl^c ctrl^c
//close gdb
(gdb) ctrl^d
A debugging session is active ....
Quit anyway? (y or n) y

This command : (gdb) tar ext localhost:????   ---->  ???? is the port you remember
Enable gdb remote debuging using st-util gdb server . You will get some log in your st-util windows ,