To build and run this NSH Task Demo...
-
Install the Build Prerequisites, skip the RISC-V Toolchain...
-
Download the ARM64 Toolchain for AArch64 Bare-Metal Target
aarch64-none-elf
(Skip the section for Beta Releases)
-
Add the downloaded toolchain to the
PATH
Environment Variable...gcc-arm-...-aarch64-none-elf/bin
Check the ARM64 Toolchain...
aarch64-none-elf-gcc -v
-
Download QEMU Machine Emulator...
-
Download NuttX...
mkdir nuttx cd nuttx git clone https://github.com/apache/nuttx nuttx git clone https://github.com/apache/nuttx-apps apps cd nuttx
-
Add
nshtask
to our NuttX Project...pushd ../apps/examples git submodule add https://github.com/lupyuen/nshtask popd
-
Configure our NuttX Project...
tools/configure.sh -l qemu-armv8a:nsh make menuconfig
-
In "Application Configuration > Examples"
Enable "NSH Task Demo"
-
Optional: If we wish to start
nshtask
when NuttX boots...In "RTOS Features > Tasks and Scheduling"
Set "Application entry point" to
nshtask_main
Set "Application entry name" to
nshtask_main
-
Save the configuration and exit
menuconfig
-
Build NuttX...
make
-
Run NuttX with QEMU...
qemu-system-aarch64 -cpu cortex-a53 -nographic \ -machine virt,virtualization=on,gic-version=3 \ -net none -chardev stdio,id=con,mux=on -serial chardev:con \ -mon chardev=con,mode=readline -kernel ./nuttx
-
At the NSH Prompt, enter this to run the demo...
nshtask
When we're done, press Ctrl-C to quit QEMU.
"How to create a NuttX Task for NSH Shell"
"To create a NuttX task for the NSH shell, you will need to do the following steps"
"In your NuttX application's main file, include the necessary headers for task creation and the NSH shell"
#include <nuttx/sched.h>
#include <nuttx/nsh.h>
"In the main function of your application, create a new task using the
task_create()
function, passing in the necessary parameters such as the task's entry point, its name, and its stack size."
"In the entry point function for the task, call the
nsh_main()
function to start the NSH shell."
"Finally, start the task using the
task_start()
function, passing in the task's ID as a parameter."
"This code creates a task named "nsh", with a priority of 100 and a stack size of 2048 bytes, that runs the nsh_main() function when started."
Lines 2 to 28 in c9d4f0b
The corrected source code is here: nshtask.c