Simulate a device without building a disk image
You can try out OTA Connect without having to build a whole device image. This can be useful for testing the system outside of actual device updates. In this guide, you will install aktualizr (the OTA client software) on your local machine, create a directory with configuration files and credentials for aktualizr to use, and run aktualizr from there.
1. Prerequisites
-
A Linux or MacOS machine to run aktualizr on
-
Provisioning credentials (
credentials.zip
file)
2. Install aktualizr locally
The first step is to install an aktualizr binary on your system. You can install packages for MacOS (with homebrew), Ubuntu 16.04, or Ubuntu 18.04. If you use a different system, you will need to build from source.
wget https://github.com/advancedtelematic/aktualizr/releases/download/2019.5/aktualizr-ubuntu_16.04.deb
sudo apt install ./aktualizr-ubuntu_16.04.deb
sudo systemctl stop aktualizr.service
sudo systemctl disable aktualizr.service
wget https://github.com/advancedtelematic/aktualizr/releases/download/2019.5/aktualizr-ubuntu_18.04.deb
sudo apt install ./aktualizr-ubuntu_18.04.deb
sudo systemctl stop aktualizr.service
sudo systemctl disable aktualizr.service
brew tap advancedtelematic/otaconnect
brew install aktualizr
Modify as needed for your distro. See https://github.com/advancedtelematic/aktualizr for further instructions
sudo apt install asn1c build-essentialclang clang-format-6.0 clang-tidy-6.0 cmake \
curl doxygen graphviz lcov libarchive-devlibboost-devlibboost-filesystem-dev \
libboost-log-dev libboost-program-options-dev libboost-serialization-dev \
libboost-iostreams-dev libcurl4-openssl-dev libdpkg-dev libostree-dev libp11-2 \
libp11-dev libpthread-stubs0-dev libsodium-devlibsqlite3-devlibssl-devlibsystemd-dev \
python3-dev python3-openssl python3-venv sqlite3 valgrind
git clone --recursive -b 2019.5 https://github.com/advancedtelematic/aktualizr
cd aktualizr
mkdir build
cd build
cmake ..
make install
3. Prepare an environment for a simulated device
Make a directory for each device that you want to simulate. This directory will store your configuration files for that device, plus the device metadata and keys.
Each directory should contain the following:
-
credentials.zip
-
sota_local.toml — a config file for aktualizr
-
(Optional) A
virtualsec.json
file containing the configuration for one or more secondary ECUs.[1].]
An example directory is below:
localtest/
├── credentials.zip
├── virtualsec.json
└── sota_local.toml
[provision]
provision_path = "credentials.zip"
primary_ecu_hardware_id = "local-fake"
[logger]
loglevel = 1
[storage]
path = "storage"
[pacman]
type = "none"
[uptane]
secondary_config_file = "virtualsec.json"
{
"virtual": [
{
"partial_verifying": "false",
"ecu_hardware_id": "demo-virtual",
"full_client_dir": "storage/demo-vsec1",
"ecu_private_key": "sec.private",
"ecu_public_key": "sec.public",
"firmware_path": "storage/demo-vsec1/firmware.bin",
"target_name_path": "storage/demo-vsec1/target_name",
"metadata_path": "storage/demo-vsec1/metadata"
},
{
"partial_verifying": "false",
"ecu_hardware_id": "demo-virtual",
"full_client_dir": "storage/demo-vsec2",
"ecu_private_key": "sec.private",
"ecu_public_key": "sec.public",
"firmware_path": "storage/demo-vsec2/firmware.bin",
"target_name_path": "storage/demo-vsec2/target_name",
"metadata_path": "storage/demo-vsec2/metadata"
}
]
}
Aktualizr’s config file format changed with version 2019.5, released July 12, 2019. These instructions apply only to version 2019.5 and later. |
4. Run aktualizr in the prepared directory
From the directory you’ve created, run aktualizr and point it to the current directory for its configuration:
aktualizr -c .
This will start aktualizr in its normal mode: it will provision with the server using the credentials.zip
provided, then start listening for updates. You can also selectively trigger aktualizr or use any of the other options; you just need to specify -c .
each time.
You should now be able to see your simulated device provisioned into your OTA Connect account, with two secondary ECUs listed.
Because the aktualizr config we’ve given uses relative paths, you must run aktualizr from the directory you created. However, if you prefer, you can use absolute paths in the config file instead. The reason we’ve chosen to use relative paths is to make it easy to simulate multiple distinct devices, by simply making a copy of the whole directory. |