Build memmap Linux® Module

Last modified by Microchip on 2026/08/17 12:19

Ultra-Fast Boot needs memory mapping parameters to help analyze memory pages and generate the snapshot image. This module is only used with the Manually Save and Load Snapshot Image mode.

Get the kernel sources. See the Linux® kernel source tree GitHub® page, which provides the Linux4SAM Linux kernel git tree for Microchip MPU devices.


Create a new folder for the mem_map module beside your Linux kernel source directory. For example, if your kernel source folder is named linux, you can create a sibling folder named mem_map to store the module source files.


Create a C file under the mem_map folder. Ultra-Fast Boot provides the mem-map module source code. See the mem_map_module.zip page.

#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("AT91: PM: mem_map     = 0x%x\n\r", __pa_symbol(mem_map));
 pr_info("AT91: PM: page_size   = 0x%lx\n\r", PAGE_SIZE);
 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");

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

Build the mem_map module.

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

Back to Top