42 Commits

Author SHA1 Message Date
Dmitry Baryshkov
cdee00d9a4 Merge pull request #83 from stephan-gh/keys
cdba: Add keys to remotely press power or fastboot key
2025-02-21 19:24:42 +02:00
Stephan Gerhold
b6d70e8b0c cdba: Add option to disable timeout_total when set to 0
If cdba is run with "-t 0", then disable the timeout completely and keep
running until manually interrupted. This is useful for non-shared boards,
e.g. when cdba is just used to power up the board remotely and you then SSH
into a standard Linux distro installed on the board.
2025-02-14 13:58:26 +01:00
Stephan Gerhold
06531f3db1 cdba: Add option to run cdba-server locally without ssh
cdba is mainly intended for remote usage, but it also works well for
controlling devices that you just need occasionally and then directly
connect to your local laptop instead of a remote server.

Another use case is if you just use cdba to power up a standard distro on a
remote board and then SSH into it remotely. To avoid interruptions, it's
better to start cdba locally on the server in a tmux session. That way,
temporary disconnections do not power down the board.

From a protocol perspective, everything is transferred through STDIN and
STDOUT. It makes no difference if we have ssh piping the data to a remote
server, or if the data is directly passed to the cdba-server binary started
locally. The functionality works exactly the same.

Add an option for this in the cdba client. If the -h <host> option is
omitted, cdba-server is started locally.
2025-02-14 13:58:26 +01:00
Stephan Gerhold
828d76df63 cdba: Avoid hardcoding ssh binary path
Use execlp() instead of execl() to search the PATH for the ssh binary. This
avoids problems in case the ssh binary is installed in a different path.
2025-02-14 13:58:26 +01:00
Stephan Gerhold
e799564f44 cdba: Document behavior when omitting <boot.img>
The <boot.img> option is optional in cdba. If omitted, cdba falls back to
falls back to running "fastboot continue" to boot the installed operating
system.
2025-02-14 13:58:21 +01:00
Stephan Gerhold
3922dc793a cdba: Add keys to remotely press power or fastboot key
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. :-)
2025-02-14 10:35:27 +01:00
Bjorn Andersson
0852da5424 cdba: Rely on fastboot completion rather than USB disconnect
The purpose for providing different exit codes (2 vs 110) for timeout
before or after fastboot was to allow tools invoking cdba to detect if
the device arrived at and performed fastboot or not.

In most cases relying on the fastboot (USB) disconnect notification
works fine, but in cases where the provided image fails to decompress
the standard fastboot implementation will OKAY the transfer, fail to
process the image and then return to process further fastboot requests.

This has been observed in cases where the image is too big, or when it
contains a big endian kernel.

Change the logic to rely on the "FASTBOOT_DOWNLOAD" response to
determine that we did reach fastboot and where able to upload the image
and then something happened - i.e. "there's a problem with the image" vs
"there's a setup problem".

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2024-11-26 09:48:15 -08:00
Dmitry Baryshkov
bde90b4a15 cdba: replace licence headers with SPDX identifiers
Replace all license headers with the SPDX-License-Identitier headers to
follow the current recommendations.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-03-30 18:06:19 +02:00
Bryan O'Donoghue
68ca7e49b4 cdba: Default to fastboot continue if image is omitted
Add the ability to omit the image from the cdba call. In this case default
to "fastboot continue" on the cdba-server side.

Regular booting continues to work like this:
cdba -b db410c -h benchtop-cdba ./qlt-kernel/build/square_5.x-tracking/boot_t2a.img

New option to boot the default image a proxy for "fastboot continue"
cdba -b db410c -h benchtop-cdba

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
2024-01-17 02:09:05 +00:00
Bjorn Andersson
130720a6df cdba: Introduce status pipe
The updated format and behavior of the status messages is not useful for
human consumption in the console stream, but rather for programatical
consumption by 3rd party tools.

Switch the status message stream to an optional fifo, which can be
consumed separately from the console - by humans or by tools.

The fifo is created and opened and status messages requested, if the
'-s <file>' option is specified.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:19:55 -06:00
Dmitry Baryshkov
18bae8dec9 cdba: remove unnecessary initialisation
Silence Clang warning by removing unused '0' from struct initialisation.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-11-06 12:21:18 +00:00
Dmitry Baryshkov
74e51393b9 cdba: extract message-sending helper
Instad of hand-coding message sending, create a single wrapper that
sends messages to the server.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-09-29 00:45:24 +03:00
Dmitry Baryshkov
bfcbff6439 cdba: fix console handling
Current default is to interpret 20 tilde characters as a signal to power
cycle the board and if there are no power cycles left to exit cdba.
Unfortunately gcc started spurting tilde chars in compile log, so
compiling software on the cdba target can cause cdba exit.

Change the defaults so that by default cdba doesn't interpret received
lines. One can specify '-c 0' on the cdba command line to restore
previous behaviour.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-09-21 13:36:58 +03:00
Krzysztof Kozlowski
647a6c59ad cdba: fix -Wpointer-arith
Pointer arithmetic should not be done on void pointers.

  cdba.c: In function ‘fastboot_work_fn’:
  cdba.c:377:38: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
    377 |         memcpy(msg->data, work->data + work->offset, left);

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Bjorn Andersson
983ec44099 cdba: Support specifying cdba-server path
For debug purposes it's useful to install a user-local version of the
cdba-server and invoke this instead, rather then having to change the
code add a flag to support specifying this on the command line.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-02-22 11:04:09 -06:00
Dmitry Baryshkov
dde2030cda cdba: allow specifying symlink as a boot file
cdba will choke with 'is not a regular file' message if one specifies
symlink as a boot file argument. Support using symlinks as a boot file.

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
2021-01-21 08:56:58 -08:00
Bjorn Andersson
b01431a83d cdba: Print "Waiting for ssh" only for boot
For list and info the "Waiting for ssh" message is anoying, remove it.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-06-29 01:14:02 -07: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
4fee7ed011 cdba: Remove unused struct
I forgot to remove the board_list_request struct as I rewrote the code,
drop it now.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-06-29 00:59:39 -07:00
Bjorn Andersson
afc61c7f6a cdba: Invoke cdba-server from $PATH
Rather than hard coding the server side path to
sandbox/cdba/cdba-server, just invoke cdba-server and rely on the server
side to have the tool in $PATH.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-06-29 00:07:16 -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
72c373451c cdba: Exit nicely on communication error
Receiving an invalid command should lead to termination of the client,
but doing so abruptly will cause the termios not to be reset.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-06-28 23:43:59 -07:00
Amit Kucheria
c5cbe74df2 bad: Rename to cdba-server
cdba-server more accurately reflects its purpose now.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
2020-06-10 10:10:23 -07:00
Bjorn Andersson
bf2521dcdb cdba: Distinguish between timeout before and after fastboot
Exit with error code 2 if a timeout occured before fastboot had finished
executing, to allow scripts to determine if the kernel timed out or if
the board didn't finish fastboot.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-05-20 22:42:21 -07:00
Bjorn Andersson
ca0564cdbb cdba: Revamp timeout handling to support both -t and -T
Revamp the implementation of timeouts, to allow for both a total timeout
(-t) and an inactivity timeout -T at the same time. This is useful for
CI-loops where a board ending up in download mode should be
released quickly (due to inactivity), but a full test can be rather
extensive.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-04-30 21:17:40 -07:00