NuttX RTOS Porting GuideLast Updated: March 13, 2009 |
Table of Contents |
up_initialize()
up_idle()
up_initial_state()
up_create_stack()
up_use_stack()
up_release_stack()
up_unblock_task()
up_block_task()
up_release_pending()
up_reprioritize_rtr()
_exit()
up_assert()
up_schedule_sigaction()
up_allocate_heap()
up_interrupt_context()
up_disable_irq()
up_enable_irq()
up_prioritize_irq()
4.1.19 up_putc()
os_start()
sched_process_timer()
irq_dispatch()
1.0 Introduction |
Overview This document provides and overview of the NuttX build and configuration logic and provides hints for the incorporation of new processor/board architectures into the build.
See also arch/README.txt
and configs/README.txt
.
2.0 Directory Structure |
Directory Structure. The general directly layout for NuttX is very similar to the directory structure of the Linux kernel -- at least at the most superficial layers. At the top level is the main makefile and a series of sub-directories identified below and discussed in the following paragraphs:
. |-- Makefile |-- Documentation | `-- (documentation files)/ |-- arch/ | |-- <arch-name>/ | | |-- include/ | | | |--<chip-name>/ | | | | `-- (chip-specific header files) | | | |--<other-chips>/ | | | `-- (architecture-specific header files) | | `-- src/ | | |--<chip-name>/ | | | `-- (chip-specific source files) | | |--<other-chips>/ | | `-- (architecture-specific source files) | `-- <other-architecture directories>/ |-- configs/ | |-- <board-name>/ | | |-- include/ | | | `-- (other board-specific header files) | | |-- src/ | | | `-- (board-specific source files) | | |---<config-name>/ | | | `-- (board configuration-specific source files) | | `---(other configuration sub-directories for this board)/ | `-- <(other board directories)>/ |-- drivers/ | |-- Makefile | |-- (driver-specific sub-directories)/ | | `-- (driver-specific source files) | `-- (common driver source files) |-- examples/ | `-- (example)/ | |-- Makefile | `-- (example source files) |-- fs/ | |-- Makefile | |-- (file system-specific sub-directories)/ | | `-- (file system-specific source files) | `-- (common file system source files) |-- graphics/ | |-- Makefile | |-- (feature-specific sub-directories)/ | | `-- (feature-specific source files library source files) | `-- (common graphics-related source files) |-- include/ | |-- (standard header files) | |-- (standard include sub-directories) | | `-- (more standard header files) | |-- (non-standard include sub-directories) | `-- (non-standard header files) |-- lib/ | |-- Makefile | `-- (lib source files) |-- mm/ | |-- Makefile | `-- (memory management source files) |-- net/ | |-- Makefile | |-- uip/ | | `-- (uip source files) | `-- (BSD socket source files) |-- netutils/ | |-- Makefile | |-- (network feature sub-directories)/ | | `-- (network feature source files) | `-- (netutils common files) |-- sched/ | |-- Makefile | `-- (sched source files) `-- tools/ `-- (miscellaneous scripts and programs)
Configuration Files. The NuttX configuration consists of:
arch/
<arch-name>/
directory
and are discussed in a paragraph below.
These chip-specific files are contained within chip-specific sub-directories in the
arch/
<arch-name>/
directory and are selected via
the CONFIG_ARCH_name
selection.
These board-specific configuration files can be found in the
configs/
<board-name>/
sub-directories and are discussed
in a paragraph below.
General documentation for the NuttX OS resides in this directory.
This directory contains several sub-directories, each containing
architecture-specific logic.
The task of porting NuttX to a new processor consists of
add a new subdirectory under arch/
containing logic specific
to the new architecture.
The complete board port in is defined by the architecture-specific code in this
directory (plus the board-specific configurations in the config/
subdirectory).
Each architecture must provide a subdirectory, <arch-name>
under arch/
with the following characteristics:
<arch-name>/ |-- include/ | |--<chip-name>/ | | `-- (chip-specific header files) | |--<other-chips>/ | |-- arch.h | |-- irq.h | |-- types.h | `-- limits.h `-- src/ |--<chip-name>/ | `-- (chip-specific source files) |--<other-chips>/ |-- Makefile `-- (architecture-specific source files)
include/
<chip-name>/
This sub-directory contains chip-specific header files.
include/arch.h
:
This is a hook for any architecture specific definitions that may
be needed by the system. It is included by include/nuttx/arch.h
.
include/types.h
:
This provides architecture/toolchain-specific definitions for
standard types. This file should typedef
:
sbyte, ubyte, uint8, boolean, sint16, uint16, sint32, uint32
and if the architecture supports 64-bit integers
sint64, uint64
and finally
irqstate_t
Must be defined to the be the size required to hold the interrupt enable/disable state.
This file will be included by include/sys/types.h and be made available to all files.
include/irq.h
:
This file needs to define some architecture specific functions (usually
inline if the compiler supports inlining) and structure. These include:
struct xcptcontext
:
This structures represents the saved context of a thread.
irqstate_t irqsave(void)
:
Used to disable all interrupts.
void irqrestore(irqstate_t flags):
Used to restore interrupt enables to the same state as before irqsave()
was called.
This file must also define NR_IRQS
, the total number of IRQs supported
by the board.
src/
<chip-name>/
This sub-directory contains chip-specific source files.
src/Makefile
:
This makefile will be executed to build the targets src/libup.a
and
src/up_head.o
. The up_head.o
file holds the entry point into the system
(power-on reset entry point, for example). It will be used in
the final link with libup.a
and other system archives to generate the
final executable.
include/nuttx/arch.h
identifies all of the APIs that must
be provided by the architecture specific logic. (It also includes
arch/
<arch-name>/arch.h
as described above).
Archictecture- and Chip-Specific Directories.
All processor architecture-specific directories are maintained in sub-directories of
the arch/
directory.
Different chips or SoC's may implement the same processor core.
Chip-specific logic can be found in sub-directories under the architecture
directory.
Current architecture/chip directories are summarized below:
arch/sim
:
A user-mode port of NuttX to the x86 Linux platform is available.
The purpose of this port is primarily to support OS feature developement.
This port does not support interrupts or a real timer (and hence no
round robin scheduler) Otherwise, it is complete.
NOTE: This target will not run on Cygwin probably for many reasons but first off because it uses some of the same symbols as does cygwind.dll.
arch/arm
:
This directory holds common ARM architectures. At present, this includes
the following subdirectories:
arch/arm/include
and arch/arm/src/common
:
Common ARM logic.
arch/arm/include/c5471
and arch/arm/src/c5471
:
TI TMS320C5471 (also called TMS320DM180 or just C5471).
NuttX operates on the ARM7 of this dual core processor.
This port is complete, verified, and included in the NuttX release 0.1.1.
arch/arm/include/dm320
and arch/arm/src/dm320
:
TI TMS320DM320 (also called just DM320).
NuttX operates on the ARM9EJS of this dual core processor.
This port complete, verified, and included in the NuttX release 0.2.1.
arch/arm/include/lpc214x
and arch/arm/src/lpc214x
:
These directories provide support for NXP LPC214x family of
processors.
STATUS: This port is in progress and should be available in the
nuttx-0.2.5 release.
configs/mcu123-lpc214x
:
The mcu123.com lpc214x development board.
This is a work in progress.
arch/m68322
A work in progress.
arch/pjrc-8051
:
8051 Microcontroller. This port is not quite ready for prime time.
arch/z16f
:
Zilog z16f Microcontroller.
This port uses the Zilog z16f2800100zcog Development Kit.
This port was released with nuttx-0.3.7.
arch/z80
:
This directory holds 8-bit ZiLOG architectures. At present, this includes the
Zilog z80, ez80Acclaim! and z8Encore! Microcontrollers.
arch/z80/include
and arch/z80/src/common
:
Common logic.
arch/z80/include/z80
and arch/z80/src/z80
:
The Z80 port was released in nuttx-0.3.6 has been verified using only a
z80 instruction simulator.
The set simulator can be found in the NuttX CVS at
http://nuttx.cvs.sourceforge.net/nuttx/misc/sims/z80sim.
This port also uses the SDCC toolchain (http://sdcc.sourceforge.net/")
(verified with version 2.6.0 and 2.7.0).
arch/z80/include/ez80
and arch/z80/src/ez80
:
The ez80Acclaim! port uses the ZiLOG ez80f0910200kitg development kit, eZ80F091 part,
with the Zilog ZDS-II Windows command line tools.
The development environment is Cygwin under WinXP.
This is a work in progress. Verified ez80 support will be announced in a future NuttX release.
arch/z80/include/z8
and arch/z80/src/z8
:
The Z8Encore! port uses either the ZiLOG z8encore000zco development kit, Z8F6403 part,
or the z8f64200100kit development kit, Z8F6423 part with the Zilog ZDS-II Windows command line
tools. The development environment is Cygwin under WinXP.
The initial release, verified only on the ZDS-II ez8 simulator, was released in nuttx-0.3.9.
Deprecated Architecture Directories.
The following architecture directories are deprecated. They have been
replaced by the logic in arm/arm
and will deleted when
arch/arm
is fully verified.
arch/c5471
:
Replaced with arch/arm/include/c5471
and
arch/arm/src/c5471.
arch/dm320
:
Replaced with arch/arm/include/dm320
and
arch/arm/src/dm320.
Other ports for the for the TI TMS320DM270 and for MIPS are in various states of progress
The configs/
subdirectory contains configuration data for each board.
These board-specific configurations plus the architecture-specific configurations in
the arch/
subdirectory complete define a customized port of NuttX.
The configs directory contains board specific configuration files. Each board must
provide a subdirectory <board-name> under configs/
with the following characteristics:
<board-name> |-- include/ | |-- board.h | `-- (board-specific header files) |-- src/ | |-- Makefile | `-- (board-specific source files) |-- <config1-dir> | |-- Make.defs | |-- defconfig | `-- setenv.sh |-- <config2-dir> | |-- Make.defs | |-- defconfig | `-- setenv.sh | ... `-- (other board-specific configuration sub-directories)/
include/
:
This directory contains board specific header files.
This directory will be linked as include/arch/board
at configuration time
and can be included via #include <arch/board/header.h>
.
These header file can only be included by files in arch/
<arch-name>/include/
and arch/
<arch-name>/src/
.
src/
:
This directory contains board specific drivers.
This directory will be linked as /src/board
src/Makefile
:
This makefile will be invoked to build the board specific drivers.
It must support the following targets: libext$(LIBEXT)
, clean
, and distclean
.
The configs/
<board-name>/
sub-directory holds all of the
files that are necessary to configure Nuttx for the particular board.
A board may have various different configurations using the common source files.
Each board configuration is described by three files: Make.defs
, defconfig
, and setenv.sh
.
Typically, each set of configuration files is retained in a separate configuration sub-directory
(<config1-dir>, <config2-dir>, .. in the above diagram).
The procedure for configuring NuttX is described below,
This paragraph will describe the contents of these configuration files.
Make.defs
: This makefile fragment provides architecture and
tool-specific build options. It will be included by all other
makefiles in the build (once it is installed). This make fragment
should define:
When this makefile fragment runs, it will be passed TOPDIR which is the path to the root directory of the build. This makefile fragment may include ${TOPDIR}/.config to perform configuration specific settings. For example, the CFLAGS will most likely be different if CONFIG_DEBUG=y.
defconfig
: This is a configuration file similar to the Linux
configuration file. In contains variable/value pairs like:
CONFIG_VARIABLE
=valueThis configuration file will be used at build time:
include/nuttx/config.h
which is included by
most C files in the system.setenv.sh
: This is a script that you can include that will be installed at
the toplevel of the directory structure and can be sourced to set any
necessary environment variables.
All of the specific boards supported by NuttX are identified below. These are the specific <board-name>'s that may be used to configure NuttX as described below.
configs/c5471evm
:
This is a port to the Spectrum Digital C5471 evaluation board. The
C5471 is a dual core processor from TI with an ARM7TDMI general purpose
processor and a c54 SDP. NuttX runs on the ARM core and is built with
with a GNU arm-elf toolchain* under Linux or Cygwin.
This port is complete, verified, and included in the NuttX release.
configs/ez80f0910200kitg
ez80Acclaim! Microcontroller. This port use the Zilog ez80f0910200kitg
development kit, eZ80F091 part, and the Zilog ZDS-II Windows command line
tools. The development environment is Cygwin under WinXP.
configs/m68322evb
:
This is a work in progress for the venerable m68322evb board from
Motorola.
configs/mcu123-lpc214x
:
This port is for the NXP LPC2148 as provided on the mcu123.com
lpc214x development board.
This OS is also built with the arm-elf toolchain* under Linux or Cygwin.
The port supports serial, timer0, spi, and usb.
configs/ntosd-dm320
:
This port uses the Neuros OSD with a GNU arm-elf toolchain* under Linux or Cygwin.
See Neuros Wiki
for futher information.
NuttX operates on the ARM9EJS of this dual core processor.
STATUS: This port is code complete, verified, and included in the
NuttX 0.2.1 release.
configs/olimex-strp711
:
This port uses the Olimex STR-P711 board arm-elf toolchain* under Linux or Cygwin.
See the Olimex web site
for futher information.
STATUS: Coding for the basic port -- serial console and system timer -- is complete
but untested to problems I am having using OpenOCD with a wiggler clone JTAG.
configs/pjrc-8051
:
8051 Microcontroller. This port uses the PJRC 87C52 development system
and the SDCC toolchain under Linux or Cygwin.
This port is not quite ready for prime time.
configs/sim
:
A user-mode port of NuttX to the x86 Linux platform is available.
The purpose of this port is primarily to support OS feature developement.
This port does not support interrupts or a real timer (and hence no
round robin scheduler) Otherwise, it is complete.
configs/us7032evb1
:
This is a port of the Hitachi SH-1 on the Hitachi SH-1/US7032EVB1 board.
STATUS: Work has just began on this port.
configs/xtrs
:
TRS80 Model 3. This port uses a vintage computer based on the Z80.
An emulator for this computer is available to run TRS80 programs on a
linux platform (http://www.tim-mann.org/xtrs.html).
configs/z16f2800100zcog
z16f Microcontroller.
This port use the Zilog z16f2800100zcog development kit and the
Zilog ZDS-II Windows command line tools.
The development environment is Cygwin under WinXP.
configs/z80sim
:
z80 Microcontroller. This port uses a Z80 instruction set simulator.
That simulator can be found in the NuttX CVS
here.
This port also the SDCC toolchain
under Linux or Cygwin(verfied with version 2.6.0).
configs/z8encore000zco
z8Encore! Microcontroller. This port use the Zilog z8encore000zco
development kit, Z8F6403 part, and the Zilog ZDS-II Windows command line
tools. The development environment is Cygwin under WinXP.
configs/z8encore000zco
z8Encore! Microcontroller. This port use the Zilog z8f64200100kit
development kit, Z8F6423 part, and the Zilog ZDS-II Windows command line
tools. The development environment is Cygwin under WinXP.
* A customized version of the buildroot
is available to build these toolchains under Linux or Cygwin.
This directory holds architecture-independent device drivers.
drivers/ |-- Makefile |-- bch/ | |-- Make.defs | `-- (bch driver source files) |-- mmcsd/ | |-- Make.defs | `-- (mmcsd driver source files) |-- net/ | |-- Make.defs | `-- (net driver source files) |-- usbdev/ | |-- Make.defs | `-- (usbdev driver source files) `-- (common driver source files)
Example and test programs to build against.
This directory contains the NuttX file system. This file system is described below.
fs/ |-- Makefile |-- fat/ | |-- Make.defs | `-- (fat file system source files) |-- romfs/ | |-- Make.defs | `-- (romfs file system source files) `-- (common file system source files)
This directory contains files for graphics/video support under NuttX.
graphics/ |-- Makefile |-- nxglib/ | |-- Make.defs | `-- (NuttX graphics library source files) |-- nx/ | |-- Make.defs | `-- (Nuttx X-server source files) `-- (common file system source files)
This directory holds NuttX header files. Standard header files file retained in can be included in the normal fashion:
include <stdio.h>
include <sys/types.h>
Directory structure:
include/ |-- (standard header files) |-- arpa/ | `-- (standard header files) |-- net/ | `-- uip/ | `-- (uIP specific header files) |-- netinet/ | `-- (standard header files) |-- nuttx/ | `-- (nuttx specific header files) `- sys/ `-- (more standard header files)2.9 lib
This directory holds a collection of standard libc-like functions with custom interfaces into Nuttx.
2.10 mm
This is the NuttX memory manager.
2.11 net
This directory contains the implementation of the socket APIs. The subdirectory,
uip
contians the uIP port.2.12 netutils
This directory contains most of the network applications. Some of these are original with NuttX (like tftpc and dhcpd) and others were leveraged from the uIP-1.0 apps directory. As the uIP apps/README says, these applications "are not all heavily tested."
netutils/ |-- Makefile |-- dhcp/ | |-- Make.defs | `-- (dhcp source files) |-- dhcpd/ | |-- Make.defs | `-- (dhcpd source files) |-- resolv/ | |-- Make.defs | `-- (resolv source files) |-- smtp/ | |-- Make.defs | `-- (smtp source files) |-- telnetd/ | |-- Make.defs | `-- (telnetd source files) |-- tftpc/ | |-- Make.defs | `-- (tftpc source files) |-- uiplib/ | |-- Make.defs | `-- (uiplib source files) |-- weblclient/ | |-- Make.defs | `-- (webclient source files) |-- webserver/ | |-- Make.defs | `-- (webserver source files) `-- (netutils common files)
The files forming core of the NuttX RTOS reside here.
This directory holds a collection of tools and scripts to simplify configuring, building and maintaining NuttX.
tools/ |-- Makefile.mkconfig |-- configure.sh |-- incdir.sh |-- indent.sh |-- link.sh |-- mkconfig.c |-- mkdeps.sh |-- mkimage.sh |-- mknulldeps.sh |-- unlink.sh |-- winlink.sh `-- zipme
The top-level Makefile
in the ${TOPDIR}
directory contains all of the top-level control
logic to build NuttX.
Use of this Makefile
to build NuttX is described below.
3.0 Configuring and Building |
Manual Configuration.
Configuring NuttX requires only copying the
board-specific configuration files into the top level directory which appears in the make files as the make variable, ${TOPDIR}
.
This could be done manually as follows:
configs/
<board-name>/[
<config-dir>/]Make.def
to ${TOPDIR}/Make.defs
,configs/
<board-name>/[
<config-dir>/]setenv.sh
to ${TOPDIR}/setenv.sh
, andconfigs/
<board-name>/[
<config-dir>/]defconfig
to ${TOPDIR}/.config
Where <board-name> is the name of one of the sub-directories of the
NuttX configs/
directory.
This sub-directory name corresponds to one of the supported boards
identified above.
And <config-dir> is the optional, specific configuration directory for the board.
Automated Configuration. There is a script that automates these steps. The following steps will accomplish the same configuration:
cd tools ./configure.sh <board-name>[/
<config-dir>]
Additional Configuration Steps.
The remainder of configuration steps will be performed by ${TOPDIR}/Makefile
the first time the system is built as described below.
Building NuttX. Once NuttX has been configured as described above, it may be built as follows:
cd ${TOPDIR} source ./setenv.sh make
The ${TOPDIR}
directory holds:
Makefile
that controls the NuttX build.
That directory also holds:
.config
that describes the current configuration.Make.defs
that provides customized build targers, andsetenv.sh
that sets up the configuration environment for the build.
The setenv.sh
contains Linux/Cygwin environmental settings that are needed for the build.
The specific environmental definitions are unique for each board but should include, as a minimum, updates to the PATH
variable to include the full path to the architecture-specific toolchain identified in Make.defs
.
The setenv.sh
only needs to be source'ed at the beginning of a session.
The system can be re-made subsequently by just typing make
.
First Time Make. Additional configuration actions will be taken the first time that system is built. These additional steps include:
include/nuttx/config.
using the ${TOPDIR}/.config
file.
${TOPDIR}/arch/
<arch-name>/include
at ${TOPDIR}/include/arch
.
${TOPDIR}/configs/
<board-name>/include
at ${TOPDIR}/include/arch/board
.
${TOPDIR}/configs/
<board-name>/src
at ${TOPDIR}/arch/
<arch-name>/src/board
4.0 Architecture APIs |
The file include/nuttx/arch.h
identifies by prototype all of the APIs that must
be provided by the architecture specific logic.
The internal OS APIs that architecture-specific logic must
interface with also also identified in include/nuttx/arch.h
or in
other header files.
up_initialize()
Prototype: void up_initialize(void);
Description.
up_initialize()
will be called once during OS
initialization after the basic OS services have been
initialized. The architecture specific details of
initializing the OS will be handled here. Such things as
setting up interrupt service routines, starting the
clock, and registering device drivers are some of the
things that are different for each processor and hardware
platform.
up_initialize()
is called after the OS initialized but
before the init process has been started and before the
libraries have been initialized. OS services and driver
services are available.
up_idle()
Prototype: void up_idle(void);
Description.
up_idle()
is the logic that will be executed
when their is no other ready-to-run task. This is processor
idle time and will continue until some interrupt occurs to
cause a context switch from the idle task.
Processing in this state may be processor-specific. e.g., this is where power management operations might be performed.
up_initial_state()
Prototype: void up_initial_state(FAR _TCB *tcb);
Description. A new thread is being started and a new TCB has been created. This function is called to initialize the processor specific portions of the new TCB.
This function must setup the intial architecture registers and/or stack so that execution will begin at tcb->start on the next context switch.
up_create_stack()
Prototype: STATUS up_create_stack(FAR _TCB *tcb, size_t stack_size);
Description. Allocate a stack for a new thread and setup up stack-related information in the TCB.
The following TCB fields must be initialized:
adj_stack_size
: Stack size after adjustment for hardware,
processor, etc. This value is retained only for debug
purposes.stack_alloc_ptr
: Pointer to allocated stackadj_stack_ptr
: Adjusted stack_alloc_ptr
for HW. The
initial value of the stack pointer.
This API is NOT required if CONFIG_CUSTOM_STACK
is defined.
Inputs:
tcb
: The TCB of new task.
stack_size
: The requested stack size. At least this much
must be allocated.
up_use_stack()
Prototype:
STATUS up_use_stack(FAR _TCB *tcb, FAR void *stack, size_t stack_size);
Description. Setup up stack-related information in the TCB using pre-allocated stack memory.
The following TCB fields must be initialized:
adj_stack_size
: Stack size after adjustment for hardware,
processor, etc. This value is retained only for debug
purposes.stack_alloc_ptr
: Pointer to allocated stackadj_stack_ptr
: Adjusted stack_alloc_ptr
for HW. The
initial value of the stack pointer.
This API is NOT required if CONFIG_CUSTOM_STACK
is defined.
Inputs:
tcb
: The TCB of new task.
stack_size
: The allocated stack size.
up_release_stack()
Prototype: void up_release_stack(FAR _TCB *dtcb);
Description. A task has been stopped. Free all stack related resources retained int the defunct TCB.
This API is NOT required if CONFIG_CUSTOM_STACK
is defined.
up_unblock_task()
Prototype: void up_unblock_task(FAR _TCB *tcb);
Description. A task is currently in an inactive task list but has been prepped to execute. Move the TCB to the ready-to-run list, restore its context, and start execution.
This function is called only from the NuttX scheduling logic. Interrupts will always be disabled when this function is called.
Inputs:
tcb
: Refers to the tcb to be unblocked. This tcb is
in one of the waiting tasks lists. It must be moved to
the ready-to-run list and, if it is the highest priority
ready to run taks, executed.
up_block_task()
Prototype: void up_block_task(FAR _TCB *tcb, tstate_t task_state);
Description. The currently executing task at the head of the ready to run list must be stopped. Save its context and move it to the inactive list specified by task_state. This function is called only from the NuttX scheduling logic. Interrupts will always be disabled when this function is called.
Inputs:
tcb
: Refers to a task in the ready-to-run list (normally
the task at the head of the list). It most be
stopped, its context saved and moved into one of the
waiting task lists. It it was the task at the head
of the ready-to-run list, then a context to the new
ready to run task must be performed.
task_state
: Specifies which waiting task list should be
hold the blocked task TCB.
up_release_pending()
Prototype: void up_release_pending(void);
Description. When tasks become ready-to-run but cannot run because pre-emption is disabled, they are placed into a pending task list. This function releases and makes ready-to-run all of the tasks that have collected in the pending task list. This can cause a context switch if a new task is placed at the head of the ready to run list.
This function is called only from the NuttX scheduling logic when pre-emption is re-enabled. Interrupts will always be disabled when this function is called.
up_reprioritize_rtr()
Prototype: void up_reprioritize_rtr(FAR _TCB *tcb, ubyte priority);
Description. Called when the priority of a running or ready-to-run task changes and the reprioritization will cause a context switch. Two cases:
This function is called only from the NuttX scheduling logic. Interrupts will always be disabled when this function is called.
Inputs:
tcb
: The TCB of the task that has been reprioritized
priority
: The new task priority
_exit()
Prototype: void _exit(int status) noreturn_function;
Description. This function causes the currently executing task to cease to exist. This is a special case of task_delete().
Unlike other UP APIs, this function may be called directly from user programs in various states. The implementation of this function should diable interrupts before performing scheduling operations.
up_assert()
Prototype:
void up_assert(FAR const ubyte *filename, int linenum);
void up_assert_code(FAR const ubyte *filename, int linenum, int error_code);
Description. Assertions may be handled in an architecture-specific way.
up_schedule_sigaction()
Prototype:
void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver);
Description. This function is called by the OS when one or more signal handling actions have been queued for execution. The architecture specific code must configure things so that the 'igdeliver' callback is executed on the thread specified by 'tcb' as soon as possible.
This function may be called from interrupt handling logic.
This operation should not cause the task to be unblocked nor should it cause any immediate execution of sigdeliver. Typically, a few cases need to be considered:
This API is NOT required if CONFIG_DISABLE_SIGNALS
is defined.
up_allocate_heap()
Prototype: void up_allocate_heap(FAR void **heap_start, size_t *heap_size);
Description. The heap may be statically allocated by defining CONFIG_HEAP_BASE and CONFIG_HEAP_SIZE. If these are not defined, then this function will be called to dynamically set aside the heap region.
This API is NOT required if CONFIG_HEAP_BASE
is defined.
up_interrupt_context()
Prototype: boolean up_interrupt_context(void)
Description. Return TRUE is we are currently executing in the interrupt handler context.
up_disable_irq()
Prototype:
#ifndef CONFIG_ARCH_NOINTC void up_disable_irq(int irq); #endf
Description. Disable the IRQ specified by 'irq' On many architectures, there are three levels of interrupt enabling: (1) at the global level, (2) at the level of the interrupt controller, and (3) at the device level. In order to receive interrupts, they must be enabled at all three levels.
This function implements enabling of the device specified by 'irq' at the interrupt controller level if supported by the architecture (irqsave() supports the global level, the device level is hardware specific).
If the architecture does not support up_disable_irq
,
CONFIG_ARCH_NOINTC
should be defined in the NuttX configuration file.
Since this API cannot be supported on all architectures, it should be
avoided in common implementations where possible.
up_enable_irq()
Prototype:
#ifndef CONFIG_ARCH_NOINTC void up_enable_irq(int irq); #endf
Description. This function implements disabling of the device specified by 'irq' at the interrupt controller level if supported by the architecture (irqrestore() supports the global level, the device level is hardware specific).
If the architecture does not support up_disable_irq
,
CONFIG_ARCH_NOINTC
should be defined in the NuttX configuration file.
Since this API cannot be supported on all architectures, it should be
avoided in common implementations where possible.
up_prioritize_irq()
Prototype:
#ifdef CONFIG_ARCH_IRQPRIO void up_enable_irq(int irq); #endf
Description. Set the priority of an IRQ.
If the architecture supports up_enable_irq
,
CONFIG_ARCH_IRQPRIO
should be defined in the NuttX configuration file.
Since this API cannot be supported on all architectures, it should be
avoided in common implementations where possible.
up_putc()
Prototype: int up_putc(int ch);
Description. This is a debug interface exported by the architecture-specific logic. Output one character on the console
These are standard interfaces that are exported by the OS for use by the architecture specific logic.
os_start()
To be provided
To be provided
sched_process_timer()
Prototype: void sched_process_timer(void);
Description.
This function handles system timer events.
The timer interrupt logic itself is implemented in the
architecture specific code, but must call the following OS
function periodically -- the calling interval must be
MSEC_PER_TICK
.
irq_dispatch()
Prototype: void irq_dispatch(int irq, FAR void *context);
Description. This function must be called from the achitecture- specific logic in order to dispaly an interrupt to the appropriate, registered handling logic.
5.0 NuttX File System |
Overview. NuttX includes an optional, scalable file system. This file-system may be omitted altogther; NuttX does not depend on the presence of any file system.
Pseudo Root File System.
Or, a simple in-memory, psuedo file system can be enabled.
This simple file system can be enabled setting the CONFIG_NFILE_DESCRIPTORS
option to a non-zero value (see Appendix A).
This is an in-memory file system because it does not require any
storage medium or block driver support.
Rather, file system contents are generated on-the-fly as referenced via
standard file system operations (open, close, read, write, etc.).
In this sense, the file system is psuedo file system (in the
same sense that the Linux /proc
file system is also
referred to as a psuedo file system).
Any user supplied data or logic can be accessed via the psuedo-file system.
Built in support is provided for character and block drivers in the
/dev
psuedo file system directory.
Mounted File Systems
The simple in-memory file system can be extended my mounting block
devices that provide access to true file systems backed up via some
mass storage device.
NuttX supports the standard mount()
command that allows
a block driver to be bound to a mountpoint within the psuedo file system
and to a a file system.
At present, NuttX supports only the VFAT file system.
Comparison to Linux From a programming perspective, the NuttX file system appears very similar to a Linux file system. However, there is a fundamental difference: The NuttX root file system is a psuedo file system and true file systems may be mounted in the psuedo file system. In the typical Linux installation by comparison, the Linux root file system is a true file system and psuedo file systems may be mounted in the true, root file system. The approach selected by NuttX is intended to support greater scalability from the very tiny platform to the moderate platform.
Appendix A: NuttX Configuration Settings |
The following variables are recognized by the build (you may also include architecture-specific settings).
The following configuration itemes select the architecture, chip, and board configuration for the build.
CONFIG_ARCH
:
Identifies the arch subdirectoryCONFIG_ARCH_name
:
For use in C codeCONFIG_ARCH_CHIP
:
Identifies the arch/*/chip subdirectoryCONFIG_ARCH_CHIP_name
:
For use in C codeCONFIG_ARCH_BOARD
:
Identifies the configs subdirectory and hence, the board that supports
the particular chip or SoC.CONFIG_ARCH_BOARD_name
:
For use in C codeCONFIG_ENDIAN_BIG
:
Define if big endian (default is little endian).CONFIG_ARCH_NOINTC
:
Define if the architecture does not support an interrupt controller
or otherwise cannot support APIs like up_enable_irq() and up_disable_irq().CONFIG_ARCH_IRQPRIO
:
Define if the architecture suports prioritizaton of interrupts and the
up_prioritize_irq() API.Some architectures require a description of the RAM configuration:
CONFIG_DRAM_SIZE
:
Describes the installed DRAM.CONFIG_DRAM_START
:
The start address of DRAM (physical)CONFIG_DRAM_VSTART
:
The start address of DRAM (virtual)General build options:
CONFIG_RRLOAD_BINARY
:
Make the rrload binary format used with BSPs from ridgerun.com
using the tools/mkimage.sh
script.CONFIG_INTELHEX_BINARY
:
Make the Intel HEX binary format used with many different loaders using the GNU objcopy program
This option hould not be selected if you are not using the GNU toolchain.CONFIG_MOTOROLA_SREC
:
Make the Motorola S-Record binary format used with many different loaders using the GNU objcopy program
Should not be selected if you are not using the GNU toolchain.CONFIG_RAW_BINARY
:
mmke a raw binary format file used with many different loaders using the GNU objcopy program.
This option should not be selected if you are not using the GNU toolchain.CONFIG_HAVE_LIBM
:
Toolchain supports libm.aCONFIG_EXAMPLE
: identifies the subdirectory in examples
that will be used in the build.
CONFIG_DEBUG
: enables built-in debug options
CONFIG_DEBUG_VERBOSE
: enables verbose debug output
CONFIG_DEBUG_SCHED
: enable OS debug output (disabled by default)
CONFIG_DEBUG_MM
: enable memory management debug output (disabld by default)
CONFIG_DEBUG_NET
: enable network debug output (disabled by default)
CONFIG_DEBUG_FS
: enable file system debug output (disabled by default)
CONFIG_DEBUG_LIB
: enable C library debug output (disabled by default)
CONFIG_ARCH_LOWPUTC
: architecture supports low-level, boot
time console output
CONFIG_MM_REGIONS
: If the architecture includes multiple
regions of memory to allocate from, this specifies the
number of memory regions that the memory manager must
handle and enables the API mm_addregion(start, end);
CONFIG_TICKS_PER_MSEC
: The default system timer is 100Hz
or TICKS_PER_MSEC
=10. This setting may be defined to inform NuttX
that the processor hardware is providing system timer interrupts at some interrupt
interval other than 10 msec.
CONFIG_RR_INTERVAL
: The round robin timeslice will be set
this number of milliseconds; Round robin scheduling can
be disabled by setting this value to zero.
CONFIG_SCHED_INSTRUMENTATION
: enables instrumentation in
scheduler to monitor system performance
CONFIG_TASK_NAME_SIZE
: Spcifies that maximum size of a
task name to save in the TCB. Useful if scheduler
instrumentation is selected. Set to zero to disable.
CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY -
Used to initialize the internal time logic.
CONFIG_JULIAN_TIME
: Enables Julian time conversions
CONFIG_DEV_CONSOLE
: Set if architecture-specific logic
provides /dev/console. Enables stdout, stderr, stdin.
CONFIG_MUTEX_TYPES
: Set to enable support for recursive and
errorcheck mutexes. Enables pthread_mutexattr_settype()
.
CONFIG_PRIORITY_INHERITANCE
: Set to enable support for
priority inheritance on mutexes and semaphores.
Priority inheritance is a strategy of addessing
priority inversion.
Details of the NuttX implementation of priority inheritance is
discussed elsewhere.
CONFIG_SEM_PREALLOCHOLDERS
: This setting is only used
if priority inheritance is enabled.
It defines the maximum number of different threads (minus one) that
can take counts on a semaphore with priority inheritance support.
This may be set to zero if priority inheritance is disabled OR if you
are only using semaphores as mutexes (only one holder) OR if no more
than two threads participate using a counting semaphore.
CONFIG_SEM_NNESTPRIO
: If priority inheritance is enabled,
then this setting is the maximum number of higher priority threads (minus
1) than can be waiting for another thread to release a count on a semaphore.
This value may be set to zero if no more than one thread is expected to
wait for a semaphore.
The following can be used to disable categories of APIs supported by the OS. If the compiler supports weak functions, then it should not be necessary to disable functions unless you want to restrict usage of those APIs.
There are certain dependency relationships in these features.
mq_notify()
logic depends on signals to awaken tasks
waiting for queues to become full or empty.
pthread_condtimedwait()
depends on signals to wake
up waiting tasks.
CONFIG_DISABLE_CLOCK
, CONFI_DISABLE_POSIX_TIMERS
,
CONFIG_DISABLE_PTHREAD
, CONFIG_DISABLE_SIGNALS
,
CONFIG_DISABLE_MQUEUE
, CONFIG_DISABLE_MOUNTPOUNT
CONFIG_NOPRINTF_FIELDWIDTH
: sprintf-related logic is a
little smaller if we do not support fieldwidthes
The architecture can provide optimized versions of the following to improve sysem performance.
CONFIG_ARCH_MEMCPY
, CONFIG_ARCH_MEMCMP
, CONFIG_ARCH_MEMMOVE
,
CONFIG_ARCH_MEMSET
, CONFIG_ARCH_STRCMP
, CONFIG_ARCH_STRCPY
,
CONFIG_ARCH_STRNCPY
, CONFIG_ARCH_STRLEN
, CONFIG_ARCH_BZERO
,
CONFIG_ARCH_KMALLOC
, CONFIG_ARCH_KZMALLOC
, ONFIG_ARCH_KFREE
,
CONFIG_MAX_TASKS
: The maximum number of simultaneously
active tasks. This value must be a power of two.
CONFIG_NPTHREAD_KEYS
: The number of items of thread-
specific data that can be retained
CONFIG_NFILE_DESCRIPTORS
: The maximum number of file
descriptors (one for each open)
CONFIG_NFILE_STREAMS
: The maximum number of streams that
can be fopen'ed
CONFIG_NAME_MAX
: The maximum size of a file name.
CONFIG_STDIO_BUFFER_SIZE
: Size of the buffer to allocate
on fopen. (Only if CONFIG_NFILE_STREAMS > 0)
CONFIG_NUNGET_CHARS
: Number of characters that can be
buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0)
CONFIG_PREALLOC_MQ_MSGS
: The number of pre-allocated message
structures. The system manages a pool of preallocated
message structures to minimize dynamic allocations
CONFIG_MQ_MAXMSGSIZE
: Message structures are allocated with
a fixed payload size given by this settin (does not include
other message structure overhead.
CONFIG_PREALLOC_WDOGS
: The number of pre-allocated watchdog
structures. The system manages a pool of preallocated
watchdog structures to minimize dynamic allocations
CONFIG_DEV_PIPE_SIZE
: Size, in bytes, of the buffer to allocated
for pipe and FIFO support (default is 1024).
CONFIG_FS_FAT
: Enable FAT filesystem support.
CONFIG_FAT_SECTORSIZE
: Max supported sector size.
CONFIG_FS_ROMFS
: Enable ROMFS filesystem support
CONFIG_MMCSD_NSLOTS
: Number of MMC/SD slots supported by the driver. Default is one.
CONFIG_MMCSD_READONLY
: Provide read-only access. Default is Read/Write
CONFIG_NET
: Enable or disable all network features
CONFIG_NET_IPv6
: Build in support for IPv6
CONFIG_NSOCKET_DESCRIPTORS
: Maximum number of socket descriptors per task/thread.
CONFIG_NET_NACTIVESOCKETS
: Maximum number of concurrent socket operations (recv, send, etc.).
Default: CONFIG_NET_TCP_CONNS
+CONFIG_NET_UDP_CONNS
.
CONFIG_NET_SOCKOPTS
: Enable or disable support for socket options.
CONFIG_NET_BUFSIZE
: uIP buffer size
CONFIG_NET_TCP
: TCP support on or off
CONFIG_NET_TCP_CONNS
: Maximum number of TCP connections (all tasks).
CONFIG_NET_TCPBACKLOG
:
Incoming connections pend in a backlog until accept()
is called.
The size of the backlog is selected when listen()
is called.
CONFIG_NET_TCP_READAHEAD_BUFSIZE
: Size of TCP read-ahead buffers
CONFIG_NET_NTCP_READAHEAD_BUFFERS
: Number of TCP read-ahead buffers (may be zero)
CONFIG_NET_MAX_LISTENPORTS
: Maximum number of listening TCP ports (all tasks).
CONFIG_NET_TCPURGDATA
: Determines if support for TCP urgent data
notification should be compiled in. Urgent data (out-of-band data)
is a rarely used TCP feature that is very seldom would be required.
CONFIG_NET_UDP
: UDP support on or off
CONFIG_NET_UDP_CHECKSUMS
: UDP checksums on or off
CONFIG_NET_UDP_CONNS
: The maximum amount of concurrent UDP connections
CONFIG_NET_ICMP
: Enable minimal ICMP support. Includes built-in support
for sending replies to received ECHO (ping) requests.
CONFIG_NET_ICMP_PING
: Provide interfaces to support application level
support for sending ECHO (ping) requests and associating ECHO replies.
CONFIG_NET_PINGADDRCONF
: Use "ping" packet for setting IP address
CONFIG_NET_STATISTICS
: uIP statistics on or off
CONFIG_NET_RECEIVE_WINDOW
: The size of the advertised receiver's window
CONFIG_NET_ARPTAB_SIZE
: The size of the ARP table
CONFIG_NET_BROADCAST
: Incoming UDP broadcast support
CONFIG_NET_MULTICAST
: Outgoing multi-cast address support
CONFIG_NET_LLH_LEN
: The link level header length
CONFIG_NET_FWCACHE_SIZE
: number of packets to remember when looking for duplicates
CONFIG_NET_DHCP_LIGHT
: Reduces size of DHCP
CONFIG_NET_RESOLV_ENTRIES
: Number of resolver entries
CONFIG_USBDEV
: Enables USB device support
CONFIG_USBDEV_ISOCHRONOUS
: Build in extra support for isochronous endpoints
CONFIG_USBDEV_DUALSPEED
: Hardware handles high and full speed operation (USB 2.0)
CONFIG_USBDEV_SELFPOWERED
: Will cause USB features to indicate that the device is self-powered
CONFIG_USBDEV_MAXPOWER
: Maximum power consumption in mA
CONFIG_USBDEV_TRACE
: Enables USB tracing for debug
CONFIG_USBDEV_TRACE_NRECORDS
: Number of trace entries to remember
CONFIG_USBSER
: Enable compilation of the USB serial driver
CONFIG_USBSER_EPINTIN
: The logical 7-bit address of a hardware endpoint that supports interrupt IN operation
CONFIG_USBSER_EPBULKOUT
: The logical 7-bit address of a hardware endpoint that supports bulk OUT operation
CONFIG_USBSER_EPBULKIN
: The logical 7-bit address of a hardware endpoint that supports bulk IN operation
CONFIG_USBSER_NWRREQS
and CONFIG_USBSER_NRDREQS
: The number of write/read requests that can be in flight
CONFIG_USBSER_VENDORID
and CONFIG_USBSER_VENDORSTR
: The vendor ID code/string
CONFIG_USBSER_PRODUCTID
and CONFIG_USBSER_PRODUCTSTR
: The product ID code/string
CONFIG_USBSER_RXBUFSIZE
and CONFIG_USBSER_TXBUFSIZE
: Size of the serial receive/transmit buffers
CONFIG_USBSTRG
:
Enable compilation of the USB storage driver
CONFIG_USBSTRG_EP0MAXPACKET
:
Max packet size for endpoint 0
CONFIG_USBSTRGEPBULKOUT
and CONFIG_USBSTRG_EPBULKIN
:
The logical 7-bit address of a hardware endpoints that support bulk OUT and IN operations
CONFIG_USBSTRG_NWRREQS
and CONFIG_USBSTRG_NRDREQS
:
The number of write/read requests that can be in flight
CONFIG_USBSTRG_BULKINREQLEN
and CONFIG_USBSTRG_BULKOUTREQLEN
:
The size of the buffer in each write/read request.
This value needs to be at least as large as the endpoint maxpacket and
ideally as large as a block device sector.
CONFIG_USBSTRG_VENDORID
and CONFIG_USBSTRG_VENDORSTR
:
The vendor ID code/string
CONFIG_USBSTRG_PRODUCTID
and CONFIG_USBSTRG_PRODUCTSTR
:
The product ID code/string
CONFIG_USBSTRG_REMOVABLE
:
Select if the media is removable
CONFIG_NX
Enables overall support for graphics library and NX
CONFIG_NX_MULTIUSER
:
Configures NX in multi-user mode.
CONFIG_NX_NPLANES
:
Some YUV color formats requires support for multiple planes,
one for each color component. Unless you have such special
hardware, this value should be undefined or set to 1.
CONFIG_NX_DISABLE_1BPP
, CONFIG_NX_DISABLE_2BPP
,
CONFIG_NX_DISABLE_4BPP
, CONFIG_NX_DISABLE_8BPP
CONFIG_NX_DISABLE_16BPP
, CONFIG_NX_DISABLE_24BPP
, and
CONFIG_NX_DISABLE_32BPP
:
NX supports a variety of pixel depths. You can save some
memory by disabling support for unused color depths.
CONFIG_NX_PACKEDMSFIRST
:
If a pixel depth of less than 8-bits is used, then NX needs
to know if the pixels pack from the MS to LS or from LS to MS
CONFIG_NX_MOUSE
:
Build in support for mouse input.
CONFIG_NX_KBD
:
Build in support of keypad/keyboard input.
CONFIG_NXTK_BORDERWIDTH
:
Specifies with with of the border (in pixels) used with
framed windows. The default is 4.
CONFIG_NXTK_BORDERCOLOR1
and CONFIG_NXTK_BORDERCOLOR2
:
Specify the colors of the border used with framed windows.
CONFIG_NXTK_BORDERCOLOR2
is the shadow side color and so
is normally darker. The default is medium and dark grey,
respectively
CONFIG_NXTK_AUTORAISE
:
If set, a window will be raised to the top if the mouse position
is over a visible portion of the window. Default: A mouse
button must be clicked over a visible portion of the window.
CONFIG_NXFONTS_CHARBITS
:
The number of bits in the character set. Current options are
only 7 and 8. The default is 7.
CONFIG_NXFONT_SANS
:
At present, there is only one font. But if there were were more,
then this option would select the sans serif font.
CONFIG_NX_BLOCKING
Open the client message queues in blocking mode. In this case,
nx_eventhandler()
will not return until a message is received and processed.
CONFIG_NX_MXSERVERMSGS
and CONFIG_NX_MXCLIENTMSGS
Specifies the maximum number of messages that can fit in
the message queues. No additional resources are allocated, but
this can be set to prevent flooding of the client or server with
too many messages (CONFIG_PREALLOC_MQ_MSGS
controls how many
messages are pre-allocated).
CONFIG_BOOT_FROM_FLASH
: Some configurations support XIP
operation from FLASH.
CONFIG_STACK_POINTER
: The initial stack pointer
CONFIG_IDLETHREAD_STACKSIZE
: The size of the initial stack.
This is the thread that (1) performs the inital boot of the system up
to the point where user_start() is spawned, and (2) there after is the
IDLE thread that executes only when there is no other thread ready to
run.
CONFIG_USERMAIN_STACKSIZE
: The size of the stack to allocate
for the main user thread that begins at the user_start() entry point.
CONFIG_PTHREAD_STACK_MIN
: Minimum pthread stack size
CONFIG_PTHREAD_STACK_DEFAULT
: Default pthread stack size
CONFIG_HEAP_BASE
: The beginning of the heap
CONFIG_HEAP_SIZE
: The size of the heap
Appendix B: Trademarks |
NOTE: NuttX is not licensed to use the POSIX trademark. NuttX uses the POSIX standard as a development guideline only.