A set of small command-line tools for the STAR-Dundee Brick Mk3: loopback, RMAP write and read, packet send and receive, error injection and time-codes.
They were written at IAA-CSIC to bring up and configure the GR718B SpaceWire router of the PLATO Main Electronic Units, and to learn how to package a C project properly with Autoconf and Automake.
# generate configure and Makefile.in $ autoreconf -vis # point configure at the STAR-System SDK $ env CPPFLAGS='-I/usr/local/STAR-Dundee/STAR-System/inc/star/' \ LDFLAGS='-L…' ./configure checking star-api.h presence... yes config.status: creating src/Makefile $ make # write a GR718B port control register over RMAP $ ./src/rmap -a 0x00000884 -d 0x000000FF -t 2 $ ./src/rd_rmap -a 0x00000884 -t 2
SpaceWire is the point-to-point data link used on most ESA spacecraft. The STAR-Dundee Brick Mk3 is a USB interface with SpaceWire links that lets a PC act as a node on the network. Its vendor library, the STAR-API, exposes devices, channels and transfer operations.
Each tool is a short C program that does one thing on the network: open a channel on a Brick link, build a packet or an RMAP command, submit the transfer operation and print what came back. Options are parsed with getopt, so the tools can be chained from shell scripts.
The first program was a 64-byte loopback: Brick link 1 sends a packet with a one-byte address path, the GR718B routes it to port 2, and Brick link 2 receives it. Without the router the packet arrives with the path byte still in the header and is flagged as wrong.
The PLATO Main Electronic Units use a GR718B radiation-tolerant router to connect the instrument control unit, the six N-DPUs and the power supplies. On the test bench, the router ports, link rates and routing tables are set by RMAP writes from the ground equipment.
These tools did that job on the bench. The scripts/ folder holds the bash sequences that configure Router A of MEU 1 and check the links.
Loopback setup from test_loopback.c: 64-byte packets, both Brick links set to 100 Mbit/s (clock multiplier 2, divisor 4).
The project started with a hand-written Makefile and moved to Autoconf and Automake on its second day. Two short input files replace the Makefile, and the generated configure script does the portability work: it finds the compiler, checks that the vendor SDK is installed, and writes Makefiles with the standard targets.
Runs aclocal, autoconf, autoheader and automake, and installs the helper scripts.
configure.ac, Makefile.am → configure, Makefile.inProbes the system and stops early if the STAR-API header is missing.
Makefile.in → Makefile, config.hBuilds the nine programs, each linked against the STAR libraries it needs.
src/*.c → src/loopback, src/rmap…Packs a source tarball that builds with only a C compiler and make.
→ spw-software-collection-1.0.tar.gzforeign tells Automake not to demand the GNU set of files (NEWS, AUTHORS, ChangeLog).-Wall -Werror turns Automake warnings into errors, so a bad Makefile.am fails at once.AC_CHECK_HEADER is the useful part: if the proprietary SDK is not on the include path, configure stops with a message that says which CPPFLAGS to pass, instead of a compiler error halfway through the build.Makefile.am is two lines: SUBDIRS = src and dist_doc_DATA = README.md.make install, make dist, make distclean and make TAGS for Emacs navigation.scripts/build.sh builds in a separate build/ folder by calling ../configure from inside it. Objects and binaries stay out of the source tree, and .gitignore lists every file Autotools generates, so the repository holds only the two inputs and the sources.
configure.ac plus a clear error message saves more time than any amount of README.LIBSTAR lines in configure.ac show the next step: an AC_CHECK_LIB per STAR library, so the link step is checked as well as the header._LDADD lists repeat the same libraries. A shared variable or LIBS set by configure would shorten Makefile.am to one line per tool.Nine programs are built by default. Most share the same options: -a address (hex), -d data (hex), -t timeout in ms, -v verbose, -i flash the Brick LEDs to identify it, and in some tools -s to pick a Brick by serial number when several are connected.
| Binary | Source | What it does |
|---|---|---|
| list | test_list_devices.c | Lists the STAR-Dundee devices on USB with name and serial number, and can identify or reset them. |
| loopback | test_loopback.c | Sends a packet on link 1 through the router and checks it arrives on link 2. |
| rmap | test_rmap.c | RMAP write: puts a 32-bit value into a router register (-a, -d). |
| rd_rmap | test_read_rmap.c | RMAP read: reads a register and decodes the reply header and status. |
| send | test_send.c | Sends a single packet on one link. |
| receiv | test_receiv.c | Receives packets continuously on one link and stores them in a file. |
| inject_error | test_error.c | Sends a packet split into data chunks with a disconnect or parity error in the middle, to exercise error handling on the link. |
| timecode | test_timecode.c | Transmits SpaceWire time-codes from one thread while another receives packets. |
| reset | test_reset_dev.c | Resets the Brick. |
Also in src/, not in the default build: router set-up experiments (test_static_routing.c, test_la_routing.c, test_la2_routing.c, test_routing_NDPU.c), multi-packet RMAP loads (load_reg.c, stipa.c, apus.c) and disable_if.c. utility.c holds packet-dump and buffer helpers taken from the STAR-Dundee example code.
The router is configured through its port 0 with RMAP writes. Once rmap and rd_rmap worked, configuring a whole router became a shell script: one line per register.
Register addresses and values live in scripts/router_defs.sh, so the same names are used by every script.
| rtr1A_config.sh | Port control and routing tables for Router A of MEU 1. |
| get_rtr1A_status.sh | Reads back port and link status. |
| rtr1A_loopback_check.sh | Checks the links after configuration. |
| rtrBroadcast_config.sh | Sets up and tests broadcast routing. |
| rtr_sist_test.sh | Port 1 error clearing and SIST port status. |
| router_defs.sh | Register map shared by the scripts. |
| grmon_script.sh | Port control writes as GRMON wmem commands. |
Documentation/ keeps the reference router configuration and constants used in the ground support equipment for the MEU router, and notes on decoding RMAP read replies.
First test: 64-byte packets at 100 Mbit/s from Brick link 1 to link 2 through the router. The next day the project moved from a Makefile to Autotools.
First RMAP write packet to router register 0x808, then the read command.
Routing configuration examples and continuous packet reception.
Out-of-tree build, rmap and rd_rmap with options, reset command, and the first script to configure Router A of MEU 1. Broadcast test.
Tools to find connected Bricks, send single packets and inject disconnect errors, with two test descriptions of the verification procedure.
Script to check the SIST port status, and the reference router constants from the ground equipment.
| configure.ac | Autoconf input: compiler and STAR-API checks. |
| src/Makefile.am | Automake input: the nine programs and their libraries. |
| src/ | Tool sources, utility.c and system_config.h (MEU logical and physical addresses). |
| scripts/ | Build script and router configuration sequences. |
| Documentation/ | Router constants and RMAP reply notes. |
star-api.h, the configuration libraries and the RMAP packet library. The SDK is proprietary and is not included.