Hibernation On DB410C

Kernel Compilation

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
$ cd linux
$ git checkout -b master_local remotes/origin/master
$ export PATH=$PATH:/path/to/toolchain/gcc-linaro-aarch64-linux-gnu-4.8-2014.04_linux/bin/
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-gnu-

$ make defconfig
$ make menuconfig

Enable these kernel configurations under:

Power management options  ---> 
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION="/dev/mmcblk1p1"
+CONFIG_PM_DEBUG=y
+CONFIG_PM_ADVANCED_DEBUG=y
+CONFIG_PM_TEST_SUSPEND=y

$ make dtbs 
$ make Image -j8

Bootargs

Add "resume=/dev/mmcblk1p1" to your bootargs and a create boot.img.

File System Instruction

Put the board in fastboot and boot the boot.img you created:

$ fastboot boot boot-db410c.img

Format a SD card with ext4 partition with at least 500MB size and insert the card in the SD Card slot of DB410c. Card should get detected. Verify from dmesg. Lets assume the card partition device is /dev/mmcblk1p1

On shell prompt runt these commands:

root@dragonboard-410c:~#  mkswap /dev/mmcblk1p1
root@dragonboard-410c:~#  swapon /dev/mmcblk1p1

Add below line to /etc/fstab

/dev/mmcblk1p1       none       swap    swap  0 0 

Execute hibernation:

root@dragonboard-410c:~# echo disk > /sys/power/state 

This starts the hibernation process. An swap image is created and it flashed in the swap partition which is /dev/mmcblk1p1 and system is put to shutdown. Below are the logs after end of hibernation:

