Get Started With the Ultra-Fast Boot Feature Under Linux®

Last modified by Microchip on 2025/08/27 12:08

Introduction

This document describes how to get started with the Ultra-Fast Boot feature under Linux®.

This user's guide presents the steps for Ultra-Fast Boot mode and how to prepare a snapshot image for Fast Boot. This document is written for SAMA7G54-EK, SAMA5D29 Curiosity and SAMA7D65 Curiosity boards, but can be tailored to any SAMA5 and SAMA7 series system.

Quick References

Reference Documentation

For further study, refer to the following:

Ultra-Fast Boot Overview

This section gives an overview of the Ultra-Fast Boot.

Booting an embedded Linux system quickly can improve the user experience. This Ultra-Fast boot is based on the fast boot technique of a snapshot image. The purpose is to restore a Linux context from a cold boot (power-up). The Linux context is a pre-saved memory image called "snapshot image." This article explains how these techniques have been used to boot Linux within milliseconds.

Boot Sequence Components

The boot process begins with the MPU’s Power-On Reset (POR) and progresses in stages, reading binary files from the external Non-Volatile Memory (NVM) and loading them into the volatile memory (internal Static RAM (SRAM) and external Dynamic RAM (DRAM)).

  • ROM code (First-stage bootloader)
  • at91bootstrap (the second-level bootloader)
  • The Universal Boot Loader (U-Boot)
  • Loading Kernel and Rootfs
Boot Sequence Components

Boot Sequence Components

The ROM code (or Boot ROM) is stored in on-chip mask ROM and executes on power-on or after a reset. It is responsible for loading the user application or a second-stage bootloader from an external NVM into internal SRAM.

Out of the factory, the ROM code boots on the SDMMC1 memory interface when an SDTM card or e.MMC memory is connected (the Card Detect pin is used). To configure a specific boot sequence tailored for the system on another memory type (NAND Flash, QSPI, SPI, SDMMC0 interfaces), you must write a Boot Configuration in the Fuse Area or One-Time Programmable (OTP) memory. Refer to the “Standard Boot Configuration” section of the product data sheet for details.

at91bootstrap is the second-level bootloader for Microchip MPU SoCs, providing a set of algorithms to manage the hardware initialization, such as clock speed configuration, PIO settings, DRAM initialization, to download your main application from specified boot media to main memory and to start it.

The at91bootstrap is also responsible for creating and loading the snapshot image for Ultra-Fast booting.

U-Boot takes place in the Linux demo as a third-stage bootloader. It is responsible for configuring main interfaces and launching a Linux system. Note, however, that it is possible to avoid this step and to directly boot Linux from at91bootstrap in a production phase, for instance.

BSR (Backup Mode With SDRAM in Self-Refresh) Mode

What is BSR?

The BSR mode is based on the STR power mode of the Linux system.

In Backup mode, the processor, its peripherals and its memories are unpowered. The SECUMOD is powered by VDDBU (either VBAT or VDDIN33).

BSR mode (Backup with SDRAM in Self-Refresh) is an extension of backup mode with the application context saved in the external DDR memory operating in Self-Refresh mode. In this mode, VBAT and VDDIODDR power inputs must be maintained, as well as the DDR component power inputs.

Hardware Requirements

  • A power management IC
    • All power supply inputs can be maintained by PMIC. The PMIC provides power to the processor and to the DDRAM. For example, MCP16502, 6-channel PMIC with an I²C control interface supports dynamic voltage scaling and processor low-power modes (ULP2, BSR).
  • A super capacitor or a coin cell battery to supply VDDBU (VBAT)

Supported Boards

BoardPMICVDDBU
SAMA5D27-WLSOM1-EKMCP16502AC-E/S8Bsuper capacitor
SAMA5D2-XULTACT8945AQJ405-Tcell battery
SAMA5D2-ICPMCP16502AAsuper capacitor
SAMA5D29-CURIOSITYMCP16502TAC-E/S8Bsuper capacitor
SAMA7G5-EKMCP16502AB-E/S8Bsuper capacitor
SAMA7G54-CURIOSITYMCP16502TAB-E/S8Bsuper capacitor
SAMA7D65-CURIOSITYMCP16502TAB-E/S8Bcell battery
SAMA7D65-DDR2-EBMCP16502TAB-E/S8Bcell battery
SAMA7D65-DDR3-EBMCP16502TAB-E/S8Bcell battery
SAMA7D65-LPDDR2-EBMCP16502TAB-E/S8Bcell battery
SAMA7D65-LPDDR3-EBMCP16502TAB-E/S8Bcell battery

