Don't make PPPS path exclusive to the driver USB control. Allow both to
be used at the same time in case the setup uses both PPPS-hubs and
driver-specific control.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Add special keys to allow triggering power and fastboot key presses from
the cdba client. There is an option to send a short key "pulse" (press
followed by release after 100ms) or to press/release keys separately:
- ctrl+a -> o: Send power key pulse
- ctrl+a -> O: Toggle power key (first use: press, next use: release)
- ctrl+a -> f: Send fastboot key pulse
- ctrl+a -> F: Toggle fastboot key (first use: press, next use: release)
In most cases you want to send the "pulse" (short key press), so it's
helpful to have this mapped to a single key. This avoids forgetting to
release the key again after pressing it.
The protocol between CDBA client and server is:
(MSG_KEY_PRESS <key:u8, state:u8>)
where key is either DEVICE_KEY_FASTBOOT (0) or DEVICE_KEY_POWER (1)
and state is either KEY_PRESS_RELEASE (0), KEY_PRESS_PRESS (1) or
KEY_PRESS_PULSE (2).
The reason for implementing the "pulse" on the server side is that it's
hard to guarantee the timing on the client side. We don't know exactly when
the packets will arrive on the server. Also, "state" is a full byte anyway,
so might as well use some of the extra bits. :-)
Loop around the flock(), sleeping in the middle. This allows CDBA to
break early if user closes the terminal (by killing SSH or by Ctrl-A-Q
sequence).
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
For some devices it might be desirable to leave device powered on after
the cdba exits (e.g. to run some long-running tests). Add the
'power_always_on' option that tells cdba server to leave device powered
on after exiting and to toggle power (to reset the device) when
connecting.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Create new function calling fastboot_open so that device_open doesn't
have dependency on the fastboot_ops or udev.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Replace all license headers with the SPDX-License-Identitier headers to
follow the current recommendations.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Add cdba-server side support for "fastboot continue" which allows
fastboot to continue its default boot process.
I find it useful to setup my boards with an additional SD card which I
frequently use the default image on eMMC to chroot to and populate
modules, rebooting into fastboot and subsequently booting via fastboot
a rootfs on the SD card.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Leaving USB connected might cause hickups on the USB bus, and causes
power measurements to report incorrect data. Turn it off once the image
has been downloaded.
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
While the CDB Assist and QcomLT Debugboard is measuring voltage and
current on the DC jack directly in the backend, other backends and
further measurements can be performed using custom tooling.
Introduce support for invoking an external "status-cmd" to produce such
status updates.
The status command should on its stdout produce json-formatted status
updates following the same format as the cdba-server:
{"ts":%d.%03d, "name": {["mv"|"ma"]: %u}(, "name2": {["mv"|"ma"]: %u})*}
with the ts aquired using clock_gettime(CLOCK_MONOTONIC) and provided in
seconds and milliseconds since the first measurement.
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
The MSG_STATUS_UPDATE message when sent from the client to the server,
has until now indicated a request for a single status update. This was
suitable when the update was for human consumption on occasional basis.
But with the transition to producing status messages for programatical
consumption it makes more sense to just keep the stream on, without the
client having to poll the server for updates. This can in particular
keep the external "status command" mechanism simpler.
Just enabling the stream of status updates would spam the console with
status updates for those users that hasn't updated their clients, so the
client needs to opt-in to the status stream.
Repurpose the status update message (sent from the client) to indicate
that the streaming of status updates should be enabled.
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
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>