Separate backend operations into control and console operations. Main
idea is that each device has single set of console ops (conmux or
console) and at most one way to control it. Each backend driver exports
a structure with the set of callbacks.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Allow PPPS function even if there is no device->usb callback. PPPS is
useable even with no control interface.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Instad of hand-coding message sending, create a single wrapper that
sends messages to the client.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Since Linux kernel 6.0, PPPS capable USB hubs expose a simple sysfs
attribute for power control. Allow overwriting the usb control callback
to use PPPS hub control instead.
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Limit access control to the boards according to the passed username. If
the user has no access, the board becoms completely invisible: it is not
listed, it is not possible to fetch board description, etc.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
For different reasons it might be desirable to keep slot 'b' as an
active slot. Add support for specifying the active slot in the config
file. The default is still slot 'a'.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Code should avoid comparing signed and unsigned integers, because of
implicit case. Explicit casts are safe because 'lock' size is PATH_MAX.
device.c: In function ‘device_lock’:
device.c:64:15: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
64 | if (n >= sizeof(lock))
| ^~
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Transfering the image to cdba server takes time (especially when working
with over the network). Notify users before actually booting the board
to ease detecting early boot issues.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Opening the lock files fails on one of my boards if the files exists and
are owned by someone else, if O_CREAT is set. This doesn't make sense,
but hack around it for now by first creating the file if it's not there,
ignoring any errors and then just opening it O_RDONLY.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
For some reason the SC8180x Primus often fails to detect the attached
USB stick if USB is toggled as part of a power cycle, so let's continue
to support the property of not toggling it.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Allow the control device to implement things such as flushing the
command buffer as part of the close operation. This used to be done to
ensure that any lingering power/usb off requests really where sent to
the device as we closed the control tty.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
As cdba-server exits it turns off power, which used to cut VBUS as well,
but since the refactoring only cuts power. Reintroduce the VBUS toggle
to ensure the device doesn't stay powered through USB after use.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The power key dance is useful outside of alpaca, move it to device and
modify the device interface to better suite this.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Squash the power_on and power_off into a single "power" function, to
harmonize the code wrt the USB handling.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Make device power controller optional, allowing one to use cdba in
non-automated setup (just simplifying the fastboot + console handling).
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
[bjorn: Rebased the patch onto master, reversed the logic in power_on/off]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
In order to sleep for fractions of a second in alpaca, change the
timeout from seconds to milliseconds.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Make the fastboot key handling a property of the device configuration
and use the newly introduced timeout mechanism for handling it.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Add a new keyword "description" to the config file, add the necessary
wire protocol to acquire this string for a given device and introduce
the "-i" option to cdba to trigger its retrieval.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Add a new argument '-l' which in combination with '-h' will connect to
said server and list the attached devices, then exit.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
It's possible for devices that are automated using e.g. a CDB Assist to
have console coming over a separate FTDI USB tty. Move the alpaca
specific implementation of the "console" directive to device.c to make
it generic.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Grab a flock() in order to prohibit multiple clients from controlling
the same board at any point in time.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>