SAMA5D2, SAMA7G5, and SAMA7D65 support backup mode.

Enter/Exit BSR Mode

Enter BSR Mode

Software saves all context information to resume (application-dependent).


Copy to SRAM and execute out of SRAM the routine to set the DDR to Self-refresh mode and to shut down the device (as soon as the DDR is in Self-refresh, accessing the DDR is no longer possible) .


Put the DDR in Self-refresh mode and wait until the self-refresh status is OK.


Switch the system clock to Slow Clock.

Back to Top


Enter Backup mode by asserting the SHDN pin to notify the PMIC that all powers except VDDBU can be turned off.

Enter BSR Mode

Enter BSR Mode

The device exits BSR mode when an active wake-up event is triggered by the SHDWC. Upon this wake-up event, the SHDWC automatically toggles its SHDN output back to VBAT and this signal typically helps to fast-boot all the power supply channels at the board level.

Exit BSR Mode

Exit BSR Mde

Exit BSR Mode

Snapshot Image

A “snapshot” is SDRAM context of Linux at any point after loading. The Ultra-Fast Boot system can capture a valid SDRAM snapshot and use it to restore a Linux system.

Save Snapshot Image

A valid “snapshot” must be captured from a runtime-Linux system and saved to NVM (like an SD card or QSPI Flash) before Ultra-Fast Boot; this is done by at91bootstrap when put in a special mode.

The standard boot sequence starting from ROM boot begins.


The kernel and application are ready.


Enter BSR mode by typing “echo mem > /sys/power/state” (make sure that BSR is set as the mem argument).


DDR is in self-refresh mode.


Exit BSR mode by pressing the nSTART button.


The ROM boot sequence is starting.


The ROM code is executed and loads the at91bootstrap in internal SRAM.

Exit DDR Self Refresh.

Analyze MEM_MAP from kernel, to get a valid memory page.

Save the valid memory page (Snapshot of DRAM) to NVM.

Back to Top


Power off.

Create ‘Snapshot Image’ in BSR Mode

Create Snapshot Image in BSR Mode

Load Snapshot Image

If a valid snapshot is stored in NVM, the system can be restored quickly by loading the snapshot from NVM to DRAM.

Boot the Linux system.

  • In AT91Bootstrap, it checks if a valid “snapshot” is stored in NVM, if Yes

    • Load “snapshot image” to DDR, recovery entire DDR memory
    • System back to suspend state
    • Jump to Linux resume address

Back to Top


Exit suspend mode in the kernel.

NVM of Snapshot Image

The current NVMs supported for snapshot images are SD/MMC and QSPI Flash.

This table summarizes the different data rates that are available for SD/eMMC® cards and QSPI Flash; the “data rate" has a direct impact on the boot speed itself. Note that not all combinations of data rate and capacity are defined, as described.

SD Card Support for Snapshot Image

SD CARDHSSDR50DDR50SDR104
SAMA5D2 SupportYesNoNoNo
SAMA7G5 SupportYesYesYesNo
SAMA7D65 SupportYesYesYesYes
Rate MB/s (Max)25MB/s50MB/s50MB/s104MB/s

eMMC Card Support for Snapshot Image

eMMCHSHS DDRHS200HS400
SAMA5D2 SupportYesNoNoNo
SAMA7G5 SupportYesNoNoNo
SAMA7D65 SupportYesYesYesYes
Rate MB/s (Max)52MB/s104MB/s200MB/s400MB/s

QSPI Flash Support for Snapshot Image

