1.20. barebox remote control¶
barebox remote control is for controlling barebox from a remote host via scripts. The barebox console is designed for human interaction, controlling it from a script is very error prone since UARTs do not offer reliable communication. Usually a tool like ‘expect’ is used for this purpose which uses its own language to communicate with the remote partner. The barebox remote control offers an alternative. barebox commands can be integrated into regular shell scripts running on the host:
bbremote --port /dev/ttyUSB0 run "ls"
Additionally files can be transferred from/to barebox and a regular console offers interactive access to barebox on flawy serial connections.
In addition to the bbremote tool provided with barebox, other third party tools exist that use the same RATP based protocol to communicate with the barebox instance, e.g. the libratp-barebox C library and the ratp-barebox-cli tool:
1.20.1. Enabling remote control support¶
To get remote control support barebox has to be compiled with CONFIG_RATP and CONFIG_CONSOLE_RATP enabled. Optionally CONFIG_FS_RATP can also be enabled.
1.20.2. Running the bbremote tool¶
The bbremote host tool is written in python. To run it python3 has to be installed with the following additional packages:
Debian package name
If your distribution does not provide aforementioned packages, you can use ‘pip’ in order to install the dependencies localy to your user account via:
python -m pip install --user crcmod pyserial
126.96.36.199. configuring bbremote¶
bbremote needs the port and possibly the baudrate to access the remote
barebox. The port can be configured with the
--port option or with
BBREMOTE_PORT environment variable. The port can either be the
device special file if it’s a local port or if it’s a remote port a
string of the form:
rfc2217://host:port. The baudrate can be given
--baudrate option or the
variable. For the rest of this document it is assumed that
has been configured using environment variables.
1.20.3. running commands on the target¶
bbremote can be used to run arbitrary commands on the remote
bbremote run "echo huhu" huhu
The bbremote exit status will be 0 if the remote command exited successfully, 1 if the remote command failed and 127 if there was a communication error.
NOTE It is possible to put the output into a shell variable for
further processing, like
RESULT=$(bbremote run "echo huhu").
However, this string may contain unexpected messages from drivers and
the like because currently we cannot filter out driver messages and
messages to stderr.
This is a simple ping test.
bbremote ping pong
bbremote getenv global.version 2015.12.0-00150-g81cd49f
1.20.6. interactive console¶
The bbremote tool also offers a regular interactive console to barebox. This is especially useful for flawy serial connections.
bbremote console barebox@Phytec phyFLEX-i.MX6 Quad Carrier-Board:/ ls . .. dev env mnt
NOTE To terminate resulting Barebox console session press ‘Ctrl-T’
NOTE You can also send ‘ping’ request to the target without closing console session by pressint ‘Ctrl-P’
1.20.7. transferring files¶
With the bbremote tool it’s possible to transfer files both from the
host to barebox and from barebox to the host. Using the
option to bbremote a directory can be specified to export to barebox.
This can be mounted on barebox using the regular mount command using
-t ratpfs as filesystem type.
bbremote --export=somedir console mkdir -p /ratpfs; mount -t ratpfs none /ratpfs ls /ratpfs