Installation instructions

This file describes how to run the Python scripts which are used in the book "Programming a toy computer from scratch". These scripts require Python3 and the pyserial package, which must be installed first. The serial port used to communicate with the Arduino must also be configured.

Ubuntu

pyserial

Python3 should be installed by default on your computer. To install the pyserial package, first install pip if it is not already installed. For this, type

sudo apt install python3-pip

in a terminal. Then install the pyserial package with

pip install pyserial

serial port

Connect the Arduino's USB native port (see Figure 6.1 in the book) to your computer, and type

ls /dev/ttyACM*

in a terminal. You should get a result such as /dev/ttyACM0. The number at the end might differ. If this is the case, edit boot_helper.py with a text editor and replace /dev/ttyACM0 (on line 18) with the result you got. Finally, type

python3 boot_helper.py

to test the connection to the Arduino. If you get a "could not open serial port" error, this is probably a permission issue to acces the dialout group. Follow the instructions on the Arduino's website to fix them. Once this is done, the above command should work. Then type V# followed by Enter. You should get a version number, such as "v1.1 Dec 15 2010 19:25:04". Finally, type exit# to quit the boot helper program.

Windows

Python3

Type python3 in the Windows PowerShell. If Python3 is not installed, this should open the Microsoft Store. Then follow the instructions to install this software. Back in the PowerShell, typing python3 again should work. Finally, type quit() followed by enter to exit.

pyserial

Install the pyserial package by typing the following command in the PowerShell:
pip install pyserial

serial port

Connect the Arduino's USB native port (see Figure 6.1 in the book) to your computer, and open the device manager. Note the port number of the Arduino in the COM ports section (here COM5):

Then edit boot_helper.py with a text editor and replace /dev/ttyACM0 (on line 18) with COMi, where i is the number you found with the device manager. Finally, type

python3 boot_helper.py

in the PowerShell to test the connection to the Arduino. Type V# followed by Enter. You should get a version number, such as "v1.1 Dec 15 2010 19:25:04". Finally, type exit# to quit the boot helper program.