# Pi Zero 2 + UnicornHat = (Hardware revision is not supported) Segmentation fault

**URL:** <https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145>\
**Category:** Support\
**Created:** [November 2, 2021, 5:01pm UTC](https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145 "2021-11-02T17:01:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard238](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard238](https://forums.pimoroni.com/u/Richard238)\
**Post date:** [November 2, 2021, 5:01pm UTC](https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145/1 "2021-11-02T17:01:27Z")

</div>

Thought I’d try the new Zero 2 with a bit of Unicornhat magic.

Sadly, it’s not working:

```auto
File "/usr/local/lib/python2.7/dist-packages/rpi_ws281x/rpi_ws281x.py", line 131, in begin
    raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, str_resp))
RuntimeError: ws2811_init failed with code -3 (Hardware revision is not supported)
Segmentation fault

```

Tried these.

```auto
pi@raspberrypi:~ $ sudo pip install --upgrade rpi_ws281x
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already up-to-date: rpi_ws281x in /usr/local/lib/python2.7/dist-packages (4.3.0)

```

```auto
pi@raspberrypi:~ $ sudo pip3 install --upgrade rpi_ws281x
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already up-to-date: rpi_ws281x in /usr/local/lib/python3.7/dist-packages (4.3.0)

```

Any ideas, please?

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [November 3, 2021, 8:26am UTC](https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145/2 "2021-11-03T08:26:54Z")

</div>

Have a look at line 131 of  
File “/usr/local/lib/python2.7/dist-packages/rpi\_ws281x/rpi\_ws281x.py”  
I’d guessing its checking to see what hardware is in use. And the Zero 2 W hasn’t been added yet.

---

<div class="post-metadata">

**Author:** ![hel](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/hel/32/6075_2.png) [@hel](https://forums.pimoroni.com/u/hel)\
**Post date:** [November 3, 2021, 9:34am UTC](https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145/3 "2021-11-03T09:34:35Z")

</div>

Does it work if you use python3 instead of python?

I don’t have one in front of me to try, but I think it might be Unicorn HAT that needs you to run the examples with sudo…

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [November 3, 2021, 9:56am UTC](https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145/4 "2021-11-03T09:56:46Z")

</div>

Yes, as far as I know the original unicorn hat requires sudo.  
I don’t have one either, I have a mini and HD.

---

<div class="post-metadata">

**Author:** ![Richard238](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard238](https://forums.pimoroni.com/u/Richard238)\
**Post date:** [November 3, 2021, 11:24am UTC](https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145/5 "2021-11-03T11:24:59Z")

</div>

Tried with python/python3  
Tried with and without sudo, although it does require sudo, try without for the sake of…

Always the same segmentation error.

And here’s line 123 to 131 of “/usr/local/lib/python2.7/dist-packages/rpi\_ws281x/rpi\_ws281x.py”  
Nowhere (in the entire file) does it mention ‘hardware’ ‘hard ware’ ‘zero’ or ‘pi’

```auto
   def begin(self):
        """Initialize library, must be called once before other functions are
        called.
        """

        resp = ws.ws2811_init(self._leds)
        if resp != 0:
            str_resp = ws.ws2811_get_return_t_str(resp)
            raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, str_resp))

```

Did a little googling, found this [Doesn't support Pi Zero 2 · Issue #475 · jgarff/rpi\_ws281x · GitHub](https://github.com/jgarff/rpi_ws281x/issues/475)  
which takes you to this [rpi-ws281x · PyPI](https://pypi.org/project/rpi-ws281x/4.3.1/)  
Error now reads

```auto
RuntimeError: ws2811_init failed with code -5 (mmap() failed)
Segmentation fault

```

---

<div class="post-metadata">

**Author:** ![hel](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/hel/32/6075_2.png) [@hel](https://forums.pimoroni.com/u/hel)\
**Post date:** [November 3, 2021, 1:17pm UTC](https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145/6 "2021-11-03T13:17:13Z")

</div>

Found my Unicorn HAT, woop!

Just tried the one line installer on a fresh Raspberry Pi OS install (installing things on the Zero 2 is so fast, wow!) and the examples seem to work ok - I’m running them with

`sudo python3 rainbow.py`

 ![PXL_20211103_130714183](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/c/cd9a743144f0f1c59233d64e749b5326df04127e.jpeg)

Might be worth flashing a new RPi OS image and starting from scratch, in case the old version of rpi\_ws281x is still lurking around somewhere?

---

<div class="post-metadata">

**Author:** ![Richard238](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard238](https://forums.pimoroni.com/u/Richard238)\
**Post date:** [November 3, 2021, 1:54pm UTC](https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145/7 "2021-11-03T13:54:56Z")

</div>

Reimaged the OS  
Installed the Unicornhat files with the one line installer.

BOOM!

```auto
pi@raspberrypi:~ $ cd /home/pi/Pimoroni/unicornhat/examples
pi@raspberrypi:~/Pimoroni/unicornhat/examples $ sudo python3 rainbow.py
Rainbow

Displays a beautiful rainbow across your HAT/pHAT :D

If you're using a Unicorn HAT and only half the screen lights up, 
edit this example and change 'unicorn.AUTO' to 'unicorn.HAT' below.

Reticulating splines
Enabled unicorn poop module!
Pooping rainbows...

```

What I haven’t done yet, is to run any updates on the OS.  
It’ll be interesting to see what happens when I do…

---

<div class="post-metadata">

**Author:** ![Richard238](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard238](https://forums.pimoroni.com/u/Richard238)\
**Post date:** [January 27, 2024, 4:54pm UTC](https://forums.pimoroni.com/t/pi-zero-2-unicornhat-hardware-revision-is-not-supported-segmentation-fault/18145/8 "2024-01-27T16:54:44Z")

</div>

Same issue with Pi5 if anyone’s found a solution.

```auto
pi@raspberrypi:~ $ cd /home/pi/Pimoroni/unicornhat/examples
pi@raspberrypi:~/Pimoroni/unicornhat/examples $ sudo python3 rainbow.py
Traceback (most recent call last):
  File "/home/pi/Pimoroni/unicornhat/examples/rainbow.py", line 6, in <module>
    import unicornhat as unicorn
  File "/usr/local/lib/python3.11/dist-packages/unicornhat.py", line 35, in <module>
    ws2812.begin()
  File "/usr/local/lib/python3.11/dist-packages/rpi_ws281x/rpi_ws281x.py", line 143, in begin
    raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, str_resp))
RuntimeError: ws2811_init failed with code -3 (Hardware revision is not supported)
Segmentation fault

```
