Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/docs/recipes/generate-asn1.md
T
Ashin Walpola 0e9525162d Keep the colleague's microbu-esp32c5 tree in this repository
obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but
that tree was gitignored, so a clone of this repository could not build the
firmware it ships. It is now committed here as ordinary files in its own
folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP
bridge's signature verification (--trust) used on the bench. Nothing is
fetched from or pushed to the colleague's repository; this repository and
its remotes carry everything. The folder's own .gitignore keeps build output,
downloaded components and private key material out, as it did there; the
committed file set is identical to that repository's tracked files.

The ESP32-C5 is still flashed from obu-firmware/, which only takes
vanetza-idf from microbu-esp32c5/, so the two stay separate folders.
FLASHING.md says how to take a newer version of the colleague's tree (copy
it over the folder, rebuild, test, commit).
2026-09-23 17:46:40 +02:00

47 lines
1.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Title: Generate code from ASN.1
# How to generate code from ASN.1 definitions
Generating new ASN.1 structs based on ASN.1 definitions can be a daunting task requiring the appropriate ASN.1 compiler.
In particular, we use the **asn1c** fork maintained by [mouse07410](https://github.com/mouse07410/asn1c).
Though the Vanetza repository comes with various pre-generated ASN.1 messages, you may want to add further or revised versions of these messages.
In this case, the following steps guide you how to generate code from ASN.1 definitions on your own.
## Prerequisites
We have streamlined the process of installing and using **asn1c** by relying on a Docker container.
1. Install Docker on your system
2. Build the Docker container from the `vanetza/asn1/Dockerfile` as `vanetza-asn1c:latest`
```bash
docker build --tag vanetza-asn1c:latest vanetza/asn1
```
## Generate ASN.1 code
Our CMake build environment comes with a `generate_asn1c` code generation target.
This target is available if the the `VANETZA_ASN1_WITH_ASN1C` CMake option is enabled.
When you invoke this target, CMake will run the Docker container for you with suitable arguments.
You can specify a custom image by modifying the `VANETZA_ASN1C_CONTAINER` CMake cache variable.
By default, CMake will use the `vanetza-asn1c:latest` image.
1. Update your copy of Vanetza with the new or updated ASN.1 definitions
2. Update the **CMakeLists.txt** file at **vanetza/asn1** accordingly
3. Create a fresh build directory and configure CMake with enabled ASN.1 targets
4. Invoke **asn1c** and compile Vanetza with newly generated code
```bash
# Create a new build directory at the project's root
mkdir build.asn1 && cd build.asn1
# Configure the build with enabled ASN.1 targets and retrieval of ISO ASN.1 files
cmake -DVANETZA_ASN1_WITH_ASN1C=ON -DVANETZA_ASN1_WITH_ISO=ON ..
# Invoke the target calling asn1c
make generate_asn1c
# Compile Vanetza with newly generated ASN.1 code
cmake --build .
```