<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Joe Davison CPSC Tech</title>
    <link>https://pages.cpsc.ucalgary.ca/~joe.davison/</link>
    <description>Recent content on Joe Davison CPSC Tech</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 13 Jan 2025 15:23:24 -0700</lastBuildDate>
    
	<atom:link href="https://pages.cpsc.ucalgary.ca/~joe.davison/index.xml" rel="self" type="application/rss+xml" />
    
    
    
    <item>
      <title>BCEM577 Remote Access</title>
      <link>https://pages.cpsc.ucalgary.ca/~joe.davison/bcem577/</link>
      <pubDate>Mon, 13 Jan 2025 15:23:24 -0700</pubDate>
      
      <guid>https://pages.cpsc.ucalgary.ca/~joe.davison/bcem577/</guid>
      <description>&lt;p&gt;Resources for BCEM577 are accessed remotely using Remote Desktop Connection from the lab computer. To begin, find Remote Desktop Connection in the Start Menu and open it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2025-01-13-15-27-16.png&#34; alt=&#34;Screenshot showing Remote Desktop Connection in the Windows Start Menu&#34;&gt;&lt;/p&gt;
&lt;p&gt;In the Computer field, enter the hostname from the password slip (eg bcem15.cs.ucalgary.ca).&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2025-01-13-15-28-53.png&#34; alt=&#34;Screenshot of the Remote Desktop Connection login screen&#34;&gt;&lt;/p&gt;
&lt;p&gt;In the login box that follows, click on &amp;ldquo;More choices&amp;rdquo;, followed by &amp;ldquo;Use a different account&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2025-01-14-09-25-14.png&#34; alt=&#34;Screenshot of the Remote Desktop Connection login dialogue, with \student entered as username, a passwod entered, and &amp;ldquo;use a different account&amp;rdquo; selected&#34;&gt;&lt;/p&gt;
&lt;p&gt;enter &lt;code&gt;\student&lt;/code&gt; as the username (note the preceding backslash, this is important) and the password from the password slip.&lt;/p&gt;
&lt;p&gt;The backslash at the start of the username is vital and &lt;strong&gt;must&lt;/strong&gt; be included, or the connection will fail.&lt;/p&gt;
&lt;p&gt;After logging in, you will see a window asking you to confirm the identity of the remote computer. On this screen,
you can tick &amp;ldquo;Don&amp;rsquo;t ask me again for connections to this computer&amp;rdquo; and then click &amp;ldquo;Yes&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2025-01-14-16-10-34.png&#34; alt=&#34;Screenshot of remote desktop connection identity confirmation screen&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;logging-out&#34;&gt;Logging out&lt;/h2&gt;
&lt;p&gt;Before logging out, ensure that all of your work is saved just in case of any problems.&lt;/p&gt;
&lt;p&gt;When logging out of the remote session, simply close the Remote Desktop window. This can
be done by clicking on the X icon in the top blue bar of the remote desktop connection window.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2025-01-14-16-08-56.png&#34; alt=&#34;Cropped screenshot of the exit UI in remote desktop connection&#34;&gt;&lt;/p&gt;
&lt;p&gt;All open applications, programs, files etc will remain on the machine while you are away. Closing the remote connection
is like turning off a monitor.&lt;/p&gt;
&lt;p&gt;Note that you can, optionally, hide the top bar by clicking the pin icon on the left hand side.
If you choose to hide it, moving your cursor to the top of the screen will display it again temporarily.&lt;/p&gt;
&lt;h2 id=&#34;changing-the-password&#34;&gt;Changing the password&lt;/h2&gt;
&lt;p&gt;If you would like to change your password from the random one from the password slip, you can do so inside the remote desktop connection.&lt;/p&gt;
&lt;p&gt;Click the &amp;ldquo;More applications&amp;rdquo; button in the bottom-left part of the screen, followed by opening the &amp;ldquo;Settings&amp;rdquo; app.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2025-01-13-15-31-22.png&#34; alt=&#34;Cropped screenshot of the Ubuntu desktop&#34;&gt;&lt;/p&gt;
&lt;p&gt;In the settings app, select &amp;ldquo;Sharing&amp;rdquo; on the left-hand side.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2025-01-13-15-34-45.png&#34; alt=&#34;View of the Ubuntu settings app, with the Sharing dialogue selected&#34;&gt;&lt;/p&gt;
&lt;p&gt;You can then change the password. The change will apply immediately, and you can close the remote desktop window as soon as you have done so by pressing the X in the top right-hand side.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2025-01-13-15-32-28.png&#34; alt=&#34;The remote desktop modal in the settings app&#34;&gt;&lt;/p&gt;
&lt;p&gt;Changing other settings on this page &lt;strong&gt;will&lt;/strong&gt; cause lost work.&lt;/p&gt;
&lt;h2 id=&#34;support&#34;&gt;Support&lt;/h2&gt;
&lt;p&gt;If you need technical support, such as if you lose access or the remote environment crashes, please email &lt;strong&gt;&lt;a href=&#34;mailto:cpsc.uls@ucalgary.ca&#34;&gt;cpsc.uls@ucalgary.ca&lt;/a&gt;&lt;/strong&gt;. In your email, please include the hostname of the machine, which can be found
on the password printout (eg bcem5, bcem16).&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Development Guide</title>
      <link>https://pages.cpsc.ucalgary.ca/~joe.davison/development-guide/</link>
      <pubDate>Thu, 22 Aug 2024 15:28:29 -0600</pubDate>
      
      <guid>https://pages.cpsc.ucalgary.ca/~joe.davison/development-guide/</guid>
      <description>&lt;p&gt;These instructions will demonstrate to you how to get a simple Hello World via the UART interface, demonstrating the full functionality of the Pi Kit.&lt;/p&gt;
&lt;p&gt;You can follow these instructions on any of the CPSC lab computers, using the &lt;a href=&#34;../cpsc359-vm&#34;&gt;Development VM&lt;/a&gt;, or by setting up your own toolchain (eg via WSL). Please note that CPSC ULS &lt;strong&gt;only&lt;/strong&gt; supports development in the labs or using the VM.&lt;/p&gt;
&lt;p&gt;This guide assumes the reader has some familiarity with basic Linux tools.&lt;/p&gt;
&lt;h2 id=&#34;hooking-up-the-pi&#34;&gt;Hooking up the Pi&lt;/h2&gt;
&lt;p&gt;Your &lt;a href=&#34;../cpsc359-pi-kits&#34;&gt;Raspberry Pi Kit&lt;/a&gt; contains all of the hardware necessary for development. The custom Pi HAT provides a number of interfaces enabling you to debug the Pi, write to the Pi&amp;rsquo;s memory, and connect devices (such as the controllers).&lt;/p&gt;
&lt;p&gt;To get started you&amp;rsquo;ll need to plug the Pi in using the included power supply. It is important to only use the included power supply with the Pi. Take the USB type B cable and plug the B end into the top of the Pi HAT and the USB A end into your computer. Finally, plug the HDMI cable into a monitor.&lt;/p&gt;
&lt;p&gt;Optionally - though not required at this stage - you can plug the SNES controller into the RJ45 port A.&lt;/p&gt;
&lt;h2 id=&#34;opening-the-uart-interface-and-using-openocd&#34;&gt;Opening the UART interface and using OpenOCD&lt;/h2&gt;
&lt;p&gt;The Pi HAT provides several interfaces, including UART and JTAG. Using standard Linux tools we can work with these interfaces to send code and receive messages.&lt;/p&gt;
&lt;p&gt;First of all, let&amp;rsquo;s open the UART interface to see if the program on the Pi is sending any data over UART. You can do this with a Linux tool called &lt;code&gt;screen&lt;/code&gt;. Open a Terminal and enter the following:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;screen /dev/ttyUSB0 115200,cs8,ixoff,-istrip&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: You may get an error at this stage that &lt;code&gt;/dev/ttyUSB0&lt;/code&gt; cannot be found. Due to the way Linux assigns devices, the correct path could be &lt;code&gt;/dev/ttyUSB1&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This Terminal will now display any data sent by the Pi over the UART interface.&lt;/p&gt;
&lt;p&gt;Next we&amp;rsquo;ll open a debug interface using &lt;code&gt;openocd&lt;/code&gt; and work with it using &lt;code&gt;gdb&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Open another Terminal (hint: ctrl+shift+t will open a new tab in the same window!) and enter the following command:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;openocd -f interface/rpi4.cfg&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: The path to &lt;code&gt;interface/rpi4.cfg&lt;/code&gt; is valid only in the development VM and on the CPSC lab computers. In your own environment you will need to get the &lt;code&gt;rpi4.cfg&lt;/code&gt; file from your instructor.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll see some output letting you know that a debug interface has been opened. You can think of it as a &amp;ldquo;server&amp;rdquo; that we&amp;rsquo;ll connect to using &lt;code&gt;gdb&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll now need to open &lt;em&gt;another&lt;/em&gt; Terminal and enter: &lt;code&gt;gdb&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;gdb has its own command line where you will need to enter the following commands to finish setting up the environment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;set architecture aarch64
target extended-remote :3333
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With the debug interface open you can send new code to the Pi by overwriting its memory - we&amp;rsquo;ll discuss compiling code in the next section - but assuming you have some, you can do:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;load /path/to/code.elf 0x0
continue
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Watch your UART interface as you do this - if you send text to UART in your program, you should see it immediately! When you want to send new code to the Pi, you can press ctrl+c in the gdb window and repeat the &lt;code&gt;load&lt;/code&gt; command.&lt;/p&gt;
&lt;p&gt;With this in mind you will be able to iterate your code more conveniently, sending new variations of your code to the Pi as you compile it.&lt;/p&gt;
&lt;h2 id=&#34;writing-some-code&#34;&gt;Writing some code&lt;/h2&gt;
&lt;p&gt;Your TA / instructor should have provided you some code to bootstrap the Pi. This will be files named similar to &lt;code&gt;start.S&lt;/code&gt;, &lt;code&gt;uart.c&lt;/code&gt; etc. If you don&amp;rsquo;t have these, speak to your instructor.&lt;/p&gt;
&lt;p&gt;The boilerplate bootstrap contains code to initiate the UART interface so text can be sent. The function as defined in &lt;code&gt;uart.c&lt;/code&gt; for this is &lt;code&gt;uart_init()&lt;/code&gt;. So with that in mind, let&amp;rsquo;s see a simple boilerplate Hello World:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;types.h&amp;quot;
#include &amp;quot;uart.h&amp;quot;
#include &amp;quot;mbox.h&amp;quot;
#include &amp;quot;ssp.h&amp;quot;

