January 30, 2016

Steps to configure NuttX to run a built-in app from NuttX Command Line (Nutt SHell or NSH)

For people who are new to NuttX like me, in a sentence, NuttX is an embedded RTOS. You can read the overview at nuttx.org. If you have tried building NuttX for your favorite board with the example application or your own application, you may be looking to run your application concurrently from NSH (Nutt SHell) as like we do in GNU/Linux Command line. Bringing up such feature is by enabling Built-In application. The following explanation is a digest of my learning from 'NuttX/apps/README.txt' and acassis blog post.

  1. To enable built-in app to be available in nsh, edit 'nuttx/configs/<board_name>/nsh/defconfig' and add the below configurations
    CONFIG_EXAMPLES_MYAPP=y /* To allow configuring myapp as
                               built-in app */
  2. fork 'apps/examples/hello' to 'apps/examples/myapp' and

    1. rename 'myapp/hello_main.c' to 'myapp/myapp.c'
    2. Edit 'myapp/mayapp.c' and change 'hello_main()' to 'myapp_main()'
    3. modify 'myapp/Kconfig' to resemble the following code to reflect your application name

      config EXAMPLES_MYAPP
              bool "\"Myapp Hello, World!\" example"
              default n
                      Enable the \"Myapp Hello, World!\" example
              string "Myapp Program name"
              default "myapp"
              depends on BUILD_KERNEL
                      This is the name of the program that will be
                      use when the NSH ELF program is installed.
    4. modify 'myapp/Makefile' with the following to reflect your application name.

      APPNAME         = myapp
      CSRCS           = myapp.c

      Note: The 'APPNAME' above should reflect the prefix in myapp_main() and this is the same name by which your NSH command line app will be.
    5. modify 'myapp/Make.defs' to reflect the following code

      ifeq ($(CONFIG_EXAMPLES_MYAPP),y)
              CONFIGURED_APPS += examples/myapp
      • check 'apps/examples/Make.defs' for

        include $(wildcard examples/*/Make.defs)
        if its not present, add it. This makes 'Make.defs' file in every examples subdirectory to be added when configuring. (In otherways, the 'myapp/Make.defs' can be omitted and its contents can be copied to this 'Make.defs' file.)
  3. In 'apps/examples/Kconfig' file, include

    source "$APPSDIR/examples/myapp/Kconfig"
  4. fork 'nuttx/configs/hello' to 'nuttx/configs/myapp' and modify 'myapp/defconfig' to add

    and comment all other examples if enabled. Say,
    # CONFIG_EXAMPLES_HELLO is not set
  5. At this point, everything is set and ready if you are not using any hardware peripheral such as UART, SPI, I2C, CAN, etc. You can jump to the next step. If you are accessing any hardware peripheral, then you need to set the corresponding configuration macros as true. You can do that in 'nuttx/config/<board_name>/myapp/defconfig'
  6. In terminal, go to 'nuttx/tools' and run the following command to tell the Makefile to use 'nsh' example.

    $ ./configure.sh <board_name>/nsh
  7. Switch back to 'nuttx' directory and run 'make' but with the parameters as below to choose the required toolchain.

After building and dumping the code, in nsh, using the command 'help'will list the available built-in app by the name as you provided for the 'APPNAME' macro in the Makefile.

The above article doesn't give you any guarantee and the sole purpose of this article is to share my learning in the way I understood. Any comments to refine this article are welcome with great pleasure. Please report any breaking link by commenting below.

No comments:

Post a Comment

Comment will be published after moderation only. Do not advertise here.

Receive all updates via Facebook. Just Click the Like Button Below

You can also receive Free Email Updates:

dgpride - Study Zone - Free Books - Tamil Lyrics

Copyright © 2008 -2012 dgpride. All rights reserved.


2 Marks (26) 8051 (1) AC Machines (7) Animations (1) Anna University Chennai (31) Arduino (4) ARM (3) Audio (1) Basic C Concepts (8) Basic Electronics (13) Basic principles (9) Book list (1) CAD (1) Chemical (2) Circuit theory (6) Civil (2) Cloud Computing (1) Communication (4) Competitive exams (2) Computer Architecture (4) Control system and components (9) CSE (40) Curriculum (4) DC Machines (9) Did you know (14) Digital (13) DLC (4) Documentation (1) DSP (1) EC 2201 (3) ECE (45) EDC (1) EEE (34) EIE (63) Electrical (35) Electronics (43) Electroplating (2) Emacs (1) Embedded basics (19) Embedded C Programming (19) Embedded Linux (5) Embedded System (22) Engineering basics (15) Environmental Science (1) Fibre Optics (1) Filters (2) FPGA (1) GATE (3) General (7) GNU (4) Handwritten (1) Hobbyist (15) How to (8) HTML (3) Humanities (2) IC Engines (7) ICE (5) Industrial Electronics (10) Industrial Instrumentatin (2) industrial process (2) Instrumentation (21) IoT (2) IT (2) Laboratory Manuals (17) LabVIEW (2) Lesson notes (2) LIC (2) Links (9) Linux (8) Magnetics (1) Management (1) Mechanical (5) Mechatronics (9) Microcontrollers (14) Microprocessors (9) Microsoft (1) Motivation (1) Must Know (11) Networks (1) NuttX (1) Objective type (1) Open Source (1) Opportunities (7) Oscillators (2) Part Time (1) Physics (1) Post Graduation (1) Power Electronics (12) Power Plant Engineering (2) Power Supplies (2) Previous GATE Papers (1) Process Control (2) Project (4) Protocol (1) R2008 (11) R2009 (1) R2013 (1) Recruitment (2) Research (2) Robotics (9) RTOS (3) Signal Processing (8) Signals and Systems (4) SMPS (1) Software tutorial (4) Stepper Motor (2) Syllabus (5) Texas Instruments (2) Thermodynamics (2) Training and Placement (6) Transducer Engineering (2) Transformer (2) Transmission (1) Tutorials (48) Two Marks (26) U-Boot (1) University Question Papers (16) Verilog (1) Video (4) Virtual Instrumentation (3) Visual Basic (21) VLSI (11) Web designing (4) Wi-Fi (3) Wireless (6)