Commit bf08dcac authored by Benoit Rat's avatar Benoit Rat

g45memtest: correct ddr and boot bug & improve the test

parent b997eee6
No preview for this file type
From f87ac48aaf4ec7726391b87577fceede1b561228 Mon Sep 17 00:00:00 2001
From 6c56f4f07d953d33a90584dd15360f8d572483a4 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Thu, 15 Sep 2011 23:41:14 +0200
Subject: [PATCH 1/6] board 9g45ek: fix ddr config for WRS-V3
Subject: [PATCH 01/19] board 9g45ek: fix ddr config for WRS-V3
---
board/at91sam9g45ek/at91sam9g45ek.c | 2 +-
......@@ -81,5 +81,5 @@ index 550aea4..a4a168f 100644
#define AT91C_DDRC2_NR_12 (0x1 << 2) // (HDDRSDRC2) 12 Bits
#define AT91C_DDRC2_NR_13 (0x2 << 2) // (HDDRSDRC2) 13 Bits
--
1.7.7.2
1.7.9.5
From c27eea873f4a7dd9bea3da51b8e4aba27b9e52fc Mon Sep 17 00:00:00 2001
From b257bbfacdfa9475ca0a812a64d6ab59de9ea440 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 10:18:59 +0100
Subject: [PATCH 2/6] printf: added files from pptp, unchanged
Subject: [PATCH 02/19] printf: added files from pptp, unchanged
---
lib/diag-printf.c | 34 ++++++++++++++++++++++++++
lib/printf-mini.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+), 0 deletions(-)
2 files changed, 103 insertions(+)
create mode 100644 lib/diag-printf.c
create mode 100644 lib/printf-mini.c
......@@ -126,5 +126,5 @@ index 0000000..d68c848
+ return str - buf;
+}
--
1.7.7.2
1.7.9.5
From 3ebc7c415750ffcd7cf4241010027773609e6919 Mon Sep 17 00:00:00 2001
From dc2e9ac1fcca99e6c4924714f26cf85a87e3259c Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 10:37:27 +0100
Subject: [PATCH 3/6] printf: fixes and addition to makefile
Subject: [PATCH 03/19] printf: fixes and addition to makefile
---
include/pp_printf.h | 9 +++++++++
......@@ -78,5 +78,5 @@ index 2a46204..8810324 100644
#include "main.h"
#include "dbgu.h"
--
1.7.7.2
1.7.9.5
From 391890df3ca410003b51bf45a4b17a5a8e22a588 Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Fri, 23 Mar 2012 13:42:57 +0100
Subject: [PATCH 04/19] version: add tmpconfig to ignore list
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index d78652e..a973a59 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@ binaries
*.o
tags
*.swp
+.tmpconfig*
--
1.7.9.5
From c28fc11363fb86c25b447817a6554874ad65f09a Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Wed, 28 Mar 2012 18:54:06 +0200
Subject: [PATCH 05/19] version: Improve tracking bin versions adding git
version in Makefile
---
.gitignore | 1 +
Makefile | 25 ++++++++++++++++++++++++-
main.c | 6 ++++++
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index a973a59..8b91fe5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@ binaries
tags
*.swp
.tmpconfig*
+version.c
diff --git a/Makefile b/Makefile
index 6216632..c61ee3e 100644
--- a/Makefile
+++ b/Makefile
@@ -220,7 +220,7 @@ include driver/driver.mk
SRCS := $(COBJS-y:.o=.c)
-OBJS := $(SOBJS-y) $(COBJS-y)
+OBJS := $(SOBJS-y) $(COBJS-y) version.o
INCL=board/$(BOARD)
@@ -273,6 +273,29 @@ PHONY:=all gen_bin
all: PrintFlags gen_bin ChkFileSize
+## If not git is found
+ifeq ($(shell git status -s | grep -v "fatal*"),)
+version.c: $(SOBJS-y) $(COBJS-y)
+ @echo "/**" > $@
+ @echo " * File automatically generated by Makefile (DO NOT MODIFIED)\n *\n * To use this you in a c code just add the following lines:\n * " >> $@
+ @echo "\textern const char build_time[];\n\textern const char git_user[];\n\textren const char git_revision[];\n * " >> $@
+ @echo "**/" >> $@
+ @echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
+ @echo "const char git_user[] = \"$(shell id -nu)\";" >> $@
+ @echo "const char git_revision[] = \"\";" >> $@
+ @echo "" >> $@
+else
+version.c: $(SOBJS-y) $(COBJS-y) .git/HEAD .git/index
+ @echo "/**" > $@
+ @echo " * File automatically generated by Makefile (DO NOT MODIFIED)\n *\n * To use this you in a c code just add the following lines:\n * " >> $@
+ @echo "\textern const char build_time[];\n\textern const char git_user[];\n\textren const char git_revision[];\n * " >> $@
+ @echo "**/" >> $@
+ @echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
+ @echo "const char git_user[] = \"$(shell git config --get user.name)\";" >> $@
+ @echo "const char git_revision[] = \"$(shell git rev-parse HEAD)$(shell if git status -s > /dev/null; then echo '+'; fi;)\";" >> $@
+ @echo "" >> $@
+endif
+
PrintFlags:
@echo as FLAGS
@echo ========
diff --git a/main.c b/main.c
index 8810324..0ea1716 100644
--- a/main.c
+++ b/main.c
@@ -83,6 +83,10 @@ void Wait(unsigned int count)
/*------------------------------------------------------------------------------*/
int main(void)
{
+ extern const char build_time[];
+ extern const char git_user[];
+ extern const char git_revision[];
+
/*
* ================== 1st step: Hardware Initialization =================
*
@@ -92,6 +96,8 @@ int main(void)
hw_init();
#endif
+ pp_printf("Compiled by %s (%s)\r\ngit rev:%s\r\n\r\n",git_user,build_time,git_revision);
+
#ifdef CONFIG_USER_HW_INIT
user_hw_init();
#endif
--
1.7.9.5
From 4a94ffdd4e78d50d24669f2646b3648bc93a51c4 Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Wed, 28 Mar 2012 19:19:46 +0200
Subject: [PATCH 06/19] leds: Correct FPGA LED problems, and add CPU LED
during booting
---
board/at91sam9g45ek/at91sam9g45ek.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/board/at91sam9g45ek/at91sam9g45ek.c b/board/at91sam9g45ek/at91sam9g45ek.c
index 8569231..83c2c29 100644
--- a/board/at91sam9g45ek/at91sam9g45ek.c
+++ b/board/at91sam9g45ek/at91sam9g45ek.c
@@ -80,6 +80,17 @@ void hw_init(void)
};
/*
+ * Configure LED GPIOs
+ */
+ const struct pio_desc led_gpio[] = {
+ {"D11", AT91C_PIN_PA(0), 0, PIO_OPENDRAIN, PIO_OUTPUT}, //Switch on D11 when booting start.
+ {"D12", AT91C_PIN_PA(1), 1, PIO_OPENDRAIN, PIO_OUTPUT}, //Setup D12 such to use when the programs end loading.
+ {"DDone", AT91C_PIN_PA(2), 0, PIO_DEFAULT, PIO_INPUT}, //Setup FPGA LED Done in read mode
+ {"DInit", AT91C_PIN_PA(3), 0, PIO_DEFAULT, PIO_INPUT} //Setup FPGA LED Init in read mode
+ };
+ pio_setup(led_gpio);
+
+ /*
* Disable watchdog
*/
writel(AT91C_WDTC_WDDIS, AT91C_BASE_WDTC + WDTC_WDMR);
--
1.7.9.5
From 3c96273023f759800c3cb3309ac1ef8a83fe7f04 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 10 Apr 2012 13:00:22 +0200
Subject: [PATCH 08/19] boot: disable watchdog asap
---
crt0_gnu.S | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/crt0_gnu.S b/crt0_gnu.S
index c00b717..0a9079b 100644
--- a/crt0_gnu.S
+++ b/crt0_gnu.S
@@ -105,6 +105,11 @@ _relocate_to_sram:
ldr pc, =_setup_clocks
#endif /* CONFIG_FLASH */
+ /* disable watchdog */
+ ldr r1, =0xFFFFFD44
+ mov r2, #0x00008000
+ str r2, [r1]
+
ldr r4, = lowlevel_clock_init
mov lr, pc
bx r4
--
1.7.9.5
From a6f38ea81c99fca8ad2c67b0b03d97c16fe97d94 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 10 Apr 2012 13:04:09 +0200
Subject: [PATCH 09/19] boot: added flip_leds(count) in assembler
---
crt0_gnu.S | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/crt0_gnu.S b/crt0_gnu.S
index 0a9079b..784c9ce 100644
--- a/crt0_gnu.S
+++ b/crt0_gnu.S
@@ -74,6 +74,35 @@ irq_vector:
b irq_vector
fiq_vector:
b fiq_vector
+
+/*
+ * First of all, write a procedure, that can be called from C or asm,
+ * to flip leds a number of times, after a small delay
+ */
+
+flip_leds: /* input: r0 is the count of flips */
+
+ /* a delay */
+ ldr r1, =200
+1: subs r1, r1, #1
+ bne 1b
+
+ ldr r1, =0xfffff200 /* PIOA */
+ mov r2, #3 /* bit 0 and 1: both leds */
+
+ str r2, [r1] /* enable */
+ str r2, [r1, #0x10] /* output enable */
+ cmp r0, #0
+ beq 2f
+0: str r2, [r1, #0x34] /* output clear (led on) */
+ str r2, [r1, #0x30] /* output set (led off) */
+ subs r0, r0, #1
+ bne 0b
+
+2: bx lr
+
+.ltorg
+
reset_vector:
/* Init the stack */
--
1.7.9.5
From b24256ae1eab66b12e361dc0e7873d081275ac24 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 10 Apr 2012 13:40:59 +0200
Subject: [PATCH 10/19] boot: Run a test pattern between clock configuration
---
crt0_gnu.S | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/crt0_gnu.S b/crt0_gnu.S
index 784c9ce..bc54989 100644
--- a/crt0_gnu.S
+++ b/crt0_gnu.S
@@ -79,7 +79,6 @@ fiq_vector:
* First of all, write a procedure, that can be called from C or asm,
* to flip leds a number of times, after a small delay
*/
-
flip_leds: /* input: r0 is the count of flips */
/* a delay */
@@ -139,10 +138,20 @@ _relocate_to_sram:
mov r2, #0x00008000
str r2, [r1]
+ /* test 4x the flip_leds procedure */
+ mov r0, #0x4
+ bl flip_leds
+
+ /* Call the lowlevel clock init function in ./driver/pmc.c */
ldr r4, = lowlevel_clock_init
mov lr, pc
bx r4
+ /* test 8x the flip_leds procedure */
+ mov r0, #0x8
+ bl flip_leds
+
+
#if 0
_setup_clocks:
/* Test if main oscillator is enabled */
--
1.7.9.5
From 00b15b66a2bde319a0e4ba592a26f921d542cfca Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Wed, 11 Apr 2012 17:25:28 +0200
Subject: [PATCH 11/19] boot: Correct crash due to an Atmel bug during boot
when PLL clock is already used as master clock
---
driver/pmc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/driver/pmc.c b/driver/pmc.c
index 1a09b9c..189d1c9 100644
--- a/driver/pmc.c
+++ b/driver/pmc.c
@@ -96,7 +96,7 @@ void lowlevel_clock_init()
/*
* After stablization, switch to 12MHz Main Oscillator
*/
- if ((read_pmc(PMC_MCKR) & AT91C_PMC_CSS) != AT91C_PMC_CSS_SLOW_CLK) {
+ if ((read_pmc(PMC_MCKR) & AT91C_PMC_CSS) == AT91C_PMC_CSS_SLOW_CLK) {
write_pmc(PMC_MCKR, AT91C_PMC_CSS_MAIN_CLK | AT91C_PMC_PRES_CLK);
while (!(read_pmc(PMC_SR) & AT91C_PMC_MCKRDY))
;
--
1.7.9.5
From 8083ba2049c07ce9f939819ce3016912d256019f Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Wed, 11 Apr 2012 17:25:28 +0200
Subject: [PATCH 12/19] Improve makefile to only take the gitversion of
current directory
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index c61ee3e..fd7f16e 100644
--- a/Makefile
+++ b/Makefile
@@ -292,7 +292,7 @@ version.c: $(SOBJS-y) $(COBJS-y) .git/HEAD .git/index
@echo "**/" >> $@
@echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
@echo "const char git_user[] = \"$(shell git config --get user.name)\";" >> $@
- @echo "const char git_revision[] = \"$(shell git rev-parse HEAD)$(shell if git status -s > /dev/null; then echo '+'; fi;)\";" >> $@
+ @echo "const char git_revision[] = \"$(shell git log --abbrev-commit --pretty=oneline -1 . | cut -d" " -f1)$(shell if git status -s > /dev/null; then echo '+'; fi;)\";" >> $@
@echo "" >> $@
endif
--
1.7.9.5
From eaa9bd4511b69b6097726b68957fa7da5a44323f Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Fri, 11 May 2012 12:36:25 +0200
Subject: [PATCH 13/19] add simple script to compile for DF and NF
---
build.sh | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100755 build.sh
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..a9711d9
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+showhelp()
+{
+ echo "Usage: $0 [options]"
+ echo "options:"
+ echo " --help: show this little help"
+ echo " --df: compile only for dataflash"
+ echo " --nf: compile only for nandflash"
+}
+
+
+
+case "$1" in
+ --help) showhelp;;
+ --nf) yes "" | make at91sam9g45nf_defconfig > /dev/null; make;;
+ --df) yes "" | make at91sam9g45df_defconfig > /dev/null; make;;
+ *) yes "" | make at91sam9g45df_defconfig > /dev/null; make; yes "" | make at91sam9g45nf_defconfig > /dev/null; make;;
+esac
+
+
--
1.7.9.5
From 5006567aeb801664a861ffe05337943c89dcae60 Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Fri, 11 May 2012 12:48:13 +0200
Subject: [PATCH 14/19] Correct a bug in makefile
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index fd7f16e..88dfffc 100644
--- a/Makefile
+++ b/Makefile
@@ -285,14 +285,14 @@ version.c: $(SOBJS-y) $(COBJS-y)
@echo "const char git_revision[] = \"\";" >> $@
@echo "" >> $@
else
-version.c: $(SOBJS-y) $(COBJS-y) .git/HEAD .git/index
+version.c: $(SOBJS-y) $(COBJS-y) .git/HEAD .git/index Makefile
@echo "/**" > $@
@echo " * File automatically generated by Makefile (DO NOT MODIFIED)\n *\n * To use this you in a c code just add the following lines:\n * " >> $@
@echo "\textern const char build_time[];\n\textern const char git_user[];\n\textren const char git_revision[];\n * " >> $@
@echo "**/" >> $@
@echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
@echo "const char git_user[] = \"$(shell git config --get user.name)\";" >> $@
- @echo "const char git_revision[] = \"$(shell git log --abbrev-commit --pretty=oneline -1 . | cut -d" " -f1)$(shell if git status -s > /dev/null; then echo '+'; fi;)\";" >> $@
+ @echo "const char git_revision[] = \"$(shell git log --abbrev-commit --pretty=oneline -1 . | cut -d" " -f1)$(shell if git status -s > /dev/null; then echo '+'; else echo ''; fi;)\";" >> $@
@echo "" >> $@
endif
--
1.7.9.5
From 425ef2fa1550b9e480167f8b125adb897f281798 Mon Sep 17 00:00:00 2001
From 80b81d783772a87000356f126cb47dc429a95f3d Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 10:42:17 +0100
Subject: [PATCH 4/6] memtest.c: copied from barebox (our version)
Subject: [PATCH 15/19] memtest: copied from barebox (our version)
---
lib/memtest.c | 355 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 355 insertions(+), 0 deletions(-)
1 file changed, 355 insertions(+)
create mode 100644 lib/memtest.c
diff --git a/lib/memtest.c b/lib/memtest.c
......@@ -370,5 +370,5 @@ index 0000000..d9c8b3d
+BAREBOX_CMD_END
+
--
1.7.7.2
1.7.9.5
From 74e27efd703fbafab08c28c7f7d0eb1aaae7db8e Mon Sep 17 00:00:00 2001
From fa3b681d37c9787473f4ed8fc33205471696db8d Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 11:38:53 +0100
Subject: [PATCH 5/6] memtest: fix it and add to makefile
Subject: [PATCH 16/19] memtest: fix it and add to makefile
---
lib/libc.mk | 1 +
lib/memtest.c | 85 +++++++++++++++++++++++---------------------------------
lib/memtest.c | 85 ++++++++++++++++++++++++---------------------------------
2 files changed, 36 insertions(+), 50 deletions(-)
diff --git a/lib/libc.mk b/lib/libc.mk
......@@ -191,5 +191,5 @@ index d9c8b3d..52542c9 100644
-BAREBOX_CMD_END
-
--
1.7.7.2
1.7.9.5
From cf60a3a806e75315e39610d40607d76efcc5816c Mon Sep 17 00:00:00 2001
From 5f895df9f30230375cbbf2320a7c8af00d852fc2 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 11:39:13 +0100
Subject: [PATCH 6/6] main: call memtest
Subject: [PATCH 17/19] main: call memtest
---
main.c | 92 +++-------------------------------------------------------------
1 files changed, 4 insertions(+), 88 deletions(-)
main.c | 93 ++++------------------------------------------------------------
1 file changed, 5 insertions(+), 88 deletions(-)
diff --git a/main.c b/main.c
index 8810324..e4a6956 100644
index 0ea1716..60f3fe7 100644
--- a/main.c
+++ b/main.c
@@ -83,6 +83,7 @@ void Wait(unsigned int count)
/*------------------------------------------------------------------------------*/
int main(void)
{
+ extern void mem_test(unsigned long ini, unsigned long end);
@@ -86,6 +86,8 @@ int main(void)
extern const char build_time[];
extern const char git_user[];
extern const char git_revision[];
+
+ extern void mem_test(unsigned long ini, unsigned long end);
/*
* ================== 1st step: Hardware Initialization =================
*
@@ -101,92 +102,7 @@ int main(void)
@@ -107,92 +109,7 @@ int main(void)
load_1wire_info();
#endif
......@@ -116,5 +117,5 @@ index 8810324..e4a6956 100644
+ return 0; /* not reached */
}
--
1.7.7.2
1.7.9.5
From 78f344309e4fa491efd1240f481d15c00f6d47b2 Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Mon, 2 Apr 2012 15:43:17 +0200
Subject: [PATCH 19/19] memtest: Add CPU LED switching to memtest
---
lib/memtest.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/memtest.c b/lib/memtest.c
index 4366171..20c5e45 100644
--- a/lib/memtest.c
+++ b/lib/memtest.c
@@ -26,6 +26,7 @@
#include <pp_printf.h>
#include <dbgu.h>
#include <debug.h>
+#include <gpio.h>
//#include <stdlib.h>
/* BEGIN HACKS - to compile barebox code out of barebox */
@@ -120,6 +121,8 @@ int mem_test_integrity(ulong _start, ulong _end, ulong pattern)
//Increment actual read value and decrement write value.
val += incr;
val_next -= incr;
+
+ if((*addr % (1024*100)) == 0) pio_set_value(AT91C_PIN_PA(0),*addr % (2048*100)); //Blinking light while testing
}
printf("\tOK\r\n");
@@ -401,6 +404,10 @@ int mem_test(ulong _start, ulong _end, ulong pattern_unused)
printf ("OK: bus line, address line and integrity are OK\n\r\n\r");
printf ("Now it will continue to check integrity with various patterns. (Ctrl+C to exit)...\n\r");
+ pio_set_value(AT91C_PIN_PA(0),1);
+ pio_set_value(AT91C_PIN_PA(1),0);
+
+
return mem_test_integrity(_start,_end,pattern_unused);
}
--
1.7.9.5
G45 memtest
============
The test is inspired from the one in barebox
It has been improved[^1] and now check:
* Data lines
* Address lines
* Memory integrity
* holding counters
* holding anti-counters
* Random patterns
You can find the source on my github: https://github.com/neub/wrs-sw-at91bootstrap/tree/memtest
[^1]: http://www.barrgroup.com/Embedded-Systems/How-To/Memory-Test-Suite-C
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment