[PATCH 5/6] common: add mem_test routine

Alexander Aring alex.aring at gmail.com
Thu Feb 7 06:40:32 EST 2013


Hi Sascha,

On Thu, Feb 07, 2013 at 12:00:48PM +0100, Sascha Hauer wrote:
> On Thu, Feb 07, 2013 at 11:44:59AM +0100, Alexander Aring wrote:
> > Useful to detect timing problems if someone porting a new
> > device to barebox.
> > 
> > This test includes a data bus test, address bus test and
> > integrity check of memory.
> > 
> > Allocated barebox regions between start and end will skip
> > automatically.
> > 
> > Signed-off-by: Alexander Aring <alex.aring at gmail.com>
> > ---
> >  common/Kconfig        |   7 +
> >  common/Makefile       |   1 +
> >  common/memory_test.c  | 399 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  include/memory_test.h |  13 ++
> >  4 files changed, 420 insertions(+)
> >  create mode 100644 common/memory_test.c
> >  create mode 100644 include/memory_test.h
> > 
> > diff --git a/common/Kconfig b/common/Kconfig
> > index 3f6c11e..c6988df 100644
> > --- a/common/Kconfig
> > +++ b/common/Kconfig
> > @@ -100,6 +100,13 @@ config MEMINFO
> >  	bool "display memory info"
> >  	default y
> >  
> > +config MEMTEST
> > +	bool "Offers routines for memory test"
> > +	help
> > +	  Offers memtest routines in common/memory_test.c
> > +	  This is helpful for porting devices to detect
> > +	  memory timing problems.
> > +
> >  config ENVIRONMENT_VARIABLES
> >  	bool "environment variables support"
> >  
> > diff --git a/common/Makefile b/common/Makefile
> > index 7206eed..684953c 100644
> > --- a/common/Makefile
> > +++ b/common/Makefile
> > @@ -17,6 +17,7 @@ obj-$(CONFIG_MALLOC_DLMALLOC) += dlmalloc.o
> >  obj-$(CONFIG_MALLOC_TLSF) += tlsf_malloc.o
> >  obj-$(CONFIG_MALLOC_TLSF) += tlsf.o
> >  obj-$(CONFIG_MALLOC_DUMMY) += dummy_malloc.o
> > +obj-$(CONFIG_MEMTEST) += memory_test.o
> >  obj-y += clock.o
> >  obj-$(CONFIG_BANNER) += version.o
> >  obj-$(CONFIG_MEMINFO) += meminfo.o
> > diff --git a/common/memory_test.c b/common/memory_test.c
> > new file mode 100644
> > index 0000000..80b4ff4
> > --- /dev/null
> > +++ b/common/memory_test.c
> > @@ -0,0 +1,399 @@
> > +/*
> > + * memory_test.c
> > + *
> > + * Copyright (c) 2013 Alexander Aring <aar at pengutronix.de>, Pengutronix
> > + *
> > + * See file CREDITS for list of people who contributed to this
> > + * project.
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2
> > + * as published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + */
> > +
> > +#include <memory_test.h>
> > +
> > +static const vu_long bitpattern[] = {
> > +	0x00000001,	/* single bit */
> > +	0x00000003,	/* two adjacent bits */
> > +	0x00000007,	/* three adjacent bits */
> > +	0x0000000F,	/* four adjacent bits */
> > +	0x00000005,	/* two non-adjacent bits */
> > +	0x00000015,	/* three non-adjacent bits */
> > +	0x00000055,	/* four non-adjacent bits */
> > +	0xAAAAAAAA,	/* alternating 1/0 */
> > +};
> > +
> > +/*
> > + * Perform a memory test. The complete test
> > + * loops until interrupted by ctrl-c.
> > + *
> > + * Highly recommended to test with disabled and
> > + * enabled cache.
> > + *
> > + * start: start address
> > + * end: end address
> > + * bus_only: skip integrity check
> > + */
> > +int mem_test(vu_long _start, vu_long _end,
> > +		int bus_only)
> > +{
> 
> I thought we agreed on using request_sdram_region here and drop the
> address_in_sdram_regions in this function.
> 

I don't know what you meant :-(
Sorry.

You want that I am checking if a region is already requested.
In that case request_sdram_region will return NULL. Then I know it isn't
a barebox region.
That's ok until integrity check.
This will check 4-bytewise if this is a reqyested region and if not it
will create them.
I can do this, but this will result a long list of requested regions.

A nice solution is to handle it in the function which enable and disable
caching. There I can request a big area of free memory.
I need to request free regions there and call mem_test function for that.

I will try that out.

Regards
Alex



More information about the barebox mailing list