public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] Nios2: bootm command bugs (lead to Kernel guzip "crc error" or "ran out of input data") and cfi_flash timeout error
@ 2009-04-09 15:28 Renato Andreola
  2009-04-09 19:39 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Renato Andreola @ 2009-04-09 15:28 UTC (permalink / raw)
  To: u-boot

I've tested u-boot 2009/03 with the last nios2 uClinux kernel and I've 
found 2 bugs (or things that can be changed to improve performance).

=> CFI "bug"

The first bug is related to the Common Flash Interface handling code: 
the write/clear/etc.. timeout is calculated assuming a 1kHz timer tick 
freq. and the expression used to scale the timeout leads to an incorrect 
timeou in case the tick frequency (integer) is less than 1kHz (e.g. 
999Hz due to rounding like in our case with 83.33333Mhz clock).
The integer division used in the cfi_flash.c routine can be improved 
like this:

662,663c662,665
< #if CONFIG_SYS_HZ != 1000
<     tout *= CONFIG_SYS_HZ/1000;
---
 > #if CONFIG_SYS_HZ != 1000
 >     unsigned long long ull;
 >     ull = tout*CONFIG_SYS_HZ + CONFIG_SYS_HZ/2;
 >     tout = ull/1000; /* Compute: tout *= CONFIG_SYS_HZ/1000; */


The new expression uses a long and an integer round trick to function 
properly even in case of CONFIG_SYS_HZ = 999.




=> Kernel decompression bug

The u-boot copies (sometime and in my test board!) the kernel image from 
somewhere  to the execution address specified into the image header. 
After the copy, and some more work, the Nios2 bootm() procedure jumps to 
the entry point.
The problem is that the bootm() procedure does not flush the data cache 
before jumping to the newly copied code, so the execution of the kernel 
head.S routine (that invalidates the cache and calls guzip) finds some 
invalid data into the dram memory (some data cache lines have been lost).
The following code diff (just to flush data cache) fixes the problem in 
lib_nios2/bootm.c:

26a27
 > #include <asm/cache.h>
34c35,36
<
---
 >     flush_dcache (0,CONFIG_SYS_DCACHE_SIZE );
 >     flush_icache (0,CONFIG_SYS_ICACHE_SIZE);

Renato

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

* [U-Boot] Nios2: bootm command bugs (lead to Kernel guzip "crc error" or "ran out of input data") and cfi_flash timeout error
  2009-04-09 15:28 [U-Boot] Nios2: bootm command bugs (lead to Kernel guzip "crc error" or "ran out of input data") and cfi_flash timeout error Renato Andreola
@ 2009-04-09 19:39 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2009-04-09 19:39 UTC (permalink / raw)
  To: u-boot

Dear Renato Andreola,

In message <49DE1434.2070600@imagos.it> you wrote:
> I've tested u-boot 2009/03 with the last nios2 uClinux kernel and I've 
> found 2 bugs (or things that can be changed to improve performance).

Can you please submit proper patches? Please use git tools
(git-format-patch and git-send-email) to create and send the patches,
and make sure to include a useful commit message; also, don't forget
your Signed-off-by: message. Please see
http://www.denx.de/wiki/U-Boot/Patches  for instructions.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Anarchy may not be the best form of government, but it's better  than
no government at all.

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

end of thread, other threads:[~2009-04-09 19:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-09 15:28 [U-Boot] Nios2: bootm command bugs (lead to Kernel guzip "crc error" or "ran out of input data") and cfi_flash timeout error Renato Andreola
2009-04-09 19:39 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox