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

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

[复制链接]
qianfan 发布时间:2015-10-23 15:17
本帖最后由 QianFan 于 2015-10-27 19:54 编辑 ' _% C$ {6 k2 U* q
; `8 t& e7 Y% V, V6 L" F1 V
    记事本用习惯了,论坛写帖子的时候动不动Ctrl+S一下。。。
9 \" P: r6 _4 ^! P" c
7 e" t6 N( L, h- U: x8 r4 j5 ]; k    在Ubuntu下开发STM32,两个常用软件是必须的。一是我们的交叉编译器,arm-none-eabi-xxx。二是st-link的驱动。这里的st-link并不像我们windows下面用的那样,一路点Next就好了。这里我们需要从github上面下载源码,自己编译,安装。st-link不仅仅是我们下载代码的工具,更是我们使用gdb调试的基础。# d8 T* S  m" L( e
  ?6 n* D6 Y5 Q: o; z4 T% q8 s6 i% O" c3 L
linux对USB虚拟串口的支持:5 C# H( N& r# L* j: Z
    linux下自带虚拟串口的驱动。不需要手动安装。linux对串口的命名不同于windows。像CP2102之类的USB转串口,是ttyUSBx,虚拟串口之类的是ttyACMx。我们先来找一下串口的编号。所有的设备都在/dev目录下。那么插Nucleo前后/dev中的新增项就是Nucleo的串口。  K1 l# [$ d% _& m6 T" ?7 {% A
  • 在未插Nucleo之前,保存所有的设备名字到before.txt---->ls /dev >before.txt
  • 在插上Nucleo之后,保存所有的设备名字到after.txt------>ls /dev >after.txt
  • 使用diff查看改动--->diff before.txt after.txt
  • 看到新增项,ttyACM0就是我们Nucleo的串口编号。6 }& r8 ?3 s% W! T

/ \( S4 o# j% B# d0 p7 u常用的串口软件:
- I! _8 q6 ]6 H0 F    在linux下工作,串口软件我更喜欢minicom。他小巧,使用控制台窗口。有多种模式可以选择。当然,putty也是一个不错的选择。
1 P/ g4 `8 f  b* J  q
  • 安装minicom: sudo apt-get install minicom
  • 或者安装putty:   sudo apt-get install putty
  • 安装完minicom之后,需要简单的配置一下。比如串口号,波特率,通信协议等等。可以使用sudo minicom -s 进行配置。
    " s% N% U2 ?/ \9 L. M! a
" D5 E+ z- x* B
st-link的安装:
: [( B" Z% v3 J5 @0 y7 U    在github上有st-link在linux下的源代码。为了操作简便,还是在使用st-link之前将它升级为v2。8 D9 C$ V0 y9 H. T2 F7 {( y
  • 在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。
    / Z% n' T$ C+ J. H( ~
4 }4 \- V6 N$ {
arm-none-eabi-xxx的安装:http://launchpad.net/~terry.guo/+archive/ubuntu/gcc-arm-embedded
- p5 \) |# M. d+ w/ d+ P8 j     arm-none-eabi-xxx不仅仅包含gcc,g++,而是一整套完整的工具链。像CoIDE,RIDE,TrueStudio这些都是使用它作为编译工具的。只不过在命令行的基础上,套上了一个Eclipse的壳子罢了。3 k9 W) y: _+ P  b' e. A: A
  • Step1: Inside Ubuntu, open a terminal and input
    . Y) ~) V7 T: m3 j- G) l; {       "sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded"
  • Step2: Continue to input
           "sudo apt-get update"/ r( H, S. ~7 c- `0 V
  • Step3: Continue to input to install toolchain
    + [$ Z9 V# a0 D$ Z$ _' c2 ~, I/ w       "sudo apt-get install gcc-arm-none-eabi"
    & \. \) G) k- p: R3 I  P
  • To remove installed toolchain, just input "sudo apt-get remove gcc-arm-none-eabi".
    ' D! d8 [$ k! O. m9 z8 {4 D' I+ z1 q$ g2 {$ e

      b8 L* c& r# W3 J3 E
  • To update the toolchain, just repeat above step2 and step3.
    - |  x+ N, N4 w: D
    2 x1 E. e5 g5 _5 x' E9 t- `, i  u. s1 ?
+ s& ^0 P% ~/ Q/ v! ?% i) T: B

6 u: t( g8 ]6 {0 K2 f+ p# ^1 X) L5 q
4 V8 D$ I- N6 L# t) j
赞 收藏 7 评论33 发布时间:2015-10-23 15:17

举报

33个回答
ataudio 回答时间:2015-10-29 14:53:52
本帖最后由 ataudio 于 2015-10-29 15:56 编辑 , U  c% _9 K/ F( R8 _" i7 e" S
6 W0 @9 U7 [( h4 J6 L" l! h
请教一下:安装stlink,你有没有遇到过下面的情况:
7 j! q% j) W! w# ^  U' sabyte@u-server-amd64:~/stlink-master$ ./configure
* `4 G( S" T0 j4 A4 ochecking for a BSD-compatible install... /usr/bin/install -c5 k' j8 ^% u" R1 M# W
checking whether build environment is sane... yes% I- S1 c. G" G% \, r' r) O
checking for a thread-safe mkdir -p... /bin/mkdir -p
" F* A/ Y' o: j) `2 gchecking for gawk... gawk
% X# l! D+ ^" ~8 v" uchecking whether make sets $(MAKE)... no
* s% H. T2 X$ U! o. g; Cchecking whether make supports nested variables... no' I* u( H! W) h( Z! C5 r
checking for gcc... gcc
0 N/ A5 F6 Y$ Y& c% v& hchecking whether the C compiler works... no
/ C5 B& m' N( D% F; sconfigure: error: in `/home/abyte/stlink-master':
: O; z' R# c* T; C8 F9 A) h, n& {* Aconfigure: error: C compiler cannot create executables
% h" v6 s  G9 p9 v( z/ U) i/ XSee `config.log' for more details

9 D8 e  \' @: k1 Tabyte@u-server-amd64:~/stlink-master$more config.log This file contains any messages produced by compilers while5 E2 c5 |4 k% p% H" ?! N; @: C' x6 |
running configure, to aid debugging if configure makes a mistake.
2 c: |. a  r: {8 j+ K6 O3 `( f8 G  H
$ E7 e8 S6 w, F0 u2 fIt was created by stlink configure 0.5.6, which was3 Q5 h8 H# H* p9 S) \9 c
generated by GNU Autoconf 2.69.  Invocation command line was
% U+ w" N7 B( L) e* b0 W; {
$ z6 f& a) N7 g! V. |( s  $ ./configure
- ?( y: v6 O  _$ w5 r, F7 Z
7 E2 [* A$ S& f  h& F## --------- ##  J( \% ^! R% G0 e" m( F  J
## Platform. ### }/ r/ B! Y2 [7 t( Z9 D! z
## --------- ##
/ o2 j; O% A6 o5 F" D5 e4 U+ k( _....+ q1 U8 J7 @, E
...
( j0 F! u8 f/ {* J: L! w3 W3 C, b...
0 H) W& }) `  E( x1 b! hgcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
& J* ^, G; K- Y: gconfigure:3102: $? = 0
# T8 T( }' ?. t7 n6 U8 aconfigure:3091: gcc -V >&5! j  E( q# q& o+ [0 Z
gcc: error: unrecognized command line option '-V') X) F8 |7 N4 P$ c) I" \3 O
gcc: fatal error: no input files" n; T9 v) }9 m3 ^; `
compilation terminated.6 D) Z% t8 W! I. o5 N/ j& g3 X0 K9 ~
configure:3102: $? = 4' Q2 A1 m# k% G9 ]! V+ V: @' j. A
configure:3091: gcc -qversion >&5" [& |9 w/ c4 K
gcc: error: unrecognized command line option '-qversion'0 @; o' E( S, n- z
gcc: fatal error: no input files
  _8 ^: W* C3 `% J, d0 P  Qcompilation terminated.: q. t6 `% Y0 r9 `" t& D
configure:3102: $? = 44 @: J# d" e4 o8 L) a' F6 m$ g

4 Y; W$ {4 \+ F/ w; S6 a8 \configure:3122: checking whether the C compiler works- q$ W+ \/ q$ I9 W
configure:3144: gcc    conftest.c  >&5
- p7 s; g6 a7 t+ x6 I/usr/bin/ld: cannot find crt1.o: No such file or directory
& ]. E1 J. b9 ]% d+ V# C, V% Y/usr/bin/ld: cannot find crti.o: No such file or directory' j1 X: j! R" Q9 y/ X8 W
/usr/bin/ld: cannot find -lc
' `, U' n1 S. U) U& |/usr/bin/ld: cannot find crtn.o: No such file or directory( @( X8 M' v4 F" r/ @: |
collect2: error: ld returned 1 exit status" R& G1 t! ^3 [# r3 p* t' x3 c5 R
configure:3148: $? = 1
! ]; B; ?2 T8 C$ Wconfigure:3186: result: no
/ S  j, |: {" J( j1 Econfigure: failed program was:
+ Y5 X$ L# K7 ]" J0 t) y3 U. Q7 }& K. \& Q6 t. I; z  d8 b
...
  V1 S. y9 \- Q4 Y& j...
: X- m5 U( ~: u3 w/ b% b* b9 l8 G  v1 U' |5 I; W) F/ S' D
ataudio 回答时间:2015-11-3 10:42:53
换成ubuntu 15.10桌面版,gcc版本是5.2,编译stlink成功。
; J5 F" l: X% Z3 z- Y9 o% tchecking for sys/mman.h... yes1 j# c4 f' a; n% [8 F7 u6 }
checking sys/poll.h usability... yes/ l! o' j! f( K/ Q. b3 e7 o  q
checking sys/poll.h presence... yes
' o+ }( C! b0 q+ L" Dchecking for sys/poll.h... yes3 T+ b  U3 K1 T& T  g+ M. T
checking for mmap... yes& D3 ^4 _# {; D* Q
checking for pkg-config... /usr/bin/pkg-config
, O' F% y: a  S0 gchecking pkg-config is at least version 0.9.0... yes
$ G& R& H3 p  Fchecking for USB... yes7 L, A* P, I& J+ j2 W! P3 }
checking for usb_path2devnum in -lusbpath... no, V4 _& U/ N, `" k( I) w
checking that generated files are newer than configure... done: d9 ?4 s4 `& Z3 H* [- F
configure: creating ./config.status
. v' R/ ~- O( O& t5 z7 c6 kconfig.status: creating Makefile
+ N+ L8 n1 b6 n! S$ }: `+ Yconfig.status: executing depfiles commands, j$ m5 t) k( W2 u, i2 f% D! O( F
aoems@ubuntu:~/stlink-master$ gcc --version
0 d; [# V9 K$ d7 A. R0 H' c; Egcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
1 _2 n3 _% [! q  a8 k. [Copyright (C) 2015 Free Software Foundation, Inc.) F  N0 E) B0 D" l- }' I  }% w
This is free software; see the source for copying conditions.  There is NO5 G# A& \. z! t
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.* H+ f: B! Y4 u! |) e$ h+ X
+ r8 `1 o0 d2 T+ d7 l9 u
aoems@ubuntu:~/stlink-master$ sudo make install; Y  Q5 j+ c" \% Q! L6 m  ^- v
...
( E6 F: T2 l0 s+ Y, [1 l0 u2 k% `make[2]: Entering directory '/home/aoems/stlink-master'
$ c' d3 n1 p; ?( R /bin/mkdir -p '/usr/local/bin'$ X. \& p/ G, t
  /usr/bin/install -c st-flash st-util st-term st-info '/usr/local/bin'6 G  k# |5 E0 y3 M( y" X$ z+ C
make[2]: Nothing to be done for 'install-data-am'.
7 M# H" w3 a$ J2 ymake[2]: Leaving directory '/home/aoems/stlink-master'
: q- g8 V% w: cmake[1]: Leaving directory '/home/aoems/stlink-master'0 H6 s3 n9 t- C
aoems@ubuntu:~/stlink-master$" ~' p1 l* E0 r# T

% z3 w5 L) T3 i$ [& q. v2 U- G! ]$ B安装时,显示没做任何事情,不明白安装是否成功。
ataudio 回答时间:2015-10-29 16:00:44
QianFan 发表于 2015-10-29 15:14
0 ]- \! x0 j0 ]- e一开始的sudo  sh ./autogen.sh执行了吗?
7 ^4 l! _5 ]) y$ p1 M- j8 j" M
已经执行了的。这一步没报错误。---我的ubuntu是14.04 server版。另外我编辑了上一个帖子,吧config.log的内容也附上了。3 c* v5 M5 A" V! b. }

9 N/ W. U' X# e/ r; t+ \2 Q3 P6 y
' n+ q1 I$ \( D" o8 @./autogen.sh的运行结果:
! E! I1 e2 g$ H/ u+ P3 Y; x: K# Sabyte@u-server-amd64:~/stlink-master$ ./autogen.sh * s8 d- J9 G" L3 j/ b
autoreconf: Entering directory `.'! _& e8 a9 Q' o& n- p! S
autoreconf: configure.ac: not using Gettext
( K9 {' ]% e- S0 `! V) [autoreconf: running: aclocal --force
# X' H' V# F3 e2 s: C6 \autoreconf: configure.ac: tracing
$ `# E6 V3 H, F/ f' Tautoreconf: configure.ac: not using Libtool* {1 l" c. H" b+ m) Y8 _
autoreconf: running: /usr/bin/autoconf --force/ G/ ^" N6 u- J! N, ^. k4 U
autoreconf: configure.ac: not using Autoheader
9 T( V! c6 n+ V7 X% Sautoreconf: running: automake --add-missing --copy --force-missing
: s! |- J4 E) R& D$ Nautoreconf: Leaving directory `.'
creep 回答时间:2015-10-23 15:36:14
跟着学习下!故意留个沙发吗?
qianfan 回答时间:2015-10-23 16:17:22
creep 发表于 2015-10-23 15:36+ J7 i" W! t3 n# _* I, s2 \
跟着学习下!故意留个沙发吗?
* l4 ?- z' i8 ?0 F- U7 Q5 n
对啊,专门给橙子哥留的啊
你好我好大家好! 回答时间: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
# N( X2 r; L/ |, n3 k/ ?8 Z5 U1 P请教一下:安装stlink,你有没有遇到过下面的情况:# Y7 b/ e) ?. o4 l; r
abyte@u-server-amd64:~/stlink-master$ ./configure , L1 G1 B+ I4 h
...

' ]& x; ], l5 I7 ]: l2 a) B一开始的sudo  sh ./autogen.sh执行了吗?
qianfan 回答时间:2015-10-29 16:41:17
ataudio 发表于 2015-10-29 16:00
  h- _; t* c" i/ T已经执行了的。这一步没报错误。---我的ubuntu是14.04 server版。另外我编辑了上一个帖子,吧config.log ...
% A3 P- }3 b& l- r* o
你下载的文件没有被改过吧。看这个地方
8 v% o: C7 C% {configure:3091: gcc -V >&5
7 z$ [, t7 M& u6 q. l9 {gcc: error: unrecognized command line option '-V'; I7 E: E8 G2 z" f
gcc: fatal error: no input files
6 X3 T9 w& k; ~; u, _compilation terminated.
, [" L8 w; k  A7 _# R/ l) [% p$ E3 V9 M. p. y. s  p! i9 O
应该是gcc -v才对啊。要不你重新下载一次。在重新编译试试看。不行的话我给你发一份编译好的也行。这个我也是照着github上来的。有问题可以去github上给开发者留言看看。
123下一页

所属标签

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