From: eLinux.org

Suspend To Disk For ARM

Table Of Contents:

Contents

Description

This page shows the result of applying suspend to disk feature for ARM
architecture. Related pages are:

Target Environment

Hardware Information

OSK reference board is used.

Since OSK5912 board does not have disk to save suspend image to, flash
is used to store suspend image.

Software Information

linux kernel 2.6.11 based kernel is used for swsusp, and 2.6.14 based
kernel is used for suspend2. Necessary patches are described in next
section.

swsusp for ARM

build kernel

Below is the kernel patch stack applied on top of vanilla 2.6.11 kernel.

To build kernel, do the following:

(assuming you have cross comiler for ARM)

  • enable CONFIG_PM
  • enable CONFIG_SOFTWARE_SUSPEND
  • enable CONFIG_SWSUSP_MTDBLOCK_FLUSH

This can be done for example by:

  1. $ make omap_osk_5912_defconfig
  2. $ make menuconfig
  3. General setup --->
  4. [*] Power Management Support
  5. [*] Software Suspend (EXPERIMENTAL)
  6. [*] Flush MTD Block
  7. also, NFS is used as rootfs
  8. File systems --->
  9. Network File Systems --->
  10. [*] Root file systems on NFS
  11. $ make uImage

also, check that CONFIG_SYSFS is enabled. (which is default)

do swsusp

Boot OSK board with above kernel. Issue following command as super user
to suspend to disk:

  1. (mount sysfs)
  2. $ mkdir /sys
  3. $ mount -t sysfs none /sys
  4. (enable flash as swap)
  5. $ mkswap /dev/mtdblock3
  6. $ swapon /dev/mtdblock3
  7. (run some applications)
  8. (trigger suspend to disk)
  9. $ echo disk > /sys/power/state

After the suspend to disk is triggered, messages are emitted to console,
and machine would halt.

On next bootup of the board, pass below additional argument to kernel:

    • resume=/dev/mtdblock3

Below is an example:

  1. OMAP5912 OSK # setenv bootargs console=ttyS0,115200n8 ip=dhcp root=/dev/nfs resume=/dev/mtdblock3
  2. OMAP5912 OSK # saveenv

and then boot as usual.

At near end of booting kernel, system reads suspended image, and
resumes.

Known Problems / FAQs

  1. - I would like to suspend image to different storage
  2. I have only tested with mtdblock3, and in swsusp-osk-2.6.11.patch, it is hard coded (sorry...)
  3. For other device (such as USB storage), I have not tested.
  4. - When the suspended image gets big, system does not resume
  5. This turned out to be misconfiguration of EMIFS_CS3 register at boot loader, if you are using
  6. u-boot. There are 2 solutions to this:
      • fix EMIFS_CS3 value in u-boot and rebuild it
      • set the correct value in kernel and rebuild it
  1. u-boot fix for file u-boot-1.1.[123]/board/omap5912osk/platform.S or u-boot-1.1.4/omap5912osk/lowlevel_init.S:
  2. VAL_TC_EMIFS_CS3_CONFIG:
  3. - .word 0x88011131
  4. + .word 0x88013141
  5. kernel re-set the value for file arch/arm/mach-omap/board-osk.c
  6. + #define EMIFS_CS3_VAL (0x88013141)
  7. static void __init osk_init(void)
  8. {
  9. + /* Workaround for wrong CS3 (NOR flash) timing
  10. + * There are some U-Boot versions out there which configure
  11. + * wrong CS3 memory timings. This mainly leads to CRC
  12. + * or similiar errors if you use NOR flash (e.g. with JFFS2)
  13. + */
  14. + if (EMIFS_CCS(3) != EMIFS_CS3_VAL)
  15. + EMIFS_CCS(3) = EMIFS_CS3_VAL;

suspend2 for ARM

build kernel

Below is the kernel patch stack applied on top of vanilla 2.6.14 kernel.

To build kernel, do the following: (assuming you have cross comiler for
ARM)

  • enable CONFIG_PM
  • enable CONFIG_SUSPEND2
  • enable CONFIG_SUSPEND2_CRYPTO
  • enable CONFIG_CRYPTO
  • enable CONFIG_CRYPTO_LZF

This can be done for example by:

  1. $ make omap_osk_5912_defconfig
  2. $ make menuconfig
  3. Power management options --->
  4. [*] Suspend2 --->
  5. [*] File Writer
  6. [*] Swap Writer
  7. Cryptographic options --->
  8. [*] Cryptographic API
  9. <*> LZF compression algorithm
  10. also, change the OSK system timer to MPU Timer
  11. System Type --->
  12. TI OMAP Implementations --->
  13. System timer ---> use mpu timer
  14. $ make uImage

do suspend2

Boot OSK board with above kernel. On bootup of the board, pass below
additional argument to kernel:

    • resume2=swap:/dev/mtdblock3

Below is an example:

  1. OMAP5912 OSK # setenv bootargs console=ttyS0,115200n8 ip=dhcp root=/dev/nfs resume2=swap:/dev/mtdblock3
  2. OMAP5912 OSK # saveenv

Install hibernate script into target system, which could be obtained
from suspend2 web page.

Issue following command as super user to suspend to disk:

  1. (enable flash as swap)
  2. $ mkswap /dev/mtdblock3
  3. $ swapon /dev/mtdblock3
  4. (trigger suspend2 to disk)
  5. $ hibernate

After the suspend to disk is triggered, messages are emitted to console,
and machine would halt.

Power the board again, make sure the kernel parameter contains
resume2=swap:/dev/mtdblock3.

At near the end of kernel boot, suspend2 resume operation begins, and
resumes from previously suspended state.

snapshot boot for ARM

/\ * * * WARNING * * * /\ This feature is very experimental,
Your boot loader might get corrupted. /\ To restore boot loader, refer
osk page], “Flash Recovery Utility” section.

