Shell & Scripting¶
rtems-init supports two system shells: Cexpsh and RTEMS shell.
Cexpsh, or C Expression Shell, is an open source shell that resembles the VxWorks system shell. It supports loading partially relocated ELF objects via a built-in object loader, and can call arbitrary C functions.
The RTEMS shell (or RTSH), is the default built-in shell provided by RTEMS.
In addition to these shells, rtems-init also supports scripting with Lua, a lightweight interpreted scripting language.
If configured to do so (by default it is), rtems-init will display a “press any key to skip init” message on boot. This can be used to drop into a rescue shell that uses the RTEMS shell. This is particularly handy if Cexpsh becomes useless due to loss of NFS mount or something similar.
Cexpsh¶
A number of built-in functions that are callable through Cexpsh are built into the base image:
Function |
Description |
|---|---|
|
Copy a file |
|
Cat a file to stdout |
|
List files in a directory |
|
Print current working directory |
|
Dump the current environment |
|
Show workspace (memory) usage stats |
|
Show malloc stats |
|
Compatibility with RTEMS 4’s nfsMount |
|
Launch an instance of the RTEMS shell |
RTEMS Shell¶
The following commands are registered by rtems-init:
Command |
Description |
|---|---|
|
Open an ELF object with the RTEMS run-time linker (RTL) |
|
Find a symbol in an ELF object |
|
Close an ELF object |
|
Call a function in an ELF object |
|
RTEMS run-time linker (RTL) commands |
|
Start the remote debugger |
|
Stop the remote debugger |
|
Get a parameter from NVRAM (if supported by BSP) |
|
Show all NVRAM parameters (if supported by BSP) |
|
Get a global environment variable (Motload only) |
|
Show all global environment variables (Motload only) |
|
Start the NTP daemon |
|
Dump all environment variables |
|
Sets the effective UID |
|
Gets the effective UID |
|
Sets the effective GID |
|
Resolves an address, printing the resulting IP |
|
Fuzzy search for a term in the shell command list |
|
Gets all IP addresses for all adapters on the system |
|
List all available PCI devices (similar to lspci on Linux) |
|
Launch new instance of the RTEMS shell |
|
ttcp utility for testing TCP: https://en.wikipedia.org/wiki/Ttcp |
|
Launch an interactive Lua shell, or run a Lua script off of the file system |
Lua Scripting¶
An interactive Lua interpreter can be accessed from the RTEMS shell using the lua command.
This can also be used to run Lua scripts off of the file system– it’s no different than the lua command on a Linux host.
Lua scripts located in /bin are automatically registered as RTEMS shell commands and can be easily run from anywhere.
For example, /bin/rtems-version.lua can be run as rtems-version.lua from the RTEMS shell.
These scripts are not registered with Cexpsh in any way.