Memory POST Test - Timing

2020-08-10 Thread Brownlie, Lewis
Hello all,

>From everything I have read, the memory POST test runs before U-Boot relocates 
>to RAM.

   For example, README.POST states the following (emphasis added by 
me):

Also, all tests will be discriminated by the moment they run at.
Specifically, the following groups will be singled out:

  1) Tests running before relocating to RAM

 These tests will run immediately after initializing RAM
 as to enable modifying it without taking care of its
 contents. Basically, this group will contain memory tests
 only.

  2) Tests running after relocating to RAM

 These tests will run immediately before entering the main
 loop as to guarantee full hardware initialization.

   Another example, in the U-Boot mailing list archives, in the 
message titled "POST Memory Test Problem," Wolfgang Denk wrote (Dec 22, 2014):

In case it is not obvious: you cannot run a memory test on the memory
you are running from.  You must make sure to run the POST memory test
_before_ relocation to RAM.

However, in trying to get the memory POST test to work myself, I emailed the 
U-Boot mailing list for help (my message was titled "U-Boot Fails w/ Memory 
Test"), and Heinrich replied; part of his reply was:


The test must run *after* relocation. Otherwise we will overwrite U-Boot.

When I tried running the test after relocation, the it worked, whereas it 
didn't before.

Thus, my question is, why did Heinrich say that my test must run after 
relocation, and why did this work; when everything else I've read says it must 
run before relocation?

Thank you,
-Lewis



Re: U-Boot Fails w/ Memory Test

2020-08-07 Thread Brownlie, Lewis
Thank you for your response Heinrich.  I tried running the memory test after 
relocation instead of before and it seems to have worked.  I'm going to debug 
more to make sure it really did, but in the meantime a couple questions:

You wrote:


> Have a look at arch_memory_test_prepare(). The function blindly asks to test 
> and thereby overwrite up to 256 MiB from CONFIG_SYS_SDRAM_BASE to

gd->bd.

>

> The test must run *after* relocation. Otherwise we will overwrite U-Boot.

>

> The end of the memory range tested should be 
> ((uintptr_t)map_sysmem(gd->start_addr_sp, 0) - CONFIG_STACK_SIZE.

>

> All memory areas marked as reserved in the device tree have to be excluded.



  1.  Why does the test run after relocation?  Everything I've seen has said to 
do it before, unless I'm completely misunderstanding.  For example, in 
README.post it states (emphasis added by me):



Also, all tests will be discriminated by the moment they run at.

Specifically, the following groups will be singled out:



  1) Tests running before relocating to RAM



 These tests will run immediately after initializing RAM

 as to enable modifying it without taking care of its

 contents. Basically, this group will contain memory tests

 only.



  2) Tests running after relocating to RAM



 These tests will run immediately before entering the main

 loop as to guarantee full hardware initialization.



  1.  Are you suggesting that I need to make any changes to 
arch_memory_test_prepare()?  Or are you just pointing out that function to show 
that I need to run the test after relocation?  The test seems to be working 
fine now without changing arch_memory_test_prepare(), but I want to make sure.



Thank you again for your time,

-Lewis




U-Boot Fails w/ Memory Test

2020-08-06 Thread Brownlie, Lewis
Hello all,

I am trying to enable memory POST test for my ARM-based processor.  I have 
reached the point where the U-Boot runs the test and it passes.  However, 
U-Boot later hangs after the following lines:

DDR31.9 GiB (DDR4, 64-bit, CL=22, ECC on)
  DDR Controller Interleaving Mode: 256B
  DDR Chip-Select Interleaving Mode: CS0+CS1

My guess is that the memory test is somehow messing something up, even though 
it passes, but I don't know how.  My attempts to debug and figure out the issue 
have led me to discover that the issue occurs in the relocate_code function.  
Other than that, I have not been able to figure anything out.  If I build and 
run U-Boot without the memory test, it works fine, so I know the issue has 
something to do with the test.  (The test is called from the board_init_f 
function.)

Does anyone have any ideas what may be wrong and/or what I could do to find the 
issue?

Thank you
-Lewis



Re: U-Boot POST Memory Test

2020-08-04 Thread Brownlie, Lewis
Thank you for your helpful response Heinrich.  I have a question to further 
clarify the purpose of post_bootmode_get().

You wrote,
> post_bootmode_get() tells you which type of tests should be executed.
> For tests after a watchdog reset it also returns the last executed test."

This makes sense.  So, looking at the following code in post_run (post/post.c):

