Commit Graph

34 Commits

Author SHA1 Message Date
Dmitry Baryshkov
3b089f313e device: separate backend operations
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>
2023-10-02 17:33:10 +03:00
Dmitry Baryshkov
fb23cabbc4 device: change device_usb logic
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>
2023-10-02 17:32:13 +03:00
Dmitry Baryshkov
771910e186 cdba-server: extract message-sending helper
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>
2023-09-29 00:45:25 +03:00
Caleb Connolly
d36097392e device: add fcntl.h for musl
Musl requires that this header be explicitly included for O_CREAT,
O_CLOEXEC, etc.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
2023-09-28 11:09:46 +01:00
Caleb Connolly
91daddcb7c support ppps usb control
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>
2023-09-28 11:09:46 +01:00
Dmitry Baryshkov
3ea8df6c70 device: implement access control to the boards
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>
2023-09-23 16:50:11 +03:00
Dmitry Baryshkov
327da0b5b5 device: support specifying active slot
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>
2023-09-21 13:35:04 +03:00
Krzysztof Kozlowski
044be470d2 device: fix -Wsign-compare
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>
2023-05-08 15:02:37 -05:00
Dmitry Baryshkov
961792677a device: notify before booting the board
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>
2022-02-08 09:09:13 -08:00
Bjorn Andersson
6fbc50ca58 device: Hack around EPERM issue
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>
2021-10-05 10:41:48 -07:00
Bjorn Andersson
3004fdf68d device: Reintroduce the alpaca "keep-usb-on" feature
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>
2021-02-22 11:02:57 -06:00
Bjorn Andersson
c43466a98f device: Invoke device->close on exit
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>
2021-01-25 18:48:04 -06:00
Bjorn Andersson
840b737c14 cdba-server: Disconnect USB as well on exit
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>
2021-01-25 17:32:07 -06:00
Bjorn Andersson
d947ca9d46 device: Move alpaca power key state machine to device
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>
2021-01-22 19:57:14 -06:00
Bjorn Andersson
1abac8b200 device: Combine power_on/power_off througout
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>
2021-01-22 18:52:03 -06:00
Dmitry Baryshkov
b626f41185 device: support working in non-automated setup
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>
2020-11-16 14:19:07 -06:00
Bjorn Andersson
decff00617 cdba-server: Change watch timers to ms
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>
2020-10-29 23:44:18 -05:00
Bjorn Andersson
7dbd49c4d2 device: Add fastboot_key_timeout
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>
2020-10-29 18:18:56 -05:00
Dmitry Baryshkov
793969b11d device: split console_fd handling away
Split console_fd handling to a separate source file to simplify
device.c.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2020-09-28 10:27:18 -05:00
Bjorn Andersson
4cabc1c827 Support device "description"
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>
2020-06-29 01:02:57 -07:00
Bjorn Andersson
507f5b8bf3 device: Support device listing of devices without name
Some devices doesn't have a configured "name", don't print "(null)" in
this case.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-06-29 00:10:27 -07:00
Bjorn Andersson
d094208e7c cdba: Add support for listing boards
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>
2020-06-28 23:47:56 -07:00
Bjorn Andersson
313780c7fd cdba-server: Make "console" handling generic
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>
2020-06-27 22:54:53 -07:00
Bjorn Andersson
f068352970 cdba: Support sending break with CDB assist
Add special key 'B' to send a break, currently only implemented with the
CDB assist.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-08-26 10:10:49 -07:00
Bjorn Andersson
c264b11e94 bad: Introduce lockfile for boards
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>
2018-04-22 10:06:00 -07:00