美文网首页
NuttX学习2

NuttX学习2

作者: 吃肉的马 | 来源:发表于2020-02-09 17:15 被阅读0次

第一个APP

配置与编译

在nuttx中的tool路径下

./configure.sh stm32f4stm32f4discovery/nsh #这个配置看个人情况
cd ..
make

编写Make.defs、Kconfig、Makefile文件

在apps/README.txt中有明确以上三个文件主要的格式

Example Built-In Application

An example application skeleton can be found under the examples/hello
sub-directory. This example shows how a builtin application can be added
to the project. One must:

  1. Create sub-directory as: progname
  2. In this directory there should be:
  • A Make.defs file that would be included by the apps/Makefile
  • A Kconfig file that would be used by the configuration tool (see the file kconfig-language.txt in the NuttX tools repository). This Kconfig file should be included by the apps/Kconfig file
  • A Makefile, and
  • The application source code.
  1. The application source code should provide the entry point:
    main()
  2. Set the requirements in the file: Makefile, specially the lines:
    PROGNAME = progname
    PRIORITY = SCHED_PRIORITY_DEFAULT
    STACKSIZE = 768
    ASRCS = asm source file list as a.asm b.asm ...
    CSRCS = C source file list as foo1.c foo2.c ..
  3. The Make.defs file should include a line like:
    ifneq ($(CONFIG_PROGNAME),)
    CONFIGURED_APPS += progname
    endif

注:Kconfig的语法可能需要同学去找tools/kconfig-language.txt看看

举例

我在自己的电脑上新建了一个app,其路径为apps/examples/test_20200206,并新建Make.defs、Kconfig、Makefile、hello_test.c、hello_test.h。
Make.defs内容为:

ifneq ($(CONFIG_EXAMPLES_TEST_20200206),)
CONFIGURED_APPS += $(APPDIR)/examples/test_20200206
endif

Kconfig内容为:

config EXAMPLES_TEST_20200206
        bool "test_program"
        default n
        ---help---
                Enable the test example, written by WL

Makefile内容为:

-include $(TOPDIR)/Make.defs#不可删除

PROGNAME  = test_20200206
PRIORITY  = SCHED_PRIORITY_DEFAULT
STACKSIZE = 748
ASRCS = 
CSRCS = hello_test.c

include $(APPDIR)/Application.mk#不可删除

hello_test.c内容为:

#include <nuttx/config.h>
#include <stdio.h>
int test_20200206_main(int argc, FAR char * argv[])
{
    printf("first nuttx program!\n");
    return 0;
}

进入nuttx目录下:

make menuconfig
配置界面

选择Application Configuration中的Examples下新增的App,保存退出后,直接编译,生成nuttx,运行nuttx,需要输入用户名和密码,均为默认值,username=admin password=Administrator。在nsh中运行刚刚加入的app。

nsh> test_20200206
first nuttx program!
Segmentation fault: 11

注意:出现了个段错误,直觉stack size可能比较小,我就把Makefile中的stack size=748改为2048,再次运行没有任何错误。

参考材料

1、Godenfreemans的《NuttX的学习笔记

2、nuttx/Document;
3、nuttx/README.txt;
4、tools/kconfig-language.txt

相关文章

  • NuttX学习2

    第一个APP 配置与编译 在nuttx中的tool路径下 编写Make.defs、Kconfig、Makefile...

  • NuttX学习1

    下载NuttX源码 1、先建立一个NuttX文件夹 2、将nuttx、apps、tools clone至NuttX...

  • Nuttx信号量机制

    Nuttx相关的历史文章:Nuttx Task ScheduleNuttx信号机制Nuttx编译系统Nuttx消息...

  • Nuttx工作队列机制

    Nuttx相关的历史文章:Nuttx Task ScheduleNuttx信号机制Nuttx编译系统Nuttx消息...

  • Nuttx内存管理

    Nuttx相关的历史文章:Nuttx Task ScheduleNuttx信号机制Nuttx编译系统Nuttx消息...

  • Nuttx文件系统

    Nuttx相关的历史文章:Nuttx Task ScheduleNuttx信号机制Nuttx编译系统Nuttx消息...

  • Nuttx驱动机制

    Nuttx相关的历史文章:Nuttx Task ScheduleNuttx信号机制Nuttx编译系统Nuttx消息...

  • Nuttx消息队列机制

    Nuttx相关的历史文章:Nuttx Task ScheduleNuttx信号机制Nuttx编译系统 介绍 广义来...

  • Nuttx编译系统

    Nuttx相关的历史文章:Nuttx Task ScheduleNuttx信号机制 配置 Nuttx在编译之前需要...

  • FreeRTOS的第一个任务跳转源码分析—Apple的学习笔记

    一,前言 ubuntu下Nuttx OS调试环境搭建--Apple的学习笔记[https://www.jiansh...

网友评论

      本文标题:NuttX学习2

      本文链接:https://www.haomeiwen.com/subject/tvtdxhtx.html