if (post_bootmode_get() & POST_POWERTEST) {
.
if (last < post_list_size &&
(flags & test_flags[last] & POST_ALWAYS) &&
(flags & test_flags[last] & POST_MEM)) { 


last is initialized to 62 in the first line shown above; thus, the second 
if-branch shown is not entered because 62 is not less than post_list_size 
(which is 1).  last returns the last executed test; however, I am confused 
because this is the first call of post_run(), so I don't know what the "last 
executed test" would be referring to.

Thus, my question is, what "last executed test" is last (and its value of 62) 
representing in this case, and why is it preventing the code from entering the 
shown if-branch?

Thank you again,
-Lewis



U-Boot POST Memory Test

2020-08-03 Thread Brownlie, Lewis
Hello all,

I am working on enabling a POST-based memory test for an ARM-based processor.  
I have defined CONFIG_POST CONFIG_SYS_POST_MEMORY in include/configs/.h; 
I have also defined CONFIG_POST_EXTERNAL_WORD_FUNCS and wrote some external 
word functions.  U-Boot builds with no errors and works on the board; however, 
the memory test is not being run, and I'm trying to figure out why.  Through 
some printf debugging I have determined that board_init_f() and board_init_r() 
are calling post_run(), as it should be (discussed in doc/README.POST).  In 
trying to understand the code and what I can do to make this work, I have 
encountered some questions:


  1.  Since the memory test runs before U-Boot relocates to RAM, the memory 
test should be run during the post_run() call that happens in board_init_f() 
and not board_init_r(), correct?  (I just want to clarify that I am 
understanding that correctly.)



  1.  What is the purpose of post_bootmode_get() (in post/post.c)?


  1.  In post_run() (in post/post.c), I noticed that an unsigned int called 
"last" is declared but never initialized with a value; however, "last" is then 
used as if it were initialized.  Why is it that we can use this variable 
without initializing it, and what is the purpose of this variable?


  1.  Does memory_post_test() (as declared in post/tests.c and defined in 
post/drivers/memory.c) ever get called, and if so, where?


  1.  Ultimately, like I said, I am just trying to make the POST memory test 
work; if anyone has any suggestions as to what I can do to do this it would be 
greatly appreciated.

Thank you,
-Lewis



RE: [External] Re: U-Boot Tests for ARM Architecture

2020-07-22 Thread Brownlie, Lewis
Thank you for your response.

I will have to look into it more to see if I should use the given 
post_word_load() and and post_word_store() functions or if I should define 
CONFIG_POST_EXTERNAL_WORD_FUNCS and create my own functions.  If I end up doing 
the former, I will have to define CONFIG_SYS_POST_WORD_ADDR with a memory 
address as you said; does it matter what address I use?  Can I use any address, 
or are there any I should avoid?

As for UART, I would like to run a loopback test on the board's UART, something 
similar to uart_post_test() in drivers/serial/serial.c.  From what I can tell 
from reading test/py/README.md, the tests in test/py are for testing U-Boot 
itself and not the board, which is not what I want.  I apologize for not making 
that more clear.

Thanks again,

-Lewis 

-Original Message-
From: Heinrich Schuchardt  
Sent: Wednesday, July 22, 2020 12:08 PM
To: Brownlie, Lewis ; u-boot@lists.denx.de
Subject: [External] Re: U-Boot Tests for ARM Architecture

On 22.07.20 00:28, Brownlie, Lewis wrote:
> Hello all,
>
> I am fairly new to U-Boot, and I want to perform memory and UART tests 
> on the ARM-based NXP LX2160A Reference Design Board using U-Boot.  In 
> doing research I discovered the POST tests, but it seems that these 
> are intended for MPC823E-based boards.  Is it possible/feasible to use 
> POST to perform my tests, or is there a better way?  (I am aware of 
> the mtest command for memory but I would like to find something 
> better, plus this doesn't help with UART.)
>
>
> I have done a little work on the POST code, so if using POST is a viable 
> option, here are some questions I have regarding it:
>
> If I #define CONFIG_POST in include/configs/lx2160ardb.h and build U-Boot, I 
> receive errors that _POST_WORD_ADDR is not defined.  In looking at 
> include/post.h, it appears that to fix this I must have 
> CONFIG_SYS_POST_WORD_ADDR defined in lx2160ardb.h with some value.  If I 
> #define CONFIG_SYS_POST_WORD_ADDR 0x10 in lx2160ardb.h, where 0x10 is just 
> some dummy value, U-Boot builds with no errors, but like I said it's just a 
> dummy value and I know it can't be used.  I don't know what exactly 
> _POST_WORD_ADDR and CONFIG_SYS_POST_WORD_ADDR do or what value I should use.  
> Am I going about this in the right way, and if so where should I get the 
> value to use for CONFIG_SYS_POST_WORD_ADDR?
>
> FWIW, this piece of code found in include/post.h is what I'm mainly looking 
> at:
>
> #ifndef CONFIG_POST_EXTERNAL_WORD_FUNCS #ifdef 
> CONFIG_SYS_POST_WORD_ADDR
> #define _POST_WORD_ADDR  CONFIG_SYS_POST_WORD_ADDR
> #else
>
> #if defined(CONFIG_ARCH_MPC8360)
> #include 
> #define _POST_WORD_ADDR  (CONFIG_SYS_IMMR + CPM_POST_WORD_ADDR)
>
> #elif defined (CONFIG_MPC85xx)
> #include 
> #define _POST_WORD_ADDR  (CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_PIC_OFFSET 
> + \
> 
> offsetof(ccsr_pic_t, tfrr))
>
> #elif defined (CONFIG_MPC86xx)
> #include 
> #define _POST_WORD_ADDR  (CONFIG_SYS_IMMR + CONFIG_SYS_MPC86xx_PIC_OFFSET 
> + \
> 
> offsetof(ccsr_pic_t, tfrr)) #endif
>
> #ifndef _POST_WORD_ADDR
> #error "_POST_WORD_ADDR currently not implemented for this platform!"
> #endif
> #endif /* CONFIG_SYS_POST_WORD_ADDR */
>
>
> Thank you :)
>
> -Lewis
>

