STM32F4适配nuttx

STM32F4适配nuttx

  • 基础准备
  • 下载相关文件
  • 开始配置

基础准备

这次重头再来,按照我之前的博客(NUTTX学习笔记)里面的内容来。
这次使用STM32F407ZET6的处理器,之前F1的板子因为要用stlink下载器有些麻烦,买了一个新板子还有一个Jlink下载器。

下载相关文件

按照博主xiao2yizhizai对源码构建的博客,我们下载好的文件夹应该包含下面的文件:

  1. nuttx
  2. app
  3. tools
  4. buildroot

开始配置

打开nuttx里面的readme文件,在Instantiating “Canned” Configurations会有下面这一段文字

Only a few
steps are required to instantiate a NuttX configuration, but to make the
configuration even easier there are scripts available in the tools/
sub-directory combines those simple steps into one command.
There is one tool for use with any Bash-like shell that does configuration
steps. It is used as follows:
tools/configure.sh < board-name >:< config-dir >

其中,config-dir是在对应单片机的readme文档内有说明,具体有好几种,这里我选用的是

tools/configure.sh 'mikroe-stm32f4:nsh'

此时会出现mconfig没用配置的问题,打开{Topdir}/tools文件夹,打开read文件,在里面
General Build Instructions有安装说明,执行下面:

cd kconfig-frontends
./configure --enable-mconf
make
make install

注意在输入make install的时候会提示一些库无法连接,要使用管理员模式:

sudo make install

然后注意看控制台输出,会提示你这个库的安装路径还有你需要添加路径到系统:

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

这里再按照博文
内的帮助,添加路径,但是这样做执行上一步配置单片机的时候还是会出现:

kconfig-conf: error while loading shared libraries: libkconfig-parser-4.11.0.so: cannot open shared object file: No such file or directory
make: *** [do_olddefconfig] Error 127

这里再执行

sudo ldconfig

这样似乎就可以解决。

这样给系统选板子就完成了。运行

make qconfig

出现图形界面
STM32F4适配nuttx_第1张图片
这样完成了基本的搭建,下面就是要编译。make一下就好

breeze@breeze-Inspiron-5559:~/nuttx/nuttx-8.1$ make

出现一大段代码,直到最终出现

AR:   stm32_boot.o stm32_spi.o stm32_clockconfig.o stm32_appinit.o
make[2]: Leaving directory '/home/breeze/nuttx/nuttx-8.1/boards/arm/stm32/mikroe-stm32f4/src'
LD: nuttx
make[1]: Leaving directory '/home/breeze/nuttx/nuttx-8.1/arch/arm/src'
CP: nuttx.hex
CP: nuttx.bin

说明已经生成了相应的bin和hex文件。最后查看一下文件列表:

breeze@breeze-Inspiron-5559:~/nuttx/nuttx-8.1$ ls
arch    boards     crypto         fs        Kconfig    Makefile  nuttx      pass1         sched    System.map  video
audio   ChangeLog  Documentation  graphics  libs       mm        nuttx.bin  README.txt    staging  TODO        wireless
binfmt  COPYING    drivers        include   Make.defs  net       nuttx.hex  ReleaseNotes  syscall  tools

说明编译应该是没什么问题。

下一步就是要看具体怎么配置,还有就是代码下载和app编写。代码下载要用Jlink下载,驱动安装可以参考我这篇博客:Ubuntu下Jlink驱动安装使用。

你可能感兴趣的:(nuttx,STM32)