void main() {
    uart_init();

    uart_puts(&amp;quot;Hello world!\n&amp;quot;);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There should be a &lt;code&gt;Makefile&lt;/code&gt; with the boilerplate, using that, simply &lt;code&gt;make&lt;/code&gt; your code. Two files will be generated: &lt;code&gt;kernel8.elf&lt;/code&gt; and &lt;code&gt;kernel8.img&lt;/code&gt;. We are interested in the &lt;code&gt;elf&lt;/code&gt; file at this stage.&lt;/p&gt;
&lt;p&gt;In the gdb window you opened in the previous step, enter the following, while watching your Terminal window with the UART interface:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;load /path/to/kernel8.elf 0x0
continue
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As soon as you type in &lt;code&gt;continue&lt;/code&gt; (or &lt;code&gt;c&lt;/code&gt;! gdb has lots of abbreviations), you should see Hello World! output in the the UART interface window.&lt;/p&gt;
&lt;p&gt;Now try adding an extra &lt;code&gt;uart_puts&lt;/code&gt; into your code and compile it. Press ctrl+c in gdb and then run the &lt;code&gt;load&lt;/code&gt; command again (hint: use the UP arrow on your keyboard as a neat shortcut). Your new text should appear in the UART interface!&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Development on Windows using WSL</title>
      <link>https://pages.cpsc.ucalgary.ca/~joe.davison/development-on-windows-using-wsl/</link>
      <pubDate>Thu, 07 Mar 2024 11:02:21 -0600</pubDate>
      
      <guid>https://pages.cpsc.ucalgary.ca/~joe.davison/development-on-windows-using-wsl/</guid>
      <description>&lt;p&gt;The &lt;a href=&#34;../cpsc359-vm&#34;&gt;CPSC359 VM&lt;/a&gt; is an option for most Windows devices, but modern Windows includes an awesome tool (that you should get familiar with anyway!) called Windows Subsystem for Linux - WSL.&lt;/p&gt;
&lt;p&gt;WSL is a slim virtual machine that runs Linux and tightly integrates it with Windows. It is essential for any modern developer as it lets you have a neat combination of Windows and Linux development environments.&lt;/p&gt;
&lt;p&gt;I won&amp;rsquo;t go into how to install and set up WSL here as this is covered quite nicely elsewhere, but I will provide the specific steps for hooking up your Pi and using WSL to do everything you need it to.&lt;/p&gt;
&lt;p&gt;This guide is here as a reference to get you started if you are feeling adventurous enough to try this out. Support for development and compiling on WSL cannot be provided; you&amp;rsquo;re on your own if you go this route!&lt;/p&gt;
&lt;h2 id=&#34;requirements&#34;&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;You must have local admin access on your Windows machine and WSL2 installed. You won&amp;rsquo;t be able to do any of this on a campus computer.&lt;/li&gt;
&lt;li&gt;This guide assumes you are using Ubuntu (the default distro for WSL) - other distros may differ&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;software-setup&#34;&gt;Software setup&lt;/h2&gt;
&lt;p&gt;You only need a few packages to get going, install them with the following command:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;sudo apt install openocd screen build-essential gdb-multiarch
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To build software you will also need the &lt;code&gt;aarch64-elf&lt;/code&gt; toolchain. The easiest way to install this in WSL is to use &lt;a href=&#34;https://brew.sh&#34;&gt;Homebrew&lt;/a&gt;. Run the Homebrew installation command given on the Homebrew website, and then follow the steps in the &lt;a href=&#34;https://docs.brew.sh/Homebrew-on-Linux&#34;&gt;Homebrew-on-Linux documentation&lt;/a&gt; to add it to your &lt;code&gt;$PATH&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;With Homebrew installed, simply run &lt;code&gt;brew install aarch64-elf-gcc&lt;/code&gt;. This will install the correct compiler toolchain for you to build baremetal code inside of WSL!&lt;/p&gt;
&lt;p&gt;Now looking outside of the VM, you need to install a driver called usbipd to attach USB devices to the WSL VM. Some more information on this is given on the &lt;a href=&#34;https://learn.microsoft.com/en-us/windows/wsl/connect-usb&#34;&gt;Microsoft documentation&lt;/a&gt; site, but the gist is to just do the following:&lt;/p&gt;
&lt;p&gt;In Windows Terminal, run: &lt;code&gt;winget.exe install --interactive --exact dorssel.usbipd-win&lt;/code&gt; (you can run Windows executables from inside of WSL!). If you don&amp;rsquo;t have winget (it should be included in all installations of Windows 11 now), go to the &lt;a href=&#34;https://github.com/dorssel/usbipd-win/releases&#34;&gt;Github page&lt;/a&gt; for usbipd and download the installer.&lt;/p&gt;
&lt;p&gt;Once you have installed usbipd, restart your computer.&lt;/p&gt;
&lt;h2 id=&#34;hardware-setup&#34;&gt;Hardware setup&lt;/h2&gt;
&lt;p&gt;With WSL and the usbipd driver set up, hook up your Pi to your computer via USB-B and turn it on. In an elevated Powershell window (right click Powershell and select &amp;ldquo;Run as Administrator&amp;rdquo;), do the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;usbipd list&lt;/code&gt; - This will show the USB devices that can be attached to WSL. Note the BUSID and DEVICE columns&lt;/li&gt;
&lt;li&gt;Look for a device named something like &amp;ldquo;USB Serial Converter A, USB Serial Converter B&amp;rdquo; and note its BUSID - let&amp;rsquo;s assume the BUSID is 2-3&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;usbipd bind -b 2-3&lt;/code&gt;, which opens the device up for use in WSL&lt;/li&gt;
&lt;li&gt;Finally, run &lt;code&gt;usbipd attach -b 2-3&lt;/code&gt;, which attaches the Pi to WSL&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&amp;rsquo;s it! The Pi is hooked up to WSL and you can use all the tools as you&amp;rsquo;d expect EXCEPT in the case that &lt;code&gt;gdb&lt;/code&gt; must be invoked as &lt;code&gt;gdb-multiarch&lt;/code&gt; so;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;openocd -f /path/to/rpi4.cfg
-- new terminal --
gdb-multiarch
set architecture aarch64
target extended-remote :3333
-- new terminal --
screen /dev/ttyUSB1 115200
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;support&#34;&gt;Support&lt;/h2&gt;
&lt;p&gt;Please note that I &lt;em&gt;cannot&lt;/em&gt; provide support for a WSL development environment. This is simply because I don&amp;rsquo;t have access to one readily available.&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;official&lt;/em&gt; means that you have at your disposal to develop for CPSC359 is to use the &lt;a href=&#34;../cpsc359-vm&#34;&gt;CPSC359 VM&lt;/a&gt; or any of the computer science lab spaces.&lt;/p&gt;
&lt;p&gt;If you are having a hard time finding a space to work on campus, please contact &lt;a href=&#34;mailto:cpsc.uls@ucalgary.ca&#34;&gt;cpsc.uls@ucalgary.ca&lt;/a&gt; and we can help.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Thanks to Ivan Agalakov for the tip on using WSL for development!&lt;/em&gt;&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>CPSC359 Pi Kits</title>
      <link>https://pages.cpsc.ucalgary.ca/~joe.davison/cpsc359-pi-kits/</link>
      <pubDate>Thu, 29 Jun 2023 10:53:06 -0600</pubDate>
      
      <guid>https://pages.cpsc.ucalgary.ca/~joe.davison/cpsc359-pi-kits/</guid>
      <description>&lt;p&gt;The Pi kits are loaned to you for the duration of your enrolment in CPSC359. They must be returned in full and in an undamaged state at the end of the course, subject to the damage/late fee on your signed agreement.&lt;/p&gt;
&lt;p&gt;The full contents of the kit are as follows. Everything on this list must be returned! If any of these components are missing from your kit, email &lt;a href=&#34;mailto:cpsc.uls@ucalgary.ca&#34;&gt;cpsc.uls@ucalgary.ca&lt;/a&gt;.&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Item No.&lt;/th&gt;
          &lt;th&gt;Description&lt;/th&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Image&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;1&lt;/td&gt;
          &lt;td&gt;Raspberry Pi w/ HAT, SD Card, case&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;../images/2023-06-29-11-19-42.png&#34; alt=&#34;&#34;&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;2&lt;/td&gt;
          &lt;td&gt;SNES Controller&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;../images/2023-06-29-11-21-51.png&#34; alt=&#34;&#34;&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;3&lt;/td&gt;
          &lt;td&gt;Traffic Light Board&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;../images/2023-06-29-11-22-07.png&#34; alt=&#34;&#34;&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;4&lt;/td&gt;
          &lt;td&gt;Mini-HDMI to HDMI cable&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;../images/2023-06-29-11-22-39.png&#34; alt=&#34;&#34;&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;5&lt;/td&gt;
          &lt;td&gt;RJ45/Cat6 cables (x2)&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;../images/2023-06-29-11-22-52.png&#34; alt=&#34;&#34;&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;6&lt;/td&gt;
          &lt;td&gt;USB Type B cable in Ziploc bag&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;../images/2023-06-29-11-23-24.png&#34; alt=&#34;&#34;&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;7&lt;/td&gt;
          &lt;td&gt;USB C Power Supply&lt;/td&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;&lt;img src=&#34;../images/2023-06-29-11-23-46.png&#34; alt=&#34;&#34;&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&#34;faq&#34;&gt;FAQ&lt;/h2&gt;
&lt;p&gt;Below are some common issues and steps on how to address them.&lt;/p&gt;
&lt;h3 id=&#34;do-i-get-to-keep-the-kit&#34;&gt;Do I get to keep the kit?&lt;/h3&gt;
&lt;p&gt;No. The kit is &lt;em&gt;loaned&lt;/em&gt; to you for the duration of your enrolment in CPSC359. You will be charged a damage fee if the kit is not returned on time. This is explained in the agreement you have signed. Questions regarding this should be directed to your professor.&lt;/p&gt;
&lt;h3 id=&#34;can-i-save-data-to-the-sd-card&#34;&gt;Can I save data to the SD card?&lt;/h3&gt;
&lt;p&gt;Please do not. The cards are loaded with the configuration necessary to use the UART interface and run the Pis at a safe clock speed. Further, the SD cards are reused for future classes, so anything you write to the card may be found by a student later on. If you do write any data to the card, please do future students the courtesy of restoring the card to its original state by downloading the &lt;a href=&#34;../cpsc359-baremetal-test-program/&#34;&gt;test program&lt;/a&gt; and writing it to the card.&lt;/p&gt;
&lt;h3 id=&#34;something-in-my-kit-is-broken&#34;&gt;Something in my kit is broken&lt;/h3&gt;
&lt;p&gt;First of all, check and indeed triple check if it really is broken. If your SNES controller isn&amp;rsquo;t working how you expect it to, run it through the &lt;a href=&#34;../cpsc359-baremetal-test-program/&#34;&gt;test program&lt;/a&gt; which is included in your kit. If the test program shows abnormal behaviour, send an email to &lt;a href=&#34;mailto:cpsc.uls@ucalgary.ca&#34;&gt;cpsc.uls@ucalgary.ca&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;something-is-missing-from-my-kit&#34;&gt;Something is missing from my kit&lt;/h3&gt;
&lt;p&gt;Send an email to &lt;a href=&#34;mailto:cpsc.uls@ucalgary.ca&#34;&gt;cpsc.uls@ucalgary.ca&lt;/a&gt; to let us know what is missing. You should also check to make sure it didn&amp;rsquo;t fall out in your bag!&lt;/p&gt;
&lt;h3 id=&#34;i-cannot-return-the-kit-on-time&#34;&gt;I cannot return the kit on time&lt;/h3&gt;
&lt;p&gt;You are obligated to return the kit in an undamaged state by the return date stated on your agreement. If you cannot, send an email to &lt;a href=&#34;mailto:cpsc.uls@ucalgary.ca&#34;&gt;cpsc.uls@ucalgary.ca&lt;/a&gt; as soon as possible. We may be able to help.&lt;/p&gt;
&lt;h3 id=&#34;can-i-use-my-own-raspberry-pi&#34;&gt;Can I use my own Raspberry Pi?&lt;/h3&gt;
&lt;p&gt;It&amp;rsquo;s best if you do not. The kits we provide are in the best known good state for bare metal development. If you use your own Pi you may get unexpected results which could impact your grade. You should use the skills you learn in 359 to make yourself something cool with your Pi though!&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>aarch64 Toolchain</title>
      <link>https://pages.cpsc.ucalgary.ca/~joe.davison/aarch64-toolchain/</link>
      <pubDate>Thu, 01 Jun 2023 11:02:21 -0600</pubDate>
      
      <guid>https://pages.cpsc.ucalgary.ca/~joe.davison/aarch64-toolchain/</guid>
      <description>&lt;p&gt;To support CPSC359, I needed to get access to an aarch64 cross-compiler, specifically for baremetal targets. Turns out this is&amp;hellip;harder than it needs to be. This is a brain dump of some of the work I did to get the toolchain up and running.&lt;/p&gt;
&lt;p&gt;Generally speaking, I don&amp;rsquo;t recommend trying to build your own toolchain. But hey, go nuts if you want to. In my role as a CPSC tech I &lt;em&gt;cannot&lt;/em&gt; support you if you try to do this, but it could be helpful if you need to waste a few hours :)&lt;/p&gt;
&lt;h2 id=&#34;locating-a-toolchain&#34;&gt;Locating a toolchain&lt;/h2&gt;
&lt;p&gt;Many distributions - Fedora and Arch to name a few - provide cross-compilers in their repos, but these are usually for &lt;code&gt;linux&lt;/code&gt; and &lt;code&gt;mingw32&lt;/code&gt; targets. That&amp;rsquo;s&amp;hellip;.not super useful for baremetal! We don&amp;rsquo;t have an ABI to build against in baremetal.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://linaro.org&#34;&gt;Linario&lt;/a&gt; do provide fully built binary toolchains, but the latest version they have for &lt;code&gt;aarch64-elf&lt;/code&gt; is &lt;a href=&#34;https://releases.linaro.org/components/toolchain/binaries/latest-7/&#34;&gt;7.5.0!&lt;/a&gt;. To be honest, I don&amp;rsquo;t really remember how I even stumbled upon this.&lt;/p&gt;
&lt;p&gt;A more up to date toolchain is found at &lt;a href=&#34;https://developer.arm.com/downloads/-/gnu-a%5D&#34;&gt;ARM&amp;rsquo;s developer site&lt;/a&gt;, but it targets the &lt;code&gt;none-elf&lt;/code&gt; ABI which I found didn&amp;rsquo;t always build correctly. In the early days of supporting 359 I simply packaged both of these up in my &lt;a href=&#34;https://pages.cpsc.ucalgary.ca/~joe.davison/cpsc359-vm/&#34;&gt;development VM&lt;/a&gt; and as Fedora packages for use in MS-252. But now things are weird - I&amp;rsquo;m proving two different toolchains for two different ABIs and the GCC versions are very different. And at this stage of the project, I don&amp;rsquo;t even &lt;em&gt;really understand&lt;/em&gt; the differences between the two toolchains.&lt;/p&gt;
&lt;p&gt;At any rate, the Winter 2023 semester went off without much of a problem, and students completed their assignments. Some code some students shared with me built nicely with &lt;code&gt;aarch64-elf&lt;/code&gt;, thankfully!&lt;/p&gt;
&lt;h2 id=&#34;building-a-toolchain&#34;&gt;Building a toolchain&lt;/h2&gt;
&lt;p&gt;Two GCC versions for two ABIs. That&amp;rsquo;s&amp;hellip; not ideal. A professor and TA can adapt just fine, but we can streamline this some more. I set about working to update the toolchain and provide a consistent ABI.&lt;/p&gt;
&lt;p&gt;I found very little use for the &lt;code&gt;none-elf&lt;/code&gt; target, so I decided to get rid of that. But I still needed to get the VM and 252 away from such an old version of GCC - we should not expect students to use such old versions! So let&amp;rsquo;s build a toolchain.&lt;/p&gt;
&lt;p&gt;Turns out - building a toolchain is so ridiculously hard that no one recommends doing it, but thankfully a project known as &lt;a href=&#34;https://github.com/crosstool-ng/crosstool-ng/&#34;&gt;crosstool-ng&lt;/a&gt; exists. Thank goodness! crosstool-ng vastly simplifies the process of building a toolchain by grouping together known-good versions and baselines and produces, at the end of a download, extract, and compile process, a nice tarball of a toolchain. And there is &lt;em&gt;plenty&lt;/em&gt; of flexibility!&lt;/p&gt;
&lt;p&gt;Thankfully, a template for the Pi 4 existed and using crosstool&amp;rsquo;s excellent &lt;code&gt;menuconfig&lt;/code&gt; utility I could change the ABI from Linux to none! Now I had a working toolchain I could build my test code on and deploy to MS-252 and the VM! Almost.&lt;/p&gt;
&lt;h2 id=&#34;packaging-the-toolchain&#34;&gt;Packaging the toolchain&lt;/h2&gt;
&lt;p&gt;crosstool-ng makes the whole process of building a toolchain super simple, but it also makes a &lt;em&gt;ton&lt;/em&gt; of assumptions. Primarily, it makes the assumption that if you are building a toolchain, you&amp;rsquo;re most likely not &lt;em&gt;distributing&lt;/em&gt; it. Distros have standard ways of building toolchains (we use Fedora here at the University, and I just don&amp;rsquo;t understand Fedora packaging &lt;em&gt;enough&lt;/em&gt; to crib from upstream there), so crosstool doesn&amp;rsquo;t want to advertise itself as a way of creating a new standard (insert relevant XKCD here). That&amp;rsquo;s fair, and I&amp;rsquo;m happy with that. Buuut I kinda need to get this packaged up for deployment to 252 - our sysadmins aren&amp;rsquo;t going to happy with a bash script that copies everything into &lt;code&gt;/usr/bin&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So I cobbled together enough knowledge on how Fedora&amp;rsquo;s &lt;code&gt;rpmbuild&lt;/code&gt; works to make a disgustingly hacky &lt;code&gt;.spec&lt;/code&gt; file for building a package - I have it published on &lt;a href=&#34;https://gitlab.cpsc.ucalgary.ca/joe.davison/cpsc-aarch64-elf-gcc&#34;&gt;GitLab here&lt;/a&gt; for reference. The spec is not good - it would make a real Fedora packager weep. But we need something that will work!&lt;/p&gt;
&lt;p&gt;Like crosstool itself, the spec assumes you have already built a crosstool binary and can provide it to &lt;code&gt;rpmbuild&lt;/code&gt;. It then uses the &lt;code&gt;.config&lt;/code&gt; file from crosstool to build the toolchain and stick it in an &lt;code&gt;rpm&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t use this spec. Don&amp;rsquo;t even look at it. It&amp;rsquo;s embarasing!&lt;/p&gt;
&lt;h2 id=&#34;final-thoughts&#34;&gt;Final thoughts&lt;/h2&gt;
&lt;p&gt;So as I write this we are between semesters and the Fall semester will rely on this new toolchain. Early testing and feedback is good, but once the floodgates are opened, who knows what will happen? Updates here once we know more.&lt;/p&gt;
</description>
    </item>
    
    
    
    
    
    <item>
      <title>CPSC359 VM</title>
      <link>https://pages.cpsc.ucalgary.ca/~joe.davison/cpsc359-vm/</link>
      <pubDate>Tue, 23 May 2023 11:16:05 -0600</pubDate>
      
      <guid>https://pages.cpsc.ucalgary.ca/~joe.davison/cpsc359-vm/</guid>
      <description>&lt;p&gt;The CPSC359 VM contains the tools required to connect to the FT2232 device connected to the Raspberry Pi in order to load and debug baremetal code. All of the tools in this VM should be available on all computers in MS-252.&lt;/p&gt;