root@dragonboard-410c:~# echo disk > /sys/power/state 
[  120.223852] PM: Syncing filesystems ... done.
[  120.237530] Freezing user space processes ... (elapsed 0.001 seconds) done.
[  120.243958] Double checking all user space processes after OOM killer disable... (elapsed 0.000 seconds) 
[  120.253293] PM: Preallocating image memory... done (allocated 23732 pages)
[  120.443992] PM: Allocated 94928 kbytes in 0.19 seconds (499.62 MB/s)
[  120.445560] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[  120.560015] mmc1: Reset 0x1 never completed.
[  120.560036] sdhci: =========== REGISTER DUMP (mmc1)===========
[  120.563342] sdhci: Sys addr: 0x00000000 | Version:  0x00002e02
[  120.568983] sdhci: Blk size: 0x00004000 | Blk cnt:  0x00000000
[  120.574800] sdhci: Argument: 0x00000000 | Trn mode: 0x00000000
[  120.580615] sdhci: Present:  0x01f80000 | Host ctl: 0x00000000
[  120.586432] sdhci: Power:    0x00000000 | Blk gap:  0x00000000
[  120.592248] sdhci: Wake-up:  0x00000000 | Clock:    0x00000003
[  120.598063] sdhci: Timeout:  0x00000000 | Int stat: 0x00000000
[  120.603880] sdhci: Int enab: 0x00000000 | Sig enab: 0x00000000
[  120.609696] sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000
[  120.615511] sdhci: Caps:     0x322dc8b2 | Caps_1:   0x00008007
[  120.621328] sdhci: Cmd:      0x00000000 | Max curr: 0x00000000
[  120.627143] sdhci: Host ctl2: 0x00000000
[  120.632958] sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x0000000000000000
[  120.637039] sdhci: ===========================================
[  120.661129] PM: freeze of devices complete after 201.590 msecs
[  120.661805] PM: late freeze of devices complete after 0.646 msecs
[  120.666492] PM: noirq freeze of devices complete after 0.617 msecs
[  120.672037] Disabling non-boot CPUs ...
[  120.702094] CPU1: shutdown
[  120.702119] psci: CPU1 killed.
[  120.750085] CPU2: shutdown
[  120.750113] psci: CPU2 killed.
[  120.782042] CPU3: shutdown
[  120.782069] psci: CPU3 killed.
[  120.794807] PM: Creating hibernation image:
[  120.794807] PM: Need to copy 23101 pages
[  120.794807] PM: Hibernation image created (23101 pages copied)
[  120.794807] PM: syscore_resume
[  120.794815] Enabling non-boot CPUs ...
[  120.822711] Detected VIPT I-cache on CPU1
[  120.822766] CPU1: Booted secondary processor [410fd030]
[  120.823015]  cache: parent cpu1 should not be sleeping
[  120.831443] CPU1 is up
[  120.858810] Detected VIPT I-cache on CPU2
[  120.858855] CPU2: Booted secondary processor [410fd030]
[  120.859097]  cache: parent cpu2 should not be sleeping
[  120.867473] CPU2 is up
[  120.898991] Detected VIPT I-cache on CPU3
[  120.899032] CPU3: Booted secondary processor [410fd030]
[  120.899262]  cache: parent cpu3 should not be sleeping
[  120.907649] CPU3 is up
[  120.912982] PM: noirq thaw of devices complete after 0.475 msecs
[  120.915705] PM: early thaw of devices complete after 0.721 msecs
[  120.921978] PM: thaw of devices complete after 0.950 msecs
[  120.927990] msm_hsusb_host 78d9000.ehci: unable to find transceiver
[  121.763274] PM: Using 3 thread(s) for compression.
[  121.763274] PM: Compressing and saving image data (23147 pages)...
[  121.763358] PM: Image saving progress:   0%
[  121.887028] PM: Image saving progress:  10%
[  121.976970] PM: Image saving progress:  20%
[  122.054810] PM: Image saving progress:  30%
[  122.143624] PM: Image saving progress:  40%
[  122.235466] PM: Image saving progress:  50%
[  122.295599] PM: Image saving progress:  60%
[  122.357931] PM: Image saving progress:  70%
[  122.418214] PM: Image saving progress:  80%
[  122.473768] PM: Image saving progress:  90%
[  122.545965] PM: Image saving progress: 100%
[  132.873390] PM: Image saving done.
[  132.873419] PM: Wrote 92588 kbytes in 11.11 seconds (8.33 MB/s)
[  132.878671] PM: S|
[  133.150586] mmc1: Reset 0x1 never completed.
[  133.150611] sdhci: =========== REGISTER DUMP (mmc1)===========
[  133.153916] sdhci: Sys addr: 0x00000000 | Version:  0x00002e02
[  133.159557] sdhci: Blk size: 0x00004000 | Blk cnt:  0x00000000
[  133.165373] sdhci: Argument: 0x00000000 | Trn mode: 0x00000000
[  133.171189] sdhci: Present:  0x01f80000 | Host ctl: 0x00000000
[  133.177006] sdhci: Power:    0x00000000 | Blk gap:  0x00000000
[  133.182821] sdhci: Wake-up:  0x00000000 | Clock:    0x00000003
[  133.188638] sdhci: Timeout:  0x00000000 | Int stat: 0x00000000
[  133.194453] sdhci: Int enab: 0x00000000 | Sig enab: 0x00000000
[  133.200269] sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000
[  133.206085] sdhci: Caps:     0x322dc8b2 | Caps_1:   0x00008007
[  133.211902] sdhci: Cmd:      0x00000000 | Max curr: 0x00000000
[  133.217716] sdhci: Host ctl2: 0x00000000
[  133.223531] sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x0000000000000000
[  133.227614] sdhci: ===========================================
[  133.448795] mmc0: Reset 0x1 never completed.
[  133.448815] sdhci: =========== REGISTER DUMP (mmc0)===========
[  133.452121] sdhci: Sys addr: 0x00000000 | Version:  0x00002e02
[  133.457764] sdhci: Blk size: 0x00004000 | Blk cnt:  0x00000000
[  133.463580] sdhci: Argument: 0x00000000 | Trn mode: 0x00000000
[  133.469395] sdhci: Present:  0x01f80000 | Host ctl: 0x00000000
[  133.475211] sdhci: Power:    0x00000000 | Blk gap:  0x00000000
[  133.481026] sdhci: Wake-up:  0x00000000 | Clock:    0x00000003
[  133.486842] sdhci: Timeout:  0x00000000 | Int stat: 0x00000000
[  133.492659] sdhci: Int enab: 0x00000000 | Sig enab: 0x00000000
[  133.498474] sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000
[  133.504290] sdhci: Caps:     0x322dc8b2 | Caps_1:   0x00008007
[  133.510105] sdhci: Cmd:      0x00000000 | Max curr: 0x00000000
[  133.515921] sdhci: Host ctl2: 0x00000000
[  133.521736] sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x0000000000000000
[  133.525818] sdhci: ===========================================
[  133.534033] reboot: Power down

Restarting after the hibernation

