本帖最后由 QianFan 于 2015-10-27 19:54 编辑
3 x. q5 \7 u! G/ G9 ~
4 [8 H) W2 d/ I0 T2 [* S2 M) t; f 记事本用习惯了,论坛写帖子的时候动不动Ctrl+S一下。。。
+ k; k- r% w1 }* l. a7 b/ `* `8 C/ d" A f* Y
在Ubuntu下开发STM32,两个常用软件是必须的。一是我们的交叉编译器,arm-none-eabi-xxx。二是st-link的驱动。这里的st-link并不像我们windows下面用的那样,一路点Next就好了。这里我们需要从github上面下载源码,自己编译,安装。st-link不仅仅是我们下载代码的工具,更是我们使用gdb调试的基础。
7 i4 W9 z3 G, b, M/ P- P
c# N3 J; F i/ h5 B$ slinux对USB虚拟串口的支持:
U. _& M( h: Q( v& T5 J5 v. m linux下自带虚拟串口的驱动。不需要手动安装。linux对串口的命名不同于windows。像CP2102之类的USB转串口,是ttyUSBx,虚拟串口之类的是ttyACMx。我们先来找一下串口的编号。所有的设备都在/dev目录下。那么插Nucleo前后/dev中的新增项就是Nucleo的串口。 D6 S% C) q0 Q( r! y! _
- 在未插Nucleo之前,保存所有的设备名字到before.txt---->ls /dev >before.txt
- 在插上Nucleo之后,保存所有的设备名字到after.txt------>ls /dev >after.txt
- 使用diff查看改动--->diff before.txt after.txt
- 看到新增项,ttyACM0就是我们Nucleo的串口编号。
1 c/ S) U$ u) i: m; O6 y2 ` 4 ^9 X1 ^3 o U4 H! f
常用的串口软件:
8 a$ Y1 V Y, a6 k 在linux下工作,串口软件我更喜欢minicom。他小巧,使用控制台窗口。有多种模式可以选择。当然,putty也是一个不错的选择。
8 k" s4 `+ Z! v- t# _5 {9 k- 安装minicom: sudo apt-get install minicom
- 或者安装putty: sudo apt-get install putty
- 安装完minicom之后,需要简单的配置一下。比如串口号,波特率,通信协议等等。可以使用sudo minicom -s 进行配置。; O& t% |. G4 `
, i d' G& c2 ]! d Kst-link的安装:
* ?$ V% K7 }. }& [( }5 m 在github上有st-link在linux下的源代码。为了操作简便,还是在使用st-link之前将它升级为v2。4 R* O2 P! {* O- n
- 在http://github.com/texane/stlink 下下载源码。
- 在README Markdown文件中,有详细的安装说明。按照他的要求做就行啦。
- $ ./autogen.sh $ ./configure $sudo make install
- 如果你在执行 ./autogen.sh的时候,出现错误,可以打开这个文件:autoreconf --install --force --verbose 。其实错误的原因还是autoreconf命令没有安装。在Ubuntu下使用sudo apt-get install autoconf安装完就可以了。
- 安装完st-link之后,记得将他的路径添加到PATH中。具体的方法请参考Google。
- 具体的使用方法,可以参阅 st-flash --help。这个命令是下载使用的。如果想配合gdb调试使用,需要使用st-util。
9 g# L4 o! N2 S- t ; l9 d3 X+ B5 N9 A% w
arm-none-eabi-xxx的安装:http://launchpad.net/~terry.guo/+archive/ubuntu/gcc-arm-embedded G9 ~0 n! P" x$ @
arm-none-eabi-xxx不仅仅包含gcc,g++,而是一整套完整的工具链。像CoIDE,RIDE,TrueStudio这些都是使用它作为编译工具的。只不过在命令行的基础上,套上了一个Eclipse的壳子罢了。6 O8 q- H, ?' w8 Z& N+ E1 ]
' q5 T+ ?6 Q7 z5 o" _
1 J2 o5 g* i9 Y9 V& u5 `
* K, O5 e* I7 h9 j5 B
6 [9 ~1 n' a; k! C# J6 Y |
! y" a4 i1 T0 i0 i/ ~
请教一下:安装stlink,你有没有遇到过下面的情况:$ a8 `+ R0 r( K
abyte@u-server-amd64:~/stlink-master$ ./configure 1 \; {1 r _) A) s5 k7 i
checking for a BSD-compatible install... /usr/bin/install -c2 p* A% i) d6 m& |" @% r8 _
checking whether build environment is sane... yes7 }& S% N0 @ ~0 J
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... no; {# D" h2 z2 a
checking whether make supports nested variables... no" y2 `7 e, X n0 K- w, M, }" p
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/abyte/stlink-master':* i: ~3 m. K" K5 u9 g. P- a0 ]6 L
configure: error: C compiler cannot create executables
See `config.log' for more details
abyte@u-server-amd64:~/stlink-master$more config.log This file contains any messages produced by compilers while( H6 g4 e2 t8 O$ m) {( ]9 x( e
running configure, to aid debugging if configure makes a mistake.
It was created by stlink configure 0.5.6, which was
generated by GNU Autoconf 2.69. Invocation command line was
e$ {3 O: |( ^0 X
$ ./configure " w# R5 J) o# X9 _, V1 B
## --------- ##
## Platform. ##% b9 N# |, J$ _7 c( ?: h
## --------- ##
....
...
...+ S' \ j k7 N7 Y
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) ( y* ^, G1 W9 W2 D* ?: H
configure:3102: $? = 0/ T9 }( s; E& a1 R w2 v
configure:3091: gcc -V >&5+ d7 e. F: Y/ y, O _' A
gcc: error: unrecognized command line option '-V'% G; L4 A# {- N' f8 J6 ~
gcc: fatal error: no input files
compilation terminated.
configure:3102: $? = 4
configure:3091: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files. O4 ~; V+ H% k
compilation terminated.( Q; h* F( ]" U) I# k
configure:3102: $? = 49 ]4 p- n! \) d
~: t, G- W$ Z) d2 Y3 ?2 G" o+ n
configure:3122: checking whether the C compiler works
configure:3144: gcc conftest.c >&5# p9 X" w ]/ p7 n* @. w/ ]
/usr/bin/ld: cannot find crt1.o: No such file or directory4 z8 z1 @+ C. h2 `8 ?. i
/usr/bin/ld: cannot find crti.o: No such file or directory! u+ ?' y- r8 f; F9 W
/usr/bin/ld: cannot find -lc" F+ Q& [( r3 S( s9 C$ u4 o
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status5 v9 m2 U w' s, g, n$ w3 j
configure:3148: $? = 1
configure:3186: result: no# Z; I8 ^$ w$ M- T. x
configure: failed program was:( H, j6 G. L8 |6 [
...2 x# X7 {5 ^5 R- |3 u8 P
...* f$ O5 U! d* Z {2 M2 \6 u
checking for sys/mman.h... yes
checking sys/poll.h usability... yes# v4 a. A, E7 V: H- j! D3 O
checking sys/poll.h presence... yes1 ~2 B8 J' |. Z+ W Y2 y5 k J* g
checking for sys/poll.h... yes2 D9 s' h* c6 `) I7 \! y
checking for mmap... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes% A2 V% a( I, m% [) Y: I
checking for USB... yes" T# P/ {$ ^0 y$ O& R; f1 b( n
checking for usb_path2devnum in -lusbpath... no: s$ ^5 l' x5 o& M8 y2 f7 z* s! G+ A
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile! V) K- J- \' w4 ?. T( Q
config.status: executing depfiles commands
aoems@ubuntu:~/stlink-master$ gcc --version( F% e5 k/ o( a i w
gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010# o' a2 S1 d* ~
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO2 q) u3 W t) i/ V
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
) i8 ]$ I: l! [! Y7 V. s: |/ C
aoems@ubuntu:~/stlink-master$ sudo make install
...: O2 e/ e0 b, K F4 O. H
make[2]: Entering directory '/home/aoems/stlink-master'3 }; v9 Q' W, c' p3 y1 u
/bin/mkdir -p '/usr/local/bin'
/usr/bin/install -c st-flash st-util st-term st-info '/usr/local/bin'& Q1 [0 k! H9 I3 ^0 g, b1 I
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/aoems/stlink-master'& c' c7 Z$ V# L. G# ~/ W* f
make[1]: Leaving directory '/home/aoems/stlink-master'
aoems@ubuntu:~/stlink-master$/ @5 p2 w' V+ U/ I% y9 y2 o h1 E# |
安装时,显示没做任何事情,不明白安装是否成功。
已经执行了的。这一步没报错误。---我的ubuntu是14.04 server版。另外我编辑了上一个帖子,吧config.log的内容也附上了。6 N6 P# \" w! e# P" b( t/ W
./autogen.sh的运行结果:& @0 B. ]2 x5 c# H0 n# Q v
abyte@u-server-amd64:~/stlink-master$ ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext- @# F3 s, o7 Q
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool1 B# m, e4 M- q' p/ z& L
autoreconf: running: /usr/bin/autoconf --force( D7 _$ o# a# @3 k/ E G
autoreconf: configure.ac: not using Autoheader# l- ~: t; W; _
autoreconf: running: automake --add-missing --copy --force-missing6 F/ x" L8 h7 t
autoreconf: Leaving directory `.'
对啊,专门给橙子哥留的啊
一开始的sudo sh ./autogen.sh执行了吗?
你下载的文件没有被改过吧。看这个地方
configure:3091: gcc -V >&53 [+ N* y7 A' A w
gcc: error: unrecognized command line option '-V'8 a5 _; J2 h1 E H) h0 a$ P
gcc: fatal error: no input files1 b6 b4 G6 |( q
compilation terminated.9 T5 |) n, M" @. e2 n
应该是gcc -v才对啊。要不你重新下载一次。在重新编译试试看。不行的话我给你发一份编译好的也行。这个我也是照着github上来的。有问题可以去github上给开发者留言看看。