From: Heiko Schocher <hs@denx.de>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Enrico Leto <enrico.leto@siemens.com>,
Walter Schweizer <walter.schweizer@siemens.com>,
Alexander Sverdlin <alexander.sverdlin@siemens.com>,
Heiko Schocher <hs@denx.de>, Anatolij Gustschin <agust@denx.de>,
Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: [PATCH v1 20/22] siemens: add ddr full memory test
Date: Fri, 8 Nov 2024 06:21:41 +0100 [thread overview]
Message-ID: <20241108052143.26874-21-hs@denx.de> (raw)
In-Reply-To: <20241108052143.26874-1-hs@denx.de>
Add siemens specific memory test. Enable it through Kconfig option
SPL_CMT.
The test is required from our HW team. It runs over temperature during
many days:
* must run indefinitively through the whole DDR area
* must write/read/check all values
Signed-off-by: Enrico Leto <enrico.leto@siemens.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
---
board/siemens/capricorn/Kconfig | 7 +
board/siemens/capricorn/Makefile | 1 +
board/siemens/capricorn/spl.c | 5 +
board/siemens/capricorn/spl_memory_test.c | 158 ++++++++++++++++++++++
board/siemens/capricorn/spl_memory_test.h | 7 +
5 files changed, 178 insertions(+)
create mode 100644 board/siemens/capricorn/spl_memory_test.c
create mode 100644 board/siemens/capricorn/spl_memory_test.h
diff --git a/board/siemens/capricorn/Kconfig b/board/siemens/capricorn/Kconfig
index 371eca346e0..03a433df2aa 100644
--- a/board/siemens/capricorn/Kconfig
+++ b/board/siemens/capricorn/Kconfig
@@ -14,3 +14,10 @@ config IMX_CONFIG
default "board/siemens/capricorn/imximage.cfg"
endif
+
+
+config SPL_CMT
+ bool "Enable Siemens SPL RAM test"
+ depends on SPL
+ help
+ Enable SIemens SPL RAM test.
diff --git a/board/siemens/capricorn/Makefile b/board/siemens/capricorn/Makefile
index e8a24c448b9..b8350d96d04 100644
--- a/board/siemens/capricorn/Makefile
+++ b/board/siemens/capricorn/Makefile
@@ -8,6 +8,7 @@ obj-y += ../common/eeprom.o
ifdef CONFIG_XPL_BUILD
obj-y += spl.o
+obj-$(CONFIG_SPL_CMT) += spl_memory_test.o
else
obj-y += ../common/factoryset.o
endif
diff --git a/board/siemens/capricorn/spl.c b/board/siemens/capricorn/spl.c
index 7ee2895b6d4..5865cde80b4 100644
--- a/board/siemens/capricorn/spl.c
+++ b/board/siemens/capricorn/spl.c
@@ -20,6 +20,7 @@
#include <asm/arch/iomux.h>
#include <asm/gpio.h>
#include <asm/arch/sys_proto.h>
+#include "spl_memory_test.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -58,6 +59,10 @@ void spl_board_init(void)
preloader_console_init();
puts("Normal Boot\n");
+
+#if IS_ENABLED(CONFIG_SPL_CMT)
+ spl_siemens_memory_full_test();
+#endif
}
void spl_board_prepare_for_boot(void)
diff --git a/board/siemens/capricorn/spl_memory_test.c b/board/siemens/capricorn/spl_memory_test.c
new file mode 100644
index 00000000000..84c97e7853c
--- /dev/null
+++ b/board/siemens/capricorn/spl_memory_test.c
@@ -0,0 +1,158 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright Siemens AG 2020
+ *
+ * SPL Full Memory Test
+ * - memory test through the full DDR area
+ * - refresh over temperature torture (write all, read all)
+ *
+ * Remark:
+ * This test has ran properly with the definition of the RAM sizes in board
+ * headers. Since these headers are removed it's necessary to set the correct
+ * values to PHYS_SDRAM_1_SIZE & PHYS_SDRAM_2_SIZE before to recompile.
+ *
+ * An alternative is to refactor the code to get the size info from system
+ * controller
+ */
+
+#include <init.h>
+#include <log.h>
+
+/* ----- Defines ----- */
+#define CHECK_LOWER_UPPER
+
+#define LEVEL2_PRINT 0x0FFFFFFF
+
+/* use 0x7FFF0000 for shorter loop test */
+#define BASE_OFFSET 0x00000000
+
+/* ----- Types ----- */
+struct ct_t {
+ unsigned long *start;
+ unsigned long *end;
+};
+
+/* ----- Variables ----- */
+static struct ct_t ct;
+static unsigned long error_counter;
+
+static void print_parameters(void)
+{
+ printf("\nstart addr: %p\n", ct.start);
+ printf("end addr : %p\n", ct.end);
+}
+
+static void run_test(void)
+{
+ /* moved full test in one void */
+ unsigned long *address; /* 512 */
+ unsigned long ebyte1;
+ unsigned long ebyte2;
+ unsigned int i;
+ unsigned long rpattern;
+
+ for (i = 0; i <= 255; i++) {
+ memset(&ebyte1, i, sizeof(ebyte1));
+ ebyte2 = ~ebyte1;
+ printf("LWord: %016lx #LWord: %016lx\n", ebyte1, ebyte2);
+
+ /* write all bytes -> duration ~ 150 s */
+ for (address = ct.start; address <= ct.end; address++) {
+#ifdef LEVEL2_PRINT
+ if (((unsigned long)address & LEVEL2_PRINT) == 0)
+ printf("write to %p - %p\n", address,
+ (void *)((unsigned long)address +
+ LEVEL2_PRINT));
+#endif
+ *address = ebyte1;
+ address++;
+ *address = ebyte2;
+ }
+
+ /* check all bytes */
+ for (address = ct.start; address <= ct.end; address++) {
+#ifdef LEVEL2_PRINT
+ if (((unsigned long)address & LEVEL2_PRINT) == 0)
+ printf("check from %p - %p\n", address,
+ (void *)((unsigned long)address +
+ LEVEL2_PRINT));
+#endif
+
+ rpattern = *address;
+ if (rpattern != ebyte1) {
+ error_counter++;
+ printf("Error! Read: %016lX Wrote: %016lX Address: %p\n",
+ rpattern, ebyte1, address);
+ }
+
+ address++;
+ rpattern = *address;
+ if (rpattern != ebyte2) {
+ error_counter++;
+ printf("Error! Read: %016lX Wrote: %016lX Address: %p\n",
+ rpattern, ebyte2, address);
+ }
+ }
+ }
+}
+
+#ifdef CHECK_LOWER_UPPER
+void test_lower_upper(void)
+{
+ /*
+ * write different values at the same address of both memory areas
+ * and check them
+ */
+#define TEST_ADDRESS 0x12345670UL
+#define LOWER_ADDRESS (PHYS_SDRAM_1 + TEST_ADDRESS)
+#define UPPER_ADDRESS (PHYS_SDRAM_2 + TEST_ADDRESS)
+#define LOWER_VALUE 0x0011223344556677
+#define UPPER_VALUE 0x89ab89abffeeddcc
+
+ *(unsigned long *)LOWER_ADDRESS = LOWER_VALUE;
+ *(unsigned long *)UPPER_ADDRESS = UPPER_VALUE;
+
+ puts("\nlower-upper memory area test\n");
+ printf("write %016lx to lower address %010lx\n", LOWER_VALUE,
+ LOWER_ADDRESS);
+ printf("write %016lx to upper address %010lx\n", UPPER_VALUE,
+ UPPER_ADDRESS);
+ printf("read %016lx from lower address %010lx\n",
+ *(unsigned long *)LOWER_ADDRESS, LOWER_ADDRESS);
+ printf("read %016lx from upper address %010lx\n",
+ *(unsigned long *)UPPER_ADDRESS, UPPER_ADDRESS);
+}
+#endif
+
+void spl_siemens_memory_full_test(void)
+{
+ unsigned long loopc = 0;
+
+ puts("\nSPL: memory cell test\n");
+
+#ifdef CHECK_LOWER_UPPER
+ if (PHYS_SDRAM_2_SIZE != 0)
+ test_lower_upper();
+#endif
+
+ while (true) {
+ /* imx8x has 2 memory areas up to 2 GB */
+
+ /* 1st memory area @ 0x80000000 */
+ ct.start = (unsigned long *)(PHYS_SDRAM_1 + BASE_OFFSET);
+ ct.end = (unsigned long *)(PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE - 1);
+ print_parameters();
+ run_test();
+
+ /* 2nd memory area @ 0x880000000 */
+ if (PHYS_SDRAM_2_SIZE != 0) {
+ ct.start = (unsigned long *)(PHYS_SDRAM_2 + BASE_OFFSET);
+ ct.end = (unsigned long *)(PHYS_SDRAM_2 + PHYS_SDRAM_2_SIZE - 1);
+ print_parameters();
+ run_test();
+ }
+
+ loopc++;
+ printf("loop: %ld, errors: %ld\n\n", loopc, error_counter);
+ };
+}
diff --git a/board/siemens/capricorn/spl_memory_test.h b/board/siemens/capricorn/spl_memory_test.h
new file mode 100644
index 00000000000..28df284b6d5
--- /dev/null
+++ b/board/siemens/capricorn/spl_memory_test.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright Siemens AG 2020
+ *
+ */
+
+void spl_siemens_memory_full_test(void);
--
2.20.1
next prev parent reply other threads:[~2024-11-08 5:24 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 5:21 [PATCH v1 00/22] imx8qxp: siemens board: updates / sync with mainline Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 01/22] wdt: imx8qxp: add option to control external PMIC wdt via IMX8 SCU Heiko Schocher
2024-11-08 7:19 ` Stefan Roese
2024-11-08 11:47 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 02/22] net: fec_mxc: fix probing for imx8qxp Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 03/22] tools: imx8image: Improve error message Heiko Schocher
2024-11-11 8:03 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 04/22] imx: imx_cntr_image.sh: prevent warning for missing spl Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 05/22] imx8qxp: Fix build when using SPL Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 06/22] siemens: capricorn: move to cxg3 reference project with deneb board Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 07/22] siemens: imx8qxp-capricorn-u-boot.dtsi: fix boot Heiko Schocher
2024-11-11 8:34 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 08/22] siemens: capricorn: use DCD_SKIP entry Heiko Schocher
2024-11-11 8:35 ` Schweizer, Walter
2024-11-11 8:49 ` Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 09/22] siemens: imximage.cfg: correct comment Heiko Schocher
2024-11-11 8:41 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 10/22] siemens: imximage.cfg: sync image names Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 11/22] siemens: imx8-capricorn-u-boot.dtsi: add fec2 Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 12/22] siemens: capricorn: add missing ARCH_MISC_INIT Heiko Schocher
2024-11-09 12:03 ` Fabio Estevam
2024-11-08 5:21 ` [PATCH v1 13/22] siemens: configs/capricorn_cxg3_defconfig: updates Heiko Schocher
2024-11-09 12:10 ` Fabio Estevam
2024-11-11 10:04 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 14/22] siemens: capricorn: sync spl code with 8qxp-mek Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 15/22] siemens: imx8-capricorn.dtsi: small adaptions Heiko Schocher
2024-11-09 12:03 ` Fabio Estevam
2024-11-11 5:52 ` Heiko Schocher
2024-11-11 8:25 ` Leto, Enrico
2024-11-11 8:47 ` Heiko Schocher
2024-11-11 9:24 ` Leto, Enrico
2024-11-11 12:08 ` Sverdlin, Alexander
2024-11-11 10:36 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 16/22] siemens: capricorn: board.c fixes Heiko Schocher
2024-11-09 16:38 ` Fabio Estevam
2024-11-11 6:01 ` Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 17/22] siemens: capricorn: add HW version information to boot log Heiko Schocher
2024-11-09 12:09 ` Fabio Estevam
2024-11-11 5:57 ` Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 18/22] siemens: capricorn: get ram size from system controller Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 19/22] siemens: capricorn: get module name from eeprom Heiko Schocher
2024-11-08 5:21 ` Heiko Schocher [this message]
2024-11-09 12:06 ` [PATCH v1 20/22] siemens: add ddr full memory test Fabio Estevam
2024-11-11 5:55 ` Heiko Schocher
2024-11-11 8:48 ` Leto, Enrico
2024-11-08 5:21 ` [PATCH v1 21/22] siemens: add ddr signal integrity test Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 22/22] siemens: capricorn: update maintainers Heiko Schocher
2024-11-08 11:51 ` Sverdlin, Alexander
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241108052143.26874-21-hs@denx.de \
--to=hs@denx.de \
--cc=agust@denx.de \
--cc=alexander.sverdlin@siemens.com \
--cc=enrico.leto@siemens.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=walter.schweizer@siemens.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox