Simple Lapis project to play with the idea of processing SVD files into visualized documentation of a microcontroller's register layout. Currently only lightly tested on STM32 chips, but with some work to account for formatting/schema differences across manufacturers and architectures, it should be able to work with any Cortex-M / MSP430 / RISC-V chip that has a well-formatted CMSIS SVD file.
The first step is uploading and parsing the SVD files, converting them to a JSON format, and displaying visualizations of the parsed items for verification. The Rust language's excellent svd2rust
project is used to parse uploaded SVD files - thanks, @japaric et al!
The visualizations are just a couple of simple JS/CSS views for now. The 'tree view' is a first try, which displays most of the SVD file's nested structure in a collapsible nested list view. It is fairly fast, but not a very intuitive visualization in my opinion.
The 'grid view' is a bit slow to load on low-end machines, but I think it is easier to interact with. Basic information is shown in one line along the top of the view, followed by a grid of buttons - one for each peripheral. Clicking on a 'peripheral button' unfolds a visualization of its registers and bitfields underneath the grid.
For now, javascript is required to use the web pages generated by this framework. I might look into removing that requirement later on, but it is just too convenient for prototyping.
This is a Lapis web app, so you will need to have Lapis and a compatible Lua framework - I like LuaJIT for performance reasons. The easiest way to install Lapis is to use the luarocks
library manager. On Debian/Ubuntu/etcs:
apt-get install luarocks
luarocks install lapis
This project also relies on the bit32
library for bitwise operations. It was introduced in Lua v5.2, but you can install a backport for v5.1 (which LuaJIT uses) with:
luarocks install bit32
The Postgres database connection may require the luacrypto
package for (I believe) md5 hashing, and luacrypto
is not listed in the Lapis dependency files. To install it:
luarocks install luacrypto
If you run into compilation errors, try building with OpenSSL v1.0.x by installing the appropriate development libraries. On Debian/Ubuntu/etc:
apt-get install libssl-1.0-dev
If you don't want to use the luacrypto
library, I think you can avoid the dependency by building the pgmoon
library from source without md5 hashing enabled, but I have not done that and I don't have instructions for how to do it.
The default postgres
database user should be created automatically when you install Postgres, but you will need to update its password. Log in as the postgres
OS user, enter the postgres shell (psql
), and then enter \password postgres;
to update the postgres
database user's password. Note that the configuration in config.lua
refers to the database user called postgres
, not the operating system user. If that bothers you, you can create a new database user with a different name to avoid that confusion.
You'll also need to run cargo build
in the static/rust/svd_reader
directory for the web app to work properly, and you need the Rust language and toolchain for that; for installation instructions, see: