All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot-Users] Re: Some puzzles on dram_size()
@ 2004-01-06 16:28 chris at nanometrics.ca
  2004-01-06 17:27 ` Wolfgang Denk
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: chris at nanometrics.ca @ 2004-01-06 16:28 UTC (permalink / raw)
  To: u-boot

Hi Sam,

Your problem with dram_size() may be that it tests memory
beyond the maxsize given.

     for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) {
          addr = base + cnt;  /* pointer arith! */

          save[i++] = *addr;
          *addr = ~cnt;
     }

If maxsize = 16M, initial cnt = 4M, so if base = 0,
the first time through the loop, addr = 16M which is
the first address outside of the memory range given
to test.

The reason it usually works is that most boards make the
AM (address mask) in the OR (option register) of the memory
controller specify more memory than they actually need.

This may be the easy way to fix it, however I would say the correct
way would be to change the lines
     for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) {
     for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) {
to
     for (cnt = maxsize / sizeof (long) / 2; cnt > 0; cnt >>= 1) {
     for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {

Unfortunately it appears in many board specific versions.

While I'm@it, the entire function should be moved to a file in
the common directory and the function definition changed to
     long int dram_size (long int *base, long int maxsize)

The setting of the MxMR (memory A/B mode register) has nothing
to do with determining the DRAM size and should be done in the
calling function which is board specific.

I know, I'm free to submit a patch, but I'm a combination of
busy and lazy.

Chris

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot-Users] Re: Some puzzles on dram_size()
  2004-01-06 16:28 [U-Boot-Users] Re: Some puzzles on dram_size() chris at nanometrics.ca
@ 2004-01-06 17:27 ` Wolfgang Denk
  2004-01-07 15:59   ` SAM SONG
  2004-01-06 23:08 ` Wolfgang Denk
  2004-01-07 15:16 ` [U-Boot-Users] " SAM SONG
  2 siblings, 1 reply; 10+ messages in thread
From: Wolfgang Denk @ 2004-01-06 17:27 UTC (permalink / raw)
  To: u-boot

Hi Chris,

in message <OF5B21F0A5.A3EF40B7-ON85256E13.0056838C@nanometrics.ca> you wrote:
> 
> Your problem with dram_size() may be that it tests memory
> beyond the maxsize given.

No. His max value as defined in the board config file was 64 MB, with
an actual 16 MB of RAM. Accesses at 64 MB and 32 MB  (=  non-existend
addresses)  worked,  but  when  accessing  existing  RAM  at 16 MB he
crashed.

> The reason it usually works is that most boards make the
> AM (address mask) in the OR (option register) of the memory
> controller specify more memory than they actually need.

Let's put this right: the board config file  is  required  to  define
SDRAM_MAX_SIZE  greater  than or equal to the maximum RAM size of the
system.

> This may be the easy way to fix it, however I would say the correct
> way would be to change the lines

This is not how the memory sizing algorithm is intended to work.

> Unfortunately it appears in many board specific versions.

Not much longer. I will clean this up within the next few  hours  (or
days).

> While I'm at it, the entire function should be moved to a file in
> the common directory and the function definition changed to
>      long int dram_size (long int *base, long int maxsize)

That's what I'll do.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
It is dangerous to be sincere unless you are also stupid.
                                                - George Bernard Shaw

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot-Users] Re: Some puzzles on dram_size()
  2004-01-06 16:28 [U-Boot-Users] Re: Some puzzles on dram_size() chris at nanometrics.ca
  2004-01-06 17:27 ` Wolfgang Denk
@ 2004-01-06 23:08 ` Wolfgang Denk
  2004-01-07 15:16 ` [U-Boot-Users] " SAM SONG
  2 siblings, 0 replies; 10+ messages in thread
From: Wolfgang Denk @ 2004-01-06 23:08 UTC (permalink / raw)
  To: u-boot

In message <OF5B21F0A5.A3EF40B7-ON85256E13.0056838C@nanometrics.ca> you wrote:
> 
> While I'm at it, the entire function should be moved to a file in
> the common directory and the function definition changed to
>      long int dram_size (long int *base, long int maxsize)

