currently in development
documentation will be added later
Also, the code is not finished at all. Currently rewriting the one file code from my secret Gist.
Tip
Easiest way to build the backend app for the ARM64 is to run make build-arm
in the project root.
Tip
Easiest way to build the frontend app for the is to run bun run build
in the project root.
Tip
It is very appropriate to copy the build app
from backend/target/aarch64-unknown-linux-gnu/release/app
to /cartos/backend
directory of the system together with migrations
and service
folder.
Then when running the service for the first time, install requirements using install_requirements.sh
and the service using install.sh
. The logs can be displayed using logs.sh
Note
This process will be probably automated in the future.
After copying the app
and migrations
(and cartos.db
) to the target
using for example scp -r app orangepi@<ip-address>:/cartos/backend
, where when app
is
already present it is suitable to copy the app
as app_new
and then on the server
manually rename app_new
to app
and restart the service using sudo systemctl restart cartos-backend.service
or using frontend feature HW System Restart.
The frontend uses bun as a runtime and build tool.
To build the frontend simply run bun run build
at the frontend folder.
The build artefacts can be found in build
directory.
Then transfer the files of server.js
and build
directory to the /cartos/frontend
path
in the ARM64. Please note that the client side environmental varibales in Vite are embedded
to the application at the runtime. So when using only client side part of the app, it is not
needed to copy the .env
file to the ARM64.
The service running the application can be installed using the same install.sh
script
as the backend. It is not needed to reload the service when new files are loaded to the target.
Using following command.
websocat "ws://0.0.0.0:4000/ws"
When websocat
is not installed or not in path download the prebuilt binaries
and run with the same argument.
./websocat.x86_64-unknown-linux-musl "ws://0.0.0.0:4000/ws"
For testing the api the Bruno open source tool for testing the endpoints was used. The files of bruno requests can be found in the folder bruno_api_test.
Either create directory and file in the project root ./cargo/Config.toml
and insert following values.
[build]
target = "aarch64-unknown-linux-gnu"
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
Or it can be defined in-line using following RUST_FLAGS
.
RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc" cargo build --release --target aarch64-unknown-linux-gnu
Also for the build the Dockerfile can be used.
The container can be build using following command.
docker build -f Dockerfile.rust.build.arm64 -t cartos-backend ./backend
One approach is to log in to the bash in the docker container and perform the build process manually.
Note
This approach is not suitable for CI/CD or any automated approach.
And the image then can be run manually in the project root using docker run --rm -it -v $(pwd):/project rust-cross-aarch64 bash
.
Then the build process for the ARM64 architecture can easily run using Makefile
when following is specified.
arm64:
RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc" cargo build --release --target aarch64-unknown-linux-gnu
Then run the build using make arm64
.
The project is build to the target/<architecture>/
directory.
Note
This approach is suitable for CI/CD or any automated approach.
After building the docker container, just run docker run --rm -it -v $(pwd):/project rust-cross-aarch64
and the
project is automatically build to the target/<architecture>/
directory.
Caution
Buildrun does not work when cross-compiling. Could not figure how to make it work.
The file Dockerfile.rust.buildrun.arm64 can be used to build and then run the application.
To be able to use HW devices such as GPIO or NFC reader, the devices must be passed to the docker build
command.
sudo docker run --device=/dev/gpiochip0 <image-name>
To be able to use GPIO and NFC using pcsd use probably the following command.
sudo docker run --device=/dev/gpiochip0 -v /var/run/pcscd/pcscd.comm:/var/run/pcscd/pcscd.comm gpio-rust-test
sudo vi /etc/systemd/system/cartos-backend.service
sudo systemctl daemon-reload
sudo systemctl enable cartos-backend.service
sudo systemctl start cartos-backend.service
sudo systemctl status cartos-backend.service
Warning
The USB ACS Reader must be reconnected after the system reboots and the service/app running cartos must be also restarted.
After the board reboots, there is a need to unplug and plug the USB of the NFC reader, then run
sudo systemctl restart cartos-backend
so the USB reader can be read by the backend application.
Note
This approach is not suitable but could not find how to make it automatically.
The service for backend can be installed with the usage of files in service.
Installs the requirements for the pcsc and other required configs.
Installs the service to the daemon.
Opens logs of the cartos-backend.service
.
When connected to the university wifi, there is a problem with wifi, which keeps disconnecting and the drivers must be loaded to reset the connection.
sudo rmmod sprdwl_ng && sudo modprobe sprdwl_ng
Tried to change the power saving mode using following commands.
sudo vim /etc/NetworkManager/conf.d/wifi-powersave.conf
Added following configuration.
[connection]
wifi.powersave = 2
And restarted NetworkManager
sudo systemctl restart NetworkManager
Need to create a new table, copy data over to the new table and delete the old table and then rename the new table.
Also when using triggers on the table, they must be also created as new triggers on the newly renamed table.