Pmusleep not working?

I’m trying to get PMU to get the board to sleep. I’ve set the pmukey register correctly (checked by reading back and getting 1) but writing to pmusleep doesn’t do anything at all, that is execution continues without anything happening.

I’ve checked the sleep and wake program registers as well and they seem to have different values than the documentation would suggest.

I set them to the documented defaults (confirmed to have worked) but that still doesn’t seem to have fixed the problem.

Is there something I’m missing or is the PMU broken on the hifive1-revB?

It seems that pmusleep puts the board to sleep only every 2nd restart of the board (even if I always fill the pmusleeppm registers myself!).

First run nothing happens. Pressing the reset button it seems to work and the board goes to sleep. RTC wake doesn’t seem to trigger for some reason when enabled, but button wake does.

If I reset the board again using the reset button it goes into a “failed cycle” not sleeping again. And this just continues, on and off each time.

So the wakeup portion failing was my fault, I didn’t set the “alwayson” bit on the RTCCFG register.

The non-deterministric resets with the original sifive1 “bootloader” are still there. If I use my custom protector instead it works as expected, sleeps on each iteration and reset.