你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

Ubuntu下开发STM32---0.软件搭建  

[复制链接]
qianfan 发布时间:2015-10-23 15:17
本帖最后由 QianFan 于 2015-10-27 19:54 编辑
! Z( B' m: d* G3 Q8 Q7 x; ], E6 @7 x
    记事本用习惯了,论坛写帖子的时候动不动Ctrl+S一下。。。; K' \. V. W8 f( [

) _" A7 a9 l# R$ D    在Ubuntu下开发STM32,两个常用软件是必须的。一是我们的交叉编译器,arm-none-eabi-xxx。二是st-link的驱动。这里的st-link并不像我们windows下面用的那样,一路点Next就好了。这里我们需要从github上面下载源码,自己编译,安装。st-link不仅仅是我们下载代码的工具,更是我们使用gdb调试的基础。8 X+ I- m: P" l9 {+ _1 \2 y2 O4 v

9 D$ i- k- z( Klinux对USB虚拟串口的支持:- v" w- N1 i/ j3 W% R, ]8 n
    linux下自带虚拟串口的驱动。不需要手动安装。linux对串口的命名不同于windows。像CP2102之类的USB转串口,是ttyUSBx,虚拟串口之类的是ttyACMx。我们先来找一下串口的编号。所有的设备都在/dev目录下。那么插Nucleo前后/dev中的新增项就是Nucleo的串口。
" i. g7 _, y- x
  • 在未插Nucleo之前,保存所有的设备名字到before.txt---->ls /dev >before.txt
  • 在插上Nucleo之后,保存所有的设备名字到after.txt------>ls /dev >after.txt
  • 使用diff查看改动--->diff before.txt after.txt
  • 看到新增项,ttyACM0就是我们Nucleo的串口编号。4 Y  h, f* Z; E0 m' P
9 H1 U" ^) r5 D" y* m
常用的串口软件:7 d4 P- X8 w& ?! w/ S; N
    在linux下工作,串口软件我更喜欢minicom。他小巧,使用控制台窗口。有多种模式可以选择。当然,putty也是一个不错的选择。
. I  h4 r+ I' m0 _/ Z9 }. l* H% I
  • 安装minicom: sudo apt-get install minicom
  • 或者安装putty:   sudo apt-get install putty
  • 安装完minicom之后,需要简单的配置一下。比如串口号,波特率,通信协议等等。可以使用sudo minicom -s 进行配置。3 }, X! L! m* W

. k: w; |7 f2 h. u. Y! Nst-link的安装:
$ C* u3 g* i" v    在github上有st-link在linux下的源代码。为了操作简便,还是在使用st-link之前将它升级为v2。0 ?0 m9 i( f; [/ u  l, b
  • 在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。
    ' l* P2 ~$ `  i' c2 v9 \# q) k2 o- a

/ y! A$ p7 t; D' p5 w4 p6 warm-none-eabi-xxx的安装:http://launchpad.net/~terry.guo/+archive/ubuntu/gcc-arm-embedded* Q; t+ I& ~! Y$ Z: B0 W; T
     arm-none-eabi-xxx不仅仅包含gcc,g++,而是一整套完整的工具链。像CoIDE,RIDE,TrueStudio这些都是使用它作为编译工具的。只不过在命令行的基础上,套上了一个Eclipse的壳子罢了。5 T$ p% k7 `9 E, k6 @
  • Step1: Inside Ubuntu, open a terminal and input" U4 c7 B, ^) A/ Y+ w
           "sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded"
  • Step2: Continue to input
           "sudo apt-get update"# P  J5 c& q7 ]; F4 C- w
  • Step3: Continue to input to install toolchain  ~* A4 J7 `" p. [) |$ n8 r
           "sudo apt-get install gcc-arm-none-eabi"
    6 ?7 A4 k% U) p& i$ ^& ]0 |
  • To remove installed toolchain, just input "sudo apt-get remove gcc-arm-none-eabi".& x$ m6 y6 q% y: g7 o1 c# E& c
    7 ^0 D4 J2 Q2 _0 ~  q
    ! O7 b; o$ B0 U
  • To update the toolchain, just repeat above step2 and step3.
    - W& R0 Q2 |( |  ^9 @# t
    & u( d& ~- u$ H/ P& E6 e2 Q

7 D0 C1 b, g8 H# j. u+ B7 Q$ d' T  [, c# V" H8 z( |
* A. ?% p" ~" a0 w( W0 m, T
' w" V" w* B4 h: N9 e4 L* B; N  N
赞 收藏 7 评论33 发布时间:2015-10-23 15:17

举报

33个回答
ataudio 回答时间:2015-10-29 14:53:52
本帖最后由 ataudio 于 2015-10-29 15:56 编辑
( D) s2 t' c4 t. g
" \7 Y6 O$ h# `+ H. N请教一下:安装stlink,你有没有遇到过下面的情况:; Y3 }0 j- b; `% O- N$ o
abyte@u-server-amd64:~/stlink-master$ ./configure 0 ]' U. Q# J- q# P
checking for a BSD-compatible install... /usr/bin/install -c  x" E* u+ [- F  L
checking whether build environment is sane... yes
8 z, p+ j- X6 \' J7 tchecking for a thread-safe mkdir -p... /bin/mkdir -p
: U9 t1 n8 t3 o! Q7 V, ichecking for gawk... gawk
1 n) A* a" }( x# \checking whether make sets $(MAKE)... no8 A- b) y4 ?$ e3 b
checking whether make supports nested variables... no
4 ?# g; i$ m$ U- Zchecking for gcc... gcc# d) {# T! k* h' \! X8 j
checking whether the C compiler works... no
1 v" p  K* ~+ j- O+ h2 B, Tconfigure: error: in `/home/abyte/stlink-master':; Y  m. q) b, q! F% ]; |2 H( R7 h
configure: error: C compiler cannot create executables
( G, G6 D' O3 W& v$ l) hSee `config.log' for more details

' P7 _3 [7 Y7 Z5 f1 Babyte@u-server-amd64:~/stlink-master$more config.log This file contains any messages produced by compilers while
4 E( x, E. E! J# d4 D9 ?% ?" y, Brunning configure, to aid debugging if configure makes a mistake.0 V6 Q+ K+ I1 Q1 K' Y  A$ b' O

% h5 C; g  i) V! NIt was created by stlink configure 0.5.6, which was
# d8 K+ z6 x* F- n& h6 Mgenerated by GNU Autoconf 2.69.  Invocation command line was; W5 _" M& y' n" c- o5 f, ]3 G

$ F' O: ]$ Q+ e* n  B) X; Y5 y  T  $ ./configure
7 T% I9 x- P5 D" @! o: v5 f) u) N, n+ m- Q( w
## --------- ##8 l  `9 a. O5 ]# z) S5 ^
## Platform. ##% b5 B, N: G: V: \0 d& w* t
## --------- ##  N" j- p8 P2 ]- @) F/ ~
....
* ^$ N, {0 u; j% U$ I...% s  s5 V2 v7 H' q$ J# @
...
+ g( U: Y" E; Ugcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
( o1 n1 a: i8 ~$ |+ c8 a. }configure:3102: $? = 0. Y( X# `8 \  `: c0 `
configure:3091: gcc -V >&54 [0 q* g) ~* \  B0 Y
gcc: error: unrecognized command line option '-V'  V6 F* A4 W, ?( @1 J0 P
gcc: fatal error: no input files
4 k) x5 r0 H& m, [compilation terminated.
8 a- l; B7 Q* y( `configure:3102: $? = 4! [$ P/ f- c8 R8 R: J  G
configure:3091: gcc -qversion >&5% U1 Z  k3 A- E* ^: J" Z: W
gcc: error: unrecognized command line option '-qversion'
* l7 c9 ?$ w+ @  u& G) b3 Ogcc: fatal error: no input files
# i, B* a; E/ bcompilation terminated.9 j* w" p/ z3 x" N$ Y
configure:3102: $? = 4$ l# ]% `9 |( B6 s8 V2 q7 [' v

7 I! y7 S5 @4 f0 y( lconfigure:3122: checking whether the C compiler works1 e% G3 ^( X4 G+ U1 N/ O
configure:3144: gcc    conftest.c  >&5  L! E: A6 w0 q* m9 `1 ~" b
/usr/bin/ld: cannot find crt1.o: No such file or directory% i$ }: k$ Q( z) B( a
/usr/bin/ld: cannot find crti.o: No such file or directory
2 b8 n: I9 c$ ]& m4 g. t9 r/usr/bin/ld: cannot find -lc
3 K) \3 a+ l( o/usr/bin/ld: cannot find crtn.o: No such file or directory: ]1 U1 ]( C# ^& L2 s7 d
collect2: error: ld returned 1 exit status$ A3 f% O  f% U- @" i
configure:3148: $? = 1
0 w, U% ^" ?  s' qconfigure:3186: result: no
8 g/ ^' R0 u& s# `3 ]6 @4 i* Bconfigure: failed program was:
  @- L3 ]! }1 ^' I
9 X% N; P# t1 X7 k2 P( X) Y...
; n0 D* s$ l" ~4 P* u9 I.... G& |4 l7 E/ D

- e- {3 F7 o% |  t+ a2 a# L9 C' U
ataudio 回答时间:2015-11-3 10:42:53
换成ubuntu 15.10桌面版,gcc版本是5.2,编译stlink成功。
' q: _7 V. L; H& E7 C, ~! k  Ichecking for sys/mman.h... yes
/ x9 }) F8 y1 C& g* y( g, m7 \checking sys/poll.h usability... yes
% f% [1 e8 c! z. e9 k* X0 ^/ Achecking sys/poll.h presence... yes" i6 p4 B" a  m: K8 i
checking for sys/poll.h... yes' ~; r- j* [$ O- y
checking for mmap... yes: Q! r7 t% V0 K0 e* c8 A
checking for pkg-config... /usr/bin/pkg-config
! S+ K) b/ n5 P# D/ G/ I& Ochecking pkg-config is at least version 0.9.0... yes1 i  m* J8 \- e. {" r: e6 D
checking for USB... yes( J2 G! [% O6 |: ~+ H3 E
checking for usb_path2devnum in -lusbpath... no$ ]. g; A% h5 V$ m6 F& p  }
checking that generated files are newer than configure... done/ q  w6 m: P7 o3 h
configure: creating ./config.status
, P( k) C. n( U  Q$ b4 {config.status: creating Makefile
: @9 S, I5 j9 n: f8 {$ Jconfig.status: executing depfiles commands
$ g" K" T& a; O" J  eaoems@ubuntu:~/stlink-master$ gcc --version. K2 D0 ~9 \; h1 x& E
gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
! _2 @0 O, ^. w5 CCopyright (C) 2015 Free Software Foundation, Inc.7 c3 C/ ~& ]! w$ v6 B. V/ E1 ?4 `
This is free software; see the source for copying conditions.  There is NO
- h4 D0 K" g3 M! f/ P* Q6 zwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 z7 Y/ I0 ?/ ?- W; m& b
9 R7 [% [  p2 l/ [+ B8 c. u1 o4 [; Daoems@ubuntu:~/stlink-master$ sudo make install  C- X" f$ B0 l) q* V
...
  G  @3 n9 i$ z3 o8 e( K  h9 T4 |make[2]: Entering directory '/home/aoems/stlink-master'
3 l2 ^$ m& ^# O- Y /bin/mkdir -p '/usr/local/bin'
- Y0 {8 q" H. Z; V! ~# n. }$ r5 y  /usr/bin/install -c st-flash st-util st-term st-info '/usr/local/bin'
  p! r& o8 w; b4 fmake[2]: Nothing to be done for 'install-data-am'.1 |* I- o0 T( {: G/ {5 s
make[2]: Leaving directory '/home/aoems/stlink-master'5 _. ^0 k: |& q/ h2 Y
make[1]: Leaving directory '/home/aoems/stlink-master'
" U% J7 l+ g  R; h' {' U1 a- O: Yaoems@ubuntu:~/stlink-master$
2 C5 J; Q6 V$ a" f  ?. w. A0 t
$ }8 ?* R8 Y( w# @2 h- [安装时,显示没做任何事情,不明白安装是否成功。
ataudio 回答时间:2015-10-29 16:00:44
QianFan 发表于 2015-10-29 15:14
. n6 z2 m) x( h& k% C; V一开始的sudo  sh ./autogen.sh执行了吗?

; `+ |. y0 Z  F5 Z4 t6 S! L已经执行了的。这一步没报错误。---我的ubuntu是14.04 server版。另外我编辑了上一个帖子,吧config.log的内容也附上了。2 c* |1 h: \! m1 C. z1 k
# ^0 |0 I" h, K; T3 ]
7 y, K0 S9 e' T0 A, l
./autogen.sh的运行结果:) V( G  X: S% L6 L! c
abyte@u-server-amd64:~/stlink-master$ ./autogen.sh 7 T5 Q( ]+ t, ^/ g) D4 j* L! k
autoreconf: Entering directory `.'
2 ^5 h& j) Y; o4 ^# l$ ?$ G/ Oautoreconf: configure.ac: not using Gettext
# ~: z: j0 D  |autoreconf: running: aclocal --force . e. a( b& s7 o+ o$ z0 h% b  _( J" T
autoreconf: configure.ac: tracing
1 F( K' e' N5 H3 K5 Kautoreconf: configure.ac: not using Libtool7 X  i/ n+ a- s+ }1 y% k
autoreconf: running: /usr/bin/autoconf --force
, v. B7 z" Z4 x4 R; ?' E" hautoreconf: configure.ac: not using Autoheader
( j  v% S" V5 W8 _; R, nautoreconf: running: automake --add-missing --copy --force-missing0 Y3 B8 F' g& T$ j! D5 a% N) d9 h0 L
autoreconf: Leaving directory `.'
creep 回答时间:2015-10-23 15:36:14
跟着学习下!故意留个沙发吗?
qianfan 回答时间:2015-10-23 16:17:22
creep 发表于 2015-10-23 15:36
3 \, U) `. _# i& K跟着学习下!故意留个沙发吗?

( J8 X9 T1 ^) `8 i4 |: v对啊,专门给橙子哥留的啊
你好我好大家好! 回答时间:2015-10-23 17:44:42
学习学习               
肽宰1 回答时间:2015-10-23 18:13:27
学习学习   
jiaswang 回答时间:2015-10-23 18:26:40
大神总是玩的这么高端……
cxtarm 回答时间:2015-10-24 09:46:31
大神牛人        
Veikoboy 回答时间:2015-10-24 10:00:46
跟着学习一下,正准备转战
jinzhifeng 回答时间:2015-10-24 10:56:46
汗  这么厉害  绝对要顶起吖
二货520 回答时间:2015-10-24 11:54:29
赚金币咯我要开发板
samsamhoo 回答时间:2015-10-24 14:04:15
好资料,谢谢分享。
qianfan 回答时间:2015-10-29 15:14:01
ataudio 发表于 2015-10-29 14:53
, W, c- @9 p6 l, j/ @/ o+ A4 `请教一下:安装stlink,你有没有遇到过下面的情况:1 o5 Z; ]) g6 q1 g% w3 w; r
abyte@u-server-amd64:~/stlink-master$ ./configure 7 R3 c* T. C5 j# I- z# d
...
3 p6 ~. ?- y% O
一开始的sudo  sh ./autogen.sh执行了吗?
qianfan 回答时间:2015-10-29 16:41:17
ataudio 发表于 2015-10-29 16:00, l  z! w" T! G  m
已经执行了的。这一步没报错误。---我的ubuntu是14.04 server版。另外我编辑了上一个帖子,吧config.log ...
2 ]# D* ?+ q, b
你下载的文件没有被改过吧。看这个地方8 @  ^: \# ^* t
configure:3091: gcc -V >&5
! ^/ t# _- l  T4 Q" b* Dgcc: error: unrecognized command line option '-V': R: W+ Q6 a$ \- ^6 e# L8 ~+ o; [; G( f
gcc: fatal error: no input files( B6 w2 K! X' W! L9 T( ?
compilation terminated.
  i" b) W6 k9 i3 U( s! a  [0 I4 d8 r) @9 X+ {8 y
应该是gcc -v才对啊。要不你重新下载一次。在重新编译试试看。不行的话我给你发一份编译好的也行。这个我也是照着github上来的。有问题可以去github上给开发者留言看看。
123下一页
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版