QSPI FlashQuadQuad DTROctaOcta DTR
SAMA5D2 SupportYesNoNoNo
SAMA7G5 SupportYesYesYesYes
SAMA7D65 SupportYesYesYesYes
Clock Frequency100MHz100MHz100MHz100MHz
Rate MB/s (Max)50MB/s100MB/s100MB/s200MB/s

Snapshot Image Size

The snapshot image only needs valid memory pages to be loaded. Instead of storing the entire DRAM as a snapshot image, the Ultra-Fast restore system analyzes memory maps in the kernel system and saves only the valid DRAM contents as a snapshot image to reduce the loading time, thus fastbooting the system to a fully booted state.

Reduce the Size of ‘snapshot image’

Reduce the Size of Snapshot Image

The following figure shows the results of storing a snapshot image, with only 15 percent of the valid content being written to the NVM.

Saving Snapshot image Example

Saving Snapshot image Example

Memory Map

This approach significantly reduces the size of the image, shortens the time it takes to load the image and achieves the goal of booting in a few seconds or even within a second. In order to analyze the memory usage at runtime, a module was applied to help obtain the information needed to analyze the memory, including mem_map_address, mem_page_cnt, pag_type etc. We will go into more detail in the section "Build mem_map Module".

Ultra-Fast Snapshot Creation

Create Snapshot

Create Snapshot

Ultra-Fast Working Flow in AT91Bootstrap

AT91Bootstrap Workflow for Fast Boot Mode

AT91Bootstrap Workflow for Fast Boot Mode

Back to Top

Preparation

Before starting Ultra-Fast Boot, we need to prepare boards and software.

All demo images can be downloaded from "Linux 4 Sam."

Back to Top

Boards Support for the Demo

Board NameBoot FromImage
SAMA7G54-EKSDCARD/QSPISama7g5EKMainPage < Linux4SAM < TWiki
SAMA5D29 CuriositySDCARDSama5d29CuriosityMainPage < Linux4SAM < TWiki

SAMA7D65 Curiosity

SDCARDSama7d65CuriosityMainPage < Linux4SAM < TWiki

Back to Top

Create an SD Card with Fast Boot Demo

To write the compressed image on the SD card, you will have to download and install balenaEtcher . This tool, which is an open-source software, is useful since it enables getting a compressed image as input. More information and extra help are available on the balenaEtcher website .

Back to Top

Create the Third Partition of the SD Card to Store the Snapshot Image

Disk partitioning is the process of dividing a hard drive into multiple sections called partitions. These sections are called primary partitions, and they are formatted with a file system before they can be used to store data. With the FDISK command, you can configure the SD card’s disk drives. You can also choose GParted®, which has a graphical user interface to easily edit disk partitions; see the GParted Manual for details.

FDISK on Linux

Before creating partitions on an SD card, we recommend listing available space and partitions on the hard disk so you can easily identify the storage device and create a partition on it. You can use the fdisk command with –l option to list all available partitions on the disk.

Warning

Caution: Be sure to select the correct disk, especially the one containing the operating system or important data, otherwise the data on that partition will be lost.

fdisk -l

Alternatively, you can use the lsblk command to list information about all the available or specified block devices.

lsblk

Back to Top


Next, you will need to select the storage device on which you want to create partitions. In this case, we will use the /dev/sdb as a storage disk for example:

fdisk /dev/sdb

Back to Top


First, type "m" and press the Enter key to see all available commands and help information as shown:

Fdisk Menu

Fdisk Menu

Back to Top

To create a new partition, follow these steps:

Type "n" and press the Enter key to create a new partition.


Select the partition number 3.


Choose the first sector and last sector of the hard disk, just press Enter with default sector.


Define the size of the partition. Define the size in KB, MB, GB, TB, and PB. Type "+500M" to set the size of the partition to 500 MB, or type "+1G" to set the size of the partition to 1 GB.


Once the partition is created, you see the following screen.

Type "w" and press the Enter key to write changes on the hard disk. You should see the following screen.

Write Table to Disk

Write Table to Disk

You can also type "q" and press the Enter key to exit from the fdisk menu. 

Back to Top


Next, you will need to verify whether or not the partition is created. You can verify it with the following command:

fdisk -p /dev/sdb

You will see your newly created partition on the following screen:

