##New Enabling the Suspend To RAM capabilities on the RoadRunner 1.1 Board 


https://www.linux4sam.org/bin/view/Linux4SAM/PmFaq<br>




A tutorial on how to recompile the Linux kernel 4.14.88 from Linux4SAM in order to take advantage of the Suspend To RAM feature of the RoadRunner 1.1 Board

<span class="abstract">
The updated RoadRunner V 1.1 mounted on the new BertaD2 rel. 1.1 has the possibility to put the CPU in 
<b>Suspend To Ram</b> state in order to lower the power consumption but be 
able to awake in around 1s. Power consumption in this state is around 2mA @3.3V. This state consists in 
shutting down the CPU power completely and maintaining the DDR3L RAM in self-refresh. The restart of the CPU 
can be obtained acting on an external input (WKUP signal) or through the RTC if programmed so before 
entering the "suspend-to-ram" state.
</span>

To recompile the right kernel in order to enable the lowpower <b>Suspend To Ram</b> capabilities of the 
RoadRunner 1.1 you can follow these instructions up to the generation of the zImage:

* [Linux4SAM](http://www.at91.com/linux4sam/bin/view/Linux4SAM/LinuxKernel#Getting_Kernel_sources)

Or you can go directly at the repository: 

* [GitHub Linux4SAM at91 master tree](https://github.com/Wifx/linux-at91/tree/master)

The faster way is to "<b>download ZIP</b>" (after selecting the "<b>Clone or Download</b>" button.
use the branch: origin_master and the sama5_defconfig option.<br><br>

This is a fork of the official Linux kernel 4.14.88 from Atmel Linux4SAM 6.0+ GitHub repository. 

You need to add the proper dts for the roadrunner1_1. Download it here:
<h3>dts file</h3>

<ul>
<li><a href="./acme-roadrunner1_1.dts">acme-roadrunner1_1.dts</a></li>
</ul>

and put it in your fresh downloaded kernel source tree in this position:
<pre class="terminal">
<b>linux-at91/arch/arm/boot/dts</b>
</pre>

Now you need to generate the right .dtb device tree configuration file for the RoadRunner:
<pre class="terminal">
$ <b>make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- acme-roadrunner1_1.dtb</b>
</pre>

the generated acme-roadrunner1_1.dtb will be in your directory tree in:
<pre class="terminal">
<b>linux-at91/arch/arm/boot/dts</b>
</pre>
Transfer the new zImage in your RoadRunner microSD directory /boot<br>

Transfer acme-roadrunner1_1.dtb in your RoadRunner microSD directory /boot changing its name in acme-roadrunner.dtb 
(this name is preset as the one to load in memory from the bootloader at91-bootstrap).

(in order to generate a working RoadRunner microSD please see this tutorial): 

* [Build a Debian Jessie root filesystem](https://www.acmesystems.it/debian_jessie)

To test the <b>Suspend To Ram</b> state, issue the following commands on the RoadRunner command prompt:
<pre class="terminal">
$ <b>mem2io -w -i fc040018,300</b>
$ <b>rtcwake -m mem -s 5</b>
</pre>

The first instruction sets a particular CPU memory mapped I/O register that corresponds 
to a backup pin of the SAMA5D27. This backup pin is used onboard the roadrunner1.1 to 
maintain enabled the DDR3 RAM power regulator even when in shutdown mode. Normally when 
in shutdown mode both CPU and DDR3 memory power regulators onboard the RoadRunner will 
be disabled.

The second instruction is used to put the CPU in "<b>mem</b>" state: one of the lowpower 
states supported by the Linux kernel. This "mem" has been set to correspond to backup mode in the acme-roadrunner1_1.dts file.

<b>mem2io</b> is a utility program by Dougg Gilbert that lets change CPU and memory 
registers from userspace. You can recompile it for RoadRunner from this link<br> 
(download the SAMA5 version):

* [Dougg Gilbert gpio_utils](https://www.acmesystems.it/gpio_utils)

The <b>RoadRunner1.1</b> power consumption when in Suspend to RAM state is around 
<b>2mA @ 3.3V</b> that corresponds to <b>1.6mA @ 5V</b> when using the suggested <b>BertaD2 
V1.1</b> power regulator: <b>Texas TPS62740 in the schematic configuration suggested in our article.</b>.

The <b>Suspend To Ram</b> state puts the DDR3 RAM in autorefresh mode so to maintain 
the complete memory state and stores the Linux internal state in order to let 
it "continue" from the point where it has been suspended. After that the CPU 
is put in shutdown mode and the CPU power regulator onboard the RoadRunner 
is disabled completely. Also all the hardware attached to the 3.3V output of 
the RoadRunner will be switched off as well as the microSD power.

When the mem state is finished (after 5s in our example) the Real Time Clock in the backup 
area of the CPU SAMA5D27 will raise the shutdown line restarting the CPU. However when the bootloader 
is loaded in memory it will find that the previous state was a <b>Suspend To Ram</b> so 
it will jump directly in a particular location of the main DDR3 RAM memory and 
Linux will continue from that point instead of cold booting.
The time interval needed for reloading the bootloader and present the Linux prompt is around 
<b>1s</b> only, in this way.

  
To be able to support this capability, also the bootloader at91bootstrap needs 
to be involved. From the 3.8.8 release of at91bootstrap the Suspend To RAM 
capability is already supported:

 * [Compiling AT91bootstrap 3.8.8](https://www.acmesystems.it/at91bootstrap_3_8)<br>
 
You need to enable the option Backup Mode in at91bootstrap configuration in order 
to enable the suspend to ram capability of the bootloader.<br>


 
