diff --git a/Documentation/.gitignore b/Documentation/.gitignore new file mode 100644 index 0000000000..a2966262c5 --- /dev/null +++ b/Documentation/.gitignore @@ -0,0 +1,3 @@ +/TODO.txt +/ChangeLog.txt +/NuttXConfigVariables.* diff --git a/Documentation/NXGraphicsSubsystem.html b/Documentation/NXGraphicsSubsystem.html new file mode 100644 index 0000000000..b950d6e2ff --- /dev/null +++ b/Documentation/NXGraphicsSubsystem.html @@ -0,0 +1,4289 @@ + + +NX Graphics Subsystem + + + + +

+ + + + +
+

+ NX Graphics Subsystem +

+

Last Updated: July 14, 2015

+
+

+ + + + + +
+

Table of Contents

+
+ + + + + + +
+

+ 1.0 Introduction +

+ +

+ 2.0 NX User APIs +

+
+

+ 2.4 NX Tool Kit (NXTK) +

+

+

+

+

+ 2.5 NX Fonts Support (NXFONTS) +

+

+

+

+

+ 2.6 Sample Code +

+ +

+ Appendix A graphics/ Directory Structure
+ Appendix B NX Configuration Options +

+

+

+

+

+ Appendix C Installing New Fonts +

+

+ Appendix D NX Test Coverage +

+ +
+ + + + + +
+

1.0 Introduction

+
+ +

1.1 Overview

+

+ This document describes the tiny graphics support included in NuttX. + It includes an overview description of that graphics support, detailed + descriptions of the NuttX graphics APIs, and discussion of code organization, + and OS configuration options. +

+ +
+ + + + + +
Figure 1. + This scren shot shows the final frame for the NuttX example at apps/examples/nx + running on the simulated, Linux x86 platform with simulated framebuffer output to + an X window. + This picture shows to framed windows with (blank) toolbars. + Each window has displayed text as received from the NX keyboard interface + The second window has just been raised to the top of the display. + +
+ + +

1.2 Objectives

+ +

+ The objective of this development was to provide a tiny windowing system in the + spirit of X, but greatly scaled down and appropriate for most resource-limited + embedded environments. + The current NX implementation supports the general following, high-level features: +

+ + +

1.3 Organization

+ +

+ NX is organized into 6 (and perhaps someday 7 or 8) logical modules. + These logical modules also correspond to the directory organization. + That NuttX directory organization is discussed in + Appendix B of this document. + The logic modules are discussed in the following sub-paragraphs. +

+ +

+

+

+ +

1.3.1 NX Graphics Library (NXGL)

+ +

+ NXGLIB is a standalone library that contains low-level graphics utilities and + direct framebuffer or LCD rendering logic. NX is built on top NXGLIB. +

+ +

1.3.2 NX (NXSU and NXMU)

+ +

+ NX is the tiny NuttX windowing system for raw windows (i.e., simple regions of + graphics memory). + NX includes both a small-footprint, single user implementaton (NXSU) and a somewhat + larger multi-user implentation (NXMU as described below). + Both conform to the same APIs as defined in include/nuttx/nx/nx.h and, hence, + are interchangable1. + NX can be used without NxWidgets and without NXTOOLKIT for raw window displays. +

+ +

+ 1NXMU and NXSU are interchangeable other than (1) certain start-up + and initialization APIs (as described below), and (2) timing. With NXSU, NX APIs + execute immediately; with NXMU, NX APIs defer and serialize the operations and, hence, + introduce different timing and potential race conditions that you would not experience + with NXSU. +

+ +

NXNULL? + At one time, I also envisioned a NULL front-end that did not support windowing + at all but, rather, simply provided the entire framebuffer or LCD memory as one dumb window. + This has the advantage that the same NX APIs can be used on the one dumb window as + for the other NX windows. + This would be in the NuttX spirit of scalability. +

+

+ However, the same end result can be obtained by using the + nx_requestbkgd() API. + It still may be possible to reduce the footprint in this usage case by developing + and even thinner NXNULL front-end. + That is a possible future development. +

+ +

1.3.3 NX Tool Kit (NXTK)

+ +

+ NXTK is a s set of C graphics tools that provide higher-level window drawing + operations. + This is the module where the framed windows and toolbar logic is implemented. + NXTK is built on top of NX and does not depend on NxWidgets. +

+ +

1.3.4 NX Fonts Support (NXFONTS)

+ +

+ A set of C graphics tools for present (bitmap) font images. + The font implementation is at a very low level or graphics operation, + comparable to the logic in NXGLIB. + NXFONTS does not depend on any NX module other than some utilities and types from NXGLIB. +

+ +

1.3.5 NX Widgets (NxWidgets)

+ +

+ NxWidgets is a higher level, C++, object-oriented library for object-oriented access to graphical "widgets." + NxWidgets is provided as a separate package. + NxWidgets is built on top of the core NuttX graphics subsystem, but is not a part of the core graphics subystems. +

+ +

1.3.6 NX Terminal Driver (NxTerm)

+ +

+ NxTerm is a write-only character device (not shown) that is built on top of an NX window. + This character device can be used to provide stdout and stderr and, hence, can provide the output side of NuttX console. + NxTerm is only available when the multi-user NX implementation is selected (CONFIG_NX_MULTIUSER). +

+ + + + + +
+

2.0 NX User APIs

+
+ +

2.1 NX Header Files

+ + + +

2.2 NX Graphics Library (NXGL)

+ +

+ NXGL provides many APIs, some available for use internally by NX and + others for use by applications as well. + Only those APIs intended for application usage are documented here + See include/nuttx/nx/nxglib.h for the full set of APIs; + those APIs might be of interest if you are rendering directly into + framebuffer or LCD memory. +

+ +

2.2.1 NXGL Types

+ +

+ nxgl_mxpixel_t. + Holds one device pixel. + NXGLIB will select the smallest size for the nxgl_mxpixel_t + that just contains the pixel: byte if 16, 24, and 32 resolution + support is disabled, uint16_t if 24, and 32 resolution + support is disabled, or uint32_t. +

+ +

+ nxgl_coord_t. + A given coordinate is limited to the screen height an width. If either + of those values exceed 32,767 pixels, then the following will have to need + to change: +

+ + +

+ struct nxgl_point_s. Describes a point on the display: +

+ + +

+ struct nxgl_size_s. Describes the size of a rectangular region. +

+ + +

+ struct nxgl_rect_s. Describes a positioned rectangle on the display. +

+ + +

+ struct nxgl_run_s. + Describes a run, i.e., a horizontal line. Note that the start/end positions + have fractional precision. This is necessary for good joining of trapezoids + when a more complex shape is decomposed into trapezoids +

+ + +

+ struct nxgl_trapezoid_s. + Describes a horizontal trapezoid on the display in terms the run at the + top of the trapezoid and the run at the bottom +

+ + +

2.2.1 nxgl_rgb2yuv()

+

Function Prototype:

+ +

+ Description: + Convert 8-bit RGB triplet to 8-bit YUV triplet. +

+ +

2.2.2 nxgl_yuv2rgb()

+

Function Prototype:

+ +

+ Description: + Convert 8-bit RGB triplet to 8-bit YUV triplet. +

+ +

2.2.3 nxgl_rectcopy()

+

Function Prototype:

+ +

+ Description: + This is essentially memcpy()for rectangles. We don't do structure + assignments because some compilers are not good at that. +

+ +

2.2.4 nxgl_rectoffset()

+

Function Prototype:

+ +

+ Description: + Offset the rectangle position by the specified dx, dy values. +

+ +

2.2.5 nxgl_vectoradd()

+

Function Prototype:

+ +

+ Description: + Add two 2x1 vectors and save the result to a third. +

+ +

2.2.6 nxgl_vectorsubtract()

+

Function Prototype:

+ +

+ Description: + Add subtract vector v2 from vector v1 and return the result in vector dest. +

+ +

2.2.7 nxgl_rectintersect()

+

Function Prototype:

+ +

+ Description: + Return the rectangle representing the intersection of the two rectangles. +

+ +

2.2.8 nxgl_rectunion()

+

Function Prototype:

+ +

+ Description: + Given two rectanges, src1 and src2, return the larger rectangle that + contains both, dest. +

+ +

2.2.9 nxgl_nonintersecting()

+

Function Prototype:

+ +

+ Description: + Return the regions of rectangle rect1 that do not intersect with + rect2. This will four rectangles, some of which may be + degenerate (and can be picked off with nxgl_nullrect()). +

+ +

2.2.10 nxgl_rectoverlap()

+

Function Prototype:

+ +

+ Description: + Return true if the two rectangles overlap. +

+ +

2.2.11 nxgl_rectinside()

+

Function Prototype:

+ +

+ Description: + Return true if the point pt lies within rect. +

+ +

2.2.12 nxgl_rectsize()

+

Function Prototype:

+ +

+ Description: + Return the size of the specified rectangle. +

+ +

2.2.13 nxgl_nullrect()

+

Function Prototype:

+ +

+ Description: + Return true if the area of the retangle is <= 0. +

+ +

2.2.14 nxgl_runoffset()

+

Function Prototype:

+ +

+ Description: + Offset the run position by the specified dx, dy values. +

+ +

2.2.15 nxgl_runcopy()

+

Function Prototype:

+ +

+ Description: + This is essentially memcpy()for runs. We don't do structure assignments + because some compilers are not good at that. +

+ +

2.2.16 nxgl_trapoffset()

+

Function Prototype:

+ +

+ Description: + Offset the trapezoid position by the specified dx, dy values. +

+ +

2.2.17 nxgl_trapcopy()

+

Function Prototype:

+ +

+ Description: + This is essentially memcpy()for trapezoids. We don't do structure + assignments because some compilers are not good at that. +

+ +

2.2.18 nxgl_colorcopy

+

Function Prototype:

+ +

+ Description: + This is essentially memcpy()for colors. This does very little for us + other than hide all of the conditional compilation for planar colors + in one place. +

+ +

2.2.19 nxgl_splitline

+ +

Function Prototype:

+ +

+ Description: + In the general case, a line with width can be represented as a parallelogram with a triangle at the top and bottom. + Triangles and parallelograms are both degenerate versions of a trapezoid. + This function breaks a wide line into triangles and trapezoids. + This function also detects other degenerate cases: +

+
    +
  1. + If y1 == y2 then the line is horizontal and is better represented as a rectangle. +
  2. +
  3. + If x1 == x2 then the line is vertical and also better represented as a rectangle. +
  4. +
  5. + If the width of the line is 1, then there are no triangles at the top and bottom + (this may also be the case if the width is narrow and the line is near vertical). +
  6. +
  7. + If the line is oriented is certain angles, it may consist only of the upper and lower triangles with no trapezoid in between. + In this case, 3 trapezoids will be returned, but traps[1] will be degenerate. +
  8. +
+

+ Input parameters: +

+

+

+ Returned value: +

+ + +

2.2.20 nxgl_circlepts

+ +

+ Description: + Given a description of a circle, return a set of 16 points on the circumference of the circle. + These points may then be used by nx_drawcircle() or related APIs to draw a circle outline. +

+

+ Input parameters: +

+

+

+ Returned value: None +

+ +

2.2.21 nxgl_circletraps

+ +

+ Description: + Given a description of a a circle, return 8 trapezoids that can be used to fill the circle by nx_fillcircle() and other interfaces. +

+

+ Input parameters: +

+

+

+ Returned value: None +

+ +

2.3 NX

+ +

2.3.1 Pre-Processor Definitions

+ +

+ The default server message queue name used by the + nx_run() macro: +

+ + +

+ Mouse button bits: +

+ + +

2.3.2 NX Types

+ +

+ The interface to the NX server is managed using a opaque handle: +

+ + +

+ The interface to a specific window is managed using an opaque handle: +

+ + +

+ These define callbacks that must be provided to + nx_openwindow(). + In the multi-user model, these callbacks will be invoked as part of the + processing performed by + nx_eventhandler(). +

+ + +

2.3.3 NX Server Callbacks

+ +

2.3.3.1 redraw()

+

Callback Function Prototype:

+ +

+ Description: + NX requests that the client re-draw the portion of the window within + with rectangle. +

+

+ Input Parameters: +

+

+

+ Returned Value: None +

+ +

2.3.3.2 position()

+

Callback Function Prototype:

+ +

+ Description: + The size or position of the window has changed (or the window was + just created with zero size. +

+

+ Input Parameters: +

+

+

+ Returned Value: None +

+ +

2.3.3.3 mousein()

+

Callback Function Prototype:

+ +

+ Description: + New mouse data is available for the window +

+

+ Input Parameters: +

+

+

+ Returned Value: None +

+ +

2.3.3.4 kbdin()

+

Callback Function Prototype:

+ +

+ Description: + New keyboard/keypad data is available for the window. +

+

+ Input Parameters: +

+

+

+ Returned Value: None +

+ +

2.3.4 nx_runinstance() (and nx_run() macro)

+

Function Prototype:

+ +

+ Description: + This is the server entry point. It does not return; the calling thread + is dedicated to supporting NX server. +

+

+ NOTE that multiple instances of the NX server may run at the same time, + with different callback and message queue names. nx_run() is simply + a macro that can be used when only one server instance is required. In + that case, a default server name is used. +

+

+ Multiple user mode only! +

+

+ Input Parameters: +

+

+

+ Returned Value: + This function usually does not return. If it does return, it will + return ERROR and errno will be set appropriately. +

+ +

2.3.5 nx_connectinstance() (and nx_connect() macro)

+

Function Prototype:

+ +

+ Description: + Open a connection from a client to the NX server. One one client + connection is normally needed per thread as each connection can host + multiple windows. +

+

+ NOTES: +

+ +

+ Multiple user mode only! +

+

+ Input Parameters: +

+

+

+ Returned Value: +

+ + +

2.3.6 nx_open()

+

Function Prototype:

+ +

+ Description: + Create, initialize and return an NX handle for use in subsequent + NX API calls. nx_open() is the single user equivalent of + nx_connect() plus + nx_run(). +

+

+ Single user mode only! +

+

+ Input Parameters: +

+

+

+ Returned Value: +

+ + +

2.3.7 nx_disconnect()

+

Function Prototype:

+ +

+ Description: + Disconnect a client from the NX server and/or free resources reserved + by nx_connect()/nx_connectinstance(). + nx_disconnect() is muliti-user equivalent of + nx_close(). +

+

+ Multiple user mode only! +

+

+ Input Parameters: +

+

+

+ Returned Value: None. +

+ +

2.3.8 nx_close()

+

Function Prototype:

+ +

+ Description: + Close the single user NX interface. nx_close is single-user equivalent + of nx_disconnect(). +

+

+ Single user mode only! +

+

+ Input Parameters: +

+

+

+ Returned Value: None +

+ +

2.3.9 nx_eventhandler()

+

Function Prototype:

+ +

+ Description: + The client code must call this function periodically to process + incoming messages from the server. If CONFIG_NX_BLOCKING is defined, + then this function not return until a server message is received. +

+

+ When CONFIG_NX_BLOCKING is not defined, the client must exercise + caution in the looping to assure that it does not eat up all of + the CPU bandwidth calling nx_eventhandler repeatedly. + nx_eventnotify() + may be called to get a signal event whenever a new incoming server + event is avaiable. +

+

+ Input Parameters: +

+

+

+ Returned Value: +

+ + +

2.3.10 nx_eventnotify()

+

Function Prototype:

+ +

+ Description: + Rather than calling nx_eventhandler() periodically, + the client may register to receive a signal when a server event is available. + The client can then call nv_eventhandler() only when + incoming events are available. +

+

+ The underlying implementation used mq_notifiy() and, as a result, + the client must observe the rules for using mq_notifiy(): +

+

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.11 nx_openwindow()

+

Function Prototype:

+ +

+ Description: Create a new window. +

+

+ Input Parameters: +

+

+

+ Returned Value: +

+ + +

2.3.12 nx_closewindow()

+

Function Prototype:

+ +

+ Description: + Destroy a window created by nx_openwindow() window. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.13 nx_requestbkgd()

+

Function Prototype:

+ +

+ Description: + NX normally controls a separate window called the background window. + It repaints the window as necessary using only a solid color fill. The + background window always represents the entire screen and is always + below other windows. It is useful for an application to control the + background window in the following conditions: +

+ +

+ This API only requests the handle of the background window. That + handle will be returned asynchronously in a subsequent position and + redraw callbacks. +

+

+ Cautions: +

+ +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.14 nx_releasebkgd()

+

Function Prototype:

+ +

+ Description: + Release the background window previously acquired using + nx_requestbkgd() + and return control of the background to NX. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.15 nx_getposition()

+

Function Prototype:

+ +

+ Description: + Request the position and size information for the selected window. The + values will be return asynchronously through the client callback function + pointer. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.16 nx_setposition()

+

Function Prototype:

+ +

+ Description: + Set the position and size for the selected window. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.17 nx_setsize()

+

Function Prototype:

+ +

+ Description: Set the size of the selected window. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.18 nx_raise()

+

Function Prototype:

+ +

+ Description: Bring the specified window to the top of the display. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.19 nx_lower()

+

Function Prototype:

+ +

+ Description: Lower the specified window to the bottom of the display. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.20 nx_fill()

+

Function Prototype:

+ +

+ Description: + Fill the specified rectangle in the window with the specified color. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.21 nx_getrectangle()

+

Function Prototype:

+ +

+ Description: + Get the raw contents of graphic memory within a rectangular region. NOTE: + Since raw graphic memory is returned, the returned memory content may be + the memory of windows above this one and may not necessarily belong to + this window unless you assure that this is the top window. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.22 nx_filltrapezoid()

+

Function Prototype:

+ +

+ Description: + Fill the specified trapezoidal region in the window with the specified color. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.23 nx_drawline()

+

Function Prototype:

+ +

+ Description: + Fill the specified trapezoidal region in the window with the specified color. + Fill the specified line in the window with the specified color. + This is simply a wrapper that uses nxgl_splitline() to break the line into + trapezoids and then calls nx_filltrapezoid() to render the line. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.24 nx_drawcircle()

+

Function Prototype:

+ +

+ Description: + Draw a circular outline using the specified line thickness and color. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.25 nx_fillcircle()

+

Function Prototype:

+ +

+ Description: + Fill a circular region using the specified color. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.26 nx_setbgcolor()

+

Function Prototype:

+ +

+ Description: Set the color of the background. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.27 nx_move()

+

Function Prototype:

+ +

+ Description: Move a rectangular region within the window. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.28 nx_bitmap()

+

Function Prototype:

+ +

+ Description: + Copy a rectangular region of a larger image into the rectangle in the + specified window. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.29 nx_kbdin()

+

Function Prototype:

+ +

+ Description: + Used by a thread or interrupt handler that manages some kind of keypad + hardware to report text information to the NX server. That text + data will be routed by the NX server to the appropriate window client. +

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.3.30 nx_mousein()

+

Function Prototype:

+ +

+ Description: + Used by a thread or interrupt handler that manages some kind of pointing + hardware to report new positional data to the NX server. That positional + data will be routed by the NX server to the appropriate window client. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4 NX Tool Kit (NXTK)

+ +

+ NXTK implements where the framed window. + NX framed windows consist of three components within one NX window: +

+
    +
  1. The window border,
  2. +
  3. The main client window area, and
  4. +
  5. A toolbar area
  6. +
+ +

+ Each sub-window represents a region within one window. + Figure 1 shows some simple NX framed windows. + NXTK allows these sub-windows to be managed more-or-less independently: +

+ + +

2.4.1 NXTK Types()

+ +

+ This is the handle that can be used to access the window data region. +

+ + +

2.4.2 nxtk_openwindow()

+

Function Prototype:

+ +

+ Description: Create a new, framed window. +

+

+ Input Parameters: +

+
handle +
The handle returned by nx_connect() + or nx_open(). +
cb +
Callbacks used to process window events +
arg +
User provided argument (see nx_openwindow()) +
+

+

+ Returned Value: +

+ + +

2.4.3 nxtk_closewindow()

+

Function Prototype:

+ +

+ Description: + Close the window opened by nxtk_openwindow(). +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.4 nxtk_getposition()

+

Function Prototype:

+ +

+ Description: + Request the position and size information for the selected framed window. + The size/position for the client window and toolbar will be return + asynchronously through the client callback function pointer. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.5 nxtk_setposition()

+

Function Prototype:

+ +

+ Description: + Set the position for the selected client window. This position does not + include the offsets for the borders nor for any toolbar. Those offsets + will be added in to set the full window position. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
pos +
The new position of the client sub-window +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.6 nxtk_setsize()

+

Function Prototype:

+ +

+ Description: + Set the size for the selected client window. This size does not + include the sizes of the borders nor for any toolbar. Those sizes + will be added in to set the full window size. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
size +
The new size of the client sub-window. +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.7 nxtk_raise()

+

Function Prototype:

+ +

+ Description: + Bring the window containing the specified client sub-window to the top + of the display. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow() + specifying the window to be raised. +
+
+
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.8 nxtk_lower()

+

Function Prototype:

+ +

+ Description: + Lower the window containing the specified client sub-window to the + bottom of the display. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow() + specifying the window to be lowered. +
+
+
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.9 nxtk_fillwindow()

+

Function Prototype:

+ +

+ Description: + Fill the specified rectangle in the client window with the specified color. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
rect +
The location within the client window to be filled +
color +
The color to use in the fill +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.10 nxtk_getwindow()

+

Function Prototype:

+ +

+ Description: + Get the raw contents of graphic memory within a rectangular region. NOTE: + Since raw graphic memory is returned, the returned memory content may be + the memory of windows above this one and may not necessarily belong to + this window unless you assure that this is the top window.

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
rect +
The location within the client window to be retrieved. + +
plane +
Specifies the color plane to get from. +
dest +
The location to copy the memory region +
deststride +
The width, in bytes, of the dest memory +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.11 nxtk_filltrapwindow()

+

Function Prototype:

+ +

+ Description: + Fill the specified trapezoid in the client window with the specified color +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
trap +
The trapezoidal region to be filled. +
color +
The color to use in the fill. +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.12 nxtk_drawlinewindow()

+

Function Prototype:

+ +

+ Description: + Fill the specified trapezoidal region in the window with the specified color. + Fill the specified line in the window with the specified color. + This is simply a wrapper that uses nxgl_splitline() to break the line into + trapezoids and then calls nxtk_filltrapwindow() to render the line. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.13 nxtk_drawcirclewindow()

+

Function Prototype:

+ +

+ Description: + Draw a circular outline using the specified line thickness and color. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.14 nxtk_fillcirclewindow()

+

Function Prototype:

+ +

+ Description: + Fill a circular region using the specified color. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.15 nxtk_movewindow()

+

Function Prototype:

+ +

+ Description: + Move a rectangular region within the client sub-window of a framed window. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow() + specifying the client sub-window within which the move is to be done. +
rect +
Describes the rectangular region relative to the client sub-window to move. +
offset +
The offset to move the region +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.16 nxtk_bitmapwindow()

+

Function Prototype:

+ +

+ Description: + Copy a rectangular region of a larger image into the rectangle in the + specified client sub-window. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow() + specifying the client sub-window that will receive the bitmap. +
dest +
Describes the rectangular region on in the client sub-window + will receive the bit map. +
src +
The start of the source image(s). This is an array source + images of size CONFIG_NX_NPLANES (probably 1). +
origin +
The origin of the upper, left-most corner of the full bitmap. + Both dest and origin are in sub-window coordinates, however, the + origin may lie outside of the sub-window display. +
stride +
The width of the full source image in pixels. +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.17 nxtk_opentoolbar()

+

Function Prototype:

+ +

+ Description: + Create a tool bar at the top of the specified framed window. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
height +
The requested height of the toolbar in pixels. +
cb +
Callbacks used to process toolbar events. +
arg +
User provided value that will be returned with toolbar callbacks. +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.18 nxtk_closetoolbar()

+

Function Prototype:

+ +

+ Description: + Remove the tool bar at the top of the specified framed window. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
+
+
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.19 nxtk_filltoolbar()

+

Function Prototype:

+ +

+ Description: + Fill the specified rectangle in the toolbar sub-window with the specified color. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
rect +
The location within the toolbar window to be filled. +
color +
The color to use in the fill. +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.19 nxtk_gettoolbar()

+

Function Prototype:

+ +

+ Description: + Get the raw contents of graphic memory within a rectangular region. NOTE: + Since raw graphic memory is returned, the returned memory content may be + the memory of windows above this one and may not necessarily belong to + this window unless you assure that this is the top window. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
rect +
The location within the toolbar window to be retrieved. + +
plane +
TSpecifies the color plane to get from. +
dest +
TThe location to copy the memory region. +
deststride +
The width, in bytes, of the dest memory. +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.21 nxtk_filltraptoolbar()

+

Function Prototype:

+ +

+ Description: + Fill the specified trapezoid in the toolbar sub-window with the specified color. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
trap +
The trapezoidal region to be filled +
color +
The color to use in the fill +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.22 nxtk_drawlinetoolbar()

+

Function Prototype:

+ +

+ Description: + Fill the specified line in the toolbar sub-window with the specified color. + This is simply a wrapper that uses nxgl_splitline() to break the line into + trapezoids and then calls nxtk_filltraptoolbar() to render the line. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.23 nxtk_drawcircletoolbar()

+

Function Prototype:

+ +

+ Description: + Draw a circular outline using the specified line thickness and color. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.24 nxtk_fillcircletoolbar()

+

Function Prototype:

+ +

+ Description: + Fill a circular region using the specified color. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.25 nxtk_movetoolbar()

+

Function Prototype:

+ +

+ Description: + Move a rectangular region within the toolbar sub-window of a framed window. +

+

+ Input Parameters: +

+
hfwnd +
A handle identifying sub-window containing the toolbar within which the move is + to be done. + This handle must have previously been returned by + nxtk_openwindow(). +
rect +
Describes the rectangular region relative to the toolbar sub-window to move. +
offset +
The offset to move the region +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.4.26 nxtk_bitmaptoolbar()

+

Function Prototype:

+ +

+ Description: + Copy a rectangular region of a larger image into the rectangle in the + specified toolbar sub-window. +

+

+ Input Parameters: +

+
hfwnd +
A handle previously returned by + nxtk_openwindow(). +
dest +
Describes the rectangular region on in the toolbar sub-window + will receive the bit map. +
src +
The start of the source image. +
origin +
The origin of the upper, left-most corner of the full bitmap. + Both dest and origin are in sub-window coordinates, however, the + origin may lie outside of the sub-window display. +
stride +
The width of the full source image in bytes. +
+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately +

+ +

2.5 NX Fonts Support (NXFONTS)

+ +

2.5.1 NXFONTS Types()

+

+ This structures provides the metrics for one glyph: +

+ + +

+ This structure binds the glyph metrics to the glyph bitmap: +

+ + +

+ This structure describes one contiguous grouping of glyphs that + can be described by an array starting with encoding first and + extending through (first + nchars - 1). +

+ + +

+ This structure describes the overall fontset: +

+ + +

2.5.2 nxf_getfonthandle()

+

Function Prototype:

+ +

+ Description: + Given a numeric font ID, return a handle that may be subsequently be used to access the font data sets. +

+

+ Input Parameters: +

+

+

+ Returned Value: + A handle that may be subsequently be used to access the font data sets. +

+ +

2.5.3 nxf_getfontset()

+

Function Prototype:

+ +

+ Description: + Return information about the current font set. +

+

+ Input Parameters: +

+

+

+ Returned Value: + An instance of struct nx_font_s describing the font set. +

+ +

2.5.4 nxf_getbitmap()

+

Function Prototype:

+ +

+ Description: + Return font bitmap information for the selected character encoding. +

+

+ Input Parameters: +

+

+

+ Returned Value: + An instance of struct nx_fontbitmap_s describing the glyph. +

+ +

2.5.5 nxf_convert_*bpp()

+

Function Prototype:

+ +

+ Description: Convert the 1BPP font to a new pixel depth. +

+

+ Input Parameters: +

+

+

+ Returned Value: + OK on success; + ERROR on failure with errno set appropriately. +

+ +

2.6 Sample Code

+ +

apps/examples/nx*. + No sample code is provided in this document. + However, examples can be found in the NuttX source tree at the follow locations: + That example code is intended to test NX. + Since it is test code, it is designed to exercise functionality and does not necessarily represent best NX coding practices. +

+ + +

+ In its current form, the NX graphics system provides a low level of graphics and window + support. + Most of the complexity of manage redrawing and handling mouse and keyboard events must + be implemented by the NX client code. +

+ +

Building apps/examples/nx. + Testing was performed using the Linux/Cygwin-based NuttX simulator. + Instructions are provided for building that simulation are provided in + Appendix C of this document. +

+ + + + + +
+

Appendix A graphics/ Directory Structure

+
+ +

+ The graphics capability consist both of components internal to the RTOS and of user-callable interfaces. + In the NuttX kernel mode build there are some components of the graphics subsystem are callable in user mode and other components that are internal to the RTOS. + The directory nuttx/graphics contains only those components that are internal to the RTOS. + + User callable functions must be part of a library that can be linked against user applications. + This user callable interfaces are provided in sub-directories under nuttx/libnx. +

+

+ + + + + +
+

Appendix B NX Configuration Options

+
+ +

B.1 General Configuration Settings

+ + + +

B.2 NXGL Configuration Settings

+ + + +

B.3 NX Configuration Settings

+ + + +

B.4 NX Multi-User (Only) Configuration Settings

+ + + +

B.5 NXTK Configuration Settings

+ + + +

B.6 NXFONTS Configuration Settings

+ + + +

B.7 NxTerm Configuration Settings

+ +

General NxTerm settings.

+ + +

NxTerm output text/graphics options:

+ + +

NxTerm input options:

+ + + + + + +
+

Appendix C Installing New Fonts

+
+ +

The BDF Font Converter. + There is a tool called bdf-converter in the directory tools/.. + The bdf-converter program be used to convert fonts in Bitmap Distribution Format (BDF) into fonts that can be used in the NX graphics system. + The BDF format most well known as a font format traditionally used for X-11 bitmap fonts. +

+
+ A Note about Font Copyrights: + My understanding is that the underlying bitmap font data for traditional fonts cannot be copyrighted (the same is not true for scalable fonts). + This is because a copyright covers only the form of delivery of the font and not the underlying font content and, at least for the traditional typefaces, the underlying font designs are ancient. + There could be issues, however, if you convert from modern, trademarked images. + However, remember that I am a programmer not an attorney and that my knowledge of font copyright issues is limited to what I glean by Googling. +
+

+ Font Installation Steps, + Below are general instructions for creating and installing a new font in the NX graphic system. + The first two steps only appy if you are using the BDF font converter program. +

+
    +
  1. +

    + Locate a font in BDF format. + There are many good BDF bitmap fonts bundled with X-11. + See this link, as an example, +

    +
  2. +
  3. +

    + Use the bdf-converter program to convert the BDF font to the NuttX font format. + This will result in a C header file containing definitions. + That header file should be installed at, for example, graphics/nxfonts/nxfonts_myfont.h. +

    +
  4. +
+

+ The remaining steps apply however you managed to create the NuttX C font header file. + After you have your C font header file, the next thing to do is to create a new NuttX configuration variable to select the font. + For example, suppose you define the following variable: CONFIG_NXFONT_MYFONT. + Then you would need to: +

+
    +
  1. +

    + Define CONFIG_NXFONT_MYFONT=y in your NuttX configuration file. +

    +
  2. +
+

+ A font ID number has to be assigned for each new font. + The font IDs are defined in the file include/nuttx/nx/nxfonts.h. + Those definitions have to be extended to support your new font. + Look at how the font ID enabled by CONFIG_NXFONT_SANS23X27 is defined and add an ID for yournew font in a similar fashion: +

+
    +
  1. +

    + include/nuttx/nx/nxfonts.h. Add you new font as a possible system default font: +

    + +

    + Then define the actual font ID. + Make sure that the font ID value is unique: +

    + +
  2. +
+

+ New Add the font to the NX build system. + There are several files that you have to modify to to this. + Look how the build system uses the font CONFIG_NXFONT_SANS23X27 for examaples: +

+
    +
  1. +

    + nuttx/graphics/Makefile. + This file needs logic to auto-generate a C source file from the header file that you generated with the bdf-converter program. + Notice NXFONTS_FONTID=2; this must be set to the same font ID value that you defined in the include/nuttx/nx/nxfonts.h file. +

    + +
  2. +
  3. +

    + nuttx/graphics/nxfonts/Make.defs. + Set the make variable NXFSET_CSRCS. + NXFSET_CSRCS determines the name of the font C file to build when NXFONTS_FONTID=2: +

    + +
  4. +
  5. +

    + nuttx/graphics/nxfonts/Makefile.sources. + This is the Makefile used in step 5 that will actually generate the font C file. + So, given your NXFONTS_FONTID=2, it needs to determine a prefix to use for auto-generated variable and function names and (again) the name of the autogenerated file to create (this must be the same name that was used in nuttx/graphics/nxfonts/Make.defs): +

    + +
  6. +
  7. +

    + graphics/nxfonts/nxfonts_bitmaps.c. + This is the file that contains the generic font structures. + It is used as a "template&qout; file by nuttx/graphics/nxfonts/Makefile.sources to create your customized font data set at build time. +

    + +

    + Where nxfonts_myfont.h is the NuttX font file that we generated in + step 2 using the bdf-converter tool. +

    +
  8. +

    + graphics/nxfonts/nxfonts_getfont.c. + Finally, we need to extend the logic that does the run-time font lookups so that can find our new font. + The lookup function is NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid). + Note that the lookup is based on the font ID that was defined in step 4. + The new font information needs to be added to data structures used by that function: +

    + +
  9. +
+ + + + + +
+

Appendix D NX Test Coverage

+
+ +

apps/examples/nx. + The primary test tool for debugging NX resides at apps/examples/nx. +

+

Building apps/examples/nx. + NX testing was performed using apps/examples/nx with the + Linux/Cygwin-based NuttX simulator. + Configuration files for building this test can be found in configs/sim/nx + and configs/sim/nx11. + There are two alternative configurations for building the simulation: +

+
    +
  1. + The configuration using the configuration file at configs/sim/nx/defconfig. + This default configuration exercises the NX logic a 8 BPP but provides no visual feedback. + In this configuration, a very simple, simulated framebuffer driver is used that is + based upon a simple region of memory posing as video memory. + That default configuration can be built as follows: + +
  2. +
  3. +

    + The preferred configuration is at configs/sim/nx11/defconfig. + This configuration extends the test with a simulated framebuffer driver + that uses an X window as a framebuffer. + This is a superior test configuration because the X window appears at your desktop + and you can see the NX output. + This preferred configuration can be built as follows: +

    + +

    + Update: + The sim target has suffered some bit-rot over the years and so the following caveats need to be added: +

    +

    +
  4. +
+ +

Test Coverage. + At present, apps/examples/nxt only exercises a subset of NX; + the remainder is essentially untested. + The following table describes the testing performed on each NX API: +

+ +

Table D.1: NXGLIB API Test Coverage

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionSpecial Setup/NotesVerified
nxgl_rgb2yuv()
NO
nxgl_yuv2rgb()
NO
nxgl_rectcopy()
YES
nxgl_rectoffset()
YES
nxgl_vectoradd()
YES
nxgl_vectorsubtract()
YES
nxgl_rectintersect()
YES
nxgl_rectunion()
YES
nxgl_nonintersecting()
YES
nxgl_rectoverlap()
YES
nxgl_rectinside()
YES
nxgl_rectsize()
YES
nxgl_nullrect()
YES
nxgl_runoffset() + Verified by apps/examples/nxlines. + YES
nxgl_runcopy()
NO
nxgl_trapoffset() + Verified by apps/examples/nxlines. + YES
nxgl_trapcopy() + Verified by apps/examples/nxlines. + YES
nxgl_colorcopy
YES
nxgl_splitline + Verified using apps/examples/nxlines. + Generally works well, but has some accuracy/overflow problems wide lines + that are nearly horizontal. + There is a "fudge factor" that seems to eliminate the problem, + but there could still be issues in some configurations. + YES
nxgl_circlepts + Verified by apps/examples/nxlines. + YES
nxgl_circletraps + Verified by apps/examples/nxlines. + YES
+ +

Table D.2: NX Server Callbacks Test Coverage

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionSpecial Setup/NotesVerified
redraw()
YES
position()
YES
mousein()
YES
kbdin()
YES
+ +

Table D.3: NX API Test Coverage

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionSpecial Setup/NotesVerified
nx_runinstance()Change to CONFIG_NX_MULTIUSER=y in the + <NuttX-Directory>/.config file YES
nx_connectinstance()Change to CONFIG_NX_MULTIUSER=y in the + <NuttX-Directory>/.config file YES
nx_open()
YES
nx_disconnect()Change to CONFIG_NX_MULTIUSER=y in the + <NuttX-Directory>/.config file YES
nx_close()
YES
nx_eventhandler()Change to CONFIG_NX_MULTIUSER=y in the + <NuttX-Directory>/.config fileYES
nx_eventnotify()This is not used in the current version of apps/examples/nx, + was tested in a previous version)NO
nx_openwindow()Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the + <NuttX-Directory>/.config fileYES
nx_closewindow()Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the + <NuttX-Directory>/.config fileYES
nx_requestbkgd() + Verified by apps/examples/nxtext and apps/examples/nxhello. + YES
nx_releasebkgd() + Verified by apps/examples/nxtext and apps/examples/nxhello. + YES
nx_getposition()
NO
nx_setposition()Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the + <NuttX-Directory>/.config fileYES
nx_setsize()Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the + <NuttX-Directory>/.config fileYES
nx_raise()Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the + <NuttX-Directory>/.config fileYES
nx_lower()Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the + <NuttX-Directory>/.config fileYES
nx_fill()Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the + <NuttX-Directory>/.config fileYES
nx_getrectangle()
YES
nx_filltrapezoid() + Verified by apps/examples/nxlines. + YES
nx_drawline() + Verified by apps/examples/nxlines. + YES
nx_drawcircle() + Verified by apps/examples/nxlines. + YES
nx_fillcircle() + Verified by apps/examples/nxlines. + YES
nx_setbgcolor()
YES
nx_move()Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the + <NuttX-Directory>/.config fileYES
nx_bitmap()Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the + <NuttX-Directory>/.config file.YES
nx_kbdin()
YES
nx_mousein()
YES
+ + +

Table D.4: NXTK API Test Coverage

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionSpecial Setup/NotesVerified
nxtk_openwindow()
YES
nxtk_closewindow()
YES
nxtk_getposition()
NO
nxtk_setposition()
YES
nxtk_setsize()
YES
nxtk_raise()
YES
nxtk_lower()
YES
nxtk_fillwindow()
YES
nxtk_getwindow()
NO
nxtk_filltrapwindow()
NO
nxtk_drawlinewindow()
YES
nxtk_drawcirclewindow()
YES
nxtk_fillcirclewindow()
YES
nxtk_movewindow()
NO
nxtk_bitmapwindow()
YES
nxtk_opentoolbar()
YES
nxtk_closetoolbar()
YES
nxtk_filltoolbar()
YES
nxtk_gettoolbar()
NO
nxtk_filltraptoolbar()
NO
nxtk_drawlinetoolbar()
NO
nxtk_drawcircletoolbar()
NO
nxtk_fillcircletoolbar()
NO
nxtk_movetoolbar()
NO
nxtk_bitmaptoolbar()
NO
+ +

Table D.5: NXFONTS API Test Coverage

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionSpecial Setup/NotesVerified
nxf_getfonthandle()
YES
nxf_getfontset()
YES
nxf_getbitmap()
YES
nxf_convert_2bpp()
NO
nxf_convert_4bpp()
NO
nxf_convert_8bpp()Use defconfig when building.YES
nxf_convert_16bpp()
YES
nxf_convert_24bpp()
NO
nxf_convert_32bpp()
YES
+ + + + diff --git a/Documentation/NXOrganization.gif b/Documentation/NXOrganization.gif new file mode 100644 index 0000000000..6bae8e5529 Binary files /dev/null and b/Documentation/NXOrganization.gif differ diff --git a/Documentation/NfsHowto.html b/Documentation/NfsHowto.html new file mode 100644 index 0000000000..a6e7d3fb2e --- /dev/null +++ b/Documentation/NfsHowto.html @@ -0,0 +1,388 @@ + + +NFS Client How-To + + +

+ + + + + +
+

NFS Client How-To

+

Last Updated: June 18, 2012

+
+

+ + + + + +
+

Table of Contents

+
+ +
+ + + +
+ + + + + +
+ Adding NFS to the NuttX Configuration +
+ + + + + +
+ Mount Interface +
+ + + + + +
+ NFS Mount Command +
+ + + + + +
+ Configuring the NFS server (Ubuntu) +
+
+ + + + + +
+

Adding NFS to the NuttX Configuration

+
+ +

+ The NFS client is easily added to your configuration: + You simply need to add CONFIG_NFS to your nuttx/.config file. + There are, however, a few dependencies on other system settings: +

+
    +
  1. + First, there are number of things that you must configure in order to be able to use any file system: +
  2. + +
  3. + And there are several dependencies on the networking configuration. + At a minimum, you need to have the following selections: +
  4. + +
+ + + + + +
+

Mount Interface

+
+ +

+ A low-level, C-callable interface is provided to mount a file system. + That interface is called mount() and is mentioned in the porting guide and is prototyped in the header file include/sys/mount.h: +

+ +

+ Synopsis: + mount() attaches the filesystem specified by the source block device name into the root file system at the path specified by target. +

+

+ Input Paramters: +

+

+

+ Returned Values + Zero is returned on success; -1 is returned on an error and errno is set appropriately: +

+

+

+ This same interface can be used to mount a remote, NFS file system using some special parameters. + The NFS mount differs from the normal file system mount in that: (1) there is no block driver for the NFS file system, and (2) special parameters must be passed as data to describe the remote NFS server. + Thus the following code snippet might represent how an NFS file system is mounted: +

+ +

+ NOTE that: (1) the block driver parameter is NULL. + The mount() is smart enough to know that no block driver is needed with the NFS file system. + (2) The NFS file system is identified with the simple string "nfs" + (3) A reference to struct nfs_args is passed as an NFS-specific argument. +

+

+ The NFS-specific interface is described in the file include/nuttx/fs/nfs.h. + There you can see that struct nfs_args is defined as: +

+ + + + + + +
+

NFS Mount Command

+
+ +

+ The NuttShell (NSH) also supports a command called nfsmount + that can be used to mount a remote file system via the NSH command line. +

+

+ Command Syntax: +

+ +

+ Synopsis. + The nfsmount command mounts a network file system in the NuttX pseudo filesystem. + The nfsmount will use NFSv3 UDP protocol to mount the remote file system. +

+

+ Command Line Arguments. + The nfsmount takes three arguments: +

+
    +
  1. + The <server-address> is the IP address of the server exporting the file system you wish to mount. + This implementation of NFS for the NuttX RTOS is only for a local area network, so the server and client must be in the same network. +
  2. +
  3. + The <mount-point > is the location in the NuttX pseudo filesystem where the mounted volume will appear. + This mount point can only reside in the NuttX pseudo filesystem. + By convention, this mount point is a subdirectory under /mnt. + The mount command will create whatever pseudo directories that may be needed to complete the full path (but the full path must not already exist). +
  4. +
  5. + The <remote-path> is the file system / directory being exported from server. + This / directory must have been configured for exportation on the server before when the NFS server was set up. +
  6. +
+ +

+ After the volume has been mounted in the NuttX pseudo filesystem, it may be access in the same way as other objects in the file system. +

+

+ Example. + Suppose that the NFS server has been configured to export the directory /export/shared. + The the following command would mount that file system (assuming that the target also has privileges to mount the file system). +

+ + + + + + +
+

Configuring the NFS server (Ubuntu)

+
+ +

+ Setting up the server will be done in two steps: + First, setting up the configuration file for NFS, and then starting the NFS services. + But first, you need to install the nfs server on Ubuntu with the these two commands: +

+ + +

+ After that, we need to make or choose the directory we want to export from the NFS server. + In our case, we are going to make a new directory called /export. +

+ +

+ It is important that /export directory allow access to everyone (777 permissions) as we will be accessing the NFS share from the client with no authentication. +

+ +

+ When all this is done, we will need to edit the configuration file to set up an NFS server: /etc/exports. + This file contains a list of entries; + each entry indicates a volume that is shared and how it is shared. + For more information for a complete description of all the setup options for this file you can check in the man pages (man export).

+ An entry in /etc/exports will typically look like this: +

+ +

+ So for our example we export /export to the client 10.0.0.2 add the entry: +

+ +

+ In our case we are using all the default options except for the ro that we replaced with rw so that our client will have read and write access to the directory that we are exporting. +

+

+ After we do all the require configurations, we are ready to start the server with the next command: +

+ +

+ Note: If you later decide to add more NFS exports to the /etc/exports file, you will need to either restart NFS daemon +or run command exportfs. +

+ +

Or

+ +

+ Now we can check if the export directory and our mount point is properly set up. +

+ +

+ And also we can verify if NFS is running in the system with: +

+

+

+

+ Now your NFS sever is sharing /export directory to be accessed. +

+ + + diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html new file mode 100644 index 0000000000..a4d7c2a76a --- /dev/null +++ b/Documentation/NuttShell.html @@ -0,0 +1,5306 @@ + + +NuttShell + + +

+ + + + +
+

NuttShell (NSH)

+

Last Updated: February 8, 2016

+
+

+ + + + +
+

Table of Contents

+
+ +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 1.0 Overview +

+ 1.1 Console/NSH Front End +

+ 1.2 Command Overview +

+ 1.3 Conditional Command Execution +

+ 1.4 Looping +

+ 1.5 Built-In Variables +

+ 1.6 Current Working Directory +

+ 1.7 Environment Variables +

+ 1.8 NSH Start-Up Script +
+ 2.0 Commands. +

+ 2.1 Evaluate Expression (test) +

+ 2.2 Add a Routing Table Entry (addroute) +

+ 2.3 Access the ARP table (arp) +

+ 2.4 Base64 Decode (base64dec) +

+ 2.5 Base64 Encode (base64enc) +

+ 2.6 Extract Base File/Directory Name (basename) +

+ 2.7 Terminate a Loop (break) +

+ 2.8 Concatenate Files (cat) +

+ 2.9 Change Current Working Directory (cd) +

+ 2.10 Compare Files (cmp) +

+ 2.11 Copy Files (cp) +

+ 2.12 Show or set the date and time (date) +

+ 2.13 Copy and Convert Files (dd) +

+ 2.14 Delete a Routing Table Entry (delroute) +

+ 2.15 Show volume status (df) +

+ 2.16 Extract Path to a File/Directory (dirname) +

+ 2.17 Echo Strings and Variables (echo) +

+ 2.18 Execute User Code (exec) +

+ 2.19 Exit NSH (exit) +

+ 2.20 Show Memory Manager Status (free) +

+ 2.21 Get File Via TFTP (get) +

+ 2.22 Show Usage Command Usage (help) +

+ 2.23 Hexadecimal Dump of File or Device (hexdump) +

+ 2.24 Manage Network Configuration (ifconfig) +

+ 2.25 Take a network down (ifdown) +

+ 2.26 Bring a network up (ifup) +

+ 2.27 Install an OS module (insmod) +

+ 2.28 Send a signal to a task (kill) +

+ 2.29 Setup/teardown the Loop Device (losetup) +

+ 2.30 List Directory Contents (ls) +

+ 2.31 Show information about installed OS modules (lsmod) +

+ 2.32 Calculate MD5 (md5) +

+ 2.33 Access Memory (mb, mh, and mw) +

+ 2.34 Show Current Tasks and Threads (ps) +

+ 2.35 Create a Directory (mkdir) +

+ 2.36 Create a FAT Filesystem (mkfatfs) +

+ 2.37 Create a FIFO (mkfifo) +

+ 2.38 Create a RAMDISK (mkrd) +

+ 2.39 Mount a File System (mount) +

+ 2.40 Rename a File (mv) +

+ 2.41 Mount an NFS file system (nfsmount) +

+ 2.42 Lookup a network address (nslookup) +

+ 2.43 Change a User's Password (passwd) +

+ 2.44 Check Network Peer (ping/ping6) +

+ 2.45 Shut the system down (poweroff) +

+ 2.46 Send File Via TFTP (put) +

+ 2.47 Show Current Working Directory (pwd) +

+ 2.48 Reset and reboot the system (reboot) +

+ 2.49 Remove a File (rm) +

+ 2.50 Remove a Directory (rmdir) +

+ 2.51 Remove on OS Module (rmmod) +

+ 2.52 Set an Environment Variable (set) +

+ 2.53 Execute an NSH Script (sh) +

+ 2.54 Shut the system down (shutdown) +

+ 2.55 Wait for Seconds (sleep) +

+ 2.56 Time execution of another command (time) +

+ 2.57 Unmount a File System (umount) +

+ 2.58 Print system information (uname) +

+ 2.59 Unset an Environment Variable (unset) +

+ 2.60 URL Decode (urldecode) +

+ 2.61 URL Encode (urlencode) +

+ 2.62 Add a New User (useradd) +

+ 2.63 Delete a user (userdel) +

+ 2.64 Wait for Microseconds (usleep) +

+ 2.65 Get File Via HTTP (wget) +

+ 2.66 Hexadecimal Dump of Memory (xd) +
+ 3.0 Configuration Settings +

+ 3.1 Command Dependencies on Configuration Settings +

+ 3.2 NSH-Specific Configuration Settings +
+ 4.0 Customizing the NuttShell +

+ 4.1 The NSH Library and NSH Initialization +

+ 4.2 NSH Commands +

+ 4.3 NSH "Built-In" Applications +

+ 4.4 Customizing NSH Initialization +
+ 5.0 Shell Login +

+ 5.1 Enabling Shell Logins +

+ 5.2 Verification of Credentials +

+ 5.3 Password Files +

+ 5.4 Creating a Password File for a ROMFS File System +
+ Index +
+ + + + + +
+

1.0 Overview

+
+ +

+ The NSH Library. + The apps/nshlib sub-directory contains the NuttShell (NSH) + library. + This library can easily to linked to produce a NSH application (See as an example apps/examples/nsh). + The NSH Library provides a simple shell application for NuttX. +

+ + + + + +
+

1.1 Console/NSH Front End

+
+ +

+ NSH Consoles. + Using settings in the configuration file, NSH may be configured to use + (1) the serial stdin/out, + (2) a USB serial device (such as CDC/ACM), or + (3) a telnet connection as the console. + Or, perhaps even all at once since or BOTH. + An indefinite number of telnet sessions are supported. +

+

+ Start-Up prompt. + When NSH is started, you will see the a welcome message such the following on the selected console: +

    +NuttShell (NSH)
    +nsh>
    +
+ The greating may also include NuttX versioning information if you are using a versioned copy of NuttX. + nsh> is the NSH prompt and indicates that you may enter a command from the console. +

+

+ Extended Command Line Editing. + By default, NuttX uses a simple command line editor that allows command entry after the nsh> and supports only the backspace key for editing. + However, a more complete command line editor can be selected by setting CONFIG_NSH_CLE=y in the NuttX configuration file. + When that option is selected, the following EMACS-like line editing commands are supported: +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Key Binding + + Editor Action +
+ ^A + + Move cursor to start of the line +
+ ^B + + Move left one character +
+ ^D or Del + + Delete a single character at the cursor position +
+ ^E + + Move cursor to end of current line +
+ ^F + + Move right one character +
+ ^H or Backspace + + Delete character, left (backspace) +
+ ^K + + Delete to the end of the line +
+ ^U + + Delete the entire line +
+ + + + + +
+

1.2 Command Overview

+
+ +

+ Simple, Re-directed, and Background Commands. + The NuttShell (NSH) is a simple shell application. + NSH supports the following commands forms: +

+
    + + + + + + + + + + + + + + + + +
    Simple command:<cmd>
    Command with re-directed output: + <cmd> > <file>
    + <cmd> >> <file> +
    Background command:<cmd> &
    Re-directed background command: + <cmd> > <file> &
    + <cmd> >> <file> & +
+

Where:

+
    + + + + + + + + +
    <cmd> + is any one of the simple commands listed later. +
    <file> + is the full or relative path to any writable object + in the filesystem name space (file or character driver). + Such objects will be referred to simply as files throughout + this document. +
+

+ nice'd Background Commands + NSH executes at the mid-priority (128). Backgrounded commands can + be made to execute at higher or lower priorities using nice: +

+
    + [nice [-d <niceness>>]] <cmd> [> <file>|>> <file>] [&] +
+

+ Where <niceness> is any value between -20 and 19 where lower + (more negative values) correspond to higher priorities. + The default niceness is 10. +

+ +

+ Multiple commands per line. + NSH will accept multiple commands per command line with each command separated with the semi-colon character (;). +

+ +

+ Optional Syntax Extensions + Because these features commit significant resources, it is disabled by default. +

+
    +
  • + CONFIG_NSH_CMDPARMS. + If selected, then the output from commands, from file applications, and from NSH built-in commands can be used as arguments to other commands. + The entity to be executed is identified by enclosing the command line in back quotes. + For example, +

    +

      +set FOO `myprogram $BAR`
      +
    +

    + Will execute the program named myprogram passing it the value of the environment variable BAR. + The value of the environment variable FOO is then set output of myprogram on stdout. +

  • +
  • + CONFIG_NSH_ARGCAT. + Support concatenation of strings with environment variables or command output. For example: +
      +set FOO XYZ
      +set BAR 123
      +set FOOBAR ABC_${FOO}_${BAR}
      +
    + would set the environment variable FOO to XYZ, BAR to 123 and FOOBAR to ABC_XYZ_123. + If CONFIG_NSH_ARGCAT is not selected, then a slightly small FLASH footprint results but then also only simple environment variables like $FOO can be used on the command line. +
  • +
+ + + + + +
+

1.3 Conditional Command Execution

+
+ +

+ An if-then[-else]-fi construct is also supported in order to + support conditional execution of commands. This works from the + command line but is primarily intended for use within NSH scripts + (see the sh commnd). The syntax is as follows: +

+
    +if <cmd>
    +then
    +  [sequence of <cmd>]
    +else
    +  [sequence of <cmd>]
    +fi
    +
+ + + + + +
+

1.4 Looping

+
+ +

Looping Constructs. + while-do-done and until-do-done looping constructs are also supported. + These work from the command line but are primarily intended for use within NSH scripts + (see the sh command). +

+
    +
  • +

    while-do-done. + Execute [sequence of <cmd>] as long as <cmd> has an exit status of zero. + The syntax is as follows: +

      +while <cmd>
      +do
      +  [sequence of <cmd>]
      +done
      +
    +

    +
  • +
  • +

    until-do-done + Execute [sequence of <cmd>] as long as <cmd> has a non-zero exit status. + The syntax is as follows: +

      +until <cmd>
      +do
      +  [sequence of <cmd>]
      +done
      +
    +

    +
  • +
+ +

The break Command. + A break command is also supported. + The break command is only meaningful within the body of the a while or until loop, between the do and done tokens. + If the break command is executed within the body of a loop, the loop will immediately terminate and execution will continue with the next command immediately following the done token. +

+ + + + + +
+

1.5 Built-In Variables

+
+ +

    + + + + +
    $? + The result of the last simple command execution. + On backgrounded commands, this variable holds only the result of spawning the background command. +
+ + + + + +
+

1.6 Current Working Directory

+
+ +

+ cd and pwd. + All path arguments to commands may be either an absolute path or a + path relative to the current working directory. The current working + directory is set using the cd command and can be queried either + by using the pwd command or by + using the echo $PWD + command. +

+ + + + + +
+

1.7 Environment Variables

+
+ +

+ Environment Variables: +

+
    + + + + + + +
    PWDThe current working directory
    OLDPWDThe previous working directory
+ + + + + +
+

1.8 NSH Start-Up Script

+
+ +

+ NSH Start-Up Script. + NSH supports options to provide a start up script for NSH. In general + this capability is enabled with CONFIG_NSH_ROMFSETC, but has + several other related configuration options as described with the + NSH-specific configuration settings. + This capability also depends on: +

    +
  • CONFIG_DISABLE_MOUNTPOINT not set +
  • CONFIG_NFILE_DESCRIPTORS > 4 +
  • CONFIG_FS_ROMFS enabled +
+

+ +

+ Default Start-Up Behavior. + The implementation that is provided is intended to provide great flexibility + for the use of Start-Up files. This paragraph will discuss the general + behavior when all of the configuration options are set to the default + values. +

+

+ In this default case, enabling CONFIG_NSH_ROMFSETC will cause + NSH to behave as follows at NSH startup time: +

    +
  • + NSH will create a read-only RAM disk (a ROM disk), containing a tiny + ROMFS filesystem containing the following: +
      +`--init.d/
      +     `-- rcS
      +
    + Where rcS is the NSH start-up script. +
  • +
  • + NSH will then mount the ROMFS filesystem at /etc, resulting in: +
      +|--dev/
      +|   `-- ram0
      +`--etc/
      +    `--init.d/
      +        `-- rcS
      +
    +
  • +
  • + By default, the contents of rcS script are: +
      +# Create a RAMDISK and mount it at XXXRDMOUNTPOINTXXX
      +
      +mkrd -m 1 -s 512 1024
      +mkfatfs /dev/ram1
      +mount -t vfat /dev/ram1 /tmp
      +
    +
  • +
  • + NSH will execute the script at /etc/init.d/rcS at start-up (before the + first NSH prompt. After execution of the script, the root FS will look + like: +
      +|--dev/
      +|   |-- ram0
      +|   `-- ram1
      +|--etc/
      +|   `--init.d/
      +|       `-- rcS
      +`--tmp/
      +
    +
  • +
+

+

+ Modifying the ROMFS Image. + The contents of the /etc directory are retained in the file apps/nshlib/nsh_romfsimg.h OR, if CONFIG_NSH_ARCHROMFS is defined, include/arch/board/rcs.template). + In order to modify the start-up behavior, there are three things to study: +

    +
  1. + Configuration Options. + The additional CONFIG_NSH_ROMFSETC configuration options + discussed with the other NSH-specific configuration settings. +
  2. +
  3. +

    + tools/mkromfsimg.sh Script. + The script tools/mkromfsimg.sh creates nsh_romfsimg.h. + It is not automatically executed. If you want to change the + configuration settings associated with creating and mounting + the /tmp directory, then it will be necessary to re-generate + this header file using the tools/mkromfsimg.sh script. +

    +

    + The behavior of this script depends upon three things: +

      +
    • The configuration settings then installed configuration. +
    • The genromfs tool (available from http://romfs.sourceforge.net). +
    • The file apps/nshlib/rcS.template + (OR, if CONFIG_NSH_ARCHROMFS is defined include/arch/board/rcs.template. +
    +

    +
  4. +
  5. + rcS.template. + The file apps/nshlib/rcS.template contains the general form + of the rcS file; configured values are plugged into this + template file to produce the final rcS file. +
  6. +
+

+

+ NOTE: + apps/nshlib/rcS.template generates the standard, default nsh_romfsimg.h file. + If CONFIG_NSH_ARCHROMFS is defined in the NuttX configuration file, then a custom, board-specific nsh_romfsimg.h file residing in configs/<board>/include will be used. + NOTE when the OS is configured, include/arch/board will be linked to configs/<board>/include. +

+

+ All of the startup-behavior is contained in rcS.template. The + role of mkromfsimg.sh is to (1) apply the specific configuration + settings to rcS.template to create the final rcS, and (2) to + generate the header file nsh_romfsimg.h containg the ROMFS + file system image. +

+ +

+ Further Information. + See the section on Customizing the NuttShell for additional, more detailed information about the NSH start-up script and how to modify it. +

+ + + + + +
+

2.0 Commands

+
+ + + + + +
+

2.1 Evaluate Expression (test)

+
+ +

Command Syntax:

+
    +[ <expression> ]
    +test <expression>
    +
+

+ Synopsis. + These are two alternative forms of the same command. They support + evaluation of a boolean expression which sets $?. + This command is used most frequently as the conditional command following the + if in the if-then[-else]-fi construct. +

+

Expression Syntax:

+
    +

    + expression = simple-expression | !expression | expression -o expression | expression -a expression +

    +

    + simple-expression = unary-expression | binary-expression +

    +

    + unary-expression = string-unary | file-unary +

    +

    + string-unary = -n string | -z string +

    +

    + file-unary = -b file | -c file | -d file | -e file | -f file | -r file | -s file | -w file +

    +

    + binary-expression = string-binary | numeric-binary +

    +

    + string-binary = string = string | string == string | string != string +

    +

    + numeric-binary = integer -eq integer | integer -ge integer | integer -gt integer | integer -le integer | + integer -lt integer | integer -ne integer +

    +
+ + + + + +
+

2.2 Add a Routing Table Entry (addroute)

+
+ +

Command Syntax:

+
    +addroute <target> <netmask> <router>
    +
+

+ Synopsis. + This command adds an entry in the routing table. + The new entry will map the IP address of a router on a local network(<router>) to an external network characterized by the <target> IP address and a network mask <netmask> +

+

+ Example: +

+
    +nsh> addroute 1.1.1.1 2.2.2.2 3.3.3.3
    +
+ + + + + +
+

2.3 Access the ARP table (arp)

+
+ +

Command Syntax:

+
    +arp [-a <ipaddr> |-d <ipaddr> |-s <ipaddr> <hwaddr>]
    +
+

+ Synopsis. + Access the OS ARP table. +

+
    +
    -a <ipaddr> +
    Will show the hardware address that the IP address <ipaddr> is mapped to. + +
    -d <ipaddr> +
    Will delete the mapping for the IP address <ipaddr> from the ARP table. + +
    -s <ipaddr> <hwaddr> +
    Will set (or replace) the mapping of the IP address <ipaddr> to the hardware address <hwaddr>. +
+

+ Example: +

+
    +nsh> arp -a 10.0.0.1
    +nsh: arp: no such ARP entry: 10.0.0.1
    +
    +nsh> arp -s 10.0.0.1 00:13:3b:12:73:e6
    +nsh> arp -a 10.0.0.1
    +HWAddr: 00:13:3b:12:73:e6
    +
    +nsh> arp -d 10.0.0.1
    +nsh> arp -a 10.0.0.1
    +nsh: arp: no such ARP entry: 10.0.0.1
    +
+ + + + + +
+

2.4 Base64 Decode (base64dec)

+
+ +

Command Syntax:

+
    +base64dec [-w] [-f] <string or filepath>
    +
+

+ Synopsis. + To be provided. +

+ + + + + +
+

2.5 Base64 Encode (base64enc)

+
+ +

Command Syntax:

+
    +base64enc [-w] [-f] <string or filepath>
    +
+

+ Synopsis. + To be provided. +

+ + + + + +
+

2.6 Extract Base File/Directory Name (basename)

+
+

Command Syntax:

+
    +basename <path> [<suffix>]
    +
+

+ Synopsis. + Extract the final string from a <path> by removing the preceding path + segments and (optionally) removing any trailing <suffix>. +

+ + + + + +
+

2.7 Terminate a Loop (break)

+
+ +

Command Syntax:

+
    +break
    +
+

+ Synopsis. + The break command is only meaningful within the body of the a while or until loop, between the do and done tokens. + Outside of a loop, break command does nothing. + If the break command is executed within the body of a loop, the loop will immediately terminate and execution will continue with the next command immediately following the done token. +

+ + + + + +
+

2.8 Concatenate Files (cat)

+
+ +

Command Syntax:

+
    +cat <path> [<path> [<path> ...]]
    +
+

+ Synopsis. + This command copies and concatentates all of the files at <path> + to the console (or to another file if the output is redirected). +

+ + + + + +
+

2.9 Change Current Working Directory (cd)

+
+ +

Command Syntax:

+
    +cd [<dir-path>|-|~|..]
    +
+

+ Synopsis. + Changes the current working directory (PWD). Also sets the + previous working directory environment variable (OLDPWD). +

+

Forms:

+
    + + + + + + + + + + + + + + + + +
    cd <dir-path>sets the current working directory to <dir-path>.
    cd -sets the current working directory to the previous + working directory ($OLDPWD). + Equivalent to cd $OLDPWD.
    cd or cd ~set the current working directory to the 'home' + directory. The home directory can be configured by setting + CONFIG_LIB_HOMEDIR in the configuration file. The default + home directory is /.
    cd ..sets the current working directory to the parent directory.
+ + + + + +
+

2.10 Compare Files (cmp)

+
+ +

Command Syntax:

+
    +cmp <path1> <path2>
    +
+

+ Synopsis. + Compare of the contents of the file at <path1> with the contents of the file at <path2>. Returns an indication only if the files differ. +

+ + + + + +
+

2.11 Copy Files (cp)

+
+ +

Command Syntax:

+
    +cp <source-path> <dest-path>
    +
+

+ Synopsis. + Copy of the contents of the file at <source-path> to the location + in the filesystem indicated by <dest-path>. +

+ + + + + +
+

2.12 Show or set the date and time (date)

+
+

Command Syntax:

+
    +date [-s "MMM DD HH:MM:SS YYYY"]
    +
+

+ Synopsis. + Show or set the current date and time. +

+

+ Only one format is used both on display and when setting the date/time: + MMM DD HH:MM:SS YYYY. For example, +

    +data -s "Sep 1 11:30:00 2011"
    +
+

+

+ 24-hour time is used. +

+ + + + + +
+

2.13 Copy and Convert Files (dd)

+
+

Command Syntax:

+
    +dd if=<infile> of=<outfile> [bs=<sectsize>] [count=<sectors>] [skip=<sectors>]
    +
+

+ Synopsis. + Copy blocks from <infile> to <outfile>. + <infile> or <outfile> may be the path to a standard file, a character device, or a block device. + Examples follow: +

+
    +
  1. + Read from character device, write to regular file. + This will create a new file of the specified size filled with zero. +
      +nsh> ls -l /dev
      +/dev:
      + crw-rw-rw-       0 zero
      +nsh> dd if=/dev/zero of=/tmp/zeros bs=64 count=16
      +nsh> ls -l /tmp
      +/tmp:
      + -rw-rw-rw-    1024 ZEROS
      +
    +
  2. +
  3. + Read from character device, write to block device. + This will fill the entire block device with zeros. +
  4. +
      +nsh> ls -l /dev
      +/dev:
      + brw-rw-rw-       0 ram0
      + crw-rw-rw-       0 zero
      +nsh> dd if=/dev/zero of=/dev/ram0
      +
    + +
  5. + Read from a block devic, write to a character device. This + will read the entire block device and dump the contents in + the bit bucket. +
  6. +
      +nsh> ls -l /dev
      +/dev:
      + crw-rw-rw-       0 null
      + brw-rw-rw-       0 ram0
      +nsh> dd if=/dev/ram0 of=/dev/null
      +
    + +
+ + + + + +
+

2.14 Delete a Routing Table Entry (delroute)

+
+ +

Command Syntax:

+
    +delroute <target> <netmask>
    +
+

+ Synopsis. + The entry removed will be the first entry in the routing table that matches + the external network characterized by the <target> IP address and the network mask <netmask> +

+ Example: +

+
    +nsh> delroute 1.1.1.1 2.2.2.2
    +
+ + + + + +
+

2.15 Show Volume Status (df)

+
+ +

Command Syntax:

+
    +df [-h]
    +
+

+ Synopsis. + Show the state of each mounted volume. + As an example: +

+
    +nsh> mount
    +  /etc type romfs
    +  /tmp type vfat
    +nsh> df
    +  Block  Number
    +  Size   Blocks     Used Available Mounted on
    +    64        6        6         0 /etc
    +   512      985        2       983 /tmp
    +nsh>
    +
+

+ If CONFIG_NSH_CMDOPT_DF_H is defined in the NuttX configuration, then the df will also support an option -h which may be used to show the volume information in human readable format. +

+ + + + + +
+

2.16 Extract Path to a File/Directory (dirname)

+
+

Command Syntax:

+
    +dirname <path>
    +
+

+ Synopsis. + Extract the path string leading up to the full <path> by removing + the final directory or file name. +

+ + + + + +
+

2.17 Echo Strings and Variables (echo)

+
+ +

Command Syntax:

+
    +echo [<string|$name> [<string|$name>...]]
    +
+

+ Synopsis. + Copy the sequence of strings and expanded environment variables to + console output (or to a file if the output is re-directed). +

+ + + + + +
+

2.18 Execute User Code (exec)

+
+ +

Command Syntax:

+
    +exec <hex-address>
    +
+

+ Synopsis. + Execute the user logic at address <hex-address>. NSH will pause + until the execution unless the user logic is executed in background + via exec <hex-address> &. +

+ + + + + +
+

2.19 Exit NSH (exit)

+
+ +

Command Syntax:

+
    +exit
    +
+

+ Synopsis. + Exit NSH. Only useful for the serial front end if you have started some other tasks (perhaps + using the exec command) and you would like to have NSH out of the + way. For the telnet front-end, exit terminates the telenet session. +

+ + + + + +
+

2.20 Show Memory Manager Status (free)

+
+ +

Command Syntax:

+
    +free
    +
+

+ Synopsis. + Show the current state of the memory allocator. For example, +

+
    +nsh> free
    +             total       used       free    largest
    +Mem:       4194288    1591552    2602736    2601584
    +nsh>
    +
+

Where:

+
    + + + + + + + + + + + + + + + + +
    totalThis is the total size of memory allocated for use by malloc in bytes.
    usedThis is the total size of memory occupied by chunks handed out by malloc.
    freeThis is the total size of memory occupied by free (not in use) chunks.
    largestSize of the largest free (not in use) chunk.
+ + + + + +
+

2.21 Get File Via TFTP (get)

+
+ +

Command Syntax:

+
    +get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path>
    +
+

+ Synopsis. + Copy the file at <remote-address> from the host whose IP address is + identified by <ip-address>. +

+

Other options:

+
    + + + + + + + + +
    -f <local-path> + The file will be saved relative to the current working directory + unless <local-path> is provided. +
    -b|-n + Selects either binary ("octet") or test ("netascii") transfer + mode. Default: text. +
+ + + + + +
+

2.22 Show Usage Command Usage (help)

+
+ +

Command Syntax:

+
    +help [-v] [<cmd>]
    +
+

+ Synopsis. + Presents summary information about NSH commands to console. +

+

Options:

+
    + + + + + + + + +
    -v + how verbose output will full command usage. +
    <cmd> + Show full command usage only for this command. +
+ + + + + +
+

2.23 Hexadecimal Dump of File or Device (hexdump)

+
+ +

Command Syntax:

+
    +hexdump <file or device>
    +
+

+ Synopsis. + Dump data in hexadecimal format from a file or character device. +

+ +

+ +
+ + + +
+

2.24 Manage Network Configuration (ifconfig)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Multiple forms of the ifconfigcommand are supported: +

+
    +
  1. +

    + With one or no arguments, ifconfig will shows the + current configuration of the network and, perhaps, the status of ethernet + device: +

    +
      +ifconfig
      +ifconfig [nic_name]
      +
    +

    + As an example: +

    +
      +nsh> ifconfig
      +eth0    HWaddr 00:18:11:80:10:06
      +        IPaddr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0
      +
    +

    + If network statistics are enabled (CONFIG_NET_STATISTICS), then + this command will also show the detailed state of network. +

    +
  2. +
  3. +

    + If both the network interface name and an IP address are supplied as arguments, + then ifconfig will set the address of the ethernet device: +

    +
      +ifconfig nic_name ip_address
      +
    +
  4. +
  5. + Other forms to be provided +
  6. +
+

+NOTE: This commands depends upon having the procfs file system configured into the system. +The procfs file system must also have been mounted with a command like: +

+ +

+ + + + + +
+

2.25 Take a network down (ifdown)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Take down the interface identified by the name <nic-name>. +

+

+ Example: +

+ + + + + + +
+

2.26 Bring a network up (ifup)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Bring up down the interface identified by the name <nic-name>. +

+

+ Example: +

+ + + + + + +
+

2.27 Install an OS module (insmod)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Install the loadable OS module at <file-path> as module <module-name>. +

+

Example:

+ + + + + + +
+

2.28 Send a signal to a task (kill)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Send the <signal> to the task identified by <pid>. +

+

Example:

+ +

+ NOTE: + NuttX does not support a FULL POSIX signalling system. + Standard signals like SIGCHLD, SIGINTR, SIGKILL, etc. do not exist in NuttX and sending those signal may not have the result that you expect. + Rather, NuttX supports only what are referred to as POSIX real-time signals. + These signals may be used to communicate with running tasks, may be use to waiting waiting tasks, etc. + But, as an example, kill -9 (SIGKILL) will not terminate a task. +

+ + + + + +
+

2.29 Setup/teardown the Loop Device (losetup)

+
+ +

Command Syntax 1:

+ +

+ Synopsis. + Setup the loop device at <dev-path> to access the file at <file-path> as a block device. + In the following example a 256K file is created (dd) and losetup is + used to make the file accessible as a block device. + A FAT file system is created (mkfatfs) and mounted (mount). + Files can then be managed on the loop-mounted file. +

+

+ +

Command Syntax 2:

+ +

+ Synopsis. + Teardown the setup for the loop device at <dev-path>. +

+ + + + + +
+

2.30 List Directory Contents (ls)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Show the contents of the directory at <dir-path>. NOTE: + <dir-path> must refer to a directory and no other filesystem + object. +

+

Options:

+ + + + + + + +
+

2.31 Show information about installed OS modules (lsmod)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Show information about the currently installed OS modules. This information includes: +

+ +

Example:

+ + + + + + +
+

2.32 Calculate MD5 (md5)

+
+ +

Command Syntax:

+ +

+ Synopsis. + To be provided. +

+ + + + + +
+

2.33 Access Memory (mb, mh, and mw)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Access memory using byte size access (mb), 16-bit accesses (mh), + or 32-bit access (mw). In each case, +

+ +

Example:

+

+ + + + + +
+

2.34 Show Current Tasks and Threads (ps)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Show the currently active threads and tasks. For example, +

+ +

+NOTE: This commands depends upon having the procfs file system configured into the system. +The procfs file system must also have been mounted with a command like: +

+ +

+ + + + + +
+

2.35 Create a Directory (mkdir)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Create the directory at <path>. + All components of of <path> except the final directory name must exist on a mounted file + system; the final directory must not. +

+

+ Limited to Mounted File Systems. + Recall that NuttX uses a pseudo filesystem for its root file + system. + The mkdir command can only be used to create directories in volumes set up with the + mount command; it cannot be used to create directories in the pseudo filesystem. +

+

Example:

+ + + + + + +
+

2.36 Create a FAT Filesystem (mkfatfs)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Format a fat file system on the block device specified by <block-driver> path. + The FAT size may be provided as an option. + Without the <fatsize> option, mkfatfs will select either the FAT12 or FAT16 format. + For historical reasons, if you want the FAT32 format, it must be explicitly specified on the command line. +

+

+ NSH provides this command to access the mkfatfs() NuttX API. + This block device must reside in the NuttX pseudo filesystem and + must have been created by some call to register_blockdriver() (see include/nuttx/fs/fs.h). +

+ + + + + +
+

2.37 Create a FIFO (mkfifo)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Creates a FIFO character device anywhere in the pseudo file system, creating + whatever pseudo directories that may be needed to complete the <path>. + By convention, however, device drivers are place in the standard /dev directory. + After it is created, the FIFO device may be used as any other device driver. + NSH provides this command to access the mkfifo() NuttX API. +

+

Example

+ + + + + + +
+

2.38 Create a RAMDISK (mkrd)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Create a ramdisk consisting of <nsectors>, each of size + <sector-size> (or 512 bytes if <sector-size> is not specified. + The ramdisk will be registered as /dev/ram<n> (if <n> is not + specified, mkrd will attempt to register the ramdisk as /dev/ram0. +

+

Example

+ +

+ Once the ramdisk has been created, it may be formatted using + the mkfatfs command and mounted using the mount command. +

+

Example

+ + + + + + +
+

2.39 Mount a File System (mount)

+
+ +

Command Syntax:

+ +

+ Synopsis. + The mount command performs one of two different operations. + If no parameters are provided on the command line after the mount command, then the mount command will enumerate all of the current mountpoints on the console. +

+

+ If the mount parameters are provied on the command after the mount command, then the mount command will mount a file system in the NuttX pseudo-file system. + mount' performs a three way association, binding: +

+
    +
  1. File system. + The '-t <fstype>' option identifies the type of + file system that has been formatted on the <block-device>. + As of this writing, vfat is the only supported value for <fstype> +
  2. +
  3. Block Device. + The <block-device> argument is the full or relative + path to a block driver inode in the pseudo filesystem. + By convention, this is a name under the /dev sub-directory. + This <block-device> must have been previously formatted with the same file system + type as specified by <fstype> +
  4. +
  5. Mount Point. + The mount point, <dir-path>, is the location in the + pseudo filesystem where the mounted volume will appear. + This mount point can only reside in the NuttX pseudo filesystem. + By convention, this mount point is a subdirectory under /mnt. + The mount command will create whatever pseudo directories that may be needed to complete the + full path but the full path must not already exist. +
  6. +
+

+ After the volume has been mounted in the NuttX + pseudo filesystem, + it may be access in the same way as other objects in thefile system. +

+

Examples:

+

Using mount to mount a file system:

+ +

Using mount to enumerate mounts:

+ + + + + + +
+

2.40 Rename a File (mv)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Rename the file object at <old-path> to <new-path>. + Both paths must reside in the same mounted filesystem. +

+ + + + + +
+

2.41 Mount an NFS file system (nfsmount)

+
+ + +

Command Syntax:

+ +

+ Synopsis. + Mount the remote NFS server directory<remote-path> at <mount-point> on the target machine. + <server-address> is the IP address of the remote server. +

+ + + + + +
+

2.42 Lookup a network address (nslookup)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Lookup and print the IP address associated with <host-name>. +

+ + + + + +
+

2.43 Change a User's Password (passwd)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Set the password for the existing user <username> to <password>. +

+ + + + + +
+

2.44 Check Network Peer (ping/ping6)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Test the network communication with a remote peer. Example, +

+ +

+ ping6 differs from ping in that it uses IPv6 addressing. +

+ + + + + +
+

2.45 Shut the system down (poweroff)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Shutdown and power off the system immediately. + This command depends on hardware support to power down the system. +

+

+ NOTE: Supporting both the poweroff and shutdown commands is redundant. +

+ + + + + + +
+

2.46 Send File Via TFTP (put)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Copy the file at <local-address> to the host whose IP address is + identified by <ip-address>. +

+

Other options:

+ + + + + + +
+

2.47 Show Current Working Directory (pwd)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Show the current working directory. +

+ + +

Same as echo $PWD.

+ + + + + + +
+

2.48 Reboot the system (reboot)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Reset and reboot the system immediately. + This command depends on hardware support to reset the system. +

+

+

+ NOTE: Supporting both the reboot and shutdown commands is redundant. +

+ + + + + +
+

2.49 Remove a File (rm)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Remove the specified <file-path> name from the mounted file system. + Recall that NuttX uses a pseudo filesystem for its root file + system. + The rm command can only be used to remove (unlink) files in volumes set up with the + mount command; + it cannot be used to remove names in the pseudo filesystem. +

+

Example:

+ + + + + + +
+

2.50 Remove a Directory (rmdir)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Remove the specified <dir-path> directory from the mounted file system. + Recall that NuttX uses a pseudo filesystem for its root file + system. + The rmdir command can only be used to remove directories from volumes set up with the + mount command; + it cannot be used to remove directories from the pseudo filesystem. +

+

Example:

+ + + + + + +
+

2.51 Remove on OS Module (rmmod)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Remove the loadable OS module with the <module-name>. + NOTE: An OS module can only be removed if it is not busy. +

+

Example:

+ + + + + + +
+

2.52 Set an Environment Variable (set)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Set the environment variable <name> to the string <value>. + For example, +

+ + + + + + +
+

2.53 Execute an NSH Script (sh)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Execute the sequence of NSH commands in the file referred + to by <script-path>. +

+ + + + + + +
+

2.54 Shut the system down (shutdown)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Shutdown and power off the system or, optionally, reset and reboot the system immediately. + This command depends on hardware support to power down or reset the system; one, both, or neither behavior may be supported. +

+

+ NOTE: The shutdown command duplicates the behavior of the poweroff and eboot commands. +

+ + + + + +
+

2.55 Wait for Seconds (sleep)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Pause execution (sleep) for <sec> seconds. +

+ + + + + +
+

2.56 Time execution of another command (time)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Perform command timing. + This command will execute the following <command> string and then show how much time was required to execute the command. + Time is shown with a resolution of 100 microseconds which may be beyond the resolution of many configurations. + Note that the <command> must be enclosed in quotation marks if it contains spaces or other delimiters. +

+

Example:

+ +

+ The additional 10 millseconds in this example is due to the way that the sleep command works: It always waits one system clock tick longer than requested and this test setup used a 10 millisecond periodic system + timer. + Sources of error could include various quantization errors, competing CPU usage, and the additional overhead of the time command execution itself which is included in the total. +

+

+ The reported time is the elapsed time from starting of the command to completion of the command. + This elapsed time may not necessarily be just the processing time for the command. + It may included interrupt level processing, for example. + In a busy system, command processing could be delayed if pre-empted by other, higher priority threads competing for CPU time. + So the reported time includes all CPU processing from the start of the command to its finish possibly including unrelated processing time during that interval. +

+

+ Notice that: +

+ +

+ Since the sleep command is executed in background, the sleep command completes almost immediately. + As opposed to the following where the time command is run in background with the sleep command: +

+ + + + + + +
+

2.57 Unmount a File System (umount)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Un-mount the file system at mount point <dir-path>. + The umount command can only be used to un-mount volumes previously mounted using + mount command. +

+

Example:

+ + + + + + +
+

2.58 Print system information (uname)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Print certain system information. With no options, the output is the same as -s. +

+

+ + + + + +
+

2.59 Unset an Environment Variable (unset)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Remove the value associated with the environment variable + <name>. Example: +

+ + + + + + +
+

2.60 URL Decode (urldecode)

+
+ +

Command Syntax:

+ +

+ Synopsis. + To be provided. +

+ + + + + +
+

2.61 URL Encode (urlencode)

+
+ +

Command Syntax:

+ +

+ Synopsis. + To be provided. +

+ + + + + +
+

2.62 Add a New User (useradd)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Add a new user with <username> and <password>. +

+ + + + + +
+

2.63 Delete a user (userdel)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Delete the user with the name <username>. +

+ + + + + +
+

2.64 Wait for Microseconds (usleep)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Pause execution (sleep) of <usec> microseconds. +

+ + + + + +
+

2.65 Get File Via HTTP (wget)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Use HTTP to copy the file at <url> to the current directory. +

+

Options:

+ + + + + + +
+

2.66 Hexadecimal Dump of Memory (xd)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Dump <byte-count> bytes of data from address <hex-address>. +

+

Example:

+ + + + + + +
+

3.0 Configuration Settings

+
+ +

+ The availability of the above commands depends upon features that + may or may not be enabled in the NuttX configuration file. The + following table indicates the dependency of each command on NuttX + configuration settings. General configuration settings are discussed + in the NuttX Porting Guide. + Configuration settings specific to NSH as discussed at the bottom of this document. +

+ +

+ Note that in addition to general NuttX configuation settings, each NSH command can be + individually disabled via the settings in the rightmost column. + All of these settings make the configuration of NSH potentially complex but also allow it to + squeeze into very small memory footprints. +

+ + + + + +
+

3.1 Command Dependencies on Configuration Settings

+
+ +

Table. Command Dependencies on Configuration Settings

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CommandDepends on ConfigurationCan Be Disabled with
[!CONFIG_NSH_DISABLESCRIPTCONFIG_NSH_DISABLE_TEST
addrouteCONFIG_NET && CONFIG_NET_ROUTECONFIG_NSH_DISABLE_ADDROUTE
arpCONFIG_NET && CONFIG_NET_ARPCONFIG_NSH_DISABLE_ARP
base64decCONFIG_NETUTILS_CODECS && CONFIG_CODECS_BASE64CONFIG_NSH_DISABLE_BASE64DEC
base64encCONFIG_NETUTILS_CODECS && CONFIG_CODECS_BASE64CONFIG_NSH_DISABLE_BASE64ENC
basename CONFIG_NSH_DISABLE_BASENAME
break!CONFIG_NSH_DISABLESCRIPT && !CONFIG_NSH_DISABLE_LOOPS 
catCONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_CAT
cd!CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_CD
cmpCONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_CMP
cpCONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_CP
date
CONFIG_NSH_DISABLE_DATE
ddCONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_DD
delrouteCONFIG_NET && CONFIG_NET_ROUTECONFIG_NSH_DISABLE_DELROUTE
df!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE3CONFIG_NSH_DISABLE_DF
dirname CONFIG_NSH_DISABLE_DIRNAME
echo
CONFIG_NSH_DISABLE_ECHO
exec
CONFIG_NSH_DISABLE_EXEC
exit
CONFIG_NSH_DISABLE_EXIT
free
CONFIG_NSH_DISABLE_FREE
getCONFIG_NET && CONFIG_NET_UDP && + CONFIG_NFILE_DESCRIPTORS > 0 && MTU >= 5581CONFIG_NSH_DISABLE_GET
help5
CONFIG_NSH_DISABLE_HELP
hexdumpCONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_HEXDUMP
ifconfigCONFIG_NET && CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_NETCONFIG_NSH_DISABLE_IFCONFIG
ifdownCONFIG_NET && CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_NETCONFIG_NSH_DISABLE_IFUPDOWN
ifupCONFIG_NET && CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_NETCONFIG_NSH_DISABLE_IFUPDOWN
insmodCONFIG_MODULECONFIG_NSH_DISABLE_MODCMDS
kill!CONFIG_DISABLE_SIGNALSCONFIG_NSH_DISABLE_KILL
losetup!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_DEV_LOOPCONFIG_NSH_DISABLE_LOSETUP
lsCONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_LS
lsmodCONFIG_MODULE && CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_MODULECONFIG_NSH_DISABLE_MODCMDS
md5CONFIG_NETUTILS_CODECS && CONFIG_CODECS_HASH_MD5CONFIG_NSH_DISABLE_MD5
mb,mh,mw
+ CONFIG_NSH_DISABLE_MB,
+ CONFIG_NSH_DISABLE_MH,
+ CONFIG_NSH_DISABLE_MW +
mkdir(((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0)4CONFIG_NSH_DISABLE_MKDIR
mkfatfs!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FATCONFIG_NSH_DISABLE_MKFATFS
mkfifoCONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_MKFIFO
mkrd!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE4CONFIG_NSH_DISABLE_MKRD
mount!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE3CONFIG_NSH_DISABLE_MOUNT
mv(((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0)4CONFIG_NSH_DISABLE_MV
nfsmount!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET && CONFIG_NFSCONFIG_NSH_DISABLE_NFSMOUNT
nslookupCONFIG_LIBC_NETDB && CONFIG_NETDB_DNSCLIENTCONFIG_NSH_DISABLE_NSLOOKUP
passwd!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE && CONFIG_NSH_LOGIN_PASSWDCONFIG_NSH_DISABLE_PASSWD
pingCONFIG_NET && CONFIG_NET_ICMP && + CONFIG_NET_ICMP_PING && !CONFIG_DISABLE_SIGNALSCONFIG_NSH_DISABLE_PING
ping6CONFIG_NET && CONFIG_NET_ICMPv6 && + CONFIG_NET_ICMPv6_PING && !CONFIG_DISABLE_SIGNALSCONFIG_NSH_DISABLE_PING6
poweroffCONFIG_BOARDCTL_POWEROFFCONFIG_NSH_DISABLE_POWEROFF
psCONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_PROCCONFIG_NSH_DISABLE_PS
putCONFIG_NET && CONFIG_NET_UDP && + CONFIG_NFILE_DESCRIPTORS > 0 && MTU >= 5581,2CONFIG_NSH_DISABLE_PUT
pwd!CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_PWD
rebootCONFIG_BOARD_RESETCONFIG_NSH_DISABLE_REBOOT
rm(((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0)4CONFIG_NSH_DISABLE_RM
rmdir(((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0)4CONFIG_NSH_DISABLE_RMDIR
rmmodCONFIG_MODULECONFIG_NSH_DISABLE_MODCMDS
set!CONFIG_DISABLE_ENVIRONCONFIG_NSH_DISABLE_SET
shCONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !CONFIG_NSH_DISABLESCRIPTCONFIG_NSH_DISABLE_SH
shutdownCONFIG_BOARDCTL_POWEROFF || CONFIG_BOARD_RESETCONFIG_NSH_DISABLE_SHUTDOWN
sleep!CONFIG_DISABLE_SIGNALSCONFIG_NSH_DISABLE_SLEEP
test!CONFIG_NSH_DISABLESCRIPTCONFIG_NSH_DISABLE_TEST
time CONFIG_NSH_DISABLE_TIME
umount!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE3CONFIG_NSH_DISABLE_UMOUNT
unamebrCONFIG_NSH_DISABLE_UNAME
unset!CONFIG_DISABLE_ENVIRONCONFIG_NSH_DISABLE_UNSET
urldecode!CONFIG_NETUTILS_CODECS && CONFIG_CODECS_URLCODE + CONFIG_NSH_DISABLE_URLDECODE
urlencode!CONFIG_NETUTILS_CODECS && CONFIG_CODECS_URLCODE + CONFIG_NSH_DISABLE_URLENCODE
useradd!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE && CONFIG_NSH_LOGIN_PASSWDCONFIG_NSH_DISABLE_USERADD
userdel!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE && CONFIG_NSH_LOGIN_PASSWDCONFIG_NSH_DISABLE_USERDEL
usleep!CONFIG_DISABLE_SIGNALSCONFIG_NSH_DISABLE_USLEEP
wgetCONFIG_NET && CONFIG_NET_TCP && + CONFIG_NFILE_DESCRIPTORS > 0CONFIG_NSH_DISABLE_WGET
xd
CONFIG_NSH_DISABLE_XD
+ +

1 + Because of hardware padding, the actual required packet size may be larger
+ 2 + Special TFTP server start-up optionss will probably be required to permit + creation of files for the correct operation of the put command.
+ 3 + CONFIG_FS_READABLE is not a user configuration but is set automatically + if any readable filesystem is selected. At present, this is either CONFIG_FS_FAT + or CONFIG_FS_ROMFS.
+ 4 + CONFIG_FS_WRITABLE is not a user configuration but is set automatically + if any writable filesystem is selected. At present, this is only CONFIG_FS_FAT.
+ 5 + Verbose help output can be suppressed by defining CONFIG_NSH_HELP_TERSE. + In that case, the help command is still available but will be slightly smaller. + +

+ + + + + +
+

3.2 NSH-Specific Configuration Settings

+
+ +

+ The behavior of NSH can be modified with the following settings in + the configs/<board-name>/defconfig file: +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConfigurationDescription
CONFIG_NSH_READLINE + Selects the minimal implementation of readline(). + This minimal implementation provides on backspace for command line editing. + It expects some minimal VT100 command support from the terminal. +
CONFIG_NSH_CLE + Selects the more extensive, EMACS-like command line editor. + Select this option only if + (1) you don't mind a modest increase in the FLASH footprint, and + (2) you work with a terminal that supports extensive VT100 editing commands. + Selecting this option will add probably 1.5-2KB to the FLASH footprint. +
CONFIG_NSH_BUILTIN_APPS + Support external registered, "builtin" applications that can be + executed from the NSH command line (see apps/README.txt for + more information). + This required CONFIG_BUILTIN to enable NuttX support for + "builtin" applications. +
CONFIG_NSH_FILEIOSIZE + Size of a static I/O buffer used for file access (ignored if + there is no filesystem). Default is 1024. +
CONFIG_NSH_STRERROR + strerror(errno) makes more readable output but strerror() is + very large and will not be used unless this setting is y. + This setting depends upon the strerror() having been enabled with CONFIG_LIBC_STRERROR. +
CONFIG_NSH_LINELEN + The maximum length of one command line and of one output line. + Default: 80 +
CONFIG_NSH_DISABLE_SEMICOLON + By default, you can enter multiple NSH commands on a line with each command separated by a semicolon. + You can disable this feature to save a little memory on FLASH challenged platforms. + Default: n +
CONFIG_NSH_CMDPARMS + If selected, then the output from commands, from file applications, and from NSH built-in commands can be used as arguments to other commands. + The entity to be executed is identified by enclosing the command line in back quotes. + For example, +
    +set FOO `myprogram $BAR
    +
+ will execute the program named myprogram passing it the value of the environment variable BAR. + The value of the environment variable FOO is then set output of myprogram on stdout. Because this feature commits significant resources, it is disabled by default. +
CONFIG_NSH_TMPDIR + If CONFIG_NSH_CMDPARMS is selected, then function output will be retained + in a temporary file. In that case, this string must be provided to + specify the full path to a directory where temporary files can be + created. This would be a good application of RAM disk: To provide + temporary storage for function output. +
CONFIG_NSH_MAXARGUMENTS + The maximum number of NSH command arguments. Default: 6 +
CONFIG_NSH_ARGCAT + Support concatenation of strings with environment variables or command output. + For example: +
    +set FOO XYZ
    +set BAR 123
    +set FOOBAR ABC_${FOO}_${BAR}
    +
+ would set the environment variable FOO to XYZ, BAR to 123 and FOOBAR to ABC_XYZ_123. + If CONFIG_NSH_ARGCAT is not selected, then a slightly small FLASH footprint results but then also only simple environment variables like $FOO can be used on the command line. +
CONFIG_NSH_NESTDEPTH + The maximum number of nested if-then[-else]-fi sequences that + are permissable. Default: 3 +
CONFIG_NSH_DISABLESCRIPT + This can be set to y to suppress support for scripting. This + setting disables the sh, test, and [ commands and the + if-then[-else]-fi construct. This would only be set on systems + where a minimal footprint is a necessity and scripting is not. +
CONFIG_NSH_DISABLE_ITEF + If scripting is enabled, then then this option can be selected to suppress support for if-then-else-fi sequences in scripts. + This would only be set on systems where some minimal scripting is required but if-then-else-fi is not. +
CONFIG_NSH_DISABLE_LOOPS + If scripting is enabled, then then this option can be selected suppress support for while-do-done and until-do-done sequences in scripts. + This would only be set on systems where some minimal scripting is required but looping is not. +
CONFIG_NSH_DISABLEBG + This can be set to y to suppress support for background + commands. This setting disables the nice command prefix and + the & command suffix. This would only be set on systems + where a minimal footprint is a necessity and background command execution is not. +
CONFIG_NSH_MMCSDMINOR + If the architecture supports an MMC/SD slot and if the NSH + architecture specific logic is present, this option will provide + the MMC/SD minor number, i.e., the MMC/SD block driver will + be registered as /dev/mmcsdN where N is the minor number. + Default is zero. +
CONFIG_NSH_ROMFSETC + Mount a ROMFS filesystem at /etc and provide a startup script + at /etc/init.d/rcS. The default startup script will mount + a FAT FS RAMDISK at /tmp but the logic is + easily extensible. +
CONFIG_NSH_CONSOLE +

+ If CONFIG_NSH_CONSOLE is set to y, then a serial + console front-end is selected. +

+

+ Normally, the serial console device is a UART and RS-232 interface. + However, if CONFIG_USBDEV is defined, then a USB serial device may, instead, be used if the one of the following are defined: +

+
    +
  • + CONFIG_PL2303 and CONFIG_PL2303_CONSOLE. + Sets up the Prolifics PL2303 emulation as a console device at /dev/console. +
  • +
  • + CONFIG_CDCACM and CONFIG_CDCACM_CONSOLE. + Sets up the CDC/ACM serial device as a console device at /dev/console. +
  • +
  • + CONFIG_NSH_USBCONSOLE. + If defined, then the an arbitrary USB device may be used to as the NSH console. + In this case, CONFIG_NSH_USBCONDEV must be defined to indicate which USB device to use as the console. + The advantage of using a device other that /dev/console is that normal debug output can then use /dev/console while NSH uses CONFIG_NSH_USBCONDEV. +

    + CONFIG_NSH_USBCONDEV. + If CONFIG_NSH_USBCONSOLE is set to 'y', then CONFIG_NSH_USBCONDEV must also be set to select the USB device used to support the NSH console. + This should be set to the quoted name of a readable/write-able USB driver such as: CONFIG_NSH_USBCONDEV="/dev/ttyACM0". +

    +
  • +
+

+ If there are more than one USB slots, then a USB device minor number may also need to be provided: +

+
    +
  • + CONFIG_NSH_UBSDEV_MINOR. + The minor device number of the USB device. Default: 0 +
  • +
+

+ If USB tracing is enabled (CONFIG_USBDEV_TRACE), then NSH will initialize USB tracing as requested by the following. + Default: Only USB errors are traced. +

+
    +
  • + CONFIG_NSH_USBDEV_TRACEINIT. + Show initialization events +
  • +
  • + CONFIG_NSH_USBDEV_TRACECLASS. + Show class driver events +
  • +
  • + CONFIG_NSH_USBDEV_TRACETRANSFERS. + Show data transfer events +
  • +
  • + CONFIG_NSH_USBDEV_TRACECONTROLLER. + Show controller events +
  • + CONFIG_NSH_USBDEV_TRACEINTERRUPTS. + Show interrupt-related events. +
  • +
+
CONFIG_NSH_ALTCONDEV and CONFIG_NSH_CONDEV + If CONFIG_NSH_CONSOLE is set to y, then CONFIG_NSH_ALTCONDEV + may also be selected to enable use of an alternate character device to support the NSH console. + If CONFIG_NSH_ALTCONDEV is selected, then CONFIG_NSH_CONDEV holds the quoted name of a readable/write-able character driver such as: + CONFIG_NSH_CONDEV="/dev/ttyS1". + This is useful, for example, to separate the NSH command line from the system console + when the system console is used to provide debug output. + Default: stdin and stdout (probably "/dev/console") +
    +
  • + NOTE 1: + When any other device other than /dev/console is used for a user interface, + (1) linefeeds (\n) will not be expanded to carriage return / linefeeds (\r\n). + You will need to configure your terminal program to account for this. + And (2) input is not automatically echoed so you will have to turn local echo on. +
  • +
  • + NOTE 2: + This option forces the console of all sessions to use NSH_CONDEV. + Hence, this option only makes sense for a system that supports only a single session. + This option is, in particular, incompatible with Telnet sessions because each Telnet session must use a different console device. +
  • +
+
CONFIG_NSH_TELNET + If CONFIG_NSH_TELNET is set to y, then a TELENET + server front-end is selected. When this option is provided, + you may log into NuttX remotely using telnet in order to + access NSH. +
CONFIG_NSH_ARCHINIT + Set CONFIG_NSH_ARCHINIT if your board provides architecture + specific initialization via the board-specific function board_app_initialize(). + This function will be called early in NSH initialization to allow board logic to + do such things as configure MMC/SD slots. +
+ +

+ If Telnet is selected for the NSH console, then we must configure + the resources used by the Telnet daemon and by the Telnet clients. +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
ConfigurationDescription
CONFIG_NSH_TELNETD_PORT + The telnet daemon will listen on this TCP port number for connections. Default: 23 +
CONFIG_NSH_TELNETD_DAEMONPRIO + Priority of the Telnet daemon. + Default: SCHED_PRIORITY_DEFAULT +
CONFIG_NSH_TELNETD_DAEMONSTACKSIZE + Stack size allocated for the + Telnet daemon. Default: 2048 +
CONFIG_NSH_TELNETD_CLIENTPRIO + Priority of the Telnet client. + Default: SCHED_PRIORITY_DEFAULT +
CONFIG_NSH_TELNETD_CLIENTSTACKSIZE + Stack size allocated for the Telnet client. Default: 2048 +
+ +

+ One or both of CONFIG_NSH_CONSOLE and CONFIG_NSH_TELNET + must be defined. If CONFIG_NSH_TELNET is selected, then there some + other configuration settings that apply: +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConfigurationDescription
CONFIG_NET=y + Of course, networking must be enabled. +
CONFIG_NSOCKET_DESCRIPTORS + And, of course, you must allocate some socket descriptors. +
CONFIG_NET_TCP=y + TCP/IP support is required for telnet (as well as various other TCP-related configuration settings). +
CONFIG_NSH_IOBUFFER_SIZE + Determines the size of the I/O buffer to use for sending/ + receiving TELNET commands/reponses +
CONFIG_NSH_DHCPC + Obtain the IP address via DHCP. +
CONFIG_NSH_IPADDR + If CONFIG_NSH_DHCPC is NOT set, then the static IP + address must be provided. +
CONFIG_NSH_DRIPADDR + Default router IP address +
CONFIG_NSH_NETMASK + Network mask +
CONFIG_NSH_NOMAC + Set if your ethernet hardware has no built-in MAC address. + If set, a bogus MAC will be assigned. +
CONFIG_NSH_MAX_ROUNDTRIP + This is the maximum round trip for a response to a ICMP ECHO request. + It is in units of deciseconds. The default is 20 (2 seconds). +
+ +

+ If you use DHCPC, then some special configuration network options are + required. These include: +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
ConfigurationDescription
CONFIG_NET=y + Of course, networking must be enabled. +
CONFIG_NSOCKET_DESCRIPTORS + And, of course, you must allocate some socket descriptors. +
CONFIG_NET_UDP=y + UDP support is required for DHCP (as well as various other UDP-related configuration settings). +
CONFIG_NET_BROADCAST=y + UDP broadcast support is needed. +
CONFIG_NET_ETH_MTU=650 (or larger) + Per RFC2131 (p. 9), the DHCP client must be prepared to receive DHCP messages of up to + 576 bytes (excluding Ethernet, IP, or UDP headers and FCS). + NOTE: Note that the actual MTU setting will depend upon the specific link protocol. + Here Ethernet is indicated. +
+ +

+ If CONFIG_NSH_ROMFSETC is selected, then the following additional + configuration setting apply: +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
ConfigurationDescription
CONFIG_NSH_ARCHROMFS + May be defined to specify an alternative ROMFS image that can be found at configs/<board>/include/nsh_romfsimg.h. +
CONFIG_NSH_ROMFSMOUNTPT + The default mountpoint for the ROMFS volume is "/etc", but that + can be changed with this setting. This must be a absolute path + beginning with '/' and enclosed in quotes. +
CONFIG_NSH_INITSCRIPT + This is the relative path to the startup script within the mountpoint. + The default is "init.d/rcS". This is a relative path and must not + start with '/' but must be enclosed in quotes. +
CONFIG_NSH_ROMFSDEVNO + This is the minor number of the ROMFS block device. The default is + '0' corresponding to /dev/ram0. +
CONFIG_NSH_ROMFSSECTSIZE + This is the sector size to use with the ROMFS volume. Since the + default volume is very small, this defaults to 64 but should be + increased if the ROMFS volume were to be become large. Any value + selected must be a power of 2. +
+ +

+ When the default rcS file used when CONFIG_NSH_ROMFSETC is + selected, it will mount a FAT FS under /tmp. The following selections + describe that FAT FS. +

+ +
+ + + + + + + + + + + + +
ConfigurationDescription
CONFIG_NSH_FATDEVNO + This is the minor number of the FAT FS block device. The default is + '1' corresponding to /dev/ram1. +
CONFIG_NSH_FATSECTSIZE + This is the sector size use with the FAT FS. Default is 512. +
+ + + + + +
+

4.0 Customizing the NuttShell

+
+ +

+ Overview. + The NuttShell (NSH) is a simple shell application that may be used with NuttX. + It supports a variety of commands and is (very) loosely based on the bash shell and the common utilities used in Unix shell programming. + The paragraphs in this appendix will focus on customizing NSH: Adding new commands, changing the initialization sequence, etc. +

+ + + + + +
+

4.1 The NSH Library and NSH Initialization

+
+ +

+ Overview. + NSH is implemented as a library that can be found at apps/nshlib. + As a library, it can be custom built into any application that follows the NSH initialization sequence described below. + As an example, the code at apps/examples/nsh/nsh_main.c illustrates how to start NSH and the logic there was intended to be incorporated into your own custom code. + Although code was generated simply as an example, in the end most people just use this example code as their application main() function. + That initialization performed by that example is discussed in the following paragraphs. +

+ +

4.1.1 NSH Initialization sequence

+ +

+ The NSH start-up sequence is very simple. + As an example, the code at apps/examples/nsh/nsh_main.c illustrates how to start NSH. + It simple does the following: +

+ +
    +
  1. +

    + If you have C++ static initializers, it will call your implementation of up_cxxinitialize() which will, in turn, call those static initializers. + For the case of the STM3240G-EVAL board, the implementation of up_cxxinitialize() can be found at nuttx/configs/stm3240g-eval/src/up_cxxinitialize.c. +

    +
  2. +

    + This function then calls nsh_initialize() which initializes the NSH library. + nsh_initialize() is described in more detail below. +

    +
  3. +

    + If the Telnetconsole is enabled, it calls nsh_telnetstart() which resides in the NSH library. + nsh_telnetstart() will start the Telnet daemon that will listen for Telnet connections and start remote NSH sessions. +

    +
  4. +

    + If a local console is enabled (probably on a serial port), then nsh_consolemain() is called. + nsh_consolemain() also resides in the NSH library. + nsh_consolemain() does not return so that finished the entire NSH initialization sequence. +

    +
+ +

4.1.2 nsh_initialize()

+ +

+ The NSH initialization function, nsh_initialize(), be found in apps/nshlib/nsh_init.c. + It does only three things: +

+ +
    +
  1. +

    + nsh_romfsetc(): + If so configured, it executes an NSH start-up script that can be found at /etc/init.d/rcS in the target file system. + The nsh_romfsetc() function can be found in apps/nshlib/nsh_romfsetc.c. + This function will (1) register a ROMFS file system, then (2) mount the ROMFS file system. + /etc is the default location where a read-only, ROMFS file system is mounted by nsh_romfsetc(). +

    +

    + The ROMFS image is, itself, just built into the firmware. + By default, this rcS start-up script contains the following logic: +

    +
      +# Create a RAMDISK and mount it at XXXRDMOUNTPOINTXXX
      +
      +mkrd -m XXXMKRDMINORXXX -s XXMKRDSECTORSIZEXXX XXMKRDBLOCKSXXX
      +mkfatfs /dev/ramXXXMKRDMINORXXX
      +mount -t vfat /dev/ramXXXMKRDMINORXXX XXXRDMOUNTPOINTXXX
      +
    + +

    + Where the XXXX*XXXX strings get replaced in the template when the ROMFS image is created: +

    +
      +
    • +

      + XXXMKRDMINORXXX will become the RAM device minor number. + Default: 0 +

      +
    • +

      + XXMKRDSECTORSIZEXXX will become the RAM device sector size +

      +
    • +

      + XXMKRDBLOCKSXXX will become the number of sectors in the device. +

      +
    • +

      + XXXRDMOUNTPOINTXXX will become the configured mount point. + Default: /etc +

      +
    +

    + By default, the substituted values would yield an rcS file like: +

    +
      +# Create a RAMDISK and mount it at /tmp
      +
      +mkrd -m 1 -s 512 1024
      +mkfatfs /dev/ram1
      +mount -t vfat /dev/ram1 /tmp
      +
    +

    + This script will, then: +

    +
      +
    • +

      + Create a RAMDISK of size 512*1024 bytes at /dev/ram1, +

      +
    • +

      + Format a FAT file system on the RAM disk at /dev/ram1, and then +

      +
    • +

      + Mount the FAT filesystem at a configured mountpoint, /tmp. +

      +
    +

    + This rcS template file can be found at apps/nshlib/rcS.template. + The resulting ROMFS file system can be found in apps/nshlib/nsh_romfsimg.h. +

    +
  2. +

    + board_app_initialize(): + Next any architecture-specific NSH initialization will be performed (if any). + For the STM3240G-EVAL, this architecture specific initialization can be found at configs/stm3240g-eval/src/stm32_appinit.c. + This it does things like: (1) Initialize SPI devices, (2) Initialize SDIO, and (3) mount any SD cards that may be inserted. +

    +
  3. +

    + nsh_netinit(): + The nsh_netinit() function can be found in apps/nshlib/nsh_netinit.c. +

    +
+ + + + + +
+

4.2 NSH Commands

+
+ +

+ Overview. + NSH supports a variety of commands as part of the NSH program. + All of the NSH commands are listed in the NSH documentation above. + Not all of these commands may be available at any time, however. + Many commands depend upon certain NuttX configuration options. + You can enter the help command at the NSH prompt to see the commands actual available: +

+ +

+ For example, if network support is disabled, then all network-related commands will be missing from the list of commands presented by 'nsh> help'. + You can see the specific command dependencies in the table above. +

+ +

4.2.1 Adding New NSH Commands

+ +

+ New commands can be added to the NSH very easily. + You simply need to add two things: +

+
    +
  1. +

    + The implementation of your command, and +

    +
  2. +

    + A new entry in the NSH command table +

    +
+ +

+ Implementation of Your Command. + For example, if you want to add a new a new command called mycmd to NSH, you would first implement the mycmd code in a function with this prototype: +

+ + + +

+ The argc and argv are used to pass command line arguments to the NSH command. + Command line parameters are passed in a very standard way: argv[0] will be the name of the command, and argv[1] through argv[argc-1] are the additional arguments provided on the NSH command line. +

+

+ The first parameter, vtbl, is special. + This is a pointer to session-specific state information. + You don't need to know the contents of the state information, but you do need to pass this vtbl argument when you interact with the NSH logic. + The only use you will need to make of the vtbl argument will be for outputting data to the console. + You don't use printf() within NSH commands. + Instead you would use: +

+ +

+ So if you only wanted to output "Hello, World!" on the console, then your whole command implementation might be: +

+ +

+ The prototype for the new command should be placed in apps/examples/nshlib/nsh.h>. +

+ +

+ Adding You Command to the NSH Command Table. + All of the commands support by NSH appear in a single table called: +

+ +

+ That table can be found in the file apps/examples/nshlib/nsh_parse.c. + The structure cmdmap_s is also defined in apps/nshlib/nsh_parse.c: +

+ +

+ This structure provides everything that you need to describe your command: + Its name (cmd), the function that handles the command (cmd_mycmd()), the minimum and maximum number of arguments needed by the command, + and a string describing the command line arguments. + That last string is what is printed when enter "nsh> help". +

+

+ So, for you sample commnd, you would add the following the to the g_cmdmap[] table: +

+ + +

+ This entry is particularly simply because mycmd is so simple. + Look at the other commands in g_cmdmap[] for more complex examples. +

+ + + + + +
+

4.3 NSH "Built-In" Applications

+
+ +

+ Overview. + In addition to these commands that are a part of NSH, external programs can also be executed as NSH commands. + These external programs are called "Built-In" Applications for historic reasons. + That terminology is somewhat confusing because the actual NSH commands as described above are truly "built-into" NSH whereas these applications are really external to NuttX. +

+

+ These applications are built-into NSH in the sense that they can be executed by simply typing the name of the application at the NSH prompt. + Built-in application support is enabled with these configuration option: +

+ +

+ When these configuration options are set, you will also be able to see the built-in applications if you enter "nsh> help". + They will appear at the bottom of the list of NSH commands under: +

+ + +

+ Note that no detailed help information beyond the name of the built-in application is provided. +

+ +

4.3.1 Built-In Applications

+ +

+ Overview. + The underlying logic that supports the NSH built-in applications is called "Built-In Applications". + The builtin application logic can be found at apps/builtin. + This logic simply does the following: +

+ +
    +
  1. +

    + It supports registration mechanism so that builtin applications can dynamically register themselves at build time, and +

    +
  2. +

    + Utility functions to look up, list, and execute the builtin applications. +

    +
+ +

+ Built-In Application Utility Functions. + The utility functions exported by the builtin application logic are prototyped in nuttx/include/nuttx/binfmt/builtin.h and apps/include/builtin.h. + These utility functions include: +

+ + + +

+ Autogenerated Header Files. + Application entry points with their requirements are gathered together in two files when NuttX is first built: +

+
    +
  1. +

    + apps/builtin/builtin_proto.h: + Prototypes of application task entry points. +

    +
  2. +

    + apps/builtin/builtin_list.h: + Application specific information and start-up requirements +

    +
+ +

+ Registration of Built-In Applications. + The NuttX build occurs in several phases as different build targets are executed: + (1) context when the configuration is established, + (2) depend when target dependencies are generated, and + (3) default (all) when the normal compilation and link operations are performed. + Built-in application information is collected during the make context build phase. +

+ +

+ An example application that can be "built-in" is be found in the apps/examples/hello directory. + Let's walk through this specific cause to illustrate the general way that built-in applications are created and how they register themselves so that they can be used from NSH. +

+ +

+ apps/examples/hello. + The main routine for apps/examples/hello can be found in apps/examples/hello/main.c. + The main routine is: +

+ + +

+ This is the built in function that will be registered during the context build phase of the NuttX build. + That registration is performed by logic in apps/examples/hello/Makefile. + But the build system gets to that logic through a rather tortuous path: +

+ +
    +
  1. +

    + The top-level context make target is in nuttx/Makefile. + All build targets depend upon the context build target. + For the apps/ directory, this build target will execute the context target in the apps/Makefile. +

    +
  2. +

    + The apps/Makefile will, in turn, execute the context targets in all of the configured sub-directories. + In our case will include the Makefile in apps/examples. +

    +
  3. +

    + And finally, the apps/examples/Makefile will execute the context target in all configured examplesub-directores, getting us finally to apps/examples/Makefile which is covered below.

    +
+ +

+ NOTE: + Since this context build phase can only be executed one time, any subsequent configuration changes that you make will, then, not be reflected in the build sequence. + That is a common area of confusion. + Before you can instantiate the new configuration, you have to first get rid of the old configuration. + The most drastic way to this is: +

+ +

+ But then you will have to re-configuration NuttX from scratch. + But if you only want to re-build the configuration in the apps/ sub-directory, then there is a less labor-intensive way to do that. + The following NuttX make command will remove the configuration only from the apps/ directory and will let you continue without re-configuring everything: +

+ + +

+ Logic for the context target in apps/examples/hello/Makefile registers the hello_main() application in the builtin's builtin_proto.hand builtin_list.h files. + That logic that does that in apps/examples/hello/Makefile is abstracted below: +

+
    +
  1. +

    + First, the Makefile includes apps/Make.defs: +

    +
      +include $(APPDIR)/Make.defs
      +
    +

    + This defines a macro called REGISTER that adds data to the builtin header files: +

    +
      +define REGISTER
      +    @echo "Register: $1"
      +    @echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/builtin/builtin_list.h"
      +    @echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/builtin/builtin_proto.h"
      +endef
      +
    +

    + When this macro runs, you will see the output in the build "Register: hello", that is a sure sign that the registration was successful. +

    +
  2. +

    + The make file then defines the application name (hello), the task priority (default), and the stack size that will be allocated in the task runs (2K). +

    +
      +APPNAME         = hello
      +PRIORITY        = SCHED_PRIORITY_DEFAULT
      +STACKSIZE       = 2048
      +
    + +
  3. +

    + And finally, the Makefile invokes the REGISTER macro to added the hello_main() builtin application. + Then, when the system build completes, the hello command can be executed from the NSH command line. + When the hello command is executed, it will start the task with entry point hello_main() with the default priority and with a stack size of 2K. +

    +
      +context:
      +  $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
      +
    +
+ +

+ Other Uses of Built-In Application. + The primary purpose of builtin applications is to support command line execution of applications from NSH. + However, there is one other use of builtin applications that should be mentioned. +

+ +
    +
  1. +

    binfs. + binfs is a tiny file system located at apps/builtin/binfs.c. + This provides an alternative what of visualizing installed builtin applications. + Without binfs, you can see the installed builtin applications using the NSH help command. + binfs will create a tiny pseudo-file system mounted at /bin. + Using binfs, you can see the available builtin applications by listing the contents of /bin directory. + This gives some superficial Unix compatibility, but does not really add any new functionality. +

    +
  2. +
+ +

4.3.2 Synchronous Built-In Applications

+ +

+ By default, built-in commands started from the NSH command line will run asynchronously with NSH. + If you want to force NSH to execute commands then wait for the command to execute, you can enable that feature by adding the following to the NuttX configuration file: +

+ +

+ This configuration option enables support for the standard waitpid() RTOS interface. + When that interface is enabled, NSH will use it to wait, sleeping until the built-in application executes to completion. +

+

+ Of course, even with CONFIG_SCHED_WAITPID=y defined, specific applications can still be forced to run asynchronously by adding the ampersand (&) after the NSH command. +

+ + + + + +
+

4.4 Customizing NSH Initialization

+
+ +

+ Ways to Customize NSH Initialization. + There are three ways to customize the NSH start-up behavior. + Here they are presented in order of increasing difficulty: +

+ +
    +
  1. +

    + You can extend the initialization logic in configs/stm3240g-eval/src/stm32_appinit.c. + The logic there is called each time that NSH is started and is good place in particular for any device-related initialization. +

    +
  2. +

    + You replace the sample code at apps/examples/nsh/nsh_main.c with whatever start-up logic that you want. + NSH is a library at apps/nshlib. + apps.examplex/nsh is just a tiny, example start-up function (CONFIG_USER_ENTRYPOINT()) that that runs immediately and illustrates how to start NSH + If you want something else to run immediately then you can write your write your own custom CONFIG_USER_ENTRYPOINT() function and then start other tasks from your custom CONFIG_USER_ENTRYPOINT(). +

    +
  3. +

    + NSH also supports a start-up script that executed when NSH first runs. + This mechanism has the advantage that the start-up script can contain any NSH commands and so can do a lot of work with very little coding. + The disadvantage is that is is considerably more complex to create the start-up script. + It is sufficiently complex that is deserves its own paragraph +

    +
+ +

4.4.1 NuttShell Start up Scripts

+ +

+ First of all you should look at NSH Start-Up Script paragraph. + Most everything you need to know can be found there. + That information will be repeated and extended here for completeness. +

+ +

+ NSH Start-Up Script. + NSH supports options to provide a start up script for NSH. + The start-up script contains any command support by NSH (i.e., that you see when you enter 'nsh> help'). + In general this capability is enabled with CONFIG_NSH_ROMFSETC=y, but has several other related configuration options as described with the NSH-specific configuration settings paragraph. + This capability also depends on: +

+ + + +

+ Default Start-Up Behavior. + The implementation that is provided is intended to provide great flexibility for the use of Start-Up files. + This paragraph will discuss the general behavior when all of the configuration options are set to the default values. +

+

+ In this default case, enabling CONFIG_NSH_ROMFSETC will cause NSH to behave as follows at NSH start-up time: +

+ + +

+ Example Configurations. + Here are some configurations that have CONFIG_NSH_ROMFSETC=y in the NuttX configuration file. + They might provide useful examples: +

+ +

+ In most of these cases, the configuration sets up the default /etc/init.d/rcS script. + The default script is here: apps/nshlib/rcS.template. + (The funny values in the template like XXXMKRDMINORXXX get replaced via sed at build time). + This default configuration creates a ramdisk and mounts it at /tmp as discussed above. +

+

+ If that default behavior is not what you want, then you can provide your own custom rcS script by defining CONFIG_NSH_ARCHROMFS=y in the configuration file. +

+

+ Modifying the ROMFS Image. + The contents of the /etc directory are retained in the file apps/nshlib/nsh_romfsimg.h OR, if CONFIG_NSH_ARCHROMFS is defined, include/arch/board/nsh_romfsimg.h. + In order to modify the start-up behavior, there are three things to study: +

+ +
    +
  1. +

    + Configuration Options. + The additional CONFIG_NSH_ROMFSETC configuration options discussed with the other NSH-specific configuration settings. +

    +
  2. +

    + tools/mkromfsimg.sh Script. + The script tools/mkromfsimg.sh creates nsh_romfsimg.h. + It is not automatically executed. + If you want to change the configuration settings associated with creating and mounting the /tmp directory, then it will be necessary to re-generate this header file using the tools/mkromfsimg.sh script. +

    +

    + The behavior of this script depends upon several things: +

    +
      +
    1. +

      + The configuration settings then installed configuration. +

      +
    2. +

      + The genromfs tool(available from http://romfs.sourceforge.net) or included within the NuttX buildroot toolchain. + There is also a snapshot available in the NuttX tools repository here. +

      +
    3. +

      + The xxd tool that is used to generate the C header files (xxd is a normal part of a complete Linux or Cygwin installation, usually as part of the vi package). +

      +
    4. +

      + The file apps/nshlib/rcS.template (OR, if CONFIG_NSH_ARCHROMFS is defined include/arch/board/rcs.template. +

      +
    +
  3. +

    + rcS.template. + The file apps/nshlib/rcS.template contains the general form of the rcS file; configured values are plugged into this template file to produce the final rcS file. +

    +

    + To generate a custom rcS file a copy of rcS.template needs to be placed at tools/ and changed according to the desired start-up behaviour. + Running tools/mkromfsimg.h creates nsh_romfsimg.h which needs to be copied to apps/nhslib OR if CONFIG_NSH_ARCHROMFS is defined to configs/<board>/include. +

    +
+ +

+ rcS.template. + The default rcS.template, apps/nshlib/rcS.template, generates the standard, default apps/nshlib/nsh_romfsimg.h file. +

+ +

+ If CONFIG_NSH_ARCHROMFS is defined in the NuttX configuration file, then a custom, board-specific nsh_romfsimg.h file residing in configs/<board>/includewill be used. + NOTE when the OS is configured, include/arch/board will be linked to configs/<board>/include. +

+ +

+ All of the startup-behavior is contained in rcS.template. + The role of mkromfsimg.sh script is to (1) apply the specific configuration settings to rcS.template to create the final rcS, and (2) to generate the header file nsh_romfsimg.h containg the ROMFS file system image. + To do this, mkromfsimg.sh uses two tools that must be installed in your system: +

+
    +
  1. +

    + The genromfs tool that is used to generate the ROMFS file system image. +

    +
  2. +

    + The xxd tool that is used to create the C header file. +

    +
+ + + + + +
+

5.0 Shell Login

+
+ + + + + +
+

5.1 Enabling Shell Logins

+
+

+ NuttShell sessions can be protected by requiring that the user supply username and password credentials at the beginning of the session. + Logins can be enabled for standard USB or serial consoles with: +

+ +

+ Logins for Telnet sessions can be enabled separately with: +

+ +

+ Logins can be enabled for either or both session types. + On a successful login, the user will have access to the NSH session: +

+ +

+ After each failed login attempt, a delay can be set up. + The purpose of this delay is to discourage attempts to crack the password by brute force. + That delay is configured with +

+ +

+ This setting provides the login failure delay in units of milliseconds. + The system will pause this amount of time after each failed login attempt. + After a certain number of failed login attempts, the session will be closed. + That number is controlled by: +

+ + + + + + +
+

5.2 Verification of Credentials

+
+

+ There are three ways that NSH can be configured to verify user credentials at login time: +

+
    +
  1. +

    + The simplest implementation simply uses fixed login credentials and is selected with: +

    +
      +CONFIG_NSH_LOGIN_FIXED=y
      +
    +

    + The fixed login credentials are selected via: +

    +
      +CONFIG_NSH_LOGIN_USERNAME=admin
      +CONFIG_NSH_LOGIN_PASSWORD="Administrator"
      +
    +

    + This is not very flexible since there can be only one user and the password is fixed in the FLASH image. This option is also not very secure because a malicious user could get the password by just looking at the .text stings in the flash image. +

    +
  2. +
  3. +

    + NSH can also be configured to defer the entire user credential verification to platform-specific logic with this setting: +

    +
      +CONFIG_NSH_LOGIN_PLATFORM=y
      +
    +

    + In this case, NSH will call a platform-specific function to perform the verification of user credentials. + The platform-specific logic must provide a function with the following prototype: +

    +
      +int platform_user_verify(FAR const char *username, FAR const char *password);
      +
    +

    + which is prototyped an described in apps/include/nsh.h and which may be included like: +

    +
      +#include <apps/nsh.h>
      +
    +

    + An appropriate place to implement this function might be in the directory apps/platform/<board>. +

    +
  4. +

    + A final option is to use a password file contained encrypted password information. + This final option is selected with the following and described in more detail in the + following paragraph. +

    +
      +CONFIG_NSH_LOGIN_PASSWD=y
      +
    +
  5. +
+ + + + + +
+

5.3 Password Files

+
+

+ NuttX can also be configured to support a password file, by default at /etc/passwd. + This option enables support for a password file: +

+ +

+This options requires that you have selected CONFIG_FSUTILS_PASSWD=y to enable the access methods of apps/fsutils/passwd: +

+ +

+ And this determines the location of the password file in a mounted volume: +

+ +

+ /etc/passwd is a standard location, but you will need to locate the password where ever you have a mounted volume. +

+

+ The password file can be a fixed list of users in a ROMFS file system or a modifiable list maintained in a file in some writable file system. If the password file lies in a read-only file system like ROMFS, then you should also indicate that the password file is read-only. +

+ +

+ If the password file is writable, then additional NSH commands will be enabled to modify the password file: useradd, userdel, and passwd. If you do not wish you have these commands available, then they should be specifically disabled. +

+

+ The password file logic requires a few additional settings: +

    +
  1. +

    + The size of dynamically allocated and freed buffer that is used for file access: +

    +
      +CONFIG_FSUTILS_PASSWD_IOBUFFER_SIZE=512
      +
    +
  2. +
  3. +

    + And the 128-bit encryption key. The password file currently uses the Tiny Encryption Algorithm (TEA), but could be extended to use something more powerful. +

    +
      +CONFIG_FSUTILS_PASSWD_KEY1=0x12345678
      +CONFIG_FSUTILS_PASSWD_KEY2=0x9abcdef0
      +CONFIG_FSUTILS_PASSWD_KEY3=0x12345678
      +CONFIG_FSUTILS_PASSWD_KEY4=0x9abcdef0
      +
    +
  4. +
+

+ Password can only be decrypted with access to this key. Note that this key could potentially be fished out of your FLASH image, but without any symbolic information, that would be a difficult job since the TEA KEY is binary data and not distinguishable from other binary data in the FLASH image. +

+

+ If the password file is enabled (CONFIG_NSH_LOGIN_PASSWD=y), then the fixed user credentials will not be used for the NSH session login. Instead, the password file will be consulted to verify the user credentials. +

+ + + + + +
+

5.4 Creating a Password File for a ROMFS File System

+
+

+ What we want to accomplish is a ROMFS file system, mounted at /etc and containing the password file, passwd like: +

+ +

+ Where /etc/init.d/rcS is the start-up script; /etc/passwd is a the password file. Note that here we assume that you are already using a start-up script. We can then piggyback the passwd file into the /etc file system already mounted for the NSH start up file as described above above. +

+

+ I use the sim/nsh configuration to create a new password file, but other configurations could also be used. That configuration already supports a ROMFS file system, passwords, and login prompts. First, I make these changes to that configuration. +

+
    +
  1. +

    + Disable logins +

    +
      +- CONFIG_NSH_CONSOLE_LOGIN=y
      ++ # CONFIG_NSH_CONSOLE_LOGIN is not set
      +  # CONFIG_NSH_TELNET_LOGIN is not set
      +
    +
  2. +
  3. +

    + Move the password file to a write-able file system: +

    +
      +- CONFIG_FSUTILS_PASSWD_PATH="/etc/passwd"
      ++ CONFIG_FSUTILS_PASSWD_PATH="/tmp/passwd"
      +
    +
  4. +
  5. +

    + Make the password file modifiable +

    +
      +- CONFIG_FSUTILS_PASSWD_READONLY=y
      +# CONFIG_FSUTILS_PASSWD_READONLY is not set
      +
    +
  6. +
+

+ Now rebuild the simulation. No login should be required to enter the + shell and you should find the useradd, userdel, and passwd commands available in the help summary, provided that they are enabled. + Make certain that the useradd command is not disabled: +

+ +

+ Use the NSH useradd command to add new uses with new user passwords like: +

+ +

+ Do this as many times as you would like. Each time that you do this a new + entry with an encrypted password will be added to the passwd file at + /tmp/passwd. You can see the content of the password file like: +

+ +

+ When you are finished, you can simply copy the /tmp/passwd content from the + cat command and paste it into an editor. Make sure to remove any + carriage returns that may have ended up on the file if you are using + Windows. +

+

+ Then create/re-create the nsh_romfsimg.h file as described below. +

+
    +
  1. +

    + The content on the nsh_romfsimg.h header file is generated from a template directory structure. Create the directory structure: +

    +
      +mkdir etc
      +mkdir etc/init.d
      +
    +

    + And copy your existing startup script into etc/init.c as rcS. +

    +
  2. +
  3. +

    + Save your new password file in the etc/ directory as passwd. +

    +
  4. +
  5. +

    + Create the new ROMFS image. +

    +
      +genromfs -f romfs_img -d etc -V MyVolName
      +
    +
  6. +
  7. +

    + Convert the ROMFS image to a C header file +

    +
      +xxd -i romfs_img >nsh_romfsimg.h
      +
    +
  8. +
  9. +

    + Edit nsh_romfsimg.h: Mark both data definitions as const so that the data will be stored in FLASH. +

    +
  10. +
  11. +

    + Edit nsh_romfsimg.h, mark both data definitions as const so that that will be stored in FLASH. +

    +
  12. +
+

+ There is a good example of how to do this in the NSH simulation configuration at configs/sim/nsh. The ROMFS support files are provided at configs/sim/include and the README.txt file at the location provides detailed information about creating and modifying the ROMFS file system. +

+ + + + + +
+

Index

+
+ + + + + +
+ + +
+ + + diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html new file mode 100644 index 0000000000..2ebc2eb693 --- /dev/null +++ b/Documentation/NuttX.html @@ -0,0 +1,5619 @@ + + +NuttX + + +

+ + + + +
+

NuttX RTOS

+

Last Updated: March 27, 2016

+
+

+ + + + +
+

Table of Contents

+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Overview.
+ What is NuttX? Look at all those files and features... How can it be a tiny OS? +
+ NuttX Discussion Group.
+ Do you want to talk about NuttX features? Do you need some help? Problems? Bugs? +
+ Downloads.
+ Where can I get NuttX? What is the current development status? +
+ Supported Platforms.
+ What target platforms has NuttX been ported to? +
+ Development Environments.
+ What kinds of host cross-development platforms can be used with NuttX? +
+ Licensing.
+ Are there any licensing restrictions for the use of NuttX? (Almost none) + Will there be problems if I link my proprietary code with NuttX? (No) +
+ Release Notes + What has changed in the last release of NuttX? + What has changed in previous releases of NuttX? + Are there any unreleased changes. +
+ Bugs, Issues, Things-To-Do.
+ Software is never finished nor ever tested well enough. + (Do you want to help develop NuttX? If so, send me an email). +
+ Other Documentation.
+ What other NuttX documentation is available? +
+ Trademarks.
+ Some of the words used in this document belong to other people. +
+
+ + + + + +
+

Overview

+
+ +

+ Goals. + NuttX is a real timed embedded operating system (RTOS). + Its goals are: +

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Small Footprint +

+

+ Usable in all but the tightest micro-controller environments, + The focus is on the tiny-to-small, deeply embedded environment. +

+
+ Rich Feature OS Set +

+

+ The goal is to provide implementations of most standard POSIX OS interfaces + to support a rich, multi-threaded development environment for deeply embedded + processors. +

+ NON-GOALS: (1) It is not a goal to provide the level of OS features like those provided by Linux. + In order to work with smaller MCUs, small footprint must be more important than an extensive feature set. + But standard compliance is more important than small footprint. + Surely a smaller RTOS could be produced by ignoring standards. + Think of NuttX is a tiny Linux work-alike with a much reduced feature set. + (2) There is no MMU-based support for processes. + At present, NuttX assumes a flat address space. +

+
+ Highly Scalable +

+

+ Fully scalable from tiny (8-bit) to moderate embedded (32-bit). + Scalability with rich feature set is accomplished with: + Many tiny source files, link from static libraries, highly configurable, use of + weak symbols when available. +

+
+ Standards Compliance +

+

+ NuttX strives to achieve a high degree of standards compliance. + The primary governing standards are POSIX and ANSI standards. + Additional standard APIs from Unix and other common RTOS's are + adopted for functionality not available under these standards + or for functionality that is not appropriate for the deeply-embedded + RTOS (such as fork()). +

+

+ Because of this standards conformance, software developed under other + standard OSs (such as Linux) should port easily to NuttX. +

+
+ Real-Time +

+

+ Fully pre-emptible; fixed priority, round-robin, and "sporadic" scheduling. +

+
+ Totally Open +

+

+ Non-restrictive BSD license. +

+
+ GNU Toolchains +

+

+ Compatible GNU toolchains based on buildroot + available for + download + to provide a complete development environment for many architectures. +

+
+ +

+ Feature Set. + Key features of NuttX include: +

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Standards Compliant Core Task Management +

+

+

  • Fully pre-emptible.
  • +

    +

    +

    +

  • Naturally scalable.
  • +

    +

    +

    +

  • Highly configurable.
  • +

    +

    +

    +

  • + Easily extensible to new processor architectures, SoC architecture, or board architectures. + A Porting Guide is available. +
  • +

    +

    +

    +

  • FIFO and round-robin scheduling.
  • +

    +

    +

    +

  • Realtime, deterministic, with support for priority inheritance
  • +

    +

    +

    +

  • Tickless Operation
  • +

    +

    +

    +

  • POSIX/ANSI-like task controls, named message queues, counting semaphores, clocks/timers, signals, pthreads, environment variables, filesystem.
  • +

    +

    +

    +

  • VxWorks-like task management and watchdog timers.
  • +

    +

    +

    +

  • BSD socket interface.
  • +

    +

    +

    +

  • Extensions to manage pre-emption.
  • +

    +

    +

    +

  • Optional tasks with address environments (Processes).
  • +

    +

    +

    +

  • Loadable kernel modules.
  • +

    +

    +

    +

  • Memory Configurations: (1) Flat embedded build, (2) Protected build with MPU, and (3) Kernel build with MMU.
  • +

    +

    +

    +

  • Memory Allocators: (1) standard heap memory allocation, (2) granule allocator, (3) shared memory, and (4) dynamically sized, per-process heaps.
  • +

    +

    +

    +

  • Inheritable "controlling terminals" and I/O re-direction.
  • +

    +

    +

    +

  • On-demand paging.
  • +

    +

    +
  • System logging.
  • +

    +

    +

    +

  • May be built either as an open, flat embedded RTOS or as a separately built, secure, monolithic kernel with a system call interface.
  • +

    +

    +

    +

  • Built-in, per-thread CPU load measurements.
  • +

    +

    +

    +

  • Well documented in the NuttX User Guide.
  • +

    +
    + File system +

    +

    +

  • Tiny, in-memory, root pseudo-file-system.
  • +

    +

    +

    +

  • Virtual file system (VFS) supports drivers and mountpoints.
  • +

    +

    +

    +

  • + Mount-able volumes. Bind mountpoint, filesystem, and block device driver. +
  • +

    +

    +

    +

  • Generic system logging (SYSLOG) support.
  • +

    +

    +

    +

  • + FAT12/16/32 filesystem support with optional FAT long file name support1. +
  • +

    +

    +

    +

  • + NFS Client. Client side support for a Network File System (NFS, version 3, UDP). +
  • +

    +

    +

    +

  • + NXFFS. The tiny NuttX wear-leveling FLASH file system. +
  • +

    +

    +

    +

  • + SMART. FLASH file system from Ken Pettit. +
  • +

    +

    +

    +

  • ROMFS filesystem support.
  • +

    +

    +

    +

  • TMPFS RAM filesystem support.
  • +

    +

    +

    +

  • BINFS pseudo-filesystem support.
  • +

    +

    +

    +

  • HOSTFS filesystem support (simulation only).
  • +

    +

    +

    +

  • Union filesystem - Supports combining and overlaying file systems.
  • +

    +

    +

    +

  • procfs/ pseudo-filesystem support.
  • +

    +

    +

    +

  • + A binary loader with support for the following formats: +
      +
    • Separately linked ELF modules.
    • +
    • + Separately linked NXFLAT modules. + NXFLAT is a binary format that can be XIP from a file system. +
    • +
    • + "Built-In" applications.
    • + +
    +
  • +

    +

    +

    +

  • PATH variable support.
  • +

    +

    +

    +

  • + File transfers via TFTP and FTP (get and put), HTML (wget), and Zmodem (sz and rz). +
  • +
  • + Intel HEX file conversions. +
  • +

    +

    +

    + 1 + FAT long file name support may be subject to certain Microsoft patent restrictions if enabled. + See the top-level COPYING file for details. +

    +
    + Device Drivers +

    +

    +

  • Supports character and block drivers as well as specialized driver interfaces.
  • +

    +

    +

    +

  • Full VFS integration.
  • +

    +

    +

    +

  • Asynchronous I/O (AIO)
  • +

    +

    +

    +

  • + Network, USB (host), USB (device), serial, I2C, I2S, NAND, CAN, ADC, DAC, PWM, Quadrature Encoder, I/O Expander, Wireless, generic timer, and watchdog timer driver architectures. +
  • +

    +

    +

    +

  • + RAMDISK, pipes, FIFO, /dev/null, /dev/zero, /dev/random, and loop drivers. +
  • +

    +

    +

    +

  • Generic driver for SPI-based or SDIO-based MMC/SD/SDH cards.
  • +

    +

    +

    +

  • Graphics: framebuffer drivers, graphic- and segment-LCD drivers.
  • +

    +

    +

    +

  • Audio subsystem: CODECs, audio input and output drivers. Command line and graphic media player applications.
  • +

    +

    +

    +

  • Cryptographic subsystem.
  • +

    +

    +

    +

  • Power Management sub-system.
  • +

    +

    +

    +

  • ModBus support provided by built-in FreeModBus version 1.5.0.
  • +

    +
    + C/C++ Libraries +

    +

    +

  • Standard C Library Fully integrated into the OS.
  • +

    +

    +

    +

  • Includes floating point support via a Standard Math Library.
  • +

    +

    +

    +

  • Add-on uClibc++ module provides Standard C++ Library (LGPL).
  • +

    +
    + Networking +

    +

    +

  • Multiple network interface support; multiple network link layer support.
  • +

    +

    +

    +

  • IPv4, IPv6, TCP/IP, UDP, ICMP, IGMPv2 (client) stacks.
  • +

    +

    +

    +

  • Stream and datagram sockets.
  • +

    +

    +

    +

  • Raw socket and local, Unix domain socket support.
  • +

    +

    +

    +

  • DNS name resolution.
  • +

    +

    +

    +

  • SLIP, TUN/PPP, Local loopback devices
  • +

    +

    +

    +

  • A port cJSON
  • +

    +

    +

    +

  • Small footprint.
  • +

    +

    +

    +

  • BSD compatible socket layer.
  • +

    +

    +

    +

  • Networking utilities (DHCP server and client, SMTP client, TELNET client, FTP server and client, TFTP client, HTTP server and client, PPPD, NTP client). + Inheritable TELNET sessions (as "controlling terminal")
  • +

    +

    +

    +

  • ICMPv6 autonomous auto-configuration
  • +

    +

    +

    +

  • + NFS Client. Client side support for a Network File System (NFS, version 3, UDP). +
  • +

    +

    +

    +

  • + A NuttX port of Jeff Poskanzer's THTTPD HTTP server + integrated with the NuttX binary loader to provide true, embedded CGI. +
  • +

    +

    +

    +

  • + PHY Link Status Management. +
  • +

    +

    +

    +

  • + UDP Network Discovery (Contributed by Richard Cochran). +
  • +

    +

    +

    +

  • + XML RPC Server (Contributed by Richard Cochran). +
  • +

    +

    +

    +

  • + Support for networking modules (e.g., the TI CC3000 WLAN module). +
  • +

    +
    + FLASH Support +

    +

    +

  • MTD-inspired interface for Memory Technology Devices.
  • +

    +

    +

    +

  • NAND support.
  • +

    +

    +

    +

  • FTL. Simple Flash Translation Layer support file systems on FLASH.
  • +

    +

    +

    +

  • NXFFS. the NuttX wear-leveling FLASH file system.
  • +

    +

    +

    +

  • Support for SPI-based FLASH and FRAM devices.
  • +

    +
    + USB Host Support +

    +

    +

  • USB host architecture for USB host controller drivers and device-dependent USB class drivers.
  • +

    +

    +

    +

  • USB host controller drivers available for the Atmel SAMA5Dx, NXP LPC17xx, LPC31xx, and STmicro STM32
  • +

    +

    +

    +

  • Device-dependent USB class drivers available for USB mass storage, CDC/ACM serial, HID keyboard, and HID mouse.
  • +

    +

    +

    +

  • Seam-less support for USB hubs.
  • +

    +
    + USB Device Support +

    +

    +

  • Gadget-like architecture for USB device controller drivers and device-dependent USB class drivers.
  • +

    +

    +

    +

  • USB device controller drivers available for the PIC32, Atmel AVR, SAM3, SAM4, and SAMA5Dx, NXP LPC17xx, LPC214x, LPC313x, and LPC43xx, Silicon Laboraties EFM32, STMicro STM32 F1, F2, F3, and F4, and TI DM320.
  • +

    +

    +

    +

  • Device-dependent USB class drivers available for USB serial (CDC/ACM and a PL2303 emulation), for USB mass storage, and for a composite CDC/ACM and mass storage device.
  • +

    +

    +

    +

  • Built-in USB device and USB host trace functionality for non-invasive USB debug.
  • +

    +
    + Graphics Support +

    +

    +

  • Framebuffer drivers.
  • +

    +

    +

    +

  • Graphic LCD drivers for both parallel and SPI LCDs and OLEDs.
  • +

    +

    +

    +

  • Segment LCD drivers.
  • +

    +

    +

    +

  • + NX: A graphics library, tiny windowing system and tiny font support that works with either framebuffer or LCD drivers. + Documented in the NX Graphics Subsystem + manual. +
  • +

    +

    +

    +

  • Font management sub-system.
  • +

    +

    +

    +

  • + NxWidgets: NXWidgets is library of graphic objects, or "widgets," (labels, buttons, text boxes, images, sliders, progress bars, etc.). NXWidgets is written in C++ and integrates seamlessly with the NuttX NX graphics and font management subsystems. +
  • +

    +

    +

    +

  • + NxWM: NxWM is the tiny NuttX window manager based on NX and NxWidgets. +
  • +

    +
    + Input Devices +

    +

    +

  • Touchscreen, USB keyboard, GPIO-based buttons and keypads.
  • +

    +
    + Analog Devices +

    +

    +

  • Support for Analog-to-Digital conversion (ADC), Digital-to-Analog conversion (DAC), multiplexers, and amplifiers.
  • +

    +
    + Motor Control +

    +

    +

  • Pulse width modulation (PWM) / Pulse count modulation.
  • +

    +
    + +

    + NuttX Add-Ons. + The following packages are available to extend the basic NuttX feature set: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + NuttShell (NSH) +

    +

    +

  • A small, scalable, bash-like shell for NuttX with rich feature set and small footprint. + See the NuttShell User Guide.
  • +

    +
    + BAS 2.4 +

    +

    +

  • Seamless integration of Michael Haardt's BAS 2.4: + "Bas is an interpreter for the classic dialect of the programming language + BASIC. It is pretty compatible to typical BASIC interpreters of the 1980s, + unlike some other UNIX BASIC interpreters, that implement a different + syntax, breaking compatibility to existing programs. Bas offers many ANSI + BASIC statements for structured programming, such as procedures, local + variables and various loop types. Further there are matrix operations, + automatic LIST indentation and many statements and functions found in + specific classic dialects. Line numbers are not required."
  • +

    +
    + Pascal Compiler with NuttX runtime P-Code interpreter add-on +

    +

    +

  • The Pascal add-on is available for download from the + Bitbucket.org + website.
  • +

    +
    + +

    + Look at all those files and features... How can it be a tiny OS?. + The NuttX feature list (above) is fairly long and if you look at the NuttX + source tree, you will see that there are hundreds of source files comprising + NuttX. How can NuttX be a tiny OS with all of that? +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Lots of Features -- More can be smaller! +

    +

    + The philosophy behind that NuttX is that lots of features are great... BUT + also that if you don't use those features, then you should not have to pay a penalty + for the unused features. + And, with NuttX, you don't! If you don't use a feature, it will not + be included in the final executable binary. + You only have to pay the penalty of increased footprint for the features + that you actually use. +

    +

    + Using a variety of technologies, NuttX can scale from the very tiny to + the moderate-size system. I have executed NuttX with some simple applications + in as little as 32K total memory (code and data). + On the other hand, typical, richly featured NuttX builds require more like 64K + (and if all of the features are used, this can push 100K). +

    +
    + Many, many files -- More really is smaller! +

    +

    + One may be intimidated by the size NuttX source tree. There are hundreds of source files! + How can that be a tiny OS? + Actually, the large number of files is one of the tricks to keep NuttX small and + as scalable as possible. + Most files contain only a single function. + Sometimes just one tiny function with only a few lines of code. + Why? +

    +
      +
    • + Static Libraries. + Because in the NuttX build processed, objects are compiled and saved into + static libraries (archives). + Then, when the file executable is linked, only the object files that are needed + are extracted from the archive and added to the final executable. + By having many, many tiny source files, you can assure that no code that you do + not execute is ever included in the link. + And by having many, tiny source files you have better granularity -- + if you don't use that tiny function of even just a few lines of code, it will + not be included in the binary. +
    • +
    +
    + Other Tricks +

    +

    + As mentioned above, the use of many, tiny source files and linking from static + libraries keeps the size of NuttX down. + Other tricks used in NuttX include: +

    +
      +
    • + Configuration Files. + Before you build NuttX, you must provide a configuration file that specifies + what features you plan to use and which features you do not. + This configuration file contains a long list of settings that control + what is built into NuttX and what is not. + There are hundreds of such settings + (see the Configuration Variable Documentation + for a partial list that excludes platform specific settings). + These many, many configuration options allow NuttX to be highly tuned to + meet size requirements. + The downside to all of these configuration options is that it greatly + complicates the maintenance of NuttX -- but that is my problem, not yours. +
    • +
    • + Weak Symbols + The GNU toolchain supports weak symbols and these also help to keep + the size of NuttX down. + Weak symbols prevent object files from being drawn into the link even if they + are accessed from source code. + Careful use of weak symbols is another trick for keep unused code out of the + final binary. +
    • +
    +
    + + + + + + +
    +

    NuttX Discussion Group

    +
    + +

    + Most NuttX-related discussion occurs on the Yahoo! NuttX group. + You are cordially invited to join. + I make a special effort to answer any questions and provide any help that I can. +

    + + + + + +
    +

    Downloads

    +
    + +

    Git Repository

    +

    + The working version of NuttX is available from the Bitbucket GIT repository here. + That same page provides the URLs and instructions for cloning the GIT repository. +

    + +

    Released Versions

    +

    + In addition to the ever-changing GIT repository, there are frozen released versions of NuttX available. + The current release is NuttX 7.15. + NuttX 7.15 is the 115th release of NuttX. + It was released on March 27, 2016, and is available for download from the + Bitbucket.org website. + Note that the release consists of two tarballs: nuttx-7.15.tar.gz and apps-7.15.tar.gz. + Both may be needed (see the top-level nuttx/README.txt file for build information). +

    + +

    Release Notes and Change Logs:

    + + + + + + + +
    +

    Supported Platforms

    +
    + +

    Supported Platforms by CPU core. + The number of ports to this CPU follow in parentheses. + The state of the various ports vary from board-to-board. + Follow the links for the details: +

    +
    + + + + + +
    +
  • Linux/Cygwin user mode simulation (1)
  • +
  • ARM + +
  • Atmel AVR + +
  • +
    +
  • Freescale + +
  • +
  • Intel + +
  • +
  • MicroChip + +
  • +
  • Renesas/Hitachi: + +
  • +
    +
  • ZiLOG + +
  • +
    + +

    Supported Platforms by Manufacturer/MCU Family. + CPU core type follows in parentheses. + The state of the various ports vary from MCU to MCU. + Follow the links for the details: +

    +
    + + + + + + + +
    +
  • Allwinner +
      +
    • A10 (Cortex-A8)
    • +
    +
  • +
  • Atmel + +
  • +
  • Freescale + +
  • +
  • Host PC based simulations + +
  • +
  • Intel + +
  • +
  • MicroChip + +
  • +
    +
  • Moxa + +
  • +
  • nuvoTon + +
  • +
  • NXP + +
  • +
  • Renesas/Hitachi: + +
  • +
  • Silicon Laboratories, Inc. + +
  • +
  • STMicroelectronics + +
  • +
    + +
  • Texas Instruments (some formerly Luminary) + +
  • +
  • ZiLOG + +
  • +
    + +
    + +

    + Details. + The details, caveats and fine print follow. + For even more information see the README files that can be found here. +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Linux User Mode. +

    +

    + A user-mode port of NuttX to the x86 Linux/Cygwin platform is available. + The purpose of this port is primarily to support OS feature development. +

    +
      +

      + STATUS: + Does not support interrupts but is otherwise fully functional. + Refer to the NuttX README file for further information. +

      +
    +
    + ARM7TDMI. +

    +

    + TI TMS320C5471 + (also called C5471 or TMS320DA180 or DA180). + NuttX operates on the ARM7 of this dual core processor. + This port uses the Spectrum Digital + evaluation board with a GNU arm-nuttx-elf toolchain* under Linux or Cygwin. +

    +
      +

      + STATUS: + This port is complete, verified, and included in the initial NuttX release. + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + TI Calypso. + This port supports the TI "Calypso" MCU used in various cell phones (and, in particular, + by the Osmocom-bb project). + Like the c5471, NuttX operates on the ARM7 of this dual core processor. + Board support is available for the Motorola C139, C155 and W220 phones and for the Pirelli DP-L10 phone. +

    +
      +

      + STATUS: + This port was contributed by Denis Carilki and includes the work of Denis Carikli, Alan Carvalho de Assis, and Stefan Richter. + Calypso support first appeared in NuttX-6.17 with LCD drivers. + Support for the Calypso keyboard was added in NuttX-6.24 by Denis Carilki. + Refer to the NuttX board README files for the Compal E88, Compal E99 and Pirelli DP-L10 phones for further information. +

      +
    +



    +

    + NXP LPC214x. + Support is provided for the NXP LPC214x family of processors. In particular, + support is provided for (1) the mcu123.com lpc214x evaluation board (LPC2148) + and (1) the The0.net ZPA213X/4XPA development board (with the The0.net UG-2864AMBAG01 OLED) + This port also used the GNU arm-nuttx-elf toolchain* under Linux or Cygwin. +

    +
      +

      + STATUS: + This port boots and passes the OS test (apps/examples/ostest). + The port is complete and verified. As of NuttX 0.3.17, the port includes: + timer interrupts, serial console, USB driver, and SPI-based MMC/SD card + support. A verified NuttShell (NSH) + configuration is also available. + Refer to the NuttX board README files for the mcu123.com and for the ZPA213X/4XPA boards for further information. +

      +

      + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU toolchain, 3) Cygwin/MSYS + with Windows native toolchain (CodeSourcery or devkitARM), or 4) Native Windows. A DIY toolchain for Linux + or Cygwin is provided by the NuttX + buildroot + package. +

      +
    +



    +

    + NXP LPC2378. + Support is provided for the NXP LPC2378 MCU. In particular, + support is provided for the Olimex-LPC2378 development board. + This port was contributed by Rommel Marcelo is was first released in NuttX-5.3. + This port also used the GNU arm-nuttx-elf toolchain* under Linux or Cygwin. +

    +
      +

      + STATUS: + This port boots and passes the OS test (apps/examples/ostest) and includes a + working implementation of the NuttShell (NSH). + The port is complete and verified. + As of NuttX 5.3, the port included only basic timer interrupts and serial console support. + In NuttX 7.1, Lizhuoyi contributed additional I2C and SPI drivers. + Refer to the NuttX board README file for further information. +

      +

      + Development Environments: (Same as for the NXP LPC214x). +

      +
    +



    +

    + STMicro STR71x. + Support is provided for the STMicro STR71x family of processors. In particular, + support is provided for the Olimex STR-P711 evaluation board. + This port also used the GNU arm-nuttx-elf toolchain* under Linux or Cygwin. +

    +
      +

      + STATUS: + Integration is complete on the basic port (boot logic, system time, serial console). + Two configurations have been verified: (1) The board boots and passes the OS test + with console output visible on UART0, and the NuttShell (NSH) + is fully functional with interrupt driven serial console. An SPI driver is available + but only partially tested. Additional features are needed: USB driver, MMC integration, + to name two (the slot on the board appears to accept on MMC card dimensions; I have only + SD cards). + An SPI-based ENC28J60 Ethernet driver for add-on hardware is available and + but has not been fully verified on the Olimex board (due to issues powering the ENC28J60 add-on board). + Refer to the NuttX board README file for further information. +

      +

      + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU toolchain, 3) Cygwin/MSYS + with Windows native toolchain (CodeSourcery or devkitARM), or 4) Native Windows. A DIY toolchain for Linux + or Cygwin is provided by the NuttX + buildroot + package. +

      +
    +
    + ARM920T. +

    +

    + Freescale MC9328MX1 or i.MX1. + This port uses the Freescale MX1ADS development board with a GNU arm-nuttx-elf toolchain* + under either Linux or Cygwin. +

    +
      +

      + STATUS: + This port has stalled due to development tool issues. + Coding is complete on the basic port (timer, serial console, SPI). + Refer to the NuttX board README file for further information. +

      +
    +
    + ARM926EJS. +

    +

    + TI TMS320DM320 + (also called DM320). + NuttX operates on the ARM9 of this dual core processor. + This port uses the + Neuros OSD + with a GNU arm-nuttx-elf toolchain* under Linux or Cygwin. + The port was performed using the OSD v1.0, development board. +

    +
      +

      + STATUS: + The basic port (timer interrupts, serial ports, network, framebuffer, etc.) is complete. + All implemented features have been verified with the exception of the USB device-side + driver; that implementation is complete but untested. + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + NXP LPC3131. + Two boards based on the NXP LPC3131 are supported: +

    +
      +
    • +

      + First, a port for the NXP LPC3131 on the Embedded Artists EA3131 development board was first released in NuttX-5.1 (but was not functional until NuttX-5.2). +

      +
        +

        + STATUS: + The basic EA3131 port is complete and verified in NuttX-5.2. + This basic port includes basic boot-up, serial console, and timer interrupts. + This port was extended in NuttX 5.3 with a USB high speed driver contributed by David Hewson. + David also contributed I2C and SPI drivers plus several important LPC313x USB bug fixes that appear in the NuttX 5.6 release. + This port has been verified using the NuttX OS test, USB serial and mass storage tests and includes a working implementation of the NuttShell (NSH). +

        +

        + Support for on-demand paging has been developed for the EA3131. + That support would all execute of a program in SPI FLASH by paging code sections out of SPI flash as needed. + However, as of this writing, I have not had the opportunity to verify this new feature. +

        +

        + Refer to the Embedded Artists EA3131 board README file for further information. +

        +
      +
    • +
    • +

      + A second port to the NXP LPC3131 on the Olimex LPC-H3131 development board was added in NuttX-6.32. +

      +
        +

        + STATUS: + The basic H3131 port is complete and verified in NuttX-6.3. + It is similar to the EA3131 port except: (1) I have not yet gotten the SDRAM to work, and (2) this board was used to develop and verify the USB 2.0, low-/full-/high-speed EHCI host controller driver. + NOTE: That driver should work on the EA3131 as well. However, the EA3131 uses a PCA9532 PWM part to controller the port power so the it would not quite be a simple drop-in. +

        +

        + Refer to the Olimex LPC-H3131 board README file for further information. +

        +
      +
    • +
    +



    + NXP LPC315x. + Support for the NXP LPC315x family has been incorporated into the code base as of NuttX-6.4. + Support was added for the Embedded Artists EA3152 board in NuttX-6.11. +

    +
      +

      + STATUS: + Basic support is in place for both the LPC3152 MCU and the EA3152 board. + Verification of the port was deferred due to tool issues + However, because of the high degree of compatibility between the LPC313x and LPC315x family, it + is very likely that the support is in place (or at least very close). + At this point, verification of the EA3152 port has been overcome by events and + may never happen. + However, the port is available for anyone who may want to use it. + Refer to the NuttX board README file for further information. +

      +
    +
    + Other ARMv4. +

    +

    + MoxaRT + A port to the Moxa NP51x0 series of 2-port advanced RS-232/422/485 serial device servers was contributed by Anton D. Kachalov in NuttX-7.11. + This port includes a NuttShell (NSH) configuraion with support for the Faraday FTMAC100 Ethernet MAC Driver. +

    +
    + ARM Cortex-A5. +

    +

    + Atmel SAMA5D2. +

    +

      +
    • Atmel SAMA5D2 Xplained Ultra development board. + This is the port of NuttX to the Atmel SAMA5D2 Xplained Ultra development board. + This board features the Atmel SAMA5D27 microprocessor. +

      +
        +

        + STATUS. + Initial support for the SAMA5D2 was released in NuttX-7.12. + This port is code complete but, however, still a work in progress and has not been verified in this this initial release. +

        +
      +
    +



    +

    + Atmel SAMA5D3. + There are ports to two Atmel SAMA5D3 boards: +

    +

      +
    • Atmel SAMA5D3x-EK development boards. + This is the port of NuttX to the Atmel SAMA5D3x-EK development boards (where x=1,3,4, or 5). + These boards feature the Atmel SAMA5D3x microprocessors. + Four different SAMA5D3x-EK kits are available +

      + +

      + The each kit consist of an identical base board with different plug-in modules for each CPU. + All four boards are supported by NuttX with a simple reconfiguration of the processor type. +

      +
        +

        + STATUS. + Initial support for the SAMA5D3x-EK was released in NuttX-6.29. + That initial support was minimal: + There are simple test configurations that run out of internal SRAM and extended configurations that run out of the on-board NOR FLASH: +

        +
          +
        • + A barebones NuttShell (NSH) configuration that can be used as the basis for further application development. +
        • +
        • + A full-loaded NuttShell (NSH) configuration that demonstrates all of the SAMA5D3x features. +
        • +
        +

        + The following support was added in Nuttx 6.30: +

        +
          +
        • + DMA support, and +
        • +
        • + PIO interrupts, +
        • +
        +

        + And drivers for +

        +
          +
        • + SPI (with DMA support), +
        • +
        • + AT25 Serial Flash, +
        • +
        • + Two Wire Interface (TWI), and +
        • +
        • + HSMCI memory cards. +
        • +
        +

        + NuttX-6.30 also introduces full USB support: +

        +
          +
        • + High speed device controller driver, +
        • +
        • + OHCI (low- and full-speed) and +
        • +
        • + EHCI (high-speed) host controller driver support. +
        • +
        +

        + With NuttX-6.31, these additional drivers were added: +

        +
          +
        • + A 10/100Base-T Ethernet (EMAC) driver, +
        • +
        • + A 1000Base-T Ethernet (GMAC) driver, +
        • +
        • + A Real Time Clock (RTC) driver and integrated with the NuttX system time logic +
        • +
        • + /dev/random using the SAMA5D3x True Random Number Generator (TRNG), +
        • +
        • + A Watchdog Timer (WDT) driver, +
        • +
        • + A Timer/Counter (TC) library with interface that make be used by other drivers that need timer support, +
        • +
        • + An ADC driver that can collect multiple samples using the sequencer, can be trigger by a timer/counter, and supports DMA data transfers, +
        • +
        • + A touchscreen driver based on the special features of the SAMA5D3 ADC peripheral, + An LCD controller (LCDC) frame buffer driver, and +
        • +
        • + A CAN driver (Testing of the CAN has been delayed because of cabling issues). +
        • +
        +

        + Additional board configurations were added to test and demonstrate these new drivers including new graphics and NxWM configurations. +

        +

        + These drivers were added in NuttX-6.32: +

        +
          +
        • + A PWM driver with DMA support +
        • +
        • + An SSC-based I2S driver +
        • +
        • + Support for Programmable clock outputs +
        • +
        • + NAND support including support for the PMECC hardware ECC and for DMA transfers. +
        • +
        +

        + DBGU support was added in NuttX-7.2 (primarily for the SAMA5D3 Xplained board). +

        +

        + NuttX-7.4 added support for the on-board WM8904 CODEC chip and for Tickless operation. +

        +

        + Refer to the NuttX board README file for further information. +

        +
      +
    • +

      + Atmel SAMA5D3 Xplained development board + This is the port of NuttX to the Atmel SAMA5D3 Xplained development board. + The board features the Atmel SAMA5D36 microprocessor. + See the Atmel Website for additional information about this board. +

      +

      + STATUS. + This port is complete as of this writing and ready for general use. + The basic port is expected to be simple because of the similarity to the SAMAD3x-EK boards and is available in the NuttX 7.2 release. +

      +

      + Most of the drivers and capabilities of the SAMA5D3x-EK boards can be used with the SAMA5D3 Xplained board. + The primary difference between the ports is that the SAMA5D3x-EK supports NOR FLASH and NuttX can be configured to boot directly from NOR FLASH. + The SAMA5D3 Xplained board does not have NOR FLASH and, as a consequence NuttX must boot into SDRAM with the help of U-Boot. +

      +

      + Refer to the NuttX board README file for further information. +

      +
    • +
    +



    +

    + Atmel SAMA5D4. + There is a port in progress on one Atmel SAMA5D4 board: +

    +

      +
    • Atmel SAMA5D4-EK/MB development boards + This is the port of NuttX to the Atmel SAMA5D4-MB Rev C. development board (which should be compatible with the SAMA5D4-EK). + These boards feature the Atmel SAMA5D44 microprocessors with compatibility with most of the SAMA5D3 peripherals. +

      +

      STATUS. + At the time of the release of NuttX-7.3, the basic port for the SAMA5D4-MB was complete. + The board had basic functionality. + But full functionality was not available until NuttX-7.4. + In NuttX-7.4 support was added for the L2 cache, many security features, XDMAC, HSMCI and Ethernet integrated with XDMAC, the LCDC, TWI, SSC, and most of the existing SAMA5 drivers. + Timers were added to support Tickless operation. + The TM7000 LCDC with the maXTouch multi-touch controller are also fully support in a special NxWM configuration for that larger display. + Support for a graphics media player is included (although there were issues with the WM8904 audio CODEC on my board). + An SRAM bootloader was also included. + Refer to the NuttX board README file for current status. +

    • +
    +



    +

    + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU toolchain, 3) Cygwin/MSYS with Windows native toolchain, or 4) Native Windows. + All testing has been performed with the CodeSourcery toolchain (GCC version 4.7.3) in the Cygwin environment under Windows. +

    +
    + ARM Cortex-A8. +

    +

    + Allwinner A10. + These following boards are based on the Allwinner A10 have are supported by NuttX: +

    +
      +
    • +

      + pcDuino v1. + A port of NuttX to the pcDuino v1 board was first released in NuttX-6.33. + See http://www.pcduino.com/ for information about pcDuino Lite, v1, and v2 boards. + These boards are based around the Allwinner A10 Cortex-A8 CPU. + This port was developed on the v1 board, but the others may be compatible: +

      +

      + Refer to the NuttX board README file for further information. +

      +

      + STATUS. + This port was an experiment was was not completely developed. + This configuration builds and runs an NuttShell (NSH), but only if a patch to work around some issues is applied. + While not ready for "prime time", the pcDuino port is functional and could the basis for a more extensive development. + There is, at present, no work in progress to extend this port, however. +

      +
    • +
    +
    + ARM Cortex-A9. +

    +

    + NXP/Freescale i.MX6. + A port is underway for the following i.MX6 board +

    +

      +
    • +

      + Sabre-6Quad. + This is a port to the NXP/Freescale Sabre-6Quad board. + Refer to the NuttX board README file for further information. +

      +

      + STATUS: + The basic, minimal port is code complete and introduced in NuttX-7.15, but has not yet been tested. + I am still waiting for the reciept of the Sabre board. + Expect to see the verified Sabre-6Quad support (with SMP!) in NuttX-7.16. +

      +
    • +
    +
    + ARM Cortex-R4. +

    +

    + TI/Hercules TMS570LS04xx. + A port is underway for the Texas Instruments Hercules TMS570LS04x/03x LaunchPad Evaluation Kit (LAUNCHXL-TMS57004) featuring the Hercules TMS570LS0432PZ chip. +

    +
      +

      + STATUS. + This is currently in progress but the effort is stalled due to tool-related issues. + Refer to the NuttX board README file for further information. +

      +

      + Toolchain: + The TMS570 is a big-endian ARM platform and requires a big-endian ARM toolchain. + All testing has been performed using a big-endian NuttX buildroot toolchain. + Instructions for building this toolchain are included in the board README file. +

      +
    +
    + ARM Cortex-M0/M0+. +

    +

    + nuvoTon NUC120. + This is a port of NuttX to the nuvoTon NuTiny-SDK-NUC120 that features the NUC120LE3AN MCU. +

    +
      +

      + STATUS. + Initial support for the NUC120 was released in NuttX-6.26. + This initial support is very minimal: + There is a NuttShell (NSH) configuration that might be the basis for an application development. + As of this writing, more device drivers are needed to make this a more complete port. + Refer to the NuttX board README file for further information. +

      +

      + Memory Usage. + For a full-featured RTOS such as NuttX, providing support in a usable and meaningful way within the tiny memories of the NUC120 demonstrates the scalability of NuttX. The NUC120LE2AN comes in a 48-pin package and has 128KB FLASH and 16KB of SRAM. + When running the NSH configuration (itself a full up application), there is still more than 90KB of FLASH and 10KB or SRAM available for further application development). +

      +

      + Static memory usage can be shown with size command: +

      +
        +$ size nuttx
        +   text    data     bss     dec     hex filename
        +  35037     106    1092   36235    8d8b nuttx
        +
      +

      + NuttX, the NSH application, and GCC libraries use 34.2KB of FLASH leaving 93.8KB of FLASH (72%) free from additional application development. + Static SRAM usage is about 1.2KB (<4%) and leaves 14.8KB (86%) available for heap at runtime. + SRAM usage at run-time can be shown with the NSH free command: +

      +
        +NuttShell (NSH) NuttX-6.26
        +nsh> free
        +             total       used       free    largest
        +Mem:         14160       3944      10216       10216
        +nsh>
        +
      +

      + You can see that 10.0KB (62%) is available for further application development. +

      +

      + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU toolchain, 3) Cygwin/MSYS + with Windows native toolchain, or 4) Native Windows. + A DIY toolchain for Linux or Cygwin is provided by the NuttX + buildroot package. +

      +



    +

    + FreeScale KL25Z. + There are two board ports for the KL25Z parts: +

    +
      +

      Freedom KL25Z. + This is a port of NuttX to the Freedom KL25Z board that features the MKL25Z128 Cortex-M0+ MCU, 128KB of FLASH and 16KB of SRAM. + See the Freescale website for further information about this board. +

      +
        +

        + STATUS. + This is the work of Alan Carvalho de Assis. + Verified, initial, minimal support for the Freedom KL25Z is in place in NuttX 6.27 and 6.28: + There is a working NuttShell (NSH) configuration that might be the basis for an application development. + As of NuttX-6.28 more device driver development would be needed to make this a complete port, particularly to support USB OTG. + A TSI and a SPI driver were added in NuttX-6.29. + Alan contributed a PWM driver in NuttX-6.32. + Refer to the Freedom KL25Z board README file for further information. +

        +
      +

      + PJRC Teensy-LC. + This is a port of NuttX to the PJRC Teensy-LC board that features the MKL25Z64 Cortex-M0+ MCU, 64KB of FLASH and 8KB of SRAM. + The Teensy LC is a DIP style breakout board for the MKL25Z64 and comes with a USB based bootloader. + See the Freescale website for further information about this board. +

      +
        +

        + STATUS. + This is the work of Michael Hope. + Verified, initial support for the Teensy-LC first appeared in NuttX-7.10. + Refer to the Teensy-LC board README file for further information. +

        +
      +
    +



    +

    + FreeScale Freedom KL26Z. + This is a port of NuttX to the Freedom KL25Z board that features the MK26Z128VLH4 Cortex-M0+ MCU, 128KB of FLASH and 16KB of SRAM. + See the Freescale website for further information about this board. +

    +
      +

      + STATUS. + This work was contributed in NuttX 7.8 by Derek B. Noonburg. + The board support is very similar to the Freedom-KL25Z. + It was decided to support this a a separate board, however, due to some small board-level differences. + Refer to the Freedom KL26Z board README file for further information. +

      +
    +



    +

    + Atmel SAMD20. + The port of NuttX to the Atmel SAMD20-Xplained Pro development board. + This board features the ATSAMD20J18A MCU (Cortex-M0+ with 256KB of FLASH and 32KB of SRAM). +

    +
      +

      + STATUS. + The initial SAMD20 Xplained Pro release (NuttX 7.1) included a functional NuttShell (NSH) configuration. + An SPI driver was also included to support the OLED1 and I/O1 modules. + That SPI driver, however, was not completed verified due to higher priority tasks that came up (I hope to get back to this later). + Refer to the SAMD20 Explained Pro board README file for further information. +

      +
    +



    +

    + Atmel SAML21. + The port of NuttX to the Atmel SAML21-Xplained Pro development board. + This board features the ATSAML21J18A MCU (Cortex-M0+ with 256KB of FLASH and 32KB of SRAM). +

    +
      +

      + STATUS. + This is a work in progress. + Initial support for the SAML21 Xplained Pro was release in the NuttX 7.10. + This initial support included a basic configuration for the NuttShell (NSH) + (see the NSH User Guide). + Refer to the SAML21 Explained Pro board README file for further information. +

      +
    +



    +

    + NXP LPC11xx. + Support is provided for the NXP LPC11xx family of processors. + In particular, support is provided for LPCXpression LPC1115 board. + This port was contributed by Alan Carvalho de Assis. +

    +
      +

      + STATUS: + The first released version was provided in NuttX 7.10. + Refer to the board README.txt file for further information. +

      +
    +
    + ARM Cortex-M3. +

    +

    + TI/Stellaris LM3S6432. + This is a port of NuttX to the Stellaris RDK-S2E Reference Design Kit and the MDL-S2E Ethernet to Serial module + (contributed by Mike Smith). +

    +



    +

    + TI/Stellaris LM3S6432S2E. + This port uses Serial-to-Ethernet Reference Design Kit (RDK-S2E) and has similar support as for the other Stellaris family members. + A configuration is available for the NuttShell (NSH) + (see the NSH User Guide). + The NSH configuration including networking support with a Telnet NSH console. + This port was contributed by Mike Smith. +

    +
      +

      + STATUS: + This port was was released in NuttX 6.14. + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + TI/Stellaris LM3S6918. + This port uses the Micromint Eagle-100 development + board with a GNU arm-nuttx-elf toolchain* under either Linux or Cygwin. +

    +
      +

      + STATUS: + The initial, release of this port was included in NuttX version 0.4.6. + The current port includes timer, serial console, Ethernet, SSI, and microSD support. + There are working configurations to run the NuttShell + (NSH), the NuttX networking test, and the uIP web server. + Refer to the NuttX board README file for further information. +

      +
    +

    + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU toolchain, 3) Cygwin/MSYS + with Windows native toolchain (CodeSourcery or devkitARM), or 4) Native Windows. A DIY toolchain for Linux + or Cygwin is provided by the NuttX + buildroot + package. +

    +



    +

    + TI/Stellaris LM3S6965. + This port uses the Stellaris LM3S6965 Ethernet Evalution Kit with a GNU arm-nuttx-elf toolchain* + under either Linux or Cygwin. +

    +
      +

      + STATUS: + This port was released in NuttX 5.5. + Features are the same as with the Eagle-100 LM3S6918 described above. + The apps/examples/ostest configuration has been successfully verified and an + NSH configuration with Telnet support is available. + MMC/SD and Networking support was not been thoroughly verified: + Current development efforts are focused on porting the NuttX window system (NX) + to work with the Evaluation Kits OLED display. +

      +

      + NOTE: As it is configured now, you MUST have a network connected. + Otherwise, the NSH prompt will not come up because the Ethernet + driver is waiting for the network to come up. + Refer to the NuttX board README file for further information. +

      +
    +

    + Development Environments: See the Eagle-100 LM3S6918 above. +

    +



    +

    + TI/Stellaris LM3S8962. + This port uses the Stellaris EKC-LM3S8962 Ethernet+CAN Evalution Kit with a GNU arm-nuttx-elf toolchain* + under either Linux or Cygwin. + Contributed by Larry Arnold. +

    +
      +

      + STATUS: + This port was released in NuttX 5.10. + Features are the same as with the Eagle-100 LM3S6918 described above. + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + TI/Stellaris LM3S9B96. + Header file support was contributed by Tiago Maluta for this part. + Jose Pablo Rojas V. is used those header file changes to port NuttX to the TI/Stellaris EKK-LM3S9B96. + That port was available in the NuttX-6.20 release. + Refer to the NuttX board README file for further information. +

    +



    +

    + SiLabs EFM32 Gecko. + This is a port for the Silicon Laboratories' EFM32 Gecko family. + Board support is available for the following: +

    +
      +
    1. +

      + SiLabs EFM32 Gecko Starter Kit (EFM32-G8XX-STK). + The Gecko Starter Kit features: +

      +

        +
      • EFM32G890F128 MCU with 128 kB flash and 16 kB RAM +
      • 32.768 kHz crystal (LXFO) and 32 MHz crystal (HXFO) +
      • Advanced Energy Monitoring +
      • Touch slider +
      • 4x40 LCD +
      • 4 User LEDs +
      • 2 pushbutton switches +
      • Reset button and a switch to disconnect the battery. +
      • On-board SEGGER J-Link USB emulator +
      • ARM 20 pin JTAG/SWD standard Debug in/out connector +
      +

      + STATUS. + The basic port is verified and available now. This includes + on-board LED and button support and a serial console available + on LEUART0. A single configuration is available using the + NuttShell NSH and the LEUART0 serial console. + DMA and USART-based SPI supported are included, but not fully tested. +

      +

      + Refer to the EFM32 Gecko Starter Kit README.txt file for further information. +

      +
    2. +
    3. +

      + Olimex EFM32G880F120-STK. + This board features: +

      +
        +
      • EFM32G880F128 with 128 kB flash and 16 kB RAM +
      • 32.768 kHz crystal (LXFO) and 32 MHz crystal (HXFO) +
      • LCD custom display +
      • DEBUG connector with ARM 2x10 pin layout for programming/debugging with ARM-JTAG-EW +
      • UEXT connector +
      • EXT extension connector +
      • RS232 connector and driver +
      • Four user buttons +
      • Buzzer +
      +

      + STATUS. + The board suppport is complete but untested because of tool-related issues. An OpenOCD compatible, SWD debugger would be required to make further progress in testing. +

      +

      + Refer to the Olimex EFM32G880F120-STK README.txt for further information. +

      +
    4. +
    +



    +

    + SiLabs EFM32 Giant Gecko. + This is a port for the Silicon Laboratories' EFM32 Giant Gecko family. + This board features the EFM32GG990F1024 MCU with 1 MB flash and 128 kB RAM. +

    + Board support is available for the following: +

    +
      +
    • +

      + SiLabs EFM32 Giant Gecko Starter Kit t (EFM32GG-STK3700). + The Gecko Starter Kit features: +

      +

        +
      • EFM32GG990F1024 MCU with 1 MB flash and 128 kB RAM +
      • 32.768 kHz crystal (LXFO) and 48 MHz crystal (HXFO) +
      • 32 MB NAND flash +
      • Advanced Energy Monitoring +
      • Touch slider +
      • 8x20 LCD +
      • 2 user LEDs +
      • 2 user buttons +
      • USB interface for Host/Device/OTG +
      • Ambient light sensor and inductive-capacitive metal sensor +
      • EFM32 OPAMP footprint +
      • 20 pin expansion header +
      • Breakout pads for easy access to I/O pins +
      • Power sources (USB and CR2032 battery) +
      • Backup Capacitor for RTC mode +
      • Integrated Segger J-Link USB debugger/emulator +
      +

      + STATUS. +

      +
        +
      • + The basic board support for the Giant Gecko was introduced int the NuttX source tree in NuttX-7.6. + A verified configuration was available for the basic NuttShell (NSH) using LEUART0 for the serial console. +
      • +
      • + Development of USB support is in started, but never completed. +
      • +
      • + Reset Management Unit (RMU) was added Pierre-noel Bouteville in NuttX-7.7. +
      • +
      +
    • +
    +



    +

    + STMicro STM32L152 (STM32L "EnergyLite" Line). + This is a port of NuttX to the STMicro STM32L-Discovery development board. + The STM32L-Discovery board is based on the STM32L152RBT6 MCU (128KB FLASH and 16KB of SRAM). +

    +
      +

      + The STM32L-Discovery and 32L152CDISCOVERY kits are functionally equivalent. + The difference is the internal Flash memory size (STM32L152RBT6 with 128 Kbytes or STM32L152RCT6 with 256 Kbytes). + Both boards feature: +

      +
        +
      • An ST-LINK/V2 embedded debug tool interface,
      • +
      • LCD (24 segments, 4 commons),
      • +
      • LEDs,
      • +
      • Pushbuttons,
      • +
      • A linear touch sensor, and
      • +
      • Four touchkeys.
      • +
      +

      + STATUS. + Initial support for the STM32L-Discovery was released in NuttX-6.28. + This initial support includes a configuration using the NuttShell (NSH) that might be the basis for an application development. + A driver for the on-board segment LCD is included as well as an option to drive the segment LCD from an NSH "built-in" command. + As of this writing, a few more things are needed to make this a more complete port: 1) Verfication of more device drivers (timers, quadrature encoders, PWM, etc.), and 2) logic that actually uses the low-power consumption modes of the EnergyLite part. + Refer to the NuttX board README file for further information. +

      +

      + Memory Usage. + For a full-featured RTOS such as NuttX, providing support in a usable and meaningful way within the tiny memories of the STM32L152RBT6 demonstrates the scalability of NuttX. The STM32L152RBT6 comes in a 64-pin package and has 128KB FLASH and 16KB of SRAM. +

      +

      + Static memory usage can be shown with size command: +

      +
        +$ size nuttx
        +   text    data     bss     dec     hex filename
        +  39664     132    1124   40920    9fd8 nuttx
        +
      +

      + NuttX, the NSH application, and GCC libraries use 38.7KB of FLASH leaving 89.3B of FLASH (70%) free from additional application development. + Static SRAM usage is about 1.2KB (<4%) and leaves 14.8KB (86%) available for heap at runtime. +

      + SRAM usage at run-time can be shown with the NSH free command: +
        +NuttShell (NSH) NuttX-6.27
        +nsh> free
        +             total       used       free    largest
        +Mem:         14096       3928      10168      10168
        +nsh>
        +
      +

      + You can see that 9.9KB (62%) of SRAM heap is staill available for further application development while NSH is running. +

      +



    +

    + STMicro STM32F152x/162x(STM32 F1 "EnergyLite" Medium+ Density Family). + Support for the STM32152 and STM32162 Medium+ density parts from Jussi Kivilinna and Sami Pelkonen was included in NuttX-7.3, extending the basic STM32F152x support. + This is architecture-only support, meaning that support for the boards with these chips is available, but not support for any publicly available boards is included. +

    +



    +

    + STMicro STM32F100x (STM32 F1 "Value Line"Family). +

    +
      +
    • +

      + Proprietary Boards + Chip support for these STM32 "Value Line" family was contributed by Mike Smith and users have reported that they have successful brought up NuttX on their proprietary boards using this logic. +

      +
    • +
    • +

      + STM32VL-Discovery. + In NuttX-6.33, support for the STMicro STM32VL-Discovery board was contributed by Alan Carvalho de Assis. + The STM32VL-Discovery board features an STM32F100RB MCU. + Refer to the NuttX board README file for further information. +

      +
    • +
    +



    +

    + STMicro STM32F102. + Architecture support (only) for the STM32 F102 family was contributed by the PX4 team in NuttX-7.7. +

    +
      +

      + STATUS: + Architecture support only is provided. + No specific STM32 F102 boards are supported. +

      +
    +



    +

    + STMicro STM32F103C4/8 (STM32 F1 Low- and Medium-Density Family). + This port is for "STM32 Tiny" development board. + This board is available from several vendors on the net, and may be sold under different names. + It is based on a STM32 F103C8T6 MCU, and is bundled with a nRF24L01 wireless communication module. +

    +
      +

      + STATUS: + The basic STM32F103C8 port was released in NuttX version 6.28. + This work was contributed by Laurent Latil. + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + STMicro STM32F103x (STM32 F1 Family). + Support for four MCUs and four board configurations are available. + MCU support includes all of the high density and connectivity line families. + Board supported is available specifically for: STM32F103ZET6, STM32F103RET6, STM32F103VCT, STM32F103VET6, STM32F103RBT6, and STM32103CBT6. + Boards supported include: +

    +
      +
    1. +

      + STM3210E-EVAL. + A port for the STMicro STM3210E-EVAL development board that + features the STM32F103ZET6 MCU. + Refer to the NuttX board README file for further information. +

      +
    2. +
    3. +

      + HY-Mini STM32v board. + This board is based on the STM32F103VCT chip. Port contributed by Laurent Latil. + Refer to the NuttX board README file. +

      +
    4. +
    5. +

      + The M3 Wildfire development board (STM32F103VET6), version 2. + See http://firestm32.taobao.com (the current board is version 3). + Refer to the NuttX board README file for further information. +

      +
    6. +
    7. +

      + LeafLab's Maple and Maple Mini boards. + These boards are based on the STM32F103RBT6 chip for the standard version and on the STM32F103CBT6 for the mini version. + See the LeafLabs web site for hardware information; + see the NuttX board README file for further information about the NuttX port. +

      +
    8. +
    9. +

      + Spark (and emulated Spark). + The Spark boards are based on the STM32F103CBT6 chip and feature wireless networking using the TI CC3000 WLAN module. + See the Spark web site for hardware information; + The emulated Spark is a base board for the Maple Mini board (see above) developed by David Sidrane that supports Spark development while we all way breathlessly for or Spark boards. + see the NuttX board README file for further information about the NuttX port. +

      +

      + Initially Spark support was introduced in NuttX 6.31 and completed in NuttX 6.32. + Most of this work is the result of the effort of David Sidrane. +

      +
    10. +
    11. +

      + Olimexino-STM32. + This port uses the Olimexino STM32 board (STM32F103RBT6). + See the http://www.olimex.com for further information. + Contribued by David Sidrane. +

      +
    12. +
    +

    + These ports uses a GNU arm-nuttx-elf toolchain* under either Linux or Cygwin (with native Windows GNU tools or Cygwin-based GNU tools). +

    +
      +

      + STATUS: +

      +
        +
      • +

        + Basic Support/Drivers. + The basic STM32 port was released in NuttX version 0.4.12. The basic port includes boot-up + logic, interrupt driven serial console, and system timer interrupts. + The 0.4.13 release added support for SPI, serial FLASH, and USB device.; + The 4.14 release added support for buttons and SDIO-based MMC/SD and verified DMA support. + Verified configurations are available for the NuttShell (NSH) example, + the USB serial device class, and the USB mass storage device class example. +

        +
      • +
      • +

        + Additional Drivers. + Additional drivers and configurations were added in NuttX 6.13 and later releases for the STM32 F1 and F4. + F1 compatible drivers include an Ethernet driver, ADC driver, DAC driver, PWM driver, IWDG, WWDG, and CAN drivers. +

        +
      • +
      • +

        + M3 Wildfire. + Support for the Wildfire board was included in version 6.22 of NuttX. + The board port is basically functional. + Not all features have been verified. + Support for FAT file system on an an SD card had been verified. + The ENC28J60 network is functional (but required lifting the chip select pin on the W25x16 part). + Customizations for the v3 version of the Wildfire board are selectable (but untested). +

        +
      • +
      • +

        + Maple. + Support for the Maple boards was contributed by Yiran Liao and first appear in NuttX 6-30. +

        +
      • +
      • +

        + Spark. + David Sidrane has the emulated Spark board up-and-running with a functional CC3000 network, SST25 FAT file system, an NSH shell, and a composite USB CDC/ACM and USBMSC devices. This configuration is was first available NuttX 6.31 and completed in NuttX 6.32. + That is really quite a lot of high end functionality on an STM32 that only has 20KB of RAM! I am impressed! +

        +
      • +
      • +

        + Olimexino-STM32. + Contributed by David Sidrane and introduced with NuttX 7.9. + Configurations are included for the NuttShell (NSH), a tiny version of the NuttShell, USB composite CDC/ACM + MSC, CAN support, and two tiny, small-footprint NSH configurations. +

        +
      • +
      +
    +

    + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU toolchain, 3) Cygwin/MSYS + with Windows native toolchain (RIDE7, CodeSourcery or devkitARM), or 4) Native Windows. A DIY toolchain or Linux + or Cygwin is provided by the NuttX + buildroot + package. +

    +



    +

    + STMicro STM32F107x (STM32 F1 "Connectivity Line" family). + Chip support for the STM32 F1 "Connectivity Line" family has been present in NuttX for some time and users have reported that they have successful brought up NuttX on there proprietary boards using this logic. +

    +
      +
    • +

      + Olimex STM32-P107 + Support for the Olimex STM32-P107 was contributed by Max Holtzberg and first appeared in NuttX-6.21. That port features the STMicro STM32F107VC MCU. +

      +

      + STATUS: + A configuration for the NuttShell (NSH) is available and verified. + Networking is functional. + Support for an external ENCX24J600 network was added in NuttX 6.30. +

      +
    • +
    • +

      + Shenzhou IV + A port of NuttX to the Shenzhou IV development board (See www.armjishu.com) featuring the STMicro STM32F107VCT MCU was added in NuttX-6.22. +

      +

      + STATUS: + In progress. + The following have been verified: + (1) Basic Cortex-M3 port, + (2) Ethernet, + (3) On-board LEDs. + Refer to the NuttX board README file for further information. +

      +
    • +
    • +

      + ViewTool STM32F103/F107 + Support for the Viewtool STM32F103/F107 board was added in NuttX-6.32. That board features the STMicro STM32F107VCT6 MCU. + Networking, LCD, and touchscreen support were added in NuttX-6.33. +

      +

      + Three configurations are available: +

      +
        +
      1. + A standard NuttShell (NSH) configuration that will work with either the STM32F103 or STM32F107 part. +
      2. +
      3. + A network-enabled NuttShell (NSH) configuration that will work only with the STM32F107 part. +
      4. +
      5. + The configuration that was used to verify the Nuttx high-priority, nested interrupt feature. +
      6. +
      +

      + STATUS: + Networking and touchscreen support are well test. + But, at present, neither USB nor LCD functionality have been verified. + Refer to the SViewtool STM32F103/F107 README file for further information. +

      +
    • +



    +

    + STMicro STM32F205 (STM32 F2 family). + Architecture only support for the STM32F205RG was contributed as an anonymous contribution in NuttX-7.10 +

    +
      + STATUS: + There are currently on board configurations for any board using the STM32F205. +



    +

    + STMicro STM32F207 (STM32 F2 family). +

      +
    • + Support for the STMicro STM3220G-EVAL development board was contributed by Gary Teravskis and first released in NuttX-6.16. This board uses the STM32F207IG. +
    • +
    • + Martin Lederhilger contributed support for the Olimex STM32 P207 board using the STM32F207ZE MCU. +
    • +
    +

    +
      + STATUS: + The peripherals of the STM32 F2 family are compatible with the STM32 F4 family. + See discussion of the STM3240G-EVAL board below for further information. + Refer also to the NuttX board README file for further information. +
    +



    +

    + Atmel SAM3U. + This port uses the Atmel SAM3U-EK + development board that features the SAM3U4E MCU. + This port uses a GNU arm-nuttx-elf or arm-nuttx-eabi toolchain* under either Linux or Cygwin (with native Windows GNU tools or Cygwin-based GNU tools). +

    +
      +

      + STATUS: + The basic SAM3U-EK port was released in NuttX version 5.1. The basic port includes boot-up + logic, interrupt driven serial console, and system timer interrupts. + That release passes the NuttX OS test and is proven to have a valid OS implementation. + A configuration to support the NuttShell is also included. + NuttX version 5.4 adds support for the HX8347 LCD on the SAM3U-EK board. + This LCD support includes an example using the + NX graphics system. + NuttX version 6.10 adds SPI support. + Touchscreen support was added in NuttX-6.29. +

      +

      + Subsequent NuttX releases will extend this port and add support for the SDIO-based SD cards and + USB device. + Refer to the NuttX board README file for further information about this port. +

      +
    +

    + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU toolchain, 3) Cygwin/MSYS + with Windows native toolchain (CodeSourcery or devkitARM), or 4) Native Windows. A DIY toolchain for inux + or Cygwin is provided by the NuttX + buildroot + package. +

    +



    +

    + Atmel SAM3X. + This port uses the Arduino Due development board that features the ATSAM3X8E MCU running at 84MHz. + See the Arduino Due page for more information. +

    +
      +

      + STATUS: + As of this writing, the basic port is code complete and a fully verified configuration exists for the NuttShell NSH). + The first fully functional Arduino Due port was released in NuttX-6.29. + Refer to the NuttX board README file for further information. +

      +
    +

    + Development Environments: + See the Atmel SAM3U discussion above. +

    +



    +

    + NXP LPC1766, LPC1768, and LPC1769. + Drivers are available for CAN, DAC, Ethernet, GPIO, GPIO interrupts, I2C, UARTs, SPI, SSP, USB host, and USB device. + Additional drivers for the RTC, ADC, DAC, Timers, PWM and MCPWM were contributed by Max (himax) in NuttX-7.3. + Verified LPC17xx configurations are available for these boards: +

      +
    • + The Nucleus 2G board from 2G Engineering (LPC1768), +
    • +
    • + The mbed board from mbed.org (LPC1768, Contributed by Dave Marples), and +
    • +
    • + The LPC1766-STK board from Olimex (LPC1766). +
    • +
    • + The Embedded Artists base board with NXP LPCXpresso LPC1768. +
    • +
    • + Zilogic's ZKIT-ARM-1769 board. +
    • +
    • + The Micromint Lincoln60 board with an NXP LPC1769. +
    • +
    • + A version of the LPCXPresso LPC1768 board with special support for the U-Blox model evaluation board. +
    • +
    +

    +

    + The Nucleus 2G board, the mbed board, and the LPCXpresso all feature the NXP LPC1768 MCU; + the Olimex LPC1766-STK board features an LPC1766. + All use a GNU arm-nuttx-elf or arm-eabi toolchain* under either Linux or Cygwin (with native Windows GNU tools or Cygwin-based GNU tools). +

    +
      +

      + STATUS: + The following summarizes the features that has been developed and verified on individual LPC17xx-based boards. + These features should, however, be common and available for all LPC17xx-based boards. +

      +
        +
      1. +

        Nucleus2G LPC1768

        +
          +
        • + Some initial files for the LPC17xx family were released in NuttX 5.6, but +
        • +
        • + The first functional release for the NXP LPC1768/Nucleus2G occured with NuttX 5.7 with + Some additional enhancements through NuttX-5.9. + Refer to the NuttX board README file for further information. +
        • +
        +

        +

        + That initial, 5.6, basic release included timer interrupts and a serial console and was + verified using the NuttX OS test (apps/examples/ostest). + Configurations available include include a verified NuttShell (NSH) configuration + (see the NSH User Guide). + The NSH configuration supports the Nucleus2G's microSD slot and additional configurations + are available to exercise the USB serial and USB mass storage devices. + However, due to some technical reasons, neither the SPI nor the USB device drivers are fully verified. + (Although they have since been verified on other platforms; this needs to be revisited on the Nucleus2G). +

        +
      2. +
      3. +

        mbed LPC1768

        +
          +
        • + Support for the mbed board was contributed by Dave Marples and released in NuttX-5.11. + Refer to the NuttX board README file for further information. +
        • +
        +

        +
      4. +
      5. +

        Olimex LPC1766-STK

        +
          +
        • + Support for that Olimex-LPC1766-STK board was added to NuttX 5.13. +
        • +
        • + The NuttX-5.14 release extended that support with an Ethernet driver. +
        • +
        • + The NuttX-5.15 release further extended the support with a functional USB device driver and SPI-based micro-SD. +
        • +
        • + The NuttX-5.16 release added a functional USB host controller driver and USB host mass storage class driver. +
        • +
        • + The NuttX-5.17 released added support for low-speed USB devices, interrupt endpoints, and a USB host HID keyboard class driver. +
        • +
        • + Refer to the NuttX board README file for further information. +
        • +
        +

        +

        + Verified configurations are now available for the NuttShell with networking and microSD support(NSH, see the NSH User Guide), + for the NuttX network test, for the THTTPD webserver, + for USB serial deive and USB storage devices examples, and for the USB host HID keyboard driver. + Support for the USB host mass storage device can optionally be configured for the NSH example. + A driver for the Nokia 6100 LCD and an NX graphics configuration for the Olimex LPC1766-STK have been added. + However, neither the LCD driver nor the NX configuration have been verified as of the NuttX-5.17 release. +

        +
      6. +
      7. +

        Embedded Artists base board with NXP LPCXpresso LPC1768

        +

        + An fully verified board configuration is included in NuttX-6.2. + The Code Red toolchain is supported under either Linux or Windows. + Verified configurations include DHCPD, the NuttShell (NSH), NuttX graphis (NX), THTTPD, and USB mass storage device. + Refer to the NuttX board README file for further information. +

        +
      8. +
      9. +

        Zilogic's ZKIT-ARM-1769 board

        +

        + Zilogic System's ARM development Kit, ZKIT-ARM-1769. + This board is based on the NXP LPC1769. + The initial release was included NuttX-6.26. + The Nuttx Buildroot toolchain is used by default. + Verifed configurations include the "Hello, World!" example application and a THTTPD demonstration. + Refer to the NuttX board README file for further information. +

        +
      10. +
      11. +

        Micromint Lincoln60 board with an NXP LPC1769

        +

        + This board configuration was contributed and made available in NuttX-6.20. + As contributed board support, I am unsure of what all has been verfied and what has not. + See the Microment website Lincoln60 board and the NuttX board README file for further information about the Lincoln board. +

        +
      12. +
      13. +

        U-Blox Modem Evaluation (LPCXpresso LPC1768)

        +

        + This board configuration was contributed by Vladimir Komendantskiy and made available in NuttX-7.15. + This is a variant of the LPCXpresso LPC1768 board support with special provisions for the U-Blox Model Evaluation board. + See the NuttX board README file for further information about this port. +

        +
      14. +
      +
    +

    + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU toolchain, 3) Cygwin/MSYS + with Windows native toolchain (CodeSourcery devkitARM or Code Red), or 4) Native Windows. A DIY toolchain for Linux + or Cygwin is provided by the NuttX + buildroot package. +

    +



    +

    + NXP LPC1788. + The port of NuttX to the WaveShare Open1788 is a collaborative effort between Rommel Marcelo and myself + (with Rommel being the leading contributor and I claiming only a support role). + You can get more information at the Open1788 board from the WaveShare website. +

    +
      + STATUS: + Initial Open1788 support appeared in NuttX-6.26 with the first verified configurations in NuttX-6.27. + In NuttX-6.27 there is a working basic port with OS verification, Nuttshell (NSH) configurations, and a graphics test configuration. + SDRAM and GPDMA are working. + The NSH configuration includes verified support for a DMA-based SD card interface. + The frame-buffer LCD driver is functional and uses the SDRAM for frame-buffer memory. + A touchscreen interface has been developed but there appears to be a hardware issue with the WaveShare implementation of the XPT2046 touchscreen controller. + Refer to the NuttX board README file for further information. +
    +
    + ARM Cortex-M4. +

    +

    + FreeScale Kinetis K20/Teensy-3.x. + Architecture support (only) was added in NuttX-7.10. + This support was taken from PX4 and is the work of Jakob Odersky. + Support was added for the PJRC Teensy-3.1 board in NuttX-7.11. + Backward compatible support for the Teensy-3.0 is included. +

    +
      +

      + STATUS: + Refer to the Teensy-3.1 board README file for further information. +

      +
    +



    +

    + FreeScale Kinetis K40. + This port uses the Freescale Kinetis KwikStik K40. + Refer to the Freescale web site for further information about this board. + The Kwikstik is used with the FreeScale Tower System (mostly just to provide a simple UART connection) +

    +
      +

      + STATUS: + The unverified KwikStik K40 first appeared in NuttX-6.8 + As of this writing, the basic port is complete but I accidentally locked my board during the initial bringup. + Further development is stalled unless I learn how to unlock the device (or until I get another K40). + Additional work remaining includes, among other things: (1) complete the basic bring-up, + (2) bring up the NuttShell NSH, (3) develop support for the SDHC-based SD card, + (4) develop support for USB host and device, and (2) develop an LCD driver. + NOTE: Some of these remaining tasks are shared with the K60 work described below. + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + FreeScale Kinetis K60. + This port uses the Freescale Kinetis TWR-K60N512 tower system. + Refer to the Freescale web site for further information about this board. + The TWR-K60N51 includes with the FreeScale Tower System which provides (among other things) a DBP UART connection. +

    +
      +

      + STATUS: + As of this writing, the basic port is complete and passes the NuttX OS test. + An additional, validated configuration exists for the NuttShell (NSH, see the + NSH User Guide). + This basic TWR-K60N512 first appeared in NuttX-6.8. + Ethernet and SD card (SDHC) drivers also exist: + The SDHC driver is partially integrated in to the NSH configuration but has some outstanding issues. + the Ethernet driver became stable in NuttX-7.14 thanks to the efforts of Andrew Webster. + Additional work remaining includes: (1) integrate th SDHC drivers, and (2) develop support for USB host and device. + NOTE: Most of these remaining tasks are the same as the pending K40 tasks described above. + Refer to the NuttX board README file for further information. +

      +
    +

    + MK60N512VLL100. + Architecture support for the MK60N512VLL100 was contributed by Andrew Webster in NuttX-7.14. +

    +



    +

    + STMicro STM32 F302 (STM32 F3 family). + Architecture (only) support for the STM32 F302 was contributed in NuttX-7.10 by Ben Dyer (vi the PX4 team and David Sidrane). +

    +
      +

      + STATUS: + There are currently no board configurations using the STM32 F302. +

      +
    +



    +

    + STMicro STM32 F303 (STM32 F3 family). +

    +

      +

      + STM32F3-Discovery. + This port uses the STMicro STM32F3-Discovery board featuring the STM32F303VCT6 MCU (STM32 F3 family). + Refer to the STMicro web site for further information about this board. +

      +
        +

        + STATUS: + The basic port for the STM32F3-Discover was first released in NuttX-6.26. + Many of the drivers previously released for the STM32 F1, Value Line, and F2 and F4 may be usable on this platform as well. + New drivers will be required for ADC and I2C which are very different on this platform. + Refer to the NuttX board README file for further information. +

        +
      + +

      + STMicro ST Nucleo F303RE board.. + Contributed by Paul Alexander Patience. +

      +
        +

        + STATUS: + The basic port for the Nucleo F303RE was first released in NuttX-7.12. +

        +
      +
    +



    +

    + STMicro STM32 F372/F373 (Cortex-M4). +

    +

    + Basic architecture support for the STM32F372/F373 was contributed by Marten Svanfeldt in NuttX 7.9. + There are no STM32F*72 boards currently supported, however. +

    +



    +

    + STMicro STM32401x (STM32 F4 family). +

    +

      +

      + Nucleo F401RE. + This port uses the STMicro Nucleo F401RE board featuring the STM32F104RE MCU. + Refer to the STMicro web site for further information about this board. +

      +

      + STATUS: +

        +
      • NuttX-7.2 + The basic port for STMicro Nucleo F401RE board was contributed by Frank Bennett. +
      • + Refer to the NuttX board README file for further information. +
      • +
      +

      +



    +

    + STMicro STM32407x (STM32 F4 family). +

    +

      +

      + STMicro STM3240G-EVAL. + This port uses the STMicro STM3240G-EVAL board featuring the STM32F407IGH6 MCU. + Refer to the STMicro web site for further information about this board. +

      +

      + STATUS: +

        +
      • NuttX-6.12 + The basic port is complete and first appeared in NuttX-6.12. + The initial port passes the NuttX OS test and includes a validated configuration for the NuttShell (NSH, see the + NSH User Guide) as well as several other configurations. +
      • +
      • NuttX-6.13-6.16 + Additional drivers and configurations were added in NuttX 6.13-6.16. + Drivers include an Ethernet driver, ADC driver, DAC driver, PWM driver, CAN driver, F4 RTC driver, Quadrature Encoder, DMA, SDIO with DMA + (these should all be compatible with the STM32 F2 family and many should also be compatible with the STM32 F1 family as well). +
      • +
      • NuttX-6.16 + The NuttX 6.16 release also includes and logic for saving/restoring F4 FPU registers in context switches. + Networking intensions include support for Telnet NSH sessions and new configurations for DHPCD and the networking test (nettest). +
      • +
      • NuttX-6.17 + The USB OTG device controller driver, and LCD driver and a function I2C driver were added in NuttX 6.17. +
      • +
      • NuttX-6.18 + STM32 IWDG and WWDG watchdog timer drivers were added in NuttX 6.18 (should be compatible with F1 and F2). + An LCD driver and a touchscreen driver for the STM3240G-EVAL based on the STMPE811 I/O expander were also added in NuttX 6.18. +
      • +
      • NuttX-6.21 + A USB OTG host controller driver was added in NuttX 6.21. +
      • +
      • NuttX-7.3 + Support for the Olimex STM32 H405 board was added in NuttX-7.3. +
      • +
      • + Refer to the NuttX board README file for further information. +
      • +
      +

      +

      + STMicro STM32F4-Discovery. + This port uses the STMicro STM32F4-Discovery board featuring the STM32F407VGT6 MCU. + The STM32F407VGT6 is a 168MHz Cortex-M4 operation with 1Mbit Flash memory and 128kbytes. + The board features: +

      +
        +
      • On-board ST-LINK/V2 for programming and debugging,
      • +
      • LIS302DL, ST MEMS motion sensor, 3-axis digital output accelerometer,
      • +
      • MP45DT02, ST MEMS audio sensor, omni-directional digital microphone,
      • +
      • CS43L22, audio DAC with integrated class D speaker driver,
      • +
      • Eight LEDs and two push-buttons,
      • +
      • USB OTG FS with micro-AB connector, and
      • +
      • Easy access to most MCU pins.
      • +
      +

      + Support for the STM3F4DIS-BB base board was added in NuttX-7.5. + This includes support for the serial communications via the on-board DB-9 connector, Networking, and the microSD card slot. +

      +

      + Refer to the STMicro web site for further information about this board and to +

      +
        +

        + STATUS: + The basic port for the STM32F4-Discovery was contributed by Mike Smith and was first released in NuttX-6.14. + All drivers listed for the STM3240G-EVAL are usable on this platform as well. + Refer to the NuttX board README file for further information. +

        +
      +

      + MikroElektronika Mikromedia for STM32F4. + This is another board supported by NuttX that uses the same STM32F407VGT6 MCU as does the STM32F4-Discovery board. + This board, however, has very different on-board peripherals than does the STM32F4-Discovery: +

      +
        +
      • TFT display with touch panel,
      • +
      • VS1053 stereo audio codec with headphone jack,
      • +
      • SD card slot,
      • +
      • Serial FLASH memory,
      • +
      • USB OTG FS with micro-AB connector, and
      • +
      • Battery connect and batter charger circuit.
      • +
      +

      + See the Mikroelektronika website for more information about this board and the NuttX board README file for further information about the NuttX port. +

      +
        +

        + STATUS: + The basic port for the Mikromedia STM32 M4 was contributed by Ken Petit and was first released in NuttX-6.128. + All drivers for the STM32 F4 family may be used with this board as well. +

        +
      +

      + Olimex STM32 H405. + Support for the Olimex STM32 H405 development board was contributed by Martin Lederhilger and appeared in NuttX-7.3. + See the NuttX board README file for further information about the NuttX port. +

      +

      + Olimex STM32 H407. + Support for the Olimex STM32 H407 development board was contributed by Neil Hancock and appeared in NuttX-7.14. + See the NuttX board README file for further information about the NuttX port. +

      +



    +

    + STMicro STM32 F427/437. + General architectural support was provided for the F427/437 family in NuttX 6.27. + Specific support includes the STM32F427I, STM32F427Z, and STM32F427V chips. + This is architecture-only support, meaning that support for the boards with these chips is available, but not support for any publicly available boards is included. + This support was contributed by Mike Smith. +

    +

    + The F427/437 port adds (1) additional SPI ports, (2) additional UART ports, (3) analog and digital noise filters on the I2C ports, (4) up to 2MB of flash, (5) an additional lower-power mode for the internal voltage regulator, (6) a new prescaling option for timer clock, (7) a larger FSMSC write FIFO, and (8) additional crypto modes (F437 only). +

    +



    +

    + STMicro STM32 F429. + Support for STMicro STM32F429I-Discovery development board featuring the STM32F429ZIT6 MCU was contributed in NuttX-6.32 by Ken Pettit. + The STM32F429ZIT6 is a 180MHz Cortex-M4 operation with 2Mbit Flash memory and 256kbytes. +

    +

    + STATUS: +

    +
      +
    • + The intial release included support from either OTG FS or OTG HS in FS mode. +
    • +
    • + The F429 port adds support for the STM32F439 LCD and OTG HS (in FS mode). +
    • +
    • + In Nutt-7.6, Brennan Ashton added support for concurrent OTG FS and OTG HS (still in FS mode) and Marco Krahl added support for an SPI-based LCD . +
    • +
    • + In Nutt-7.7, Marco Krahl included support for a framebuffer based driver using the LTDC and DMA2D. + Marcos's implementation included extensions to support more advance LTDC functions through an auxiliary interface. +
    • +
    +

    + Refer to the STM32F429I-Discovery board README file for further information. +

    +



    +

    + STMicro STM32 F446. + Architecture-only support is available for the STM32 F446 family (meaning that the parts are supported, but there is not example board supported in the system). + This support was contributed by David Sidrane and made available in NuttX-7.11. +

    +



    +

    + STMicro STM32 F46xx. + Architecture-only support is available for the STM32 F46xx family (meaning that the parts are supported, but there is not example board supported in the system). + This support was contributed by Paul Alexander Patienc and made available in NuttX-7.15. +

    +



    +

    + STMicro STM32 L476. + Two boards are supported in this family: +

    +
      +
    • +

      + Nucleo-L476RG. + Board support for the STMicro NucleoL476RG board from ST Micro was contributed by Sebastien Lorquet in NuttX-7.15. See the STMicro website and the board README file for further information. +

      +
    • +
    • +

      + STM32L476VG Discovery. + Board support for the STMicro STM32L476VG Discovery board from ST Micro was contributed by Dave in NuttX-7.15. See the STMicro website and the board README file for further information. +

      +
    • +
    +

    Status:

    +
      +

      + NuttX-7.15. + Only the first initial release of support for this family is present. + This is an ongoing, work-in-progress. + It includes these basics: +

      +
        +
      • RCC, clocking, Interrupts, System timer
      • +
      • UART, USART, Serial Console
      • +
      • GPIO, DMA, I2C, RNG, SPI
      • +
      +



    +

    + NCP LPC43xx. + Several board ports are available for this higher end, NXP Cortex-M4F part: +

    +
      +

      + NXG Technologies LPC4330-Xplorer. + This NuttX port is for the LPC4330-Xplorer board from NGX Technologies featuring the NXP LPC4330FET100 MCU. + See the NXG website for further information about this board. +

      +
        +
      • +

        STATUS: + Refer to the NuttX board README file for more detailed information about this port. +

        +
      • +
      • +

        NuttX-6.20 + The basic port is complete. + The basic NuttShell (NSH) configuration is present and fully verified. + This includes verified support for: SYSTICK system time, pin and GPIO configuration, and a serial console. +

        +

        + Several drivers have been copied from the related LPC17xx port but require integration into the LPC43xx: ADC, DAC, GPDMA, I2C, SPI, and SSP. + The registers for these blocks are the same in both the LPC43xx and the LPC17xx and they should integrate into the LPC43xx very easily by simply adapting the clocking and pin configuration logic. +

        +

        + Other LPC17xx drivers were not brought into the LPC43xx port because these peripherals have been completely redesigned: CAN, Ethernet, USB device, and USB host. +

        +

        + So then there is no support for the following LPC43xx peripherals: SD/MMC, EMC, USB0,USB1, Ethernet, LCD, SCT, Timers 0-3, MCPWM, QEI, Alarm timer, WWDT, RTC, Event monitor, and CAN. +

        +

        + Some of these can be leveraged from other MCUs that appear to support the same peripheral IP: +

        +
          +
        • + The LPC43xx USB0 peripheral appears to be the same as the USB OTG peripheral for the LPC31xx. + The LPC31xx USB0 device-side driver has been copied from the LPC31xx port but also integration into the LPC43xx (clocking and pin configuration). + It should be possible to complete porting of this LPC31xx driver with a small porting effort. +
        • +
        • + The Ethernet block looks to be based on the same IP as the STM32 Ethernet and, as a result, it should be possible to leverage the NuttX STM32 Ethernet driver with a little more effort. +
        • +
        +
      • +
      • +

        NuttX-6.21 + Added support for a SPIFI block driver and for RS-485 option to the serial driver. +

      • +
      +

      + NXP/Embest LPC4357-EVB. + This NuttX port is for the LPC4357-EVB from NXP/Embest featuring the NXP LPC4357FET256 MCU. + The LPC4357 differs from the LPC4330 primarily in that it includes 1024KiB of on-chip NOR FLASH. + See the NXP website for more detailed information about the LPC4357 and the LPC4357-EVB. +

      +
        +
      • +

        STATUS: + Refer to the NuttX board README file for more detailed information about this port. +

        +
      • +
      • +

        NuttX-7.6. + The basic port is was contributed by Toby Duckworth. + This port leverages from the LPC4330-Xplorer port (and, as of this writing, still requires some clean up of the technical discussion in some files). + The basic NuttShell (NSH) configuration is present and has been verified. + Support is generally the same as for the LPC4330-Xplorer as discussed above. +

        +
      • +
      + +

      + NXP LPC4370-Link2. + This is the NuttX port to the NXP LPC4370-Link2 development board featuring the NXP LPC4370FET100 MCU. +

      +
        +
      • +

        STATUS: + Refer to the NuttX board README file for more detailed information about this port. +

        +
      • +
      • +

        NuttX-7.12 + The NXP LPC4370-Link2 port is was contributed by Lok Tep and first released in NuttX-7.12. +

        +
      • +
      + +

      + WaveShare LPC4337-WS. + This is the NuttX port to the WaveShare LPC4337-WS development board featuring the NXP LPC4337JBD144 MCU. +

      +
        +
      • +

        STATUS: + Refer to the NuttX board README file for more detailed information about this port. +

        +
      • +
      • +

        NuttX-7.14 + The NXP WaveShare LPC4337-WS port is was contributed by Lok Tep and first released in NuttX-7.14. +

        +
      • +
      +



    +

    + TI Stellaris LM4F120. + This port uses the TI Stellaris LM4F120 LaunchPad. + Jose Pablo Carballo and I are doing this port. +

    +
      +

      + STATUS: + As of this writing, the basic port is code complete and a fully verified configuration exists for the NuttShell NSH). + The first fully functional LM4F120 LaunchPad port was released in NuttX-6.27. +

      +
    +



    +

    + TI Tiva TM4C123G. + This port uses the Tiva C Series TM4C123G LaunchPad Evaluation Kit (EK-TM4C123GXL). +

    +
      +

      + STATUS: +

        +
      • + Initial architectural support for the EK-TM4C123GXL was implemented and was released in NuttX 7.1. + Basic board support the EK-TM4C123GXL was also included in that release but was not fully tested. + This basic board support included a configuration for the NuttShell NSH). +
      • +
      • + The fully verified port to the EK-TM4C123GXL was provided in NuttX-7.2. +
      • +
      • + An I2C driver was added in NuttX-7.7. +
      • +
      +

      + Refer to the EK-TM4C123GXL board README file for more detailed information about this port. +

      +
    +



    +

    + TI Tiva TM4C1294. + This port uses the TI Tiva C Series TM4C1294 Connected LaunchPad (EK-TM4C1294XL). +

    +
      +

      + STATUS: +

        +
      • + Support for the EK-TM4C1294XL was contributed by Frank Sautter and was released in NuttX 7.9. + This basic board support included a configuration for the NuttShell NSH) and a configuration for testing IPv6. +
      • +
      +

      + Refer to the EK-TM4C1294XL board README file for more detailed information about this port. +

      +
    +



    +

    + TI Tiva TM4C129X. + This port uses the TI Tiva C Series TM4C129X Connected Development Kit (DK-TM4C129X). +

    +
      +

      + STATUS: +

        +
      • + A mature port to the DK-TM4C129X was implemented and was released in NuttX 7.7. +
      • +
      • + At the initial release, verified drivers were available for Ethernet interface, I2C, and timers as well as board LEDs and push buttons. + Other Tiva/Stellaris drivers should port to the TM4C129X without major difficulty. +
      • +
      • + This board supports included two configurations for the NuttShell (NSH). + Both are networked enabled: One configured to support IPv4 and one configured to supported IPv6. + Instructions are included in the board README file for configuring both IPv4 and IPv6 simultaneously.. +
      • +
      +

      + Refer to the DK-TM4C129X board README file for more detailed information about this port. +

      +
    +



    +

    + TI/Tiva CC3200 Launchpad. + TI/Tiva CC3200 Launchpad +

    +
      +

      + STATUS: + This is very much a work in progress. + The basic port was released in NuttX-7.5. + This basic board supported includes an verified configuration for the NuttShell NSH). + Key wireless networking capability is still missing. + Refer to the CC3200 LaunchPad board README file for more detailed information about this port. +

      +
    +



    +

    + Atmel SAM4L. + This port uses the Atmel SAM4L Xplained Pro development board. + This board features the ATSAM4LC4C MCU running at 48MHz with 256KB of FLASH and 32KB of internal SRAM. +

    +
      +

      + STATUS: + As of this writing, the basic port is code complete and a fully verified configuration exists for the NuttShell NSH). + The first fully functional SAM4L Xplained Pro port was released in NuttX-6.28. + Support for the SAM4L Xplained modules was added in NuttX-6.29: +

      +
        +
      • + Support for the SPI-based SD card on the I/O1 module. +
      • +
      • + Driver for the LED1 segment LCD module. +
      • +
      • + Support for the UG-2832HSWEG04 OLED on the SAM4L Xplained Pro's OLED1 module +
      • +
      +

      + Refer to the NuttX board README file for further information. +

      +

      + Memory Usage. + The ATSAM4LC4C comes in a 100-pin package and has 256KB FLASH and 32KB of SRAM. + Below is the current memory usage for the NSH configuration (June 9, 2013). + This is not a minimal implementation, but a full-featured NSH configuration. +

      +

      + Static memory usage can be shown with size command: +

      +
        +$ size nuttx
        +   text    data     bss     dec     hex filename
        +  43572     122    2380   46074    b3fa nuttx
        +
      +

      + NuttX, the NSH application, and GCC libraries use 42.6KB of FLASH leaving 213.4B of FLASH (83.4%) free from additional application development. + Static SRAM usage is about 2.3KB (<7%) and leaves 29.7KB (92.7%) available for heap at runtime. +

      + SRAM usage at run-time can be shown with the NSH free command. + This runtime memory usage includes the static memory usage plus all dynamic memory allocation for things like stacks and I/O buffers: +
        +NuttShell (NSH) NuttX-6.28
        +nsh> free
        +             total       used       free    largest
        +Mem:         29232       5920      23312      23312
        +
      +

      + You can see that 22.8KB (71.1%) of the SRAM heap is staill available for further application development while NSH is running. +

      +
    +



    +

    + Atmel SAM4C. + General architectural support was provided for SAM4CM family in NuttX 7.3 + This was architecture-only support, meaning that support for the boards with these chips is available, but no support for any publicly available boards was included. + The SAM4CM port should be compatible with most of the SAM3/4 drivers (like HSMCI, DMAC, etc.) but those have not be verified on hardware as of this writing. + This support was contributed in part by Max Neklyudov. +

    +



    +

    + Atmel SAM4E. + General architectural support was provided for the SAM4E family in NuttX 6.32. + This was architecture-only support, meaning that support for the boards with these chips is available, but no support for any publicly available boards was included. + This support was contributed in part by Mitko. +

    +

    + Atmel SAM4E-EK. + Board support was added for the SAM4E-EK development board in NuttX 7.1. + A fully functional NuttShell (NSH) configuration is available + (see the NSH User Guide). + That NSH configuration includes networking support and support for an AT25 Serial FLASH file system. +

    +
      + STATUS. + A new Ethernet MAC driver has been developed and is functional in the NSH configuration. + A DMA-base SPI driver is supported and has been verified with the AT25 Serial FLASH. + Touchscreen and LCD support was added in NuttX-7.3, but has not been fully integrated as of this writing. + The SAM4E-EK should be compatible with most of the other SAM3/4 drivers (like HSMCI, DMAC, etc.) but those have not be verified on the SAM4E-EK as of this writing. + Refer to the NuttX board README file for further information. +
    +



    +

    + Atmel SAM4S. + There are ports to two Atmel SAM4S board: +

    +
      +
    • +

      + There is a port the Atmel SAM4S Xplained development board. + This board features the ATSAM4S16 MCU running at 120MHz with 1MB of FLASH and 128KB of internal SRAM. +

      +
        +

        + STATUS: + As of this writing, the basic port is code complete and a fully verified configuration exists for the NuttShell NSH). + The first fully functional SAM4S Xplained port was released in NuttX-6.28. + Support for the on-board 1MB SRAM was added in NuttX-6.29. + An RTT driver was Bob Doiron in NuttX-7.3. + Bob also added an high resolution RTC emulation using the RTT for the sub-second counter. + Refer to the NuttX board README file for further information. +

        +
      +
    • +
    • +

      + There is also a port to the Atmel SAM4S Xplained Pro development board. + This board features the ATSAM4S32C MCU running at 120MHz with 2MB of FLASH and 160KB of internal SRAM. +

      +
        +

        + STATUS: + As of this writing, the basic port is code complete and a fully verified configuration exists for the NuttShell NSH). + The first fully functional SAM4S Xplained Pro port was released in NuttX-7.2. + This supported also added HSMCI, RTC, and watchdog and verified support for USB device. + Refer to the NuttX board README file for further information. +

        +
      +
    • +
    +



    +

    + Atmel SAM4E. + General architectural support was provided for the SAM4E family in NuttX 6.32. + This was architecture-only support, meaning that support for the boards with these chips is available, but no support for any publicly available boards was included. + This support was contributed in part by Mitko. +

    +

    + Atmel SAM4E-EK. + Board support was added for the SAM4E-EK development board in NuttX 7.1. + A fully functional NuttShell (NSH) configuration is available + (see the NSH User Guide). + That NSH configuration includes networking support and support for an AT25 Serial FLASH file system. +

    +
      + STATUS. + This is very much a work in progress. + A new Ethernet MAC driver has been developed and is functional in the NSH configuration. + A DMA-base SPI driver is supported and has been verified with the AT25 Serial FLASH. + The SAM4E-EK should be compatible with most of the other SAM3/4 drivers (like HSMCI, DMAC, etc.) but those have not be verified on the SAM4E-EK as of this writing. + Refer to the NuttX board README file for further information. +
    +



    +

    + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU Cortex-M3 or 4 toolchain, 3) Cygwin/MSYS with Windows native GNU Cortex-M3 or M4 toolchain (CodeSourcery or devkitARM), or 4) Native Windows. A DIY toolchain for Linux or Cygwin is provided by the NuttX + buildroot package. +

    +
    + ARM Cortex-M7. +

    +

    + Atmel SAMV71. + This port uses Atmel SAM V71 Xplained Ultra Evaluation Kit (SAMV71-XULT). + This board features the ATSAMV71Q21 Cortex-M7 microcontroller. + Refer to the Atmel web site for further information about this board. +

    +
      +

      + STATUS: + The basic port is complete and there are several different, verified configurations available. + All configurations use the NuttShell (NSH) and a serial console. + The first release of the SAMV71-XULT port was available in NuttX-7.9. + Support for the connect maXTouch Xplained Pro LCD as added in NuttX-7.10. +

      +

      + Additional drivers, with status as of 2015-04-03, include: +

      +
        +
      • PIO configuration, including PIO interrupts,
      • +
      • On-board LEDs and buttons,
      • +
      • DMA,
      • +
      • SDRAM (not yet functional),
      • +
      • UART/USART-based serial drivers, including the NuttShell serial console,
      • +
      • High Speed Memory Card Interface (HSMCI) with support for the on board SD card slot,
      • +
      • SPI (not fully tested),
      • +
      • TWIHS/I2C, with the support for the on-board serial EEPROM,
      • +
      • SSC/I2S (not fully tested),
      • +
      • Ethernet MAC,
      • +
      • USB device controller driver (complete, partially functional, but not well tested).
      • +
      • On-board AT24 I2C EEPROM.
      • +
      • On-board WM8904 Audio CODEC with CS2100-CP Fractional-N Multiplier (not yet tested).
      • +
      • Support for the (optional) maXTouch Xplained Pro LCD module.
      • +
      +

      + Additional Drivers added in NuttX-7.11 include: +

      +
        +
      • MCAN CAN device driver (fully verified in loopback mode only).
      • +
      • SPI slave driver.
      • +
      +

      + Additional Drivers added in NuttX-7.13 include: +

      +
        +
      • MPU and protected build mode support.
      • +
      • Timer/Counter driver, one-shot timer, free-running timer support.
      • +
      • Tickless mode of operation.
      • +
      • QuadSPI driver.
      • +
      • Support for programming on-chip FLASH.
      • +
      +

      + And in NuttX-7.14: +

      +
        +
      • TRNG driver,
      • +
      • WDT driver, and
      • +
      • RSWDT driver.
      • +
      +

      + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + Atmel SAME70. + This port uses Atmel SAM E70 Xplained Evaluation Kit (ATSAME70-XPLD). + This board is essentially a lower cost version of the SAMV71-XULT board featuring the ATSAME70Q21 Cortex-M7 microcontroller. + See the Atmel SAMV71 for supported features. + Also refer to the NuttX board README file for further information. +

    +



    +

    + STMicro STM32 F745/F746. + This port uses the STMicro STM32F746G-DISCO development board featuring the STM32F746NGH6 MCU. The STM32F746NGH6 is a 216MHz Cortex-M7 operation with 1024Kb Flash. + Refer to the STMicro web site for further information about this board. +

    +
      +

      + STATUS: + The basic port is complete and there are two, verified configurations available. + Both configurations use the NuttShell (NSH) and a serial console; one includes Ethernet support. + DMA supports is available. + The STM32 F7 peripherals are very similar to some members of the STM32 F4 and additional drivers can easily be ported the F7 as discussed in this Wiki page: Porting Drivers to the STM32 F7 + The first release of the STM32F746G_DISCO port was available in NuttX-7.11. +

      +

      + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + STMicro STM32 F756. + Architecture-only support is available for the STM32 F756 family (meaning that the parts are supported, but there is not example board supported in the system). + This support was made available in NuttX-7.11. +

    +



    +

    + Development Environments: + The same basic development environment is recommended for the Cortex-M7 as for the Cortex-M4. + It would be wise to use the latest GNU toolchains for this part because as of this writing (2015-02-09), support for the Cortex-M7 is a very new GCC feature. +

    +
    + Atmel AVR. +

    +

    + AVR ATMega. +

    +
      +

      + SoC Robotics ATMega128. + This port of NuttX to the Amber Web Server from SoC Robotics + is partially completed. + The Amber Web Server is based on an Atmel ATMega128. +

      +
        +

        + STATUS: + Work on this port has stalled due to toolchain issues. Complete, but untested code for this port appears in the NuttX 6.5 release. + Refer to the NuttX board README file for further information. +

        +
      +

      + LowPowerLab MoteinoMEGA. + This port of NuttX to the MoteinoMEGA from LowPowerLab. + The MoteinoMEGA is based on an Atmel ATMega1284P. + See the LowPowerlab website and the board README file for further information. +

      +
        +

        + STATUS: + The basic function port support the NuttShell (NSH) was contribute by Jedi Tek'Enum and first appeared in the NuttX 7.8 release. +

        +
      +

      + Arduino MEGA2560. + Extension of the AVR architecture to support the ATMega2560 and specifi support for the Arduion MEGA2560 board were contributed by Dimitry Kloper and first released in NuttX-7.14. +

      +
        +

        + STATUS: + The basic port was released in NuttX-7.14 including a simple "Hello, World!" and OS test configurations. + Extensive effort was made to the use the special capabilities of the Atmel Studio AVR compiler to retain strings in FLASH memory and so keep the SRAM memory usage to a minimum. + Refer to the NuttX board README file for further information. +

        +
      +
    +



    +

    + AVR AT90USB64x and AT90USB6128x. +

    +
      +

      + Micropendous 3 AT90USB64x and AT90USB6128x. + This port of NuttX to the Opendous Micropendous 3 board. The Micropendous3 is + may be populated with an AT90USB646, 647, 1286, or 1287. I have only the AT90USB647 + version for testing. This version have very limited memory resources: 64K of + FLASH and 4K of SRAM. +

      +
        +

        + STATUS: + The basic port was released in NuttX-6.5. This basic port consists only of + a "Hello, World!!" example that demonstrates initialization of the OS, + creation of a simple task, and serial console output. + Refer to the NuttX board README file for further information. +

        +
      +

      + PJRC Teensy++ 2.0 AT90USB1286. + This is a port of NuttX to the PJRC Teensy++ 2.0 board. + This board was developed by PJRC. + The Teensy++ 2.0 is based on an Atmel AT90USB1286 MCU. +

      +
        +

        + STATUS: + The basic port was released in NuttX-6.5. This basic port consists of + a "Hello, World!!" example that demonstrates initialization of the OS, + creation of a simple task, and serial console output as well as a somewhat + simplified NuttShell (NSH) configuration (see the + NSH User Guide). +

        +

        + An SPI driver and a USB device driver exist for the AT90USB as well + as a USB mass storage configuration. However, this configuration is not + fully debugged as of the NuttX-6.5 release. + Refer to the NuttX board README file for further information. +

        +
      +



    +

    AVR-Specific Issues. + The basic AVR port is solid. + The biggest issue for using AVR is its tiny SRAM memory and its Harvard architecture. + Because of the Harvard architecture, constant data that resides to flash is inaccessible using "normal" memory reads and writes (only SRAM data can be accessed "normally"). + Special AVR instructions are available for accessing data in FLASH, but these have not been integrated into the normal, general purpose OS. +

    +

    + Most NuttX test applications are console-oriented with lots of strings used for printf() and debug output. + These strings are all stored in SRAM now due to these data accessing issues and even the smallest console-oriented applications can quickly fill a 4-8K memory. + So, in order for the AVR port to be useful, one of two things would need to be done: +

    +
      +
    1. + Don't use console applications that required lots of strings. + The basic AVR port is solid and your typical deeply embedded application should work fine. + Or, +
    2. +
    3. + Create a special version of printf that knows how to access strings that reside in FLASH (or EEPROM). +
    4. +
    +



    +

    + Development Environments: + 1) Linux with native Linux GNU toolchain, 2) Cygwin/MSYS with Cygwin GNU toolchain, 3) Cygwin/MSYS with Windows native toolchain, or 4) Native Windows. + All testing, however, has been performed using the NuttX DIY toolchain for Linux or Cygwin is provided by the NuttX + buildroot package. + As a result, that toolchain is recommended. +

    +


    + Atmel AVR32. +

    +

    + AV32DEV1. + This port uses the www.mcuzone.com AVRDEV1 board based on the Atmel AT32UC3B0256 MCU. + This port requires a special GNU avr32 toolchain available from atmel.com website. + This is a windows native toolchain and so can be used only under Cygwin on Windows. +

    +
      +

      + STATUS: + This port is has completed all basic development, but there is more that needs to be done. + All code is complete for the basic NuttX port including header files for all AT32UC3* peripherals. + The untested AVR32 code was present in the 5.12 release of NuttX. + Since then, the basic RTOS port has solidified: +

      +
        +
      • + The port successfully passes the NuttX OS test (apps/examples/ostest). +
      • +
      • + A NuttShell (NSH) configuration is in place (see the NSH User Guide). + Testing of that configuration has been postponed (because it got bumped by the Olimex LPC1766-STK port). + Current Status: I think I have a hardware problem with my serial port setup. + There is a good chance that the NSH port is complete and functional, but I am not yet able to demonstrate that. + At present, I get nothing coming in the serial RXD line (probably because the pins are configured wrong or I have the MAX232 connected wrong). +
      • +
      +

      + The basic, port was be released in NuttX-5.13. + A complete port will include drivers for additional AVR32 UC3 devices -- like SPI and USB --- and will be available in a later release, + time permitting. + Refer to the NuttX board README file for further information. +

      +
    +
    + Freescale M68HCS12. +

    +

    + MC9S12NE64. + Support for the MC9S12NE64 MCU and two boards are included: +

    +
      +
    • + The Freescale DEMO9S12NE64 Evaluation Board, and +
    • +
    • + The Future Electronics Group NE64 /PoE Badge board. +
    • +
    +

    + Both use a GNU arm-nuttx-elf toolchain* under Linux or Cygwin. + The NuttX buildroot provides a properly patched GCC 3.4.4 toolchain that is highly optimized for the m9s12x family. +

    +
      +

      + STATUS: + Coding is complete for the MC9S12NE64 and for the NE64 Badge board. + However, testing has not yet begun due to issues with BDMs, Code Warrior, and + the paging in the build process. + Progress is slow, but I hope to see a fully verified MC9S12NE64 port in the near future. + Refer to the NuttX board README files for DEMO9S12NE64 and for the NE64 /PoE Badge for further information. +

      +
    +
    + Intel 80x86. +

    +

    + QEMU/Bifferboard i486. + This port uses the QEMU i486 and the native + Linux, Cywgin, MinGW the GCC toolchain under Linux or Cygwin. +

    +
      +

      + STATUS: + The basic port was code-complete in NuttX-5.19 and verifed in NuttX-6.0. + The port was verified using the OS and NuttShell (NSH) examples under QEMU. + The port is reported to be functional on the Bifferboard as well. + In NuttX 7.1, Lizhuoyi contributed additional keyboard and VGA drivers. + This is a great, stable starting point for anyone interest in fleshing out the x86 port! + Refer to the NuttX README file for further information. +

      +
    +



    +

    + RGMP. + RGMP stands for RTOS and GPOS on Multi-Processor. + RGMP is a project for running GPOS and RTOS simultaneously on multi-processor platforms + You can port your favorite RTOS to RGMP together with an unmodified Linux to form a hybrid operating system. + This makes your application able to use both RTOS and GPOS features. +

    +

    + See the RGMP Wiki for further information about RGMP. +

    +
      +

      + STATUS: + This initial port of NuttX to RGMP was provided in NuttX-6.3. + This initial RGP port provides only minimal driver support and does not use the native NuttX interrupt system. + This is a great, stable starting point for anyone interest in working with NuttX under RGMP! + Refer to the NuttX README file for further information. +

      +
    +
    + MicroChip PIC32MX (MIPS 24Kc). +

    +

    + PIC32MX250F128D. + A port is in progress from the DTX1-4000L "Mirtoo" module from Dimitech. + This module uses MicroChip PIC32MX250F128D and the Dimitech DTX1-4000L EV-kit1 V2. + See the Dimitech website for further information. +

    +
      +

      + STATUS: + The basic port is code complete. + The OS test configuration is fully functional and proves that we have a basically healthy NuttX port to the Mirtoo. + A configuration is available for the NuttShell (NSH). + The NSH configuration includes support for a serial console and for the SST25 serial FLASH and the PGA117 amplifier/multiplexer on board the module. + The NSH configuration is set up to use the NuttX wear-leveling FLASH file system (NXFFS). + The PGA117, however, is not yet fully integrated to support ADC sampling. + See the NSH User Guide for further information about NSH. + The first verified port to the Mirtoo module was available with the NuttX 6.20 release. + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + PIC32MX4xx Family. +

    +
      +

      + PIC32MX440F512H. + This port uses the "Advanced USB Storage Demo Board," Model DB-DP11215, from Sure Electronics. + This board features the MicroChip PIC32MX440F512H. + See the Sure website for further information about the DB-DP11215 board. + (I believe that that the DB-DP11215 may be obsoleted now but replaced with the very similar, DB-DP11212. + The DB-DP11212 board differs, I believe, only in its serial port configuration.) +

      +
        +

        + STATUS: + This NuttX port is code complete and has considerable test testing. + The port for this board was completed in NuttX 6.11, but still required a few bug fixes before it will be ready for prime time. + The fully verified port first appeared in NuttX 6.13. + Available configurations include the NuttShell (NSH - see the NSH User Guide). + An untested USB device-side driver is available in the source tree. + A more complete port would include support of the USB OTG port and of the LCD display on this board. + Those drivers are not yet available as of this writing. + Refer to the NuttX board README file for further information. +

        +
      +

      + PIC32MX460F512L. + There one two board ports using this chip: +

      +
        +
      • PIC32MX Board from PCB Logic Design Co. + This port is for the PIC32MX board from PCB Logic Design Co. and used the PIC32MX460F512L. + The board is a very simple -- little more than a carrier for the PIC32 MCU plus voltage regulation, debug interface, and an OTG connector. +
      • +

        + STATUS: + The basic port is code complete and fully verified in NuttX 6.13. + Available configurations include the NuttShell (NSH - see the NSH User Guide). + Refer to the NuttX board README file for further information. +

        +
      • UBW32 Board from Sparkfun + This is the port to the Sparkfun UBW32 board. + This port uses the original v2.5 board which is based on the MicroChip PIC32MX460F512L. + This older version has been replaced with this newer board. + See also the UBW32 web site. +
      • +

        + STATUS: + The basic port is code complete and fully verified in NuttX 6.18. + Available configurations include the NuttShell (NSH - see the NSH User Guide). + USB has not yet been fully tested but on first pass appears to be functional. + Refer to the NuttX board README file for further information. +

        +
      +
    +



    +

    + PIC32MX795F512L. + There one two board ports using this chip: +

    +
      +
    • Microchip PIC32 Ethernet Starter Kit. + This port uses the Microchip PIC32 Ethernet Starter Kit (DM320004) with the Expansion I/O board. + See the Microchip website for further information. +
    • +

      + STATUS: + This port was started and then shelved for some time until I received the Expansion I/O board. + The basic Starter Kit (even with the Multimedia Expansion Board, MEB, DM320005)) has no serial port and most NuttX test configurations depend heavily on console output. +

      +

      + A verified configuration is available for the NuttShel (NSH) appeared in NuttX-6.16. + Board support includes a verified USB (device-side) driver. + Also included are a a verified Ethernet driver, a partially verified USB device controller driver, and an unverifed SPI driver. + Refer to the NuttX board README file for further information. +

      +
    • Mikroelektronika PIC32MX7 Mulitmedia Board (MMB). + A port has been completed for the Mikroelektronika PIC32MX7 Multimedia Board (MMB). + See http://www.mikroe.com/ for further information about this board. +
    • +

      + STATUS: + A verified configuration is available for an extensive NuttShell (NSH) configuration. + The NSH configuration includes: + (1) Full network support, + (2) Verified SPI driver, + (3) SPI-based SD Card support, + (4) USB device support (including configuration options for the USB mass storage device and the CDC/ACM serial class), and + (5) Support for the MIO283QT2 LCD on the PIC32MX7 MMB. + (6) Support for the MIO283QT9A LCD used on later boards (NuttX 7.1). +

      +

      + The PIC32MX7 MMB's touchscreen is connected directly to the MCU via ADC pins. + A touchscreen driver has been developed using the PIC32's ADC capabilities and can be enabled in the NSH configuration. + However, additional verification and tuning of this driver is required. + Further display/touchscreen verification would require C++ support (for NxWidgets and NxWM). + Since I there is no PIC32 C++ is the free version of the MPLAB C32 toolchain, further graphics development is stalled. + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + Development Environment: + These ports uses either: +

    +
      +
    1. + The LITE version of the PIC32MX toolchain available + for download from the MicroChip website, or +
    2. +
    3. + The Pinguino MIPS ELF toolchain avaiable from the Pinquino website. +
    4. +
    5. + The MIPS SDE toolchain available from the Mentor Graphics website. +
    6. +
    +
    + MicroChip PIC32MZ (MIPS M14K). +

    +

    + PIC32MZEC Family. + A port is in available for the PIC32MZ Embedded Connectivity (EC) Starter Kit. + There are two configurations of the Microchip PIC32MZ EC Starter Kit: +

    +
      +
    1. The PIC32MZ Embedded Connectivity Starter Kit based on the PIC32MZ2048ECH144-I/PH chip (DM320006), and
    2. +
    3. The PIC32MZ Embedded Connectivity Starter Kit based on the PIC32MZ2048ECM144-I/PH w/Crypto Engine (DM320006-C).
    4. +
    +

    + See the Microchip website for further information. +

    +
      +

      + STATUS: + This is a collaborative effort between Kristopher Tate, David Sidrane and myself. + The basic port is functional and a NuttShell (NSH) configurqation is available. + The first official release was in NuttX-7.9. + Current efforts are focused on driver development. + Many drivers port simply from the PIC32MX; others require more extensive efforts. + Driver status as of (2015-03-29) is provided below: +

      +

        +
      • I/O ports include I/O port interrupts
      • +
      • UART serial driver that provides the NSH console,
      • +
      • Timer,
      • +
      • I2C (untested),
      • +
      • SPI (untested),
      • +
      • On-board buttons and LEDs,
      • +
      • Ethernet (code complete, but not yet functional),
      • +
      +

      + Refer to the NuttX board README file for further information. +

      +
    +



    +

    + Development Environment: + Same as for the PIC32MZ. +

    +


    + Renesas/Hitachi SuperH. +

    +

    + SH-1 SH7032. + This port uses the Hitachi SH-1 Low-Cost Evaluation Board (SH1_LCEVB1), US7032EVB, + with a GNU ELF toolchain* under Linux or Cygwin. +

    +
      +

      + STATUS: + This port is available as of release 0.3.18 of NuttX. The port is basically complete + and many examples run correctly. However, there are remaining instabilities that + make the port un-usable. The nature of these is not understood; the behavior is + that certain SH-1 instructions stop working as advertised. This could be a silicon + problem, some pipeline issue that is not handled properly by the gcc 3.4.5 toolchain + (which has very limit SH-1 support to begin with), or perhaps with the CMON debugger. + At any rate, I have exhausted all of the energy that I am willing to put into this cool + old processor for the time being. + Refer to the NuttX board README file for further information. +

      +
    +
    + Renesas M16C/26. +

    +

    + Renesas M16C/26 Microcontroller. + This port uses the Renesas SKP16C26 Starter kit and the GNU M32C toolchain. + The development environment is either Linux or Cygwin under WinXP. +

    +
      +

      + STATUS: + Initial source files released in nuttx-0.4.2. + At this point, the port has not been integrated; the target cannot be built + because the GNU m16c-nuttx-elf-ld link fails with the following message: +

      +
        + m32c-nuttx-elf-ld: BFD (GNU Binutils) 2.19 assertion fail /home/Owner/projects/nuttx/buildroot/toolchain_build_m32c/binutils-2.19/bfd/elf32-m32c.c:482 +
      +

      Where the reference line is:

      +
        +/* If the symbol is out of range for a 16-bit address,
        +   we must have allocated a plt entry.  */
        +BFD_ASSERT (*plt_offset != (bfd_vma) -1);
        +
      +

      + No workaround is known at this time. This is a show stopper for M16C. + Refer to the NuttX board README file for further information. +

      +
    +
    + Zilog ZNEO Z16F. +

    +
      +
    • +

      + Zilog z16f2800100zcog development kit. + This port use the Zilog z16f2800100zcog development kit and the Zilog + ZDS-II Windows command line tools. + The development environment is either Windows native or Cygwin under Windows. +

      +

      + STATUS: + The initial release of support for the z16f was made available in NuttX version 0.3.7. + A working NuttShell (NSH) configuration as added in NuttX-6.33 (although a patch is required to work around an issue with a ZDS-II 5.0.1 tool problem). + An ESPI driver was added in NuttX-7.2. + Refer to the NuttX board README file for further information. +

      +
    • +
    +
    + Zilog eZ80 Acclaim!. +

    +

    + Zilog eZ80Acclaim! Microcontroller. + There are two eZ80Acclaim! ports: +

    +
      +
    • One uses the ZiLOG ez80f0910200kitg development kit, and +
    • The other uses the ZiLOG ez80f0910200zcog-d development kit. +
    +

    + Both boards are based on the eZ80F091 part and both use the Zilog ZDS-II + Windows command line tools. + The development environment is either Windows native or Cygwin under Windows. +

    +
      +

      + STATUS: + Integration and testing of NuttX on the ZiLOG ez80f0910200zcog-d is complete. + The first integrated version was released in NuttX version 0.4.2 (with important early bugfixes + in 0.4.3 and 0.4.4). + As of this writing, that port provides basic board support with a serial console, SPI, and eZ80F91 EMAC driver. + Refer to the NuttX board README files for the ez80f0910200kitg and ez80f910200zcofile for further information. +

      +
    +
    + Zilog Z8Encore!. +

    +

    + Zilog Z8Encore! Microcontroller. + This port uses the either: +

    +
      +
    • Zilog z8encore000zco development kit, Z8F6403 part, or
    • +
    • Zilog z8f64200100kit development kit, Z8F6423 part
    • +
    +

    + and the Zilog ZDS-II Windows command line tools. + The development environment is either Windows native or Cygwin under Windows. +

    +
      +

      + STATUS: + This release has been verified only on the ZiLOG ZDS-II Z8Encore! chip simulation + as of nuttx-0.3.9. + Refer to the NuttX board README files for the z8encore000zco and for thez8f64200100kit for further information. +

      +
        +
    + Zilog Z180. +

    +

    + P112. + The P112 is a hobbyist single board computer based on a 16MHz Z80182 with up to 1MB of memory, serial, parallel and diskette IO, and realtime clock, in a 3.5-inch drive form factor. + The P112 computer originated as a commercial product of "D-X Designs Pty Ltd"[ of Australia. +

    +

    + Dave Brooks was successfully funded through Kickstarter for and another run of P112 boards in November of 2012. + In addition Terry Gulczynski makes additional P112 derivative hobbyist home brew computers. +

    +
      +

      + STATUS: + Most of the NuttX is in port for both the Z80182 and for the P112 board. + Boards from Kickstarter project will not be available, however, until the third quarter of 2013. + So it will be some time before this port is verified on hardware. + Refer to the NuttX board README file for further information. +

      +
        +
    + Zilog Z80. +

    +

    + Z80 Instruction Set Simulator. + This port uses the SDCC toolchain + under Linux or Cygwin (verified using version 2.6.0). + This port has been verified using only a Z80 instruction simulator called z80sim. +

    +
      +

      + STATUS: + This port is complete and stable to the extent that it can be tested + using an instruction set simulator. + Refer to the NuttX board README file for further information. +

      +
        +



    +

    + XTRS: TRS-80 Model I/III/4/4P Emulator for Unix. + A very similar Z80 port is available for XTRS, + the TRS-80 Model I/III/4/4P Emulator for Unix. + That port also uses the SDCC toolchain + under Linux or Cygwin (verified using version 2.6.0). +

    +
      +

      + STATUS: + Basically the same as for the Z80 instruction set simulator. + This port was contributed by Jacques Pelletier. + Refer to the NuttX board README file for further information. +

      +
        +
    + +
    * A highly modified buildroot +is available that may be used to build a NuttX-compatible ELF toolchain under +Linux or Cygwin. Configurations are available in that buildroot to support ARM, Cortex-M3, +avr, m68k, m68hc11, m68hc12, m9s12, blackfin, m32c, h8, and SuperH ports.
    + + + + + +
    +

    Development Environments

    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Linux + GNU make + GCC/binutils for Linux +

    +

    + The is the most natural development environment for NuttX. + Any version of the GCC/binutils toolchain may be used. + There is a highly modified buildroot + available for download from the + NuttX Bitbucket.org + page. + This download may be used to build a NuttX-compatible ELF toolchain under Linux or Cygwin. + That toolchain will support ARM, m68k, m68hc11, m68hc12, and SuperH ports. + The buildroot GIT may be accessed in the NuttX + buildroot GIT. +

    +
    + Linux + GNU make + SDCC for Linux +

    +

    + Also very usable is the Linux environment using the + SDCC compiler. + The SDCC compiler provides support for the 8051/2, z80, hc08, and other microcontrollers. + The SDCC-based logic is less well exercised and you will likely find some compilation + issues if you use parts of NuttX with SDCC that have not been well-tested. +

    +
    + Windows with Cygwin + GNU make + GCC/binutils (custom built under Cygwin) +

    +

    + This combination works well too. + It works just as well as the native Linux environment except that compilation and build times are a little longer. + The custom NuttX buildroot referenced above may be build in the Cygwin environment as well. +

    +
    + Windows with Cygwin + GNU make + SDCC (custom built under Cygwin) +

    +

    + I have never tried this combination, but it would probably work just fine. +

    +
    + Windows with Cygwin + GNU make + Windows Native Toolchain +

    +

    + This is a tougher environment. + In this case, the Windows native toolchain is unaware of the + Cygwin sandbox and, instead, operates in the native Windows environment. + The primary difficulties with this are: +

    +
      +
    • + Paths. + Full paths for the native toolchain must follow Windows standards. + For example, the path /home/my\ name/nuttx/include my have to be + converted to something like 'C:\cygwin\home\my name\nuttx\include' + to be usable by the toolchain. +
    • +

      + Fortunately, this conversion is done simply using the cygpath utility. +

      +
    • + Symbolic Links + NuttX depends on symbolic links to install platform-specific directories in the build system. + On Linux, true symbolic links are used. + On Cygwin, emulated symbolic links are used. + Unfortunately, for native Windows applications that operate outside of the + Cygwin sandbox, these symbolic links cannot be used. +
    • +

      + The NuttX make system works around this limitation by copying the platform + specific directories in place. + These copied directories make work a little more complex, but otherwise work well. +

      +

      + NOTE: In this environment, it should be possible to use the NTFS mklink command to create links. + This should only require a minor modification to the build scripts (see tools/copydir.sh script). +

      +
    • + Dependencies + NuttX uses the GCC compiler's -M option to generate make dependencies. These + dependencies are retained in files called Make.deps throughout the system. + For compilers other than GCC, there is no support for making dependencies in this way. +
    • +

      + NOTE: dependencies may be suppressed by setting the make variable MKDEPS to point + to the do-nothing dependency script, tools/mknulldeps.sh. +

      +
    +

    + Supported Windows Native Toolchains. + At present, the following Windows native toolchains are in use: +

      +
    1. GCC built for Windows (such as CodeSourcery, Atollic, devkitARM, etc.),
    2. +
    3. SDCC built for Windows,
    4. +
    5. the ZiLOG XDS-II toolchain for Z16F, z8Encore, and eZ80Acclaim parts.
    6. +
    +

    +
    + Windows Native (CMD.exe) + GNUWin32 (including GNU make) + MinGW Host GCC compiler + Windows Native Toolchain +

    +

    + Build support has been added to support building natively in a Windows console rather than in a POSIX-like environment. +

    +

    + This build: +

    +
      +
    1. Uses all Windows style paths
    2. +
    3. Uses primarily Windows batch commands from cmd.exe, with
    4. +
    5. A few extensions from GNUWin32
    6. +
    +

    + This capability first appeared in NuttX-6.24 and should still be considered a work in progress because: (1) it has not been verfied on all targets and tools, and (2) still lacks some of the creature-comforts of the more mature environments. + The windows native build logic initiated if CONFIG_WINDOWS_NATIVE=y is defined in the NuttX configuration file: +

    +

    + At present, this build environment also requires: +

    +
      +
    • + Windows Console. + The build must be performed in a Windows console window. + This may be using the standard CMD.exe terminal that comes with Windows. + I prefer the ConEmu terminal which can be downloaded from: + http://code.google.com/p/conemu-maximus5/ +
    • +
    • + GNUWin32. + The build still relies on some Unix-like commands. + I usethe GNUWin32 tools that can be downloaded from http://gnuwin32.sourceforge.net/. + See the top-level nuttx/README.txt file for some download, build, and installation notes. +
    • +
    • + MinGW-GCC. + MinGW-GCC is used to compiler the C tools in the nuttx/tools directory that are neede by the build. + MinGW-GCC can be downloaded from http://www.mingw.org/. + If you are using GNUWin32, then it is recommended that you not install the optional MSYS components as there may be conflicts. +
    • +
    + Wine + GNU make + Windows Native Toolchain +

    +

    + I've never tried this one, but I off the following reported by an ez80 user using the ZiLOG ZDS-II Windows-native toolchain: +

    +
    +

    + "I've installed ZDS-II 5.1.1 (IDE for ez80-based boards) on wine (windows emulator for UNIX) and to my surprise, not many changes were needed to make GIT snapshot of NuttX buildable... + I've tried nsh profile and build process completed successfully. + One remark is necessary: NuttX makefiles for ez80 are referencing cygpath utility. + Wine provides similar thing called winepath which is compatible and offers compatible syntax. + To use that, winepath (which itself is a shell script) has to be copied as cygpath somewhere in $PATH, and edited as in following patch: +

    +
      +# diff -u `which winepath` `which cygpath`
      +--- /usr/bin/winepath 2011-05-02 16:00:40.000000000 +0200
      ++++ /usr/bin/cygpath 2011-06-22 20:57:27.199351255 +0200
      +@@ -20,7 +20,7 @@
      +#
      +
      +# determine the app Winelib library name
      +-appname=`basename "$0" .exe`.exe
      ++appname=winepath.exe
      +
      +# first try explicit WINELOADER
      +if [ -x "$WINELOADER" ]; then exec "$WINELOADER" "$appname" "$@"; fi
      +
    +

    + "Better solution would be replacing all cygpath references in Makefiles with $(CONVPATH) (or ${CONVPATH} in shell scripts) and setting CONVPATH to cygpath or winepath regarding to currently used environment. +

    +
    +
    + Other Environments? +

    +

    + Environment Dependencies. + The primary environmental dependency of NuttX are (1) GNU make, + (2) bash scripting, and (3) Linux utilities (such as cat, sed, etc.). + If you have other platforms that support GNU make or make + utilities that are compatible with GNU make, then it is very + likely that NuttX would work in that environment as well (with some + porting effort). If GNU make is not supported, then some significant + modification of the Make system would be required. +

    +

    + MSYS. + I have not used MSYS but what I gather from talking with NuttX users is that MSYS can be used as an alternative to Cygwin in any of the above Cygwin environments. + This is not surprising since MSYS is based on an older version of Cygwin (cygwin-1.3). + MSYS has been modified, however, to interoperate in the Windows environment better than Cygwin and that may be of value to some users. +

    +

    + MSYS, however, cannot be used with the native Windows NuttX build because it will invoke the MSYS bash shell instead of the CMD.exe shell. + Use GNUWin32 in the native Windows build envionment. +

    +
    + + + + + +
    +

    Licensing

    +
    + + + + + + + +
    +

    Bugs, Issues, Things-To-Do

    +
    + + + + + + +
    +

    Other Documentation

    +
    + + + +
    + 1 + This configuration variable document is auto-generated using the kconfig2html tool + That tool analyzes the NuttX Kconfig files and generates the HTML document. + As a consequence, this file may not be present at any given time but can be regenerated following the instructions in tools directory README file. +
    + + + + + + +
    +

    Trademarks

    +
    + + +

    + NOTE: NuttX is not licensed to use the POSIX trademark. + NuttX uses the POSIX standard as a development guideline only. +

    +
    + + + diff --git a/Documentation/NuttX.png b/Documentation/NuttX.png new file mode 100644 index 0000000000..360e657dd2 Binary files /dev/null and b/Documentation/NuttX.png differ diff --git a/Documentation/NuttX2-a.png b/Documentation/NuttX2-a.png new file mode 100644 index 0000000000..20c2fd6e71 Binary files /dev/null and b/Documentation/NuttX2-a.png differ diff --git a/Documentation/NuttX2-b.png b/Documentation/NuttX2-b.png new file mode 100644 index 0000000000..5bdab5c29d Binary files /dev/null and b/Documentation/NuttX2-b.png differ diff --git a/Documentation/NuttX2.png b/Documentation/NuttX2.png new file mode 100644 index 0000000000..422d1191fd Binary files /dev/null and b/Documentation/NuttX2.png differ diff --git a/Documentation/NuttX320.png b/Documentation/NuttX320.png new file mode 100644 index 0000000000..f736c41308 Binary files /dev/null and b/Documentation/NuttX320.png differ diff --git a/Documentation/NuttXBinfmt.html b/Documentation/NuttXBinfmt.html new file mode 100644 index 0000000000..49a999846c --- /dev/null +++ b/Documentation/NuttXBinfmt.html @@ -0,0 +1,608 @@ + + +NuttX Binary Loader + + +

    + + + + +
    +

    NuttX Binary Loader

    +

    Last Updated: August 22, 2014

    +
    +

    + + + + + +
    +

    Table of Contents

    +
    + + + + + + + +
    +

    1.0 Introduction

    +
    + +

    + Binary Loaders. + The purpose of a binary loader is to load and execute modules in various binary formats that reside in a file system. + Loading refers instantiating the binary module in some fashion, usually copy all or some of the binary module into memory and then linking the module with other components. + In most architectures, it is the base FLASH code that is the primary component that the binary module must link with because that is where the RTOS and primary tasks reside. + Program modules can then be executed after they have been loaded. +

    + +

    + Binary Formats. + The binary loader provides generic support for different binary formats. + It supports a registration interface that allows the number of support binary formats to be loaded at run time. + Each binary format provides a common, interface for use by the binary loader. + When asked to load a binary, the binary loader will query each registered binary format, providing it with the path of the binary object to be loaded. + The binary loader will stop when first binary format the recognizes the binary object and successfully loads it or when all registered binary formats have attempt loading the binary object and failed. +

    + +

    + At present, the following binary formats are support by NuttX: +

    + + +

    + Executables and Libraries + The generic binary loader logic does not care what it is that it being loaded. It could load an executable program or a library. + There are no strict rules, but a library will tend to export symbols and a program will tend to import symbols: The program will use the symbols exported by the library. + However, at this point in time, none of the supported binary formats support exporting of symbols. +

    + +

    + binfmt. + In the NuttX source code, the short name binfmt is used to refer to the NuttX binary loader. + This is the name of the directory containing the binary loader and the name of the header files and variables used by the binary loader. +

    + +

    + The name binfmt is the same name used by the Linux binary loader. + However, the NuttX binary loader is an independent development and shares nothing with the Linux binary loader other the same name and the same basic functionality. +

    + + + + + +
    +

    2.0 Binary Loader Interface

    +
    + +

    2.1 Binary Loader Header Files

    +

    + The interface to the binary loader is described in the header file + + include/nuttx/binfmt/binfmt.h. + A brief summary of the data structurs and interfaces prototyped in that header file are listed below. +

    + +

    2.2 Binary Loader Data Structures

    + +

    + When a binary format registers with the binary loader, it provides a pointer to a write-able instance of the following data structure: +

    + + +

    + The load method is used to load the binary format into memory. + It returns either OK (0) meaning that the binary object was loaded successfully, or a negated errno indicating why the object was not loaded. +

    + +

    + The type struct binary_s is use both to (2) describe the binary object to be loaded, and if successfully loaded, (2) to provide information about where and how the binary object was loaded. + That structure is shown below: +

    + + + + +

    + Where the types binfmt_ctor_t and binfmt_dtor_t define the type of one C++ constructor or destructor: +

    + + + +

    2.3 Binary Loader Function Interfaces

    + +

    + Binary format management: +

    + +

    + Basic module management: +

    + +

    + PATH traversal logic: +

    + + +

    2.3.1 register_binfmt()

    + +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.2 unregister_binfmt()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.3 load_module()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.4 unload_module()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.5 exec_module()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.7 exec()

    +

    Function Prototype:

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    2.3.8 exepath_init()

    +

    Function Prototype:

    + +

    Description:

    + +

    Input Parameters: None

    +

    Returned Value:

    + + +

    2.3.9 exepath_next()

    +

    Function Prototype:

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    2.3.10- exepath_release()

    +

    Function Prototype:

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value: None

    + + + + + +
    +

    3.0 Symbol Tables

    +
    + +

    + Symbol Tables. + Symbol tables are lists of name value mappings: + The name is a string that identifies a symbol, and the value is an address in memory where the symbol of that name has been positioned. + In most NuttX architectures symbol tables are required, as a minimum, in order to dynamically link the loaded binary object with the base code on FLASH. + Since the binary object was separately built and separately linked, these symbols will appear as undefined symbols in the binary object. + The binary loader will use the symbol table to look up the symbol by its name and to provide the address associated with the symbol as needed to perform the dynamic linking of the binary object to the base FLASH code. +

    + +

    3.1 Symbol Table Header Files

    +

    + The interface to the symbol table logic is described in the header file + + include/nuttx/binfmt/symtab.h. + A brief summary of the data structurs and interfaces prototyped in that header file are listed below. +

    + +

    3.2 Symbol Table Data Structures

    +

    + struct symbtab_s describes one entry in the symbol table. +

    + + + +

    + A symbol table is a fixed size array of struct symtab_s. + The information is intentionally minimal and supports only: +

    +
      +
    1. + Function pointers as sym_values. + Of other kinds of values need to be supported, then typing information would also need to be included in the structure. +
    2. +
    3. + Fixed size arrays. + There is no explicit provisional for dyanamically adding or removing entries from the symbol table (realloc might be used for that purpose if needed). + The intention is to support only fixed size arrays completely defined at compilation or link time. +
    4. +
    + +

    3.3 Symbol Table Function Interfaces

    + + + +

    3.3.1 symtab_findbyname()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    3.3.2 symtab_findorderedbyname()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    3.3.3 symtab_findbyvalue()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    3.3.4 symtab_findorderedbyvalue()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + + + + + +
    +

    4.0 Configuration Variables

    +
    + + + +

    + Additional configuration options may be required for the each enabled binary format. +

    + + diff --git a/Documentation/NuttXCCodingStandard.html b/Documentation/NuttXCCodingStandard.html new file mode 100644 index 0000000000..d1e96795c7 --- /dev/null +++ b/Documentation/NuttXCCodingStandard.html @@ -0,0 +1,2599 @@ + + +NuttX C Coding Standard + + + + +

    + + + + +
    +

    + NuttX C Coding Standard +

    +

    Last Updated: July 28, 2015

    +
    +

    + + + + + +
    +

    Table of Contents

    +
    + + + + + + + +
    +

    1.0 General Organization

    +
    + +

    1.1 File Organization

    + +

    + File Extensions + Use the .h extension for C header files and .c for C source files. +

    +

    + File header. + Every C, C++, make file, or script begins with a file header. + That file header is enclosed with a block comment (see below). + Within the block comment, the following must appear: +

    + +

    + Sample File Headers. + Sample file headers are provided in an Appendix to this document. + No software may be included in the NuttX source tree that does not have licensing information included in the file. + No software may be included in the NuttX source tree that does not have a (modified) BSD license or compatible license (such as the MIT license). + If the file does not following BSD licensing, then the appropriate license information should be provided in the header rather than the (modified) BSD licensing information and a NOTE should be included in the top-level COPYING file to indicate any variations from (modified) BSD licensing. +

    +

    + Grouping. + All like components in a C source or header file are grouped together. + Definitions do not appear arbitrarily through the file, rather, like definitions are grouped together and preceded by a block comment identifying the grouping. +

    +

    + Block Comments. + Each grouping in the file is separated with a block comment. + The block comment consists of: +

    + +

    + Examples of Block Comments. + See Appendix A for examples of block comments. +

    +

    + Order of Groupings. + The following groupings should appear in all C source files in the following order: +

    +
      +
    1. + Included Files +
    2. +
    3. + Pre-processor Definitions +
    4. +
    5. + Private Types +
    6. +
    7. + Private Function Prototypes +
    8. +
    9. + Private Data (definitions) +
    10. +
    11. + Public Data (definitions) +
    12. +
    13. + Private Functions (definitions) +
    14. +
    15. + Public Functions (definitions) +
    16. +
    +

    + The following groupings should appear in all C header files in the following order: +

    +
      +
    1. + Included Files +
    2. +
    3. + Pre-processor Definitions +
    4. +
    5. + Public Types +
    6. +
    7. + Public Data (declarations) +
    8. +
    9. + Inline Functions (definitions) +
    10. +
    11. + Public Function Prototypes (declarations) +
    12. +
    +

    + Large vs. Small Files. + In larger files, block comments should be included for all groupings, even if they are empty; + the empty grouping provides important information in itself. + Smaller files may omit some of the block comments; + it is awkard if the block comments are larger than the file content! +

    +

    + Header File Idempotence. + C header file must protect against multipleinclusion through the use of macros that "guard" against multiple definitions if the header file is included multiple times. +

    + +

    + Forming Guard Names. + Then pre-processor macro name used in the guard is formed from the full, relative path to the header for from the top-level, controlled directory. + That pat is preceded by __ and _ replaces each character that would otherwise be invalid in a macro name. + So, for example, __INCLUDE_NUTTX_ARCH_H corresponds to the header file include/nuttx/arch.h +

    + +

    + Deoxygen Information. + NuttX does not use Deoxygen for documentation and no file should contain Doxygen tags. +

    + +

    + Sample File Formats. + C source and header file templates are provided in an Appendix to this document. +

    + +

    1.2 Lines

    +

    + Line Endings. + Files should be formatted with \n as the line ending (Unix line endings), not \r\n (Windows line endings). + There should be no extra whitespace at the end of the line. + In addition, all text files should end in a single newline (\n). This avoids the "No newline at end of file" warning generated by certain tools. +

    + +

    + Line Width. + Text should not extend past column 78 in the typical C source or header file. + Sometimes the nature of the content of a file may require that the lines exceed this limit. + This often occurs in header files with naturally long definitions. + If the line width must extend 78 lines, then some wider line width may be used in the file provided that it is used consistently. +

    + +

    + Line Wrapping. +

    +
    + + +
    +

    Incorrect

    +
      +  struct some_long_struct_name_s
      +  {
      +    struct some_long_struct_name_s *flink;  /* The forward link to the next instance of struct some_long_struct_name_s in a singly linked list */
      +    int short_name1;   /* Short comment 1 */
      +    int short_name2;   /* This is a very long comment describing subtle aspects of the short_name2 field */
      +  };
      +
      +  struct some_medium_name_s *ptr = (struct some_medium_name_s *)malloc(sizeof(some_medium_name_s);
      +
      +  struct some_long_struct_name_s *ptr = (struct some_long_struct_name_s *)malloc(sizeof(some_long_struct_name_s);
      +
      +  ret = some_function_with_many parameters(long_parameter_name_1, long_parameter_name_2, long_parameter_name_3, long_parameter_name_4, long_parameter_name_5, long_parameter_name_6, long_parameter_name_7, long_parameter_name_8);
      +
      +  ret = some_function_with_many parameters(long_parameter_name_1,
      +    long_parameter_name_2,
      +    long_parameter_name_3
      +    long_parameter_name_4,
      +    long_parameter_name_5,
      +    long_parameter_name_6,
      +    long_parameter_name_7,
      +    long_parameter_name_8);
      +
    +
    +

    Correct

    +
      +  struct some_long_struct_name_s
      +  {
      +    /* The forward link to the next instance of struct
      +     * some_long_struct_name_s in a singly linked list.
      +     */
      +
      +    struct some_long_struct_name_s *flink;
      +    int short_name1;   /* Short comment 1. */
      +    int short_name2;   /* This is a very long comment describing subtle
      +                        * aspects of the short_name2 field. */
      +  };
      +
      +  FAR struct some_medium_name_s *ptr = (FAR struct some_medium_name_s *)
      +    malloc(sizeof(some_medium_name_s);
      +
      +  FAR struct some_medium_name_s *ptr =
      +    (FAR struct some_medium_name_s *)malloc(sizeof(some_medium_name_s);
      +
      +  FAR struct some_long_struct_name_s *ptr =
      +    (FAR struct some_long_struct_name_s *)
      +      malloc(sizeof(some_long_struct_name_s);
      +
      +  ret = some_function_with_many parameters(long_parameter_name_1,
      +                                           long_parameter_name_2,
      +                                           long_parameter_name_3,
      +                                           long_parameter_name_4,
      +                                           long_parameter_name_5,
      +                                           long_parameter_name_6,
      +                                           long_parameter_name_7,
      +                                           long_parameter_name_8);
      +
    +
    + +

    + NOTE: + See the discussion of pointers for information about the FAR qualifier used above. +

    + +

    + Double Spacing. + A single blank line may be use to separate logical groupings as the designer feels fit. + Single blank lines are also required in certain contexts as defined in this standard. + Additional blanks lines (two or more) are prohibited. +

    + +

    + Columnar Organization. + Similar things should be aligned on the same column unless doing so would cause the line width to be exceeded. +

    +
    + + +
    +

    Acceptable

    +
      +  dog = cat;
      +  monkey = oxen;
      +  aardvark = macaque;
      +
    +
    +

    Preferred

    +
      +  dog      = cat;
      +  monkey   = oxen;
      +  aardvark = macaque;
      +
    +
    + +

    + Block Comments + The final asterisk (*) should occur at column 78 (or the line width of files with longer lines). + Note that the final comment delimiter of the block comment is an exception an lies at column 79. +

    + +

    1.3 Comments

    + +

    + General. + Within a comment, the text must be standard English conforming to standard English rules of grammar and spelling (US English spelling). + Of course, this is not the place to summarize all English grammar, but as examples of common grammatic issues in comments: +

    + +

    + Line Spacing + A single blank line should precede and follow each comment. + The only exception is for the file header block comment that begins on line one; + there is no preceding blank line in that case. +

    +
    + + +
    +

    Incorrect

    +
      +  /* set a equal to b */
      +  a = b;
      +  /* set b equal to c */
      +  b = c;
      +
    +
    +

    Correct

    +
      +
      +  /* Set a equal to b. */
      +
      +  a = b;
      +
      +  /* Set b equal to c. */
      +
      +  b = c;
      +
      +
    +
    + +

    + Indentation + Comments should, typically, be placed before the code section to which they apply. + The comment identation should be the same as the follow identation rules as the following code (if applicable). +

    + +

    + Short, Single line comments. + Short comments must lie on a single line. + The comment delimiters must lie on the same line. +

    +
    + + +
    +

    Incorrect

    +
      +  /*
      +   * This is a single line comment
      +   */
      +
    +
    +

    Correct

    +
      +  /* This is a single line comment. */
      +
    +
    + +

    + Multi-line comments. + If the comment is too long to fit on a single, it must be broken into a multi-line comment. + The comment must be begin on the first line of the multi-line comment with the opening comment delimiter (/*). + The following lines of the multi-line comment must be with an asterisk (*) aligned in the same column as the asterisk in the preceding line. + The closing comment delimiter must lie on a separate line with the asterisk (*) aligned in the same column as the asterisk in the preceding line. +

    +
    + + +
    +

    Incorrect

    +
      +  /*
      +     This is the first line of a multi-line comment.
      +     This is the second line of a multi-line comment.
      +     This is the third line of a multi-line comment. */
      +
      +  /* This is the first line of another multi-line comment.  */
      +  /* This is the second line of another multi-line comment. */
      +  /* This is the third line of another multi-line comment.  */
      +
      +
    +
    +

    Correct

    +
      +  /* This is the first line of a multi-line comment.
      +   * This is the second line of a multi-line comment.
      +   * This is the third line of a multi-line comment.
      +   */
      +
      +
    +
    + +

    + Comments to the Right of Statements. + Comments to the right of statements in C source files are discouraged + If such comments are used, they should at least be aligned so that the comment begins in the same comment on each line. +

    +
    + + + +
    +

    Incorrect

    +
      +  dog = cat; /* Make the dog be a cat */
      +  monkey = oxen; /* Make the monkey be an oxen */
      +  aardvark = macaque; /* Make the aardvark be a macaque */
      +
    +
    +

    Acceptable

    +
      +  dog      = cat;     /* Make the dog be a cat. */
      +  monkey   = oxen;    /* Make the monkey be an oxen. */
      +  aardvark = macaque; /* Make the aardvark be a macaque. */
      +
    +
    +

    Preferred

    +
      +  /* Make the dog be a cat. */
      +
      +  dog      = cat;
      +
      +  /* Make the monkey be an oxen. */
      +
      +  monkey   = oxen;
      +
      +  /* Make the aardvark be a macaque. */
      +
      +  aardvark = macaque;
      +
    +
    + +

    + Comments to the Right of Data Definitions. + Comments to the right of a declaration with an enumeration or structure, on the other hand, are encourage. + Columnar alignment of comments is very desireable (but often cannot be achieved without violating the line width). +

    +
    + + + +
    +

    Incorrect

    +
      +struct animals_s
      +{
      +  int dog; /* This is a dog */
      +  int cat; /* This is a cat */
      +  double monkey; /* This is a monkey */
      +  double oxen; /* This is an oxen */
      +  bool aardvark; /* This is an aardvark */
      +  bool macaque; /* This is a macaque */
      +};
      +
    +
    +

    Acceptable

    +
      +struct animals_s
      +{
      +  int dog;       /* This is a dog. */
      +  int cat;       /* This is a cat. */
      +  double monkey; /* This is a monkey. */
      +  double oxen;   /* This is an oxen. */
      +  bool aardvark; /* This is an aardvark. */
      +  bool macaque;  /* This is a macaque. */
      +};
      +
    +
    +

    Preferred

    +
      +struct animals_s
      +{
      +  int    dog;      /* This is a dog. */
      +  int    cat;      /* This is a cat. */
      +  double monkey;   /* This is a monkey. */
      +  double oxen;     /* This is an oxen. */
      +  bool   aardvark; /* This is an aardvark. */
      +  bool   macaque;  /* This is a macaque. */
      +};
      +
    +
    + +

    + Block comments. + Block comments are only used to delimit groupings with the overall file organization and should not be used unless the usage is consistent with delimiting logical groupings in the program. +

    + +

    + C Style Comments. + C99/C11/C++ style comments (beginning wih //) should not be used with NuttX. + NuttX generally follows C89 and all code outside of architecture specific directories must be compatible with C89. +

    +
    + + +
    +

    Incorrect

    +
      +// This is a structure of animals
      +struct animals_s
      +{
      +  int    dog;      // This is a dog
      +  int    cat;      // This is a cat
      +  double monkey;   // This is a monkey
      +  double oxen;     // This is an oxen
      +  bool   aardvark; // This is an aardvark
      +  bool   macaque;  // This is a macaque
      +};
      +
    +
    +

    Correct

    +
      +/* This is a structure of animals. */
      +
      +struct animals_s
      +{
      +  int    dog;      /* This is a dog. */
      +  int    cat;      /* This is a cat. */
      +  double monkey;   /* This is a monkey. */
      +  double oxen;     /* This is an oxen. */
      +  bool   aardvark; /* This is an aardvark. */
      +  bool   macaque;  /* This is a macaque. */
      +};
      +
    +
    + +

    + "Commenting Out" Large Code Blocks. + Do not use C or C++ comments to disable compilation of large blocks of code. + Instead, use #if 0 to do that. + Make sure there is a comment before the #if 0 to explain why the code is not compiled. +

    +
    + + +
    +

    Incorrect

    +
      +void some_function(void)
      +{
      +  ... compiled code ...
      +
      +  /*
      +  ... disabled code ..
      +   */
      +
      +  ... compiled code ...
      +}
      +
      +void some_function(void)
      +{
      +  ... compiled code ...
      +
      +  //
      +  // ... disabled code ..
      +  //
      +
      +  ... compiled code ...
      +}
      +
    +
    +

    Correct

    +
      +void some_function(void)
      +{
      +  ... compiled code ...
      +
      +  /* The following code is disabled because it is no longer needed. */
      +
      +#if 0
      +  ... disabled code ..
      +#endif
      +
      +  ... compiled code ...
      +}
      +
    +
    + +

    1.4 Braces

    + +

    Coding Standard:

    + + +
    + + +
    +

    Incorrect

    +
      +while (true)
      +  {
      +    if (valid)
      +      {
      +      ...
      +      } /* if valid */
      +    else
      +      {
      +      ...
      +      } /* not valid */
      +  } /* end forever */
      +
    +
    +

    Correct

    +
      +while (true)
      +  {
      +    if (valid)
      +      {
      +      ...
      +      }
      +    else
      +      {
      +      ...
      +      }
      +  }
      +
    +
    + +

    + Exceptions. + The exception is braces that following structure, enumeration, union, and function declarations. + There is no additional indentation for those braces; + those braces align with the beginning of the definition +

    +
    + + +
    +

    Incorrect

    +
      +enum kinds_of_dogs_e
      +  {
      +  ...
      +  };
      +
      +struct dogs_s {
      +  ...
      +  union {
      +  ...
      +  } u;
      +  ...
      +};
      +
      +struct cats_s
      +  {
      +  ...
      +    union
      +     {
      +     ...
      +     } u;
      +  ...
      +  };
      +
      +int animals(int animal)
      +  {
      +  ...
      +  }
      +
    +
    +

    Correct

    +
      +enum kinds_of_dogs_e
      +{
      +  ...
      +};
      +
      +struct dogs_s
      +{
      +  ...
      +  union
      +  {
      +  ...
      +  } u;
      +  ...
      +};
      +
      +struct cats_s
      +{
      +  ...
      +  union
      +  {
      +  ...
      +  } u;
      +  ...
      +};
      +
      +int animals(int animal)
      +{
      +  ...
      +}
      +
    +
    + +

    1.5 Indentation

    + +

    + Indentation Unit. + Indentation is in units of two spaces; Each indentation level is twos spaces further to the right than the preceding identation levels. +

    +
    + + +
    +

    Incorrect

    +
      +	if (x == y) {
      +		dosomething(x);
      +	}
      +
      +    if (x == y) {
      +        dosomething(x);
      +    }
      +
    +
    +

    Correct

    +
      +  if (x == y)
      +    {
      +      dosomething(x);
      +    }
      +
    +
    + +

    + Use of TAB Characters. + The use of TAB characters for indentation is prohibited in C source and header files. + TAB characters are, however, used in make files, assembly language source files, Kconfig files and some script files. + When TAB characters are used in these files, spaces may not be used for indentation. + The correct TAB setting is 4 spaces (not 8) in these cases. +

    +

    + Alignment of Braces. + Note that since braces must be on a separate line (see above), this indentation by two spaces has an interesting property: + All C statements (and case selectors) like on lines that are odd multiples of 2 spaces: 2, 6, 10, ... (2*n + 1). + A braces lie on a separate line indented by an even multple of 2 spaces: 4, 8, 12, ... 2*n. +

    + +

    + Indentation of Pre-Processor Lines. + C Pre-processor commands following any conditional computation are also indented following basically the indentation same rules, differing in that the # always remains in column 1. +

    + +
    + + +
    +

    Incorrect

    +
      +#ifdef CONFIG_ABC
      +#define ABC_THING1 1
      +#define ABC_THING2 2
      +#define ABC_THING3 3
      +#endif
      +
      +#ifdef CONFIG_ABC
      +  #define ABC_THING1 1
      +  #define ABC_THING2 2
      +  #define ABC_THING3 3
      +#endif
      +
    +
    +

    Correct

    +
      +#ifdef CONFIG_ABC
      +#  define ABC_THING1 1
      +#  define ABC_THING2 2
      +#  define ABC_THING3 3
      +#endif
      +
      +#ifdef CONFIG_ABC
      +#  define ABC_THING1 1
      +#  define ABC_THING2 2
      +#  define ABC_THING3 3
      +#endif
      +
    +
    + +

    + Exception. + Each header file includes idempotence definitions at the beginning of the header file. + This conditional compilation does not cause any change to the indentation. +

    +
    + + +
    +

    Incorrect

    +
      +#ifndef __INCLUDE_SOMEHEADER_H
      +#  define __INCLUDE_SOMEHEADER_H
      +...
      +#  define THING1 1
      +#  define THING2 2
      +#  define THING3 3
      +...
      +#endif /* __INCLUDE_SOMEHEADER_H */
      +
    +
    +

    Correct

    +
      +#ifndef __INCLUDE_SOMEHEADER_H
      +#define __INCLUDE_SOMEHEADER_H
      +...
      +#define THING1 1
      +#define THING2 2
      +#define THING3 3
      +...
      +#endif /* __INCLUDE_SOMEHEADER_H */
      +
    +
    + +

    1.6 Parentheses

    + +

    Coding Standard:

    + +
    + + +
    +

    Incorrect

    +
      +int do_foobar ( void )
      +{
      +  int ret = 0;
      +  int i;
      +
      +  for( i = 0; ( ( i < 5 ) || ( ret < 10 ) ); i++ )
      +    {
      +      ret = foobar ( i );
      +    }
      +
      +  return ( ret );
      +}
      +
    +
    +

    Correct

    +
      +int do_foobar(void)
      +{
      +  int ret = 0;
      +  int i;
      +
      +  for (i = 0; i < 5 || ret < 10; i++)
      +    {
      +      ret = foobar(i);
      +    }
      +
      +  return ret;
      +}
      +
    +
    + +

    + NOTE: + Many people do not trust their understanding of the precedence of operators and so use lots of parentheses in expressions to force the order of evaluation even though the parentheses may have no effect. + This will certainly avoid errors due to an unexpected order of evaluation, but can also make the code ugly and overly complex (as in the above example). + In general, NuttX does not use unnecessary parentheses to force order of operations. + There is no particular policy in this regard. + However, you are are advised to check your C Programming Language book if necessary and avoid unnecessary parenthesis when possible. +

    + + + + + +
    +

    2.0 Data and Type Definitions

    +
    + +

    2.1 One Definition/Declaration Per Line

    + +
    + + +
    +

    Incorrect

    +
      +  extern long time, money;
      +  char **ach, *bch;
      +  int i, j, k;
      +
    +
    +

    Correct

    +
      +  extern long time;
      +  extern long money;
      +  FAR char **ach;
      +  FAR char *bch;
      +  int i;
      +  int j;
      +  int k;
      +
    +
    + +

    + NOTE: + See the discussion of pointers for information about the FAR qualifier used above. +

    + +

    2.2 Global Variables

    + +

    Coding Standard:

    + +
    + + + +
    +

    Incorrect

    +
      +extern int someint;
      +uint32_t dwA32BitInt;
      +uint32_t gAGlobalVariable;
      +
    +
    +

    Acceptable

    +
      +extern int g_someint;
      +uint32_t g_a32bitint;
      +uint32_t g_aglobal;
      +
    +
    +

    Preferred

    +
      +struct my_variables_s
      +{
      +  uint32_t a32bitint;
      +  uint32_t aglobal;
      +};
      +
      +extern int g_someint;
      +struct my_variables_s g_myvariables;
      +
    +
    + +

    2.3 Parameters and Local Variables

    + +

    Coding Standard:

    + +
    + + +
    +

    Incorrect

    +
      +uint32_t somefunction(int a, uint32_t dwBValue)
      +{
      +  uint32_t this_is_a_long_variable_name = 1;
      +  int i;
      +
      +  for (i = 0; i < a; i++)
      +    {
      +      this_is_a_long_variable_name *= dwBValue--;
      +    }
      +
      +  return this_is_a_long_variable_name;
      +}
      +
    +
    +

    Correct

    +
      +uint32_t somefunction(int limit, uint32_t value)
      +{
      +  uint32_t ret = 1;
      +  int i;
      +
      +  for (i = 0; i < limit; i++)
      +    {
      +      ret *= value--;
      +    }
      +
      +  return ret;
      +}
      +
    +
    + +

    + NOTE: + You will see the local variable named ret is frequently used in the code base for the name of a local variable whose value will be returned or to received the returned value from a called function. +

    + +

    2.4 Type Definitions

    + +

    Coding Standard:

    + +
    + + +
    +

    Incorrect

    +
      +typedef void *myhandle;
      +typedef int myInteger;
      +
    +
    +

    Correct

    +
      +typedef FAR void *myhandle_t;
      +typedef int myinteger_t;
      +
    +
    + +

    + NOTE: + See the discussion of pointers for information about the FAR qualifier used above. +

    + +

    2.5 Structures

    + +

    Structure Naming

    + + +

    Structure Field Naming

    + +

    + Other Applicable Coding Standards. + See sections related to line formatting, use of braces, indentation, and comments. +

    +

    + Size Optimizations. + When declaring fields in structures, order the declarations in such a way as to minimize memory waste due of data alignment. + This essentially means that that fields should be organized by data size, not by functionality: + Put all pointers togeter, all uint8_t's together, all uint32_t's together. + Data types withi well known like uint8_t and uint32_t should also be place in either ascending or descending size order. +

    +
    + + +
    +

    Incorrect

    +
      +typedef struct
      +{
      +  ...
      +  int val1, val2, val3; /* Values 1-3 */
      +  ...
      +} xzy_info_t;
      +
      +struct xyz_information
      +{
      +  ...
      +  uint8_t bita : 1,  /* Bit A */
      +          bitb : 1,  /* Bit B */
      +          bitc : 1;  /* Bit C */
      +  ...
      +};
      +
    +
    +

    Correct

    +
      +struct xyz_info_s
      +{
      +  ...
      +  int val1; /* Value 1. */
      +  int val2; /* Value 2. */
      +  int val3; /* Value 3. */
      +  ...
      +};
      +
      +
      +typdef struct xyz_info_s xzy_info_t;
      +
      +

      (The use of typedef'ed structures is acceptable but discouraged)

      +
      +struct xyz_info_s
      +{
      +  ...
      +  uint8_t bita : 1,  /* Bit A. */
      +  uint8_t bitb : 1,  /* Bit B. */
      +  uint8_t bitc : 1,  /* Bit C. */
      +  ...
      +};
      +
    +
    + +

    2.6 Unions

    +

    + Union and Field Names. + Naming of unions and fields within unions follow the same naming rules as for structures and structure fields. + The only difference is that the suffix _u is used to identify unions. +

    +

    + Other Applicable Coding Standards. + See sections related to line formatting, use of braces, indentation, and comments. +

    +
    + +
    +

    Example

    +
      +union xyz_union_u
      +{
      +  uint8_t  b[4]; /* Byte values. */
      +  uint16_t h[2]; /* Half word values. */
      +  uint32_t w;    /* Word Value. */
      +};
      +
      +struct xyz_info_s
      +{
      +  ...
      +  union
      +  {
      +    uint8_t  b[4]; /* Byte values. */
      +    uint16_t h[2]; /* Half word values. */
      +    uint32_t w;    /* Word Value. */
      +  } u;
      +  ...
      +};
      +
    +
    +

    + NOTE: + Note that the union name u is used often. + This is another exception to the prohibition against using single character variable and field names. + The short field name u clearly identifies a union field and prevents the full name to the union value from being excessively long. +

    + +

    2.7 Enumerations

    +

    + Enumeration Naming. + Naming of enumerations follow the same naming rules as for structure and union naming. + The only difference is that the suffix _e is used to identify an enumeration. +

    +

    + Enumeration Value Naming. + Enumeration values, however, following a naming convention more similar to macros. +

    + +

    + Other Applicable Coding Standards. + See sections related to line formatting, use of braces, indentation, and comments. +

    +
    + +
    +

    Example

    +
      +enum xyz_state_e
      +{
      +  XYZ_STATE_UNINITIALIZED = 0, /* Uninitialized state. */
      +  XYZ_STATE_WAITING,           /* Waiting for input state. */
      +  XYZ_STATE_BUSY,              /* Busy processing input state. */
      +  XYZ_STATE_ERROR,             /* Halted due to an error. */
      +  XYZ_STATE_TERMINATING,       /* Terminating stated. */
      +  XYZ_STATE_TERMINATED         /* Terminating stated. */
      +};
      +
    +
    + +

    2.8 C Pre-processor Macros

    + +

    Coding Standard:

    + +

    + Macro Naming. + Macro naming following a naming convention similar to the naming of enumeration values. +

    + +

    + Other Applicable Coding Standards. + See sections related to line formatting, indentation, and comments. +

    +
    + + +
    +

    Incorrect

    +
      +#define max(a,b) a > b ? a : b
      +
      +#define ADD(x,y) x + y
      +
      +#ifdef HAVE_SOMEFUNCTION
      +int somefunction(struct somestruct_s* psomething);
      +#else
      +#define SOMEFUNCTION() (0)
      +#endif
      +
      +#	define	IS_A_CAT(c)		((c) == A_CAT)
      +
      +#define LONG_MACRO(a,b)                                  \
      +  {                                                      \
      +    int value;                                           \
      +    value = b-1;                                         \
      +    a = b*value;                                         \
      +  }
      +
      +#define DO_ASSIGN(a,b) a = b
      +
    +
    +

    Correct

    +
      +#define MAX(a,b) (((a) > (b)) ? (a) : (b))
      +
      +#define ADD(x,y) ((x) + (y))
      +
      +#ifdef HAVE_SOMEFUNCTION
      +int somefunction(struct somestruct_s* psomething);
      +#else
      +#  define somefunction(p) (0)
      +#endif
      +
      +# define IS_A_CAT(c)  ((c) == A_CAT)
      +
      +#define LONG_MACRO(a,b) \
      +  { \
      +    int value; \
      +    value = (b)-1; \
      +    (a) = (b)*value; \
      +  }
      +
      +#define DO_ASSIGN(a,b) do { (a) = (b); } while (0)
      +
    +
    + +

    2.9 Pointer Variables

    +

    + Pointer Naming. + Pointers following same naming conventions as for other variable types. + A pointer (or pointer-to-a-pointer) variable may be prefaced with p (or pp) with no intervening underscore character _ in order to identify that variable is a pointer. + That convention is not encouraged, however, and is only appropriate if there is some reason to be concerned that there might otherwise be confusion with another variable that differs only in not being a pointer. +

    + White Space. + The asterisk used in the declaration of a pointer variable or to dereference a pointer variable should be placed immediately before the variable name with no intervening spaces. + A space should precede the asterisk in a cast to a pointer type. +

    +
    + + +
    +

    Incorrect

    +
      +int somefunction(struct somestruct_s* psomething);
      +
      +ptr = (struct somestruct_s*)value;
      +
    +
    +

    Correct

    +
      +int somefunction(FAR struct somestruct_s *something);
      +
      +ptr = (FAR struct somestruct_s *)value;
      +
    +
    + +

    + FAR, NEAR, DSEG and CODE pointers. + Some architectures require a qualifier on pointers to identify the address space into which the pointer refers. + The macros FAR, NEAR, DSEG and CODE are defined in include/nuttx/compiler.h to provide meaning for this qualifiers when needed. + For portability, the general rule is that pointers to data that may lie in the stack, heap, .bss, or .data should be prefaced by the qualifier FAR; pointers to functions probably lie in a code address space and should have the qualifier CODE. + The typical effect of these macros on architectures where they have meaning to determine the size of the pointer (size in the sense of the width of the pointer value in bits). +

    + +

    2.10 Initializers

    +

    + Applicable Coding Standards. + See the section related to parentheses. +

    +

    + C89 Compatibility. + All common NuttX code must conform to ANSII C89 requirements. + Newer C standards permit more flexible initialization with named initializers and array initializers. + However, these are not backward compatible with C89 and cannot be used in common code. + Newer C99 features may be included in architecture-specific sub-directories where there is no possibility of the use of such older toolchains. + C11 is included in NuttX, but has not been verified and, hence, it not encourage anywhere. +

    + + + + + +
    +

    3.0 Functions

    +
    + +

    3.1 Function Headers

    + +

    Coding Standard:

    + +

    + Function header template. + Refer to Appendix A for the template for a function header. +

    + +

    3.2 Function Naming

    + +

    Coding Standard:

    + + +

    3.3 Parameter Lists

    + +

    + Coding Standards. + See general rules for parameter naming. + See also the sections related to the use of parentheses. +

    +

    + Use of const Parameters. + Use of the const storage class is encouraged. + This is appropriate to indicate that the function will not modify the object. +

    + +

    3.4 Function Body

    + +

    Coding Standard:

    + + +

    Returned Values

    + +

    + OS Internal Functions. + In general, OS internal functions return a type int to indicate success or failure conditions. + Non-negative values indicate success. + The return value of zero is the typical success return value, but other successful return can be represented with other positive values. + Errors are always reported with negative values. + These negative values must be a well-defined errno as defined in the file nuttx/include/errno.h. +

    + +

    + Application/OS Interface. + All but a few OS interfaces conform to documented standards that have precedence over the coding standards of this document. +

    + +

    + Checking Return Values. + Callers of internal OS functions should always check return values for an error. + At a minimum, a debug statement should indicate that an error has occurred. + The calling logic intentionally ignores the returned value, then the function return value should be explicitly cast to (void) to indicate that the return value is intentionally ignored. + An exception of for standard functions for which people have historically ignored the returned values, such as printf() or close. + All calls to malloc or realloc must be checked for failures to allocate memory. +

    + + + + + +
    +

    4.0 Statements

    +
    + +

    4.1 One Statement Per Line

    + +

    Coding Standard:

    + +

    + Other Applicable Coding Standards. + See the section related to the use of braces. +

    + +
    + + +
    +

    Incorrect

    +
      +  if (var1 < var2) var1 = var2;
      +
      +  case 5: var1 = var2; break;
      +
      +  var1 = 5; var2 = 6; var3 = 7;
      +
      +  var1 = var2 = var3 = 0;
      +
    +
    +

    Correct

    +
      +  if (var1 < var2)
      +    {
      +      var1 = var2;
      +    }
      +
      +  case 5:
      +    {
      +      var1 = var2;
      +    }
      +    break;
      +
      +  var1 = 5;
      +  var2 = 6;
      +  var3 = 7;
      +
      +  var1 = 0;
      +  var2 = 0;
      +  var3 = 0;
      +
    +
    + +

    4.2 Casts

    + +

    Coding Standard:

    + +
    + + +
    +

    Incorrect

    +
      +struct something_s *x = (struct something_s*) y;
      +
    +
    +

    Correct

    +
      +struct something_s *x = (struct something_s *)y;
      +
    +
    + +

    4.3 Operators

    +

    + Spaces before and after binary operators. + All binary operators (operators that come between two values), such as +, -, =, !=, ==, >, etc. should have a space before and after the operator, for readability. As examples: +

    +
    + + +
    +

    Incorrect

    +
      +for=bar;
      +if(a==b)
      +for(i=0;i>5;i++)
      +
    +
    +

    Correct

    +
      +for = bar;
      +if (a == b)
      +for (i = 0; i > 5; i++)
      +
    +
    + +

    + No space separating unary operators. + Unary operators (operators that operate on only one value), such as ++, should not have a space between the operator and the variable or number they are operating on. +

    +
    + + +
    +

    Incorrect

    +
      +x ++;
      +
    +
    +

    Correct

    +
      +x++;
      +
    +
    + +

    +

    4.4 if then else Statement

    + +

    Coding Standard:

    + +

    + Other Applicable Coding Standards. + See sections related to use of braces and indentation. +

    + +
    + + +
    +

    Incorrect

    +
      +  if(var1 < var2) var1 = var2;
      +
      +  if(var > 0)
      +    var--;
      +  else
      +    var = 0;
      +
      +  if (var1 > 0) {
      +    var1--;
      +  } else {
      +    var1 = 0;
      +  }
      +  var2 = var1;
      +
    +
    +

    Correct

    +
      +  if (var1 < var2
      +    {
      +      var1 = var2;
      +    }
      +
      +  if (var > 0)
      +    {
      +      var--;
      +    }
      +  else
      +    {
      +      var = 0;
      +    }
      +
      +  if (var1 > 0)
      +    {
      +      var1--;
      +    }
      +  else
      +    {
      +      var1 = 0;
      +    }
      +
      +  var2 = var1;
      +
    +
    + +

    + <condition> ? <then> : <else> +

    + +

    + Other Applicable Coding Standards. + See sections related to parentheses. +

    +
    + +
    +

    Example

    +
      +  int arg1 = arg2 > arg3 ? arg2 : arg3;
      +  int arg1 = ((arg2 > arg3) ? arg2 : arg3);
      +
    +
    + +

    4.5 switch Statement

    + +

    Coding Standard:

    + +

    + Other Applicable Coding Standards. + See sections related to use of braces, indentation, and comments. +

    +
    + +
    +

    Example

    +
      +  switch (...)
      +    {
      +      case 1:  /* Example of a comment following a case selector. */
      +      ...
      +
      +      /* Example of a comment preceding a case selector. */
      +
      +      case 2:
      +        {
      +          /* Example of comment following the case selector. */
      +
      +          int value;
      +          ...
      +        }
      +        break;
      +
      +      default:
      +        break;
      +    }
      +
    +
    + +

    4.6 while Statement

    +

    Coding Standard:

    + +

    + Other Applicable Coding Standards. + See sections related to use of braces, indentation, and comments. +

    +
    + + +
    +

    Incorrect

    +
      +  while( notready() )
      +    {
      +    }
      +  ready = true;
      +
      +  while (*ptr != '\0') ptr++;
      +
    +
    +

    Correct

    +
      +  while (notready());
      +
      +  ready = true;
      +
      +  while (*ptr != '\0')
      +    {
      +      ptr++;
      +    }
      +
      +
    +
    + +

    4.7 do while Statement

    +

    Coding Standard:

    + +

    + Other Applicable Coding Standards. + See sections related to use of braces, indentation, and comments. +

    +
    + + +
    +

    Incorrect

    +
      +  do {
      +    ready = !notready();
      +  } while (!ready);
      +  senddata();
      +
      +  do ptr++; while (*ptr != '\0');
      +
    +
    +

    Correct

    +
      +  do
      +    {
      +      ready = !notready();
      +    }
      +  while (!ready);
      +
      +  senddata();
      +
      +  do
      +    {
      +      ptr++;
      +    }
      +  while (*ptr != '\0');
      +
    +
    + +

    4.8 Use of goto

    +

    Coding Standard:

    + +
    + +
    +

    Example

    +
      +   FAR struct some_struct_s *ptr;
      +   int fd;
      +   int ret;
      +   ...
      +
      +   if (arg == NULL)
      +     {
      +       ret = -EINVAL;
      +       goto errout;
      +     }
      +   ...
      +   ptr = (FAR struct some_struct_s *)malloc(sizeof(struct some_struct_s));
      +   if (!ptr)
      +     {
      +       ret = -ENOMEM;
      +       goto errout;
      +     }
      +   ...
      +   fd = open(filename, O_RDONLY);
      +   if (fd < 0)
      +     {
      +       errcode = -errno;
      +       DEBUGASSERT(errcode > 0);
      +       goto errotout_with_alloc;
      +     }
      +   ...
      +   ret = readfile(fd);
      +   if (ret < 0)
      +     {
      +       goto errout_with_openfile;
      +     }
      +   ...
      +errout_with_openfile:
      +  close(fd);
      +
      +errout_with_alloc:
      +  free(ptr);
      +
      +error:
      +  return ret;
      +
    +
    +

    + NOTE: + See the discussion of pointers for information about the FAR qualifier used above. +

    + + + + + +
    +

    Appendix A

    +
    + +

    A.1 C Source File Structure

    +
    +/****************************************************************************
    + * <Relative path to the file>
    + * <Optional one line file description>
    + *
    + *   Copyright (C) <Year> <Copyright holder's name>. All rights reserved.
    + *   Author: <Author's name> <Contact e-mail>
    + *
    + * Redistribution and use in source and binary forms, with or without
    + * modification, are permitted provided that the following conditions
    + * are met:
    + *
    + * 1. Redistributions of source code must retain the above copyright
    + *    notice, this list of conditions and the following disclaimer.
    + * 2. Redistributions in binary form must reproduce the above copyright
    + *    notice, this list of conditions and the following disclaimer in
    + *    the documentation and/or other materials provided with the
    + *    distribution.
    + * 3. Neither the name NuttX nor the names of its contributors may be
    + *    used to endorse or promote products derived from this software
    + *    without specific prior written permission.
    + *
    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
    + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
    + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
    + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    + * POSSIBILITY OF SUCH DAMAGE.
    + *
    + ****************************************************************************/
    +
    +/****************************************************************************
    + * Included Files
    + ****************************************************************************/
    +
    +

    All header files are included here.

    +
    +/****************************************************************************
    + * Pre-processor Definitions
    + ****************************************************************************/
    +
    +

    All C pre-processor macros are defined here.

    +
    +/****************************************************************************
    + * Private Types
    + ****************************************************************************/
    +
    +

    Any types, enumerations, structures or unions used by the file are defined here.

    +
    +/****************************************************************************
    + * Private Function Prototypes
    + ****************************************************************************/
    +
    +

    Prototypes of all static functions in the file are provided here.

    +
    +/****************************************************************************
    + * Private Data
    + ****************************************************************************/
    +
    +

    All static data definitions appear here.

    +
    +/****************************************************************************
    + * Public Data
    + ****************************************************************************/
    +
    +

    All data definitions with global scope appear here.

    +
    +/****************************************************************************
    + * Private Functions
    + ****************************************************************************/
    +
    +/****************************************************************************
    + * Name: <Static function name>
    + *
    + * Description:
    + *   Description of the operation of the static function.
    + *
    + * Input Parameters:
    + *   A list of input parameters, one-per-line, appears here along with a
    + *   description of each input parameter.
    + *
    + * Returned Value:
    + *   Description of the value returned by this function (if any),
    + *   including an enumeration of all possible error values.
    + *
    + * Assumptions/Limitations:
    + *   Anything else that one might need to know to use this function.
    + *
    + ****************************************************************************/
    +
    +

    All static functions in the file are defined in this grouping. +Each is preceded by a function header similar to the above.

    +
    +/****************************************************************************
    + * Public Functions
    + ****************************************************************************/
    +
    +/****************************************************************************
    + * Name: <Global function name>
    + *
    + * Description:
    + *   Description of the operation of the function.
    + *
    + * Input Parameters:
    + *   A list of input parameters, one-per-line, appears here along with a
    + *   description of each input parameter.
    + *
    + * Returned Value:
    + *   Description of the value returned by this function (if any),
    + *   including an enumeration of all possible error values.
    + *
    + * Assumptions/Limitations:
    + *   Anything else that one might need to know to use this function.
    + *
    + ****************************************************************************/
    +
    +

    All global functions in the file are defined here.

    + +

    A.2 C Header File Structure

    + +
    +/****************************************************************************
    + * <Relative path to the file>
    + * <Optional one line file description>
    + *
    + *   Copyright (C) <Year> <Copyright holder's name>. All rights reserved.
    + *   Author: <Author's name> <Contact e-mail>
    + *
    + * Redistribution and use in source and binary forms, with or without
    + * modification, are permitted provided that the following conditions
    + * are met:
    + *
    + * 1. Redistributions of source code must retain the above copyright
    + *    notice, this list of conditions and the following disclaimer.
    + * 2. Redistributions in binary form must reproduce the above copyright
    + *    notice, this list of conditions and the following disclaimer in
    + *    the documentation and/or other materials provided with the
    + *    distribution.
    + * 3. Neither the name NuttX nor the names of its contributors may be
    + *    used to endorse or promote products derived from this software
    + *    without specific prior written permission.
    + *
    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
    + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
    + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
    + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    + * POSSIBILITY OF SUCH DAMAGE.
    + *
    + ****************************************************************************/
    +
    +

    Header file idempotence definitions go here

    +
    +/****************************************************************************
    + * Included Files
    + ****************************************************************************/
    +
    +

    All header files are included here.

    +
    +/****************************************************************************
    + * Pre-processor Definitions
    + ****************************************************************************/
    +
    +

    All C pre-processor macros are defined here.

    +
    +/****************************************************************************
    + * Public Types
    + ****************************************************************************/
    +
    +#ifndef __ASSEMBLY__
    +
    +

    Any types, enumerations, structures or unions are defined here.

    +
    +/****************************************************************************
    + * Public Data
    + ****************************************************************************/
    +
    +#ifdef __cplusplus
    +#define EXTERN extern "C"
    +extern "C"
    +{
    +#else
    +#define EXTERN extern
    +#endif
    +
    +
    +

    All data declarations with global scope appear here, preceded by the definition EXTERN.

    +
    +/****************************************************************************
    + * Inline Functions
    + ****************************************************************************/
    +
    +/****************************************************************************
    + * Name: <Inline function name>
    + *
    + * Description:
    + *   Description of the operation of the inline function.
    + *
    + * Input Parameters:
    + *   A list of input parameters, one-per-line, appears here along with a
    + *   description of each input parameter.
    + *
    + * Returned Value:
    + *   Description of the value returned by this function (if any),
    + *   including an enumeration of all possible error values.
    + *
    + * Assumptions/Limitations:
    + *   Anything else that one might need to know to use this function.
    + *
    + ****************************************************************************/
    +
    +

    Any static inline functions may be defined in this grouping. +Each is preceded by a function header similar to the above.

    +
    +/****************************************************************************
    + * Public Function Prototypes
    + ****************************************************************************/
    +
    +/****************************************************************************
    + * Name: <Global function name>
    + *
    + * Description:
    + *   Description of the operation of the function.
    + *
    + * Input Parameters:
    + *   A list of input parameters, one-per-line, appears here along with a
    + *   description of each input parameter.
    + *
    + * Returned Value:
    + *   Description of the value returned by this function (if any),
    + *   including an enumeration of all possible error values.
    + *
    + * Assumptions/Limitations:
    + *   Anything else that one might need to know to use this function.
    + *
    + ****************************************************************************/
    +
    +

    All global functions in the file are prototyped here. The keyword extern or the definition EXTERN are never used with function prototypes.

    +
    +#undef EXTERN
    +#ifdef __cplusplus
    +}
    +#endif
    +
    +#endif /* __INCLUDE_ASSERT_H */
    +
    +

    Ending with the header file idempotence #endif.

    + + + diff --git a/Documentation/NuttXDemandPaging.html b/Documentation/NuttXDemandPaging.html new file mode 100644 index 0000000000..afaaacf862 --- /dev/null +++ b/Documentation/NuttXDemandPaging.html @@ -0,0 +1,674 @@ + + +On-Demand Paging + + +

    + + + + +
    +

    On-Demand Paging

    +

    Last Updated: February 4, 2010

    +
    +

    + + + + + +
    +

    Table of Contents

    +
    + +
    + + + + + + + + + + +
    + + + + + + + + + + + + + +
    + Introduction +
      + Overview +
      + Terminology +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + NuttX Common Logic Design Description +
      + Initialization +
      + Page Faults +
      + Fill Initiation +
      + Fill Complete +
      + Task Resumption +
    +
    + + + + + + + + + + + + + +
    + Architecture-Specific Support Requirements +
      + Memory Organization +
      + Architecture-Specific Functions +
    +
    + + + + + +
    +

    Introduction

    +
    +

    Overview

    + +

    + This document summarizes the design of NuttX on-demand paging. + This feature permits embedded MCUs with some limited RAM space to execute large programs from some non-random access media. + This feature was first discussed in this email thread: + https://groups.yahoo.com/neo/groups/nuttx/conversations/messages/213. +

    +

    + What kind of platforms can support NuttX on-demang paging? +

      +
    1. + The MCU should have some large, probably low-cost non-volatile storage such as serial FLASH or an SD card. + This storage probably does not support non-random access (otherwise, why not just execute the program directly on the storage media). + SD and serial FLASH are inexpensive and do not require very many pins and SPI support is prevalent in just about all MCUs. + This large serial FLASH would contain a big program. Perhaps a program of several megabytes in size. +
    2. +
    3. + The MCU must have a (relatively) small block of fast SRAM from which it can execute code. + A size of, say 256K (or 192K as in the NXP LPC3131) would be sufficient for many applications. +
    4. +
    5. + The MCU has an MMU (again like the NXP LPC3131). +
    6. +
    +

    +

    + If the platform meets these requirement, then NuttX can provide on-demand paging: + It can copy .text from the large program in non-volatile media into RAM as needed to execute a huge program from the small RAM. +

    + +

    Terminology

    + +
    +
    g_waitingforfill
    +
    An OS list that is used to hold the TCBs of tasks that are waiting for a page fill.
    +
    g_pftcb
    +
    A variable that holds a reference to the TCB of the thread that is currently be re-filled.
    +
    g_pgworker
    +
    The process ID of of the thread that will perform the page fills.
    +
    pg_callback()
    +
    The callback function that is invoked from a driver when the fill is complete.
    +
    pg_miss()
    +
    The function that is called from architecture-specific code to handle a page fault.
    +
    TCB
    +
    Task Control Block
    +
    + + + + + +
    +

    NuttX Common Logic Design Description

    +
    + + +

    Initialization

    + +

    + The following declarations will be added. +

    +

    +

    + During OS initialization in sched/os_start.c, the following steps + will be performed: +

    +

    +

    + Declarations for g_waitingforfill, g_pgworker, and other + internal, private definitions will be provided in sched/paging/paging.h. + All public definitions that should be used by the architecture-specific code will be available + in include/nuttx/page.h. + Most architecture-specific functions are declared in include/nuttx/arch.h, + but for the case of this paging logic, those architecture specific functions are instead declared in include/nuttx/page.h. +

    + +

    Page Faults

    + +

    + Page fault exception handling. + Page fault handling is performed by the function pg_miss(). + This function is called from architecture-specific memory segmentation + fault handling logic. This function will perform the following + operations: +

      +
    1. + Sanity checking. + This function will ASSERT if the currently executing task is the page fill worker thread. + The page fill worker thread is how the page fault is resolved and all logic associated with the page fill worker + must be "locked" and always present in memory. +
    2. +
    3. + Block the currently executing task. + This function will call up_block_task() to block the task at the head of the ready-to-run list. + This should cause an interrupt level context switch to the next highest priority task. + The blocked task will be marked with state TSTATE_WAIT_PAGEFILL and will be retained in the g_waitingforfill prioritized task list. +
    4. +
    5. + Boost the page fill worker thread priority. + Check the priority of the task at the head of the g_waitingforfill list. + If the priority of that task is higher than the current priority of the page fill worker thread, then boost the priority of the page fill worker thread to that priority. + Thus, the page fill worker thread will always run at the priority of the highest priority task that is waiting for a fill. +
    6. +
    7. + Signal the page fill worker thread. + Is there a page already being filled? + If not then signal the page fill worker thread to start working on the queued page fill requests. +
    8. +
    +

    +

    + When signaled from pg_miss(), the page fill worker thread will be awakenend and will initiate the fill operation. +

    +

    + Input Parameters. + None -- The head of the ready-to-run list is assumed to be that task that caused the exception. + The current task context should already be saved in the TCB of that task. + No additional inputs are required. +

    +

    + Assumptions. +

    +

    + +

    Fill Initiation

    + +

    + The page fill worker thread will be awakened on one of three conditions: +

    +

    + +

    + The page fill worker thread will maintain a static variable called struct tcb_s *g_pftcb. + If no fill is in progress, g_pftcb will be NULL. + Otherwise, it will point to the TCB of the task which is receiving the fill that is in progess. +

    + + +

    + When awakened from pg_miss(), no fill will be in progress and g_pftcb will be NULL. + In this case, the page fill worker thread will call pg_startfill(). + That function will perform the following operations: +

    +

    +

    + In any case, while the fill is in progress, other tasks may execute. + If another page fault occurs during this time, the faulting task will be blocked, its TCB will be added (in priority order) to g_waitingforfill, and the priority of the page worker task may be boosted. + But no action will be taken until the current page fill completes. + NOTE: The IDLE task must also be fully locked in memory. + The IDLE task cannot be blocked. + It the case where all tasks are blocked waiting for a page fill, the IDLE task must still be available to run. +

    + The architecture-specific functions, up_checkmapping(), up_allocpage(tcb, &vpage) and up_fillpage(page, pg_callback) + will be prototyped in include/nuttx/arch.h +

    + +

    Fill Complete

    + +

    + For the blocking up_fillpage(), the result of the fill will be returned directly from the call to up_fillpage. +

    +

    + For the non-blocking up_fillpage(), the architecture-specific driver call the pg_callback() that was provided to up_fillpage() when the fill completes. + In this case, the pg_callback() will probably be called from driver interrupt-level logic. + The driver will provide the result of the fill as an argument to the callback function. + NOTE: pg_callback() must also be locked in memory. +

    +

    + In this non-blocking case, the callback pg_callback() will perform the following operations when it is notified that the fill has completed: +

    +

    + +

    Task Resumption

    + +

    + For the non-blocking up_fillpage(), the page fill worker thread will detect that the page fill is complete when it is awakened with g_pftcb non-NULL and fill completion status from pg_callback. + In the non-blocking case, the page fill worker thread will know that the page fill is complete when up_fillpage() returns. +

    +

    + In this either, the page fill worker thread will: +

    +

    + + + + + +
    +

    Architecture-Specific Support Requirements

    +
    + +

    Memory Organization

    + +

    + Memory Regions. + Chip specific logic will map the virtual and physical address spaces into three general regions: +

      +
    1. + A .text region containing "locked-in-memory" code that is always avaialable and will never cause a page fault. + This locked memory is loaded at boot time and remains resident for all time. + This memory regions must include: +
        +
      • + All logic for all interrupt paths. + All interrupt logic must be locked in memory because the design present here will not support page faults from interrupt handlers. + This includes the page fault handling logic and pg_miss() that is called from the page fault handler. + It also includes the pg_callback() function that wakes up the page fill worker thread + and whatever architecture-specific logic that calls pg_callback(). +
      • +
      • + All logic for the IDLE thread. + The IDLE thread must always be ready to run and cannot be blocked for any reason. +
      • +
      • + All of the page fill worker thread must be locked in memory. + This thread must execute in order to unblock any thread waiting for a fill. + It this thread were to block, there would be no way to complete the fills! +
      +
    2. +
    3. + A .text region containing pages that can be assigned allocated, mapped to various virtual addresses, and filled from some mass storage medium. +
    4. +
    5. + And a fixed RAM space for .bss, .text, and .heap. +
    6. +
    +

    +

    + This memory organization is illustrated in the following table. + Notice that: +

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    SRAMVirtual Address SpaceNon-Volatile Storage
     DATA 
     Virtual Page n (n > m)Stored Page n
     Virtual Page n-1Stored Page n-1
    DATA......
    Physical Page m (m < n)......
    Physical Page m-1......
    .........
    Physical Page 1Virtual Page 1Stored Page 1
    Locked MemoryLocked MemoryMemory Resident
    + +

    + Example. + As an example, suppose that the size of the SRAM is 192K (as in the NXP LPC3131). And suppose further that: +

    +

    + Then, the size of the locked, memory resident code is 32K (m=32 pages). + The size of the physical page region is 96K (96 pages), and the + size of the data region is 64 pages. + And the size of the virtual paged region must then be greater than or equal to (1024-32) or 992 pages (n). +

    + +

    + Building the Locked, In-Memory Image. + One way to accomplish this would be a two phase link: +

    +

    + +

    Architecture-Specific Functions

    + +

    + Most standard, architecture-specific functions are declared in include/nuttx/arch.h. + However, for the case of this paging logic, the architecture specific functions are declared in include/nuttx/page.h. + Standard, architecture-specific functions that should already be provided in the architecture port. + The following are used by the common paging logic: +

    + + +

    + New, additional functions that must be implemented just for on-demand paging support: +

    + + + + + diff --git a/Documentation/NuttXGettingStarted.html b/Documentation/NuttXGettingStarted.html new file mode 100644 index 0000000000..ddc02844b2 --- /dev/null +++ b/Documentation/NuttXGettingStarted.html @@ -0,0 +1,25 @@ + + +NuttX Getting Started + + + +

    + + + + +
    +

    Getting Started with NuttX

    +

    Last Updated: December 31, 2011

    +
    +

    +

    Getting Started. + There is no "Getting Started" Guide for NuttX yet. + However, most everything that you need to get started with NuttX can be found in the README.txt file located in the top-level NuttX directory. + That README.txt can also be read online in the NuttX GIT repository + here. + Just click on "Links to HEAD: (view)" on that page. +

    + + diff --git a/Documentation/NuttXNxFlat.html b/Documentation/NuttXNxFlat.html new file mode 100644 index 0000000000..0b8561a624 --- /dev/null +++ b/Documentation/NuttXNxFlat.html @@ -0,0 +1,803 @@ + + +NXFLAT + + + +

    + + + + +
    +

    NXFLAT

    +

    Last Updated: September 1, 2012

    +
    +

    + + + + +
    +

    Table of Contents

    +
    + +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + 1.0 Overview +

    + 1.1 Functionality +

    + 1.2 Background +

    + 1.3 Limitations +

    + 1.4 Supported Processors +

    + 1.5 Development Status +
    + 2.0 NXFLAT Toolchain +

    + 1.2 Building the NXFLAT Toolchain +

    + 1.2 mknxflat +

    + 1.3 ldnxflat +

    + 1.4 mksymtab +

    + 1.5 Making an NXFLAT module +
    + 3.0. Binary Loader APIs +
    + Appendix A. No GOT Operation +
    + Appendix B. PIC Text Workaround +
    +
    + + + + + +
    +

    1.0 Overview

    +
    + +

    1.1 Functionality

    + +

    + NXFLAT is a customized and simplified version of binary format implemented a few years ago called + XFLAT + With the NXFLAT binary format you will be able to do the following: +

    + +

    + This allows you to extend the NuttX base code after it has been written into FLASH. + One motivation for implementing NXFLAT is support clean CGI under an HTTPD server. +

    +

    + This feature is especially attractive when combined with the NuttX ROMFS support: + ROMFS allows you to execute programs in place (XIP) in flash without copying anything + other than the .data section to RAM. + In fact, the initial NXFLAT release only worked on ROMFS. + Later extensions also support execution NXFLAT binaries from an SRAM copy as well. +

    +

    + This NuttX feature includes: +

    + + +

    1.2 Background

    + +

    + NXFLAT is derived from XFLAT. + XFLAT is a toolchain add that provides full shared library and XIP executable + support for processors that have no Memory Management Unit (MMU1). + NXFLAT is greatly simplified for the deeply embedded environment targeted by Nuttx: +

    + +

    + Rather, the NXFLAT module only imports symbol values. + In the NXFLAT model, the (PIC2) NXFLAT module resides in a FLASH file system and + when it is loaded at run time, it is dynamically linked only to the (non-PIC) base NuttX + code: + The base NuttX exports a symbol table; the NXFLAT module imports those symbol value + to dynamically bind the module to the base code. +

    + + + +

    1.3 Limitations

    + + + + + +

    1.4 Supported Processors

    + +

    + As mentioned above, the NXFLAT toolchain is only available for ARM and + Cortex-M3 (thumb2) targets. + Furthermore, NXFLAT has only been tested on the Eagle-100 LMS6918 Cortex-M3 board. +

    + +

    1.5 Development Status

    + +

    + The initial release of NXFLAT was made in NuttX version 0.4.9. + Testing is limited to the tests found under apps/examples/nxflat in the source tree. + Some known problems exist + (see the TODO list). + As such, NXFLAT is currently in an early alpha phase. +

    + + + + + +
    +

    2.0 NXFLAT Toolchain

    +
    + +

    1.2 Building the NXFLAT Toolchain

    + +

    + In order to use NXFLAT, you must use special NXFLAT tools to create the binary module in FLASH. + To do this, you will need to download the buildroot package and build it on your Linux or Cygwin machine. + The buildroot can be downloaded from + Bitbucket.org. + You will need version 0.1.7 or later. +

    +

    + Here are some general build instructions: +

    + + +

    1.2 mknxflat

    + +

    + mknxflat is used to build a thunk file. + See below for usage. + +

    + +

    1.3 ldnxflat

    + +

    + ldnxflat is use to link your object files along with the thunk file + generated by mknxflat to produce the NXFLAT binary module. + See below for usage. +

    + + + +

    1.4 mksymtab

    + +

    + There is a small helper program available in nuttx/tools call mksymtab. + mksymtab can be sued to generate symbol tables for the NuttX base code that would be usable by the typical NXFLAT application. + mksymtab builds symbol tables from common-separated value (CSV) files. + In particular, the CSV files: +

    +
      +
    1. + nuttx/syscall/syscall.csv that describes the NuttX RTOS interface, and +
    2. +
    3. + nuttx/libc/libc.csv that describes the NuttX C library interface. +
    4. +
    5. + nuttx/libc/math.cvs that descirbes any math library. +
    6. +
    + +

    + For example, +

    + + +

    1.5 Making an NXFLAT module

    + +

    + Below is a snippet from an NXFLAT make file (simplified from NuttX + + Hello, World! example. +

    +

    + +

    Target 1. + This target links all of the module's object files together into one relocatable object. + Two relocatable objects will be generated; this is the first one (hence, the suffic .r1). + In this "Hello, World!" case, there is only a single object file, hello.o, + that is linked to produce the hello.r1 object. +

    + +

    + When the module's object files are compiled, some special compiler CFLAGS must be provided. + First, the option -fpic is required to tell the compiler to generate position independent code (other + GCC options, like -fno-jump-tables might also be desirable). + For ARM compilers, two additional compilation options are required: -msingle-pic-base + and -mpic-register=r10. +

    + +

    Target 2. + Given the hello.r1 relocatable object, this target will invoke + mknxflat + to make the thunk file, hello-thunk.S. + This thunk file contains all of the information needed to create the imported function list. +

    + +

    Target 3 + This target is similar to Target 1. + In this case, it will link together the module's object files (only hello.o here) + along with the assembled thunk file, hello-thunk.o to create the second relocatable object, + hello.r2. + The linker script, gnu-nxflat-gotoff.ld is required at this point to correctly position the sections. + This linker script produces two segments: + An I-Space (Instruction Space) segment containing mostly .text and a D-Space (Data Space) segment + containing .got, .data, and .bss sections. + The I-Space section must be origined at address 0 (so that the segment's addresses are really offsets into + the I-Space segment) + and the D-Space section must also be origined at address 0 (so that segment's addresses are really offsets into + the I-Space segment). + The option -no-check-sections is required to prevent the linker from failing because these segments overlap. +

    + +

    NOTE: + There are two linker scripts located at binfmt/libnxflat/. +

    +
      +
    1. + binfmt/libnxflat/gnu-nxflat-gotoff.ld. + Older versions of GCC (at least up to GCC 4.3.3), use GOT-relative addressing to access RO data. + In that case, read-only data (.rodata) must reside in D-Space and this linker script should be used. +
    2. +
    3. + binfmt/libnxflat/gnu-nxflat-pcrel.ld. + Newer versions of GCC (at least as of GCC 4.6.3), use PC-relative addressing to access RO data. + In that case, read-only data (.rodata) must reside in I-Space and this linker script should be used. +
    4. +
    + +

    Target 4. + Finally, this target will use the hello.r2 relocatable object to create the final, NXFLAT module + hello by executing ldnxflat. +

    + + + + + +
    +

    3.0 Binary Loader APIs

    +
    + +

    Relevant Header Files:

    + + +

    binfmt Registration + These first interfaces are used only by a binary loader module, such as NXFLAT itself. + NXFLAT (or any future binary loader) calls register_binfmt() to incorporate + itself into the system. + In this way, the binary loader logic is dynamically extensible to support any kind of loader. + Normal application code should not be concerned with these interfaces. +

    + + + +

    NXFLAT Initialization + These interfaces are specific to NXFLAT. + Normally, an application needs only call nxflat_initialize() during its initialization + to have full NXFLAT support. +

    + + + +

    Binary Loader Interfaces. + The remaining APIs are called by user applications to maintain modules in the file system. +

    + + + + + + + +
    +

    Appendix A. No GOT Operation

    +
    + +

    + When GCC generate position independent code, new code sections will appear in your programs. + One of these is the GOT (Global Offset Table) and, in ELF environments, another is the PLT (Procedure + Lookup Table. + For example, if your C code generated (ARM) assembly language like this without PIC: +

    +

    + +

    + Then when PIC is enabled (say with the -fpic compiler option), it will generate code like + this: +

    + + + +

    See reference

    + +

    + Notice that the generates an extra level of indirection through the GOT. + This indirection is not needed by NXFLAT and only adds more RAM usage and + execution time. +

    +

    + NXFLAT (like XFLAT) can work even better without + the GOT. + Patches against older version of GCC exist to eliminate the GOT indirections. + Several are available here + if you are inspired to port them to a new GCC version. +

    + + + + + + +
    +

    Appendix B. PIC Text Workaround

    +
    + +

    + There is a problem with the memory model in GCC that prevents it from + being used as you need to use it in the NXFLAT context. + The problem is that GCC PIC model assumes that the executable lies in a flat, contiguous (virtual) address space like: +

    +

    +

    + It assumes that the PIC base register (usually r10 for ARM) points to the base of .text + so that any address in .text, .got, .data, .bss + can be found with an offset from the same base address. + But that is not the memory arrangement that we need in the XIP embedded environment. + We need two memory regions, one in FLASH containing shared code and on per task in RAM containing task-specific data: +

    + + + +

    + The PIC base register needs to point to the base of the .got and only + addresses in the .got, .data, and .bss + sections can be accessed as an offset from the PIC base register. + See also this + XFLAT discussion. +

    +

    + Patches against older version of GCC exist to correct this GCC behavior. + Several are available here + if you are inspired to port them to a new GCC version. +

    + + + diff --git a/Documentation/NuttXScreenShot.jpg b/Documentation/NuttXScreenShot.jpg new file mode 100644 index 0000000000..f5a9dc1fe7 Binary files /dev/null and b/Documentation/NuttXScreenShot.jpg differ diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html new file mode 100644 index 0000000000..f5f927dea1 --- /dev/null +++ b/Documentation/NuttxPortingGuide.html @@ -0,0 +1,5910 @@ + + +NuttX Porting Guide + + + + +

    + + + + +
    +

    + NuttX RTOS Porting Guide +

    +

    Last Updated: March 28, 2016

    +
    +

    + + + + + +
    +

    Table of Contents

    +
    + + + + + + + +
    +

    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: +

    + + +

    + Configuration Files. + The NuttX configuration consists of: +

    + + +

    2.1 Documentation

    + +

    + General documentation for the NuttX OS resides in this directory. +

    + +

    2.2 nuttx/arch

    + +

    2.2.1 Subdirectory Structure

    +

    + 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: +

    + + +

    2.2.2 Summary of Files

    + + +

    2.2.3 Supported Architectures

    +

    + Architecture- 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: +

    + + +

    + 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. +

    + +

    + Other ports for the for the TI TMS320DM270 and for MIPS are in various states + of progress +

    + +

    2.3 nuttx/binfmt

    + +

    + The binfmt/ subdirectory contains logic for loading binaries in the file + system into memory in a form that can be used to execute them. +

    + +

    2.4 nuttx/audio

    + +

    + The audio/ subdirectory contains the NuttX audio sub-system. +

    + +

    2.5 nuttx/configs

    +

    + 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. +

    + +

    2.5.1 Subdirectory Structure

    +

    + The configs directory contains board specific configuration files. Each board must + provide a subdirectory <board-name> under configs/ with the following characteristics: +

    + + +

    2.5.2 Summary of Files

    +

    2.5.2.1 Board Specific Logic

    + +

    2.5.2.2 Board Specific Configuration Sub-Directories

    +

    + 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. +

    + + +

    2.5.3 Supported Boards

    +

    + All of the specific boards supported by NuttX are identified in the README.txt file. +

    +

    2.5.4 Adding a New Board Configuration

    +

    + Okay, so you have created a new board configuration directory. + Now, how do you hook this board into the configuration system so that you can select with make menuconfig? +

    +

    + You will need modify the file configs/Kconfig. + Let's look at the STM32F4-Discovery configuration in the Kconfig file and see how we would add a new board directory to the configuration. + For this configuration let's say that you new board resides in the directory configs/myboard; + It uses an MCU selected with CONFIG_ARCH_CHIP_MYMCU; and you want the board to be selected with CONFIG_ARCH_BOARD_MYBOARD. + Then here is how you can clone the STM32F4-Discovery configuration in configs/Kconfig to support your new board configuration. +

    +

    + In configs/Kconfig for the stm32f4-discovery, you will see a configuration definition like this: +

    +

    +

    + The above selects the STM32F4-Discovery board. + The select lines say that the board has both LEDs and buttons and that the board can generate interrupts from the button presses. + You can just copy the above configuration definition to a new location (notice that they the configurations are in alphabetical order). + Then you should edit the configuration to support your board. + The final configuration definition might look something like: +

    + +

    + Later in the configs/Kconfig file, you will see a long, long string configuration with lots of defaults like this: +

    + +

    + This logic will assign string value to a configuration variable called CONFIG_ARCH_BOARD that will name the directory where the board-specific files reside. + In our case, these files reside in configs/myboard and we add the following to the long list of defaults (again in alphabetical order): +

    + +

    + Now the build system knows where to find your board configuration! +

    +

    + And finally, add something like this near the bottom of configs/myboard: +

    + +

    + This includes additional, board-specific configuration variable definitions in configs/myboard/Kconfig. +

    + +

    2.6 nuttx/crypto

    + +

    + This sub-directory holds the NuttX cryptographic sub-system. +

    + +

    2.7 nuttx/drivers

    + +

    + This directory holds architecture-independent device drivers. +

    + + +

    2.8 nuttx/fs

    + +

    + This directory contains the NuttX file system. + This file system is described below. +

    + + +

    2.9 nuttx/graphics

    + +

    + This directory contains files for graphics/video support under NuttX. +

    + + +

    2.10 nuttx/include

    +

    + This directory holds NuttX header files. + Standard header files file retained in can be included in the normal fashion: +

    + +

    + Directory structure: +

    + + +

    2.11 nuttx

    + +

    + This is a (almost) empty directory that has a holding place for generated static libraries. + The NuttX build system generates a collection of such static libraries in this directory during the compile phaase. + These libraries are then in a known place for the final link phase where they are accessed to generated the final binaries. +

    + +

    2.12 nuttx/libc

    +

    + This directory holds a collection of standard libc-like functions with custom + interfaces into NuttX. +

    +

    + Normally the logic in this file builds to a single library (libc.a). + However, if NuttX is built as a separately compiled kernel (with CONFIG_BUILD_PROTECTED=y or CONFIG_BUILD_KERNEL=y), then the contents of this directory are built as two libraries: + One for use by user programs (libuc.a) and one for use only within the <kernel> space (libkc.a). +

    +

    + These user/kernel space libraries (along with the sycalls of nuttx/syscall) are needed to support the two differing protection domains. +

    +

    + Directory structure: +

    + + +

    2.13 nuttx/libxx

    +

    + This directory holds a tiny, minimal standard std C++ that can be used to + build some, simple C++ applications in NuttX. +

    + +

    2.14 nuttx/mm

    +

    + This is the NuttX memory manager. +

    + +

    2.15 nuttx/net

    +

    + This directory contains the implementation of the NuttX networking layer including internal socket APIs. +

    + +

    2.16 nuttx/sched

    +

    + The files forming core of the NuttX RTOS reside here. +

    + +

    2.17 nuttx/syscall

    +

    + If NuttX is built as a separately compiled kernel (with CONFIG_BUILD_PROTECTED=y or CONFIG_BUILD_KERNEL=y), + then the contents of this directory are built. + This directory holds a syscall interface that can be used for communication + between user-mode applications and the kernel-mode RTOS. +

    + +

    2.18 nuttx/tools

    +

    + This directory holds a collection of tools and scripts to simplify + configuring, building and maintaining NuttX. +

    + + +

    + Refer to the README file in the tools directory for more information about the individual files. + Some of these tools are discussed below as well in the discussion of configuring and building NuttX. +

    + +

    2.19 nuttx/wireless

    + +

    + This directory holds support for hardware-independent wireless support. +

    + +

    2.20 nuttx/Makefile

    +

    + 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

    +
    + +

    3.1 Configuring NuttX

    +

    + 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: +

    + + +

    + 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. + <config-dir> is the optional, specific configuration directory for the board. + And <app-dir> is the location of the optional application directory. +

    +

    + Automated Configuration. + There is a script that automates these steps. The following steps will + accomplish the same configuration: +

    + + +

    + There is an alternative Windows batch file, configure.bat, that can be used instead of configure.sh in the windows native environment like: +

    + +

    + See tools/README.txt for more information about these scripts. +

    + +

    + If your application directory is not in the standard location (../apps or ../apps-<version>), + then you should also specify the location of the application directory on the command line like: +

    + + +

    + Version Files. + The NuttX build expects to find a version file located in the top-level NuttX build directory. + That version file is called .version. + The correct version file is installed in each versioned NuttX released. + However, if you are working from an GIT snapshot, then there will be no version file. + If there is no version file, the top-level Makefile will create a dummy .version file on the first make. + This dummy version file will contain all zeroes for version information. + If that is not what you want, they you should run the version.sh script to create a better .version file. +

    + +

    + You can get help information from the version.sh script using the -h option. + For example: +

    + + +

    + As an example, the following command will generate a version file for version 6.1 using the current GIT revision number: +

    + + +

    + The .version file is also used during the build process to create a C header file at include/nuttx/version.h that contains the same version information. + That version file may be used by your C applications for, as an example, reporting version information. +

    + +

    + Additional Configuration Steps. + The remainder of configuration steps will be performed by ${TOPDIR}/Makefile + the first time the system is built as described below. +

    + +

    3.2 Building NuttX

    +

    + Building NuttX. + Once NuttX has been configured as described above, it may be built as follows: +

    + +

    + The ${TOPDIR} directory holds: +

    + +

    + That directory also holds: +

    + +

    +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: +

    + + + + + + +
    +

    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. +

    + +

    4.1 Naming and Header File Conventions

    + + + +

    4.2 APIs Exported by Architecture-Specific Logic to NuttX

    +

    4.2.1 up_initialize()

    + +

    Function 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. +

    + +

    4.2.2 up_idle()

    +

    Function 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. +

    + +

    4.2.3 up_initial_state()

    +

    Function Prototype: void up_initial_state(FAR struct tcb_s *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 initial architecture registers and/or stack so that execution + will begin at tcb->start on the next context switch. +

    +

    + This function may also need to set up processor registers so that the new thread executes + with the correct privileges. + If CONFIG_BUILD_PROTECTED or CONFIG_BUILD_KERNEL have been selected in the NuttX configuration, then special initialization may need to be performed depending on the task type specified in the TCB's flags field: + Kernel threads will require kernel-mode privileges; + User tasks and pthreads should have only user-mode privileges. + If neither CONFIG_BUILD_PROTECTED nor CONFIG_BUILD_KERNEL have been selected, then all threads should have kernel-mode privileges. +

    + +

    4.2.4 up_create_stack()

    +

    Function Prototype: STATUS up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype);

    + +

    Description. + Allocate a stack for a new thread and setup up stack-related information in the TCB. +

    +

    + The following TCB fields must be initialized: +

    + + +

    Input Parameters:

    + + +

    4.2.5 up_use_stack()

    +

    Function Prototype: + STATUS up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size); +

    + +

    Description. + Setup up stack-related information in the TCB using pre-allocated stack memory. + This function is called only from task_init() when a task or kernel thread is started (never for pthreads). +

    +

    + The following TCB fields must be initialized: +

    + + +

    Input Parameters:

    + +

    + NOTE: Unlike up_stack_create() and up_stack_release, this function does not require the task type (ttype) parameter. + The TCB flags will always be set to provide the task type to up_use_stack() if the information needs that information. +

    + + +

    4.2.6 up_stack_frame()

    +

    Function Prototype: FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size);

    + +

    + Description. + Allocate a stack frame in the TCB's stack to hold thread-specific data. + This function may be called any time after up_create_stack() or up_use_stack() have been called but before the task has been started. +

    +

    + Thread data may be kept in the stack (instead of in the TCB) if it is accessed by the user code directly. + This includes such things as argv[]. + The stack memory is guaranteed to be in the same protection domain as the thread. +

    +

    + The following TCB fields will be re-initialized: +

    + +

    Input Parameters:

    + +

    + Returned Value: + A pointer to bottom of the allocated stack frame. + NULL will be returned on any failures. + The alignment of the returned value is the same as the alignment of the stack itself +

    + +

    4.2.7 up_release_stack()

    +

    Function Prototype: void up_release_stack(FAR struct tcb_s *dtcb);

    + +

    Description. + A task has been stopped. + Free all stack related resources retained int the defunct TCB. +

    +

    Input Parameters:

    + + +

    4.2.8 up_unblock_task()

    +

    Function Prototype: void up_unblock_task(FAR struct tcb_s *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. +

    + +

    Input Parameters: +

    + +

    4.2.9 up_block_task()

    +

    Function Prototype: void up_block_task(FAR struct tcb_s *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. + +

    Input Parameters:

    + + +

    4.2.10 up_release_pending()

    +

    Function 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. +

    + +

    4.2.11 up_reprioritize_rtr()

    +

    Function Prototype: void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t 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: +

    +
      +
    1. + The priority of the currently running task drops and the next + task in the ready to run list has priority. +
    2. +
    3. + An idle, ready to run task's priority has been raised above the + the priority of the current, running task and it now has the + priority. +
    4. +
    +

    + This function is called only from the NuttX scheduling + logic. Interrupts will always be disabled when this + function is called. +

    + +

    Input Parameters:

    + + +

    4.2.12 _exit()

    +

    Function 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 disable interrupts + before performing scheduling operations. +

    + +

    4.2.13 up_assert()

    +

    Function Prototype:
    + void up_assert(FAR const uint8_t *filename, int linenum); +

    + +

    Description. + Assertions may be handled in an architecture-specific way. +

    + +

    4.2.14 up_schedule_sigaction()

    +

    Function Prototype: + void up_schedule_sigaction(FAR struct tcb_s *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 'sigdeliver' 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: +

    +
      +
    1. + This function may be called from an interrupt handler + During interrupt processing, all xcptcontext structures + should be valid for all tasks. That structure should + be modified to invoke sigdeliver() either on return + from (this) interrupt or on some subsequent context + switch to the recipient task. +
    2. +
    3. + If not in an interrupt handler and the tcb is NOT + the currently executing task, then again just modify + the saved xcptcontext structure for the recipient + task so it will invoke sigdeliver when that task is + later resumed. +
    4. +
    5. + If not in an interrupt handler and the tcb IS the + currently executing task -- just call the signal + handler now. +
    6. +
    +

    + This API is NOT required if CONFIG_DISABLE_SIGNALS + is defined. +

    + +

    4.2.15 up_allocate_heap()

    +

    Function Prototype: void up_allocate_heap(FAR void **heap_start, size_t *heap_size);

    + +

    Description. + This function will be called to dynamically set aside the heap region. +

    +

    + For the kernel build (CONFIG_BUILD_PROTECTED=y or CONFIG_BUILD_KERNEL=y) with both kernel- and user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function provides the size of the unprotected, user-space heap. + If a protected kernel-space heap is provided, the kernel heap must be allocated (and protected) by an analogous up_allocate_kheap(). +

    + +

    4.2.16 up_interrupt_context()

    +

    Function Prototype: bool up_interrupt_context(void)

    + +

    Description. + Return true if we are currently executing in the interrupt handler context. +

    + +

    4.2.17 up_disable_irq()

    +

    Function Prototype:

    + + +

    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 + (up_irq_save() 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. +

    + +

    4.2.18 up_enable_irq()

    +

    Function Prototype:

    + + +

    Description. + This function implements disabling of the device specified by 'irq' + at the interrupt controller level if supported by the architecture + (up_irq_restore() 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. +

    + +

    4.2.19 up_prioritize_irq()

    +

    Function Prototype:

    + +

    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. +

    + +

    4.2.20 up_putc()

    + +

    Function Prototype: int up_putc(int ch);

    +

    Description. + This is a debug interface exported by the architecture-specific logic. + Output one character on the console +

    + +

    4.3 System Time and Clock

    + +

    4.3.1 Basic System Timer

    + +

    System Timer + In most implementations, system time is provided by a timer interrupt. + That timer interrupt runs at rate determined by CONFIG_USEC_PER_TICK (default 10000 microseconds or 100Hz. If CONFIG_SCHED_TICKLESS is selected, the default is 100 microseconds). + The timer generates an interrupt each CONFIG_USEC_PER_TICK microseconds and increments a counter called g_system_timer. + g_system_timer then provides a time-base for calculating up-time and elapsed time intervals in units of CONFIG_USEC_PER_TICK. + The range of g_system_timer is, by default, 32-bits. + However, if the MCU supports type long long and CONFIG_SYSTEM_TIME16 is selected, + a 64-bit system timer will be supported instead. +

    +

    System Timer Accuracy + On many system, the exact timer interval specified by CONFIG_USEC_PER_TICK cannot be achieved due to limitations in frequencies or in dividers. + As a result, the time interval specified by CONFIG_USEC_PER_TICK may only be approximate and there may be small errors in the apparent up-time time. + These small errors, however, will accumulate over time and after a long period of time may have an unacceptably large error in the apparent up-time of the MCU. +

    + If the timer tick period generated by the hardware is not exactly CONFIG_USEC_PER_TICK and if there you require accurate up-time for the MCU, then there are measures that you can take: +

    + + +

    Delta-Sigma Modulation Example. + Consider this case: The system timer is a count-up timer driven at 32.768KHz. + There are dividers that can be used, but a divider of one yields the highest accuracy. + This counter counts up until the count equals a match value, then a timer interrupt is generated. + The desire frequency is 100Hz (CONFIG_USEC_PER_TICK is 10000). +

    +

    + This exact frequency of 100Hz cannot be obtained in this case. + In order to obtain that exact frequency a match value of 327.68 would have to be provided. + The closest integer value is 328 but the ideal match value is between 327 and 328. + The closest value, 328, would yield an actual timer frequency of 99.9Hz! + That will may cause significant timing errors in certain usages. +

    +

    + Use of Delta-Sigma Modulation can eliminate this error in the long run. + Consider this example implementation: +

    +
      +
    1. + Initially an accumulator is zero an the match value is programmed to 328: +
        +accumulator = 0;
        +match = 328;
        +
      +
    2. +
    3. + On each timer interrupt, accumulator is updated with difference that, in this reflects, 100* the error in interval that just passed. + So on the first timer interrupt, the accumulator would be updated like: +
        +if (match == 328)
        +  {
        +    accumulator += 32; // 100*(328 - 327.68)
        +  }
        +else
        +  {
        +    accumulator -= 68; // (100*(327 - 327.68)
        +  }
        +
      +
    4. +
    5. + And on that same timer interrupt a new match value would be programmed: +
        +if (accumulator < 0)
        +  {
        +    match = 328;
        +  }
        +else
        +  {
        +    match = 327;
        +  }
        +
      +
    +

    + In this way, the timer interval is controlled from interrupt-to-interrupt to produce an average frequency of exactly 100Hz. +

    + +

    4.3.2 Hardware

    +

    + To enable hardware module use the following configuration options: +

    +

    +

    + which requires the following base functions to read and set time: +

    + + +

    4.3.3 System Tick and Time

    +

    + The system tick is represented by:: +

    + +

    + Running at rate of system base timer, used for time-slicing, and so forth. +

    +

    + If hardware RTC is present (CONFIG_RTC) and and high-resolution timing + is enabled (CONFIG_RTC_HIRES), then after successful + initialization variables are overridden by calls to up_rtc_gettime() which is + running continuously even in power-down modes. +

    +

    + In the case of CONFIG_RTC_HIRES is set the g_system_timer + keeps counting at rate of a system timer, which however, is disabled in power-down mode. + By comparing this time and RTC (actual time) one may determine the actual system active time. + To retrieve that variable use: +

    + +

    4.3.4 Tickless OS

    +

    4.3.4.1 Tickless Overview

    + +

    + Default System Timer. + By default, a NuttX configuration uses a periodic timer interrupt that drives all system timing. The timer is provided by architecture-specific code that calls into NuttX at a rate controlled by CONFIG_USEC_PER_TICK. The default value of CONFIG_USEC_PER_TICK is 10000 microseconds which corresponds to a timer interrupt rate of 100 Hz. +

    +

    + On each timer interrupt, NuttX does these things: +

    +

    +

    + What is wrong with this default system timer? Nothing really. It is reliable and uses only a small fraction of the CPU band width. But we can do better. Some limitations of default system timer are, in increasing order of importance: +

    + +

    + Tickless OS. + The so-called Tickless OS provides one solution to issue. The basic concept here is that the periodic, timer interrupt is eliminated and replaced with a one-shot, interval timer. It becomes event driven instead of polled: The default system timer is a polled design. On each interrupt, the NuttX logic checks if it needs to do anything and, if so, it does it. +

    +

    + Using an interval timer, one can anticipate when the next interesting OS event will occur, program the interval time and wait for it to fire. When the interval time fires, then the scheduled activity is performed. +

    + +

    4.3.4.2 Tickless Platform Support

    + +In order to use the Tickless OS, one must provide special support from the platform-specific code. Just as with the default system timer, the platform-specific code must provide the timer resources to support the OS behavior. + +Currently these timer resources are only provided on a few platforms. An example implementation is for the simulation is at nuttx/arch/sim/src/up_tickless.c. There is another example for the Atmel SAMA5 at nuttx/arch/arm/src/sama5/sam_tickless.c. These paragraphs will explain how to provide the Tickless OS support to any platform. + +

    4.3.4.3 Tickless Configuration Options

    + + +

    4.3.4.4 Tickless Imported Intefaces

    +

    + The interfaces that must be provided by the platform specified code are defined in include/nuttx/arch.h, listed below, and summarized in the following paragraphs: +

    + +

    + The tickless option can be supported either via a simple interval timer (plus elapsed time) or via an alarm. The interval timer allows programming events to occur after an interval. With the alarm, you can set a time in* the future and get an event when that alarm goes off. +

    +

    + If CONFIG_SCHED_TICKLESS_ALARM is defined, then the platform code must provide the following: +

    +

    +

    + If CONFIG_SCHED_TICKLESS_ALARM is notdefined, then the platform code must provide the following verify similar functions: +

    +

    +

    + Note that a platform-specific implementation would probably require two hardware timers: (1) A interval timer to satisfy the requirements of up_timer_start() and up_timer_cancel(), and a (2) a counter to handle the requirement of up_timer_gettime(). Ideally, both timers would run at the rate determined by CONFIG_USEC_PER_TICK (and certainly never slower than that rate). +

    +

    + Since timers are a limited resource, the use of two timers could be an issue on some systems. + The job could be done with a single timer if, for example, the single timer were kept in a free-running at all times. Some timer/counters have the capability to generate a compare interrupt when the timer matches a comparison value but also to continue counting without stopping. If your hardware supports such counters, one might used the CONFIG_SCHED_TICKLESS_ALARM option and be able to simply set the comparison count at the value of the free running timer PLUS the desired delay. Then you could have both with a single timer: An alarm and a free-running counter with the same timer! +

    +

    + In addition to these imported interfaces, the RTOS will export the following interfaces for use by the platform-specific interval timer implementation: +

    + + +
    4.3.4.4.1 up_timer_initialize()
    +

    Function Prototype:

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + +

    Assumptions:

    + + +
    4.3.4.4.2 up_timer_gettime()
    +

    Function Prototype:

    +

    +

    Description:

    + Return the elapsed time since power-up (or, more correctly, since up_timer_initialize() was called). This function is functionally equivalent to clock_gettime() for the clock ID CLOCK_MONOTONIC. This function provides the basis for reporting the current time and also is used to eliminate error build-up from small errors in interval time calculations. + +

    Input Parameters:

    + +

    Returned Value:

    + +

    Assumptions:

    + + +
    4.3.4.4.3 up_alarm_cancel()
    +

    Function Prototype:

    +

    +

    Description:

    + Cancel the alarm and return the time of cancellation of the alarm. These two steps need to be as nearly atomic as possible. sched_timer_expiration() will not be called unless the alarm is restarted with up_alarm_start(). If, as a race condition, the alarm has already expired when this function is called, then time returned is the current time. + +

    Input Parameters:

    + +

    Returned Value:

    + +

    Assumptions:

    + + +
    4.3.4.4.4 up_alarm_start()
    +

    Function Prototype:

    +

    +

    Description:

    + Start the alarm. sched_timer_expiration() will be called when the alarm occurs (unless up_alaram_cancel is called to stop it). + +

    Input Parameters:

    + +

    Returned Value:

    + +

    Assumptions:

    + + +
    4.3.4.4.5 up_timer_cancel()
    +

    Function Prototype:

    +

    +

    Description:

    + Cancel the interval timer and return the time remaining on the timer. These two steps need to be as nearly atomic as possible. sched_timer_expiration() will not be called unless the timer is restarted with up_timer_start(). If, as a race condition, the timer has already expired when this function is called, then that pending interrupt must be cleared so that sched_timer_expiration() is not called spuriously and the remaining time of zero should be returned. + +

    Input Parameters:

    + +

    Returned Value:

    + +

    Assumptions:

    + + +
    4.3.4.4.6 up_timer_start()
    +

    Function Prototype:

    +

    +

    Description:

    + Start the interval timer. sched_timer_expiration() will be called at the completion of the timeout (unless up_timer_cancel() is called to stop the timing). + +

    Input Parameters:

    + +

    Returned Value:

    + +

    Assumptions:

    + + +

    4.3.5 Watchdog Timer Interfaces

    +

    + NuttX provides a general watchdog timer facility. + This facility allows the NuttX user to specify a watchdog timer function + that will run after a specified delay. + The watchdog timer function will run in the context of the timer interrupt handler. + Because of this, a limited number of NuttX interfaces are available to he watchdog timer function. + However, the watchdog timer function may use mq_send(), sigqueue(), + or kill() to communicate with NuttX tasks. +

    + + +

    4.3.5.1 wd_create/wd_static

    + +

    +Function Prototype: +

    +    #include <nuttx/wdog.h>
    +    WDOG_ID wd_create(void);
    +    void wd_static(FAR struct wdog_s *wdog);
    +
    + +

    +Description: The wd_create() function will create a timer by allocating the appropriate resources for the watchdog. The wd_create() function returns a pointer to a fully initialized, dynamically allocated struct wdog_s instance (which is typedef'ed as WDOG_ID); +

    +

    +wd_static() performs the equivalent initialization of a statically allocated struct wdog_s instance. No allocation is performed in this case. The initializer definition, WDOG_INITIALIZER is also available for initialization of static instances of struct wdog_s. NOTE: wd_static() is also implemented as a macro definition. +

    +

    +Input Parameters: None. +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the following comparable interface: +

    +    WDOG_ID wdCreate (void);
    +
    + +

    +Differences from the VxWorks interface include: +

    + +

    4.3.5.2 wd_delete

    + +

    +Function Prototype: +

    +    #include <nuttx/wdog.h>
    +    int wd_delete(WDOG_ID wdog);
    +
    + +

    +Description: The wd_delete function will deallocate a watchdog timer previously allocated via wd_create(). The watchdog timer will be removed from the timer queue if has been started. +

    +

    +This function need not be called for statically allocated timers (but it is not harmful to do so). +

    +Input Parameters: + + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: It is the responsibility of the +caller to assure that the watchdog is inactive before deleting +it. +

    +POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the following comparable interface: +

    +    STATUS wdDelete (WDOG_ID wdog);
    +
    + +

    +Differences from the VxWorks interface include: +

    + +

    4.3.5.3 wd_start

    + +

    +Function Prototype: +

    +    #include <nuttx/wdog.h>
    +    int wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry,
    +                 int argc, ....);
    +
    + +

    +Description: This function adds a watchdog to the timer +queue. The specified watchdog function will be called from the +interrupt level after the specified number of ticks has elapsed. +Watchdog timers may be started from the interrupt level. +

    +Watchdog times execute in the context of the timer interrupt handler. +

    +Watchdog timers execute only once. +

    +To replace either the timeout delay or the function to be executed, +call wd_start again with the same wdog; only the most recent +wd_start() on a given watchdog ID has any effect. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: The watchdog routine runs in the +context of the timer interrupt handler and is subject to all ISR +restrictions. +

    +POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the following comparable interface: +

    +    STATUS wdStart (WDOG_ID wdog, int delay, FUNCPTR wdentry, int parameter);
    +
    + +

    +Differences from the VxWorks interface include: +

    + +

    4.3.5.4 wd_cancel

    +

    +Function Prototype: +

    +    #include <nuttx/wdog.h>
    +    int wd_cancel(WDOG_ID wdog);
    +
    + +

    +Description: This function cancels a currently running +watchdog timer. Watchdog timers may be canceled from the interrupt +level. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    +POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the following comparable interface: +

    +    STATUS wdCancel (WDOG_ID wdog);
    +
    + +

    4.3.5.5 wd_gettime

    +

    + Function Prototype: +

    +
    +    #include <nuttx/wdog.h>
    +    Sint wd_gettime(WDOG_ID wdog);
    +
    +

    + Description: + This function returns the time remaining before the specified watchdog expires. +

    +

    + Input Parameters: +

    +

    +

    + Returned Value: + The time in system ticks remaining until the watchdog time expires. Zero + means either that wdog is not valid or that the wdog has already expired. +

    + +

    4.3.5.6 Watchdog Timer Callback

    +

    + When a watchdog expires, the callback function with this type is called: +

    +
    +    typedef void (*wdentry_t)(int argc, ...);
    +
    +

    + Where argc is the number of wdparm_t type arguments that follow. +

    +

    + The arguments are passed as scalar wdparm_t values. For systems where the sizeof(pointer) < sizeof(uint32_t), the following union defines the alignment of the pointer within the uint32_t. For example, the SDCC MCS51 general pointer is 24-bits, but uint32_t is 32-bits (of course). +

    + We always have sizeof(pointer) <= sizeof(uintptr_t) by definition. +

    + + +

    4.4 Work Queues

    +

    Work Queues. + NuttX provides work queues. Work queues are threads that service a queue of work items to be performed. They are useful for off-loading work to a different threading context, for delayed processing, or for serializing activities. +

    + +

    4.4.1 Classes of Work Queues

    + +

    Classes of Work Queues. + There are three different classes of work queues, each with different properties and intended usage. These class of work queues along with the the common work queue interface are described in the following paragraphs. +

    + +

    4.4.1.1 High Priority Kernel Work queue

    + +

    High Priority Kernel Work queue. + The dedicated high-priority work queue is intended to handle delayed processing from interrupt handlers. This work queue is required for some drivers but, if there are no complaints, can be safely disabled. The high priority worker thread also performs garbage collection -- completing any delayed memory deallocations from interrupt handlers. If the high-priority worker thread is disabled, then that clean up will be performed either by (1) the low-priority worker thread, if enabled, and if not (2) the IDLE thread instead (which runs at the lowest of priority and may not be appropriate if memory reclamation is of high priority) +

    +

    Device Driver Bottom Half. + The higher priority worker thread is intended to serve as the bottom half for device drivers. As a consequence it must run at a very high, fixed priority rivalling the priority of the interrupt handler itself. Typically, the high priority work queue should be the highest priority thread in your system (the default priority is 224). +

    +

    Compared to the Low Priority Kernel Work Queue. + For less critical, lower priority, application oriented worker thread support, consider enabling the lower priority work queue. The lower priority work queue runs at a lower priority, of course, but has the added advantage that it supports priority inheritance (if <config> CONFIG_PRIORITY_INHERITANCE is also selected): The priority of the lower priority worker thread can then be adjusted to match the highest priority client. +

    +

    + Configuration Options. +

    + +

    + Common Configuration Options. + These options apply to all work queues: +

    + + +

    4.4.1.2 Low Priority Kernel Work Queue

    +

    + Low Priority Kernel Work Queue. + This lower priority work queue is better suited for more extended, application oriented processing such as file system clean-up, memory garbage collection and asynchronous I/O operations. +

    +

    + Compared to the High Priority Work Queue. + The lower priority work queue runs at a lower priority than the high priority work queue, of course, and so is inapproperiate to serve as a driver bottom half. The lower priority work queue has the other advantages, however, that make it better suited for some tasks: +

    + +

    + Configuration Options. +

    + + +

    4.4.1.3 User-Mode Work Queue

    +

    + Work Queue Accessibility. + The high- and low-priority worker threads are kernel-mode threads. In the normal, flat NuttX build, these work queues are are useful to application code and may be shared. However, in the NuttX protected and kernel build modes, kernel mode code is isolated and cannot be accessed from user-mode code. +

    +

    + User-Mode Work Queue. + if either CONFIG_BUILD_PROTECTED or CONFIG_BUILD_KERNEL are selected, then the option to enable a special user-mode work queue is enable. The interface to the user-mode work queue is identical to the interface to the kernel-mode work queues and the user-mode work queue is functionally equivalent to the high priority work queue. It differs in that its implementation does not depend on internal, kernel-space facilities. +

    +

    + Configuration Options. +

    + + +

    4.4.2 Common Work Queue Interfaces

    +

    4.4.2.1 Work Queue IDs

    + +

    + Work queue IDs. + All work queues use the identical interface functions (at least identical in terms of the function signature). The first parameter passed to the work queue interface function identifies the work queue: +

    +

    + Kernel-Mode Work Queue IDs: +

    +

    +

    + User-Mode Work Queue IDs: +

    +

    + +

    4.4.2.2 Work Queue Interface Types

    + + + +

    4.4.2.3 Work Queue Interfaces

    +
    4.4.2.3.1 work_queue()
    +

    + Function Prototype: +

    +

    +

    + Description. + Queue work to be performed at a later time. All queued work will be performed on the worker thread of execution (not the caller's). +

    +

    + The work structure is allocated by caller, but completely managed by the work queue logic. The caller should never modify the contents of the work queue structure; the caller should not call work_queue() again until either (1) the previous work has been performed and removed from the queue, or (2) work_cancel() has been called to cancel the work and remove it from the work queue. +

    +

    + Input Parameters: +

    + +

    + Returned Value: +

    + + +
    4.4.2.3.2 work_cancel()
    +

    + Function Prototype: +#include <nuttx/wqueue.h> +int work_cancel(int qid, FAR struct work_s *work); +

    +

    +

    + Description. + Cancel previously queued work. This removes work from the work queue. After work has been cancelled, it may be re-queue by calling work_queue() again. +

    +

    + Input Parameters: +

    + +

    + Returned Value: +

    + + +
    4.4.2.3.3 work_signal()
    +

    + Function Prototype: +#include <nuttx/wqueue.h> +int work_signal(int qid); +

    +

    +

    + Description. + Signal the worker thread to process the work queue now. This function is used internally by the work logic but could also be used by the user to force an immediate re-assessment of pending work. +

    +

    + Input Parameters: +

    + +

    + Returned Value: +

    + + +
    4.4.2.3.4 work_available()
    +

    + Function Prototype: +

    +

    +

    + Description. +

    +

    + Input Parameters: + Check if the work structure is available. +

    + +

    + Returned Value: +

    + + +
    4.4.2.3.5 work_usrstart()
    +

    + Function Prototype: +

    +

    +

    + Description. + The function is only available as a user interface in the kernel-mode build. In the flat build, there is no user-mode work queue; in the protected mode, the user-mode work queue will automatically be started by the OS start-up code. But in the kernel mode, each user process will be required to start is own, private instance of the user-mode work thread using this interface. +

    +

    + Input Parameters: None +

    +

    + Returned Value: +

    + + +
    4.4.2.3.6 lpwork_boostpriority()
    +

    + Function Prototype: +

    +

    +

    + Description. + Called by the work queue client to assure that the priority of the low-priority worker thread is at least at the requested level, reqprio. This function would normally be called just before calling work_queue(). +

    +

    + Input Parameters: +

    + +

    + Returned Value: None +

    + +
    4.4.2.3.7 lpwork_restorepriority()
    +

    + Function Prototype: +

    +

    +

    + Description. + This function is called to restore the priority after it was previously boosted. This is often done by client logic on the worker thread when the scheduled work completes. It will check if we need to drop the priority of the worker thread. +

    +

    + Input Parameters: +

    + +

    + Returned Value: None +

    + +

    4.5 Address Environments

    +

    + CPUs that support memory management units (MMUs) may provide address environments within which tasks and their child threads execute. + The configuration indicates the CPUs ability to support address environments by setting the configuration variable CONFIG_ARCH_HAVE_ADDRENV=y. + That will enable the selection of the actual address evironment support which is indicated by the selection of the configuration variable CONFIG_ARCH_ADDRENV=y. + These address environments are created only when tasks are created via exec() or exec_module() (see include/nuttx/binfmt/binfmt.h). +

    +

    + When CONFIG_ARCH_ADDRENV=y is set in the board configuration, the CPU-specific logic must provide a set of interfaces as defined in the header file include/nuttx/arch.h. + These interfaces are listed below and described in detail in the following paragraphs. +

    +

    + The CPU-specific logic must provide two categories in interfaces: +

    +
      +
    1. +

      + Binary Loader Support. + These are low-level interfaces used in binfmt/ to instantiate tasks with address environments. + These interfaces all operate on type group_addrenv_t which is an abstract representation of a task group's address environment and the type must be defined inarch/arch.h if CONFIG_ARCH_ADDRENV is defined. These low-level interfaces include: +

      + +
    2. +
    3. +

      + Tasking Support. + Other interfaces must be provided to support higher-level interfaces used by the NuttX tasking logic. + These interfaces are used by the functions in sched/ and all operate on the task group which as been assigned an address environment by up_addrenv_clone(). +

      +
        +
      • + 4.5.9 up_addrenv_attach(): + Clone the group address environment assigned to a new thread. + This operation is done when a pthread is created that share's the same address environment. +
      • +
      • + 4.5.10 up_addrenv_detach(): + Release the thread's reference to a group address environment when a task/thread exits. +
      • +
      +
    4. +
    5. +

      + Dynamic Stack Support. + CONFIG_ARCH_STACK_DYNAMIC=y indicates that the user process stack resides in its own address space. + This option is also required if CONFIG_BUILD_KERNEL and CONFIG_LIBC_EXECFUNCS are selected. + Why? + Because the caller's stack must be preserved in its own address space when we instantiate the environment of the new process in order to initialize it. +

      +

      + NOTE: The naming of the CONFIG_ARCH_STACK_DYNAMIC selection implies that dynamic stack allocation is supported. + Certainly this option must be set if dynamic stack allocation is supported by a platform. + But the more general meaning of this configuration environment is simply that the stack has its own address space. +

      +

      + If CONFIG_ARCH_STACK_DYNAMIC=y is selected then the platform specific code must export these additional interfaces: +

      + +
    6. +
    7. +

      + If CONFIG_ARCH_KERNEL_STACK is selected, then each user process will have two stacks: (1) a large (and possibly dynamic) user stack and (2) a smaller kernel stack. However, this option is required if both CONFIG_BUILD_KERNEL and CONFIG_LIBC_EXECFUNCS are selected. Why? Because when we instantiate and initialize the address environment of the new user process, we will temporarily lose the address environment of the old user process, including its stack contents. The kernel C logic will crash immediately with no valid stack in place. +

      +

      + If CONFIG_ARCH_KERNEL_STACK=y is selected then the platform specific code must export these additional interfaces: +

      + +
    8. +
    + +

    4.5.1 up_addrenv_create()

    +

    Function Prototype:

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.2 up_addrenv_destroy()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.3 up_addrenv_vtext()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.4 up_addrenv_vdata()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.5 up_addrenv_heapsize()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.6 up_addrenv_select()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.7 up_addrenv_restore()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.8 up_addrenv_clone()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.9 up_addrenv_attach()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.10 up_addrenv_detach()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.11 up_addrenv_ustackalloc()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.12 up_addrenv_ustackfree()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.13 up_addrenv_vustack()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.14 up_addrenv_ustackselect()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.15 up_addrenv_kstackalloc()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.5.16 up_addrenv_kstackfree()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.6 boardctl() Application Interface

    + +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.7 Symmetric Multiprocssing (SMP) Application Interface

    +

    +According to Wikipedia: "Symmetric multiprocessing (SMP) involves a symmetric multiprocessor system hardware and software architecture where two or more identical processors connect to a single, shared main memory, have full access to all I/O devices, and are controlled by a single operating system instance that treats all processors equally, reserving none for special purposes. Most multiprocessor systems today use an SMP architecture. In the case of multi-core processors, the SMP architecture applies to the cores, treating them as separate processors. +

    +

    +"SMP systems are tightly coupled multiprocessor systems with a pool of homogeneous processors running independently, each processor executing different programs and working on different data and with capability of sharing common resources (memory, I/O device, interrupt system and so on) and connected using a system bus or a crossbar." +

    +

    +For a technical description of the NuttX implementation of SMP, see the NuttX SMP Wiki Page. +

    + + None + + +

    4.7.1 up_testset()

    +

    Function Prototype:

    +

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.7.2 up_cpu_index()

    +

    Function Prototype:

    +

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.7.3 up_cpu_start()

    +

    Function Prototype:

    +

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.7.4 up_cpu_initialize()

    +

    Function Prototype:

    +

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.7.5 up_cpu_pause()

    +

    Function Prototype:

    +

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.7.6 up_cpu_resume()

    +

    Function Prototype:

    +

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.8 APIs Exported by NuttX to Architecture-Specific Logic

    +

    + These are standard interfaces that are exported by the OS + for use by the architecture specific logic. +

    + +

    4.8.1 os_start()

    +

    + To be provided +

    + +

    4.8.2 OS List Management APIs

    +

    + To be provided +

    + +

    4.8.3 sched_process_timer()

    +

    Function Prototype:

    + + +

    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. +

    + +

    4.8.4 sched_timer_expiration()

    +

    Function Prototype:

    +

    +

    Description:

    + Description: if CONFIG_SCHED_TICKLESS is defined, then this function is provided by the RTOS base code and called from platform-specific code when the interval timer used to implemented the tick-less OS expires. + +

    Input Parameters:

    + +

    Returned Value:

    + +

    Assumptions:

    + + +

    4.8.5 sched_alaram_expiration()

    +

    Function Prototype:

    +

    +

    Description:

    + Description: if CONFIG_SCHED_TICKLESS is defined, then this function is provided by the RTOS base code and called from platform-specific code when the interval timer used to implemented the tick-less OS expires. + +

    Input Parameters:

    + +

    Returned Value:

    + +

    Assumptions:

    + + +

    4.8.6 irq_dispatch()

    +

    Function Prototype: void irq_dispatch(int irq, FAR void *context);

    + +

    Description. + This function must be called from the architecture- + specific logic in order to display an interrupt to + the appropriate, registered handling logic. +

    + +

    4.9 Shared Memory

    +

    + Shared memory interfaces are only available with the NuttX kernel build (CONFIG_BUILD_KERNEL=y). + These interfaces support user memory regions that can be shared between multiple user processes. + The user interfaces are provided in the standard header file include/sys/shm.h>. + All logic to support shared memory is implemented within the NuttX kernel with the exception of two low-level functions that are require to configure the platform-specific MMU resources. + Those interfaces are described below: +

    + +

    4.9.1 up_shmat()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.9.2 up_shmdt()

    +

    Function Prototype:

    +

    +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + +

    4.10 On-Demand Paging

    +

    + The NuttX On-Demand Paging feature permits embedded MCUs with some limited RAM space to execute large programs from some non-random access media. + If the platform meets certain requirements, then NuttX can provide on-demand paging: + It can copy .text from the large program in non-volatile media into RAM as needed to execute a huge program from the small RAM. + Design and porting issues for this feature are discussed in a separate document. + Please see the NuttX Demand Paging design document for further information. +

    + +

    4.11 LED Support

    + +

    + A board architecture may or may not have LEDs. + If the board does have LEDs, then most architectures provide similar LED support that is enabled when CONFIG_ARCH_LEDS + is selected in the NuttX configuration file. + This LED support is part of architecture-specific logic and is not managed by the core NuttX logic. + However, the support provided by each architecture is sufficiently similar that it can be documented here. +

    + +

    4.11.1 Header Files

    + +

    + LED-related definitions are provided in two header files: +

    +

    + +

    4.11.2 LED Definitions

    + +

    + The implementation of LED support is very specific to a board architecture. + Some boards have several LEDS, others have only one or two. + Some have none. + Others LED matrices and show alphanumeric data, etc. + The NuttX logic does not refer to specific LEDS, rather, it refers to an event to be shown on the LEDS + in whatever manner is appropriate for the board; + the way that this event is presented depends upon the hardware available on the board. +

    +

    + The model used by NuttX is that the board can show 8 events defined as follows in <board-name>/include/board.h: +

    + +

    + The specific value assigned to each pre-processor variable can be whatever makes the implementation easiest for the board logic. + The meaning associated with each definition is as follows: +

    + + +

    4.11.3 Common LED interfaces

    + +

    + The include/nuttx/board.h has declarations like: +

    + +

    + Where: +

    +

    + + + + + +
    +

    5.0 NuttX File System

    +
    + +

    Overview. + NuttX includes an optional, scalable file system. + This file-system may be omitted altogether; NuttX does not depend on the presence + of any file system. +

    + +

    Pseudo Root File System. + Or, a simple in-memory, pseudo 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 pseudo file system (in the + same sense that the Linux /proc file system is also + referred to as a pseudo file system). +

    + +

    + Any user supplied data or logic can be accessed via the pseudo-file system. + Built in support is provided for character and block drivers in the + /dev pseudo 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 pseudo file system + and to a file system. + At present, NuttX supports the standard VFAT and ROMFS file systems, + a special, wear-leveling NuttX FLASH File System (NXFFS), + as well as a Network File System client (NFS version 3, UDP). +

    + +

    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 pseudo file system and true file systems may be + mounted in the pseudo file system. + In the typical Linux installation by comparison, the Linux root file system + is a true file system and pseudo 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. +

    + + + + + +
    +

    6.0 NuttX Device Drivers

    +
    + +

    + NuttX supports a variety of device drivers including: +

    + These different device driver types are discussed in the following paragraphs. + Note: device driver support requires that the in-memory, pseudo file system + is enabled by setting the CONFIG_NFILE_DESCRIPTORS in the NuttX configuration file to a + non-zero value. +

    + +

    6.1 Character Device Drivers

    + +

    + Character device drivers have these properties: +

    + + +

    6.1.1 Serial Device Drivers

    + + + +

    6.1.1 Touchscreen Device Drivers

    + +

    + NuttX supports a two-part touchscreen driver architecture. +

    +
      +
    1. + An "upper half", generic driver that provides the common touchscreen interface to application level code, and +
    2. +
    3. + A "lower half", platform-specific driver that implements the low-level touchscreen controls to implement the touchscreen functionality. +
    4. +
    +

    + Files supporting the touchscreen controller (TSC) driver can be found in the following locations: +

    + + +

    6.1.2 Analog (ADC/DAC) Drivers

    +

    + The NuttX analog drivers are split into two parts: +

    +
      +
    1. + An "upper half", generic driver that provides the common analog interface to application level code, and +
    2. +
    3. + A "lower half", platform-specific driver that implements the low-level controls to implement the analog functionality. +
    4. +
    + + +

    6.1.3.1 ADC Drivers

    + + +

    6.1.3.2 DAC Drivers

    + + +

    6.1.4 PWM Drivers

    +

    + For the purposes of this driver, a PWM device is any device that generates periodic output pulses of controlled frequency and pulse width. + Such a device might be used, for example, to perform pulse-width modulated output or frequency/pulse-count modulated output + (such as might be needed to control a stepper motor). +

    +

    + The NuttX PWM driver is split into two parts: +

    +
      +
    1. + An "upper half", generic driver that provides the common PWM interface to application level code, and +
    2. +
    3. + A "lower half", platform-specific driver that implements the low-level timer controls to implement the PWM functionality. +
    4. +
    +

    + Files supporting PWM can be found in the following locations: +

    + + +

    6.1.5 CAN Drivers

    +

    + NuttX supports only a very low-level CAN driver. + This driver supports only the data exchange and does not include any high-level CAN protocol. + The NuttX CAN driver is split into two parts: +

    +
      +
    1. + An "upper half", generic driver that provides the common CAN interface to application level code, and +
    2. +
    3. + A "lower half", platform-specific driver that implements the low-level timer controls to implement the CAN functionality. +
    4. +
    +

    + Files supporting CAN can be found in the following locations: +

    + + +

    6.1.6 Quadrature Encoder Drivers

    +

    + NuttX supports a low-level, two-part Quadrature Encoder driver. +

    +
      +
    1. + An "upper half", generic driver that provides the common Quadrature Encoder interface to application level code, and +
    2. +
    3. + A "lower half", platform-specific driver that implements the low-level timer controls to implement the Quadrature Encoder functionality. +
    4. +
    +

    + Files supporting the Quadrature Encoder can be found in the following locations: +

    + + +

    6.1.7 Timer Drivers

    +

    + NuttX supports a low-level, two-part timer driver. +

    +
      +
    1. + An "upper half", generic driver that provides the common timer interface to application level code, and +
    2. +
    3. + A "lower half", platform-specific driver that implements the low-level timer controls to implement the timer functionality. +
    4. +
    +

    + Files supporting the timer driver can be found in the following locations: +

    + + +

    6.1.8 RTC Drivers

    +

    + NuttX supports a low-level, two-part RealTime Clock (RTC) driver. +

    +
      +
    1. + An "upper half", generic driver that provides the common RTC interface to application level code, and +
    2. +
    3. + A "lower half", platform-specific driver that implements the low-level timer controls to implement the RTC functionality. +
    4. +
    +

    + Files supporting the RTC driver can be found in the following locations: +

    + + +

    6.1.9 Watchdog Timer Drivers

    +

    + NuttX supports a low-level, two-part watchdog timer driver. +

    +
      +
    1. + An "upper half", generic driver that provides the common watchdog timer interface to application level code, and +
    2. +
    3. + A "lower half", platform-specific driver that implements the low-level timer controls to implement the watchdog timer functionality. +
    4. +
    +

    + Files supporting the watchdog timer driver can be found in the following locations: +

    + + +

    6.1.10 Keyboard/Keypad Drivers

    +

    + Keypads vs. Keyboards + Keyboards and keypads are really the same devices for NuttX. + A keypad is thought of as simply a keyboard with fewer keys. +

    +

    + Special Commands. + In NuttX, a keyboard/keypad driver is simply a character driver that may have an (optional) encoding/decoding layer on the data returned by the character driver. + A keyboard may return simple text data (alphabetic, numeric, and punctuation) or control characters (enter, control-C, etc.) when a key is pressed. + We can think about this the "normal" keyboard data stream. + However, in addition, most keyboards support actions that cannot be represented as text or control data. + Such actions include things like cursor controls (home, up arrow, page down, etc.), editing functions (insert, delete, etc.), volume controls, (mute, volume up, etc.) and other special functions. + In this case, some special encoding may be required to multiplex the normal text data and special command key press data streams. +

    +

    + Key Press and Release Events + Sometimes the time that a key is released is needed by applications as well. + Thus, in addition to normal and special key press events, it may also be necessary to encode normal and special key release events. +

    +

    + Encoding/Decoding Layer. + An optional encoding/decoding layer can be used with the basic character driver to encode the keyboard events into the text data stream. + The function interfaces that comprise that encoding/decoding layer are defined in the header file include/nuttx/input/kbd_code.h. + These functions provide an matched set of (a) driver encoding interfaces, and (b) application decoding interfaces. +

    +
      +
    1. +

      + Driver Encoding Interfaces. + These are interfaces used by the keyboard/keypad driver to encode keyboard events and data. +

      +
        +
      • +

        + kbd_press() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +void kbd_press(int ch, FAR struct lib_outstream_s *stream);
          +
        +

        Description:

        +
          + Indicates a normal key press event. + Put one byte of normal keyboard data into the output stream. +
        +

        Input Parameters:

        +
          +
        • + ch: The character to be added to the output stream. +
        • +
        • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
        • +
        +

        Returned Value:

        +
          + None. +
        +
      • +
      • +

        + kbd_release() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +void kbd_release(uint8_t ch, FAR struct lib_outstream_s *stream);
          +
        +

        Description:

        +
          + Encode the release of a normal key. +
        +

        Input Parameters:

        +
          +
        • + ch: The character associated with the key that was released. +
        • +
        • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
        • +
        +

        Returned Value:

        +
          + None. +
        +
      • +
      • +

        + kbd_specpress() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +void kbd_specpress(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
          +
        +

        Description:

        +
          + Denotes a special key press event. + Put one special keyboard command into the output stream. +
        +

        Input Parameters:

        +
          +
        • + keycode: The command to be added to the output stream. + The enumeration enum kbd_keycode_e keycode identifies all commands known to the system. +
        • +
        • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
        • +
        +

        Returned Value:

        +
          + None. +
        +
      • +
      • +

        + kbd_specrel() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +void kbd_specrel(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
          +
        +

        Description:

        +
          + Denotes a special key release event. + Put one special keyboard command into the output stream. +
        +

        Input Parameters:

        +
          +
        • + keycode: The command to be added to the output stream. + The enumeration enum kbd_keycode_e keycode identifies all commands known to the system. +
        • +
        • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
        • +
        +

        Returned Value:

        +
          + None. +
        +
      • +
      +
    2. +
    3. +

      + Application Decoding Interfaces. + These are user interfaces to decode the values returned by the keyboard/keypad driver. +

      +
        +
      • +

        + kbd_decode() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +int kbd_decode(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *state, FAR uint8_t *pch);
          +
        +

        Description:

        +
          + Get one byte of data or special command from the driver provided input buffer. +
        +

        Input Parameters:

        +
          +
        • + stream: An instance of lib_instream_s to perform the actual low-level get operation. +
        • +
        • + pch: The location to save the returned value. + This may be either a normal, character code or a special command (i.e., a value from enum kbd_getstate_s. +
        • +
        • + state: A user provided buffer to support parsing. + This structure should be cleared the first time that kbd_decode() is called. +
        • +
        +

        Returned Value:

        +
          +
        • + KBD_PRESS (0): + Indicates the successful receipt of normal, keyboard data. + This corresponds to a keypress event. + The returned value in pch is a simple byte of text or control data. +
        • +
        • + KBD_RELEASE (1): + Indicates a key release event. + The returned value in pch is the byte of text or control data corresponding to the released key. +
        • +
        • + KBD_SPECPRESS (2): + Indicates the successful receipt of a special keyboard command. + The returned value in pch is a value from enum kbd_getstate_s. +
        • +
        • + KBD_SPECREL (3): + Indicates a special command key release event. + The returned value in pch is a value from enum kbd_getstate_s. +
        • +
        • + KBD_ERROR (EOF): + An error has getting the next character (reported by the stream). + Normally indicates the end of file. +
        • +
        +
      • +
      +
    4. +
    +

    + I/O Streams. + Notice the use of the abstract I/O streams in these interfaces. + These stream interfaces are defined in include/nuttx/streams.h. +

    + +

    6.2 Block Device Drivers

    + +

    + Block device drivers have these properties: +

    + + +

    6.3 Specialized Device Drivers

    + +

    + All device drivers that are accessible to application logic are either: (1) Character device drivers that can be accessed via the standard driver operations (open(), close(), read(), write(), etc.), or (2) block drivers that can be accessing only as part of mounting a file system or other special use cases as described in the preceding paragraph. +

    +

    + In addition to this, there are also specialized "drivers" that can be used only within the OS logic itself and are not accessible to application logic. These specialized drivers are discussed in the following paragraphs. +

    + +

    6.3.1 Ethernet Device Drivers

    + + + +

    6.3.2 SPI Device Drivers

    + + + +

    6.3.3 I2C Device Drivers

    + + + +

    6.3.4 Frame Buffer Drivers

    + + + +

    6.3.5 LCD Drivers

    + + + +

    6.3.6 Memory Technology Device Drivers

    + + + +

    6.3.7 SDIO Device Drivers

    + + + +

    6.3.8 USB Host-Side Drivers

    + + + +

    6.3.9 USB Device-Side Drivers

    + + + +

    6.4 Power Management

    + +

    6.4.1 Overview

    +

    + Power Management (PM) Sub-System. + NuttX supports a simple power management (PM) sub-system. This sub-system: +

    + +

    +

    +

    +

    + The PM sub-system integrates the MCU idle loop with a collection of device drivers to support: +

    + +

    + Low Power Consumption States. + Various "sleep" and low power consumption states have various names and are sometimes used in conflicting ways. + In the NuttX PM logic, we will use the following terminology: +

    +
    +
    NORMAL +
    The normal, full power operating mode. +
    IDLE +
    This is still basically normal operational mode, the system is, + however, IDLE and some simple simple steps to reduce power + consumption provided that they do not interfere with normal + Operation. Simply dimming the a backlight might be an example + somethat that would be done when the system is idle. +
    STANDBY +
    Standby is a lower power consumption mode that may involve more + extensive power management steps such has disabling clocking or + setting the processor into reduced power consumption modes. In + this state, the system should still be able to resume normal + activity almost immediately. +
    SLEEP +
    The lowest power consumption mode. The most drastic power + reduction measures possible should be taken in this state. It + may require some time to get back to normal operation from + SLEEP (some MCUs may even require going through reset). +
    +

    + These various states are represented with type enum pm_state_e in include/nuttx/power/pm.h. +

    + +

    + Power Management Domains. + Each PM interfaces includes a integer domain number. + By default, only a single power domain is supported (CONFIG_PM_NDOMAINS=1). + But that is configurable; any number of PM domains can be supported. + Multiple PM domains might be useful, for example, if you would want to control power states associated with a network separately from power states associated with a user interface. +

    + +

    6.4.2 Interfaces

    +

    + All PM interfaces are declared in the file include/nuttx/power/pm.h. +

    + +

    6.4.2.1 pm_initialize()

    +

    Function Prototype:

    + +

    Description: +This function is called by MCU-specific one-time at power on reset in order to initialize the power management capabilities. +This function must be called very early in the initialization sequence before any other device drivers are initialize (since they may attempt to register with the power management subsystem). +

    +

    Input Parameters: +None +

    +

    Returned Value: +None +

    + +

    6.4.2.2 pm_register()

    +

    Function Prototype:

    + +

    Description: + This function is called by a device driver in order to register to receive power management event callbacks. + Refer to the PM Callback section for more details. +

    +

    Input Parameters: +

    +
    callbacks +
    An instance of struct pm_callback_s providing the driver callback functions. +
    +

    +

    Returned Value: +Zero (OK) on success; otherwise a negated errno value is returned. +

    + +

    6.4.2.3 pm_activity()

    +

    Function Prototype:

    + +

    Description: + This function is called by a device driver to indicate that it is performing meaningful activities (non-idle). + This increment an activity count and/or will restart a idle timer and prevent entering reduced power states. +

    +

    Input Parameters: +

    +
    domain +
    Identifies the domain of the new PM activity +
    priority +
    + Activity priority, range 0-9. + Larger values correspond to higher priorities. + Higher priority activity can prevent the system from entering reduced power states for a longer period of time. + As an example, a button press might be higher priority activity because it means that the user is actively interacting with the device. +
    +

    +

    Returned Value: + None +

    +

    Assumptions: + This function may be called from an interrupt handler (this is the ONLY PM function that may be called from an interrupt handler!). +

    + +

    6.4.2.4 pm_checkstate()

    +

    Function Prototype:

    + +

    Description: + This function is called from the MCU-specific IDLE loop to monitor the power management conditions. + This function returns the "recommended" power management state based on the PM configuration and activity reported in the last sampling periods. + The power management state is not automatically changed, however. + The IDLE loop must call pm_changestate() in order to make the state change. +

    +

    + These two steps are separated because the platform-specific IDLE loop may have additional situational information that is not available to the PM sub-system. + For example, the IDLE loop may know that the battery charge level is very low and may force lower power states even if there is activity. +

    +

    + NOTE: That these two steps are separated in time and, hence, the IDLE loop could be suspended for a long period of time between calling pm_checkstate() and pm_changestate(). + The IDLE loop may need to make these calls atomic by either disabling interrupts until the state change is completed. +

    +

    Input Parameters: +

    +
    domain +
    Identifies the PM domain to check +
    +

    +

    Returned Value: + The recommended power management state. +

    + +

    6.4.2.5 pm_changestate()

    +

    Function Prototype:

    + +

    Description: + This function is used by platform-specific power management logic. + It will announce the power management power management state change to all drivers that have registered for power management event callbacks. +

    +

    Input Parameters: +

    +
    domain +
    Identifies the domain of the new PM state +
    newstate +
    Identifies the new PM state +
    +

    +

    Returned Value: + 0 (OK) means that the callback function for all registered drivers returned OK (meaning that they accept the state change). + Non-zero means that one of the drivers refused the state change. + In this case, the system will revert to the preceding state. +

    +

    Assumptions: + It is assumed that interrupts are disabled when this function is called. + This function is probably called from the IDLE loop... the lowest priority task in the system. + Changing driver power management states may result in renewed system activity and, as a result, can + suspend the IDLE thread before it completes the entire state change unless interrupts are disabled throughout the state change. +

    + +

    6.4.3 Callbacks

    +

    + The struct pm_callback_s includes the pointers to the driver callback functions. + This structure is defined include/nuttx/power/pm.h. + These callback functions can be used to provide power management information to the driver. +

    + +

    6.4.3.1 prepare()

    +

    Function Prototype:

    + +

    Description: + Request the driver to prepare for a new power state. + This is a warning that the system is about to enter into a new power state. + The driver should begin whatever operations that may be required to enter power state. + The driver may abort the state change mode by returning a non-zero value from the callback function. +

    +

    Input Parameters: +

    +
    cb +
    Returned to the driver. + The driver version of the callback structure may include additional, driver-specific state data at the end of the structure. +
    domain +
    Identifies the activity domain of the state change +
    pmstate +
    Identifies the new PM state +
    +

    +

    Returned Value: + Zero (OK) means the event was successfully processed and that the driver is prepared for the PM state change. + Non-zero means that the driver is not prepared to perform the tasks needed achieve this power setting and will cause the state change to be aborted. + NOTE: The prepare() method will also be called when reverting from lower back to higher power consumption modes (say because another driver refused a lower power state change). + Drivers are not permitted to return non-zero values when reverting back to higher power + consumption modes! +

    + +

    6.4.3.1 notify()

    +

    Function Prototype:

    + +

    Description: + Notify the driver of new power state. + This callback is called after all drivers have had the opportunity to prepare for the new power state. +

    +

    Input Parameters: +

    +
    cb +
    Returned to the driver. + The driver version of the callback structure may include additional, driver-specific state data at the end of the structure. +
    domain +
    Identifies the activity domain of the state change +
    pmstate +
    Identifies the new PM state +
    +

    +

    Returned Value: + None. + The driver already agreed to transition to the low power consumption state when when it returned OK to the prepare() call. +

    + + + + + +
    +

    Appendix A: NuttX Configuration Settings

    +
    + +

    + At one time, this section provided a list of all NuttX configuration variables. + However, NuttX has since converted to use the kconfig-frontends tools. + Now, the NuttX configuration is determined by a self-documenting set of Kconfig files. +

    +

    + The current NuttX configuration variables are also documented in separate, auto-generated configuration variable document. + That configuration variable document is generated using the kconfig2html tool that can be found in the nuttx/tools directory. + That tool analyzes the NuttX Kconfig files and generates excruciatingly boring HTML document. +

    +

    + The latest boring configuration variable documentation can be regenerated at any time using that tool or, more appropriately, the wrapper script at nuttx/tools/mkconfigvars.sh. + That script will generate the file nuttx/Documentation/NuttXConfigVariables.html. +

    + The version of NuttXConfigVariables.html for the last released version of NuttX can also be found online. +

    + + + + + +
    +

    Appendix B: Trademarks

    +
    + +
  • ARM, ARM7 ARM7TDMI, ARM9, ARM920T, ARM926EJS, Cortex-M3 are trademarks of Advanced RISC Machines, Limited.
  • +
  • Cygwin is a trademark of Red Hat, Incorporated.
  • +
  • Linux is a registered trademark of Linus Torvalds.
  • +
  • Eagle-100 is a trademark of Micromint USA, LLC. +
  • LPC2148 is a trademark of NXP Semiconductors.
  • +
  • TI is a trade name of Texas Instruments Incorporated.
  • +
  • UNIX is a registered trademark of The Open Group.
  • +
  • VxWorks is a registered trademark of Wind River Systems, Incorporated.
  • +
  • ZDS, ZNEO, Z16F, Z80, and Zilog are a registered trademark of Zilog, Inc.
  • + +

    + NOTE: NuttX is not licensed to use the POSIX trademark. NuttX uses the POSIX + standard as a development guideline only. +

    + + + + + diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html new file mode 100644 index 0000000000..a91959e198 --- /dev/null +++ b/Documentation/NuttxUserGuide.html @@ -0,0 +1,10180 @@ + + + +NuttX Users Manual + + + + +

    + + + + +
    +

    NuttX Operating System

    User's Manual

    +

    by

    +

    Gregory Nutt

    +

    Last Updated: July 24, 2015

    +
    +

    + + + + + +
    +

    1.0 Introduction

    +
    + +

    + This manual provides general usage information for the NuttX RTOS from the + perspective of the firmware developer. +

    + + + + + +
    +

    1.1 Document Overview

    +
    + +

    + This user's manual is divided into three sections plus a index: +

    + + + + + + +
    +

    1.2 Intended Audience and Scope

    +
    + +

    + The intended audience for this document are firmware developers who are implementing applications on NuttX. + Specifically, this documented is limited to addressing only NuttX RTOS APIs that are available to the application developer. + As such, this document does not focus on any technical details of the organization or implementation of NuttX. + Those technical details are provided in the NuttX Porting Guide. +

    +

    + Information about configuring and building NuttX is also needed by the application developer. + That information can also be found in the NuttX Porting Guide. +

    + + + + + +
    +

    2.0 OS Interfaces

    +
    + +

    + This section describes each C-callable interface to the NuttX + Operating System. The description of each interface is presented + in the following format: +

    +Function Prototype: The C prototype of the interface function +is provided. +

    +Description: The operation performed by the interface function +is discussed. +

    +Input Parameters: All input parameters are listed along +with brief descriptions of each input parameter. +

    +Returned Value: All possible values returned by the interface +function are listed. Values returned as side-effects (through +pointer input parameters or through global variables) will be +addressed in the description of the interface function. +

    +Assumptions/Limitations: Any unusual assumptions made by +the interface function or any non-obvious limitations to the use +of the interface function will be indicated here. +

    +POSIX Compatibility: Any significant differences between the +NuttX interface and its corresponding POSIX interface will be noted +here. +

    +NOTE: In order to achieve an independent name space for the NuttX +interface functions, differences in function names and types are +to be expected and will not be identified as differences in these +paragraphs. +

    + + + + + +
    +

    2.1 Task Control Interfaces

    +
    + +

    + Tasks. + NuttX is a flat address OS. As such it does not support processes + in the way that, say, Linux does. + NuttX only supports simple threads running within the same address space. + However, the programming model makes a distinction between tasks + and pthreads: +

    + +

    + File Descriptors and Streams. + This applies, in particular, in the area of opened file descriptors and streams. + When a task is started using the interfaces in this section, it will be created + with at most three open files. +

    +

    + If CONFIG_DEV_CONSOLE is defined, the first three file descriptors (corresponding + to stdin, stdout, stderr) will be duplicated for the new task. + Since these file descriptors are duplicated, the child task can free close + them or manipulate them in any way without effecting the parent task. + File-related operations (open, close, etc.) within a task will have no effect + on other tasks. + Since the three file descriptors are duplicated, it is also possible to perform + some level of redirection. +

    +

    + pthreads, on the other hand, will always share file descriptors with the parent + thread. In this case, file operations will have effect only all pthreads the + were started from the same parent thread. +

    +

    Executing Programs within a File System. + NuttX also provides internal interfaces for the execution of separately built + programs that reside in a file system. + These internal interfaces are, however, non-standard and are documented with the + NuttX binary loader and + NXFLAT. +

    +

    Task Control Interfaces. + The following task control interfaces are provided by NuttX: +

    +

    + Non-standard task control interfaces inspired by VxWorks interfaces: +

    + +

    + Standard interfaces +

    + +

    + Standard vfork and exec[v|l] interfaces: +

    + +

    + Standard posix_spawn interfaces: +

    + +

    + Non-standard task control interfaces inspired by posix_spawn: +

    + + +

    2.1.1 task_create

    + +

    +Function Prototype: +

    + +

    +Description: + This function creates and activates a new task with a + specified priority and returns its system-assigned ID. +

    + +

    The entry address entry is the address of the "main" + function of the task. + This function will be called once the C environment has been set up. + The specified function will be called with four arguments. + Should the specified routine return, a call to exit() will automatically be made. +

    +

    + Note that an arbitrary number of arguments may be passed to the + spawned functions. +

    +

    + The arguments are copied (via strdup) so that the + life of the passed strings is not dependent on the life of the + caller to task_create(). +

    +

    + The newly created task does not inherit scheduler characteristics + from the parent task: The new task is started at the + default system priority and with the SCHED_FIFO scheduling + policy. These characteristics may be modified after the new + task has been started. +

    +

    + The newly created task does inherit the first three file + descriptors (corresponding to stdin, stdout, and stderr) and + redirection of standard I/O is supported. +

    +

    +Input Parameters: +

    +

    + Returned Value: +

    + + +

    +Assumptions/Limitations: +

    +POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the following similar interface: +

    +   int taskSpawn(char *name, int priority, int options, int stackSize, FUNCPTR entryPt,
    +                 int arg1, int arg2, int arg3, int arg4, int arg5,
    +                 int arg6, int arg7, int arg8, int arg9, int arg10);
    +
    + +

    + The NuttX task_create() differs from VxWorks' taskSpawn() in the + following ways: +

    + + +

    2.1.2 task_init

    + +

    +Function Prototype: +

    +   #include <sched.h>
    +   int task_init(struct tcb_s *tcb, char *name, int priority, uint32_t *stack, uint32_t stack_size,
    +                 maint_t entry, char * const argv[]);
    +
    + +

    +Description: +

    + This function initializes a Task Control Block (TCB) + in preparation for starting a new thread. It performs a subset + of the functionality of task_create() (see above). +

    +

    + Unlike task_create(), task_init() does not activate the task. + This must be done by calling task_activate(). +

    +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    +

    +POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the following similar interface: +

    +   STATUS taskInit(WIND_TCB *pTcb, char *name, int priority, int options, uint32_t *pStackBase, int stackSize,
    +                   FUNCPTR entryPt, int arg1, int arg2, int arg3, int arg4, int arg5,
    +                   int arg6, int arg7, int arg8, int arg9, int arg10);
    +
    + +

    + The NuttX task_init() differs from VxWorks' taskInit() in the + following ways: +

    + + +

    2.1.3 task_activate

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    int task_activate(struct tcb_s *tcb);
    +
    + +

    +Description: This function activates tasks created by task_init(). +Without activation, a task is ineligible for execution by the +scheduler. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    +

    +POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the following similar interface: +

    +    STATUS taskActivate(int tid);
    +
    + +

    + The NuttX task_activate() differs from VxWorks' taskActivate() in the + following ways: +

    + + +

    2.1.4 task_delete

    + +

    +Function Prototype: +

    + +

    + Description: + This function causes a specified task to cease to exist -- its stack and TCB will be deallocated. + This function is the companion to task_create(). +

    +Input Parameters: +

    +

    +Returned Value: +

    +

    +Assumptions/Limitations: +

    + task_delete() must be used with caution: + If the task holds resources (for example, allocated memory or semaphores needed by other tasks), then task_delete() can strand those resources. +

    +

    +POSIX Compatibility: + This is a NON-POSIX interface. + VxWorks provides the following similar interface: +

    + + +

    + The NuttX task_delete() differs from VxWorks' taskDelete() in + the following ways: +

    + + +

    2.1.5 task_restart

    +

    +Function Prototype: +

    +

    + Description: + This function "restarts" a task. + The task is first terminated and then reinitialized with same ID, priority, original entry point, stack size, and parameters it had when it was first started. +

    +

    + NOTES: +

    +
      +
    1. + The normal task exit clean up is not performed. + For example, file descriptors are not closed; any files opened prior to the restart will remain opened after the task is restarted. +
    2. +
    3. + Memory allocated by the task before it was restart is not freed. + A task that is subject to being restart must be designed in such a way as to avoid memory leaks. +
    4. +
    5. + Initialized data is not reset. + All global or static data is left in the same state as when the task was terminated. + This feature may be used by restart task to detect that it has been restarted, for example. +
    6. +
    +

    +Input Parameters: +

    +

    +Returned Value: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the following similar interface: +

    +    STATUS taskRestart (int tid);
    +
    + +

    + The NuttX task_restart() differs from VxWorks' taskRestart() in the following ways: +

    + + +

    2.1.6 exit

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    void exit(int code);
    +
    +    #include <nuttx/unistd.h>
    +    void _exit(int code);
    +
    + +

    +Description: This function causes the calling task to cease +to exist -- its stack and TCB will be deallocated. exit differs from +_exit in that it flushes streams, closes file descriptors and will +execute any function registered with atexit() or on_exit(). +

    +Input Parameters: +

    + +

    +Returned Value: None. + +

    +Assumptions/Limitations: + +

    +POSIX Compatibility: This is equivalent to the ANSI interface: +

    +    void exit(int code);
    +
    +And the UNIX interface: +
    +    void _exit(int code);
    +
    + +

    + The NuttX exit() differs from ANSI exit() in the following ways: +

    + + +

    2.1.7 getpid

    + +

    +Function Prototype: +

    +    #include <unistd.h>
    +    pid_t getpid(void);
    +
    + +

    +Description: This function returns the task ID of the +calling task. The task ID will be invalid if called at the interrupt +level. +

    +Input Parameters: None. +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    +POSIX Compatibility: +Compatible with the POSIX interface of the same name. +

    + +

    2.1.8 vfork

    +

    + Function Prototype: +

    + +

    + Description: + The vfork() function has the same effect as fork(), except that the behavior is undefined if the process created by vfork() either modifies any data other than a variable of type pid_t used to store the return value from vfork(), or returns from the function in which vfork() was called, or calls any other function before successfully calling _exit() or one of the exec family of functions. +

    +

    + NOTE: + vfork() is not an independent NuttX feature, but is implemented in architecture-specific logic (using only helper functions from the NuttX core logic). + As a result, vfork() may not be available on all architectures. +
    +

    + Input Parameters: + None. +

    +

    + Returned Value: + Upon successful completion, vfork() returns 0 to the child process and returns + the process ID of the child process to the parent process. + Otherwise, -1 is returned to the parent, no child process is created, and errno is set to indicate the error. +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Compatible with the Unix interface of the same name. +

    + +

    2.1.9 execv

    +

    + Function Prototype: +

    + +

    + Description: + The standard exec family of functions will replace the current process image with a new process image. + The new image will be constructed from a regular, executable file called the new process image file. + There will be no return from a successful exec, because the calling process image is overlaid by the new process image. +

    +

    + Simplified execl() and execv() functions are provided by NuttX for compatibility. + NuttX is a tiny embedded RTOS that does not support processes and hence the concept of overlaying a tasks process image with a new process image does not make any sense. + In NuttX, these functions are wrapper functions that: +

    +
      +
    1. + Call the non-standard binfmt function exec(), and then +
    2. +
    3. + exit(0). +
    4. +
    +

    + Note the inefficiency when execv() or execl() is called in the normal, two-step process: + (1) first call vfork() to create a new thread, then (2) call execv() or execl() to replace the new thread with a program from the file system. + Since the new thread will be terminated by the execv() or execl() call, it really served no purpose other than to support Unix compatibility. +

    +

    + The non-standard binfmt function exec() needs to have (1) a symbol table that provides the list of symbols exported by the base code, and (2) the number of symbols in that table. + This information is currently provided to exec() from execv() or execl() via NuttX configuration settings: +

    + +

    + As a result of the above, the current implementations of execl() and execv() suffer from some incompatibilities that may or may not be addressed in a future version of NuttX. + Other than just being an inefficient use of MCU resource, the most serious of these is that + the exec'ed task will not have the same task ID as the vfork'ed function. + So the parent function cannot know the ID of the exec'ed task.

    +

    + Input Parameters: +

    + +

    + Returned Value: + This function does not return on success. + On failure, it will return -1 (ERROR) and will set the errno value appropriately. +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Similar with the Unix interface of the same name. + There are, however, several compatibility issues as detailed in the description above. +

    + +

    2.1.10 execl

    +

    + Function Prototype: +

    + +

    + Description: + execl() is functionally equivalent to execv(), differing only in the form of its input parameters. + See the decription of execv() for additional information. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + This function does not return on success. + On failure, it will return -1 (ERROR) and will set the errno value appropriately. +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Similar with the Unix interface of the same name. + There are, however, several compatibility issues as detailed in the description of execv(). +

    + +

    2.1.11 posix_spawn and posix_spawnp

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn() and posix_spawnp() functions will create a new, child task, constructed from a regular executable file. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + posix_spawn() and posix_spawnp() will return zero on success. + Otherwise, an error number will be returned as the function return value to indicate the error: +

    + +

    + Assumptions/Limitations: +

    + +

    + POSIX Compatibility: + The value of the argv[0] received by the child task is assigned by NuttX. + For the caller of posix_spawn(), the provided argv[0] will correspond to argv[1] received by the new task. +

    + +

    2.1.12 posix_spawn_file_actions_init

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_init() function initializes the object referenced by file_actions to an empty set of file actions for subsequent use in a call to posix_spawn() or posix_spawnp(). +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h>. +

    + +

    2.1.13 posix_spawn_file_actions_destroy

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_destroy() function destroys the object referenced by file_actions which was previously initialized by posix_spawn_file_actions_init(), returning any resources obtained at the time of initialization to the system for subsequent reuse. + A posix_spawn_file_actions_t may be reinitialized after having been destroyed, but must not be reused after destruction, unless it has been reinitialized. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.14 posix_spawn_file_actions_addclose

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_addclose() function adds a close operation to the list of operations associated with the object referenced by file_actions, for subsequent use in a call to posix_spawn() or posix_spawnp(). + The descriptor referred to by fd is closed as if close() had been called on it prior to the new child process starting execution. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.15 posix_spawn_file_actions_adddup2

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_adddup2() function adds a dup2 operation to the list of operations associated with the object referenced by file_actions, for subsequent use in a call to posix_spawn() or posix_spawnp(). + The descriptor referred to by fd2 is created as if dup2() had been called on fd1 prior to the new child process starting execution. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.16 posix_spawn_file_actions_addopen

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_addopen() function adds an open operation to the list of operations associated with the object referenced by file_actions, for subsequent use in a call to posix_spawn() or posix_spawnp(). + The descriptor referred to by fd is opened using the path, oflag, and mode arguments as if open() had been called on it prior to the new child process starting execution. + The string path is copied by the posix_spawn_file_actions_addopen() function during this process, so storage need not be persistent in the caller. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.17 posix_spawnattr_init

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_init() function initializes the object referenced by attr, to an empty set of spawn attributes for subsequent use in a call to posix_spawn() or posix_spawnp(). +

    +

    + Then the spawn attributes are no longer needed, they should be destroyed by calling posix_spawnattr_destroyed(). + In NuttX, however, posix_spawnattr_destroyed() is just stub: +

    + +

    + For portability, the convention of calling posix_spawnattr_destroyed() when the attributes are not longer needed should still be followed. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.18 posix_spawnattr_getflags

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_getflags() function will obtain the value of the spawn-flags attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.19 posix_spawnattr_getschedparam

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_getschedparam() function will obtain the value of the spawn-schedparam attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.20 posix_spawnattr_getschedpolicy

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_getschedpolicy() function will obtain the value of the spawn-schedpolicy attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.21 posix_spawnattr_getsigmask

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_getsigdefault() function will obtain the value of the spawn-sigmask attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.22 posix_spawnattr_setflags

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_setflags() function will set the spawn-flags attribute in an initialized attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.23 posix_spawnattr_setschedparam

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_setschedparam() function will set the spawn-schedparam attribute in an initialized attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.24 posix_spawnattr_setschedpolicy

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_setschedpolicy() function will set the spawn-schedpolicy attribute in an initialized attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.25 posix_spawnattr_setsigmask

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_setsigmask() function will set the spawn-sigmask attribute in an initialized attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.26 task_spawn

    +

    + Function Prototype: +

    + +

    + Description: + The task_spawn() function will create a new, child task, where the entry point to the task is an address in memory. +

    +

    + +

    + Returned Value: + task_spawn() will return zero on success. + Otherwise, an error number will be returned as the function return value to indicate the error: +

    +

    + POSIX Compatibility: + This is a non-standard interface inspired by posix_spawn(). +

    + +

    2.1.26 task_spawnattr_getstacksize

    +

    + Function Prototype: +

    + +

    + Description: + The task_spawnattr_getstacksize() function will obtain the value of the spawn-stacksize attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.26 task_spawnattr_setstacksize

    +

    + Function Prototype: +

    + +

    + Description: + The task_spawnattr_setstacksize() function will set the spawn-stacksize attribute in an initialized attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.12 posix_spawn_file_actions_init

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_init() function initializes the object referenced by file_actions to an empty set of file actions for subsequent use in a call to posix_spawn() or posix_spawnp(). +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h>. +

    + + + + + +
    +

    2.2 Task Scheduling Interfaces

    +
    + +

    + By default, NuttX performs strict priority scheduling: Tasks of higher priority have exclusive access to the CPU until they become blocked. + At that time, the CPU is available to tasks of lower priority. + Tasks of equal priority are scheduled FIFO. +

    +

    + Optionally, a Nuttx task or thread can be configured with round-robin or sporadic scheduler. + The round-roben is similar to priority scheduling except that tasks with equal priority and share CPU time via time-slicing. + The time-slice interval is a constant determined by the configuration + setting CONFIG_RR_INTERVAL to a positive, non-zero value. + Sporadic scheduling scheduling is more complex, varying the priority of a thread over a replenishment period. + Support for sporadic scheduling is enabled by the configuration option CONFIG_SCHED_SPORADIC. +

    +

    + The OS interfaces described in the following paragraphs provide a POSIX- compliant interface to the NuttX scheduler: +

    + + +

    2.2.1 sched_setparam

    +

    + Function Prototype: +

    +    #include <sched.h>
    +    int sched_setparam(pid_t pid, const struct sched_param *param);
    +
    +

    + Description: + This function sets the priority of the task specified by pid input parameter. +

    +

    + NOTE: Setting a task's priority to the same value has the similar + effect to sched_yield(): The task will be moved to after all + other tasks with the same priority. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, sched_setparam() returns 0 (OK). + On error, -1 (ERROR) is returned, and errno is set appropriately. +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. + Differences from the full POSIX implementation include: +

    + + +

    2.2.2 sched_getparam

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    int sched_getparam (pid_t pid, struct sched_param *param);
    +
    + +

    +Description: This function gets the scheduling priority +of the task specified by pid. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.2.3 sched_setscheduler

    +

    + Function Prototype: +

    + +

    + Description: + sched_setscheduler() sets both the scheduling policyand the priority for the task identified by pid. + If pid equals zero, the scheduler of the calling thread will be set. + The parameter param holds the priority of the thread under the new policy. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, sched_setscheduler() returns OK (zero). On + error, ERROR (-1) is returned, and errno is set appropriately: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.2.4 sched_getscheduler

    +

    +Function Prototype: +

    +

    + Description: + sched_getscheduler() returns the scheduling policy + currently applied to the task identified by pid. If + pid equals zero, the policy of the calling process will + be retrieved. +

    +Input Parameters: +

    +

    +Returned Value: +

    +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. + +

    2.2.5 sched_yield

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    int sched_yield(void);
    +
    + +

    +Description: This function forces the calling task to give +up the CPU (only to other tasks at the same priority). +

    +Input Parameters: None. +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.2.6 sched_get_priority_max

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    int sched_get_priority_max (int policy)
    +
    + +

    +Description: This function returns the value of the highest +possible task priority for a specified scheduling policy. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.2.7 sched_get_priority_min

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    int sched_get_priority_min (int policy);
    +
    + +

    +Description: This function returns the value of the lowest +possible task priority for a specified scheduling policy. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.2.8 sched_get_rr_interval

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    int sched_get_rr_interval (pid_t pid, struct timespec *interval);
    +
    + +

    + Description: + sched_rr_get_interval() writes the timeslice interval + for task identified by pid into the timespec structure + pointed to by interval. If pid is zero, the timeslice + for the calling process is written into 'interval. The + identified process should be running under the SCHED_RR + scheduling policy.' +

    +

    + Input Parameters: +

    + + +

    + Returned Value: + On success, sched_rr_get_interval() returns OK (0). On + error, ERROR (-1) is returned, and errno is set to: +

    + + +

    + Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX + interface of the same name. +

    + + + + + +
    +

    2.3 Task Control Interfaces

    +
    + +

    + Task Control Interfaces. +

    + + +

    + Parent and Child Tasks. + The task synchronization interfaces historically depend upon parent and child relationships between tasks. + But default, NuttX does not use any parent/child knowledge. + However, there are three important configuration options that can change that. +

    + +

    + Warning: + If you enable the CONFIG_SCHED_CHILD_STATUS feature, then your application must either (1) take responsibility for reaping the child status with wait(), waitpid() or waitid(), or (2) suppress retention of child status. + If you do not reap the child status, then you have a memory leak and your system will eventually fail. +

    + Retention of child status can be suppressed on the parent using logic like: +

    + + +

    2.3.1 sched_lock

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    int sched_lock(void);
    +
    + +

    +Description: This function disables context switching by +Disabling addition of new tasks to the ready-to-run task list. +The task that calls this function will be the only task that is +allowed to run until it either calls sched_unlock (the appropriate +number of times) or until it blocks itself. +

    +Input Parameters: None. +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    +POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the comparable interface: +

    +    STATUS taskLock(void);
    +
    + +

    2.3.2 sched_unlock

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    int sched_unlock(void);
    +
    + +

    +Description: This function decrements the preemption lock +count. Typically this is paired with sched_lock() and concludes +a critical section of code. Preemption will not be unlocked until +sched_unlock() has been called as many times as sched_lock(). +When the lockCount is decremented to zero, any tasks that were +eligible to preempt the current task will execute. +

    +Input Parameters: None. +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    +POSIX Compatibility: This is a NON-POSIX interface. +VxWorks provides the comparable interface: +

    +    STATUS taskUnlock(void);
    +
    + +

    2.3.3 sched_lockcount

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    int32_t sched_lockcount(void)
    +
    + +

    +Description: This function returns the current value of +the lockCount. If zero, preemption is enabled; if non-zero, this +value indicates the number of times that sched_lock() has been called +on this thread of execution. +

    +Input Parameters: None. +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: None. +

    + +

    2.3.4 waitpid

    + +

    +Function Prototype: +

    +    #include <sys/wait.h>
    +    ipid_t waitpid(pid_t pid, int *stat_loc, int options);
    +
    + +

    + Description: +

    +
    + The following discussion is a general description of the waitpid() interface. + However, as of this writing, the implementation of waitpid() is incomplete (but usable). + If CONFIG_SCHED_HAVE_PARENT is defined, waitpid() will be a little more compliant to specifications. + Without CONFIG_SCHED_HAVE_PARENT, waitpid() simply supports waiting for any task to complete execution. + With CONFIG_SCHED_HAVE_PARENT, waitpid() will use SIGCHLD and can, therefore, wait for any child of the parent to complete. + The implementation is incomplete in either case, however: NuttX does not support any concept of process groups. + Nor does NuttX retain the status of exited tasks so if waitpid() is called after a task has exited, then no status will be available. + The options argument is currently ignored. +
    +

    + The waitpid() functions will obtain status information pertaining to one of the caller's child processes. + The waitpid() function will suspend execution of the calling thread until status information for one of the terminated child processes of the calling process is available, or until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process. + If more than one thread is suspended in waitpid() awaiting termination of the same process, exactly one thread will return the process status at the time of the target process termination. + If status information is available prior to the call to waitpid(), return will be immediate. +

    +

    + NOTE: + Because waitpid() is not fully POSIX compliant, it must be specifically enabled by setting CONFIG_SCHED_WAITPID in the NuttX configuration file. +

    +

    + Input Parameters: +

    + +

    + The pid argument specifies a set of child processes for which status is requested. + The waitpid() function will only return the status of a child process from this set: +

    + +

    + The options argument is constructed from the bitwise-inclusive OR of zero or more of the following flags, + defined in the <sys/wait.h> header: +

    + +

    + If the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, and the process has no unwaited-for children that were transformed into zombie processes, the calling thread will block until all of the children of the process containing the calling thread terminate, and waitpid() will fail and set errno to ECHILD. +

    +

    + If waitpid() returns because the status of a child process is available, these functions will return a value equal to the process ID of the child process. + In this case, if the value of the argument stat_loc is not a null pointer, information will be stored in the location pointed to by stat_loc. + The value stored at the location pointed to by stat_loc will be 0 if and only if the status returned is from a terminated child process that terminated by one of the following means: +

    +
      +
    1. + The process returned 0 from main(). +
    2. +
    3. + The process called _exit() or exit() with a status argument of 0. +
    4. +
    5. + The process was terminated because the last thread in the process terminated. +
    6. +
    +

    + Regardless of its value, this information may be interpreted using the following macros, which are defined in <sys/wait.h> and evaluate to integral expressions; the stat_val argument is the integer value pointed to by stat_loc. +

    + +

    + Returned Value: +

    +

    + If waitpid() returns because the status of a child process is available, it will return a value equal to the process ID of the child process for which status is reported. +

    +

    + If waitpid() returns due to the delivery of a signal to the calling process, -1 will be returned and errno set to EINTR. +

    +

    + If waitpid() was invoked with WNOHANG set in options, it has at least one child process specified by pid for which status is not available, and status is not available for any process specified by pid, 0 is returned. +

    +

    + Otherwise, (pid_t)-1errno set to indicate the error: +

    + + +

    + Assumptions/Limitations: +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name, but the implementation is incomplete (as detailed above). +

    + +

    2.3.5 waitid

    +

    +Function Prototype: +

    +    #include <sys/wait.h>
    +    #ifdef CONFIG_SCHED_HAVE_PARENT
    +    int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options);
    +    #endif
    +
    +

    + Description: +

    +
    + The following discussion is a general description of the waitid() interface. + However, as of this writing, the implementation of waitid() is incomplete (but usable). + If CONFIG_SCHED_HAVE_PARENT is defined, waitid() will be a little more compliant to specifications. + waitpid() simply supports waiting a specific child task (P_PID or for any child task P_ALL to complete execution. + SIGCHLD is used. + The implementation is incomplete in either case, however: NuttX does not support any concept of process groups. + Nor does NuttX retain the status of exited tasks so if waitpid() is called after a task has exited, then no status will be available. + The options argument is currently ignored. +
    +

    + The waitid() function suspends the calling thread until one child of the process containing the calling thread changes state. + It records the current state of a child in the structure pointed to by info. + If a child process changed state prior to the call to waitid(), waitid() returns immediately. + If more than one thread is suspended in wait() or waitpid() waiting termination of the same process, exactly one thread will return the process status at the time of the target process termination +

    +

    + The idtype and id arguments are used to specify which children waitid() will wait for. +

    +

    +

    +

    + The options argument is used to specify which state changes waitid() will will wait for. + It is formed by OR-ing together one or more of the following flags: +

    + + The info argument must point to a siginfo_t structure. + If waitid() returns because a child process was found that satisfied the conditions indicated by the arguments idtype and options, then the structure pointed to by info will be filled in by the system with the status of the process. + The si_signo member will always be equal to SIGCHLD. +

    +

    + Input Parameters: + See the description above. +

    +

    + Returned Value: + If waitid() returns due to the change of state of one of its children, 0 is returned. + Otherwise, -1 is returned and errno is set to indicate the error. +

    +

    + The waitid() function will fail if: +

    + +

    + Assumptions/Limitations: +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name, but the implementation is incomplete (as detailed in the description above). +

    + +

    2.3.6 wait

    +

    +Function Prototype: +

    +    #include <sys/wait.h>
    +    #ifdef CONFIG_SCHED_HAVE_PARENT
    +    pid_t wait(FAR int *stat_loc);
    +    #endif
    +
    +

    + Description: +

    +
    + The following discussion is a general description of the wait() interface. + However, as of this writing, the implementation of wait() is incomplete (but usable). + wait() is based on waitpaid(). + See the description of waitpaid() for further information. +
    +

    + The wait() function will suspend execution of the calling thread until status information for one of its terminated child processes is available, or until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process. + If more than one thread is suspended in wait() awaiting termination of the same process, exactly one thread will return the process status at the time of the target process termination. + If status information is available prior to the call towait(), return will be immediate. +

    +

    + The waitpid() function will behave identically to wait(), if its pid argument is (pid_t)-1 and the options argument is 0. + Otherwise, its behavior will be modified by the values of the pid and options arguments. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + See the values returned by waitpaid(). +

    +

    + Assumptions/Limitations: +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name, but the implementation is incomplete (as detailed in the description waitpaid()). +

    + +

    2.3.7 atexit

    + +

    +Function Prototype: +

    +    #include <stdlib.h>
    +    int atexit(void (*func)(void));
    +
    +

    + Description: + Registers a function to be called at program exit. + The atexit() function registers the given function to be called at normal process termination, whether via exit() or via return from the program's main(). +

    +

    + NOTE: CONFIG_SCHED_ATEXIT must be defined to enable this function. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, atexit() returns OK (0). + On error, ERROR (-1) is returned, and errno is set to indicate the cause of the failure. +

    + +

    + Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the ISO C interface of the same name. + Limitiations in the current implementation: +

    +
      +
    1. Only a single atexit function can be registered unless CONFIG_SCHED_ATEXIT_MAX defines a larger number.
    2. +
    3. atexit() functions are not inherited when a new task is created.
    4. +
    + +

    2.3.8 on_exit

    + +

    +Function Prototype: +

    +    #include <stdlib.h>
    +    int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg)
    +
    +

    + Description: + Registers a function to be called at program exit. + The on_exit() function registers the given function to be called at normal process termination, whether via exit() or via return from the program's main(). + The function is passed the status argument given to the last call to exit() and the arg argument from on_exit(). +

    +

    + NOTE: CONFIG_SCHED_ONEXIT must be defined to enable this function +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, on_exit() returns OK (0). + On error, ERROR (-1) is returned, and errno is set to indicate the cause of the failure. +

    + +

    + Assumptions/Limitations: +

    + POSIX Compatibility: + This function comes from SunOS 4, but is also present in libc4, libc5 and glibc. + It no longer occurs in Solaris (SunOS 5). + Avoid this function, and use the standard atexit() instead. +

    +
      +
    1. Only a single on_exit function can be registered unless CONFIG_SCHED_ONEXIT_MAX defines a larger number.
    2. +
    3. on_exit() functions are not inherited when a new task is created.
    4. +
    + + + + + +
    +

    2.4 Named Message Queue Interfaces

    +
    + +

    + NuttX supports POSIX named message queues for inter-task communication. + Any task may send or receive messages on named message queues. + Interrupt handlers may send messages via named message queues. +

    + + +

    2.4.1 mq_open

    + +

    +Function Prototype: +

    +    #include <mqueue.h>
    +    mqd_t mq_open(const char *mqName, int oflags, ...);
    +
    + +

    +Description: This function establish a connection between +a named message queue and the calling task. After a successful +call of mq_open(), the task can reference the message queue using +the address returned by the call. The message queue remains usable +until it is closed by a successful call to mq_close(). +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX interface +of the same name. +Differences from the full POSIX implementation include: +

    + +

    2.4.2 mq_close

    + +

    +Function Prototype: +

    +    #include <mqueue.h>
    +    int mq_close(mqd_t mqdes);
    +
    + +

    +Description: This function is used to indicate that the +calling task is finished with the specified message queued mqdes. +The mq_close() deallocates any system resources allocated by the +system for use by this task for its message queue. +

    +If the calling task has attached a notification request to the message +queue via this mqdes (see mq_notify()), this attachment will be +removed and the message queue is available for another task to attach +for notification. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    +

    +

    + POSIX Compatibility: Comparable to the POSIX interface +of the same name. + +

    2.4.3 mq_unlink

    + +

    +Function Prototype: +

    +    #include <mqueue.h>
    +    int mq_unlink(const char *mqName);
    +
    + +

    +Description: This function removes the message queue named +by "mqName." If one or more tasks have the message queue +open when mq_unlink() is called, removal of the message queue +is postponed until all references to the message queue have been +closed. +

    +Input Parameters: +

    + +

    +Returned Value: None. +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.4.4 mq_send

    +

    +Function Prototype: +

    +
    +    #include <mqueue.h>
    +    int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio);
    +
    +

    +Description: + This function adds the specified message, msg, to the message queue, mqdes. + The msglen parameter specifies the length of the message in bytes pointed to by msg. + This length must not exceed the maximum message length from the mq_getattr(). +

    +

    + If the message queue is not full, mq_send() will place the msg + in the message queue at the position indicated by the prio argument. + Messages with higher priority will be inserted before lower priority messages + The value of prio must not exceed MQ_PRIO_MAX. +

    +

    + If the specified message queue is full and O_NONBLOCK is not + set in the message queue, then mq_send() will block until space + becomes available to the queue the message. +

    +

    + If the message queue is full and NON_BLOCK is set, the message + is not queued and ERROR is returned. +

    +

    + NOTE: + mq_send() may be called from an interrupt handler. + However, it behaves differently when called from the interrupt level: +

    + +

    + Input Parameters: +

    + +

    + Returned Value: + On success, mq_send() returns 0 (OK); + on error, -1 (ERROR) is returned, with errno set + to indicate the error: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. +

    + +

    mq_timedsend

    +Function Prototype: +

    +
    +    #include <mqueue.h>
    +    int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio,
    +                     const struct timespec *abstime);
    +
    +

    +Description: + This function adds the specified message, msg, + to the message queue, mqdes. + The msglen parameter specifies the length of the message in bytes pointed to by msg. + This length must not exceed the maximum message length from the mq_getattr(). +

    +

    + If the message queue is not full, mq_timedsend() will place the msg + in the message queue at the position indicated by the prio argument. + Messages with higher priority will be inserted before lower priority messages + The value of prio must not exceed MQ_PRIO_MAX. +

    +

    + If the specified message queue is full and O_NONBLOCK is not + set in the message queue, then mq_send() will block until space + becomes available to the queue the message or until a timeout occurs. +

    +

    + mq_timedsend() behaves just like mq_send(), except + that if the queue is full and the O_NONBLOCK flag is not enabled + for the message queue description, then abstime points to a + structure which specifies a ceiling on the time for which the call will block. + This ceiling is an absolute timeout in seconds and nanoseconds since the + Epoch (midnight on the morning of 1 January 1970). +

    +

    + If the message queue is full, and the timeout has already expired by the time + of the call, mq_timedsend() returns immediately. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, mq_send() returns 0 (OK); + on error, -1 (ERROR) is returned, with errno set + to indicate the error: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. +

    + +

    2.4.5 mq_receive

    +

    + Function Prototype: +

    +
    +    #include <mqueue.h>
    +    ssize_t mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio);
    +
    +

    + Description: + This function receives the oldest of the highest priority messages from the message + queue specified by mqdes. + If the size of the buffer in bytes, msgLen, is less than the + mq_msgsize attribute of the message queue, mq_receive() will + return an error. + Otherwise, the selected message is removed from the queue and copied to msg. +

    +

    + If the message queue is empty and O_NONBLOCK was not set, mq_receive() + will block until a message is added to the message queue. + If more than one task is waiting to receive a message, only the task with the highest + priority that has waited the longest will be unblocked. +

    +

    + If the queue is empty and O_NONBLOCK is set, ERROR will be returned. +

    +

    + Input Parameters: +

    + +

    + Returned Value:. + One success, the length of the selected message in bytes is returned. + On failure, -1 (ERROR) is returned and the errno is set appropriately: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. +

    + +

    2.4.6 mq_timedreceive

    +

    + Function Prototype: +

    +
    +    #include <mqueue.h>
    +    ssize_t mq_timedreceive(mqd_t mqdes, void *msg, size_t msglen,
    +                            int *prio, const struct timespec *abstime);
    +
    +

    + Description: + This function receives the oldest of the highest priority messages from the message + queue specified by mqdes. + If the size of the buffer in bytes, msgLen, is less than the + mq_msgsize attribute of the message queue, mq_timedreceive() will + return an error. + Otherwise, the selected message is removed from the queue and copied to msg. +

    +

    + If the message queue is empty and O_NONBLOCK was not set, mq_timedreceive() + will block until a message is added to the message queue (or until a timeout occurs). + If more than one task is waiting to receive a message, only the task with the highest + priority that has waited the longest will be unblocked. +

    +

    + mq_timedreceive() behaves just like mq_receive(), except + that if the queue is empty and the O_NONBLOCK flag is not enabled + for the message queue description, then abstime points to a structure + which specifies a ceiling on the time for which the call will block. + This ceiling is an absolute timeout in seconds and nanoseconds since the Epoch + (midnight on the morning of 1 January 1970). +

    +

    + If no message is available, and the timeout has already expired by the time of + the call, mq_timedreceive() returns immediately. +

    +

    + Input Parameters: +

    + +

    + Returned Value:. + One success, the length of the selected message in bytes is returned. + On failure, -1 (ERROR) is returned and the errno is set appropriately: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. +

    + +

    2.4.7 mq_notify

    + +

    + Function Prototype: +

    +    #include <mqueue.h>
    +    int mq_notify(mqd_t mqdes, const struct sigevent *notification);
    +
    +

    +

    + Description: If the notification input parameter + is not NULL, this function connects the task with the message queue such + that the specified signal will be sent to the task whenever the message + changes from empty to non-empty. One notification can be attached + to a message queue. +

    +

    + If notification; is NULL, the attached notification + is detached (if it was held by the calling task) and the queue + is available to attach another notification. +

    +

    + When the notification is sent to the registered task, its registration + will be removed. The message queue will then be available for + registration. +

    + Input Parameters: +

    +

    +

    + Returned Value: + On success mq_notify() returns 0; on error, -1 is returned, with + errno set to indicate the error: +

    +

    +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. + Differences from the full POSIX implementation include: +

    +

    + +

    2.4.8 mq_setattr

    + +

    +Function Prototype: +

    +    #include <mqueue.h>
    +    int mq_setattr(mqd_t mqdes, const struct mq_attr *mqStat,
    +                   struct mq_attr *oldMqStat);
    +
    + +

    +Description: This function sets the attributes associated +with the specified message queue "mqdes." Only the "O_NONBLOCK" +bit of the "mq_flags" can be changed. +

    +If "oldMqStat" is non-null, mq_setattr() will store +the previous message queue attributes at that location (just as +would have been returned by mq_getattr()). +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.4.9 mq_getattr

    + +

    +Function Prototype: +

    +    #include <mqueue.h>
    +    int mq_getattr(mqd_t mqdes, struct mq_attr *mqStat);
    +
    + +

    +Description: This functions gets status information and +attributes associated with the specified message queue. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. +

    + + + + + +
    +

    2.5 Counting Semaphore Interfaces

    +
    + +

    + Semaphores. Semaphores are the basis for + synchronization and mutual exclusion in NuttX. NuttX supports + POSIX semaphores. +

    +

    + Semaphores are the preferred mechanism for gaining exclusive access to a + resource. sched_lock() and sched_unlock() can also be used for this purpose. + However, sched_lock() and sched_unlock() have other undesirable side-affects + in the operation of the system: sched_lock() also prevents higher-priority + tasks from running that do not depend upon the semaphore-managed resource + and, as a result, can adversely affect system response times. +

    +

    + Priority Inversion. + Proper use of semaphores avoids the issues of sched_lock(). + However, consider the following example: +

      +
    1. Some low-priority task, Task C, acquires a semaphore in order to + get exclusive access to a protected resource.
    2. +
    3. Task C is suspended to allow some high-priority task,
    4. + Task A, to execute. +
    5. Task A attempts to acquire the semaphore held by Task C and + gets blocked until Task C relinquishes the semaphore.
    6. +
    7. Task C is allowed to execute again, but gets suspended by some + medium-priority Task B.
    8. +
    +

    + At this point, the high-priority Task A cannot execute until + Task B (and possibly other medium-priority tasks) completes and until + Task C relinquishes the semaphore. In effect, the high-priority task, + Task A behaves as though it were lower in priority than the + low-priority task, Task C! This phenomenon is called priority + inversion. +

    +

    + Some operating systems avoid priority inversion by automatically + increasing the priority of the low-priority Task C (the operable + buzz-word for this behavior is priority inheritance). NuttX + supports this behavior, but only if CONFIG_PRIORITY_INHERITANCE + is defined in your OS configuration file. If CONFIG_PRIORITY_INHERITANCE + is not defined, then it is left to the designer to provide implementations + that will not suffer from priority inversion. + The designer may, as examples: +

    + +

    + Priority Inheritance. + As mentioned, NuttX does support priority inheritance provided that + CONFIG_PRIORITY_INHERITANCE is defined in your OS configuration file. + However, the implementation and configuration of the priority inheritance feature + is sufficiently complex that more needs to be said. + How can a feature that can be described by a single, simple sentence require such + a complex implementation: +

    + +

    + POSIX semaphore interfaces: +

    + + +

    2.5.1 sem_init

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    int sem_init(sem_t *sem, int pshared, unsigned int value);
    +
    + +

    +Description: This function initializes the UN-NAMED semaphore +sem. Following a successful call to sem_init(), the semaphore +may be used in subsequent calls to sem_wait(), sem_post(), and +sem_trywait(). The semaphore remains usable until it is destroyed. +

    +Only sem itself may be used for performing synchronization. The +result of referring to copies of sem in calls to sem_wait(), +sem_trywait(), sem_post(), and sem_destroy(), is +not defined. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. +Differences from the full POSIX implementation include: +

    + +

    2.5.2 sem_destroy

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    int sem_destroy(sem_t *sem);
    +
    + +

    +Description: This function is used to destroy the un-named semaphore +indicated by sem. Only a semaphore that was created using +sem_init() may be destroyed using sem_destroy(). The effect +of calling sem_destroy() with a named semaphore is undefined. The +effect of subsequent use of the semaphore sem is undefined until +sem is re-initialized by another call to sem_init(). +

    +The effect of destroying a semaphore upon which other tasks are currently +blocked is undefined. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.5.3 sem_open

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    sem_t *sem_open(const char *name, int oflag, ...);
    +
    + +

    +Description: This function establishes a connection between +named semaphores and a task. Following a call to sem_open() with +the semaphore name, the task may reference the semaphore associated +with name using the address returned by this call. The semaphore +may be used in subsequent calls to sem_wait(), sem_trywait(), +and sem_post(). The semaphore remains usable until the semaphore +is closed by a successful call to sem_close(). +

    +If a task makes multiple calls to sem_open() with the same name, +then the same semaphore address is returned (provided there have +been no calls to sem_unlink()). +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. +Differences from the full POSIX implementation include: +

    + +

    2.5.4 sem_close

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    int sem_close(sem_t *sem);
    +
    + +

    +Description: This function is called to indicate that the +calling task is finished with the specified named semaphore, sem. +The sem_close() deallocates any system resources allocated by +the system for this named semaphore. +

    +If the semaphore has not been removed with a call to sem_unlink(), +then sem_close() has no effect on the named semaphore. However, +when the named semaphore has been fully unlinked, the semaphore +will vanish when the last task closes it. +

    +Care must be taken to avoid risking the deletion of a semaphore +that another calling task has already locked. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.5.5 sem_unlink

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    int sem_unlink(const char *name);
    +
    + +

    +Description: This function will remove the semaphore named by the +input name parameter. If one or more tasks have the semaphore named by +name open when sem_unlink() is called, destruction of the semaphore will +be postponed until all references have been destroyed by calls to +sem_close(). +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. +Differences from the full POSIX implementation include: +

    + +

    2.5.6 sem_wait

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    int sem_wait(sem_t *sem);
    +
    + +

    +Description: This function attempts to lock the semaphore +referenced by sem. If the semaphore as already locked by another +task, the calling task will not return until it either successfully acquires +the lock or the call is interrupted by a signal. +

    +Input Parameters: +

    + +

    +Returned Value: +

    +

    +If sem_wait returns -1 (ERROR) then the cause of the failure +will be indicated by the thread-specific errno. +The following lists the possible values for errno: +

    +

    +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.5.7 sem_timedwait

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    #include <time.h>
    +    int sem_wait(sem_t *sem, const struct timespec *abstime);
    +
    + +

    +Description: + This function will lock the semaphore referenced by sem as in the sem_wait() function. + However, if the semaphore cannot be locked without waiting for another process or thread to unlock the semaphore by performing a sem_post() function, this wait will be terminated when the specified timeout expires. +

    + The timeout will expire when the absolute time specified by abstime passes, as measured by the clock on which timeouts are based (that is, when the value of that clock equals or exceeds abstime), or if the absolute time specified by abstime has already been passed at the time of the call. + This function attempts to lock the semaphore referenced by sem. + If the semaphore as already locked by another task, the calling task will not return until it either successfully acquires the lock or the call is interrupted by a signal. +

    +Input Parameters: +

    + +

    +Returned Value: +

    +

    +If sem_wait returns -1 (ERROR) then the cause of the failure +will be indicated by the thread-specific errno. +The following lists the possible values for errno: +

    +

    +
  • + EINVAL: + Indicates that the sem input parameter is not valid or the + thread would have blocked, and the abstime parameter specified + a nanoseconds field value less than zero or greater than or + equal to 1000 million. +
  • +
  • + ETIMEDOUT: + The semaphore could not be locked before the specified timeout expired. +
  • +
  • + EDEADLK: + A deadlock condition was detected. +
  • +
  • + EINTR: + Indicates that the wait was interrupt by a signal received by this task. + In this case, the semaphore has not be acquired. +
  • + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Derived from IEEE Std 1003.1d-1999. +

    + +

    2.5.8 sem_trywait

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    int sem_trywait(sem_t *sem);
    +
    + +

    +Description: This function locks the specified semaphore +only if the semaphore is currently not locked. In any event, the call +returns without blocking. +

    +Input Parameters: +

    + +

    +Returned Value: +

    +If sem_wait returns -1 (ERROR) then the cause of the failure +will be indicated by the thread-specific errno. +The following lists the possible values for errno: +

    +

    +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.5.9 sem_post

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    int sem_post(sem_t *sem);
    +
    + +

    +Description: When a task has finished with a semaphore, +it will call sem_post(). This function unlocks the semaphore referenced +by sem by performing the semaphore unlock operation. +

    +If the semaphore value resulting from this operation is positive, then +no tasks were blocked waiting for the semaphore to become unlocked; +The semaphore value is simply incremented. +

    +If the value of the semaphore resulting from this operation is zero, then +on of the tasks blocked waiting for the semaphore will be allowed to +return successfully from its call to sem_wait(). +

    +NOTE: sem_post() may be called from an interrupt handler. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations:. +When called from an interrupt handler, it will appear as though the +interrupt task is the one that is performing the unlock. +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.5.10 sem_getvalue

    + +

    +Function Prototype: +

    +    #include <semaphore.h>
    +    int sem_getvalue(sem_t *sem, int *sval);
    +
    + +

    +Description: This function updates the location referenced +by sval argument to have the value of the semaphore referenced +by sem without effecting the state of the semaphore. The updated +value represents the actual semaphore value that occurred at some +unspecified time during the call, but may not reflect the actual +value of the semaphore when it is returned to the calling task. +

    +If sem is locked, the value return by sem_getvalue() will either +be zero or a negative number whose absolute value represents the +number of tasks waiting for the semaphore. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. +

    + + + + + +
    +

    2.6 Clocks and Timers

    +
    + + + +

    2.6.1 clock_settime

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    int clock_settime(clockid_t clockid, const struct timespec *tp);
    +
    +

    + Description: +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the clock_settime() function will return zero (OK). + Otherwise, an non-zero error number will be returned to indicate the error: +

    + +

    2.6.2 clock_gettime

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    int clock_gettime(clockid_t clockid, struct timespec *tp);
    +
    +

    + Description: +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the clock_gettime() function will return zero (OK). + Otherwise, an non-zero error number will be returned to indicate the error: +

    + +

    2.6.3 clock_getres

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    int clock_getres(clockid_t clockid, struct timespec *res);
    +
    +

    + Description: +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the clock_getres() function will return zero (OK). + Otherwise, an non-zero error number will be returned to indicate the error: +

    + +

    2.6.4 mktime

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    time_t mktime(struct tm *tp);
    +
    +

    + Description: +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the mktime() function will return zero (OK). + Otherwise, an non-zero error number will be returned to indicate the error: +

    + +

    2.6.5 gmtime

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    FAR struct tm *gmtime(FAR const time_t *timep);
    +
    +

    + Description: + Represents GMT date/time in a type struct tm. + This function is not re-entrant. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the gmtime() function will return the pointer to a statically defined instance of struct tm. + Otherwise, a NULL will be returned to indicate the error: +

    + +

    2.6.6 localtime

    + +

    + Description: + Represents local date/time in a type struct tm. + This function is not re-entrant. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + Returned Value: + If successful, the localtime() function will return the pointer to a statically defined instance of struct tm. + Otherwise, a NULL will be returned to indicate the error: +

    + +

    2.6.7 asctime

    +

    + Function Prototype: +

    + +

    + Description: + asctime() convert the time provided in a struct tm to a string representation. + asctime() is not re-entrant. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the asctime() function will return a pointer to a statically defined string holding the converted time. + Otherwise, a NULL will be returned to indicate the error. +

    + +

    2.6.8 ctime

    +

    + Function Prototype: +

    + +

    + Description: + ctime() converts the time provided in seconds since the epoch to a string representation. + ctime() is not re-entrant. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the ctime() function will return the pointer to the converted string. + Otherwise, a NULL will be returned to indicate the error. +

    + +

    2.6.9 gmtime_r

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    struct tm *gmtime_r(const time_t *timep, struct tm *result);
    +
    +

    + Description: + Represents GMT date/time in a type struct tm. + This function is re-entrant. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the gmtime_r() function will return the pointer, result, + provided by the caller. + Otherwise, a NULL will be returned to indicate the error: +

    + +

    2.6.10 localtime_r

    + +

    + Description: + Represents local date/time in a type struct tm. + This function is re-entrant. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + Returned Value: + If successful, the localtime_r() function will return the pointer, result, + provided by the caller. + Otherwise, a NULL will be returned to indicate the error: +

    + +

    2.6.11 asctime_r

    +

    + Function Prototype: +

    + +

    + Description: + asctime_r() converts the time provided in a struct tm to a string representation. + asctime-r() is re-entrant. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the asctime_r() function will return the pointer, buf, provided by the caller. + Otherwise, a NULL will be returned to indicate the error. +

    + +

    2.6.12 ctime_r

    +

    + Function Prototype: +

    + +

    + Description: + ctime_r() converts the time provided in seconds since the epoch to a string representation. + ctime() is re-entrant. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the ctime_r() function will return the pointer, buf, provided by the caller. + Otherwise, a NULL will be returned to indicate the error. +

    + +

    2.6.13 timer_create

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid);
    +
    +

    + Description: + The timer_create() function creates per-thread timer using the specified + clock, clock_id, as the timing base. + The timer_create() function returns, in + the location referenced by timerid, a timer ID of type timer_t used to identify + the timer in timer requests. + This timer ID is unique until the timer is deleted. + The particular clock, clock_id, is defined in <time.h>. + The timer whose ID is returned will be in a disarmed state upon return from + timer_create(). +

    +

    + The evp argument, if non-NULL, points to a sigevent structure. + This structure is allocated by the called and defines the asynchronous notification to occur. + If the evp argument is NULL, the effect is as if the evp argument pointed to + a sigevent structure with the sigev_notify member having the value SIGEV_SIGNAL, + the sigev_signo having a default signal number, and the sigev_value member + having the value of the timer ID. +

    +

    + Each implementation defines a set of clocks that can be used as timing bases + for per-thread timers. All implementations will support a clock_id of + CLOCK_REALTIME. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If the call succeeds, timer_create() will return 0 (OK) and update the + location referenced by timerid to a timer_t, which can be passed to the + other per-thread timer calls. If an error occurs, the function will return + a value of -1 (ERROR) and set errno to indicate the error. +

    + +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. Differences from the full POSIX implementation include: +

    + + +

    2.6.14 timer_delete

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    int timer_delete(timer_t timerid);
    +
    +

    + Description: + The timer_delete() function deletes the specified timer, timerid, previously + created by the timer_create() function. + If the timer is armed when timer_delete() is called, the timer will be automatically disarmed before + removal. + The disposition of pending signals for the deleted timer is unspecified. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the timer_delete() function will return zero (OK). + Otherwise, the function will return a value of -1 (ERROR) and set + errno to indicate the error: +

    + +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. +

    + +

    2.6.15 timer_settime

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
    +                      struct itimerspec *ovalue);
    +
    +

    + Description: + The timer_settime() function sets the time until the next expiration of the + timer specified by timerid from the it_value member of the value argument + and arm the timer if the it_value member of value is non-zero. If the + specified timer was already armed when timer_settime() is called, this call + will reset the time until next expiration to the value specified. If the + it_value member of value is zero, the timer will be disarmed. The effect + of disarming or resetting a timer with pending expiration notifications is + unspecified. +

    +

    + If the flag TIMER_ABSTIME is not set in the argument flags, timer_settime() + will behave as if the time until next expiration is set to be equal to the + interval specified by the it_value member of value. That is, the timer will + expire in it_value nanoseconds from when the call is made. If the flag + TIMER_ABSTIME is set in the argument flags, timer_settime() will behave as + if the time until next expiration is set to be equal to the difference between + the absolute time specified by the it_value member of value and the current + value of the clock associated with timerid. That is, the timer will expire + when the clock reaches the value specified by the it_value member of value. + If the specified time has already passed, the function will succeed and the + expiration notification will be made. +

    +

    + The reload value of the timer will be set to the value specified by the + it_interval member of value. When a timer is armed with a non-zero + it_interval, a periodic (or repetitive) timer is specified. +

    +

    + Time values that are between two consecutive non-negative integer multiples + of the resolution of the specified timer will be rounded up to the larger + multiple of the resolution. Quantization error will not cause the timer to + expire earlier than the rounded time value. +

    +

    + If the argument ovalue is not NULL, the timer_settime() function will store, + in the location referenced by ovalue, a value representing the previous + amount of time before the timer would have expired, or zero if the timer was + disarmed, together with the previous timer reload value. Timers will not + expire before their scheduled time. +

    + NOTE:At present, the ovalue argument is ignored. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If the timer_gettime() succeeds, a value of 0 (OK) will be returned. + If an error occurs, the value -1 (ERROR) will be returned, and + errno set to indicate the error. +

    + +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. Differences from the full POSIX implementation include: +

    + + +

    2.6.16 timer_gettime

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    int timer_gettime(timer_t timerid, struct itimerspec *value);
    +
    +

    + Description: + The timer_gettime() function will store the amount of time until the + specified timer, timerid, expires and the reload value of the timer into the + space pointed to by the value argument. The it_value member of this structure + will contain the amount of time before the timer expires, or zero if the timer + is disarmed. This value is returned as the interval until timer expiration, + even if the timer was armed with absolute time. The it_interval member of + value will contain the reload value last set by timer_settime(). +

    +

    + Due to the asynchronous operation of this function, the time reported + by this function could be significantly more than that actual time + remaining on the timer at any time. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If successful, the timer_gettime() function will return zero (OK). + Otherwise, an non-zero error number will be returned to indicate the error: +

    + +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. +

    + +

    2.6.17 timer_getoverrun

    +

    + Function Prototype: +

    +
    +    #include <time.h>
    +    int timer_getoverrun(timer_t timerid);
    +
    +

    + Description: + Only a single signal will be queued to the process for a given timer at any + point in time. When a timer for which a signal is still pending expires, no + signal will be queued, and a timer overrun will occur. When a timer + expiration signal is delivered to or accepted by a process, if the + implementation supports the Realtime Signals Extension, the + timer_getoverrun() function will return the timer expiration overrun count for + the specified timer. The overrun count returned contains the number of extra + timer expirations that occurred between the time the signal was generated + (queued) and when it was delivered or accepted, up to but not including an + implementation-defined maximum of DELAYTIMER_MAX. If the number of such + extra expirations is greater than or equal to DELAYTIMER_MAX, then the + overrun count will be set to DELAYTIMER_MAX. The value returned by + timer_getoverrun() will apply to the most recent expiration signal delivery + or acceptance for the timer. If no expiration signal has been delivered + for the timer, or if the Realtime Signals Extension is not supported, the + return value of timer_getoverrun() is unspecified. +

    +

    + NOTE: This interface is not currently implemented in NuttX. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + If the timer_getoverrun() function succeeds, it will return the timer + expiration overrun count as explained above. timer_getoverrun() will fail if: +

    + +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. Differences from the full POSIX implementation include: +

    + + +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. +

    + +

    2.6.18 gettimeofday

    +

    + Function Prototype: +

    +
    +    #include <sys/time.h>
    +    int gettimeofday(struct timeval *tp, void *tzp);
    +
    +

    + Description: + This implementation of gettimeofday() is simply a thin wrapper around + clock_gettime(). + It simply calls clock_gettime() using the CLOCK_REALTIME timer and + converts the result to the required struct timeval. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + See clock_gettime(). +

    + + + + + +
    +

    2.7 Signal Interfaces

    +
    + +

    + Tasks and Signals. + NuttX provides signal interfaces for tasks and pthreads. + Signals are used toalter the flow control of tasks by communicating asynchronous events within or between task contexts. + Any task or interrupt handler can post (or send) a signal to a particular task using its task ID. + The task being signaled will execute task-specified signal handler function the next time that the task has priority. + The signal handler is a user-supplied function that is bound to a specific signal and performs whatever actions are necessary whenever the signal is received. +

    +

    + There are no predefined actions for any signal. + The default action for all signals (i.e., when no signal handler has been supplied by the user) is to ignore the signal. + In this sense, all NuttX are real time signals. +

    +

    + Tasks may also suspend themselves and wait until a signal is received. +

    +

    + Tasks Groups. + NuttX supports both tasks and pthreads. + The primary difference between tasks and pthreads is the tasks are much more independent. + Tasks can create pthreads and those pthreads will share the resources of the task. + The main task and its children pthreads together are referred as a task group. + A task group is used in NuttX to emulate a POSIX process. +

    +
    + NOTE: + Behavior of features related to task groups depend of NuttX configuration settings. + See the NuttX Threading Wiki page and the Tasks vs. Threads FAQ for additional information on tasks and threads in NuttX. +
    +

    + Signalling Multi-threaded Task Groups. + The behavior of signals in the multi-thread task group is complex. + NuttX emulates a process model with task groups and follows the POSIX rules for signalling behavior. + Normally when you signal the task group you would signal using the task ID of the main task that created the group (in practice, a different task should not know the IDs of the internal threads created within the task group); that ID is remembered by the task group (even if the main task thread exits). +

    +

    + Here are some of the things that should happen when you signal a multi-threaded task group: +

    + +

    + You can mask out that signal using ''sigprocmask()'' (or ''pthread_sigmask()''). + That signal will then be effectively disabled and will never be received in those threads that have the signal masked. + On creation of a new thread, the new thread will inherit the signal mask of the parent thread that created it. + So you if block signal signals on one thread then create new threads, those signals will also be blocked in the new threads as well. +

    +

    + You can control which thread receives the signal by controlling the signal mask. + You can, for example, create a single thread whose sole purpose it is to catch a particular signal and respond to it: Simply block the signal in the main task; then the signal will be blocked in all of the pthreads in the group too. In the one "signal processing" pthread, enable the blocked signal. This thread will then be only thread that will receive the signal. +

    +

    + Signal Interfaces. + The following signal handling interfaces are provided by NuttX: +

    + + +

    2.7.1 sigemptyset

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigemptyset(sigset_t *set);
    +
    + +

    +Description: This function initializes the signal set specified +by set such that all signals are excluded. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.7.2 sigfillset

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigfillset(sigset_t *set);
    +
    + +

    +Description: This function initializes the signal set specified +by set such that all signals are included. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.7.3 sigaddset

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigaddset(sigset_t *set, int signo);
    +
    + +

    +Description: This function adds the signal specified by +signo to the signal set specified by set. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.7.4 sigdelset

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigdelset(sigset_t *set, int signo);
    +
    + +

    +Description: This function deletes the signal specified +by signo from the signal set specified by set. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.7.5 sigismember

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int  sigismember(const sigset_t *set, int signo);
    +
    + +

    +Description: This function tests whether the signal specified +by signo is a member of the set specified by set. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.7.6 sigaction

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigaction(int signo, const struct sigaction *act,
    +                  struct sigaction *oact);
    +
    + +

    +Description: This function allows the calling task to +examine and/or specify the action to be associated with a specific +signal. +

    +The structure sigaction, used to describe an action to be taken, is defined +to include the following members: +

    +

    +If the argument act is not NULL, it points to a structure specifying the +action to be associated with the specified signal. If the argument oact +is not NULL, the action previously associated with the signal is stored +in the location pointed to by the argument oact. If the argument act is +NULL, signal handling is unchanged by this function call; thus, the call +can be used to inquire about the current handling of a given signal. +

    +When a signal is caught by a signal-catching function installed by the +sigaction() function, a new signal mask is calculated and installed for +the duration of the signal-catching function. This mask is formed by taking +the union of the current signal mask and the value of the sa_mask for the +signal being delivered, and then including the signal being delivered. If +and when the signal handler returns, the original signal mask is restored. +

    +Signal catching functions execute in the same address environment as the +task that called sigaction() to install the signal-catching function. +

    +Once an action is installed for a specific signal, it remains installed +until another action is explicitly requested by another call to +sigaction(). +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. +Differences from the POSIX implementation include: +

    + +

    2.7.7 sigignore

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigignore(int signo);
    +
    + +

    +Description: The sigignore() function will set the disposition of signo to SIG_IGN. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    2.7.8 sigset

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    void (*sigset(int signo, void (*disp)(int)))(int);
    +
    + +

    +Description: + The sigset() function will modify signal dispositions. + The signo argument specifies the signal. + The disp argument specifies the signal's disposition, which may be SIG_DFL, SIG_IGN, or the address of a signal handler. + If disp is the address of a signal handler, the system will add signo to the calling process' signal mask before executing the signal handler; when the signal handler returns, the system will restore the calling process' signal mask to its state prior to the delivery of the signal. + signo will be removed from the calling process' signal mask. +

    +

    + NOTE: The value SIG_HOLD for disp is not currently supported. +

    +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    2.7.9 sigprocmask

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigprocmask(int how, const sigset_t *set, sigset_t *oset);
    +
    + +

    +Description: This function allows the calling task to +examine and/or change its signal mask. If the set is not NULL, +then it points to a set of signals to be used to change the currently +blocked set. The value of how indicates the manner in which the +set is changed. +

    +If there are any pending unblocked signals after the call to sigprocmask(), +those signals will be delivered before sigprocmask() returns. +

    +If sigprocmask() fails, the signal mask of the task is not changed. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.7.10 sighold

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sighold(int signo);
    +
    + +

    +Description: The sighold() function will add signo to the calling process' signal mask +

    +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    2.7.11 sigrelse

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigrelse(int signo);
    +
    + +

    +Description: The sighold() function will remove signo from the calling process' signal mask +

    +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    2.7.12 sigpending

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigpending(sigset_t *set);
    +
    + +

    +Description: This function stores the returns the set of +signals that are blocked for delivery and that are pending for +the calling task in the space pointed to by set. +

    +If the task receiving a signal has the signal blocked via its +sigprocmask, the signal will pend until it is unmasked. Only one pending +signal (for a given signo) is retained by the system. This is consistent +with POSIX which states: "If a subsequent occurrence of a pending +signal is generated, it is implementation defined as to whether the signal +is delivered more than once." +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.7.13 sigsuspend

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigsuspend(const sigset_t *set);
    +
    + +

    +Description: The sigsuspend() function replaces the signal mask +with the set of signals pointed to by the argument set and then suspends +the task until delivery of a signal to the task. +

    +If the effect of the set argument is to unblock a pending signal, then +no wait is performed. +

    +The original signal mask is restored when sigsuspend() returns. +

    +Waiting for an empty signal set stops a task without freeing any +resources (a very bad idea). +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. +Differences from the POSIX specification include: +

    + +

    2.7.14 sigpause

    +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigpause(int signo);
    +
    + +

    +Description: The sigpause()) function will remove signo) from the calling process' signal mask and suspend the calling process until a signal is received. +The sigpause()) function will restore the process' signal mask to its original state before returning. +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    2.7.15 sigwaitinfo

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigwaitinfo(const sigset_t *set, struct siginfo *info);
    +
    + +

    +Description: This function is equivalent to sigtimedwait() +with a NULL timeout parameter. (see below). +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. + +

    2.7.16 sigtimedwait

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigtimedwait(const sigset_t *set, struct siginfo *info,
    +                     const struct timespec *timeout);
    +
    + +

    +Description: This function selects the pending signal set +specified by the argument set. If multiple signals are pending in set, +it will remove and return the lowest numbered one. If no signals in set +are pending at the time of the call, the calling task will be suspended +until one of the signals in set becomes pending OR until the task +interrupted by an unblocked signal OR until the time interval specified by +timeout (if any), has expired. If timeout is NULL, then the timeout interval +is forever. +

    +If the info argument is non-NULL, the selected signal number is +stored in the si_signo member and the cause of the signal is store +in the si_code member. The content of si_value is only meaningful +if the signal was generated by sigqueue(). The following values +for si_code are defined in signal.h: +

    + +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. +Differences from the POSIX interface include: +

    + +

    2.7.17 sigqueue

    + +

    +Function Prototype: +

    +    #include <signal.h>
    +    int sigqueue (int tid, int signo, union sigval value);
    +
    + +

    +Description: This function sends the signal specified by +signo with the signal parameter value to the task specified +by tid. +

    +If the receiving task has the signal blocked via its sigprocmask, +the signal will pend until it is unmasked. Only one pending signal +(for a given signo) is retained by the system. This is consistent with +POSIX which states: "If a subsequent occurrence of a pending signal +is generated, it is implementation defined as to whether the signal +is delivered more than once." +

    +Input Parameters: +

    + +

    +Returned Value: +

    + +

    +Assumptions/Limitations: +

    + POSIX Compatibility: Comparable to the POSIX +interface of the same name. +Differences from the POSIX interface include: +

    + +

    2.7.18 kill

    + +

    +Function Prototype: +

    +   #include <sys/types.h>
    +   #include <signal.h>
    +   int kill(pid_t pid, int sig);
    +
    + +

    +Description: + The kill() system call can be used to send any signal to + any task. +

    +

    + If the receiving task has the signal blocked via its sigprocmask, + the signal will pend until it is unmasked. Only one pending signal + (for a given signo) is retained by the system. This is consistent with + POSIX which states: "If a subsequent occurrence of a pending signal + is generated, it is implementation defined as to whether the signal + is delivered more than once." +

    +

    +Input Parameters: +

    + +

    + Returned Value: +

    +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. + Differences from the POSIX interface include: +

    + + +

    2.7.19 pause

    + +

    +Function Prototype: +

    +   #include <unistd.h>
    +   int pause(void);
    +
    + +

    +Description: + The pause() function will suspend the calling thread until delivery of a non-blocked signal. +

    +Input Parameters: + + +

    + Returned Value: + Since pause() suspends thread execution indefinitely unless interrupted a signal, there is no successful completion return value. + A value of -1 (ERROR will always be returned and errno set to indicate the error (EINTR). +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + In the POSIX description of this function is the pause() function will suspend the calling thread until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process. + This implementation only waits for any non-blocked signal to be received. +

    + + + + + +
    +

    2.8 Pthread Interfaces

    +
    + +

    + NuttX does not support processes in the way that, say, Linux does. + NuttX only supports simple threads or tasks running within the same address space. + However, NuttX does support the concept of a task group. + A task group is the functional analog of a process: + It is a group that consists of the main task thread and of all of the pthreads created by the main thread or any of the other pthreads within the task broup. + Members of a task group share certain resources such as environment variables, file descriptors, FILE streams, sockets, pthread keys and open message queues. +

    +
    + NOTE: + Behavior of features related to task groups depend of NuttX configuration settings. + See the NuttX Threading Wiki page and the Tasks vs. Threads FAQ for additional information on tasks and threads in NuttX. +
    +

    + The following pthread interfaces are supported in some form by NuttX: +

    + +

    + No support for the following pthread interfaces is provided by NuttX: +

    + + +

    2.8.1 pthread_attr_init

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_attr_init(pthread_attr_t *attr);
    +
    +

    +Description: +Initializes a thread attributes object (attr) with default values +for all of the individual attributes used by the implementation. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_init() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. +

    +

    2.8.2 pthread_attr_destroy

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_attr_destroy(pthread_attr_t *attr);
    +
    +

    +Description: +An attributes object can be deleted when it is no longer needed. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_destroy() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. +

    +

    2.8.3 pthread_attr_setschedpolicy

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_setschedpolicy() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.4 pthread_attr_getschedpolicy

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_attr_getschedpolicy(pthread_attr_t *attr, int *policy);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_getschedpolicy() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.5 pthread_attr_getschedpolicy

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_attr_setschedparam(pthread_attr_t *attr,
    +                                   const struct sched_param *param);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_getschedpolicy() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.6 pthread_attr_getschedparam

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_attr_getschedparam(pthread_attr_t *attr,
    +                                   struct sched_param *param);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_getschedparam() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.7 pthread_attr_setinheritsched

    +

    +Function Prototype: +

    +

    +   #include <pthread.h>
    +    int pthread_attr_setinheritsched(pthread_attr_t *attr,
    +                                     int inheritsched);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_setinheritsched() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. +

    +

    2.8.8 pthread_attr_getinheritsched

    +

    +Function Prototype: +

    +

    +   #include <pthread.h>
    +     int pthread_attr_getinheritsched(const pthread_attr_t *attr,
    +                                      int *inheritsched);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_getinheritsched() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.9 pthread_attr_setstacksize

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_attr_setstacksize(pthread_attr_t *attr, long stacksize);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_setstacksize() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.10 pthread_attr_getstacksize

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_attr_getstacksize(pthread_attr_t *attr, long *stackaddr);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_attr_getstacksize() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.11 pthread_create

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_create(pthread_t *thread, pthread_attr_t *attr,
    +                       pthread_startroutine_t startRoutine,
    +                       pthread_addr_t arg);
    +
    +

    +Description: +To create a thread object and runnable thread, a routine +must be specified as the new thread's start routine. An +argument may be passed to this routine, as an untyped +address; an untyped address may also be returned as the +routine's value. An attributes object may be used to +specify details about the kind of thread being created. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_create() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.12 pthread_detach

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_detach(pthread_t thread);
    +
    +

    +Description: +A thread object may be "detached" to specify that the +return value and completion status will not be requested. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_detach() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.13 pthread_exit

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    void pthread_exit(pthread_addr_t pvValue);
    +
    +

    +Description: +A thread may terminate it's own execution. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_exit() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.14 pthread_cancel

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_cancel(pthread_t thread);
    +
    +

    +Description: + +

    The pthread_cancel() function will request that thread +be canceled. The target thread's cancelability state determines +when the cancellation takes effect. When the +cancellation is acted on, thread will be terminated.

    + +

    When cancelability is disabled, all cancels are held pending +in the target thread until the thread changes the cancelability. +When cancelability is deferred, all cancels are held pending in +the target thread until the thread changes the cancelability or +calls pthread_testcancel().

    + +

    Cancelability is asynchronous; all cancels are acted upon +immediately (when enable), interrupting the thread with its processing.

    + +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_cancel() function will return zero (OK). +Otherwise, an error number will be returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. Except:

    + + +

    2.8.15 pthread_setcancelstate

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_setcancelstate(int state, int *oldstate);
    +
    +

    +Description: +

    The pthread_setcancelstate() function atomically +sets both the calling thread's cancelability state to the indicated +state and returns the previous cancelability state at the location +referenced by oldstate. +Legal values for state are PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DISABLE.<.li> + +

    Any pending thread cancellation may occur at the time that the +cancellation state is set to PTHREAD_CANCEL_ENABLE.

    + +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_setcancelstate() function will return +zero (OK). Otherwise, an error number will be returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.16 pthread_testcancelstate

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_setcancelstate(void);
    +
    +

    +Description: +

    NOT SUPPORTED +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_setcancelstate() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.17 pthread_join

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_join(pthread_t thread, pthread_addr_t *ppvValue);
    +
    +

    +Description: +A thread can await termination of another thread and retrieve +the return value of the thread. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_join() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.18 pthread_yield

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    void pthread_yield(void);
    +
    +

    +Description: +A thread may tell the scheduler that its processor can be +made available. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_yield() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.19 pthread_self

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    pthread_t pthread_self(void);
    +
    +

    +Description: +A thread may obtain a copy of its own thread handle. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_self() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.20 pthread_getschedparam

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_getschedparam(pthread_t thread, int *policy,
    +                              struct sched_param *param);
    +
    +

    + Description: + The pthread_getschedparam() functions will get the + scheduling policy and parameters of threads. + For SCHED_FIFO and SCHED_RR, the only + required member of the sched_param structure is the + priority sched_priority. +

    +

    + The pthread_getschedparam() function will retrieve the + scheduling policy and scheduling parameters for the thread whose thread + ID is given by thread and will store those values in + policy and param, respectively. + The priority value returned from pthread_getschedparam() + will be the value specified by the most recent pthread_setschedparam(), + pthread_setschedprio(), or pthread_create() call + affecting the target thread. + It will not reflect any temporary adjustments to its priority (such as might + result of any priority inheritance, for example). +

    +

    + The policy parameter may have the value SCHED_FIFO, SCHED_RR, or SCHED_SPORADIC. + SCHED_RR requires the configuration setting CONFIG_RR_INTERVAL > 0; + SCHED_SPORADIC requires the configuration setting CONFIG_SCHED_SPORADIC=y. + (SCHED_OTHER and non-standard scheduler policies, in particular, are not supported). + The SCHED_FIFO and SCHED_RR policies will have a single + scheduling parameter: +

    + + +

    + The SCHED_SPORADIC policy has four additional scheduling parameters: +

    + +

    + Input Parameters: +

    + +

    + Returned Value: + 0 (OK) if successful. + Otherwise, the error code ESRCH if the value specified by + thread does not refer to an existing thread. +

    +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. +

    + +

    2.8.21 pthread_setschedparam

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_setschedparam(pthread_t thread, int policy,
    +                              const struct sched_param *param);
    +
    +

    + Description: + The pthread_setschedparam() functions will set the scheduling policy + and parameters of threads. + For SCHED_FIFO and SCHED_RR, the only required member + of the sched_param structure is the priority sched_priority. +

    +

    + The pthread_setschedparam() function will set the scheduling policy + and associated scheduling parameters for the thread whose thread ID is given by + thread to the policy and associated parameters provided in + policy and param, respectively. +

    +

    + The policy parameter may have the value SCHED_FIFO or SCHED_RR. + (SCHED_OTHER and SCHED_SPORADIC, in particular, are not supported). + The SCHED_FIFO and SCHED_RR policies will have a single + scheduling parameter, sched_priority. +

    +

    + If the pthread_setschedparam() function fails, the scheduling + parameters will not be changed for the target thread. +

    +

    + Input Parameters: +

    + +

    + Returned Value: +

    +

    + If successful, the pthread_setschedparam() function will return + zero (OK). Otherwise, an error number will be + returned to indicate the error: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: + Comparable to the POSIX interface of the same name. +

    + +

    2.8.22 pthread_key_create

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_key_create(pthread_key_t *key, void (*destructor)(void*))
    +
    +

    +Description: +

    +This function creates a thread-specific data key visible +to all threads in the system. Although the same key value +may be used by different threads, the values bound to +the key by pthread_setspecific() are maintained on a +per-thread basis and persist for the life of the calling +thread. +

    +Upon key creation, the value NULL will be associated with +the new key in all active threads. Upon thread +creation, the value NULL will be associated with all +defined keys in the new thread. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_key_create() function will +store the newly created key value at *key and return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. +

    + +

    2.8.23 pthread_setspecific

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_setspecific(pthread_key_t key, void *value)
    +
    +

    +Description: +

    +The pthread_setspecific() function associates a thread- +specific value with a key obtained via a previous call +to pthread_key_create(). Different threads may bind +different values to the same key. These values are +typically pointers to blocks of dynamically allocated +memory that have been reserved for use by the calling +thread. +

    +The effect of calling pthread_setspecific() with a key value +not obtained from pthread_key_create() or after a key has been +deleted with pthread_key_delete() is undefined. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, pthread_setspecific() will return zero (OK). +Otherwise, an error number will be returned: +

    +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. +

    + +

    2.8.24 pthread_getspecific

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    void *pthread_getspecific(pthread_key_t key)
    +
    +

    +Description: +

    +The pthread_getspecific() function returns the value +currently bound to the specified key on behalf of the +calling thread. +

    +The effect of calling pthread_getspecific() with a key value +not obtained from pthread_key_create() or after a key has been +deleted with pthread_key_delete() is undefined. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +The function pthread_getspecific() returns the thread- +specific data associated with the given key. If no +thread specific data is associated with the key, then +the value NULL is returned. +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. +

    + +

    2.8.25 pthread_key_delete

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_key_delete(pthread_key_t key)
    +
    +

    +Description: +

    +This POSIX function should delete a thread-specific data +key previously returned by pthread_key_create(). However, +this function does nothing in the present implementation. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.26 pthread_mutexattr_init

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_mutexattr_init(pthread_mutexattr_t *attr);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutexattr_init() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.27 pthread_mutexattr_destroy

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutexattr_destroy() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.28 pthread_mutexattr_getpshared

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr,
    +                                     int *pshared);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutexattr_getpshared() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.29 pthread_mutexattr_setpshared

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +   int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
    +                                    int pshared);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutexattr_setpshared() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.30 pthread_mutexattr_gettype

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +#ifdef CONFIG_MUTEX_TYPES
    +    int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type);
    +#endif
    +
    +

    +Description: Return the mutex type from the mutex attributes. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutexattr_settype() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX interface of the same name. + +

    2.8.31 pthread_mutexattr_settype

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +#ifdef CONFIG_MUTEX_TYPES
    +    int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
    +#endif
    +
    +

    +Description: Set the mutex type in the mutex attributes. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutexattr_settype() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX interface of the same name. + +

    2.8.32 pthread_mutex_init

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_mutex_init(pthread_mutex_t *mutex,
    +                           pthread_mutexattr_t *attr);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutex_init() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.33 pthread_mutex_destroy

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_mutex_destroy(pthread_mutex_t *mutex);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutex_destroy() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.34 pthread_mutex_lock

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_mutex_lock(pthread_mutex_t *mutex);
    +
    +

    +Description: + The mutex object referenced by mutex is locked by calling pthread_mutex_lock(). + If the mutex is already locked, the calling thread blocks until the mutex + becomes available. This operation returns with the mutex object referenced + by mutex in the locked state with the calling thread as its owner. +

    +

    + If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection is not provided. + Attempting to re-lock the mutex causes deadlock. If a thread attempts to unlock + a mutex that it has not locked or a mutex which is unlocked, undefined behavior + results. +

    +

    + In NuttX, PTHREAD_MUTEX_NORMAL is not implemented. Rather, the behavior described + for PTHREAD_MUTEX_ERRORCHECK is the normal behavior. +

    +

    + If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking is provided. + If a thread attempts to re-lock a mutex that it has already locked, an error + will be returned. If a thread attempts to unlock a mutex that it has not + locked or a mutex which is unlocked, an error will be returned. +

    +

    + If the mutex type is PTHREAD_MUTEX_RECURSIVE, then the mutex maintains the concept + of a lock count. When a thread successfully acquires a mutex for the first time, + the lock count is set to one. Every time a thread re-locks this mutex, the lock count + is incremented by one. Each time the thread unlocks the mutex, the lock count is + decremented by one. When the lock count reaches zero, the mutex becomes available + for other threads to acquire. If a thread attempts to unlock a mutex that it has + not locked or a mutex which is unlocked, an error will be returned. +

    +

    + If a signal is delivered to a thread waiting for a mutex, upon return from + the signal handler the thread resumes waiting for the mutex as if it was + not interrupted. +

    +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutex_lock() function will return zero (OK). +Otherwise, an error number will be returned to indicate the error: +

    +

    +

    Note that this function will never return the error EINTR.

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.35 pthread_mutex_trylock

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_mutex_trylock(pthread_mutex_t *mutex);
    +
    +

    +Description: + The function pthread_mutex_trylock() is identical to pthread_mutex_lock() + except that if the mutex object referenced by mutex is currently locked + (by any thread, including the current thread), the call returns immediately + with the errno EBUSY. +

    + If a signal is delivered to a thread waiting for a mutex, upon return from + the signal handler the thread resumes waiting for the mutex as if it was + not interrupted. +

    +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutex_trylock() function will return zero (OK). +Otherwise, an error number will be returned to indicate the error: +

    +

    +

    Note that this function will never return the error EINTR.

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.36 pthread_mutex_unlock

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_mutex_unlock(pthread_mutex_t *mutex);
    +
    +

    +Description: +

    + The pthread_mutex_unlock() function releases the mutex object referenced + by mutex. The manner in which a mutex is released is dependent upon the + mutex's type attribute. If there are threads blocked on the mutex object + referenced by mutex when pthread_mutex_unlock() is called, resulting in + the mutex becoming available, the scheduling policy is used to determine + which thread will acquire the mutex. (In the case of PTHREAD_MUTEX_RECURSIVE + mutexes, the mutex becomes available when the count reaches zero and the + calling thread no longer has any locks on this mutex). +

    +

    + If a signal is delivered to a thread waiting for a mutex, upon return from + the signal handler the thread resumes waiting for the mutex as if it was + not interrupted. +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_mutex_unlock() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +

    Note that this function will never return the error EINTR.

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.37 pthread_condattr_init

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_condattr_init(pthread_condattr_t *attr);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_condattr_init() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.38 pthread_condattr_destroy

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_condattr_destroy(pthread_condattr_t *attr);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_condattr_destroy() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.39 pthread_cond_init

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_cond_init() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.40 pthread_cond_destroy

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_cond_destroy(pthread_cond_t *cond);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_cond_destroy() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.41 pthread_cond_broadcast

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_cond_broadcast(pthread_cond_t *cond);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_cond_broadcast() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.42 pthread_cond_signal

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_cond_signal(pthread_cond_t *dond);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    +Returned Value: +

    +If successful, the pthread_cond_signal() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.43 pthread_cond_wait

    +

    +Function Prototype: +

    +

    +    #include <pthread.h>
    +    int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
    +
    +

    +Description: +

    +Input Parameters: +

    +

    +

    + Returned Value: +

    +If successful, the pthread_cond_wait() function will return +zero (OK). Otherwise, an error number will be +returned to indicate the error: +

    +

    +Assumptions/Limitations: +

    +POSIX Compatibility: Comparable to the POSIX +interface of the same name. + +

    2.8.44 pthread_cond_timedwait

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
    +                               const struct timespec *abstime);
    +
    +

    + Description: +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: +

    +

    + If successful, the pthread_cond_timedwait() function will return + zero (OK). Otherwise, an error number will be + returned to indicate the error: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.8.45 pthread_barrierattr_init

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_barrierattr_init(FAR pthread_barrierattr_t *attr);
    +
    +

    + Description: + The pthread_barrierattr_init() function will initialize a barrier + attribute object attr with the default value for all of the attributes + defined by the implementation. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + 0 (OK) on success or EINVAL if attr is invalid. +

    +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.8.46 pthread_barrierattr_destroy

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_barrierattr_destroy(FAR pthread_barrierattr_t *attr);
    +
    +

    + Description: + The pthread_barrierattr_destroy() function will destroy a barrier attributes object. + A destroyed attributes object can be reinitialized using pthread_barrierattr_init(); + the results of otherwise referencing the object after it has been destroyed are undefined. +

    +

    + Input Parameters: +

    + +

    + Returned Value: 0 (OK) on success or EINVAL if attr is invalid. +

    +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.8.47 pthread_barrierattr_setpshared

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr, int pshared);
    +
    +

    + Description: + The process-shared attribute is set to PTHREAD_PROCESS_SHARED to permit + a barrier to be operated upon by any thread that has access to the memory where the + barrier is allocated. + If the process-shared attribute is PTHREAD_PROCESS_PRIVATE, the barrier can + only be operated upon by threads created within the same process as the thread that + initialized the barrier. + If threads of different processes attempt to operate on such a barrier, the behavior is undefined. + The default value of the attribute is PTHREAD_PROCESS_PRIVATE. +

    +

    + Input Parameters: +

    + +

    + Returned Value: 0 (OK) on success or EINVAL if either + attr is invalid or pshared is not one of + PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE. +

    +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.8.48 pthread_barrierattr_getpshared

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr, FAR int *pshared);
    +
    +

    + Description: + The pthread_barrierattr_getpshared() function will obtain the value of the + process-shared attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: 0 (OK) on success or EINVAL if + either attr or pshared is invalid. +

    +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.8.49 pthread_barrier_init

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_barrier_init(FAR pthread_barrier_t *barrier,
    +                             FAR const pthread_barrierattr_t *attr, unsigned int count);
    +
    +

    + Description: + The pthread_barrier_init() function allocates any resources required to + use the barrier referenced by barrier and initialized the barrier with + the attributes referenced by attr. + If attr is NULL, the default barrier attributes will be used. + The results are undefined if pthread_barrier_init() is called when any + thread is blocked on the barrier. + The results are undefined if a barrier is used without first being initialized. + The results are undefined if pthread_barrier_init() is called specifying + an already initialized barrier. +

    +

    + Input Parameters: +

    + +

    + Returned Value:0 (OK) on success or on of the following error numbers: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.8.50 pthread_barrier_destroy

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_barrier_destroy(FAR pthread_barrier_t *barrier);
    +
    +

    + Description: + The pthread_barrier_destroy() function destroys the barrier referenced + by barrie and releases any resources used by the barrier. + The effect of subsequent use of the barrier is undefined until the barrier is + reinitialized by another call to pthread_barrier_init(). + The results are undefined if pthread_barrier_destroy() is called when + any thread is blocked on the barrier, or if this function is called with an + uninitialized barrier. +

    +

    + Input Parameters: +

    + +

    + Returned Value: 0 (OK) on success or on of the following error numbers: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.8.51 pthread_barrier_wait

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_barrier_wait(FAR pthread_barrier_t *barrier);
    +
    +

    + Description: + The pthread_barrier_wait() function synchronizes participating + threads at the barrier referenced by barrier. + The calling thread is blocked until the required number of threads have called + pthread_barrier_wait() specifying the same barrier. + When the required number of threads have called pthread_barrier_wait() + specifying the barrier, the constant PTHREAD_BARRIER_SERIAL_THREAD + will be returned to one unspecified thread and zero will be returned to each of + the remaining threads. + At this point, the barrier will be reset to the state it had as a result of the most + recent pthread_barrier_init() function that referenced it. +

    +

    + The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in + pthread.h and its value must be distinct from any other value + returned by pthread_barrier_wait(). +

    +

    + The results are undefined if this function is called with an uninitialized barrier. +

    +

    + If a signal is delivered to a thread blocked on a barrier, upon return from the + signal handler the thread will resume waiting at the barrier if the barrier wait + has not completed. + Otherwise, the thread will continue as normal from the completed barrier wait. + Until the thread in the signal handler returns from it, it is unspecified whether + other threads may proceed past the barrier once they have all reached it. +

    +

    + A thread that has blocked on a barrier will not prevent any unblocked thread that + is eligible to use the same processing resources from eventually making forward + progress in its execution. + Eligibility for processing resources will be determined by the scheduling policy. +

    +

    + Input Parameters: +

    + +

    + Returned Value: 0 (OK) on success or EINVAL if the barrier is not valid. +

    +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + + +

    2.8.52 pthread_once

    +

    + Function Prototype: +

    +
    +    #include <pthread.h>
    +    int pthread_once(FAR pthread_once_t *once_control, CODE void (*init_routine)(void));
    +
    +

    + Description: + The first call to pthread_once() by any thread with a given + once_control, will call the init_routine() with no arguments. + Subsequent calls to pthread_once() with the same once_control will have no effect. + On return from pthread_once(), init_routine() will have completed. +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: + 0 (OK) on success or EINVAL if either once_control or init_routine are invalid. +

    +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.8.53 pthread_kill

    +

    + Function Prototype: +

    +
    +    #include <signal.h>
    +    #include <pthread.h>
    +    int pthread_kill(pthread_t thread, int signo)
    +
    +

    + Description: + The pthread_kill() system call can be used to send any + signal to a thread. See kill() for further information + as this is just a simple wrapper around the kill() + function. +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: +

    +

    + On success, the signal was sent and zero is returned. + On error one of the following error numbers is returned. +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + +

    2.8.54 pthread_sigmask

    +

    + Function Prototype: +

    +
    +    #include <signal.h>
    +    #include <pthread.h>
    +    int pthread_sigmask(int how, FAR const sigset_t *set, FAR sigset_t *oset);
    +
    +

    + Description: + This function is a simple wrapper around sigprocmask(). + See the sigprocmask() function description for further information. +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: +

    + +

    + Assumptions/Limitations: +

    +

    + POSIX Compatibility: Comparable to the POSIX interface of the same name. +

    + + + + + +
    +

    2.9 Environment Variables

    +
    + +

    Overview. + NuttX supports environment variables that can be used to control the behavior of programs. + In the spirit of NuttX the environment variable behavior attempts to emulate the behavior of + environment variables in the multi-processing OS: +

    + +

    Programming Interfaces. + The following environment variable programming interfaces are provided by Nuttx and are + described in detail in the following paragraphs. +

    + +

    Disabling Environment Variable Support. + All support for environment variables can be disabled by setting CONFIG_DISABLE_ENVIRON + in the board configuration file. +

    + +

    2.9.1 getenv

    +

    + Function Prototype: +

    +
    +  #include <stdlib.h>
    +  FAR char *getenv(const char *name);
    +
    +

    + Description: + The getenv() function searches the environment list for a string that + matches the string pointed to by name. +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: + The value of the variable (read-only) or NULL on failure. +

    + +

    2.9.2 putenv

    +

    + Function Prototype: +

    +
    +  #include <stdlib.h>
    +  int putenv(char *string);
    +
    +

    + Description: + The putenv() function adds or changes the value of environment variables. + The argument string is of the form name=value. If name does not already + exist in the environment, then string is added to the environment. If + name does exist, then the value of name in the environment is changed to + value. +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: + Zero on success. +

    + +

    2.9.3 clearenv

    +

    + Function Prototype: +

    +
    +  #include <stdlib.h>
    +  int clearenv(void);
    +
    +

    + Description: + The clearenv() function clears the environment of all name-value pairs + and sets the value of the external variable environ to NULL. +

    +

    + Input Parameters: + None +

    +

    + Returned Value: + Zero on success. +

    + +

    2.9.4 setenv

    +

    + Function Prototype: +

    +
    +  #include <stdlib.h>
    +  int setenv(const char *name, const char *value, int overwrite);
    +
    +

    + Description: + The setenv() function adds the variable name to the environment with the + specified value if the variable name does not exist. If the name + does exist in the environment, then its value is changed to value if overwrite + is non-zero; if overwrite is zero, then the value of name is unaltered. +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: + Zero on success. +

    + +

    2.9.5 unsetenv

    +

    + Function Prototype: +

    +
    +  #include <stdlib.h>
    +  int unsetenv(const char *name);
    +
    +

    + Description: + The unsetenv() function deletes the variable name from the environment. +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: + Zero on success. +

    + + + + + +
    +

    2.10 File System Interfaces

    +
    + + + +

    2.10.1 NuttX File System Overview

    + +

    Overview. + NuttX includes an optional, scalable file system. + This file-system may be omitted altogether; NuttX does not depend on the presence + of any file system. +

    + +

    Pseudo Root File System. + Or, a simple in-memory, pseudo file system can be enabled. + This simple file system can be enabled setting the CONFIG_NFILE_DESCRIPTORS + option to a non-zero value. + 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 pseudo file system (in the + same sense that the Linux /proc file system is also + referred to as a pseudo file system). +

    + +

    + Any user supplied data or logic can be accessed via the pseudo-file system. + Built in support is provided for character and block + driver nodes in the any + pseudo file system directory. + (By convention, however, all driver nodes should be in the /dev + pseudo 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 mount-point within the pseudo 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 pseudo file system and true file systems may be + mounted in the pseudo file system. + In the typical Linux installation by comparison, the Linux root file system + is a true file system and pseudo 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. +

    + +

    File System Interfaces. + The NuttX file system simply supports a set of standard, file system APIs + (open(), close(), read(), write, etc.) + and a registration mechanism that allows devices drivers to a associated with nodes + in a file-system-like name space. +

    + +

    2.10.2 Driver Operations

    + + +

    2.10.2.1 fcntl.h

    + + + +

    2.10.2.2 unistd.h

    + + + +

    2.10.2.3 sys/ioctl.h

    + + + +

    2.10.2.4 poll.h

    + +
    2.10.2.4.1 poll
    +

    + Function Prototype: +

    +
    +  #include <poll.h>
    +  int poll(struct pollfd *fds, nfds_t nfds, int timeout);
    +
    +

    + Description: + poll() waits for one of a set of file descriptors to become ready to + perform I/O. If none of the events requested (and no error) has + occurred for any of the file descriptors, then poll() blocks until + one of the events occurs. +

    +

    + Configuration Settings. + In order to use the poll() API, the following must be defined + in your NuttX configuration file: +

    + +

    + In order to use the select with TCP/IP sockets test, you must also have the following additional things + selected in your NuttX configuration file: +

    + +

    + In order to for select to work with incoming connections, you must also select: +

    + +

    + Input Parameters: +

    + +

    + Returned Value: +

    +

    + On success, the number of structures that have nonzero revents fields. + A value of 0 indicates that the call timed out and no file descriptors were ready. + On error, -1 is returned, and errno is set appropriately: +

    + + +

    2.10.2.5 sys/select.h

    + +
    2.10.2.5.1 select
    +

    + Function Prototype: +

    + +

    + Description: + select() allows a program to monitor multiple file descriptors, waiting + until one or more of the file descriptors become "ready" for some class + of I/O operation (e.g., input possible). A file descriptor is + considered ready if it is possible to perform the corresponding I/O + operation (e.g., read(2)) without blocking. +

    +

    + NOTE: poll() is the fundamental API for performing such monitoring + operation under NuttX. select() is provided for compatibility and + is simply a layer of added logic on top of poll(). As such, select() + is more wasteful of resources and poll() is the recommended API to be + used. +

    +

    + Input Parameters: +

    + +

    + Returned Value: +

    + + +

    2.10.3 Directory Operations

    + + + + +

    2.10.4 UNIX Standard Operations

    + + + +

    2.10.5 Standard I/O

    + + +

    2.10.6 Standard Library

    +

    + stdlib.h generally addresses other operating system interfaces. + However, the following may also be considered as file system interfaces: +

    + + +

    2.10.7 Asynchronous I/O

    + + +

    2.10.8 Standard String Operations

    + + +

    2.10.9 Pipes and FIFOs

    + +

    2.10.9.1 pipe

    +

    + Function Prototype: +

    + +

    + Description: +

    +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: +

    +

    + +

    2.10.9.2 mkfifo

    +

    + Function Prototype: +

    + +

    + Description: +

    +

    +

    + Input Parameters: +

    +

    +

    + Returned Value: +

    +

    + +

    2.10.10 FAT File System Support

    +

    2.10.10.1 mkfatfs

    +

    + Function Prototype: +

    + +

    + Description: +

    +

    +

    + Input Parameters: +

    +

    +

    + Returned Value: +

    +

    + +

    2.10.11 mmap() and eXecute In Place (XIP)

    +

    + NuttX operates in a flat open address space and is focused on MCUs that do + support Memory Management Units (MMUs). Therefore, NuttX generally does not + require mmap() functionality and the MCUs generally cannot support true + memory-mapped files. +

    +

    + However, memory mapping of files is the mechanism used by NXFLAT, the NuttX + tiny binary format, to get files into memory in order to execute them. + mmap() support is therefore required to support NXFLAT. + There are two conditions where mmap() can be supported: +

    +
      +
    1. +

      + mmap() can be used to support eXecute In Place (XIP) on random access media + under the following very restrictive conditions: +

      +
        +
      1. +

        + The file-system supports the FIOC_MMAP ioctl command. + Any file system that maps files contiguously on the media should support this + ioctl command. + By comparison, most file system scatter files over the media in non-contiguous + sectors. As of this writing, ROMFS is the only file system that meets this requirement. +

        +
      2. +
      3. +

        + The underlying block driver supports the BIOC_XIPBASE ioctl command + that maps the underlying media to a randomly accessible address. + At present, only the RAM/ROM disk driver does this. +

        +
      4. +
      +

      + Some limitations of this approach are as follows: +

      +

        +
      1. +

        + Since no real mapping occurs, all of the file contents are "mapped" into memory. +

        +
      2. +
      3. +

        + All mapped files are read-only. +

        +
      4. +
      5. +

        + There are no access privileges. +

        +
      6. +
      +
    2. +
    3. +

      + If CONFIG_FS_RAMMAP is defined in the configuration, then mmap() will + support simulation of memory mapped files by copying files whole into RAM. + These copied files have some of the properties of standard memory mapped files. + There are many, many exceptions exceptions, however. + Some of these include: +

      +
        +
      1. +

        + The goal is to have a single region of memory that represents a single + file and can be shared by many threads. That is, given a filename a + thread should be able to open the file, get a file descriptor, and + call mmap() to get a memory region. Different file descriptors opened + with the same file path should get the same memory region when mapped. +

        +

        + The limitation in the current design is that there is insufficient + knowledge to know that these different file descriptors correspond to + the same file. So, for the time being, a new memory region is created + each time that rammmap() is called. Not very useful! +

        +
      2. +
      3. +

        + The entire mapped portion of the file must be present in memory. + Since it is assumed that the MCU does not have an MMU, on-demanding + paging in of file blocks cannot be supported. Since the while mapped + portion of the file must be present in memory, there are limitations + in the size of files that may be memory mapped (especially on MCUs + with no significant RAM resources). +

        +
      4. +
      5. +

        + All mapped files are read-only. You can write to the in-memory image, + but the file contents will not change. +

        +
      6. +
      7. +

        + There are no access privileges. +

        +
      8. +
      9. +

        + Since there are no processes in NuttX, all mmap() and munmap() + operations have immediate, global effects. Under Linux, for example, + munmap() would eliminate only the mapping with a process; the mappings + to the same file in other processes would not be effected. +

        +
      10. +
      11. +

        + Like true mapped file, the region will persist after closing the file + descriptor. However, at present, these ram copied file regions are + not automatically "unmapped" (i.e., freed) when a thread is terminated. + This is primarily because it is not possible to know how many users + of the mapped region there are and, therefore, when would be the + appropriate time to free the region (other than when munmap is called). +

        +

        + NOTE: Note, if the design limitation of a) were solved, then it would be + easy to solve exception d) as well. +

        +
      12. +
      +
    4. +
    + +

    2.10.11.1 mmap

    +

    + Function Prototype: +

    + +

    + Description: +

    +

    +

    + Input Parameters: +

    +

    +

    + Returned Value: +

    +

    + + + + + +
    +

    2.11 Network Interfaces

    +
    + +

    + NuttX includes a simple interface layer based on uIP (see http://www.sics.se). + NuttX supports subset of a standard socket interface to uIP. + These network feature can be enabled by settings in the architecture configuration file. + Those socket APIs are discussed in the following paragraphs. +

    + + +

    2.11.1 socket

    +

    + Function Prototype: +

    + +

    + Description: + socket() creates an endpoint for communication and returns a descriptor. +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: + 0 on success; -1 on error with errno set appropriately: +

    + + +

    2.11.2 bind

    +

    + Function Prototype: +

    + +

    + Description: + bind() gives the socket sockfd the local address addr. + addr is addrlen bytes long. Traditionally, this is called + "assigning a name to a socket." When a socket is created with socket(), + it exists in a name space (address family) but has no name assigned. +

    +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: + 0 on success; -1 on error with errno set appropriately: +

    + + +

    2.11.3 connect

    +

    + Function Prototype: +

    + +

    + Description: + connect() connects the socket referred to by the file descriptor + sockfd to the address specified by addr. + The addrlen argument specifies the size of addr. + The format of the address in addr is determined by the address space + of the socket sockfd. + + If the socket sockfd is of type SOCK_DGRAM then addr is the address + to which datagrams are sent by default, and the only address from which + datagrams are received. If the socket is of type SOCK_STREAM or + SOCK_SEQPACKET, this call attempts to make a connection to the socket + that is bound to the address specified by addr. + + Generally, connection-based protocol sockets may successfully connect() + only once; connectionless protocol sockets may use connect() multiple + times to change their association. Connectionless sockets may dissolve + the association by connecting to an address with the sa_family member of + sockaddr set to AF_UNSPEC. +

    +

    +

    + Input Parameters: +

    +

    +

    +

    + Returned Value: + 0 on success; -1 on error with errno set appropriately: +

    +
  • EACCES or EPERM: + The user tried to connect to a broadcast address without having the + socket broadcast flag enabled or the connection request failed + because of a local firewall rule.
  • +
  • EADDRINUSE + Local address is already in use.
  • +
  • EAFNOSUPPORT + The passed address didn't have the correct address family in its + sa_family field.
  • +
  • EAGAIN + No more free local ports or insufficient entries in the routing + cache. For PF_INET.
  • +
  • EALREADY + The socket is non-blocking and a previous connection attempt has + not yet been completed.
  • +
  • EBADF + The file descriptor is not a valid index in the descriptor table.
  • +
  • ECONNREFUSED + No one listening on the remote address.
  • +
  • EFAULT + The socket structure address is outside the user's address space.
  • +
  • EINPROGRESS + The socket is non-blocking and the connection cannot be completed + immediately.
  • +
  • EINTR + The system call was interrupted by a signal that was caught.
  • +
  • EISCONN + The socket is already connected.
  • +
  • ENETUNREACH + Network is unreachable.
  • +
  • ENOTSOCK + The file descriptor is not associated with a socket.
  • +
  • ETIMEDOUT + Timeout while attempting connection. The server may be too busy + to accept new connections.
  • + + +

    2.11.4 listen

    +

    + Function Prototype: +

    + +

    + Description: + To accept connections, a socket is first created with socket(), a + willingness to accept incoming connections and a queue limit for incoming + connections are specified with listen(), and then the connections are + accepted with accept(). The listen() call applies only to sockets of + type SOCK_STREAM or SOCK_SEQPACKET. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, zero is returned. On error, -1 is returned, and + errno is set appropriately. +

    + + +

    2.11.5 accept

    +

    + Function Prototype: +

    + +

    + Description: + The accept() function is used with connection-based socket types + (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). + It extracts the first connection request on the queue of pending connections, + creates a new connected socket with most of the same properties as sockfd, + and allocates a new socket descriptor for the socket, which is returned. The + newly created socket is no longer in the listening state. The original + socket sockfd is unaffected by this call. Per file descriptor flags + are not inherited across an accept. +

    +

    + The sockfd argument is a socket descriptor that has been created with + socket(), bound to a local address with bind(), and is listening for + connections after a call to listen(). +

    +

    + On return, the addr structure is filled in with the address of the + connecting entity. The addrlen argument initially contains the size + of the structure pointed to by addr; on return it will contain the + actual length of the address returned. +

    +

    + If no pending connections are present on the queue, and the socket is + not marked as non-blocking, accept blocks the caller until a connection + is present. If the socket is marked non-blocking and no pending + connections are present on the queue, accept returns EAGAIN. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + Returns -1 on error. If it succeeds, it returns a non-negative integer + that is a descriptor for the accepted socket. +

    + + +

    2.11.6 send

    +

    + Function Prototype: +

    + +

    + Description: + The send() call may be used only when the socket is in a connected state + (so that the intended recipient is known). + The only difference between send() and write() is the + presence of flags. + With zero flags parameter, send() is equivalent to + write(). Also, send(s,buf,len,flags) is + equivalent to sendto(s,buf,len,flags,NULL,0). +

    +

    + Input Parameters: +

    + +

    + Returned Value: + See sendto(). +

    + +

    2.11.7 sendto

    +

    + Function Prototype: +

    + +

    + Description: + If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET) + socket, the parameters to and tolen are ignored (and the error EISCONN + may be returned when they are not NULL and 0), and the error ENOTCONN is + returned when the socket was not actually connected. +

    +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, returns the number of characters sent. On error, -1 is returned, + and errno is set appropriately: +

    + + +

    2.11.8 recv

    +

    + Function Prototype: +

    + +

    + Description: + The recv() call is identical to + recvfrom() with a NULL + from parameter. +

    +

    +

    + Input Parameters: +

    + +

    + Returned Value: + See recvfrom(). +

    + +

    2.11.9 recvfrom

    +

    + Function Prototype: +

    + +

    + Description: + recvfrom() receives messages from a socket, and may be used to receive + data on a socket whether or not it is connection-oriented. +

    +

    + If from is not NULL, and the underlying protocol provides the source + address, this source address is filled in. The argument fromlen + initialized to the size of the buffer associated with from, and modified + on return to indicate the actual size of the address stored there. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, returns the number of characters sent. + If no data is available to be received and the peer has performed an orderly shutdown, recv() will return 0. + Othwerwise, on errors, -1 is returned, and errno is set appropriately: +

    + + +

    2.11.10 setsockopt

    +

    + Function Prototype: +

    + +

    + Description: + setsockopt() sets the option specified by the option argument, + at the protocol level specified by the level argument, to the value + pointed to by the value argument for the socket associated with the + file descriptor specified by the sockfd argument. +

    +

    + The level argument specifies the protocol level of the option. To set + options at the socket level, specify the level argument as SOL_SOCKET. +

    +

    + See sys/socket.h for a complete list of values for the option argument. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, returns the number of characters sent. + On error, -1 is returned, and errno is set appropriately: +

    + + +

    2.11.11 getsockopt

    +

    + Function Prototype: +

    + +

    + Description: + getsockopt() retrieve those value for the option specified by the + option argument for the socket specified by the sockfd argument. If + the size of the option value is greater than value_len, the value + stored in the object pointed to by the value argument will be silently + truncated. Otherwise, the length pointed to by the value_len argument + will be modified to indicate the actual length of thevalue. +

    +

    + The level argument specifies the protocol level of the option. To + retrieve options at the socket level, specify the level argument as + SOL_SOCKET. +

    +

    + See sys/socket.h for a complete list of values for the option argument. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, returns the number of characters sent. + On error, -1 is returned, and errno is set appropriately: +

    + + + + + + +
    +

    2.12 Shared Memory Interfaces

    +
    +

    + Shared memory interfaces are only available with the NuttX kernel build (CONFIG_BUILD_KERNEL=y). + These interfaces support user memory regions that can be shared between multiple user processes. + Shared memory interfaces: +

    + + +

    2.12.1 shmget

    +

    + Function Prototype: +

    + +

    + Description: + The shmget() function will return the shared memory identifier associated with key. +

    +

    + A shared memory identifier, associated data structure, and shared memory segment of at least size bytes is created for key if one of the following is true: +

    + +

    + Upon creation, the data structure associated with the new shared memory identifier will be initialized as follows: +

    + +

    + When the shared memory segment is created, it will be initialized with all zero values. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + Upon successful completion, shmget() will return a non-negative integer, namely a shared memory identifier; otherwise, it will return -1 and set errno to indicate the error. +

    + +

    + POSIX Deviations +

    +

    + +

    2.12.2 shmat

    +

    + Function Prototype: +

    + +

    + Description: + The shmat() function attaches the shared memory segment associated with the shared memory identifier specified by shmid to the address space of the calling process. The segment is attached at the address specified by one of the following criteria: +

    + +

    + Input Parameters: +

    + +

    + Returned Value: + Upon successful completion, shmat() will increment the value of shm_nattch in the data structure associated with the shared memory ID of the attached shared memory segment and return the segment's start address. + + Otherwise, the shared memory segment will not be attached, shmat() will return -1, and errno will be set to indicate the error. +

    + + +

    2.12.3 shmctl

    +

    + Function Prototype: +

    + +

    + Description: + The shmctl() function provides a variety of shared memory control operations as specified by cmd. The following values for cmd are available: +

    + +

    + Input Parameters: +

    + +

    + Returned Value: + Upon successful completion, shmctl() will return 0; otherwise, it will return -1 and set errno to indicate the error. +

    + +

    + POSIX Deviations +

    +

    + +

    2.12.4 shmdt

    +

    + Function Prototype: +

    + +

    + Description: + The shmdt() function detaches the shared memory segment located at the address specified by shmaddr from the address space of the calling process. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + Upon successful completion, shmdt() will decrement the value of shm_nattch in the data structure associated with the shared memory ID of the attached shared memory segment and return 0. +

    +

    + Otherwise, the shared memory segment will not be detached, shmdt() will return -1, and errno will be set to indicate the error. +

    + + + + + + +
    +

    3.0 OS Data Structures

    +
    + + + + + +
    +

    3.1 Scalar Types

    +
    + +

    +Many of the types used to communicate with NuttX are simple +scalar types. These types are used to provide architecture independence +of the OS from the application. The scalar types used at the NuttX +interface include: +

    + + + + + +
    +

    3.2 Hidden Interface Structures

    +
    + +

    +Several of the types used to interface with NuttX are +structures that are intended to be hidden from the application. +From the standpoint of the application, these structures (and +structure pointers) should be treated as simple handles to reference +OS resources. These hidden structures include: +

    +

    + In order to maintain portability, applications should not reference + specific elements within these hidden structures. These hidden + structures will not be described further in this user's manual. +

    + + + + + +
    +

    3.3 Access to the errno Variable

    +
    + +

    + A pointer to the thread-specific errno value is available through a + function call: +

    +

    + Function Prototype: +

    +

    +

    + Description: + get_errno_ptr() returns a pointer to the thread-specific errno value. + Note that the symbol errno is defined to be get_errno_ptr() so that the usual + access by referencing the symbol errno will work as expected. +

    +

    + There is a unique, private errno value for each NuttX task. + However, the implementation of errno differs somewhat from the use of + errno in most multi-threaded process environments: + In NuttX, each pthread will also have its own private copy of errno and the + errno will not be shared between pthreads. + This is, perhaps, non-standard but promotes better thread independence. +

    +Input Parameters: None +

    +Returned Values: +

    +

    +

    + + + + + +
    +

    3.4 User Interface Structures

    +
    + +

    3.4.1 main_t

    +

    +main_t defines the type of a task entry point. main_t is declared +in sys/types.h as: +

    +    typedef int (*main_t)(int argc, char *argv[]);
    +
    + +

    3.4.2 struct sched_param

    + +

    +This structure is used to pass scheduling priorities to and from +NuttX; +

    +    struct sched_param
    +    {
    +      int sched_priority;
    +    };
    +
    + +

    3.4.3 struct timespec

    + +

    +This structure is used to pass timing information between the +NuttX and a user application: +

    +    struct timespec
    +    {
    +      time_t tv_sec;  /* Seconds */
    +      long   tv_nsec; /* Nanoseconds */
    +    };
    +
    + +

    3.4.4 struct mq_attr

    + +

    +This structure is used to communicate message queue attributes +between NuttX and a MoBY application: +

    +    struct mq_attr {
    +      size_t       mq_maxmsg;   /* Max number of messages in queue */
    +      size_t       mq_msgsize;  /* Max message size */
    +      unsigned     mq_flags;    /* Queue flags */
    +      size_t       mq_curmsgs;  /* Number of messages currently in queue */
    +    };
    +
    + +

    3.4.5 struct sigaction

    + +

    +The following structure defines the action to take for given signal: +

    +    struct sigaction
    +    {
    +      union
    +      {
    +        void (*_sa_handler)(int);
    +        void (*_sa_sigaction)(int, siginfo_t *, void *);
    +      } sa_u;
    +      sigset_t           sa_mask;
    +      int                sa_flags;
    +    };
    +    #define sa_handler   sa_u._sa_handler
    +    #define sa_sigaction sa_u._sa_sigaction
    +
    + +

    3.4.6 struct siginfo/siginfo_t

    + +

    +The following types is used to pass parameters to/from signal +handlers: +

    +    typedef struct siginfo
    +    {
    +      int          si_signo;
    +      int          si_code;
    +      union sigval si_value;
    +   } siginfo_t;
    +
    + +

    3.4.7 union sigval

    + +

    +This defines the type of the struct siginfo si_value field and +is used to pass parameters with signals. +

    +    union sigval
    +    {
    +      int   sival_int;
    +      void *sival_ptr;
    +    };
    +
    + +

    3.4.8 struct sigevent

    + +

    +The following is used to attach a signal to a message queue to +notify a task when a message is available on a queue. +

    +    struct sigevent
    +    {
    +      int          sigev_signo;
    +      union sigval sigev_value;
    +      int          sigev_notify;
    +    };
    +
    + + + + + + +
    +

    Index

    +
    + + + + + + + +
    +
  • accept
  • +
  • aio.h
  • +
  • aio_cancel
  • +
  • aio_error
  • +
  • aio_fsync
  • +
  • aio_read
  • +
  • aio_return
  • +
  • aio_suspend
  • +
  • aio_write
  • +
  • asctime
  • +
  • asctime_r
  • +
  • atexit +
  • bind
  • +
  • BIOC_XIPBASE
  • +
  • chdir
  • +
  • clock_getres
  • +
  • clock_gettime
  • +
  • Clocks
  • +
  • clock_settime
  • +
  • close
  • +
  • closedir
  • +
  • connect
  • +
  • creat
  • +
  • ctime
  • +
  • ctime_r
  • +
  • Data structures
  • +
  • Directory operations
  • +
  • dirent.h
  • +
  • Driver operations
  • +
  • dup
  • +
  • dup2
  • +
  • execl
  • +
  • eXecute In Place (XIP)
  • +
  • execv
  • +
  • exit
  • +
  • FAT File System Support
  • +
  • fclose
  • +
  • fcntl
  • +
  • fcntl.h
  • +
  • fdopen
  • +
  • feof
  • +
  • ferror
  • +
  • File system, interfaces
  • +
  • File system, overview
  • +
  • fflush
  • +
  • fgetc
  • +
  • fgetpos
  • +
  • fgets
  • +
  • FIOC_MMAP
  • +
  • fopen
  • +
  • fprintf
  • +
  • fputc
  • +
  • fputs
  • +
  • fread
  • +
  • fseek
  • +
  • fsetpos
  • +
  • fstat
  • +
  • ftell
  • +
  • fwrite
  • +
  • getcwd
  • +
  • getpid
  • +
  • gets
  • +
  • getsockopt
  • +
  • gmtime
  • +
  • gmtime_r
  • +
  • Introduction +
  • ioctl
  • +
  • kill
  • +
  • lio_listio
  • +
  • listen
  • +
  • localtime_r
  • +
  • lseek
  • +
  • Named Message Queue Interfaces +
  • mkdir
  • +
  • mkfatfs
  • +
  • mkfifo
  • +
  • mktime
  • +
  • mq_close
  • +
  • mq_getattr
  • +
  • mq_notify
  • +
  • mq_open
  • +
  • mq_receive
  • +
  • mq_send
  • +
  • mq_setattr
  • +
  • mq_timedreceive
  • +
  • mq_timedsend
  • +
  • mq_unlink
  • +
  • mmap
  • +
    +
  • Network Interfaces
  • +
  • on_exit +
  • open
  • +
  • opendir
  • +
  • OS Interfaces
  • +
  • pause
  • +
  • pipe
  • +
  • poll
  • +
  • poll.h
  • +
  • posix_spawn
  • +
  • posix_spawn_file_actions_addclose
  • +
  • posix_spawn_file_actions_adddup2
  • +
  • posix_spawn_file_actions_addopen
  • +
  • posix_spawn_file_actions_destroy
  • +
  • posix_spawn_file_actions_init
  • +
  • posix_spawnattr_init
  • +
  • posix_spawnattr_destroy
  • +
  • posix_spawnattr_getflags
  • +
  • posix_spawnattr_getschedparam
  • +
  • posix_spawnattr_getschedpolicy
  • +
  • posix_spawnattr_getsigmask
  • +
  • posix_spawnattr_setflags
  • +
  • posix_spawnattr_setschedparam
  • +
  • posix_spawnattr_setschedpolicy
  • +
  • posix_spawnattr_setsigmask
  • +
  • posix_spawnp
  • +
  • pread
  • +
  • printf
  • +
  • pwrite
  • +
  • Pthread Interfaces +
  • pthread_attr_destroy
  • +
  • pthread_attr_getinheritsched
  • +
  • pthread_attr_getschedparam
  • +
  • pthread_attr_getschedpolicy
  • +
  • pthread_attr_getstacksize
  • +
  • pthread_attr_init
  • +
  • pthread_attr_setinheritsched
  • +
  • pthread_attr_setschedparam
  • +
  • pthread_attr_setschedpolicy
  • +
  • pthread_attr_setstacksize
  • +
  • pthread_barrierattr_init
  • +
  • pthread_barrierattr_destroy
  • +
  • pthread_barrierattr_getpshared
  • +
  • pthread_barrierattr_setpshared
  • +
  • pthread_barrier_destroy
  • +
  • pthread_barrier_init
  • +
  • pthread_barrier_wait
  • +
  • pthread_cancel
  • +
  • pthread_condattr_init
  • +
  • pthread_cond_broadcast
  • +
  • pthread_cond_destroy
  • +
  • pthread_cond_init
  • +
  • pthread_cond_signal
  • +
  • pthread_cond_timedwait
  • +
  • pthread_cond_wait
  • +
  • pthread_create
  • +
  • pthread_detach
  • +
  • pthread_exit
  • +
  • pthread_getschedparam
  • +
  • pthread_getspecific
  • +
  • pthreads share some resources. +
  • pthread_join
  • +
  • pthread_key_create
  • +
  • pthread_key_delete
  • +
  • pthread_kill
  • +
  • pthread_mutexattr_destroy
  • +
  • pthread_mutexattr_getpshared
  • +
  • pthread_mutexattr_gettype
  • +
  • pthread_mutexattr_init
  • +
  • pthread_mutexattr_setpshared
  • +
  • pthread_mutexattr_settype
  • +
  • pthread_mutex_destroy
  • +
  • pthread_mutex_init
  • +
  • pthread_mutex_lock
  • +
  • pthread_mutex_trylock
  • +
  • pthread_mutex_unlock
  • +
  • pthread_condattr_destroy
  • +
  • pthread_once
  • +
  • pthread_self
  • +
  • pthread_setcancelstate
  • +
  • pthread_setschedparam
  • +
  • pthread_setspecific
  • +
  • pthread_sigmask
  • +
  • pthread_testcancelstate
  • +
  • pthread_yield
  • +
  • puts
  • +
  • RAM disk driver
  • +
  • read
  • +
    +
  • readdir
  • +
  • readdir_r
  • +
  • recv
  • +
  • recvfrom
  • +
  • rename
  • +
  • rmdir
  • +
  • rewinddir
  • +
  • ROM disk driver
  • +
  • ROMFS
  • +
  • sched_getparam
  • +
  • sched_get_priority_max
  • +
  • sched_get_priority_min
  • +
  • sched_get_rr_interval
  • +
  • sched_lockcount
  • +
  • sched_lock
  • +
  • sched_setparam
  • +
  • sched_setscheduler
  • +
  • sched_unlock
  • +
  • sched_yield
  • +
  • select
  • +
  • Counting Semaphore Interfaces +
  • sem_close
  • +
  • sem_destroy
  • +
  • sem_getvalue
  • +
  • sem_init
  • +
  • sem_open
  • +
  • sem_post
  • +
  • sem_trywait
  • +
  • sem_unlink
  • +
  • sem_wait
  • +
  • sched_getscheduler
  • +
  • seekdir
  • +
  • send
  • +
  • sendto
  • +
  • setsockopt
  • +
  • sigaction
  • +
  • sigaddset
  • +
  • sigdelset
  • +
  • sigemptyset
  • +
  • sigfillset
  • +
  • sigismember
  • +
  • Signal Interfaces +
  • sigpending
  • +
  • sigprocmask
  • +
  • sigqueue
  • +
  • sigsuspend
  • +
  • sigtimedwait
  • +
  • sigwaitinfo
  • +
  • socket
  • +
  • sprintf
  • +
  • Standard I/O
  • +
  • stat
  • +
  • statfs
  • +
  • stdio.h
  • +
  • sys/select.h
  • +
  • sys/ioctl.h
  • +
  • task_activate
  • +
  • Task Control Interfaces +
  • task_create
  • +
  • task_delete
  • +
  • task_init
  • +
  • task_restart
  • +
  • Task Scheduling Interfaces +
  • task_spawn
  • +
  • task_spawnattr_getstacksize
  • +
  • task_spawnattr_setstacksize
  • +
  • Task Switching Interfaces +
  • telldir
  • +
  • timer_create
  • +
  • timer_delete
  • +
  • timer_getoverrun
  • +
  • timer_gettime
  • +
  • Timers
  • +
  • timer_settime
  • +
  • ungetc
  • +
  • unistd.h, + unistd.h
  • +
  • unlink
  • +
  • vfork
  • +
  • vfprintf
  • +
  • vprintf
  • +
  • vsprintf
  • +
  • wait
  • +
  • waitid
  • +
  • waitpid +
  • write
  • +
  • XIP
  • +
    + + + diff --git a/Documentation/NxWidgets.html b/Documentation/NxWidgets.html new file mode 100644 index 0000000000..2d88d2bf48 --- /dev/null +++ b/Documentation/NxWidgets.html @@ -0,0 +1,75 @@ + + +NxWidgets + + +

    + + + + +
    +

    NxWidgets

    +

    Last Updated: March 27, 2012

    +
    +

    NXWidgets

    +

    + In order to better support NuttX based platforms, a special graphical userinterface has been created called NXWidgets. + NXWidgets is written in C++ and integrates seamlessly with the NuttX NX graphics subsystem in order to provide graphic objects, or "widgets," in the NX Graphics Subsystem +

    +

    + Some of the features of NXWidgets include: +

    + +

    + Note: Many of the fundamental classed in NxWidgets derive from the Antony + Dzeryn's "Woopsi" project: http://woopsi.org/ which also has a BSD style + license. See the COPYING file for details. +

    +

    NXWidgets DOxygen Documentation

    +

    + Release notes, DOxygen documentation, as well as downloads for the latest NxWidgets releases are available online: +

    +