Print Partition Table

Print Partition Table

Back to Top

Diskpart on Windows®

Diskpart is a command-line disk partitioning utility included with Windows operating systems. It allows users to manage disks, partitions, and volumes, including creating, deleting, formatting, and resizing partitions, as well as assigning drive letters.

Back to Top

Build mem_map Module

Get the kernel sources.

Before completing this inclusion process, which can take time, see the GitHub® - linux4microchip/linux: Linux kernel source tree page, which provides the Linux4SAM Linux Kernel git tree for Microchip MPU devices.


Create the folder for the mem_map module.

Create new folder at the same level as Linux for the mem_map module, for example mem_map.


Create a C file under mem_map folder.

#include <linux/module.h>
#include
<linux/init.h>
#include
<linux/mm.h>
#include
<linux/highmem.h>

static int __init mem_map_init(void)
{
 pr_info("The start virtual address of kernel 'page' structures: %px\n", &mem_map);
 pr_info("The maximum Number of Mapped Pages: 0x%lx\n", max_mapnr);
 pr_info("The sizeof 'Page' Structure: 0x%x\n", sizeof(struct page));
 pr_info("The offset of 'page_type' in 'page' structure: 0x%x\n", offsetof(struct page, page_type));
 pr_info("The offset of 'private' in 'Page' structure: 0x%x\n", offsetof(struct page, private));
return 0;
}

static void __exit mem_map_exit(void)
{
pr_info("Exiting mem_map module.\n");
}

module_init(mem_map_init);
module_exit(mem_map_exit);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Print mem_map Address");
MODULE_AUTHOR("Your Name");

Back to Top


Create a Makefile under mem_map folder.

# Name of the object to be built (the source file must be called mem_map_module.c, for example))
obj-m := mem_map_module.o

 KERNEL_DIR := ../linux

 # command by dafault
all:
  make -C $(KERNEL_DIR) M=$(PWD) modules

 # Clean up generated files
clean:
  make -C $(KERNEL_DIR) M=$(PWD) clean

Back to Top


Build the mem_map module.

$ cd mem_map
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

Back to Top

First Boot

Update the u-boot argument for BSR mode.

Boot the board with an SD card.

When u-boot appears, press any key to stop autoboot.

Type "print" to print environment variables.

Update the bootargs variable with backup instead of ulp1.

setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk1p2 rootfstype=ext4 rw rootwait cma=192m atmel.pm_modes=standby,backup"

Save updated variables with the saveenv command:

U-Boot Save Environment

U-Boot Save Environment

Back to Top


Continue to load the kernel.

Type “boot” to continue loading the kernel as shown:

Boot and Login

Boot and Login

Back to Top


Get mem_map information with the mem_map module.

Here are the steps to get runtime MEM MAP information on the target board.

Users can send modules via console input or USB flash.

 
First, send mem_map module.ko with ZMODEM™; type “lrz”.

# lrz
lrz waiting to receive.**B0100000023be50

Next, select File > Transfer > ZMODEM > Send from the menu as shown:

Transfer File with ZMODEM

Transfer File with ZMODEM

Then, select the mem_map_module.ko file under the mem_map folder (see steps on how to create folder for the mem_map module).

And run the module with command as shown:

# insmod -f mem_map_module.ko
Run mem_map Module

Run mem_map Module

Finally, record these for later use.

  • The start virtual address of kernel Page structures: c0d87a68
  • The maximum Number of Mapped Pages: 0x10000
  • The size of Page Structure: 0x20
  • The offset of page_type in Page structure: 0x18
  • The offset of private in Page structure: 0x14

Back to Top

Build aT91bootstrap

Get aT91bootstrap Source Code

You can download at91bootstrap source code from the AT91bootstrap git repository.

Back to Top


Fast Boot Default Configs

The aT91bootstrap program must be configured for Ultra-Fast boot. Assuming you are at the aT91bootstrap root directory, you will find a configs folder that contains several default configuration files. The first step is to configure a default configuration. Here are some default configurations dedicated to fast booting:

  • sama7d65_curiositysd1_fb_uboot_defconfig
  • sama7g5ekdf_qspi_fb_uboot_defconfig
  • sama7g5eksd_fb_uboot_defconfig
  • sama5d29_curiositysd_fb_uboot_defconfig

These defaults already enable almost all fast boot configurations except the memory map configuration.

It includes:

  • Enable Fast Boot Mode,
  • Enable Backup Mode
  • Enable Shutdown Controller Support

See the "Fast Boot Configurations" sections for details.

Back to Top


Default Configuration Example

Set the fast boot default config for the sama7g54-ek to boot using SD card.

$ make sama7g5eksd_fb_uboot_defconfig

Back to Top


To add more configuration, type the following command:

$ make menuconfig

You will see a screen similar with the following:

Make Menuconfig

Make Menuconfig

Back to Top


Fast Boot Setup

Enable Fast Boot mode.

To enable Ultra-Fast boot, the CONFIG_FAST_BOOT must be set by selecting Flash Memory > Enable Fast Boot.

Enable Fast Boot Mode

Enable Fast Boot Mode

Back to Top


Choose the correct Linux4SAM demo version.

Since memory management varies greatly from one version of the Linux kernel to another, you must choose the correct kernel version.

Select Kernel version

Select Kernel version

  • Kernel revisions 6.12 and above:
    • New memory allocation feature in Kernel revisions 6.12, a new system to profile memory allocation, aiding in debugging and performance optimization. The feature has been tested in Linux4SAM 2025.04 demo (based on Linux kernel 6.12.x)
  • Kernel revisions 6.11.11 and below:
    • Use the memory management mechanisms in Kernel 6.11.11 and below. The memory management mechanisms have been tested in Linux4SAM 2024.10 demo (based on Linux kernel 6.6.x) and Linux4SAM 2024.04 demo (based on Linux kernel 6.6.x).

Back to Top


Set the memory map.
  • CONFIG_FASTBOOT_SD_PARTITION: The configuration is for SDCARD only! It selects the partition number (2|3|4) on SDCARD, the dedicated partition is for storing fast boot snapshot image, by default the partition is 3.
  • CONFIG_FASTBOOT_IMG_ADDRESS: Flash offset in QSPI Flash to store fast boot snapshot image. By default, the offset is 0x800000; this configuration is for QSPI boot only.
  • CONFIG_FASTBOOT_MEM_MAP_ADDRESS: The Start Virtual Address of Kernel Page Structures
  • CONFIG_FASTBOOT_MAX_NB_MEM_MAP: The maximum number of mapped pages
  • CONFIG_FASTBOOT_SIZEOF_PAGE_STRUCT: The size of ‘Page’ structure
  • CONFIG_FASTBOOT_OFFSET_OF_PAGETYPE: The offset of ‘page_type’ in ‘Page’ structure
  • CONFIG_FASTBOOT_OFFSET_OF_PRIVATE: The offset of 'private' in 'Page' structure

These values can be obtained from Get mem_map information with mem_map module

Fast Boot Setup

Fast Boot Setup

Back to Top

Fast Boot Configurations

By default, fast boot configurations are disabled and users can set these manually. For example:

$ make sama7g5ekdf_qspi_uboot_defconfig

Enable Backup mode.

We must enable CONFIG_BACKUP_MODE by enabling Enable Backup Mode in the main configuration page.

Enable Backup Mode

Enable Backup Mode

Back to Top


Enable shutdown controller support.

We should enable shutdown controller support for Backup mode, this configuration is only available for SAMA7G54 and SAMA7D65. To enable shutdown controller support, select Basic Drivers Support:

Enable Shutdown Controller Support

Enable Shutdown Controller Support

Back to Top


 Then select Shutdown controller support.

Shutdown Controller Support

Shutdown Controller Support

Back to Top


Build Binary

Then you can build the aT91bootstrap binary:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

If the building process is successful, the final .bin image is build/binaries/boot.bin.

Back to Top


Overriding the aT91bootstrap

Now we can replace the bootloader in NVM with the new one.

To boot using the SD card, copy boot.bin to the SD card and replace the old one.

For QSPI boot, we first backup u-boot.bin and delete boot.bin and u-boot.bin from the SD card. We can then write a new at91bootstrap and set the boot configuration with the SAM-BA tool.

Back to Top

SAM-BA

SAM-BA software provides an open set of tools for in-system programming of internal and external memories connected to our MPUs. You can program your device through the JTAG, debug UART, or USB interfaces.

SAM-BA QSPI Flash Example for sama7g5-ek

To erase all QSPI Flash:

sam-ba -p usb -b sama7g5-ek -a qspiflash -c erase

To write boot file to QSPI Flash:

sam-ba -p usb -b sama7g5-ek -a qspiflash -c writeboot:boot.bin

To write u-boot file to QSPI Flash:

sam-ba -p usb -b sama7g5-ek -a qspiflash -c write:u-boot.bin:0x40000

To write boot configuration to enable QSPI boot in emulation mode:

sam-ba -p usb -b sama7g5-ek -a bootconfig -c writecfg:bscr:EMULATION_ENABLED
sam-ba -p usb -b sama7g5-ek -a bootconfig -c resetemul
sam-ba -p usb -b sama7g5-ek -a bootconfig -c refreshcfg:emul
sam-ba -p usb -b sama7g5-ek -a bootconfig -c writecfg:bcp-emul:FLEXCOM3_USART_IOSET5,QSPI0_IOSET1_AT25

Back to Top

Run Ultra-Fast Boot

Prerequisites

Before creating the snapshot image, we must make sure that the following preparations have been completed:

  • A third partition has been created to store a snapshot image when booting from the SD card.
  • Backup mode has been added to U-Boot boot argument.
  • The at91bootstrap has been built with Fast Boot mode enabled and mem_map parameters.
  • at91bootstrap binary has been written to QSPI Flash if booting from QSPI Flash.
  • Boot configuration has been configured as QSPI boot if booting from QSPI Flash.
  • If your board does not have a supercapacitor, make sure the coin cell battery is fully charged.

Back to Top

Create Snapshot Image

Boot and Enter BSR Mode

Turning on the power will begin the boot process, enter the root password to login as root.

Enter backup mode by command:

# echo mem>/sys/power/state

Then, the system enters BSR mode.

Boot and enter BSR mode

Boot and enter BSR mode

Back to Top


Exit BSR and Save Snapshot Image

Now we can press the nStart button on the board to exit BSR mode, then load at91bootstrap and start saving snapshot image until the console output shows ”Done to save snapshot”.

Saving a snapshot image to the SD card takes a few seconds; QSPI flash takes a few minutes due to the lower performance of QSPI writing.

Exit BSR and Save Snapshot Image

Exit BSR and Save Snapshot Image


Finally, power off the board. 

Boot With Fast Restore

Power on your board and the system is restored in milliseconds.

Boot with Fast Restore

Boot with Fast Restore

Back to Top

FAQ

Which NVM is the fastest when storing and loading snapshot images?

The eMMC in HS400 mode is the fastest memory for storing and loading snapshot images in seconds, it is only available on SAMA7D65.

Can we use other NVMs besides SD and QSPI for fast booting?

We can add NAND flash support upon request.

How do I delete a snapshot image from the third partition or QSPI Flash?

You can format the SD card using the mkfs.fat /dev/sdb3 command or use SAM-BA to erase parts of the area in the QSPI.

Is it possible to enter backup mode as usual when Fast Boot mode is enabled?

No, in this demo, the BSR mode is used for Fast Boot.

Back to Top

Demo

Demo Archives

Failed to execute the [display] macro. Cause: [Current user [null] doesn't have view rights on document [xwiki:Development.applications.linux4sam.demo-archive.archive2025_08.ultrafastboot.WebHome]]. Click on this message for details.

Back to Top

Document Revision History

RevisionDateSectionDescription
12/21DocumentInitial Revision
1.13/6DocumentFix some grammatical errors
1.26/4DocumentFix typo, description
   Add Linux4SAM demo Version
1.37/4DocumentFix Grammar
   Add fast boot default configs
   Use Kernel revisions configs instead of Linux4SAM demo Version
   Update Git repository

Back to Top