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

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

[复制链接]
qianfan 发布时间:2015-10-23 15:17
本帖最后由 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 ]
  • Step1: Inside Ubuntu, open a terminal and input
    * @3 X, H3 ~4 ^" H       "sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded"
  • Step2: Continue to input
           "sudo apt-get update"* A5 r; i7 |, ~  Y
  • Step3: Continue to input to install toolchain
    , m0 F1 p: V$ l       "sudo apt-get install gcc-arm-none-eabi"
    / o" E* r, G) g8 B) n$ i- x" f# A
  • To remove installed toolchain, just input "sudo apt-get remove gcc-arm-none-eabi".
    - N9 ?  v# }, M8 O9 j: H3 ^
    ! [- m6 k# V$ N- D
    : x8 Q$ L5 T" L+ I* O) W- \
  • To update the toolchain, just repeat above step2 and step3.- i! K! Z8 X+ a4 P
    , `3 U5 d( |: P% P' a

' 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
赞 收藏 7 评论33 发布时间:2015-10-23 15:17

举报

33个回答
ataudio 回答时间:2015-10-29 14:53:52
本帖最后由 ataudio 于 2015-10-29 15:56 编辑
- \; A1 V0 G) F* G! 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
: d% z( ?0 ~% S( Lchecking for gawk... gawk
5 ?9 |' E) e# [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
5 D8 ]* [3 r9 M! I$ Ochecking whether the C compiler works... no
' y/ T% [" A& `3 M- W# Mconfigure: error: in `/home/abyte/stlink-master':* i: ~3 m. K" K5 u9 g. P- a0 ]6 L
configure: error: C compiler cannot create executables
, p4 Q. q4 k) @! d6 M6 C' o9 {See `config.log' for more details

; M8 U/ ]  E4 b2 N5 ]1 A$ ?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.
, q+ H+ l9 A# z, S
" X9 g1 J/ d; [5 N2 A$ BIt was created by stlink configure 0.5.6, which was
+ I! M% s0 |5 p* e" j' Cgenerated by GNU Autoconf 2.69.  Invocation command line was
2 a1 G" X; u1 M  e$ {3 O: |( ^0 X
  $ ./configure " w# R5 J) o# X9 _, V1 B

