commands: import memtester 4.3.0 from Debian GNU/Linux
PATCH v3 1/1 commands: import memtester 4.3.0 from Debian GNU/Linux
Memtester is an utility for testing the memory subsystem for faults. For hardware developers, memtester can be told to test memory starting at a particular physical address.
This port is based on the sources from Debian GNU/Linux. Debian package meta data is as follows:
Package: memtester Version: 4.3.0-5 Homepage: http://pyropus.ca/software/memtester/ APT-Sources: http://ftp.ru.debian.org/debian testing/main amd64 Packages
Dissected version of this patch can be found at
https://github.com/pmamonov/barebox/commits/memtester
Changes since v2:
6fe3d86f9b add prefix to global variables names 81441f8ff8 drop volatile for buf/aligned pointers 336d1ddf5f close memfd if mmap() failed 4b52d3990d define rand32() as random32() 9fa593f130 tests: make global vars static ce00f1aadb fix error handling when parsing arguments 5107cc4b19 don't flush the console
Changes since v1:
1acbafe7a2 init global vars on start 7664692fd4 use proper return value a10eba5b49 use strtoull_suffix() to parse memory size 001b623c16 add option to set TESTMASK 3acfe07d56 make tests[] static
528360ebd7 fix license
--- commands/Kconfig | 8 + commands/Makefile | 1 + commands/memtester/Makefile | 1 + commands/memtester/memtester.c | 275 ++++++++++++++++++ commands/memtester/memtester.h | 21 ++ commands/memtester/sizes.h | 37 +++ commands/memtester/tests.c | 495 +++++++++++++++++++++++++++++++++ commands/memtester/tests.h | 36 +++ commands/memtester/types.h | 35 +++ 9 files changed, 909 insertions(+) create mode 100644 commands/memtester/Makefile create mode 100644 commands/memtester/memtester.c create mode 100644 commands/memtester/memtester.h create mode 100644 commands/memtester/sizes.h create mode 100644 commands/memtester/tests.c create mode 100644 commands/memtester/tests.h create mode 100644 commands/memtester/types.h
commands/Kconfig +8 -0
@@ -1611,6 +1611,14 @@ config CMD_MEMTEST -i ITERATIONS perform number of iterations (default 1, 0 is endless) -b perform only a test on bus lines +config CMD_MEMTESTER + tristate + prompt "memtester" + help + Utility for testing the memory subsystem. + + Homepage: http://pyropus.ca/software/memtester/ + config CMD_MM tristate select DEV_MEM
commands/Makefile +1 -0
@@ -49,6 +49,7 @@ obj-$(CONFIG_CMD_LOADENV) += loadenv.o obj-$(CONFIG_CMD_NAND) += nand.o obj-$(CONFIG_CMD_NANDTEST) += nandtest.o obj-$(CONFIG_CMD_MEMTEST) += memtest.o +obj-$(CONFIG_CMD_MEMTESTER) += memtester/ obj-$(CONFIG_CMD_TRUE) += true.o obj-$(CONFIG_CMD_FALSE) += false.o obj-$(CONFIG_CMD_VERSION) += version.o
commands/memtester/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += tests.o memtester.o
commands/memtester/memtester.c new file +275 -0
275 lines not on this page · raw message
commands/memtester/memtester.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Very simple (yet, for some reason, very effective) memory tester. +* Originally by Simon Kirby <[email protected]> <[email protected]> +* Version 2 by Charles Cazabon <[email protected]> +* Version 3 not publicly released. +* Version 4 rewrite: +* Copyright (C) 2004-2012 Charles Cazabon <[email protected]> +* +* This file contains the declarations for external variables from the main file. +* See other comments in that file. +* +*/ + +#include <types.h> + +/* extern declarations. */ + +extern int memtester_use_phys; +extern off_t memtester_physaddrbase; +
commands/memtester/sizes.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Very simple but very effective user-space memory tester. +* Originally by Simon Kirby <[email protected]> <[email protected]> +* Version 2 by Charles Cazabon <[email protected]> +* Version 3 not publicly released. +* Version 4 rewrite: +* Copyright (C) 2004-2012 Charles Cazabon <[email protected]> +* +* This file contains some macro definitions for handling 32/64 bit platforms. +* +*/ + +#include <linux/limits.h> + +#define rand32 () random32() + +#if defined(CONFIG_32BIT ) +#define rand_ul () rand32() +#define UL_ONEBITS 0xffffffff +#define UL_LEN 32 +#define CHECKERBOARD1 0x55555555 +#define CHECKERBOARD2 0xaaaaaaaa +#define UL_BYTE (x) ((x | x << 8 | x << 16 | x << 24)) +#elif defined(CONFIG_64BIT ) +#define rand64 () (((ul) rand32()) << 32 | ((ul) rand32())) +#define rand_ul () rand64() +#define UL_ONEBITS 0xffffffffffffffffUL +#define UL_LEN 64 +#define CHECKERBOARD1 0x5555555555555555 +#define CHECKERBOARD2 0xaaaaaaaaaaaaaaaa +#define UL_BYTE (x) (((ul)x | (ul)x<<8 | (ul)x<<16 | (ul)x<<24 | (ul)x<<32 | (ul)x<<40 | (ul)x<<48 | (ul)x<<56)) +#else +#error long on this platform is not 32 or 64 bits +#endif + +
commands/memtester/tests.c new file +495 -0
495 lines not on this page · raw message
commands/memtester/tests.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Very simple yet very effective memory tester. +* Originally by Simon Kirby <[email protected]> <[email protected]> +* Version 2 by Charles Cazabon <[email protected]> +* Version 3 not publicly released. +* Version 4 rewrite: +* Copyright (C) 2004-2012 Charles Cazabon <[email protected]> +* +* This file contains the declarations for the functions for the actual tests, +* called from the main routine in memtester.c. See other comments in that +* file. +* +*/ + +/* Function declaration. */ + +int test_stuck_address (unsigned long volatile *bufa,size_t count); +int test_random_value (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_xor_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_sub_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_mul_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_div_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_or_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_and_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_seqinc_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_solidbits_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_checkerboard_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_blockseq_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_walkbits0_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_walkbits1_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_bitspread_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_bitflip_comparison (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_8bit_wide_random (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +int test_16bit_wide_random (unsigned long volatile *bufa,unsigned long volatile *bufb,size_t count); +
commands/memtester/types.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Very simple but very effective user-space memory tester. +* Originally by Simon Kirby <[email protected]> <[email protected]> +* Version 2 by Charles Cazabon <[email protected]> +* Version 3 not publicly released. +* Version 4 rewrite: +* Copyright (C) 2004-2010 Charles Cazabon <[email protected]> +* +* This file contains typedefs, structure, and union definitions. +* +*/ + +#include "sizes.h" + +typedef unsigned long ul ; +typedef unsigned long long ull ; +typedef unsigned long volatile ulv ; +typedef unsigned char volatile u8v ; +typedef unsigned short volatile u16v ; + +struct test { +char *name; +int (*fp)(ulv *,ulv *,size_t ); +}; + +typedef union { +unsigned char bytes[UL_LEN /8 ]; +ul val; +}mword8_t ; + +typedef union { +unsigned short u16s[UL_LEN /16 ]; +ul val; +}mword16_t ;
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Peter,
Quoted 3 lines · Peter Mamonov
Memtester is an utility for testing the memory subsystem for faults. For hardware developers, memtester can be told to test memory starting at a particular physical address.
Applied with some adjustments, thanks
Quoted 12 lines
commands/memtester/sizes.h new file +12
-0+#include <linux/limits.h> + +#define rand32 () random32() + +#if defined(CONFIG_32BIT ) +#define rand_ul () rand32() +#define UL_ONEBITS 0xffffffff +#define UL_LEN 32 +#define CHECKERBOARD1 0x55555555 +#define CHECKERBOARD2 0xaaaaaaaa +#define UL_BYTE (x) ((x | x << 8 | x << 16 | x << 24)) +#elif defined(CONFIG_64BIT )
commands/memtester/sizes.h line 35
Quoted 10 lines
commands/memtester/sizes.h new file +10
-0+#define rand64 () (((ul) rand32()) << 32 | ((ul) rand32())) +#define rand_ul () rand64() +#define UL_ONEBITS 0xffffffffffffffffUL +#define UL_LEN 64 +#define CHECKERBOARD1 0x5555555555555555 +#define CHECKERBOARD2 0xaaaaaaaaaaaaaaaa +#define UL_BYTE (x) (((ul)x | (ul)x<<8 | (ul)x<<16 | (ul)x<<24 | (ul)x<<32 | (ul)x<<40 | (ul)x<<48 | (ul)x<<56)) +#else +#error long on this platform is not 32 or 64 bits +#endif
CONFIG_32BIT is not always set, only CONFIG_64BIT is. I had to change this to
#ifdef CONFIG_64BIT
...
#else
...
#endif
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox