Running an Application
To run an application on the PYNQ robot you need to get source code, or program it, then compile the program and run it. The starting image has a few example applications pre-installed in the folder
/home/student/pynq-io-library/applications/
For example, an application called buttons-ledbar.
Start a terminal within Visual Studio Code, MobaXTerm, or using SSH and login.
Change to the application folder with:
List the directory contents:
This reveals the source source file main.c and the file Makefile that (somewhat cryptically) tells the C compiler how to build the application.
Note that this application also uses source code from the folder /home/student/pynq-io-library/applications/lib/ledbar/.
Compile the source code and build an executable as follows:
If successful, it will show the following:
student@pynq:~/pynq-io-library/applications/buttons-ledbar$ make
(DEP) ../lib/ledbar/ledbar.d
(DEP) main.d
(OBJ) main.o
(OBJ) ../lib/ledbar/ledbar.o
(EXE) main
(It will show much more if you had not yet compiled the libpyq library.)
If the compilation successfully completes, it has compiled all source files and built an executable file called main in the same directory, which can be run with:
Don't forget the ./ at the beginning, otherwise it won't work.
Alternatively, it can be run by invoking make as follows.
It it works (try pressing the buttons on the lower left side of the robot), congratulations! Otherwise, check all the steps carefully, check the troubleshooting section below, and if it still doesn't work, get help!
Now proceed by checking the source code file, main.c and see how the behavior is coded.
You can open it in Visual Studio Code, or MobaXTerm, or if you are using SSH, you can use the simple editor nano:
Troubleshooting
You may observe warnings like: Warning: File '...' has modification time 96052932 s in the future
The pynq robot is not connected to the internet and most of the time off, so it cannot keep its internal clock up to date.
Imported files may therefore have timestamps that are ahead of the internal clock.
The build tools may observe this and give warnings. Sometimes the build still completes. Sometimes it ends up trying to build the same files over and over in an infinite loop.
In that case you can set the internal clock to the current date and time with the following command:
For example, for November 7, 8:45, 2026 it would be:
sudo date 110708452026
After that the warnings should disappear.
Note that sudo means that you want to run the following command with elevated (super) user privileges, needed to change system time and date.
Running a Program while Disconnecting
Editing and compiling a program for the robot happens with a terminal connection to the robot, while the robot is connected with an ethernet cable to the laptop. Often, we want to run a program on the robot without it being constrained by a cable to the laptop. Just unplugging the cable would disrupt the connection and consequently (possibly after some time) stop the application, because the terminal connection from which it was started has been lost.
The following can be used to run a program without a cable connection and without an active terminal.
The disown command severs the link between the running program and the terminal connection so that it keeps running when the connection is terminated.
Since it takes time to disconnect the cable after starting the program, some method to synchronize the actual start of the program can be used. For example,
- waiting for a button to be pressed at the start of the program
- starting with a timer delay
- synchronizing the start by an MQTT message, which would also allow multiple robots to start synchronously.
Shutting Down the Robot
If you want to shut down the robot and ensure it is in a safe state to turn it off, issue the following command.
Then wait for about ten seconds before unplugging the battery to turn everything off.