Raspberry Pi Rainbow Screen Of Death: How To Stack Multiple HATS And Avoid Disaster

Rainbow on a rainy day

The “Rainbow Screen of Death” aka “Rainbow screen at boot” is that dreaded Rainbow screen that appears and doesn’t disappear when you boot up your Raspberry Pi. It gets stuck on the Rainbow. Its arrival is never a good sign. 

The Rainbow Screen Of Death

Whilst there is a multitude of reasons for this to happen: Like outdated firmware on your Rpi, bad SD Card, etc, I want to focus this article on one specific cause: stacking multiple HATS. You may find that everything is fine until you add another HAT. At this point, everything breaks. Fear not, there is a reason for that and a solution.

Stacking Multiple HATS

Before going any further its worth reviewing what a HAT technically is and the different types. 

A “HAT” is shorthand for Hardware Attached on Top and was introduced as a concept by the Raspberry Pi Foundation way back in 2014. The goal of the HAT concept was to include an EEPROM that identified the HAT to the Raspberry Pi system and allowed for some clever automatic configuration of the drivers and necessary software. 

The HAT format is also a physical format that defines the board size and shape and the position of the 40-pin GPIO connector. This leads to many “HATS’ in the market place that are called HATs merely by dint of their form factor but they don’t have the ID EEPROM.

It’s fair to say that since 2014 there are a multitude of HATs that have been produced that offer incredible functionality and often you need the functionality of more that one HAT. No problem, you can physically stack virtually any number. However this is where your problems start. 

You see, you can’t stack multiple HATs if they have an ID EEPROM.

How Can You Tell Whether Your HAT Has An EEPROM?

As many of you have found, stacking multiple HATS may or may not work. It all comes down to whether they are a HAT that includes an EEPROM or not. How can you tell?

Apart from not getting the Raspberry Pi Screen of Death when stacking, you can be a bit more intentional about looking for that EEPROM in the follows ways.

Look At The Schematic

If the manufacturer publishes their schematic for the HAT, then somewhere in it you are looking for a circuit block that looks something like this (from the Spec):

HAT ID EEPROM Circuit

Visually

Get your glasses on or your magnifying glass out and look for any chip with markings that include something like “24C32…”. Here’s what the datasheet advises to look out for:

EEPROM Chip Idents from the Datasheet

If you can’t see one, it’s might still be there but in disguise (I’ve seen some other random markings on them).

ID EEPROM Examples

Query It

This is pretty definitive : you can query the HAT from an SSH / Terminal window by the following incantation:

cd /proc/device-tree/hat
more product

This will print out the ID of a detected HAT. For example with a Sleepy Pi 2 you get:

Query ID EEPROM

The Fix: The Highlander Modification

Because….

There can be only one.

Connor MacLeod, Highlander
Eilean Donan Castle

(At this pointing the story I really wanted to put an image from the Highlander movie, but I feared the copyright trolls too much, so here instead is an image of Eilean Donan Castle used in the film – oh and NEVER, EVER waste your time watching ANY of the sequels – they are the biggest pile of poo ever in the history of film. The first is fab though!).

Delving into the deep recesses of the specification there is an implicit and little known fact: the EEPROM address is fixed in the specification at 0x50 and thus you can have ONLY ONE HAT. 

Now if your “HATS” don’t include ID EEPROMs then breathe a sigh of relief and start stacking because you won’t have a problem. However, if you have HAT’s that DO have ID EEPROMs you have a problem. On boot, the Raspberry Pi queries the EEPROM, finds multiple EEPROMs which conflict, and it disappears up its own rear end and gets stuck at the Raspberry Pi Rainbow Screen of Death.

Now if you have a properly designed HAT it includes a removable 40-pin header. So you just remove the ID_SC and ID_SD pins from the connector(s) in the HATs beyond the first one (or all of them if you like). You can either cut them off or just get a pair of pliers and pull them out – you can reinsert them again if ever you want to as this is non-destructive. 

Remove the ID_SC and ID_SD pins

If your HAT has fixed headers (bangs eyes) then you can insert one of these headers in line and remove the pins as described above.

Conclusion

With a bit of jiggery-pokery and cunning you can stack as many HATs as you like (barring pinning conflicts). You sacrifice the auto-configuration option, but all HATs have a manual installation, and let’s face it, the ones that do configuration are few and far between.

In this way, the Raspberry Pi will stop getting it’s knickers in a twist at boot and everything is unicorns and rainbows in Raspberry Pi Land.

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top