post/drivers/memory.c looks rather generic so reusing it should be feasible.

post_word_load() and and post_word_store() retrieve and save a bitmask with 
bits like POST_POWERDOWN that define what test should be run.

If CONFIG_POST_EXTERNAL_WORD_FUNCS is not defined CONFIG_SYS_POST_WORD_ADDR 
defines a memory address that serves for saving the bitmask. This should work 
fine if you have static RAM.

If you do not want to use a memory location for communication, you can define 
your own post_word_load() and and post_word_store() functions. In this case you 
need to define CONFIG_POST_EXTERNAL_WORD_FUNCS.

Concerning UART testing I am wondering if you mean the UART with the console? 
What specifically do you want to test?

In test/py there are a lot of tests that you cat run on your board while 
communicating over the UART. Do you really need a UART specific test?
See test/py/README.md.

Best regards

Heinrich


U-Boot Tests for ARM Architecture

2020-07-22 Thread Brownlie, Lewis
Hello all,

I am fairly new to U-Boot, and I want to perform memory and UART tests on the 
ARM-based NXP LX2160A Reference Design Board using U-Boot.  In doing research I 
discovered the POST tests, but it seems that these are intended for 
MPC823E-based boards.  Is it possible/feasible to use POST to perform my tests, 
or is there a better way?  (I am aware of the mtest command for memory but I 
would like to find something better, plus this doesn't help with UART.)


I have done a little work on the POST code, so if using POST is a viable 
option, here are some questions I have regarding it:

If I #define CONFIG_POST in include/configs/lx2160ardb.h and build U-Boot, I 
receive errors that _POST_WORD_ADDR is not defined.  In looking at 
include/post.h, it appears that to fix this I must have 
CONFIG_SYS_POST_WORD_ADDR defined in lx2160ardb.h with some value.  If I 
#define CONFIG_SYS_POST_WORD_ADDR 0x10 in lx2160ardb.h, where 0x10 is just some 
dummy value, U-Boot builds with no errors, but like I said it's just a dummy 
value and I know it can't be used.  I don't know what exactly _POST_WORD_ADDR 
and CONFIG_SYS_POST_WORD_ADDR do or what value I should use.  Am I going about 
this in the right way, and if so where should I get the value to use for 
CONFIG_SYS_POST_WORD_ADDR?

FWIW, this piece of code found in include/post.h is what I'm mainly looking at:

#ifndef CONFIG_POST_EXTERNAL_WORD_FUNCS
#ifdef CONFIG_SYS_POST_WORD_ADDR
#define _POST_WORD_ADDR  CONFIG_SYS_POST_WORD_ADDR
#else

#if defined(CONFIG_ARCH_MPC8360)
#include 
#define _POST_WORD_ADDR  (CONFIG_SYS_IMMR + CPM_POST_WORD_ADDR)

#elif defined (CONFIG_MPC85xx)
#include 
#define _POST_WORD_ADDR  (CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_PIC_OFFSET + 
\

offsetof(ccsr_pic_t, tfrr))

#elif defined (CONFIG_MPC86xx)
#include 
#define _POST_WORD_ADDR  (CONFIG_SYS_IMMR + CONFIG_SYS_MPC86xx_PIC_OFFSET + 
\

offsetof(ccsr_pic_t, tfrr))
#endif

#ifndef _POST_WORD_ADDR
#error "_POST_WORD_ADDR currently not implemented for this platform!"
#endif
#endif /* CONFIG_SYS_POST_WORD_ADDR */


Thank you :)

-Lewis