&lt;p&gt;You can use it as a means to quickly get a development environment for your Pi kit if you are not sure how to install the toolchain yourself (which is fair - don&amp;rsquo;t build toolchains!) or work in MS-252.&lt;/p&gt;
&lt;h2 id=&#34;specs&#34;&gt;Specs&lt;/h2&gt;
&lt;p&gt;The VM is configured with the following specs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Fedora 42&lt;/li&gt;
&lt;li&gt;4GB RAM&lt;/li&gt;
&lt;li&gt;2 CPUs&lt;/li&gt;
&lt;li&gt;15GB disk.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The specs can be adjusted in the VM settings if desired.&lt;/p&gt;
&lt;p&gt;The VM runs Fedora 42 and includes a mostly-default Cinnamon desktop, Visual Studio Code, &lt;code&gt;openocd&lt;/code&gt;, &lt;code&gt;screen&lt;/code&gt;, &lt;code&gt;gdb&lt;/code&gt;, and the toolchain required to build code for the Pi - &lt;code&gt;aarch64-elf-gcc&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A basic bare metal code example is included in &lt;code&gt;~/Examples/rpi4-baremetal-uart&lt;/code&gt;, sourced from &lt;a href=&#34;https://github.com/ethanfaust/rpi4-baremetal-uart&#34;&gt;ethanfaust/rpi4-baremetal-uart&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;system-requirements&#34;&gt;System Requirements&lt;/h2&gt;
&lt;p&gt;You will require the latest version of VirtualBox available for your OS. The VM has been tested in VirtualBox 7.1.12 running on Linux and Windows. macOS is currently not supported and your mileage may vary if you intend to run the VM on a macOS host.&lt;/p&gt;
&lt;p&gt;You will need a minimum of &lt;strong&gt;20GB&lt;/strong&gt; free disk space and at least &lt;strong&gt;8GB RAM&lt;/strong&gt;. You should also ensure that virtualisation acceleration enabled in your BIOS. Check your motherboard&amp;rsquo;s documentation for more information on this.&lt;/p&gt;
&lt;h2 id=&#34;downloading-the-vm&#34;&gt;Downloading the VM&lt;/h2&gt;
&lt;p&gt;The VM image is approx. 4GB in size and can be downloaded &lt;a href=&#34;https://pages.cpsc.ucalgary.ca/~joe.davison/cpsc359/CPSC359.ova&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CPSC359.ova 4.3GB, sha256:
245e0113a1238875ba2f7f3a96261f4f98926e2f5ba1f95a245bd9fb2886412b
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;installing-the-vm&#34;&gt;Installing the VM&lt;/h2&gt;
&lt;p&gt;The following steps assume you &lt;strong&gt;already have VirtualBox installed on your system.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;VirtualBox has an import feature accessed from its main menu. Select Import and then browse to where you have saved the &lt;code&gt;CPSC359.ova&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2023-05-23-11-45-54.png&#34; alt=&#34;Screenshot showing the Import Appliance dialogue in VirtualBox&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2023-05-23-11-47-26.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Once you have selected the &lt;code&gt;.ova&lt;/code&gt; file, you will be presented with a screen that will allow you to customise the VM configuration. By default, we have allocated 2GB of memory and 2 CPU cores. If your hardware is up to it, feel free to increase these before continuing.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2023-05-23-11-47-41.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Once you are happy with your settings, click Import. Do note that it will take some time to import the image.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2023-05-23-11-47-50.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;accessing-the-ft2232-debuguartserial-interface&#34;&gt;Accessing the FT2232 (Debug/UART/Serial interface)&lt;/h2&gt;
&lt;p&gt;Plug the FT2232 device into your computer via USB. With the VM running, navigate to &lt;code&gt;Devices -&amp;gt; Usb&lt;/code&gt; and select the FT2232 device. The name may differ from what is shown here, but it will probably be something like &lt;code&gt;FTDI &amp;lt;-&amp;gt; Serial&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../images/2023-05-23-11-48-29.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;With it selected, the device will be passed through to the VM and you will be able to interface with it as though it were &amp;ldquo;plugged in&amp;rdquo; to the VM itself.&lt;/p&gt;
&lt;p&gt;See the &lt;a href=&#34;../development-guide&#34;&gt;Development Guide&lt;/a&gt; for information on working with sending code to the Pi.&lt;/p&gt;
&lt;h2 id=&#34;known-issues&#34;&gt;Known issues&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;When running VirtualBox on some Linux distributions, you may need to add your user to the &lt;code&gt;vboxusers&lt;/code&gt; group.&lt;/li&gt;
&lt;li&gt;Under Windows, USB passthrough can fail if the FTDI device is &amp;ldquo;busy&amp;rdquo; in the host. Windows tends to take control of it to install the driver - rebooting your PC may help.&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    
    
    
  </channel>
</rss>
