diff --git a/part14-ethernet/Makefile b/part14-spi-ethernet/Makefile similarity index 100% rename from part14-ethernet/Makefile rename to part14-spi-ethernet/Makefile diff --git a/part14-ethernet/Makefile.gcc b/part14-spi-ethernet/Makefile.gcc similarity index 100% rename from part14-ethernet/Makefile.gcc rename to part14-spi-ethernet/Makefile.gcc diff --git a/part14-spi-ethernet/README.md b/part14-spi-ethernet/README.md new file mode 100644 index 0000000..221d182 --- /dev/null +++ b/part14-spi-ethernet/README.md @@ -0,0 +1,35 @@ +Writing a "bare metal" operating system for Raspberry Pi 4 (Part 14) +==================================================================== + +Bare metal Ethernet for under £10 +--------------------------------- +It's exciting to build your own OS, but until you give it the ability to communicate with the outside world, your possibilities are limited. Indeed, our simple Bluetooth comms got us up and running - but if we're to do anything meaningful then we need proper networking. + +In this tutorial, we're going to connect to an external Ethernet controller (a network card, if you like) using the RPi4's Serial Peripheral Interface (SPI). + +Things you'll need: + + * An [ENC28J60 Ethernet module](https://www.amazon.co.uk/dp/B00DB76ZSK) - it cost me less than £6 and was worth every penny (n.b. code only tested on this exact model) + * Some [female-to-female jumper cables](https://www.amazon.co.uk/dp/B072LN3HLG) - cost me less than £2.50 + * An Ethernet cable to connect to your Internet router + +Connecting up the ENC28J60 Ethernet module +------------------------------------------ +I followed the very helpful instructions [here](https://www.instructables.com/Super-Cheap-Ethernet-for-the-Raspberry-Pi/). + +We won't be connecting the interrupt line for now, so there are just six jumper leads (I've suggested colours) that need connecting: + + | Pi pin | Pi GPIO | Jumper colour | ENC28J60 pin | + | ------ | ----------- | ------------- | ------------ | + | Pin 17 | +3V3 power | Red | VCC | + | Pin 19 | GPIO10/MOSI | Green | SI | + | Pin 20 | GND | Black | GND | + | Pin 21 | GPIO09/MISO | Yellow | SO | + | Pin 23 | GPIO11/SCLK | Blue | SCK | + | Pin 24 | GPIO08/CE0 | Green | CS | + +![GPIO location](../part3-helloworld/images/3-helloworld-pinloc.png) + +Here's a (not very useful) photo of my RPi4 connected correctly: + +![ENC28J60 connections](images/14-spi-ethernet-photo.jpg) diff --git a/part14-ethernet/boot/boot.S b/part14-spi-ethernet/boot/boot.S similarity index 100% rename from part14-ethernet/boot/boot.S rename to part14-spi-ethernet/boot/boot.S diff --git a/part14-ethernet/boot/link.ld b/part14-spi-ethernet/boot/link.ld similarity index 100% rename from part14-ethernet/boot/link.ld rename to part14-spi-ethernet/boot/link.ld diff --git a/part14-ethernet/boot/sysregs.h b/part14-spi-ethernet/boot/sysregs.h similarity index 100% rename from part14-ethernet/boot/sysregs.h rename to part14-spi-ethernet/boot/sysregs.h diff --git a/part14-spi-ethernet/images/part14-spi-ethernet-photo.jpg b/part14-spi-ethernet/images/part14-spi-ethernet-photo.jpg new file mode 100644 index 0000000..c3d22f7 Binary files /dev/null and b/part14-spi-ethernet/images/part14-spi-ethernet-photo.jpg differ diff --git a/part14-ethernet/include/fb.h b/part14-spi-ethernet/include/fb.h similarity index 100% rename from part14-ethernet/include/fb.h rename to part14-spi-ethernet/include/fb.h diff --git a/part14-ethernet/include/io.h b/part14-spi-ethernet/include/io.h similarity index 100% rename from part14-ethernet/include/io.h rename to part14-spi-ethernet/include/io.h diff --git a/part14-ethernet/include/mb.h b/part14-spi-ethernet/include/mb.h similarity index 100% rename from part14-ethernet/include/mb.h rename to part14-spi-ethernet/include/mb.h diff --git a/part14-ethernet/include/multicore.h b/part14-spi-ethernet/include/multicore.h similarity index 100% rename from part14-ethernet/include/multicore.h rename to part14-spi-ethernet/include/multicore.h diff --git a/part14-ethernet/include/spi.h b/part14-spi-ethernet/include/spi.h similarity index 100% rename from part14-ethernet/include/spi.h rename to part14-spi-ethernet/include/spi.h diff --git a/part14-ethernet/include/terminal.h b/part14-spi-ethernet/include/terminal.h similarity index 100% rename from part14-ethernet/include/terminal.h rename to part14-spi-ethernet/include/terminal.h diff --git a/part14-ethernet/kernel/arp.c b/part14-spi-ethernet/kernel/arp.c similarity index 100% rename from part14-ethernet/kernel/arp.c rename to part14-spi-ethernet/kernel/arp.c diff --git a/part14-ethernet/kernel/irq.c b/part14-spi-ethernet/kernel/irq.c similarity index 100% rename from part14-ethernet/kernel/irq.c rename to part14-spi-ethernet/kernel/irq.c diff --git a/part14-ethernet/kernel/irqentry.S b/part14-spi-ethernet/kernel/irqentry.S similarity index 100% rename from part14-ethernet/kernel/irqentry.S rename to part14-spi-ethernet/kernel/irqentry.S diff --git a/part14-ethernet/kernel/kernel.c b/part14-spi-ethernet/kernel/kernel.c similarity index 100% rename from part14-ethernet/kernel/kernel.c rename to part14-spi-ethernet/kernel/kernel.c diff --git a/part14-ethernet/kernel/kernel.h b/part14-spi-ethernet/kernel/kernel.h similarity index 100% rename from part14-ethernet/kernel/kernel.h rename to part14-spi-ethernet/kernel/kernel.h diff --git a/part14-ethernet/kernel/utils.S b/part14-spi-ethernet/kernel/utils.S similarity index 100% rename from part14-ethernet/kernel/utils.S rename to part14-spi-ethernet/kernel/utils.S diff --git a/part14-ethernet/lib/fb.c b/part14-spi-ethernet/lib/fb.c similarity index 100% rename from part14-ethernet/lib/fb.c rename to part14-spi-ethernet/lib/fb.c diff --git a/part14-ethernet/lib/io.c b/part14-spi-ethernet/lib/io.c similarity index 100% rename from part14-ethernet/lib/io.c rename to part14-spi-ethernet/lib/io.c diff --git a/part14-ethernet/lib/mb.c b/part14-spi-ethernet/lib/mb.c similarity index 100% rename from part14-ethernet/lib/mb.c rename to part14-spi-ethernet/lib/mb.c diff --git a/part14-ethernet/lib/multicore.c b/part14-spi-ethernet/lib/multicore.c similarity index 100% rename from part14-ethernet/lib/multicore.c rename to part14-spi-ethernet/lib/multicore.c diff --git a/part14-ethernet/lib/spi.c b/part14-spi-ethernet/lib/spi.c similarity index 100% rename from part14-ethernet/lib/spi.c rename to part14-spi-ethernet/lib/spi.c diff --git a/part14-ethernet/net/enc28j60.c b/part14-spi-ethernet/net/enc28j60.c similarity index 100% rename from part14-ethernet/net/enc28j60.c rename to part14-spi-ethernet/net/enc28j60.c diff --git a/part14-ethernet/net/enc28j60.h b/part14-spi-ethernet/net/enc28j60.h similarity index 100% rename from part14-ethernet/net/enc28j60.h rename to part14-spi-ethernet/net/enc28j60.h diff --git a/part14-ethernet/net/encspi.c b/part14-spi-ethernet/net/encspi.c similarity index 100% rename from part14-ethernet/net/encspi.c rename to part14-spi-ethernet/net/encspi.c