Computer Systems Experiments 4 | Blinking Activity Light

Series: Computer Systems Experiments

Computer Systems Experiments 4 | Blinking Activity Light

Now, we have powered the light with the Raspberry Pi and we have already set the environment for the experiment. Let’s move on to create a blinking activity ACT light (the green light on the Pi next to the power light PWR).

From the home directory, let’s firstly pull or clone (it depends on whether you have created this local repo) https://github.com/Sadamingh/ComputerSysE (note that if the local repo is already up-to-date, there’s no need to pull). Then, let’s go to the blinking folder,

$ cd blinking/
$ ls

From this folder, we can find four files blink-actled.bin, bootloader.bin, bootcode.bin and start.elf. We don't have to understand these files now. But if you are interested,

  • bootcode.bin to boot the GPU
  • start.elf to start the CPU
  • bootloader.bin to listen to the file transmission

Notice that the Pi must have a file named kernel.img to execute when booting. Normally, the kernel.img file is the operating system kernel that you may want to run on the Pi, like Linux or Windows. But notice that we don't give you a kernel.img. What we can do is to copy the file bootloader.bin and rename it to kernel.img and so that it will listen to the pins in case there is any file to be transferred.

$ cp bootloader.bin kernel.img

We can not transfer the file when we use the Pi for the first time, because there’s no kernel and other critical files in the SDHC card. Thus, we have to manually copy these files to the SDHC card. We use an SD card reader to save those files to the SD card.

First, let’s check the name of our SD card,

$ ls /Volumes

Instead of Macintosh HD, there’s another folder (mine named boot). This folder is the folder of our SD card. Then let’s copy the necessary files into this folder,

$ cp kernel.img /Volumes/boot/
$ cp bootcode.bin /Volumes/boot/
$ cp start.elf /Volumes/boot/

To make sure all the steps are right, check the files in the SD card,

$ ls /Volumes/boot/

This should be,

bootcode.bin kernel.img start.elf

Then we pull out the SD card and insert the card into the Raspberry Pi. Restart the Pi by breaking and reconnecting the power jumper. You can find that the ACT light is blinking now (but this is not what we want). The ACT light is now blinking like bibi — bibi — bibi — (this is called the heartbeat of the bootloader) but what we want is bi-bi-bi- (bi means lighten). The way that it’s blinking now actually means that the Pi is listening to the pins directed by the kernel.img file.

Normally, the RXD (means Receive Data) pin on our CP2102 should be connected (always connected as the green line) to the GPIO14 (UART TX) and the TXD (means Transmit Data) pin on our CP2102 should be connected (always connected as the blue line) to the GPIO15(UART RX).

Finally, let’s transmit our blink-actled.bin file to the Pi,

$ rpi-install.py blink-actled.bin

If it sends back,

Found serial device: /dev/cu.SLAB_USBtoUART
Sending `blink-actled.bin` (72 bytes): .
Successfully sent!

This means that we successfully transmit the file to the Pi. Notice that the ACT light is now blinking like bi-bi-bi-.