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.
-
To enable built-in app to be available in nsh, edit 'nuttx/configs/<board_name>/nsh/defconfig' and add the below configurations
CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_EXAMPLES_MYAPP=y /* To allow configuring myapp as built-in app */
-
fork 'apps/examples/hello' to 'apps/examples/myapp' and
-
rename 'myapp/hello_main.c' to 'myapp/myapp.c'
-
Edit 'myapp/mayapp.c' and change 'hello_main()' to 'myapp_main()'
-
modify 'myapp/Kconfig' to resemble the following code to reflect your application name
config EXAMPLES_MYAPP bool "\"Myapp Hello, World!\" example" default n ---help--- Enable the \"Myapp Hello, World!\" example if EXAMPLES_MYAPP config EXAMPLES_MYAPP_PROGNAME string "Myapp Program name" default "myapp" depends on BUILD_KERNEL ---help--- This is the name of the program that will be use when the NSH ELF program is installed. endif
-
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. -
modify 'myapp/Make.defs' to reflect the following code
ifeq ($(CONFIG_EXAMPLES_MYAPP),y) CONFIGURED_APPS += examples/myapp endif
-
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.)
-
check 'apps/examples/Make.defs' for
-
rename 'myapp/hello_main.c' to 'myapp/myapp.c'
-
In 'apps/examples/Kconfig' file, include
source "$APPSDIR/examples/myapp/Kconfig"
-
fork 'nuttx/configs/hello' to 'nuttx/configs/myapp' and modify 'myapp/defconfig' to add
CONFIG_EXAMPLES_MYAPP=y
and comment all other examples if enabled. Say,# CONFIG_EXAMPLES_HELLO is not set
-
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'
-
In terminal, go to 'nuttx/tools' and run the following command to tell the Makefile to use 'nsh' example.
$ ./configure.sh <board_name>/nsh
-
Switch back to 'nuttx' directory and run 'make' but with the parameters as below to choose the required toolchain.
$ make CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=n
No comments:
Post a Comment
Comment will be published after moderation only. Do not advertise here.