mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Cristiano De Alti <cristiano_dealti@hotmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: i.mx21 ads nor flash
Date: Tue, 28 Jan 2014 12:33:11 +0100	[thread overview]
Message-ID: <20140128113311.GB16215@pengutronix.de> (raw)
In-Reply-To: <loom.20140128T004554-598@post.gmane.org>

On Mon, Jan 27, 2014 at 11:46:12PM +0000, Cristiano De Alti wrote:
> Hi,
>   I'm trying to revive an old i.mx21 ads board.
> I've flashed barebox-2014.01.0 and the board boots.
> Ethernet works and I'm able to boot Linux via tftp.
> Adding CONFIG_NAND=y in the .config enables the 64MB NAND flash (why is it
> not set in the board defconfig?) and I can erase it.

Amazing! I think this hasn't been tested for longer, I'm surprised that
still so many things work :)

> Nice work, Barebox!
> My question is about the NOR flash. The board has two banks of 8Mx16bit NOR
> flash paralleled. So the data bus width is 32 bit and the capacity is 32MB.
> The NOR is detected by Barebox:
> 
> cfi_flash cfi_flash0: found cfi flash at c8000000, size 33554432
> 
> and I can see the /dev/nor0 device:
> 
> crw-------   33554432 /dev/nor0
> 
> I can erase it but only up to 16M. For example, this works:
> 
> erase /dev/nor0 10M+6M
> 
> Anyway if I try to erase an area above 16M, e.g.:
> 
> erase /dev/nor0 16M+1k
> 
> or the whole device, e.g.:
> 
> erase /dev/nor0
> 
> the command fails with:
> 
> erase: Invalid argument
> 
> I've added printouts and the area I want to delete is past the last eraseregion.
> 
> So I wonder how the units of the erase command are meant. If the unit is
> byte, the command:
> 
> erase /dev/nor0 0+16M
> 
> should obviously mean "erase the first half of the whole flash".
> But then the above commands shouldn't fail.
> 
> Alternatively, given that there are 2 16MB banks in parallel it could also
> mean "erase 16MB in each bank" i.e. the whole flash.
> 
> I'm not sure what's happening.

erase /dev/nor0 0+32M
or
erase /dev/nor0

should both erase the whole flash and should both work for you. erase
/dev/nor0 0+16M should erase the first half of the flash. You have
encountered a bug somewhere.

Could you paste the output of 'devinfo cfi_flash0'? Also you could
#define DEBUG ontop of drivers/mtd/nor/cfi_flash*.c. Please also use
'md -s /dev/nor0' and 'md -s /dev/nor 16M' which show a hexdump of the
beginning of the flash and at 16MiB into the flash. you can write
something to the flash using

memcpy -s /env/config -d /dev/nor0 0 0 1K
(beginning of flash)

and

memcpy -s /env/config -d /dev/nor0 0 16M 1K
(middle of flash)

Do these work and show a sane result on the flash?
There may be a bug in the cfi flash driver, but it could also be
that the Chipselect is misconfigured, check
imx21_setup_eimcs(0, 0x00003E00, 0x00000E01);

I have no idea what's happening exactly, but I can say that the commands
you used should behave as you expect.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-01-28 11:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-27 23:46 Cristiano De Alti
2014-01-28 11:33 ` Sascha Hauer [this message]
2014-02-02 16:17   ` Cristiano De Alti
2014-02-03  8:35     ` Sascha Hauer

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=20140128113311.GB16215@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=cristiano_dealti@hotmail.com \
    /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