记事本用习惯了,论坛写帖子的时候动不动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的安装
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.