what is it

Snapshot boot is similar to swsusp, but with much faster start up, by
kernel and boot loader working together. In swsusp, time taken to resume
is not very fast, since (a) it starts at `late_initcall’, (b) snapshot
image is copied twice (swap -> allocated mem -> orig mem), and (c)
device state transfer from active -> suspend -> resume. In snapshot
boot, image is copied directly to orig mem addr, and jumps into kernel
resume point, not kernel entry point, and kernel handles device resume,
and thaw processes.

build boot loader

Below is the patch stack applied on top of u-boot-1.1.4 from
u-boot web page. First three
patches are to build osk5912 target, rest are for snapshot boot.

To build u-boot, do the following:

  1. $ make CROSS_COMPILE=arm-linux- omap5912osk_config
  2. $ make CROSS_COMPILE=arm-linux- all

install boot loader

If autoboot is set, hit any key to enter u-boot command prompt.

Below is example installation

  1. OMAP5912 OSK # tftp 0x10000000 u-boot.bin
  2. Take note of bytes that were transfered; take note of below message
  3. Bytes transferred = 96952 (17ab8 hex)
  4. OMAP5912 OSK # protect off 00000000 0001ffff
  5. OMAP5912 OSK # erase 00000000 0001ffff
  6. OMAP5912 OSK # cp.b 0x10000000 0x00000000 0x00017ab8
  7. OMAP5912 OSK # protect on 00000000 0001ffff
  8. OMAP5912 OSK # reset

Again, if you are messed up, take a look at osk page],
“Flash Recovery Utility” section.

build kernel

Below is the kernel patch stack applied on top of vanilla 2.6.11 kernel.
First three patches are the same patches that were used in swsusp.

To build kernel, do the following:

(assuming you have cross comiler for ARM)

  1. $ make omap_osk_5912_defconfig
  2. $ make menuconfig
  3. General setup --->
  4. PCCARD (PCMCIA/CardBus) support --->
  5. <*> PCCard (PCMCIA/CardBus) support
  6. <*> 16-bit PCMCIA support (NEW)
  7. <*> OMAP CompactFlash Controller
  8. [*] Power Management Support
  9. [*] Software Suspend (EXPERIMENTAL)
  10. [*] Flush MTD Block
  11. [*] Preserve swsuspend image
  12. also, NFS is used as rootfs
  13. File systems --->
  14. Network File Systems --->
  15. [*] Root file systems on NFS
  16. $ make uImage

do snapshot boot

On bootup of the board, pass below additional argument to kernel:

    • resume=/dev/mtdblock3
    • prsv-img

Below is an example:

  1. OMAP5912 OSK # setenv bootargs console=ttyS0,115200n8 ip=dhcp root=/dev/nfs resume=/dev/mtdblock3 prsv-img
  2. OMAP5912 OSK # saveenv

Boot OSK board with above kernel.

Issue following command as super user to suspend to disk: (These steps
are identical to swsusp)

  1. (mount sysfs)
  2. $ mkdir /sys
  3. $ mount -t sysfs none /sys
  4. (enable flash as swap)
  5. $ mkswap /dev/mtdblock3
  6. $ swapon /dev/mtdblock3
  7. (run some applications)
  8. (trigger suspend to disk)
  9. $ echo disk > /sys/power/state

After the suspend to disk is triggered, messages are emitted to console,
and machine would halt. Power off the board.

Power on the board, and hit any key to enter u-boot command prompt. From
u-boot, issue snapshot boot command.

  1. OMAP5912 OSK # bootss 0x00240000

The snapshot boot will start, and system resumes from previously
suspended system state. Note that same image could be reused, (by
specifying prsv-img in kernel command line) and contribute to fast
startup of whole system.

Startup comparison

Below is a comparison of swusps vs. snapshot boot startup time. Time is
measured using printk times, so there is some overhead due to
measurement. Rootfs is nfs, and application is mplayer, running mpeg
file. Application and userland is not optimized, prelink, XIP or other
startup improvement techniques are not applied, so refer the data with
relative time, not absolute time. Normal startup time without swsusp nor
snapshot boot is about 11 seconds.

Media:mplayer-swsusp.log Media:mplayer-ssboot.log

NOTE: The latter two log files were not found on the old CELF Pulic
Wiki, therefore links are broken here.

http://elinux.org/Tiny6410

http://elinux.org/Micro2440

http://elinux.org/Mini210

http://elinux.org/Tiny210

Category: