[U-Boot-Users] memsize.c patch

Hi,
When get_ram_size(common/memsize.c) is called on a MPC8245 board which has 256MB SDRAM, booting stops. This is because the function tries to read outside BAT boundary. This patch fixes the problem. I tested it on our board(board/etin/debris).
Regards, Sangmoon Kim

In message 000c01c41868$34814910$212d4cdc@smkim you wrote:
When get_ram_size(common/memsize.c) is called on a MPC8245 board which has 256MB SDRAM, booting stops. This is because the function tries to read outside BAT boundary.
This is intentional. You can only find out how much mempory is installed when you test beyound the end - otrherwise there might be more memory, right? You must map more memory, then.
This patch fixes the problem. I tested it on our board(board/etin/debris).
But it breaks many other boards.
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) { addr = base + cnt; /* pointer arith! */
val = *addr;
*addr = save[--i];
if (val != ~cnt) {
if (addr < maxsize) {
val = *addr;
*addr = save[--i];
}
Just a simple question: what happens if base != 0 ?
Rejected.
Wolfgang Denk

Hi,
This is intentional. You can only find out how much mempory is installed when you test beyound the end - otrherwise there might be more memory, right? You must map more memory, then.
I know this is intentional. But in case of MPC8245 which has 4 DBATs. We need one DBAT for DCACHE, one for PCI and one for Flash. Then there is only one DBAT left for SDRAM. The maximum size of DBAT is 256M bytes. So the maximum capacity of SDRAM that u-boot can handle is 256M bytes. Now if the CFG_MAX_RAM_SIZE is set to 256M and 256M SDRAM is installed, the get_ram_size routine tries to read some value at (base + 0x10000000) which is outside of block address translation. Then the board hangs. The patch fixes the problem.
Just a simple question: what happens if base != 0 ?
I forgot that. Then how about this.
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) { addr = base + cnt; /* pointer arith! */ - val = *addr; - *addr = save[--i]; - if (val != ~cnt) { + if (addr < (base + maxsize)) { + val = *addr; + *addr = save[--i]; + } + if ((val != ~cnt) || (addr >= base + maxsize)) {
Regards, Sangmoon Kim

Hi, You are right. Sorry for the wrong arguing. Actually I was debugging my code(board/etin/debris/debrs.c) from old version of u-boot. Because I found some problem of my initdram. After I fixed the problem I found that u-boot gets to use the simular code. And asumed that u-boot has the same problem. The difference was this.
My code : for (cnt = 1; cnt <= CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1) u-boot : for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1)
Isn't it fun?
Regards, Sangmoon Kim
----- Original Message ----- From: "Sangmoon Kim" dogoil@etinsys.com To: "Wolfgang Denk" wd@denx.de Cc: u-boot-users@lists.sourceforge.net Sent: Friday, April 02, 2004 6:25 PM Subject: Re: [U-Boot-Users] memsize.c patch
Hi,
This is intentional. You can only find out how much mempory is installed when you test beyound the end - otrherwise there might be more memory, right? You must map more memory, then.
I know this is intentional. But in case of MPC8245 which has 4 DBATs. We need one DBAT for DCACHE, one for PCI and one for Flash. Then there is only one DBAT left for SDRAM. The maximum size of DBAT is 256M bytes. So the maximum capacity of SDRAM that u-boot can handle is 256M bytes. Now if the CFG_MAX_RAM_SIZE is set to 256M and 256M SDRAM is installed, the get_ram_size routine tries to read some value at (base + 0x10000000) which is outside of block address translation. Then the board hangs. The patch fixes the problem.
Just a simple question: what happens if base != 0 ?
I forgot that. Then how about this.
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) { addr = base + cnt; /* pointer arith! */
val = *addr;
*addr = save[--i];
if (val != ~cnt) {
if (addr < (base + maxsize)) {
val = *addr;
*addr = save[--i];
}
if ((val != ~cnt) || (addr >= base + maxsize)) {
Regards, Sangmoon Kim
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users

In message 001201c41894$7f766af0$212d4cdc@smkim you wrote:
The patch fixes the problem.
This patch breaks the logic on all other boards.
Best regards,
Wolfgang Denk
participants (2)
-
Sangmoon Kim
-
Wolfgang Denk