Build is only tested on a Linux system, but should be possible on any systemusing the GNU toolchain and the ELF file format. The tools required are:
To build a 32-bit image, change directory into thebuild32
directory andtypemake
. The result is amt86plus
binary image file which can bebooted directly by a 32-bit UEFI BIOS (if named mt86plus.efi), by a legacyBIOS (in floppy mode) or by an intermediate bootloader using the Linux 16-bitboot protocol. The image can be also booted by an intermediate bootloaderusing the Linux 32-bit or 32-bit EFI handover boot protocols.
To build a 64-bit image, change directory into thebuild64
directory andtypemake
. The result is amt86plus
binary image file which can bebooted directly by a 64-bit UEFI BIOS (if named mt86plus.efi), by a legacyBIOS (in floppy mode) or by an intermediate bootloader using the Linux 16-bitboot protocol. The image can be also booted by an intermediate bootloaderusing the Linux 32-bit, 64-bit, or 64-bit EFI handover boot protocols.
In either case, to build an ISO image that can be used to create a bootableCD, DVD, or USB Flash drive, typemake iso
, The result is amemtest.iso
ISO image file. This can then be written directly to a blank CD or DVD, orto a USB Flash drive, which can then be booted directly by a legacy or UEFIPC BIOS.
Note that when writing to a USB Flash drive, the ISO image must be writtendirectly ('dumped') to the raw device, either by using thedd
command orby using a utility that provides the same functionality.
When using an intermediate bootloader,mt86plus
file should be storedin a disk partition the bootloader can access, and the bootloaderconfiguration should be updated to boot from that file as if it were a Linuxkernel with no initial RAM disk. Several boot command line options arerecognised, as described below. If using the 16-bit boot protocol, Memtest86+will use the display in text mode (640x400). If using the 32-bit or 64-bitboot protocols, Memtest86+ will use the display in either text mode orgraphics mode, as specified in theboot_params
struct passed to it bythe bootloader. If in graphics mode, the supplied framebuffer must beat least 640x400 pixels; if larger, the display will be centred. Ifthe system was booted in UEFI mode, graphics mode must be used.
For test purposes, there is also an option to build an ISO image that usesGRUB as an intermediate bootloader. See theMakefile
in thebuild32
orbuild64
directory for details. The ISO image is both legacy and UEFIbootable, so you need GRUB modules for both legacy and EFI boot installedon your build system (e.g. on Debian, the required GRUB modules are locatedin packagesgrub-pc-bin
,grub-efi-ia32-bin
andgrub-efi-amd64-bin
).You may need to adjust some path and file names in the Makefile to matchthe naming on your system.
The GRUB configuration files contained in thegrub
directory are there foruse on the test ISO, but also serve as an example of how to boot Memtest86+from GRUB.
An intermediate bootloader may pass a boot command line to Memtest86+. Thecommand line may contain one or more options, separated by spaces. Eachoption consists of an option name, optionally followed by an=
sign andone or more parameters, separated by commas. The following options arerecognised:
0x
prefix (eg: 0xFEDC9000)Memtest86+ v6.0 was based on PCMemTest, developed by Martin Whitaker, whichwas based on Memtest86+ v5.01, developed by Samuel Demeulemeester, which inturn was based on Memtest86, developed by Chris Brady with the resources andassistance listed below:
The initial versions of the source files bootsect.S, setup.S, head.S andbuild.c are from the Linux 1.2.1 kernel and have been heavily modified.
Doug Sisk provided code to support a console connected via a serial port.(not currently used)
Code to create BadRAM patterns was provided by Rick van Rein.
The block move test is based on Robert Redelmeier's burnBX test.
Screen buffer code was provided by Jani Averbach.(not used by Memtest86+ v6.0)
Eric Biederman provided all of the feature content for version 3.0plus many bugfixes and significant code cleanup.
Major enhancements to hardware detection and reporting in version 3.2, 3.3and 3.4 provided by Samuel Demeulemeester (from Memtest86+ v1.11, v1.60and v1.70).
In addition, several bug fixes for Memtest86+ were imported fromanphsw/memtest86.
This is the developer's guide to the Memtest86+ source code. The user's guidecan be found in the README.md file in the top level directory.
The source code is divided into the following categories, each contained in asubdirectory of the same name:
app
The main application and framework for running the memory tests.
boot
The code that runs from the BIOS or bootloader entry point to thestart of the main application.
lib
The subset of the C standard library that is used by Memtest86+ plus otherhardware-independent low-level support functions.
system
Low-level support functions that interface to the hardware.
tests
The individual memory tests.
The boot code is mostly written in AT&T syntax x86 assembly language. Theremaining code is written in C with a smattering of inline assembly code.
Each category is further subdivided into multiple source files, splitting thecode into small units of closely related functionality. For the C code, theAPI for each unit is defined in a header (.h
) file and the implementation(if required) is found in the correspondingly named source (.c
) file.
Doxygen can be used to automatically generate HTML documentation for the APIfor each code unit from the comments in the C header files. To regenerate thedocumentation, change directory into thedoc
subdirectory and rundoxygen
.
Macro names and enumeration values are written in upper case separated byunderscores. All other identifiers are written in lower case separated byunderscores. Both excessive length and excessive abbreviation are avoided.
Line length is normally limited to 120 characters.
Indentation is 4 spaces. No hard tab characters are used.
Opening braces for function bodies are put on a new line. Other opening bracesare put on the same line as the construct that introduces them.
The C11 dialect is used. In particular, variable declarations and statementsare interspersed and loop variables are declared within thefor
loopconstruct.
Labels are written in lower case separated by underscores. Op-codes andregister names are written in lower case.
Line length is normally limited to 120 characters.
Indentation is 8 spaces using hard tab characters.
The C preprocessor is used for defining constant values and expressions.Macro names are written in upper case separated by underscores.