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

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

[复制链接]
qianfan 发布时间:2015-10-23 15:17
本帖最后由 QianFan 于 2015-10-27 19:54 编辑

    记事本用习惯了,论坛写帖子的时候动不动Ctrl+S一下。。。

    在Ubuntu下开发STM32,两个常用软件是必须的。一是我们的交叉编译器,arm-none-eabi-xxx。二是st-link的驱动。这里的st-link并不像我们windows下面用的那样,一路点Next就好了。这里我们需要从github上面下载源码,自己编译,安装。st-link不仅仅是我们下载代码的工具,更是我们使用gdb调试的基础。

linux对USB虚拟串口的支持:
    linux下自带虚拟串口的驱动。不需要手动安装。linux对串口的命名不同于windows。像CP2102之类的USB转串口,是ttyUSBx,虚拟串口之类的是ttyACMx。我们先来找一下串口的编号。所有的设备都在/dev目录下。那么插Nucleo前后/dev中的新增项就是Nucleo的串口。
  • 在未插Nucleo之前,保存所有的设备名字到before.txt---->ls /dev >before.txt
  • 在插上Nucleo之后,保存所有的设备名字到after.txt------>ls /dev >after.txt
  • 使用diff查看改动--->diff before.txt after.txt
  • 看到新增项,ttyACM0就是我们Nucleo的串口编号。

常用的串口软件:
    在linux下工作,串口软件我更喜欢minicom。他小巧,使用控制台窗口。有多种模式可以选择。当然,putty也是一个不错的选择。
  • 安装minicom: sudo apt-get install minicom
  • 或者安装putty:   sudo apt-get install putty
  • 安装完minicom之后,需要简单的配置一下。比如串口号,波特率,通信协议等等。可以使用sudo minicom -s 进行配置。

st-link的安装:
    在github上有st-link在linux下的源代码。为了操作简便,还是在使用st-link之前将它升级为v2。
  • 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。

arm-none-eabi-xxx的安装:http://launchpad.net/~terry.guo/+archive/ubuntu/gcc-arm-embedded
     arm-none-eabi-xxx不仅仅包含gcc,g++,而是一整套完整的工具链。像CoIDE,RIDE,TrueStudio这些都是使用它作为编译工具的。只不过在命令行的基础上,套上了一个Eclipse的壳子罢了。
  • Step1: Inside Ubuntu, open a terminal and input
           "sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded"
  • Step2: Continue to input
           "sudo apt-get update"
  • Step3: Continue to input to install toolchain
           "sudo apt-get install gcc-arm-none-eabi"
  • To remove installed toolchain, just input "sudo apt-get remove gcc-arm-none-eabi".


  • To update the toolchain, just repeat above step2 and step3.





收藏 7 评论33 发布时间:2015-10-23 15:17

举报

33个回答
ataudio 回答时间:2015-10-29 14:53:52
本帖最后由 ataudio 于 2015-10-29 15:56 编辑

请教一下:安装stlink,你有没有遇到过下面的情况:
abyte@u-server-amd64:~/stlink-master$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... no
checking whether make supports nested variables... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/abyte/stlink-master':
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
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

  $ ./configure

## --------- ##
## Platform. ##
## --------- ##
....
...
...
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
configure:3102: $? = 0
configure:3091: gcc -V >&5
gcc: error: unrecognized command line option '-V'
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
compilation terminated.
configure:3102: $? = 4

configure:3122: checking whether the C compiler works
configure:3144: gcc    conftest.c  >&5
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
configure:3148: $? = 1
configure:3186: result: no
configure: failed program was:

...
...

ataudio 回答时间:2015-11-3 10:42:53
换成ubuntu 15.10桌面版,gcc版本是5.2,编译stlink成功。
checking for sys/mman.h... yes
checking sys/poll.h usability... yes
checking sys/poll.h presence... yes
checking for sys/poll.h... yes
checking for mmap... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for USB... yes
checking for usb_path2devnum in -lusbpath... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
aoems@ubuntu:~/stlink-master$ gcc --version
gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

aoems@ubuntu:~/stlink-master$ sudo make install
...
make[2]: Entering directory '/home/aoems/stlink-master'
/bin/mkdir -p '/usr/local/bin'
  /usr/bin/install -c st-flash st-util st-term st-info '/usr/local/bin'
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/aoems/stlink-master'
make[1]: Leaving directory '/home/aoems/stlink-master'
aoems@ubuntu:~/stlink-master$

安装时,显示没做任何事情,不明白安装是否成功。
ataudio 回答时间:2015-10-29 16:00:44
QianFan 发表于 2015-10-29 15:14
一开始的sudo  sh ./autogen.sh执行了吗?

已经执行了的。这一步没报错误。---我的ubuntu是14.04 server版。另外我编辑了上一个帖子,吧config.log的内容也附上了。


./autogen.sh的运行结果:
abyte@u-server-amd64:~/stlink-master$ ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
autoreconf: configure.ac: not using Autoheader
autoreconf: running: automake --add-missing --copy --force-missing
autoreconf: Leaving directory `.'
creep 回答时间:2015-10-23 15:36:14
跟着学习下!故意留个沙发吗?
qianfan 回答时间:2015-10-23 16:17:22
creep 发表于 2015-10-23 15:36
跟着学习下!故意留个沙发吗?

对啊,专门给橙子哥留的啊
你好我好大家好! 回答时间: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
请教一下:安装stlink,你有没有遇到过下面的情况:
abyte@u-server-amd64:~/stlink-master$ ./configure
...

一开始的sudo  sh ./autogen.sh执行了吗?
qianfan 回答时间:2015-10-29 16:41:17
ataudio 发表于 2015-10-29 16:00
已经执行了的。这一步没报错误。---我的ubuntu是14.04 server版。另外我编辑了上一个帖子,吧config.log ...

你下载的文件没有被改过吧。看这个地方
configure:3091: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.

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

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版