' B2 v2 V3 K1 z6 A' p## --------- ##
7 N2 p+ @( G9 \& w) a## Platform. ##% b9 N# |, J$ _7 c( ?: h
## --------- ##
+ k, W  }4 n! f2 g& ~1 x% P7 l+ R$ ^....
9 E" G$ @* p0 A- Z5 k5 u. g) B; F! ?' r...
% v# D2 Q+ E; M1 a/ g8 \...+ 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
$ {3 e1 j: t+ [0 {2 c3 L! ?3 t6 Vcompilation terminated.
$ I/ E& u+ e$ _3 Z4 h8 Bconfigure:3102: $? = 4
( }8 i5 Q: D9 K7 A$ F  oconfigure:3091: gcc -qversion >&5
! H# v# h- Y- I9 R+ Hgcc: error: unrecognized command line option '-qversion'
# m  k* J& ~# U+ ^$ a9 @, rgcc: 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
4 A/ q& _- k* y* W$ ?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
  Q. ?& N4 ^$ M( wcollect2: error: ld returned 1 exit status5 v9 m2 U  w' s, g, n$ w3 j
configure:3148: $? = 1
: y5 p  ^3 t, T% [; W5 wconfigure:3186: result: no# Z; I8 ^$ w$ M- T. x
configure: failed program was:( H, j6 G. L8 |6 [

: m& X: [& o' @...2 x# X7 {5 ^5 R- |3 u8 P
...* f$ O5 U! d* Z  {2 M2 \6 u

" S. U( C6 n$ v( [- B+ }
ataudio 回答时间:2015-11-3 10:42:53
换成ubuntu 15.10桌面版,gcc版本是5.2,编译stlink成功。6 P8 h) k( E) ~: k! J6 }
checking for sys/mman.h... yes
7 m# ~6 I% L6 g+ n- b1 Echecking 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
0 m" q' I+ Q! w7 }! T& {checking for pkg-config... /usr/bin/pkg-config
  w; C+ l; V5 A  X9 rchecking 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
! V& I3 r/ U# e, e) f! Xconfigure: creating ./config.status
/ ^2 e, o( y' D( oconfig.status: creating Makefile! V) K- J- \' w4 ?. T( Q
config.status: executing depfiles commands
3 _1 \% n' t; Zaoems@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.
5 U0 F$ R6 X4 P8 b2 zThis 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.
$ c& }; {; T$ D8 K) i8 ]$ I: l! [! Y7 V. s: |/ C
aoems@ubuntu:~/stlink-master$ sudo make install
5 |8 i( c- v4 y% I; O2 e...: 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'
# N0 X2 S3 t1 F; B9 `2 c  /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'.
) |. O0 |; f0 r- @" T+ I# jmake[2]: Leaving directory '/home/aoems/stlink-master'& c' c7 Z$ V# L. G# ~/ W* f
make[1]: Leaving directory '/home/aoems/stlink-master'
9 j' b9 x. P: K% p. B+ T; l/ ^aoems@ubuntu:~/stlink-master$/ @5 p2 w' V+ U/ I% y9 y2 o  h1 E# |

2 v& g% d  m/ m) Q+ s0 |2 E+ X. A安装时,显示没做任何事情,不明白安装是否成功。
ataudio 回答时间:2015-10-29 16:00:44
QianFan 发表于 2015-10-29 15:14. l- ^/ `: l' T) _1 P5 i* ^3 s
一开始的sudo  sh ./autogen.sh执行了吗?
& y4 h" j9 a& ]! ~4 @
已经执行了的。这一步没报错误。---我的ubuntu是14.04 server版。另外我编辑了上一个帖子,吧config.log的内容也附上了。6 N6 P# \" w! e# P" b( t/ W

1 W% A% x; N6 i& J: B
+ w0 @, ?) H+ B; E2 f8 |./autogen.sh的运行结果:& @0 B. ]2 x5 c# H0 n# Q  v
abyte@u-server-amd64:~/stlink-master$ ./autogen.sh
. c; B9 _& V" m: i- ~/ qautoreconf: Entering directory `.'
: ^. \  k1 j& ]  I, Yautoreconf: configure.ac: not using Gettext- @# F3 s, o7 Q
autoreconf: running: aclocal --force
4 E3 ~* r0 F6 B7 l2 U  Eautoreconf: configure.ac: tracing
+ o8 ?. w' w6 f6 k! {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 `.'
creep 回答时间:2015-10-23 15:36:14
跟着学习下!故意留个沙发吗?
qianfan 回答时间:2015-10-23 16:17:22
creep 发表于 2015-10-23 15:36
  G; ^' g& E# O' w跟着学习下!故意留个沙发吗?
& o! J3 X* t5 M# V9 y
对啊,专门给橙子哥留的啊
你好我好大家好! 回答时间: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
, U: b! f$ }3 G请教一下:安装stlink,你有没有遇到过下面的情况:
, ?0 N- }& s. `. Q8 wabyte@u-server-amd64:~/stlink-master$ ./configure 9 Z& c2 \' j$ h! P
...
7 t, F. V1 b. p; |
一开始的sudo  sh ./autogen.sh执行了吗?
qianfan 回答时间:2015-10-29 16:41:17
ataudio 发表于 2015-10-29 16:00
% l: O/ S: t; X0 j+ }已经执行了的。这一步没报错误。---我的ubuntu是14.04 server版。另外我编辑了上一个帖子,吧config.log ...

6 G0 ~" d+ w- ?' L你下载的文件没有被改过吧。看这个地方
# t& s3 l3 u% G4 `& {8 uconfigure: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

( n  j% Z+ }- ^( b应该是gcc -v才对啊。要不你重新下载一次。在重新编译试试看。不行的话我给你发一份编译好的也行。这个我也是照着github上来的。有问题可以去github上给开发者留言看看。
123下一页

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版