PATCH for cmd_mem.c:do_mem_mtest()
Sorry the patch below isn't from git - I hope it's still acceptable. I've put a copy in the body and attached it incase gmail decides to line wrap the text.
ChangeLog:
* Patch by Andrew Dyer, 13 September 2005:
if CFG_ALT_MEMTEST is defined withoutCFG_MEMTEST_SCRATCH, cmd_mem.c
code will dereference a null pointer. Change
the code to use the last word of the memory test
area as the scratch location in this case. Print
the scratch memory location used.
Index: common/cmd_mem.c
===================================================================
RCS file: /home/cvsroot/Projects/u-boot/common/cmd_mem.c,v retrieving revision 1.1.1.1
cmd_mem.c +11 -1
@@ -707,7 +707,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int#if defined(CFG_MEMTEST_SCRATCH )vu_long *dummy = (vu_long *)CFG_MEMTEST_SCRATCH ;#else -vu_long *dummy =NULL ; +vu_long *dummy;#endif int j;int iterations =1 ;
@@ -747,7 +747,17 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int }#if defined(CFG_ALT_MEMTEST ) + +#if !defined(CFG_MEMTEST_SCRATCH ) +/* if no fixed scratch area is defined use +* the last location of the test area +*/ + end--; + dummy = end; +#endif +printf ("Testing %08x ... %08x:\n" , (uint )start, (uint )end); +printf ("using address %08x as scratch\n" ,dummy);PRINTF ("%s:%d: start 0x%p end 0x%p\n" , __FUNCTION__, __LINE__, start, end);
Signature · 6 lines
Hardware, n.:
The parts of a computer system that can be kicked.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: u-boot-memtest-patch.txt
Url: http://lists.denx.de/pipermail/u-boot/attachments/20050913/23287345/attachment.txt Quoted 2 lines · In message <[email protected]> you wrote:
Sorry the patch below isn't from git - I hope it's still acceptable.
No problem.
Quoted 2 lines
I've put a copy in the body and attached it incase gmail decides to line wrap the text.
Ummm.. one copy is enough.
Quoted 5 lines
ChangeLog:
* Patch by Andrew Dyer, 13 September 2005:
ifCFG_ALT_MEMTESTis defined withoutCFG_MEMTEST_SCRATCH,cmd_mem.c
code will dereference a null pointer. Change
No, it does not. It just points to address 0x0000. This is a perfectly valid address on many systems.
Quoted 3 lines
the code to use the last word of the memory test area as the scratch location in this case. Print the scratch memory location used.
Which problem is this patch supposed to fix in the first place? The existing code compiles and works fine on many, many systems.
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A meeting is an event at which the minutes are kept and the hours are lost.
Quoted 8 lines · Wolfgang Denk
Quoted 5 lines
ChangeLog:
* Patch by Andrew Dyer, 13 September 2005:
ifCFG_ALT_MEMTESTis defined withoutCFG_MEMTEST_SCRATCH,cmd_mem.c
code will dereference a null pointer. ChangeNo, it does not. It just points to address
0x0000. This is a perfectly valid address on many systems.
I sent patch to mailing list few months ago which changes NULL to 0x00000000 and adds some comment to avoid such confusion (I burned my fingers the same way :-)).
ftp://ftp.linux-mips.org/pub/linux/mips/people/ladis/u-boot/cmd_mem_dummy_addr.diff
Best regards,
ladis
Quoted 4 lines · In message <20050913163114.GA19366@orphique> you wrote:
I sent patch to mailing list few months ago which changes NULL to
0x00000000and adds some comment to avoid such confusion (I burned my fingers the same way :-)).
We can write 0 or 0x0 or 000 or 0x00000 or (1 - 1) or NULL - all this does not change the behaviour of the code at all.
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de If today is the first day of the rest of your life, what the hell was yesterday?
[U-Boot-Users] ppcboot_stage2
I am using target :ppc405 netbsd host i386, netbsd
I can use u-boot to boot up.
I use load to load netbsd.bin (kernel) to bootup. I read about bootm, that netbsd image needs bootloader to load kernel and rootfile system.
I don't have Stage 2 Netbsd loader so I downloaded from website, but don't know how to build it. Can anyone help ? or any other bootloader for netbsd images
I am really stuck at this and cannot proceed.
thanks
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
[U-Boot-Users] ppcboot_stage2
I've been unable to download the stage 2 NetBSD loader from this link:
ftp://ftp.denx.de/pub/u-boot/ppcboot_stage2.tar.gz. Are there any other alternatives, or can anyone send me this loader? Also, is there any documentation of how to use it?
Thanks.
Sam
Quoted 15 lines · --- manju mahajan
I am using target :ppc405 netbsd host i386, netbsd
I can use u-boot to boot up.
I use load to load netbsd.bin (kernel) to bootup. I read about bootm, that netbsd image needs bootloader
to load kernel and rootfile system.I don't have Stage 2 Netbsd loader so I downloaded from website, but don't know how to build it. Can anyone help ? or any other bootloader for netbsd images
I am really stuck at this and cannot proceed.
Quoted 10 lines
thanks
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
-------------------------------------------------------
Quoted 11 lines
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play:
http://sourceforge.net/geronimo.php
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users
Quoted 1 line
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[U-Boot-Users] ppcboot_stage2
Quoted 3 lines · In message <[email protected]> you wrote:
I've been unable to download the stage 2 NetBSD loader from this link:
ftp://ftp.denx.de/pub/u-boot/ppcboot_stage2.tar.gz.
Why not? The link is correct and the server is up and running.
Quoted 3 lines
Are there any other alternatives, or can anyone send me this loader? Also, is there any documentation of how to use it?
Except from the README? Ask the NetBSD folks, pelase.
Best regards,
Wolfgang Denk
Signature · 6 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Niklaus Wirth has lamented that, whereas Europeans pronounce his name correctly (Ni-klows Virt), Americans invariably mangle it into (Nick- les Worth). Which is to say that Europeans call him by name, but Americans call him by value.
[U-Boot-Users] ppcboot_stage2
Quoted 12 lines · --- Wolfgang Denk
In message <[email protected]>
Quoted 1 line · you
I've been unable to download the stage 2 NetBSD
loader
Quoted 2 lines
from this link:
ftp://ftp.denx.de/pub/u-boot/ppcboot_stage2.tar.gz.
Why not? The link is correct and the server is up
and running.
You're right. I was able to get from home. I guess it has to do with the firewall at my workplace.
Quoted 8 lines
Quoted 1 line
Are there any other alternatives, or can anyone
send
Quoted 1 line
me this loader? Also, is there any documentation
of
Quoted 1 line
how to use it?
Except from the README? Ask the NetBSD folks,
pelase.
Will do. Thanks.
Quoted 18 lines
Best regards,
Wolfgang Denk
Signature · 11 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Niklaus Wirth has lamented that, whereas Europeans pronounce his name correctly (Ni-klows Virt), Americans invariably mangle it into (Nick- les Worth). Which is to say that Europeans call him by name, but Americans call him by value.
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
Quoted 2 lines · Wolfgang Denk
We can write 0 or
0x0or 000 or0x00000or (1 - 1) or NULL - all this does not change the behaviour of the code at all.
No doubt, but practice is to use NULL to mark invalid pointer, while address zero is simply "0". It won't affect generated code, but will make understanding it better.
Best regards,
ladis
Quoted 7 lines · In message <20050914080947.GA22280@orphique> you wrote:
Quoted 3 lines
We can write 0 or
0x0or 000 or0x00000or (1 - 1) or NULL - all this does not change the behaviour of the code at all.No doubt, but practice is to use NULL to mark invalid pointer, while address zero is simply "0". It won't affect generated code, but will make understanding it better.
OK, applied.
Best regards,
Wolfgang Denk
Signature · 5 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de ...computer hardware progress is so fast. No other technology since civilization began has seen six orders of magnitude in performance- price gain in 30 years. - Fred Brooks, Jr.
Quoted 8 lines · Wolfgang Denk
Quoted 5 lines
ChangeLog:
* Patch by Andrew Dyer, 13 September 2005:
ifCFG_ALT_MEMTESTis defined withoutCFG_MEMTEST_SCRATCH,cmd_mem.c
code will dereference a null pointer. ChangeNo, it does not. It just points to address
0x0000. This is a perfectly valid address on many systems.
Not on MIPS (unless someone was daft enough to map it with the TLB). The code causes a TLB store miss exception. Since this is in 'common' code, I think it's a bug.
Quoted 6 lines
Quoted 3 lines
the code to use the last word of the memory test
area as the scratch location in this case. Print
the scratch memory location used.Which problem is this patch supposed to fix in the first place? The existing code compiles and works fine on many, many systems.
There are two problems -
1) writing to address 0 is bad on MIPS and causes a crash.
2) I have a system with two banks of DRAM, 1 attached to the CPU directly and 1 hooked through an FPGA to do video stuff. Both are entirely accessable through the CPU, but via different external busses. I would like to be able to test either one with the same basic command.
With a static define of the scratch address I can't test one of the memories correctly becuase the scratch address is pointing to the other memory, so the scratch writes don't serve their purpose.
My solution was to just allocate a location in the test range as scratch if the static define isn't present. This guarantees the scratch address used is valid and in the bank of ram required.
Signature · 2 lines
Hardware, n.:
The parts of a computer system that can be kicked.Quoted 4 lines · In message <[email protected]> you wrote:
Not on MIPS (unless someone was daft enough to map it with the TLB). The code causes a TLB store miss exception. Since this is in 'common' code, I think it's a bug.
OK.
But all you need to do is #define CFG_MEMTEST_SCRATCH in your board config file, right?
Quoted 3 lines
With a static define of the scratch address I can't test one of the memories correctly becuase the scratch address is pointing to the other memory, so the scratch writes don't serve their purpose.
OK, but this is a special case, isn't it?
Would it be acceptable for you if we just move the initialization
dummy = (vu_long*)CFG_MEMTEST_SCRATCH;
below the computation of "end", so that you can use
#define CFG_MEMTEST_SCRATCH (--end)
in your board config file?
Best regards,
Wolfgang Denk
Signature · 3 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Anything free is worth what you pay for it.
Quoted 26 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:
Not on MIPS (unless someone was daft enough to map it with the TLB). The code causes a TLB store miss exception. Since this is in 'common' code, I think it's a bug.
OK.
But all you need to do is #define
CFG_MEMTEST_SCRATCHin your board config file, right?Quoted 3 lines
With a static define of the scratch address I can't test one of the memories correctly becuase the scratch address is pointing to the other memory, so the scratch writes don't serve their purpose.
OK, but this is a special case, isn't it?
Would it be acceptable for you if we just move the initialization
dummy = (vu_long*)CFG_MEMTEST_SCRATCH;below the computation of "end", so that you can use
Quoted 7 lines
#define CFG_MEMTEST_SCRATCH (--end)in your board config file?
Best regards,
Wolfgang Denk
I'm not sure you want that, exactly. You are affecting the variable "end" as a side effect in a macro which is generally a bad idea. A no side effect version would be:
#define CFG_MEMTEST_SCRATCH (end - 1)
You are also making assumptions on the type of end (the variable, that is). I'm assuming this is a 32 bit wide memory test, sorry for not verifying that. You may want to coerce "end" to make sure the "- 1" subtracts the proper number of bytes:
#define CFG_MEMTEST_SCRATCH ((void *)end - 1)
gvb
Quoted 2 lines · In message <[email protected]> you wrote:
Quoted 2 lines
#define CFG_MEMTEST_SCRATCH (--end)
...
Quoted 4 lines
I'm not sure you want that, exactly. You are affecting the variable "end" as a side effect in a macro which is generally a bad idea. A no side effect version would be:
#defineCFG_MEMTEST_SCRATCH(end - 1)
That would mean that *end is included in testing, and used as scratch cell at the same time --> will not work.
Quoted 1 line
You are also making assumptions on the type of end (the variable, that
No. Just, that it has the same type as the "dummy" variable initilaized by CFG_MEMTEST_SCRATCH
Quoted 1 line
#define
CFG_MEMTEST_SCRATCH((void *)end - 1)
That would be definitely worse.
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Harrison's Postulate: For every action, there is an equal and opposite criticism.
Quoted 23 lines · Wolfgang Denk
Quoted 1 line · In message <[email protected]> you wrote:
Quoted 1 line
#define CFG_MEMTEST_SCRATCH (--end)...
Quoted 4 lines
I'm not sure you want that, exactly. You are affecting the variable "end" as a side effect in a macro which is generally a bad idea. A no side effect version would be:
#defineCFG_MEMTEST_SCRATCH(end - 1)That would mean that *end is included in testing, and used as scratch cell at the same time --> will not work.
Quoted 1 line
You are also making assumptions on the type of end (the variable, that
No. Just, that it has the same type as the "dummy" variable initilaized by
CFG_MEMTEST_SCRATCH
Quoted 8 lines
Quoted 1 line
#define
CFG_MEMTEST_SCRATCH((void *)end - 1)That would be definitely worse.
Best regards,
Wolfgang Denk
Ahh, you _did_ intend the side effect. You are being trickier than I gave you credit for. Please disregard my interference...
gvb
Quoted 8 lines · Wolfgang Denk
Quoted 3 lines
Not on MIPS (unless someone was daft enough to map it with the TLB). The code causes a TLB store miss exception. Since this is in 'common' code, I think it's a bug.
OK.
But all you need to do is #define
CFG_MEMTEST_SCRATCHin your board config file, right?
Since this is common code I would suggest requiring all boards that want to use CFG_ALT_MEMTEST be required to define CFG_MEMTEST_SCRATCH in their config and a #error if it's not defined. It seems like something likely to trip up the unaware. Attached is a revised patch that does this.
ChangeLog:
* Patch by Andrew Dyer, 13 September 2005:
in common/cmd_mem.c:do_mem_mtest():
Require CFG_MEMTEST_SCRATCH to be
defined if CFG_ALT_MEMTEST is enabled
instead of using the unsafe default of 0x00000000
Define CFG_MEMTEST_SCRATCH for all
targets with CFG_ALT_MEMTEST enabled.
evaluate CFG_MEMTEST_SCRATCH after
start and end are computed so CFG_MEMTEST_SCRATCH
can use those values
Update ./README
Signature · 6 lines
Hardware, n.:
The parts of a computer system that can be kicked.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: u-boot-memtest-patch2.txt
Url: http://lists.denx.de/pipermail/u-boot/attachments/20050913/636e4410/attachment.txt Quoted 4 lines · In message <[email protected]> you wrote:
Since this is common code I would suggest requiring all boards that want to use
CFG_ALT_MEMTESTbe required to defineCFG_MEMTEST_SCRATCHin their config and a #error if it's not defined. It seems like
No. I reject this. The overwhelming majority of boards does not need this, so why enforce it?
Quoted 2 lines
something likely to trip up the unaware. Attached is a revised patch that does this.
I also reject the patch because you define a variable in the middle of the code. I will not accept such code.
Best regards,
Wolfgang Denk
Signature · 5 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de About the use of language: it is impossible to sharpen a pencil with a blunt ax. It is equally vain to try to do it with ten blunt axes instead. -- Edsger Dijkstra