AntonioND
Posts: 8
Joined: Mon Nov 06, 2017 7:03 pm

Powering CPUs on/off in RPi3

Tue Nov 07, 2017 3:08 pm

Hello,

I was wondering if there is any way of actually powering down the cores in the Raspberry Pi 3 (not just wait in a wfi or wfe loop). I've checked the Cortex-A53 manual, but that only takes you so far, after issuing the wfi the hardware is supposed to do the rest.

Same thing for powering on, I know the steps to take once it is actually powered on, but I wouldn't know where to write to actually do it.

As far as I know, this is a platform-specific thing (the registers that you need to use, etc). Can someone point me at some documentation/example code of how to do it? Can even the Linux kernel do this?

Antonio

timanu90
Posts: 63
Joined: Sat Dec 24, 2016 11:54 am

Re: Powering CPUs on/off in RPi3

Wed Nov 08, 2017 8:01 pm

My guess would be to try set the core clock to 0hz. I am not sure if it is even possible. But you can try :D

AntonioND
Posts: 8
Joined: Mon Nov 06, 2017 7:03 pm

Re: Powering CPUs on/off in RPi3

Wed Nov 08, 2017 11:17 pm

It that was possible, would you even be able to set the frequency to non-zero afterwards? xD Can you even set the frequency in a per-cpu basis? If so, it could be something to consider...

timanu90
Posts: 63
Joined: Sat Dec 24, 2016 11:54 am

Re: Powering CPUs on/off in RPi3

Thu Nov 09, 2017 9:47 am

I was checking and it applies to all cores. You can change the frequency but will be the same to all cores, it won't work for you use case.

As seen here https://github.com/raspberrypi/firmware ... -interface, it seems you can turn off some devices, but not cores individually.

AntonioND
Posts: 8
Joined: Mon Nov 06, 2017 7:03 pm

Re: Powering CPUs on/off in RPi3

Thu Nov 09, 2017 11:15 pm

That's unfortunate... But it's interesting that I can turn off the peripherals I'm not using, I definitely could use that (if Linux doesn't do it by default!).

Anyway, thanks for the help! I just wish the documentation was easier to find...

AlfredJingle
Posts: 62
Joined: Thu Mar 03, 2016 10:43 pm

Re: Powering CPUs on/off in RPi3

Sat Jan 06, 2018 5:55 pm

Hi,

In assembly you use the WFE command or WFI for that. They tell the Core to stop (as in don't do anything) and wait till either an Event or Interrupt happen (for definitions see the ARMv8 ref. manual). If you set the WFI in the interrupt handler of the Core it will always go back to nothing no matter how many interrupt are generated.

As for CPU-freq. I for a while on my system (bare-metal, OS-free, C-free, Forth-system) reduced the CPU freq to 10 Mhz if nothing happened, and raised it to 1200 Mhz as soon as there was input, or something else needed handling. And this worked fine. But it interfered with the bitmap-based simple windowing system I was developing. As the frequency has to be the same for all cores and I use 1 core for the windowing.
going from a 6502 on an Oric-1 to an ARMv8 is quite a big step...

AntonioND
Posts: 8
Joined: Mon Nov 06, 2017 7:03 pm

Re: Powering CPUs on/off in RPi3

Sat Jan 06, 2018 8:53 pm

I mentioned that I wasn't looking for a WFE or WFI loop in the first post. I wanted to be able to turn the cores on or off, something that this SoC apparently doesn't support. It's a shame, but well, it's not the end of the world...

However, thanks for confirming that the frequency change is practical, I might take a look at that.

AlfredJingle
Posts: 62
Joined: Thu Mar 03, 2016 10:43 pm

Re: Powering CPUs on/off in RPi3

Sun Jan 07, 2018 10:12 am

Ooh, my mistake!

Out of curriosity: Why would you want to switch off any further than using wfi? Power consumption is very close to zero for a core that way.
going from a 6502 on an Oric-1 to an ARMv8 is quite a big step...

dwelch67
Posts: 919
Joined: Sat May 26, 2012 5:32 pm

Re: Powering CPUs on/off in RPi3

Sun Jan 07, 2018 1:21 pm

I am still curious about this as well, I would hope it is just an undocumented register and they flip on all four at once. (and have four sets of controls)

Why? Because it is there, like why climb the mountain. In part if you are not using the core why have the other three be beating on the cache/dram constantly. I guess you could try to put them in wfi/wfe...

On a battery based system you would want to turn them off, although I dont know how much that saves if any over a WFI/WFE.

Other platforms like allwinner it is the other way around, how the blank do I enable/start the other cores...

If anyone figures this out would love to know the answer as well...

David

AntonioND
Posts: 8
Joined: Mon Nov 06, 2017 7:03 pm

Re: Powering CPUs on/off in RPi3

Sun Jan 07, 2018 2:30 pm

Basically for the reasons that dwelch67 has mentioned. If I'm just going to have a Pi at home idle most of the time, I'd rather use as little energy as I can. WFI + MMU off is probably pretty close to CPU off, but well, as I said, it's not the end of the world, the difference in consumption is probably too small to notice in most cases.

AlfredJingle
Posts: 62
Joined: Thu Mar 03, 2016 10:43 pm

Re: Powering CPUs on/off in RPi3

Mon Jan 08, 2018 8:01 pm

Haha, I know that feeling: I wanna do it because I wanna do it! For the past 3 years I have been busy developing a Raspberry based, OS-free, C-free, Library-free, Forth based home-computer (like the ones in the 80s - fast booting and lots of fun to use). And there is NO logic behind it that other than: I like doing it.

Now for some power management:
On page 2.21 of the TRM of the Cortex-a53 processor ARM describes in detailed steps how to switch off an individual core. Problem being that you have to check the level at a pin (STANDBYWFI), pull another pin low, assert output-clamps etc. In other words: if Broadcom hasn't provided for that, than it cannot realistically been done.

In the same document it is also stated that WFE/WFI puts a core into a static state with only power drawn due to static leakage and a small amount of power drawn by the logic needed to be able to switch on the core. Which in my interpretation sounds like microwatts or even nanowatts.

Experimenting with switching off items like HDMI, USB-controller (if you like a bit of soldering), the power-led etc, etc.and managing frequencies has a bigger potential to save some real power. Buying a good power-supply might also be a good idea.

Just my thoughts. Have fun programming!
going from a 6502 on an Oric-1 to an ARMv8 is quite a big step...

dwelch67
Posts: 919
Joined: Sat May 26, 2012 5:32 pm

Re: Powering CPUs on/off in RPi3

Mon Jan 08, 2018 9:57 pm

nCPUPORESET[CN:0]

nCORERESET[CN:0]

as with other arm cores that came before there are individual reset lines per core that the chip vendor controls. its a chip vendor question not an arm TRM question.

Return to “Bare metal”

Who is online

Users browsing this forum: No registered users and 2 guests