Post · 4 min read· pp. 638–642

Board IOCTL

Board IOCTL

In a small embedded system, there will typically be a much greater interaction between application and low-level board features. The canonically correct to implement such interactions is by implementing a character driver and performing the interactions via low level ioctl() calls. This, however, may not be practical in many cases and will lead to “correct” but awkward implementations.

boardctl() is non-standard OS interface to alleviate the problem. It basically circumvents the normal device driver ioctl() interface and allows the application to perform direct IOCTL-like calls to the board-specific logic. It is especially useful for setting up board operational and test configurations.

boardctl() is an application interface to the OS. There is no point, in fact, of using boardctl() within the OS; the board interfaces prototyped in include/nuttx/board.h may be called directly from within the OS.

int boardctl(unsigned int cmd, uintptr_t arg) : Parameters: : - cmd – Identifies the board command to be executed. See include/sys/boardctl.h for the complete list of common board commands. Provisions are made to support non-common, board-specific commands as well. - arg – The argument that accompanies the command. The nature of the argument is determined by the specific command.

code
Returns:
:   On success zero (OK) is returned; -1 (ERROR) is
    returned on failure with the errno variable set to indicate the nature of the failure.

Supported commands

The following is the list of supported boardctl() commands. Besides this list, board logic can implement handling of custom commands by implementing the board_ioctl() interface.

System state control

BOARDIOC_POWEROFF : Power off the board

code
Argument:
:   Integer value providing power off status information

Configuration:
:   CONFIG\_BOARDCTL\_POWEROFF

Dependencies:
:   Board logic must provide the `board_power_off()` interface.

BOARDIOC_RESET : Reset the board

code
Argument:
:   Integer value providing power off status information

Configuration:
:   CONFIG\_BOARDCTL\_RESET

Dependencies:
:   Board logic must provide the `board_reset()` interface.

Power Management

BOARDIOC_PM_CONTROL : Manage power state transition and query. The supplied argument indicates the specific PM operation to perform, which map to corresponding internal pm_<operation> functions (see Power Management).

code
With this interface you can interact with PM handling arch/board logic
(typically done in IDLE loop) or you can directly manage state transitions
from userspace.

Argument:
:   A pointer to an instance of `boardioc_pm_ctrl_s`.

Configuration:
:   CONFIG\_PM

Board information

BOARDIOC_UNIQUEID : Return a unique ID associated with the board (such as a serial number or a MAC address).

code
Argument:
:   A writable array of size `CONFIG_BOARDCTL_UNIQUEID_SIZE` in
    which to receive the board unique ID.

Dependencies:
:   Board logic must provide the `board_uniqueid()` interface.

BOARDIOC_MACADDR : Get the network driver MAC address.

code
Argument:
:   A pointer to an instance of `boardioc_macaddr_s`.

Configuration:
:   CONFIG\_BOARDCTL\_MACADDR

Dependencies:
:   Board logic must provide the `board_macaddr()` interface.

Filesystems

BOARDIOC_MKRD : Create a RAM disk

code
Argument:
:   Pointer to read-only instance of `boardioc_mkrd_s`.

Configuration:
:   CONFIG\_BOARDCTL\_MKRD

BOARDIOC_ROMDISK : Register a ROM disk

code
Argument:
:   Pointer to read-only instance of `boardioc_romdisk_s`.

Configuration:
:   CONFIG\_BOARDCTL\_ROMDISK

Symbol Handling

BOARDIOC_APP_SYMTAB : Select the application symbol table. This symbol table provides the symbol definitions exported to application code from application space.

code
Argument:
:   A pointer to an instance of `boardioc_symtab_s`.

Configuration:
:   CONFIG\_BOARDCTL\_APP\_SYMTAB

BOARDIOC_OS_SYMTAB : Select the OS symbol table. This symbol table provides the symbol definitions exported by the OS to kernel modules.

code
Argument:
:   A pointer to an instance of `boardioc_symtab_s`.

Configuration:
:   CONFIG\_BOARDCTL\_OS\_SYMTAB

USB

BOARDIOC_USBDEV_CONTROL : Manage USB device classes

code
Argument:
:   A pointer to an instance of `boardioc_usbdev_ctrl_s`.

Configuration:
:   CONFIG\_BOARDCTL && CONFIG\_BOARDCTL\_USBDEVCTRL

Dependencies:
:   Board logic must provide board\_<usbdev>\_initialize().

Graphics

BOARDIOC_NX_START : Start the NX server

code
Argument:
:   Integer display number to be served by this NXMU instance.

Configuration:
:   CONFIG\_NX

Dependencies:
:   Base graphics logic provides [`nxmu_start()`](https://nuttx.apache.org/docs/latest/os/graphics/nx.html#c.nxmu_start).

BOARDIOC_VNC_START : Start the NX server and framebuffer driver.

code
Argument:
:   A reference readable instance of `boardioc_vncstart_s`.

Configuration:
:   CONFIG\_VNCSERVER

Dependencies:
:   VNC server provides `nx_vnc_fbinitialize()`.

BOARDIOC_NXTERM : Create an NX terminal device

code
Argument:
:   A reference readable/writable instance of
    `boardioc_nxterm_create_s`.

Configuration:
:   CONFIG\_NXTERM

Dependencies:
:   Base NX terminal logic provides `nx_register()` and
    `nxtk_register()`.

BOARDIOC_NXTERM_IOCTL : Create an NX terminal IOCTL command. Normal IOCTLs cannot be be performed in most graphics contexts since the depend on the task holding an open file descriptor

code
Argument:
:   A reference readable/writable instance of
    `boardioc_nxterm_ioctl_s`.

Configuration:
:   CONFIG\_NXTERM

Dependencies:
:   Base NX terminal logic provides `nxterm_ioctl_tap()`.