Make With Ada repository for a model railway signalling system
Competition now called Ada/SPARK Crate Of The Year
The project includes a runner.py
python script which runs docker commands.
There are various options that are explained if you run python3 runner.py --help
.
python3 runner.py -b
will build a firmware.uf2 file ready to be flashed to the pico, and place it at the top of the project directory structure.
You can then drag and drop the firmware onto the pi pico
python3 runner.py -p <filename>
will run gnatprove on the given file. If no filename is stated, this defaults to main.adb
.
Outputs from building and proving the project with the python runner tool are stored in the logs
directory.
These logs are overwritten each time the appropriate command is run.
You can show the contents of the log in your terminal using the -l
option
python3 runner.py -l
To create tests, write test code in the Harness/tests/
directory
This project can call functions, packages and procedures from the Trains_With_Ada
project.
To build the test harness Pico Firmware run
python3 runner.py -t
This wil create a test_firmware.uf2
file that can be loaded onto the Pico.
The output of the tests are sent as strings using the Send_String
and Echo
procedures using the UART interface on GPIO pins 16 (TX) and 17 (RX).
You can read these output strings using a second Raspberry Pi Pico that has the Pico UART-USB bridge Firmware firmware installed.
This "Bridge Pico" must be connected to a Computer via USB that has a Serial console installed, such as Minicom or PuTTY
The "Test Pico" must be connected to the "Bridge Pico" as follows:
Test Pico | Bridge Pico |
---|---|
GPIO 16 (TX) | GPIO 1 (RX) |
GPIO 17 (RX) | GPIO 0 (TX) |
Install your favourite text editor/IDE. If you wish to use GNATStudio, see the GNATCommunity and Alire section
You will need docker installed on your machine to build the Raspberry Pi Pico firmware from the Ada project.
For full instructions regarding the installation of docker, see the Docker Getting Started Guide
You will also need at least 15GB of space for the completed docker image/containers
If you wish to use the python runner.py
tool, you will need python3 installed locally.
If you are using linux, you can install python3 using your package manager
apt install python3
Alternatively, you can download and install it from the python website
You can install GNATStudio on your local machine if you wish to use it as an IDE for writing your SPARK/Ada code. To use GNATStudio with the project, you will also need to install Alire.
Alire is a package manager for Ada/SPARK, and we need it installed to include the Pico_BSP libraries we use.
Note that if you are using another IDE/Text editor, like VSCode or Vim, you do not need to install GNAT Community or Alire; all the runner.py
commands use docker containers.
For Mac and Linux there are install scripts for setting up GNAT Community and Alire (in addition to the rest of the toolchain) in the setup
directory.
bash /setup/setup_permissions.sh
./setup/setup.sh
Alternatively, you can download GNAT Community and Alire from the AdaCore Website and the Alire Website.
Both of these include comprehensive installation instructions.
docker images // list images either built locally or pulled from docker hub
docker container ls // list running containers
docker container ls -a // list all containers
docker container start <container name> // start a stopped container
docker container stop <container name> // stop a running container
docker inspect <container name> // view configuration information about a container
docker conatiner prune // remove unused containers