|
GR712RC unit tests 1.0
Bare-metal C++ hardware tests for the PLATO DPU (IAA-CSIC, 2019)
|
Bare-metal C++ test programs that bring up and check the hardware of a GR712RC board: the SDRAM behind the fault-tolerant memory controller, GPIO, UART and SpaceWire. They were written in 2019 at IAA-CSIC for the PLATO mission, to validate the GR712RC commercial board from Frontgrade Gaisler and the IAA ed31 board before running flight software on them.
Each test is a small stand-alone program. It is built with the Gaisler BCC 2 toolchain, loaded into the processor's on-chip RAM with GRMON2 (so the SDRAM under test is not used by the program itself) and reports its result through its exit code, words written at the start of the SDRAM, GPIO pins that can be watched with an oscilloscope or logic analyser, or the serial port.
Project page with diagrams: https://jmgomez-iaa.github.io/sw-gr712-unit-test-web/
The code follows the layered design of Christopher Kormanyos' Real-Time C++ (Springer), the same one used in Embedded_Software_Collection (branch gr712rc), of which this is the continuation.
| Layer | Folder | What it does |
|---|---|---|
| Test programs | src/app/unit_test/ | One main() per test |
| MCAL | src/mcal/ | mcal::init() plus one driver per peripheral: cpu, mem, port, uart, spw (and gpt, irq, wdt for ed31) |
| Board selection | src/mcal/gr712rc_comercial/, src/mcal/gr712rc_ed31/ | Memory map (mcal_reg.h) and drivers for each board; only one folder is on the include path |
| Register access | src/mcal/mcal_reg_access_template.h | mcal::reg::access<addr_type, reg_type, address, value> templates: register reads and writes resolved at compile time |
| Utilities | src/util/ | Kormanyos' bare-metal subset of the C++ standard library |
| Start-up | BCC 2 BSP | Start-up code and the linkcmds-ahbram linker script come from the toolchain |
mcal::init() initialises the CPU and programs the memory controller (FTMCTRL): it disables the SRAM bank, enables the SDRAM and switches off EDAC, so the tests see the raw memory.
| Item | Address |
|---|---|
| SDRAM (under test) | 0x40000000 (64 MB on the commercial board, 256 MiB on ed31) |
| Memory controller registers MCFG1–3 | 0x80000000, 0x80000004, 0x80000008 |
| GRGPIO port 1 / port 2 | 0x80000900 / 0x80000A00 |
| APBUART 0 (1–5) | 0x80000100 (0x80100100–0x80100500) |
| GRSPW 0–5 | 0x80100800–0x80100D00 |
| Test | What it checks | How the result is seen |
|---|---|---|
| memory_config | The memory controller accepts the configuration | MCFG1–3 are read back and copied to 0x40000000–0x40000008 |
| memory_single_access | One SDRAM word keeps a value after a cache flush | Writes and reads 0xA5A5A5A5 at 0x40000000 forever; exits with 1 on a mismatch |
| memory_run | Every SDRAM word can be written and read | Fills the SDRAM with 0xABABABAB, then checks it; exit code 0 or 1 |
| memory_run_bucle | The same, repeated without end | Loop of fill and check with 0xA5A5A5A5 |
| memory_persistence | The SDRAM keeps its contents over time (refresh) | Fills once, then checks forever; the number of full passes is kept at 0x40000000 (0x12000000 \| n on error) |
| memory_run_gpio | Speed of the write and read passes | Same as memory_run, toggling GPIO26 at each phase and at every read |
| memory_count_gpio | Address lines (each word holds its own address) | Every address is also shifted out on GPIO26 (data) with GPIO25 as clock, for a logic analyser |
| gpio_config | A GPIO can be driven | GPIO26 toggles as fast as possible: square wave of about 1.6 µs period on J23 pin 13 |
| gpio_inout | A GPIO can be read | GPIO26 oscillates only while GPIO25 (J23 pin 11) is low |
| uart_periph | APBUART 0 at 9600 baud | Prints a banner, sends T continuously and echoes each byte received |
| spw_periph | GRSPW 0 link and transmission | Reports the link state over the UART and, once the link is Run, sends a counter word and a 20-word packet |
The memory tests also have PlantUML sequence diagrams in Documentation/ (memory_*.uml), and Documentation/readme.txt has the original notes.
There is no project Makefile in this repository: each test was compiled on its own with BCC 2 (Makefile_GR712RC_Template only holds Gaisler's example commands). The flags below are the ones of the gr712rc branch of Embedded_Software_Collection; it is a reconstruction, not a tested script:
Every test notes that it must be linked to run from the GR712RC on-chip RAM (linkcmds-ahbram), so that the SDRAM is free for the test.
Then load and run it from GRMON2 (load memory_run.elf, run) and inspect the results, for example with mem 0x40000000 16.
On the commercial board the GPIO tests need the JP29 switch matrix in position A.
Documentation/html holds the Doxygen output from 2019 (doxygen doxygen_plato_dpu_unit_test.cfg). The workflow in .github/workflows/docs.yml regenerates it from the current sources and publishes it as an artifact.
There is no licence file. The test programs and the MCAL were written for the PLATO project at IAA-CSIC. The files in src/util and the register access templates come from real-time-cpp and keep Christopher Kormanyos' copyright and the Boost Software License 1.0.