Done and checked in.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Once upon a time, "PC" meant "personal computer".  Now  it  seems  to
only  mean  "Prisoner  of Bill". Alas! All my PCs run Unix, and those
include Intel, Sparc, and other processors.
          -- Tom "Bring back the non-PC meaning of `PC'" Christiansen

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot-Users] Some puzzles on dram_size()
  2004-01-06 16:28 [U-Boot-Users] Re: Some puzzles on dram_size() chris at nanometrics.ca
  2004-01-06 17:27 ` Wolfgang Denk
  2004-01-06 23:08 ` Wolfgang Denk
@ 2004-01-07 15:16 ` SAM SONG
  2004-01-07 15:28   ` Wolfgang Denk
  2 siblings, 1 reply; 10+ messages in thread
From: SAM SONG @ 2004-01-07 15:16 UTC (permalink / raw)
  To: u-boot

Hi,Chris,

 --- chris at nanometrics.ca > 
> Hi Sam,
> 
>for (cnt = maxsize / sizeof (long) / 2; cnt >
> 0; cnt >>= 1) {
>for (cnt = 1; cnt < maxsize / sizeof (long);
> cnt <<= 1) {

>I know, I'm free to submit a patch, but I'm a
>combination of busy and lazy.

Thanks for your "lazy" work.It does work basically.I
tested these two lines on LITE_DW and ran well when
SDRAM_MAX_SIZE equaled to the actual RAM size.A pity
is that it cannot work while the setting of
SDRAM_MAX_SIZE is bigger than the actual RAM.It seems
that the RAM-SIZE test code still needs your patch.

Have a nice day!

Sam


  

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot-Users] Some puzzles on dram_size()
  2004-01-07 15:16 ` [U-Boot-Users] " SAM SONG
@ 2004-01-07 15:28   ` Wolfgang Denk
  0 siblings, 0 replies; 10+ messages in thread
From: Wolfgang Denk @ 2004-01-07 15:28 UTC (permalink / raw)
  To: u-boot

In message <20040107151638.55077.qmail@web15204.mail.bjs.yahoo.com> you wrote:
>
> Thanks for your "lazy" work.It does work basically.I
> tested these two lines on LITE_DW and ran well when
> SDRAM_MAX_SIZE equaled to the actual RAM size.A pity
> is that it cannot work while the setting of
> SDRAM_MAX_SIZE is bigger than the actual RAM.It seems
> that the RAM-SIZE test code still needs your patch.

It works on all other boards. If you check out the current version of
U-Boot from CVS you will find a common implementation for all boards.
If it doesn't work for you, you probably have other problems.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
I am a computer. I am dumber than any human and smarter than any  ad-
ministrator.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot-Users] Re: Some puzzles on dram_size()
  2004-01-06 17:27 ` Wolfgang Denk
@ 2004-01-07 15:59   ` SAM SONG
  2004-01-07 16:36     ` Wolfgang Denk
  0 siblings, 1 reply; 10+ messages in thread
From: SAM SONG @ 2004-01-07 15:59 UTC (permalink / raw)
  To: u-boot

Hi,Wolfgang,

 --- Wolfgang Denk <wd@denx.de> wrote:
> 
> >in message
> >
<OF5B21F0A5.A3EF40B7ON85256E13.0056838C@nanometrics.ca>>
> you wrote:
> > 
> > Your problem with dram_size() may be that it tests
> > memory beyond the maxsize given.
> 
> No. His max value as defined in the board config
> file was 64 MB, with an actual 16 MB of RAM.

But there are two chips of MT48LC16M16A2
[2*(16*16/8)=64MByte] on LITE_DW.So set SDRAM_MAX_SIZE
as 0x4000000 can match the need of SDRAM_MAX_SIZE.It
should work but crashed.When I set SDRAM_MAX_SIZE as
0x2000000(32MB),it booted normally but the memory
layout didn't look reasonable for u-boot located at
high 128K of 32MB rather than high 128K of actual
RAM.Followings are my test results on LITE_DW.

1.When I set SDRAM_MAX_SIZE as 0x2000000(32MB):

U-Boot 1.0.0 (Jan  7 2004 - 21:13:13)

CPU:   PPC823EZTnnB2 at 64 MHz: 16 kB I-Cache 8 kB
D-Cache
Board: RPXlite
DRAM:  32 MB
FLASH: 16 MB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   SCC ETHERNET
u-boot>
 
But u-boot located at 0x01fe1000.And I could see
0x2000000-0x3ffffff.Meanwhile,it could load linux
kernel and booted.

2.When I changed two lined code as Chris gave and set
SDRAM_MAX_SIZE = 0x4000000(64MB),it worked well.

U-Boot 1.0.0 (Jan  7 2004 - 21:13:13)

CPU:   PPC823EZTnnB2 at 64 MHz: 16 kB I-Cache 8 kB
D-Cache
Board: RPXlite
DRAM:  64 MB
FLASH: 16 MB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   SCC ETHERNET
u-boot>

U-boot located at 0x03fe1000.

3.When I changed two lined code as Chris gave and set
SDRAM_MAX_SIZE = 0x8000000(128MB),it worked badly.

U-Boot 1.0.0 (Jan  7 2004 - 21:22:40)

CPU:   PPC823EZTnnB2 at 64 MHz: 16 kB I-Cache 8 kB
D-Cache
Board: RPXlite
DRAM:  Bus Fault @ 0xff012f4c, fixup 0x00000000
Machine check in kernel mode.
NIP: 01FF1F88 XER: C000B25F LR: 03FE905C REGS:
fa202bc0 TRAP: 1000 DAR: FF010F84
MSR: 00001002 EE: 0 PR: 0 FP: 0 ME: 1 IR/DR: 00

GPR00: 03FE9054 FA202CB0 00000000 03FF683C FA202B88
FA202B78 FFFFFFFE 00000000
GPR08: 00000001 00000000 FA202808 FA2011C8 00000000
00600000 FF020E00 04FE1000
GPR16: FFAC0085 00010001 00900104 40101D41 00001002
FA202CC8 00000000 03FE309C
GPR24: 03FE9000 011C8402 00000001 00000007 FA200100
FA202EC0 04001F60 FA202CD8
Call backtrace:
Software Emulation Exception
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN

BDI>re
- TARGET: processing user reset request
- TARGET: resetting target passed
- TARGET: processing target init list ....
- TARGET: processing target init list passed
BDI>g
BDI>i
    Target state      : running
BDI>halt
    Target state      : debug mode
    Debug entry cause : external breakpoint
    Current PC        : 0x03ff5414
BDI>

My conclusion for the RAM-SIZE test code:
1. If the following word is the test code's
purpose,the test code by now still need to fix. 
> Let's put this right: the board config file  is 
> required  to  define SDRAM_MAX_SIZE  greater  than 
> or equal to the maximum RAM size of the system.
2. The RAM-SIZE test code of u-boot-1.0.0 in RPXlite.c
can only work right when the setting of SDRAM_MAX_SIZE
smaller than actual RAM but u-boot locates at high
128k of SDRAM_MAX_SIZE rather than high 128K of actual
RAM.At least on LITE_DW,it work like this.

Best regards,

Sam Song

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot-Users] Re: Some puzzles on dram_size()
  2004-01-07 15:59   ` SAM SONG
@ 2004-01-07 16:36     ` Wolfgang Denk
  2004-01-08 16:03       ` SAM SONG
  0 siblings, 1 reply; 10+ messages in thread
From: Wolfgang Denk @ 2004-01-07 16:36 UTC (permalink / raw)
  To: u-boot

In message <20040107155938.24169.qmail@web15207.mail.bjs.yahoo.com> you wrote:
>
> 2. The RAM-SIZE test code of u-boot-1.0.0 in RPXlite.c
> can only work right when the setting of SDRAM_MAX_SIZE

I'm not discussing any (probably broken) implementation of a specific
board  in  1.0.0.  I  was   referring   to   the   current   _common_
implemetation_  for  all boards that use such a function from the top
of CVS (checked in _after_ 1.0.1).

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
If programming was easy, they wouldn't need something as  complicated
as a human being to do it, now would they?
                       - L. Wall & R. L. Schwartz, _Programming Perl_

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot-Users] Re: Some puzzles on dram_size()
  2004-01-07 16:36     ` Wolfgang Denk
@ 2004-01-08 16:03       ` SAM SONG
  0 siblings, 0 replies; 10+ messages in thread
From: SAM SONG @ 2004-01-08 16:03 UTC (permalink / raw)
  To: u-boot

Hi,Wolfgank,

Wolfgank wrote:
> I'm not discussing any (probably broken)
> implementation of a specific board  in  1.0.0.  I  
> was   referring   to   the  current   _common_
> implemetation_  for  all boards that use such a
> function from the top of CVS (checked in _after_ 
> 1.0.1).
 
Yeah,I tested the code from current CVS and it worked
well when I set SDRAM_MAX_SIZE bigger than or same as
actual RAM size.Thanks for your adjustment on the
code.

Best regards,

Sam Song

 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot-Users] Re: Some puzzles on dram_size()
  2004-01-07 21:39 [U-Boot-Users] " chris at nanometrics.ca
@ 2004-01-08 15:56 ` SAM SONG
  0 siblings, 0 replies; 10+ messages in thread
From: SAM SONG @ 2004-01-08 15:56 UTC (permalink / raw)
  To: u-boot

Hi,Chris,

Chris you wrote:
> Did you remember to change the AM bits in the OR?
> If you want to test 128MB the memory controller must
> be given 128MB for the SDRAM chip select.

Sorry for neglecting the key point.When I added
it,u-boot worked fine.Thanks for your hints.
 
> Most board specific files include/configs/<board>.h
> have a line like:
> #define CFG_OR1_PRELIM   (CFG_PRELIM_OR_AM |
> CFG_OR_TIMING_SDRAM )
> 
> Maybe it should be changed to
> #define CFG_OR_AM_SDRAM  (- (SDRAM_MAX_SIZE &
> 0xffff8000))
> #define CFG_OR1_PRELIM   (CFG_OR_AM_SDRAM |
> CFG_OR_TIMING_SDRAM )

Yeah,I tested it.It did work well when I set
SDRAM_MAX_SIZE bigger than or same as actual RAM size.

Thanks for your notes again!

Best regards,

Sam


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot-Users] Re: Some puzzles on dram_size()
@ 2004-01-07 21:39 chris at nanometrics.ca
  2004-01-08 15:56 ` SAM SONG
  0 siblings, 1 reply; 10+ messages in thread
From: chris at nanometrics.ca @ 2004-01-07 21:39 UTC (permalink / raw)
  To: u-boot

Hi Sam,

Sam you wrote:
> 3.When I changed two lined code as Chris gave and set
> SDRAM_MAX_SIZE = 0x8000000(128MB),it worked badly.
Did you remember to change the AM bits in the OR?
If you want to test 128MB the memory controller must
be given 128MB for the SDRAM chip select.

You must have changed it before for 64MB to work,
since the default value for CFG_PRELIM_OR_AM for
the RPX Lite is 0xfe000000 (32MB).

Most board specific files include/configs/<board>.h
have a line like:
#define CFG_OR1_PRELIM   (CFG_PRELIM_OR_AM | CFG_OR_TIMING_SDRAM )

Maybe it should be changed to
#define CFG_OR_AM_SDRAM  (- (SDRAM_MAX_SIZE & 0xffff8000))
#define CFG_OR1_PRELIM   (CFG_OR_AM_SDRAM | CFG_OR_TIMING_SDRAM )

Then the only problem will be if the banks overlap,
which is much too complicated to automate or verify.


Thanks Wolfgang for such a quick patch.

Note that the remaining dram_size functions can usually be eliminated
and have the initdram function call get_ram_size directly after setting
the MxMR again.

Chris

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-01-08 16:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-06 16:28 [U-Boot-Users] Re: Some puzzles on dram_size() chris at nanometrics.ca
2004-01-06 17:27 ` Wolfgang Denk
2004-01-07 15:59   ` SAM SONG
2004-01-07 16:36     ` Wolfgang Denk
2004-01-08 16:03       ` SAM SONG
2004-01-06 23:08 ` Wolfgang Denk
2004-01-07 15:16 ` [U-Boot-Users] " SAM SONG
2004-01-07 15:28   ` Wolfgang Denk
2004-01-07 21:39 [U-Boot-Users] " chris at nanometrics.ca
2004-01-08 15:56 ` SAM SONG

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.