public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Renato Andreola <renato.andreola@imagos.it>
To: u-boot@lists.denx.de
Subject: [U-Boot] Nios2: bootm command bugs (lead to Kernel guzip "crc error" or "ran out of input data") and cfi_flash timeout error
Date: Thu, 09 Apr 2009 17:28:52 +0200	[thread overview]
Message-ID: <49DE1434.2070600@imagos.it> (raw)

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

             reply	other threads:[~2009-04-09 15:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-09 15:28 Renato Andreola [this message]
2009-04-09 19:39 ` [U-Boot] Nios2: bootm command bugs (lead to Kernel guzip "crc error" or "ran out of input data") and cfi_flash timeout error Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49DE1434.2070600@imagos.it \
    --to=renato.andreola@imagos.it \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox