https://spivey.oriel.ox.ac.uk/bmwiki/index.php?title=Appendix_B:_Software_setup&feed=atom&action=historyAppendix B: Software setup - Revision history2024-03-29T06:38:19ZRevision history for this page on the wikiMediaWiki 1.39.6https://spivey.oriel.ox.ac.uk/bmwiki/index.php?title=Appendix_B:_Software_setup&diff=243&oldid=prevMike at 18:58, 14 August 20222022-08-14T18:58:41Z<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 18:58, 14 August 2022</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><!--Uploaded-->The experiments in this book assume that you are preparing programs for the {{microbit}} using a Raspberry Pi (version <del style="font-weight: bold; text-decoration: none;">2 </del>or later), and the instructions given here are aimed at setting up the Pi with the software needed for that. The steps involve installing various software packages needed for <del style="font-weight: bold; text-decoration: none;">ptogramming </del>the {{microbit}}, such as versions of the GNU C compiler and attendant programs that are capable of generating code for the ARM Cortex-M0 processor on the board. They also install a modified version of the Geany programming environment that is able to make sense of the syntax of ARM assembly language.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><!--Uploaded-->The experiments in this book assume that you are preparing programs for the {{microbit}} using a Raspberry Pi (version <ins style="font-weight: bold; text-decoration: none;">3 </ins>or later), and the instructions given here are aimed at setting up the Pi with the software needed for that. The steps involve installing various software packages needed for <ins style="font-weight: bold; text-decoration: none;">programming </ins>the {{microbit}}, such as versions of the GNU C compiler and attendant programs that are capable of generating code for the ARM Cortex-M0 processor on the board. They also install a modified version of the Geany programming environment that is able to make sense of the syntax of ARM assembly language.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Using a Raspberry Pi is convenient as a way of getting a standardised Linux-based setup with minimal fuss. However, it is almost as easy to set up any other Linux machine in a similar way, and I did much of the development work for the book on an ordinary Intel-based laptop. For machines running Debian or a derivative, the same setup script described below will work just as well as on a Raspberry Pi. For other Linux distributions, similar steps will work if performed manually. It doesn't matter if the host machine is based on an Intel processor rather than an ARM processor, because it's not necessary for the host processor actually to run any of the code that is being compiled; even on the Raspberry Pi, the compiler we use is a cross-compiler, running on one machine and generating code for another. <del style="font-weight: bold; text-decoration: none;">Althogh </del>in that case, both machines are designed by ARM, the host runs native ARM code while the target machine runs Thumb code.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Using a Raspberry Pi is convenient as a way of getting a standardised Linux-based setup with minimal fuss. However, it is almost as easy to set up any other Linux machine in a similar way, and I did much of the development work for the book on an ordinary Intel-based laptop. For machines running Debian or a derivative, the same setup script described below will work just as well as on a Raspberry Pi. For other Linux distributions, similar steps will work if performed manually. It doesn't matter if the host machine is based on an Intel processor rather than an ARM processor, because it's not necessary for the host processor actually to run any of the code that is being compiled; even on the Raspberry Pi, the compiler we use is a cross-compiler, running on one machine and generating code for another. <ins style="font-weight: bold; text-decoration: none;">Although </ins>in that case, both machines are designed by ARM, the host runs native ARM code while the target machine runs Thumb code.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Similarly, the instructions in this book are written on the assumption that you will be using Geany as a programming environment for editing and compiling the programs, but it is quite easy to use a different <del style="font-weight: bold; text-decoration: none;">enviornment </del>instead. The procedure for compiling and linking each program is described by a Makefile, so any programming environment that can invoke @make@ to build a program can easily be used in place of Geany. If you prefer, you can use an ordinary text editor for programming and invoke @make@ from the command line.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Similarly, the instructions in this book are written on the assumption that you will be using Geany as a programming environment for editing and compiling the programs, but it is quite easy to use a different <ins style="font-weight: bold; text-decoration: none;">environment </ins>instead. The procedure for compiling and linking each program is described by a Makefile, so any programming environment that can invoke @make@ to build a program can easily be used in place of Geany. If you prefer, you can use an ordinary text editor for programming and invoke @make@ from the command line.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Some experiments rely on connecting the serial port on the {{microbit}} directly to the serial port on the {{RPi}}, and for these to work, it's necessary to enable the serial port on the Pi. Instructions for doing this appear below.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Some experiments rely on connecting the serial port on the {{microbit}} directly to the serial port on the {{RPi}}, and for these to work, it's necessary to enable the serial port on the Pi. Instructions for doing this appear below.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Instructions==</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Instructions==</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* '''1: Begin with latest version of <del style="font-weight: bold; text-decoration: none;">Raspbian</del>,''' which you can get from the Raspberry Pi [https://www.raspberrypi.org/downloads downloads page].</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* '''1: Begin with latest version of <ins style="font-weight: bold; text-decoration: none;">Raspberry Pi OS</ins>,''' which you can get from the Raspberry Pi [https://www.raspberrypi.org/downloads downloads page]. <ins style="font-weight: bold; text-decoration: none;"> Follow the instructions on that page </ins>to <ins style="font-weight: bold; text-decoration: none;">write </ins>the <ins style="font-weight: bold; text-decoration: none;">operating system image </ins>to an <ins style="font-weight: bold; text-decoration: none;">SD card and boot it in </ins>your <ins style="font-weight: bold; text-decoration: none;">Raspberry Pi</ins>.</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">:It works well if we continue </del>to <del style="font-weight: bold; text-decoration: none;">use </del>the <del style="font-weight: bold; text-decoration: none;">automatically generated 'pi' account: if you prefer </del>to <del style="font-weight: bold; text-decoration: none;">create </del>an <del style="font-weight: bold; text-decoration: none;">account with </del>your <del style="font-weight: bold; text-decoration: none;">own name, be sure to add yourself to all the same groups as user 'pi'</del>.</div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Perform the following steps in a Terminal window (which you can open by clicking on the [[Image:Terminal.png]] icon near the top left corner of the screen. In what follows, @$@ represents the shell prompt, and the rest of the line (shown in italics) is what you must type.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Perform the following steps in a Terminal window (which you can open by clicking on the [[Image:Terminal.png]] icon near the top left corner of the screen. In what follows, @$@ represents the shell prompt, and the rest of the line (shown in italics) is what you must type.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''2: Update the system''' with the latest versions of all installed packages:</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''2: Update the system''' with the latest versions of all installed packages:</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l23">Line 23:</td>
<td colspan="2" class="diff-lineno">Line 22:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''sh setup/install''</code></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''sh setup/install''</code></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:This will automatically carry out the steps listed later in this appendix, and takes about 10 minutes at most.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:This will automatically carry out the steps listed later in this appendix, and takes about 10 minutes at most.</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* '''5: Finally, reboot the machine''' by choosing {{Menu|Shutdown>Reboot}} in the main system menu. Afterwards, you should see that Geany project files (such as the file @x01.geany@ in <del style="font-weight: bold; text-decoration: none;">subdirectory </del>@x01-echo@ of the software kit) have the Geany icon, and double-clicking them opens the project in Geany. That is our preferred method of starting Geany with the correct options for building the project.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* '''5: Finally, reboot the machine''' by choosing {{Menu|Shutdown>Reboot}} in the main system menu. Afterwards, you should see that Geany project files (such as the file @x01.geany@ in <ins style="font-weight: bold; text-decoration: none;">sub-directory </ins>@x01-echo@ of the software kit) have the Geany icon, and double-clicking them opens the project in Geany. That is our preferred method of starting Geany with the correct options for building the project.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Updating==</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Updating==</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l34">Line 34:</td>
<td colspan="2" class="diff-lineno">Line 33:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Setup actions==</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Setup actions==</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>These are the actions performed by the setup script.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>These are the actions performed by the setup script.</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>*Add a new software repository and signing key: the repository contains an enhanced build of the latest version of Geany, able to handle syntax <del style="font-weight: bold; text-decoration: none;">hightlighting </del>for ARM assembly language, and with space for more entries in the {{Menu|Build}} menu.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>*Add a new software repository and signing key: the repository contains an enhanced build of the latest version of Geany, able to handle syntax <ins style="font-weight: bold; text-decoration: none;">highlighting </ins>for ARM assembly language, and with space for more entries in the {{Menu|Build}} menu.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>*Install the following Raspbian packages, together with the other packages on which they depend. Some may already be installed, but installing them again does no harm.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>*Install the following Raspbian packages, together with the other packages on which they depend. Some may already be installed, but installing them again does no harm.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l52">Line 52:</td>
<td colspan="2" class="diff-lineno">Line 51:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Enabling the serial port==</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Enabling the serial port==</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>For some <del style="font-weight: bold; text-decoration: none;">experiements</del>, we will want to use the serial port on the {{RPi}} to connect to the {{microbit}}. Luckily, the 3.3V signals on both boards are compatible. For these experiments, the serial port on the Pi should be enabled, but should not show a login prompt. To set this up, from the main menu choose {{Menu|Preferences>Raspberry Pi Configuration}}; in the dialog that appears, click on the {{Menu|Interfaces}} tab, choose {{Menu|Serial Port}} = enable and {{Menu|Serial Console}} = disable and click on {{Menu|OK}}. A pop-up will appear asking if you would you like to reboot: click {{Menu|Yes}}.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>For some <ins style="font-weight: bold; text-decoration: none;">experiments</ins>, we will want to use the serial port on the {{RPi}} to connect to the {{microbit}}. Luckily, the 3.3V signals on both boards are compatible. For these experiments, the serial port on the Pi should be enabled, but should not show a login prompt. To set this up, from the main menu choose {{Menu|Preferences>Raspberry Pi Configuration}}; in the dialog that appears, click on the {{Menu|Interfaces}} tab, choose {{Menu|Serial Port}} = enable and {{Menu|Serial Console}} = disable and click on {{Menu|OK}}. A pop-up will appear asking if you would you like to reboot: click {{Menu|Yes}}.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Image:RPi-config.png|center|frame|Raspberry Pi configuration]]</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Image:RPi-config.png|center|frame|Raspberry Pi configuration]]</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l59">Line 59:</td>
<td colspan="2" class="diff-lineno">Line 58:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>All the experiments in this book will work with either Version 1 of the {{microbit}} board (released in 2016), based on the Nordic nRF51822 chip, or Version 2 (released in 2020), based on the nRF52833 chip. There are separate software kits for each of them, installed by fetching the GitHub repositories @baremetal-v1@ or @baremetal-v2@ respectively. Some difference between the two versions is inevitable because the board designs differ, and while the peripherals integrated into the two microcontrollers are similar, the memory layout, the clock setup and other details differ. The software follows a number of principles to keep the differences between versions manageable.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>All the experiments in this book will work with either Version 1 of the {{microbit}} board (released in 2016), based on the Nordic nRF51822 chip, or Version 2 (released in 2020), based on the nRF52833 chip. There are separate software kits for each of them, installed by fetching the GitHub repositories @baremetal-v1@ or @baremetal-v2@ respectively. Some difference between the two versions is inevitable because the board designs differ, and while the peripherals integrated into the two microcontrollers are similar, the memory layout, the clock setup and other details differ. The software follows a number of principles to keep the differences between versions manageable.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* The layout of device registers in each chip is defined in a header file @hardware.h@ that, as far as possible, provides the same interface for both chips, but with definitions adjusted for each of them. The header file exists in two versions, each adjusted to the hardware of one of the chips. One version additionally defines the macro @UBIT_V1@ and the other defines @UBIT_V2@, and these macros are used to enable variants of the code in other source files that are adapted to the different boards.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* The layout of device registers in each chip is defined in a header file @hardware.h@ that, as far as possible, provides the same interface for both chips, but with definitions adjusted for each of them. The header file exists in two versions, each adjusted to the hardware of one of the chips. One version additionally defines the macro @UBIT_V1@ and the other defines @UBIT_V2@, and these macros are used to enable variants of the code in other source files that are adapted to the different boards.</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* Any files that participants are expected to edit are free of @ifdefs@, to avoid the familiar problem of editing the wrong piece of conditionally-compiled code and then puzzling over why the changes have no effect. Wherever possible, these participant-modified files are the same in both versions, but occasionally they exist in two <del style="font-weight: bold; text-decoration: none;">vesions</del>, with the differences between them noted in the text, often in callout boxes labelled "{{microbit}} version 2".</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* Any files that participants are expected to edit are free of @ifdefs@, to avoid the familiar problem of editing the wrong piece of conditionally-compiled code and then puzzling over why the changes have no effect. Wherever possible, these participant-modified files are the same in both versions, but occasionally they exist in two <ins style="font-weight: bold; text-decoration: none;">versions</ins>, with the differences between them noted in the text, often in callout boxes labelled "{{microbit}} version 2".</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* Other files, when the content is vastly different for the two boards, also exist in two versions that are identically named and provide the same interface, but contain different implementations for the two versions. When the differences are more circumscribed (and especially in the source code of the {{microbian}} operating system in the third part of the book), there are sometimes parallel pieces of code that are activated by @ifdef@s based on the @UBIT_V1@ and @UBIT_V2@ macros.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* Other files, when the content is vastly different for the two boards, also exist in two versions that are identically named and provide the same interface, but contain different implementations for the two versions. When the differences are more circumscribed (and especially in the source code of the {{microbian}} operating system in the third part of the book), there are sometimes parallel pieces of code that are activated by @ifdef@s based on the @UBIT_V1@ and @UBIT_V2@ macros.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l65">Line 65:</td>
<td colspan="2" class="diff-lineno">Line 64:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>The simplicity of the setup does mean that it's hard to support both boards at the same time: but doing that more or less demands a setup with separate source directories for the common parts of the code and for the files specific to each board, separate build directories for the boards, and Makefiles that include search paths to find the relevant source -- all many times more complicated than the one-program-one-directory approach that is provided for this book.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>The simplicity of the setup does mean that it's hard to support both boards at the same time: but doing that more or less demands a setup with separate source directories for the common parts of the code and for the files specific to each board, separate build directories for the boards, and Makefiles that include search paths to find the relevant source -- all many times more complicated than the one-program-one-directory approach that is provided for this book.</div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">==Alternatives==</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">The instructions in this book assume you are using a Raspberry Pi to prepare programs for the {{microbit}}, but they can also be followed with little change on other platforms.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* You could use a PC running Linux. If you are running Debian, then the @install@ script from the software kit can likely be used without change to install the tools you need. It doesn't matter at all that the host processor in the PC is an Intel chip and the binary code for our programs will be for the Cortex-M variant of the ARM: the translation will explicitly be done by a ''cross-compiler'' that runs on one kind of machine but generates binary code for another kind.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* You could use a PC running Windows or a Macintosh, and set up a virtual Linux environment within VirtualBox. For this, I recommend as the 'guest' operating system a version of Debian with the Raspberry Pi desktop, because it look identical to the screenshots in the book and is lightweight enough to make good use of the limited amounts of RAM and machine time that are available in a virtual machine. You can download it from the same Raspberry Pi [https://www.raspberrypi.org/downloads downloads page].</ins></div></td></tr>
</table>Mikehttps://spivey.oriel.ox.ac.uk/bmwiki/index.php?title=Appendix_B:_Software_setup&diff=236&oldid=prevMike at 09:18, 13 August 20222022-08-13T09:18:41Z<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 09:18, 13 August 2022</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>The experiments in this book assume that you are preparing programs for the {{microbit}} using a Raspberry Pi (version 2 or later), and the instructions given here are aimed at setting up the Pi with the software needed for that. The steps involve installing various software packages needed for ptogramming the {{microbit}}, such as versions of the GNU C compiler and attendant programs that are capable of generating code for the ARM Cortex-M0 processor on the board. They also install a modified version of the Geany programming environment that is able to make sense of the syntax of ARM assembly language.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"><!--Uploaded--></ins>The experiments in this book assume that you are preparing programs for the {{microbit}} using a Raspberry Pi (version 2 or later), and the instructions given here are aimed at setting up the Pi with the software needed for that. The steps involve installing various software packages needed for ptogramming the {{microbit}}, such as versions of the GNU C compiler and attendant programs that are capable of generating code for the ARM Cortex-M0 processor on the board. They also install a modified version of the Geany programming environment that is able to make sense of the syntax of ARM assembly language.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Using a Raspberry Pi is convenient as a way of getting a standardised Linux-based setup with minimal fuss. However, it is almost as easy to set up any other Linux machine in a similar way, and I did much of the development work for the book on an ordinary Intel-based laptop. For machines running Debian or a derivative, the same setup script described below will work just as well as on a Raspberry Pi. For other Linux distributions, similar steps will work if performed manually. It doesn't matter if the host machine is based on an Intel processor rather than an ARM processor, because it's not necessary for the host processor actually to run any of the code that is being compiled; even on the Raspberry Pi, the compiler we use is a cross-compiler, running on one machine and generating code for another. Althogh in that case, both machines are designed by ARM, the host runs native ARM code while the target machine runs Thumb code.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Using a Raspberry Pi is convenient as a way of getting a standardised Linux-based setup with minimal fuss. However, it is almost as easy to set up any other Linux machine in a similar way, and I did much of the development work for the book on an ordinary Intel-based laptop. For machines running Debian or a derivative, the same setup script described below will work just as well as on a Raspberry Pi. For other Linux distributions, similar steps will work if performed manually. It doesn't matter if the host machine is based on an Intel processor rather than an ARM processor, because it's not necessary for the host processor actually to run any of the code that is being compiled; even on the Raspberry Pi, the compiler we use is a cross-compiler, running on one machine and generating code for another. Althogh in that case, both machines are designed by ARM, the host runs native ARM code while the target machine runs Thumb code.</div></td></tr>
</table>Mikehttps://spivey.oriel.ox.ac.uk/bmwiki/index.php?title=Appendix_B:_Software_setup&diff=219&oldid=prevMike at 15:19, 2 July 20212021-07-02T15:19:11Z<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 15:19, 2 July 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l55">Line 55:</td>
<td colspan="2" class="diff-lineno">Line 55:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Image:RPi-config.png|center|frame|Raspberry Pi configuration]]</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Image:RPi-config.png|center|frame|Raspberry Pi configuration]]</div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">==V1 and V2 boards==</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">All the experiments in this book will work with either Version 1 of the {{microbit}} board (released in 2016), based on the Nordic nRF51822 chip, or Version 2 (released in 2020), based on the nRF52833 chip. There are separate software kits for each of them, installed by fetching the GitHub repositories @baremetal-v1@ or @baremetal-v2@ respectively. Some difference between the two versions is inevitable because the board designs differ, and while the peripherals integrated into the two microcontrollers are similar, the memory layout, the clock setup and other details differ. The software follows a number of principles to keep the differences between versions manageable.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* The layout of device registers in each chip is defined in a header file @hardware.h@ that, as far as possible, provides the same interface for both chips, but with definitions adjusted for each of them. The header file exists in two versions, each adjusted to the hardware of one of the chips. One version additionally defines the macro @UBIT_V1@ and the other defines @UBIT_V2@, and these macros are used to enable variants of the code in other source files that are adapted to the different boards.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* Any files that participants are expected to edit are free of @ifdefs@, to avoid the familiar problem of editing the wrong piece of conditionally-compiled code and then puzzling over why the changes have no effect. Wherever possible, these participant-modified files are the same in both versions, but occasionally they exist in two vesions, with the differences between them noted in the text, often in callout boxes labelled "{{microbit}} version 2".</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* Other files, when the content is vastly different for the two boards, also exist in two versions that are identically named and provide the same interface, but contain different implementations for the two versions. When the differences are more circumscribed (and especially in the source code of the {{microbian}} operating system in the third part of the book), there are sometimes parallel pieces of code that are activated by @ifdef@s based on the @UBIT_V1@ and @UBIT_V2@ macros.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">Programs in the early part of the book are entirely independent of each other, and each contains in a single directory all the source code that is needed, with each program having its own copy of shared files like @hardware.h@ and the library @lib.c@ that provides @printf@ and other things. For the third part of the book, there is a shared directory containing the source code for the {{microbian}} scheduler and various device drivers.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">The simplicity of the setup does mean that it's hard to support both boards at the same time: but doing that more or less demands a setup with separate source directories for the common parts of the code and for the files specific to each board, separate build directories for the boards, and Makefiles that include search paths to find the relevant source -- all many times more complicated than the one-program-one-directory approach that is provided for this book.</ins></div></td></tr>
</table>Mikehttps://spivey.oriel.ox.ac.uk/bmwiki/index.php?title=Appendix_B:_Software_setup&diff=216&oldid=prevMike at 08:46, 2 July 20212021-07-02T08:46:22Z<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 08:46, 2 July 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l27">Line 27:</td>
<td colspan="2" class="diff-lineno">Line 27:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Updating==</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Updating==</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>As more experiments are released, you will want to add the code to your copy of the software kit. You can do this using the @git pull@ command, then running a script to create new Geany project files.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>As more experiments are released, you will want to add the code to your copy of the software kit. You can do this using the @git pull@ command, then running a script to create new Geany project files.</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''cd baremetal''</code></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''cd baremetal<ins style="font-weight: bold; text-decoration: none;">-v1</ins>''</code><ins style="font-weight: bold; text-decoration: none;">&emsp;(or <code>''cd baremetal-v2''</code>) </ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''git pull''</code></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''git pull''</code></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''bash setup/genproj''</code></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''bash setup/genproj''</code></div></td></tr>
</table>Mikehttps://spivey.oriel.ox.ac.uk/bmwiki/index.php?title=Appendix_B:_Software_setup&diff=213&oldid=prevMike at 10:51, 1 July 20212021-07-01T10:51:37Z<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 10:51, 1 July 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l20">Line 20:</td>
<td colspan="2" class="diff-lineno">Line 20:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:If you have the V2 {{microbit}}, replace @baremetal-v1.git@ with @baremetal-v2.git@; for simplicity, the software kit supports one version or the other, but not both at once.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:If you have the V2 {{microbit}}, replace @baremetal-v1.git@ with @baremetal-v2.git@; for simplicity, the software kit supports one version or the other, but not both at once.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''4: Run the setup script:'''</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''4: Run the setup script:'''</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''cd baremetal-v1''</code> (or <code>''cd baremetal-v2''</code>)</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''cd baremetal-v1''</code><ins style="font-weight: bold; text-decoration: none;">&emsp;</ins>(or <code>''cd baremetal-v2''</code>)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''sh setup/install''</code></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''sh setup/install''</code></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:This will automatically carry out the steps listed later in this appendix, and takes about 10 minutes at most.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:This will automatically carry out the steps listed later in this appendix, and takes about 10 minutes at most.</div></td></tr>
</table>Mikehttps://spivey.oriel.ox.ac.uk/bmwiki/index.php?title=Appendix_B:_Software_setup&diff=212&oldid=prevMike at 10:47, 1 July 20212021-07-01T10:47:51Z<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 10:47, 1 July 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l20">Line 20:</td>
<td colspan="2" class="diff-lineno">Line 20:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:If you have the V2 {{microbit}}, replace @baremetal-v1.git@ with @baremetal-v2.git@; for simplicity, the software kit supports one version or the other, but not both at once.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:If you have the V2 {{microbit}}, replace @baremetal-v1.git@ with @baremetal-v2.git@; for simplicity, the software kit supports one version or the other, but not both at once.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''4: Run the setup script:'''</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''4: Run the setup script:'''</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''cd baremetal''</code></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''cd baremetal<ins style="font-weight: bold; text-decoration: none;">-v1</ins>''</code> <ins style="font-weight: bold; text-decoration: none;">(or <code>''cd baremetal-v2''</code>)</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''sh setup/install''</code></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>::<code>$ ''sh setup/install''</code></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:This will automatically carry out the steps listed later in this appendix, and takes about 10 minutes at most.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>:This will automatically carry out the steps listed later in this appendix, and takes about 10 minutes at most.</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* '''5: Finally, reboot the machine''' by choosing {{Menu|Shutdown>Reboot}} in the main system menu. Afterwards, you should see that Geany project files (such as the file @<del style="font-weight: bold; text-decoration: none;">x1000</del>.geany@ in subdirectory @<del style="font-weight: bold; text-decoration: none;">x1000</del>-echo@ of the software kit) have the Geany icon, and double-clicking them opens the project in Geany. That is our preferred method of starting Geany with the correct options for building the project.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* '''5: Finally, reboot the machine''' by choosing {{Menu|Shutdown>Reboot}} in the main system menu. Afterwards, you should see that Geany project files (such as the file @<ins style="font-weight: bold; text-decoration: none;">x01</ins>.geany@ in subdirectory @<ins style="font-weight: bold; text-decoration: none;">x01</ins>-echo@ of the software kit) have the Geany icon, and double-clicking them opens the project in Geany. That is our preferred method of starting Geany with the correct options for building the project.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Updating==</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==Updating==</div></td></tr>
</table>Mikehttps://spivey.oriel.ox.ac.uk/bmwiki/index.php?title=Appendix_B:_Software_setup&diff=190&oldid=prevMike: Created page with "The experiments in this book assume that you are preparing programs for the {{microbit}} using a Raspberry Pi (version 2 or later), and the instructions given here are aimed a..."2021-06-28T12:22:39Z<p>Created page with "The experiments in this book assume that you are preparing programs for the {{microbit}} using a Raspberry Pi (version 2 or later), and the instructions given here are aimed a..."</p>
<p><b>New page</b></p><div>The experiments in this book assume that you are preparing programs for the {{microbit}} using a Raspberry Pi (version 2 or later), and the instructions given here are aimed at setting up the Pi with the software needed for that. The steps involve installing various software packages needed for ptogramming the {{microbit}}, such as versions of the GNU C compiler and attendant programs that are capable of generating code for the ARM Cortex-M0 processor on the board. They also install a modified version of the Geany programming environment that is able to make sense of the syntax of ARM assembly language.<br />
<br />
Using a Raspberry Pi is convenient as a way of getting a standardised Linux-based setup with minimal fuss. However, it is almost as easy to set up any other Linux machine in a similar way, and I did much of the development work for the book on an ordinary Intel-based laptop. For machines running Debian or a derivative, the same setup script described below will work just as well as on a Raspberry Pi. For other Linux distributions, similar steps will work if performed manually. It doesn't matter if the host machine is based on an Intel processor rather than an ARM processor, because it's not necessary for the host processor actually to run any of the code that is being compiled; even on the Raspberry Pi, the compiler we use is a cross-compiler, running on one machine and generating code for another. Althogh in that case, both machines are designed by ARM, the host runs native ARM code while the target machine runs Thumb code.<br />
<br />
Similarly, the instructions in this book are written on the assumption that you will be using Geany as a programming environment for editing and compiling the programs, but it is quite easy to use a different enviornment instead. The procedure for compiling and linking each program is described by a Makefile, so any programming environment that can invoke @make@ to build a program can easily be used in place of Geany. If you prefer, you can use an ordinary text editor for programming and invoke @make@ from the command line.<br />
<br />
Some experiments rely on connecting the serial port on the {{microbit}} directly to the serial port on the {{RPi}}, and for these to work, it's necessary to enable the serial port on the Pi. Instructions for doing this appear below.<br />
<br />
==Instructions==<br />
* '''1: Begin with latest version of Raspbian,''' which you can get from the Raspberry Pi [https://www.raspberrypi.org/downloads downloads page].<br />
:It works well if we continue to use the automatically generated 'pi' account: if you prefer to create an account with your own name, be sure to add yourself to all the same groups as user 'pi'.<br />
Perform the following steps in a Terminal window (which you can open by clicking on the [[Image:Terminal.png]] icon near the top left corner of the screen. In what follows, @$@ represents the shell prompt, and the rest of the line (shown in italics) is what you must type.<br />
* '''2: Update the system''' with the latest versions of all installed packages:<br />
::<code>$ ''sudo apt-get update''</code><br />
::<code>$ ''sudo apt-get upgrade''</code><br />
:This will avoid problems when the setup script installs new repositories and packages later.<br />
* '''3: Download the software kit.''' (For now, that means installing Git and cloning the Git repository as follows.)<br />
::<code>$ ''sudo apt-get install git''</code><br />
::<code>$ ''git clone <nowiki>https://spivey.oriel.ox.ac.uk/git/baremetal-v1.git</nowiki>''</code><br />
:If you have the V2 {{microbit}}, replace @baremetal-v1.git@ with @baremetal-v2.git@; for simplicity, the software kit supports one version or the other, but not both at once.<br />
* '''4: Run the setup script:'''<br />
::<code>$ ''cd baremetal''</code><br />
::<code>$ ''sh setup/install''</code><br />
:This will automatically carry out the steps listed later in this appendix, and takes about 10 minutes at most.<br />
* '''5: Finally, reboot the machine''' by choosing {{Menu|Shutdown>Reboot}} in the main system menu. Afterwards, you should see that Geany project files (such as the file @x1000.geany@ in subdirectory @x1000-echo@ of the software kit) have the Geany icon, and double-clicking them opens the project in Geany. That is our preferred method of starting Geany with the correct options for building the project.<br />
<br />
==Updating==<br />
As more experiments are released, you will want to add the code to your copy of the software kit. You can do this using the @git pull@ command, then running a script to create new Geany project files.<br />
::<code>$ ''cd baremetal''</code><br />
::<code>$ ''git pull''</code><br />
::<code>$ ''bash setup/genproj''</code><br />
Any additions will be merged into your working copy of the files.<br />
<br />
==Setup actions==<br />
These are the actions performed by the setup script.<br />
*Add a new software repository and signing key: the repository contains an enhanced build of the latest version of Geany, able to handle syntax hightlighting for ARM assembly language, and with space for more entries in the {{Menu|Build}} menu.<br />
*Install the following Raspbian packages, together with the other packages on which they depend. Some may already be installed, but installing them again does no harm.<br />
<pre><br />
gcc-arm-none-eabi gdb-arm-none-eabi<br />
pulseview sigrok-firmware-fx2lafw<br />
minicom python3<br />
geany geany-plugin-projectorganizer<br />
</pre><br />
*Associate Geany with project files (extension @.geany@), by adding a new MIME type @application-geany-project.xml@ and a new desktop file @geany.desktop@.<br />
*Install various personalised configuration files and settings for Geany. Specifically:<br />
**Create a file @filetype_extensions.conf@ that associates files with extension @.s@ with the language code @GnuARM@.<br />
**Disable the 'Load files from last session' option (it is confusing when used with projects).<br />
**Enable the project organiser plugin, and pre-select the Project tab in the Geany sidebar.<br />
*Adjust the personalised file manager settings so that it no longer opens a dialog box every time a USB drive is inserted. (It's annoying if this happens every time the {{microbit}} reconnects.)<br />
*Set the defaults for @minicom@ to 9600 baud and device @/dev/ttyACM0@.<br />
The script will also work on a PC running 32 bit or 64 bit Debian.<br />
<br />
==Enabling the serial port==<br />
For some experiements, we will want to use the serial port on the {{RPi}} to connect to the {{microbit}}. Luckily, the 3.3V signals on both boards are compatible. For these experiments, the serial port on the Pi should be enabled, but should not show a login prompt. To set this up, from the main menu choose {{Menu|Preferences>Raspberry Pi Configuration}}; in the dialog that appears, click on the {{Menu|Interfaces}} tab, choose {{Menu|Serial Port}} = enable and {{Menu|Serial Console}} = disable and click on {{Menu|OK}}. A pop-up will appear asking if you would you like to reboot: click {{Menu|Yes}}.<br />
<br />
[[Image:RPi-config.png|center|frame|Raspberry Pi configuration]]</div>Mike