Nuttx开发初探-编译篇

各类系统搞了这么多年,感觉关于OS的各类底层机制已经摸透了,直到两年前遇到Nuttx,大致浏览了目录结构和源码readme后,感觉Nuttx应该是一个不错的系统,有瓜可挖。 只是一直忙于项目,没有时间深入研究。 直到翻出之前参加某活动获赠的FRDM-K64F开发板在那静静吃灰,有了想动一动的冲动。

废话不多说,下面直入主题写步骤,会比较干,喜欢文艺范的绕行.

主机配置:ubuntu14.04.4 LTS

 编译器:

sudo apt-get install gcc-arm-none-eabi
sudo apt-get install flex libncurses5-dev 
sudo apt-get install gperf

step 1:下载源码:

  创建工作目录nuttx

   mkdir nuttx && cd nuttx

  下载nuttx内核源码:

git clone https://bitbucket.org/nuttx/nuttx.git nuttx

  下载nuttx应用源码:

git clone https://bitbucket.org/nuttx/apps.git apps

   下载nuttx编译配置工具:  

git clone https://bitbucket.org/nuttx/tools.git tools

step 2:安装依赖包: 

    不墨迹,不管你之前装没装,autoconf和automake升级到最新版, 我用的是 autoconf-2.69 和 automake-1.15

不排除你的环境还会遇到没安装的依赖包,没关系,兵来将挡,水来土掩,找最新版的安装就是了。

step3:工具编译

 nuttx使用类似于Linux的menuconfig和qconfig配置方式,需要kconfig工具的支持,这里进行这一步

 进入到./tools/kconfig-frontends目录

./configure --enable-mconf 

结束后:

 

nuttx还支持qconfig配置,使能选项是--enable-qconf, 不过我嫌安装QT5过于麻烦,没有选择。

接着执行make && sudo make install编译安装

step3:内核&&应用编译

   进入到./nuttx/tools目录, 执行./configure.sh freedom-k64f:nsh

    一开始的时候,我遇到找不到libkconfig-parser-4.11.0.so的问题,实际上这个库文件在上一步的编译过程中已经生成了,并且安装成功了,我没有细究原因,直接通过用LD_LIBRARY_PATH暴露库路径的方式解决。

libkconfig-parser-4.11.0.so:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:xxxxxxxxx/nuttx/tools/kconfig-frontends/libs/parser/.libs

接着进入主目录先执行 make distclean(可能上一步虽然没执行成功但生成了临时文件,需要清理)

再次执行上述命令./configure.sh freedom-k64f:nsh,成功执行

关于app目录的放置和应用配置,可以参考app下的 readme文件。

 35 If all of the above conditions are TRUE, then NuttX will be able to
 36 find the application directory.  If your application directory has a
 37 different name or is location at a different position, then you will
 38 have to inform the NuttX build system of that location.  There are several
 39 ways to do that:                           
 40                                            
 41 1) You can define CONFIG_APPS_DIR to be the full path to your application
 42    directory in the NuttX configuration file.
 43 2) You can provide the path to the application directory on the command line
 44    like:  make APPDIR=<path> or make CONFIG_APPS_DIR=<path>
 45 3) When you configure NuttX using tools/configure.sh, you can provide that
 46    path to the application directory on the configuration command line
 47    like: ./configure.sh -a <app-dir> <board-name>:<config-name>
 

默认情况下,最终编译结果只有.hex和.srec文件,没有elf的binary输出,需要手动打开。

进入到nuttx主目录,执行make menuconfig,进入到相关项选择raw binary format.

关闭配置菜单,执行 make,编译内核和app.

step4:烧录nuttx.bin

 frdm-k64f自带板载调试器st-link,支持工具烧录和虚拟磁盘烧录,这里使用虚拟磁盘烧录的方式.

nuttx.bin是nuttx elf文件的Binary转制版,可以通过objcopy -O binary生成,拷贝 nuttx.bin到frdm-k64f挂载后的磁盘目录。

拷贝完毕,系统会自动重启,进入到nsh主shell.

使用minicom工具链接串口节点:

  sudo minicom -D /dev/ttyACM0

可以看到shell控制台

结束

  • 8
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

papaofdoudou

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值