An iPad and a RPI

Why we don’t give every child at school is beyond me. As Computer Science at school slips every year, we may be losing another generation…

An iPad, a Laptop and a Raspberry Pi 4

Why we don’t give every child at school a Raspberry Pi (RPI) is beyond me. It would allow every child to see the power of software and learn operating systems, Python programming and electronics. As Computer Science at school slips every year, we may be losing another generation of technologists. In Scotland, for example, Computer Science is not even in the Top 15 subjects at school.

To me, the RPI is the answer to making software engaging for every child, and opens up learning in an almost infinite number of possibilities. From the days of the classic BBC Micro, I’ve always been a fan of standardising the platform for learning coding, and in creating shared resources. With the magic of Git, we have a device that can be set up in minutes and can be used anywhere.

The RPI is a device that fits in your pocket but can be set up to be whatever computer system you want. There’s a simple SD-Card transfer for all your files, and with a simple command-line interface command of “sudo apt install”, you can have almost every piece of software that you would ever want. There’s no silly Microsoft Windows running on it, and no overblown graphical interfaces … it is the computer as it was meant to be. And, if you add the power of GitHub, you now have a place to store code, and which can be easily downloaded onto the device.

So, over Christmas, I have been setting up a full demo test system using just a RPI, and a whole lot of sensors and Pen Testing tools. When we go back to physical conferences, I will be all ready to demo a range of cybersecurity applications. But, what’s so great about the R-PI? Well, the R-PI 4 now has a USB-C power slot, and which can be used both for power and for a network connection. So let’s interface it to an iPad:

To setup the RPI, I basically followed the approach here:

  • Add dtoverlay=dwc2 to the /boot/config.txt
  • Add modules-load=dwc2 to the end of /boot/cmdline.txt
  • If you have not already enabled ssh then create a empty file called ssh in /boot
  • Add libcomposite to /etc/modules
  • Add denyinterfaces usb0 to /etc/dhcpcd.conf
  • Install dnsmasq with sudo apt-get install dnsmasq
  • Create /etc/dnsmasq.d/usb with following:
interface=usb0
dhcp-range=10.55.0.2,10.55.0.6,255.255.255.248,1h
dhcp-option=3
leasefile-ro
  • Create /etc/network/interfaces.d/usb0 with the following:
auto usb0
allow-hotplug usb0
iface usb0 inet static
address 10.55.0.1
netmask 255.255.255.248
  • Create /root/usb.sh
#!/bin/bash
cd /sys/kernel/config/usb_gadget/
mkdir -p pi4
cd pi4
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol
mkdir -p strings/0x409
echo "fedcba9876543211" > strings/0x409/serialnumber
echo "Ben Hardill" > strings/0x409/manufacturer
echo "PI4 USB Device" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower
# Add functions here
# see gadget configurations below
# End functions
mkdir -p functions/ecm.usb0
HOST="00:dc:c8:f7:75:14" # "HostPC"
SELF="00:dd:dc:eb:6d:a1" # "BadUSB"
echo $HOST > functions/ecm.usb0/host_addr
echo $SELF > functions/ecm.usb0/dev_addr
ln -s functions/ecm.usb0 configs/c.1/
udevadm settle -t 5 || :
ls /sys/class/udc > UDC
ifup usb0
service dnsmasq restart
  • Make /root/usb.sh executable with chmod +x /root/usb.sh
  • Add /root/usb.sh to /etc/rc.local before exit 0

And that was it. The IP address of the RPI is 10.55.0.1, and there is no need to connect through wi-fi. Then we just have to enable the VNC server on the RPI with:

sudo apt install realvnc-vnc-server realvnc-vnc-viewer

and then enabling the VNC interface from Menu>Preferences>Raspberry PI Configuration > Interface.

So, what about a laptop? Well, that’s no problem too, and just as easy:

In this case, we just connect with:

ping 10.55.0.1
ssh [email protected]

On the MAC, the USB-C adaptor is setup as an Ethernet adaptor (en7 in my case) and will request an IP address from the RPI. In the following example, it is granted 10.55.0.5 (with a /28 subnet):

> ifconfig
en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=6467<RXCSUM,TXCSUM,VLAN_MTU,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
ether 00:d1:d8:e9:25:74
inet6 fe80::1ca1:c468:81b1:f566%en7 prefixlen 64 secured scopeid 0xb
inet 10.55.0.5 netmask 0xfffffff8 broadcast 10.55.0.7
nd6 options=201<PERFORMNUD,DAD>
media: autoselect (100baseTX <full-duplex>)
status: active

Conclusions

To me, the RPI-4 is one of the most significant computers ever created, and it’s a great learning environment. Just get yourself a 250GB SDCard, and you’ll never look back. To me, it all seems obvious what we need to do:

  • Make Computer Science mandatory for all kids at secondary school, with a key focus on bring the subject alive and making it relevant to make other topics, especially maths and science.
  • Standardize around a language like Python for coding.
  • Standardize on Linux for operating system learning.
  • Purchase a Raspberry PI 4 for every child at secondary school.
  • Setup a central Git repository for the code examples and learning material.
  • Distribute a standard OS image for schools (such as for a 16GB SD Card).
  • Engage with industry to build educational material around the syllabus. As a GitHub is used, this material can be easily integrated into the curriculum.

The RPI can then be used at home, either connecting to another computer or onto a TV. As the BBC Micro did, parents would probably get more engaged with coding and help with the setup.