After the system shuts down it tries to reboot. If you have your kernel images flashed in the emmc it should boot the board with the same. Else make sure you put the device to fastboot just after shutdown by pressing the volume down key. And boot your kernel using fastboot. The board should boot normally and resume from the swap partition:

PM: Starting manual resume from disk
. [    1.795248] Freezing user space processes ... (elapsed 0.001 seconds) done.
[    1.801081] Double checking all user space processes after OOM killer disable... (elapsed 0.000 seconds) 
[    1.836361] PM: Using 3 thread(s) for decompression.
[    1.836361] PM: Loading and decompressing image data (23147 pages)...
[    3.259382] PM: Image loading progress:   0%
[    3.403951] PM: Image loading progress:  10%
[    3.476037] PM: Image loading progress:  20%
[    3.541138] PM: Image loading progress:  30%
[    3.609315] PM: Image loading progress:  40%
[    3.679581] PM: Image loading progress:  50%
[    3.741592] PM: Image loading progress:  60%
[    3.804015] PM: Image loading progress:  70%
[    3.867448] PM: Image loading progress:  80%
[    3.932810] PM: Image loading progress:  90%
[    3.999124] PM: Image loading progress: 100%
[    3.999375] PM: Image loading done.
[    4.002486] PM: Read 92588 kbytes in 2.16 seconds (42.86 MB/s)
[    4.111780] mmc1: Reset 0x1 never completed.
[    4.111801] sdhci: =========== REGISTER DUMP (mmc1)===========
[    4.115107] sdhci: Sys addr: 0x00000000 | Version:  0x00002e02
[    4.120749] sdhci: Blk size: 0x00004000 | Blk cnt:  0x00000000
[    4.126565] sdhci: Argument: 0x00000000 | Trn mode: 0x00000000
[    4.132381] sdhci: Present:  0x01f80000 | Host ctl: 0x00000000
[    4.138198] sdhci: Power:    0x00000000 | Blk gap:  0x00000000
[    4.144013] sdhci: Wake-up:  0x00000000 | Clock:    0x00000003
[    4.149833] sdhci: Timeout:  0x00000000 | Int stat: 0x00000000
[    4.155645] sdhci: Int enab: 0x00000000 | Sig enab: 0x00000000
[    4.161460] sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000
[    4.167278] sdhci: Caps:     0x322dc8b2 | Caps_1:   0x00008007
[    4.173092] sdhci: Cmd:      0x00000000 | Max curr: 0x00000000
[    4.178908] sdhci: Host ctl2: 0x00000000
[    4.184722] sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x0000000000000000
[    4.188805] sdhci: ===========================================
[    4.213286] PM: quiesce of devices complete after 201.718 msecs
[    4.213878] PM: late quiesce of devices complete after 0.563 msecs
[    4.246244] PM: noirq quiesce of devices complete after 28.215 msecs
[    4.246266] Disabling non-boot CPUs ...
[    4.274095] CPU1: shutdown
[    4.274121] psci: CPU1 killed.
[    4.329930] IRQ5 no longer affine to CPU2
[    4.330061] CPU2: shutdown
[    4.333038] psci: CPU2 killed.
[    4.394003] CPU3: shutdown
[    4.394029] psci: CPU3 killed.
[  120.794807] PM: syscore_resume
[  120.794867] Enabling non-boot CPUs ...
[  120.822689] Detected VIPT I-cache on CPU1
[  120.822746] CPU1: Booted secondary processor [410fd030]
[  120.822993]  cache: parent cpu1 should not be sleeping
[  120.831418] CPU1 is up
[  120.858798] Detected VIPT I-cache on CPU2
[  120.858841] CPU2: Booted secondary processor [410fd030]
[  120.859085]  cache: parent cpu2 should not be sleeping
[  120.867459] CPU2 is up
[  120.898988] Detected VIPT I-cache on CPU3
[  120.899027] CPU3: Booted secondary processor [410fd030]
[  120.899258]  cache: parent cpu3 should not be sleeping
[  120.907641] CPU3 is up
[  120.912967] PM: noirq restore of devices complete after 0.467 msecs
[  120.915691] PM: early restore of devices complete after 0.714 msecs
[  120.959501] PM: restore of devices complete after 1.157 msecs
[  120.959916] Restarting tasks ...
Reference-Platform-Build-Wayland 2.0+linaro dragonboard-410c ttyMSM0

dragonboard-410c login: root

root@dragonboard-410c:~# 

HowTo/HibernationOnDB410C (last modified 2016-09-01 05:59:10)