Pete [Wed, 10 Apr 2024 10:25:05 +0000 (03:25 -0700)]
Use the IPv6-friendly default hostname.
Pete [Mon, 8 Apr 2024 08:28:15 +0000 (01:28 -0700)]
Allow binding to a specific address.
Sven Rademakers [Thu, 28 Mar 2024 15:00:36 +0000 (15:00 +0000)]
migrate to tracing fwk
Use the tracing framework for logging purposes. It will enable us to do
better logging and tracing going forward. SimpleLogger is therefore removed.
This commit also adds hourly log-rotation to '/var/log/bmcd'
Sven Rademakers [Thu, 28 Mar 2024 12:24:11 +0000 (12:24 +0000)]
enable gpiod v2
Now that we updated to kernel 6.6, we can disable v1 compatibility
mode.
fixes https://github.com/turing-machines/BMC-Firmware/issues/56
Sven Rademakers [Mon, 25 Mar 2024 14:59:59 +0000 (14:59 +0000)]
persistency fix
fixes https://github.com/turing-machines/BMC-Firmware/issues/191
Sven Rademakers [Sat, 23 Mar 2024 09:24:33 +0000 (09:24 +0000)]
add hostname to about
related to https://github.com/turing-machines/BMC-Firmware/issues/188
Sven Rademakers [Wed, 13 Mar 2024 14:52:53 +0000 (14:52 +0000)]
authentication: fix loopback detection
When an request is coming from a loopback interface, authentication is
not required. This commit fixes ipv4 addresses mapped inside ipv6
addresses, by first converting to a canonical address. There addresses
were otherwise falsely tested as a non loopback addresses.
Sven Rademakers [Wed, 13 Mar 2024 11:05:10 +0000 (11:05 +0000)]
remove peekpoke dependency
peekpoke requires a clang toolchain in order to build.
Use a simple write to /dev/mem instead. which doesnt require any
additional packages.
Sven Rademakers [Thu, 7 Mar 2024 12:35:24 +0000 (12:35 +0000)]
update dependencies
Sven Rademakers [Fri, 16 Feb 2024 11:34:14 +0000 (11:34 +0000)]
Implemented v2.5 changes
Changes to the `PinController` and `PowerController`.
* The `bmcd` remains fully compatible with v2.4 and v2.5 hardware.
* The additional Node1 USB source switching for v2.5 is
not yet implemented. The switches are currently configured so that: USB0 is routed to the
usb hub and usb2 is routed to the USB-A port.
* The actual location of gpio pins inside gpiod is still tentative at
this point for TPv2.5.
Sven Rademakers [Fri, 16 Feb 2024 09:23:13 +0000 (09:23 +0000)]
pin_controller: load gpio pins by label
Sven Rademakers [Fri, 16 Feb 2024 09:01:10 +0000 (09:01 +0000)]
power_controller: leds: support latest dts changes
A fallback is implemented to support both old and new definitions of the
status and power sysfs paths
Sven Rademakers [Thu, 15 Feb 2024 19:50:23 +0000 (19:50 +0000)]
power_controller: read gpio pins from device tree
This commit is part of the effort to move configuration of hardware more
closely to the linux platform
Sven Rademakers [Thu, 15 Feb 2024 19:47:27 +0000 (19:47 +0000)]
update ttySx remapping
We are planning to remap the tty's devices to match them numerically
with the actual nodes. This commit prepares for this change
Sven Rademakers [Wed, 14 Feb 2024 13:11:48 +0000 (13:11 +0000)]
app_persistency: file open fix
An error was logged when there is no persistency file available on the
system. Even though the bmcd recover from this quickly, a fix was
made so that no attempt is made to open a non existing file.
Sven Rademakers [Sat, 3 Feb 2024 20:29:26 +0000 (20:29 +0000)]
api: added reboot into FEL mode
FEL mode is a recovery mechanism of BMC's bootROM.
Sven Rademakers [Fri, 2 Feb 2024 17:18:26 +0000 (17:18 +0000)]
node_info api rework
Changed the data format and implementation of the node_info
functionality.
Sven Rademakers [Mon, 29 Jan 2024 10:57:37 +0000 (10:57 +0000)]
increase sleep RK1 flashing
* increased the waiting time for the RK1 to announce itself on the USB
subsystem.
* small typo's and update of dependencies
Sven Rademakers [Mon, 18 Dec 2023 15:13:37 +0000 (15:13 +0000)]
Node MSC over BMC_USB_OTG
Sven Rademakers [Fri, 19 Jan 2024 20:54:14 +0000 (20:54 +0000)]
bump dependencies to latest
Sven Rademakers [Fri, 19 Jan 2024 20:33:09 +0000 (20:33 +0000)]
IPv6 dual stack binding fix
Listening only on '::' is sufficient to bind both to IPv4 and IPv6.
Sven Rademakers [Thu, 18 Jan 2024 13:14:40 +0000 (13:14 +0000)]
serial over websocket
This commit contains a websocket implementation for a given node. This
websocket implementation communicates with `bytes` messages. A watchdog
is implemented to monitor client pings.
a websocket can be opened using the following API call:
`/api/bmc/serial/ws?node=0`, which opens a serial connection over a
websocket to node 1.
Sven Rademakers [Thu, 21 Dec 2023 10:40:12 +0000 (10:40 +0000)]
serial_service: Prep work for byte stream support
This commit aims to refactor the serial_service component. The
functionality stays the same, therefore no changes in the external API as well.
An additional hook is added in the serial handler that will be used in
subsequent commits to implement a byte stream object with.
Implemented the `open_channel()` function which was marked as `todo!()`.
This channel is a asynchronous bi-directional bytes transport. Purposed
to handle the communication to the various Nodes on the TuringPi board.
No0ne [Tue, 19 Dec 2023 21:16:37 +0000 (22:16 +0100)]
open port 80+443 on ipv6 too
Sven Rademakers [Tue, 19 Dec 2023 17:58:45 +0000 (17:58 +0000)]
data_transfer: remove workaround
After consulting the maintainers, it was recommended to enable
`multi_members` on the decoder. Via this way the decoder will try to
decode more content after its finished decoding the first image. This
will make sure the 256 validation gets triggered.
Ruslan Akbashev [Tue, 19 Dec 2023 13:18:52 +0000 (17:18 +0400)]
cargo: point rustpiboot to upstream instead of a fork
Ruslan Akbashev [Mon, 18 Dec 2023 10:24:44 +0000 (14:24 +0400)]
api: add `node_info` set & get endpoints
For testing, use
curl 'https://turingpi.local/api/bmc?opt=set&type=node_info' \
-X POST \
-H "Content-Type: application/json" \
-d '
{
"node_info":
[
{
"node": 1,
"module_name": "Raspberry Pi CM4",
"uart_baud": 115200
},
{
"node": 3,
"name": "New Name"
}
]
}' \
-k \
--header "Authorization: Bearer $token"
Closes #77
Sven Rademakers [Sun, 17 Dec 2023 13:51:05 +0000 (13:51 +0000)]
Changed firmware_update definition to usb_boot
This commit contains only definition and name changes. The aim is to
be more descriptive.
Sven Rademakers [Fri, 15 Dec 2023 16:20:25 +0000 (16:20 +0000)]
Simply usb boot interface
In the current firmware_update module, there are a lot of assumptions
made to support use cases that probably never are going to be
implemented.
Ruslan Akbashev [Fri, 8 Dec 2023 19:29:40 +0000 (23:29 +0400)]
fwupdate: use `rockusb` driver for maskrom rk1 transfers
As a consequence, this enables functionality of `tpi advanced msd` for
rk1 nodes.
Closes turing-machines/BMC-Firmware#137
Sven Rademakers [Mon, 4 Dec 2023 14:22:17 +0000 (14:22 +0000)]
get latest on dependencies
Sven Rademakers [Mon, 4 Dec 2023 11:02:06 +0000 (11:02 +0000)]
streaming_data_service: fix get error msg deadlock
When an error occurs during a file transfer, method
`return_transfer_error` always falls back on the default error message
'transfer canceled'.
The issues is fixed by not holding the streaming_data_service state lock
when waiting for the error message to bubble up. This gives the
streaming_data_service the opportunity to update the error state.
Sven Rademakers [Thu, 30 Nov 2023 14:27:18 +0000 (14:27 +0000)]
data_transfer: accept URL as transfer sources
transfer data from an alternative source, HTTP, for firmware and flash
upgrades.
Sven Rademakers [Fri, 1 Dec 2023 18:33:10 +0000 (18:33 +0000)]
patch async-compression: make sure to exhaust reader
This commit makes sure that underlaying readers are exhausted.
This fixes a bug that sha256 validation was not triggered as the stream
was still ready to accept new data even though the decompressor which
was on a higher layer already communicated that the stream is EOF.
Next to that, some logging improvements are present in this commit
Sven Rademakers [Fri, 1 Dec 2023 10:46:20 +0000 (10:46 +0000)]
API: expose crc options
When initiating a file transfer (to flash a node or upgrade firmware) a
sha256 query parameter can now be passed that will be used to verify
integrity of the written image:
`/api/bmc?opt=set&type=flash&file=/my/file.img&node=1&sha256=
74eea5165db`
A query option `skip_crc` can be passed to skip the crc validation step.
This step gets executed after writing the node. It reads back the whole
written area and compares this crc with the crc checksum of the written
data:
`/api/bmc?opt=set&type=flash&skip_crc`
Sven Rademakers [Thu, 30 Nov 2023 17:08:43 +0000 (17:08 +0000)]
streaming_data_service: improvements
* The BMC will restore USB and power state of the given node even if a
transfer was aborted prematurely.
* The multi-part HTTP handler cancels the node flash process if a partial
byte-stream was received.
Sven Rademakers [Wed, 15 Nov 2023 14:05:04 +0000 (14:05 +0000)]
xz decoding: calculate available memory
determine the amount of allocate-able memory before initializing the
decoder. This lowers the chance of running out of memory.
Sven Rademakers [Wed, 15 Nov 2023 10:24:25 +0000 (10:24 +0000)]
added xz decoder
xz decoding support is very unstable at the moment due to the high
demand of memory.
Sven Rademakers [Wed, 15 Nov 2023 09:05:04 +0000 (09:05 +0000)]
change read interface to AsyncRead
This work prepares the code base for easy integration with decoding
codec streams. Using `AsyncRead` means we can get rid off an extra
buffering step when using decompression
Sven Rademakers [Tue, 28 Nov 2023 12:47:28 +0000 (12:47 +0000)]
v2.0.5
Sven Rademakers [Tue, 28 Nov 2023 12:44:49 +0000 (12:44 +0000)]
pin_controller: fix clearing of boot pin
When toggling USB mode from flashing to another mode, the RPI_BOOT pin
is not cleared. This means that a given node does not boot when
restarted until this pin is cleared via an alternative way.
Sven Rademakers [Thu, 23 Nov 2023 17:15:14 +0000 (17:15 +0000)]
v2.0.4
Sven Rademakers [Thu, 23 Nov 2023 14:05:57 +0000 (14:05 +0000)]
USB route added 'flash' option to API
The boot pin state is added to the USB state, as its closely related to
the different roles a given node fulfills.
Sven Rademakers [Tue, 21 Nov 2023 12:22:35 +0000 (12:22 +0000)]
KEY_1 long press improvement.
Long pressing KEY_1 will execute the inverse power action of on normal press.
Prior, long pressing would always force all nodes on.
See the state table:
| state | long_press | All nodes |
| :---------------- | :--------: | :-------: |
| 0b0000 | False | On |
| 0b0111 | False | Off |
| 0b1111 | False | Off |
| 0b0000 | True | On |
| 0b0111 | True | On |
| 0b1111 | True | Off |
Sven Rademakers [Wed, 15 Nov 2023 17:59:24 +0000 (17:59 +0000)]
bump patch version to v2.0.3
Sven Rademakers [Wed, 15 Nov 2023 17:48:02 +0000 (17:48 +0000)]
update clap dependency
Sven Rademakers [Wed, 15 Nov 2023 17:44:02 +0000 (17:44 +0000)]
streaming_data_service: wait for error state
wait up to a maximum of 5 seconds for the worker attached to the
streaming service to shutdown and return its error message.
Sven Rademakers [Wed, 15 Nov 2023 10:23:39 +0000 (10:23 +0000)]
improve Gzip implementation
makes use of the gzip encoder inside async_compression crate.
Return archive as streaming body.
Sven Rademakers [Sun, 12 Nov 2023 19:44:46 +0000 (19:44 +0000)]
created v2.0.2
Sven Rademakers [Sun, 12 Nov 2023 11:44:16 +0000 (11:44 +0000)]
add bmcd reload endpoint
Sven Rademakers [Sun, 12 Nov 2023 11:09:14 +0000 (11:09 +0000)]
added backup endpoint
Compresses filesystem overlay into a `tar.gz` and returns it as response.
Uses zlib for compression.
Sven Rademakers [Sun, 12 Nov 2023 00:22:41 +0000 (00:22 +0000)]
upgrade_worker: fix clippy
Sven Rademakers [Sat, 11 Nov 2023 22:41:58 +0000 (22:41 +0000)]
os upgrade: dont block runtime
schedule blocking `osupgrade` process call on designated thread.
Sven Rademakers [Sat, 11 Nov 2023 19:44:22 +0000 (19:44 +0000)]
streaming_data_service: cleanup
* updated implementation from `AsyncRead` to `AsyncBufRead`.
* moved CRC checker from reader half to writer half. see `WriteWatcher`
* split data_transfer into its own file.
Sven Rademakers [Fri, 10 Nov 2023 16:12:18 +0000 (16:12 +0000)]
format NodeId's with Display trait
In order for smooth API handling, align response json with UI text
Sven Rademakers [Fri, 10 Nov 2023 11:50:23 +0000 (11:50 +0000)]
tokio: remove patch, `take` fix landed in 1.34
Sven Rademakers [Fri, 10 Nov 2023 10:31:41 +0000 (10:31 +0000)]
rename firmware_runner to upgrade_worker
Sven Rademakers [Fri, 10 Nov 2023 07:23:27 +0000 (07:23 +0000)]
flash node: improve flashing performance
Decreased the flashing time from 16m to 6m40s.
Conducted a dd test locally on the BMC to determine the correct block
size for writing to a raspberry CM4.
Times measured using a 206Mb file:
512B 1m50.22s
512K 43.0s
1M 43.03s
4M 42.96s
8M 43.19s
16M 43.00s
32M 45.95s
Concluded 4M is the optimal blocksize.
Ran some tests writing `2023-05-03-raspios-bullseye-armhf-lite.img`
* using dd 4M => 6m23.86s
* using tpi with -l flag => 6m22s
* using tpi over local network => 6m40s
Sven Rademakers [Thu, 9 Nov 2023 11:13:46 +0000 (11:13 +0000)]
redirect_service: forward to correct port
The redirect service was not taking into account an explicitly configured
HTTP port. Resulting i a redirect that was not resolvable.
By parsing the configured port in the destination location, browsers now
can forward correctly requests to port 80.
Sven Rademakers [Wed, 8 Nov 2023 16:51:15 +0000 (16:51 +0000)]
expose additional endpoint
Exposes 2 additional endpoints in the API. Intended to serve the BMC-UI.
It sorts version related strings in a 'about' call and info about your
specific board into 'info'
Sven Rademakers [Mon, 6 Nov 2023 13:09:30 +0000 (13:09 +0000)]
v2.0.1 include fixes during RC1 testing
Sven Rademakers [Mon, 6 Nov 2023 12:50:06 +0000 (12:50 +0000)]
Simplify power state
Previously, an attempt was made to make a power controller with a on
and off state. The "on" state had a sub-state where nodes could be
activated, they were participating in the on/off state
toggling. Power commands to nodes that were 'deactivated` were omitted.
After some trial and error, its concluded that for the end user its
confusing as:
* there is no real way to detect if a module is inserted at a slot and
therefore can be labeled as active. As a fallback it was up to the
user to flag a given node as active.
* there was no easy way to see if a node was/is active and to what state
it will go when an global on or off command was given
The global power state is removed and the interface is simplified.
* on restart the previous power-state prior reboot is restored
* pressing KEY_1 will toggle all nodes on if 3 or less nodes are powered
on
* pressing KEY_1 when all nodes are off will turn all nodes on
* pressing KEY_1 when all nodes are on will turn all nodes off
* long press KEY_1 will force every node to on
* the API does not cache a global state, command `on --node 1` will turn
node 1 on etc
Sven Rademakers [Mon, 6 Nov 2023 12:46:45 +0000 (12:46 +0000)]
persistency: improve logging, decrease write timeout
decrease write timeout. Actual caching is handled by linux filesystem.
Sven Rademakers [Mon, 6 Nov 2023 10:15:43 +0000 (10:15 +0000)]
ban_patrol: simplify ban deadline
Improvements to simplify deadline logic. The time the user is banned
from authenticating in case of exceeding the authentication threshold
Sven Rademakers [Mon, 6 Nov 2023 00:10:25 +0000 (00:10 +0000)]
Update default_config.yaml
Add trailing backslash to www path
Ruslan Akbashev [Sat, 4 Nov 2023 00:47:14 +0000 (04:47 +0400)]
serial: replace custom ring buffer impl with a crate
Fixes turing-machines/BMC-Firmware#135
Sven Rademakers [Fri, 3 Nov 2023 16:26:47 +0000 (16:26 +0000)]
bring back info logging of `bmcd` module
Sven Rademakers [Fri, 3 Nov 2023 16:23:01 +0000 (16:23 +0000)]
fix typo in reboot API query
Sven Rademakers [Fri, 3 Nov 2023 15:40:20 +0000 (15:40 +0000)]
move the default www directory to /srv/bmcd/www
According FHS:
'/srv – this directory should contain data that is served by the system'
Sven Rademakers [Fri, 3 Nov 2023 15:19:39 +0000 (15:19 +0000)]
Expose more daemon configuration to config file
in particular:
* port
* www dir
* enable/disable http redirect
Sven Rademakers [Fri, 3 Nov 2023 13:30:34 +0000 (13:30 +0000)]
authentication: auto reload users
Reload the internal cache when an users are added or removed. This
prevents granting stale users access the API + UI.
Implementation is based on `inotify` subsystem.
Sven Rademakers [Fri, 3 Nov 2023 08:11:13 +0000 (08:11 +0000)]
fix unit-test ban_patrol
Sven Rademakers [Wed, 25 Oct 2023 16:28:41 +0000 (17:28 +0100)]
auth: ban consecutive failed requests
Consecutive unauthenticated requests that exceed a given threshold will
be banned for a given period before they are allowed to make any new
request. Every consecutive failed attempt exponentially increases the
cool down period in which the peer is blocked from authenticate itself
up to a upper limit.
Sven Rademakers [Wed, 25 Oct 2023 10:57:02 +0000 (11:57 +0100)]
config: added authentication group
default_config is updated with the exposed values and a description is
added.
Sven Rademakers [Wed, 25 Oct 2023 10:33:52 +0000 (11:33 +0100)]
humantime: convert durations into human readable
Sven Rademakers [Fri, 3 Nov 2023 08:42:41 +0000 (08:42 +0000)]
fix power init
Sven Rademakers [Fri, 3 Nov 2023 07:57:10 +0000 (07:57 +0000)]
bmc_application: restore power and usb settings
This commit contains 2 improvements:
* Internal operations are not triggering persistency updates anymore.
Minimizing flash wear.
* After a flash command the power and USB settings are restored to their
previous values
Sven Rademakers [Fri, 3 Nov 2023 07:49:03 +0000 (07:49 +0000)]
expose reboot over API
Sven Rademakers [Wed, 1 Nov 2023 15:02:01 +0000 (15:02 +0000)]
v2.0.0
Ruslan Akbashev [Tue, 31 Oct 2023 12:15:58 +0000 (16:15 +0400)]
stub: adjust `get_device_path` signature to original
Ruslan Akbashev [Tue, 31 Oct 2023 12:05:04 +0000 (16:05 +0400)]
usbboot: move searching from `/dev/disk/by-id` to `/sys/block`
After turing-machines/BMC-Firmware@
1193ce32 [1] mdev replaced eudev, and
with it directory of symlinks /dev/disk/by-id stopped being generated.
Work around this by searching in /sys/block instead.
[1]: https://github.com/turing-machines/BMC-Firmware/commit/
1193ce329f952297ab9604238097523839a2c287
Sven Rademakers [Tue, 31 Oct 2023 13:15:00 +0000 (13:15 +0000)]
streaming_data_service: improve error message
When the channel closes which the sender uses to transport the file
data. Ask the `StreamingDataService` what the current error state is
rather then just responding to the client with a generic answer.
Sven Rademakers [Tue, 31 Oct 2023 07:31:59 +0000 (07:31 +0000)]
do not run clippy on all features
Feature "stubbed" is meant for development purposes.
Sven Rademakers [Mon, 30 Oct 2023 15:35:45 +0000 (15:35 +0000)]
Update README.md
Sven Rademakers [Mon, 30 Oct 2023 11:51:39 +0000 (11:51 +0000)]
added stubs
Stubs can be enabled with compiling feature flag 'stubbed'
* gpio controllers dont do anything
* serial returns static content
* firmware_update writes to /tmp/stubbed_device
* usb filtering is omitted
Sven Rademakers [Mon, 30 Oct 2023 09:25:48 +0000 (09:25 +0000)]
cleanup module directories of hal
Sven Rademakers [Sat, 28 Oct 2023 09:31:35 +0000 (10:31 +0100)]
sanitize module layout files
added a clippy lint to only allow self named modules files
Sven Rademakers [Thu, 26 Oct 2023 19:53:54 +0000 (20:53 +0100)]
update dependencies and remove pinned rockusb commit
Sven Rademakers [Thu, 26 Oct 2023 02:25:22 +0000 (03:25 +0100)]
auth: default to Basic WWW-Authenticate header
Sven Rademakers [Wed, 25 Oct 2023 09:39:47 +0000 (10:39 +0100)]
authentication_context: fix failing unit-tests
Sven Rademakers [Wed, 25 Oct 2023 09:27:51 +0000 (10:27 +0100)]
auth: format authorization denied based on scheme
When responding with an unauthorized response, make sure that the
correct header is returned based on the scheme used.
Only a "realm" attribute is used when the scheme is unknown or not
parse-able.
Ruslan Akbashev [Wed, 25 Oct 2023 07:07:50 +0000 (11:07 +0400)]
auth: fix clippy and fmt
Ruslan Akbashev [Tue, 24 Oct 2023 12:37:14 +0000 (16:37 +0400)]
auth: ask for `Basic` authentication scheme
This causes browsers to ask and use authentication credentials
Sven Rademakers [Thu, 19 Oct 2023 10:49:37 +0000 (11:49 +0100)]
toggle `RPI_BOOT` signal instead of keeping it high
This way we can support a wider range of compute modules for image upgrade.
In particular, on an Orange-Pi(RK3566), the RPI_BOOT pin is connected to short
the MMC clock. This forces the device to go into Maskrom mode. Keeping the
RPI_BOOT pin logically means that its impossible for this device to
write anything to MMC.
Sven Rademakers [Wed, 18 Oct 2023 12:11:32 +0000 (13:11 +0100)]
firmware_update: cleanup error and logging
* Cleaned up the async logging/state component. Error information should
flow back via `FwUdateError`.
* Flattened the `SUPPORTED_DEVICES` and `SUPPORTED_MSD_DEVICES`. All
official supported devices need to be able to run as MSD. If
there are any technical reasons why this is not feasible an appropriate
error response is sufficient to differentiate between supported and
not supported MSD devices.
Sven Rademakers [Mon, 16 Oct 2023 14:55:22 +0000 (15:55 +0100)]
streaming_data_service:
* Includes patch for tokio::io::Take which caused overflows when
steaming files over 4GB
* Decreased lock contention of the streaming_data_service state by
exposing the "Sender" of the data. (`take_sender()`)
* Upgraded from peer validation to handle validation. Only data that is
send to the correct handle endpoint is allowed.
* various fixes and improvements
Sven Rademakers [Fri, 13 Oct 2023 16:23:35 +0000 (17:23 +0100)]
show buildroot info in `other` API endpoint
Sven Rademakers [Fri, 13 Oct 2023 14:21:48 +0000 (15:21 +0100)]
streaming_data_service: added write progress
The status endpoint returns now the amount of bytes written to a given
node. e.g. `http://<HOST>/api/bmc?opt=get&type=flash`
Sven Rademakers [Fri, 13 Oct 2023 11:21:51 +0000 (12:21 +0100)]
streaming_data_service: added support for local file writes
Sven Rademakers [Thu, 12 Oct 2023 12:51:43 +0000 (13:51 +0100)]
streaming_data_service: improve logging of service