A tutorial on how to recompile the Linux kernel 4.9.109 from Linux4SAM 5.8+ in order to take advantage of the Suspend To RAM feature of the RoadRunner 1.1 Board
The updated RoadRunner V 1.1 has the possibility to put the CPU in Suspend To Ram 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.
To recompile the right kernel to enable the lowpower Suspend To Ram capabilities of the RoadRunner 1.1 you can clone the GitHub repository:
use the branch: RoadRunner1_1_lowpower.
This is a fork of the official Linux kernel 4.9.109 from Atmel Linux4SAM 5.8+ GitHub repository:
with the only additions of the right acme-roadrunner-defconfig file and the right acme-roadrunner-lowpower.dts files.
Before recompiling you need to prepare the compilation environment with the correct config:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- acme-roadrunner_defconfig
To change some options in the kernel you can issue (not necessary at this point though):
$ make ARCH=arm menuconfig
Then you need to generate the .dtb file:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- acme-roadrunner-lowpower.dtb
Now you can compile the kernel image:
$ make -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
zImage will be in your directory tree in:
transfer zImage in the RoadRunner microSD directory /boot.
(in order to generate a working RoadRunner microSD please see this tutorial):
To test the Suspend To Ram condition issue the following commands:
$ mem2io -w -i fc040018,300 $ rtcwake -m mem -s 5
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 "mem" state: one of the lowpower states supported by the Linux kernel.
In order to support the Suspend To Ram state it is necessary to insert a special directive in the command line parameters. This can be found in the acme-roadrunner-lowpower.dts file used in this tutorial.
mem2io is an utility program by Dougg Gilbert that lets change CPU and memory
registers from userspace. You can recompile it for RoadRunner from this link
(download the SAMA5 version):
The RoadRunner1.1 power consumption when in Suspend to RAM state is down to 3mA @ 3.3V that corresponds to 2.4mA @ 5V when using the suggested BertaD2 V1.1 power regulator: Texas TPS62740.
The Suspend To Ram 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 Suspend To Ram so it will jump directly in a particular location of the main DDR3 RAM memory and Linux will continue from that point. The process of reloading the bootloader and give out the Linux prompt is around 1s 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 supported: