Commit Graph

169 Commits

Author SHA1 Message Date
Neil Armstrong
87fbc38286 Add local gpio control
This driver permits controlling local (on the system) gpios
by using the libgpiod library.

Support for gpiod v1 and v2 is added, and parses the options
via the yaml parser.

This can be tested with the gpio-sim module:
https://docs.kernel.org/admin-guide/gpio/gpio-sim.html

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-10-30 16:16:36 +01:00
Neil Armstrong
55902b7ba9 Export device_parser struct and functions
Export the functions and struct to enable devices to parse
yaml aswell via the parse_options op to be stored in the
device control_options device property.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-10-30 16:00:40 +01:00
Konrad Dybcio
fbdc677ee6 Merge pull request #9 from lumag/external
Rework cdba to support controlling device via external program
2023-10-23 16:06:07 +02:00
Dmitry Baryshkov
a0de781e1b cdba-server: sanitise file descriptors before device_close()
If we got to device_close(), the parent SSH might have been exited,
making standard file descriptors unusable. Rebind them to /dev/null, so
that any output during device_close (both from the cdba server and the
helpers) doesn't cause SIGPIPE.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-10-02 17:33:13 +03:00
Dmitry Baryshkov
310004badb external: control the board using external program
Control the board using external program. It will be called with 3
arguments: <board> <command> <on/off>, where command is one of "power",
"usb", "key-fastboot", "key-power".

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-10-02 17:33:13 +03:00
Dmitry Baryshkov
8663f5c7b4 backends: mark all functions as static
Now as each backend exports data structure, mark all functions as
static.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-10-02 17:33:13 +03:00
Dmitry Baryshkov
2014d2c0d8 backends: remove unused headers
Remove headers declaring internal backends API.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-10-02 17:33:13 +03:00
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
f09b3e1b2b Merge pull request #14 from superna9999/meson-build
Introduce meson.build
2023-10-02 16:21:03 +02:00
Neil Armstrong
4225dc819c Remove Makefile
Remove the Makefile and all the references in the README
and CI scripts.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-10-02 15:19:21 +02:00
Neil Armstrong
93a2e192e6 Use autobuild for CodeQL
This detects Meson automatically and drops custom build step

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-10-02 15:18:57 +02:00
Neil Armstrong
6cbe23c92e Generate meson cross compile file
Meson requires a cross_compile file for foreign architectures,
and also needs the CPU family.

Add FAMILY to all matrix entries
Remove unused MODE
Print PKG_CONFIG_PATH
Add i386 special Meson setup case
Add cross-compile Meson setup case

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-10-02 15:18:56 +02:00
Neil Armstrong
f7d7054933 Add meson build to CI
Add x86_64 only meson build for now, meson requires some
cross-compile files to be passed.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-10-02 15:18:56 +02:00
Neil Armstrong
606a242dcf Introduce meson.build
Introduce meson.build to be used with the Meson build system,
which handles the dependency and advanced compiler options
for when used on various linux distributions.

The libftdi .so for example has different names on different
distribution, using meson makes sure we can handle those easily,
and easily integrate with other package build systems like
Yocto or Buildroot.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-10-02 11:10:51 +02:00
Dmitry Baryshkov
3e8e3bbcf5 conmux: switch to getaddrinfo
On ARM the conmux.c around gethostbyname() results in a compiler
warning/error:

conmux.c:269:27: error: cast increases required alignment of target type [-Werror=cast-align]
  269 |         saddr.sin_addr = *(struct in_addr *)hent->h_addr_list[0];

Instead of trying to fix the (deprecated) gethostbyname() call, switch
conmux to use getaddrinfo(), which is the proper way to resolve
addresses.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-10-02 11:07:32 +02:00
Konrad Dybcio
c403782f8e Merge pull request #32 from lumag/buf
Extract message sending helpers
2023-09-28 23:45:40 +02: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
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
363bac3232 Merge pull request #33 from calebccff/ppps
support ppps usb control
2023-09-28 12:40:13 +02: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
757f8e5ba6 Merge pull request #18 from lumag/acl
add ACL support
2023-09-23 15:53:48 +02:00
Dmitry Baryshkov
926ca248fd cdba-shell: set the CDBA_USER variable
Set and export the CDBA_USER variable to enable ACL in cdba-server.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-09-23 16:50:11 +03:00
Dmitry Baryshkov
5164ca9234 README: update config file syntax
Describe optional user/group/device mapping in the config file example.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-09-23 16:50:11 +03:00