mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Question about SPI NOR flash
@ 2014-05-13  8:55 Holger Schurig
  2014-05-13 10:00 ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Holger Schurig @ 2014-05-13  8:55 UTC (permalink / raw)
  To: barebox

Hi,

my device has an SPI NOR flash Micron N25Q512A13G124F. With the patch
below it get's detected by barebox and I can at least dump it ("md -s
/dev/m25p0).

Before submitting that patch with signed-off, I want however first
test SPI. It works a but, but only so far:

barebox:/ unprotect /dev/m25p0
barebox:/ erase /dev/m25p0
barebox:/ erase /dev/m25p0.barebox-environment
barebox:/ saveenv
saving environment
could not open /dev/env0: Read-only file system
saveenv: Read-only file system

So, what am I missing to connect /dev/env0 by default?

And, when I do this:

barebox:/ saveenv /dev/m25p0.barebox-environment
saving environment

it seems that it just wrote 00's (before it was FF's, because of the erase):

barebox:/ md -s /dev/m25p0.barebox-environment
00000000: 00000000 00000000 00000000 00000000                ................
00000010: 00000000 00000000 00000000 00000000                ................
00000020: 00000000 00000000 00000000 00000000                ................
00000030: 00000000 00000000 00000000 00000000                ................
00000040: 00000000 00000000 00000000 00000000                ................
00000050: 00000000 00000000 00000000 00000000                ................
00000060: 00000000 00000000 00000000 00000000                ................
00000070: 00000000 00000000 00000000 00000000                ................
00000080: 00000000 00000000 00000000 00000000                ................
00000090: 00000000 00000000 00000000 00000000                ................
000000a0: 00000000 00000000 00000000 00000000                ................
000000b0: 00000000 00000000 00000000 00000000                ................
000000c0: 00000000 00000000 00000000 00000000                ................
000000d0: 00000000 00000000 00000000 00000000                ................
000000e0: 00000000 00000000 00000000 00000000                ................
000000f0: 00000000 00000000 00000000 00000000                ................

Now, perhaps I must add something to the device tree? When I do ...

chosen {
   # ...
   environment@0 {
      compatible = "barebox,environment";
      device-path = &flash, "partname:barebox-environment";
    };
};

&ecspi3 {
  flash: spiflash@0 {
    #address-cells = <1>;
    #size-cells = <1>;
    compatible = "m25p80";
    spi-max-frequency = <20000000>;
    reg = <0>;

    partition@0 {
      label = "barebox-environment";
      reg = <0x0 0x40000>;
    };
  };
};

then I get a backtrace at boot:

detected i.MX6 Quad revision 1.2
mdio_bus: miibus0: probed
m25p80 spiflash@00: mr25h256 (32 Kbytes)
partition m25p0.barebox-environment not completely inside device m25p0
unable to handle paging request at address 0xfffffff2
pc : [<4fe0f0b0>]    lr : [<4fe1fea7>]
sp : 4ffffe58  ip : 4ffff9bc  fp : 00000002
r10: 00000000  r9 : 00040000  r8 : 00000000
r7 : 4be22ea4  r6 : 4be22c58  r5 : ffffffea  r4 : 4be053d8
r3 : 4ffffe20  r2 : 4ffffe28  r1 : 4be22c58  r0 : ffffffea
Flags: nZCv  IRQs off  FIQs off  Mode SVC_32
[<4fe0f0b0>] (of_parse_partition+0x8c/0xb0) from [<4fe0f0eb>]
(of_parse_partitions+0x17/0x2c)
[<4fe0f0eb>] (of_parse_partitions+0x17/0x2c) from [<4fe095fb>]
(add_mtd_device+0xc7/0x110)
[<4fe095fb>] (add_mtd_device+0xc7/0x110) from [<4fe090cd>]
(m25p_probe+0x2a9/0x31c)
[<4fe090cd>] (m25p_probe+0x2a9/0x31c) from [<4fe099dd>] (spi_probe+0x9/0xa)
[<4fe099dd>] (spi_probe+0x9/0xa) from [<4fe07141>] (device_probe+0x11/0x44)
[<4fe07141>] (device_probe+0x11/0x44) from [<4fe07199>] (match.part.2+0x25/0x2c)
[<4fe07199>] (match.part.2+0x25/0x2c) from [<4fe071ed>]
(register_driver+0x4d/0x74)
[<4fe071ed>] (register_driver+0x4d/0x74) from [<4fe0071b>]
(start_barebox+0x17/0xd4)
[<4fe0071b>] (start_barebox+0x17/0xd4) from [<4fe25aff>] (__start+0xa3/0xb8)
[<4fe25aff>] (__start+0xa3/0xb8) from [<4fe00005>] (__bare_init_start+0x1/0xc)

[<4fe25529>] (unwind_backtrace+0x1/0x58) from [<4fe16a99>] (panic+0x1d/0x2c)
[<4fe16a99>] (panic+0x1d/0x2c) from [<4fe259c1>] (do_exception+0xd/0x10)
[<4fe259c1>] (do_exception+0xd/0x10) from [<4fe25a29>] (do_data_abort+0x21/0x2c)
[<4fe25a29>] (do_data_abort+0x21/0x2c) from [<4fe256e8>] (data_abort+0x48/0x60)
### ERROR ### Please RESET the board ###


Index: barebox/drivers/mtd/devices/m25p80.c
===================================================================
--- barebox.orig/drivers/mtd/devices/m25p80.c   2014-05-06
19:28:24.735953323 +0200
+++ barebox/drivers/mtd/devices/m25p80.c        2014-05-06
19:29:01.907954021 +0200
@@ -661,6 +661,7 @@ static const struct platform_device_id m
        /* Micron */
        { "n25q128",  INFO(0x20ba18, 0, 64 * 1024, 256, 0) },
        { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) },
+       { "n25q512",  INFO(0x20ba20, 0, 64 * 1024,1024, SECT_4K) },

        /* Spansion -- single (large) sector size only, at least
         * for the chips listed here (without boot sectors).

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

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

* Re: Question about SPI NOR flash
  2014-05-13  8:55 Question about SPI NOR flash Holger Schurig
@ 2014-05-13 10:00 ` Sascha Hauer
  2014-05-13 10:22   ` Holger Schurig
  0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2014-05-13 10:00 UTC (permalink / raw)
  To: Holger Schurig; +Cc: barebox

On Tue, May 13, 2014 at 10:55:33AM +0200, Holger Schurig wrote:
> Hi,
> 
> my device has an SPI NOR flash Micron N25Q512A13G124F. With the patch
> below it get's detected by barebox and I can at least dump it ("md -s
> /dev/m25p0).
> 
> Before submitting that patch with signed-off, I want however first
> test SPI. It works a but, but only so far:
> 
> barebox:/ unprotect /dev/m25p0
> barebox:/ erase /dev/m25p0
> barebox:/ erase /dev/m25p0.barebox-environment
> barebox:/ saveenv
> saving environment
> could not open /dev/env0: Read-only file system
> saveenv: Read-only file system
> 
> So, what am I missing to connect /dev/env0 by default?
> 
> And, when I do this:
> 
> barebox:/ saveenv /dev/m25p0.barebox-environment
> saving environment
> 
> it seems that it just wrote 00's (before it was FF's, because of the erase):
> 
> barebox:/ md -s /dev/m25p0.barebox-environment
> 00000000: 00000000 00000000 00000000 00000000                ................
> 00000010: 00000000 00000000 00000000 00000000                ................
> 00000020: 00000000 00000000 00000000 00000000                ................
> 00000030: 00000000 00000000 00000000 00000000                ................
> 00000040: 00000000 00000000 00000000 00000000                ................
> 00000050: 00000000 00000000 00000000 00000000                ................
> 00000060: 00000000 00000000 00000000 00000000                ................
> 00000070: 00000000 00000000 00000000 00000000                ................
> 00000080: 00000000 00000000 00000000 00000000                ................
> 00000090: 00000000 00000000 00000000 00000000                ................
> 000000a0: 00000000 00000000 00000000 00000000                ................
> 000000b0: 00000000 00000000 00000000 00000000                ................
> 000000c0: 00000000 00000000 00000000 00000000                ................
> 000000d0: 00000000 00000000 00000000 00000000                ................
> 000000e0: 00000000 00000000 00000000 00000000                ................
> 000000f0: 00000000 00000000 00000000 00000000                ................
> 
> Now, perhaps I must add something to the device tree? When I do ...
> 
> chosen {
>    # ...
>    environment@0 {
>       compatible = "barebox,environment";
>       device-path = &flash, "partname:barebox-environment";
>     };
> };
> 
> &ecspi3 {
>   flash: spiflash@0 {
>     #address-cells = <1>;
>     #size-cells = <1>;
>     compatible = "m25p80";
>     spi-max-frequency = <20000000>;
>     reg = <0>;
> 
>     partition@0 {
>       label = "barebox-environment";
>       reg = <0x0 0x40000>;
>     };
>   };
> };

This looks perfectly fine.

> 
> then I get a backtrace at boot:
> 
> detected i.MX6 Quad revision 1.2
> mdio_bus: miibus0: probed
> m25p80 spiflash@00: mr25h256 (32 Kbytes)

This is your problem. Your device is detected as a 32KB mr25h256 instead
of the n25q512 you really have. Have you seen
http://lists.infradead.org/pipermail/linux-mtd/2014-January/051382.html?

> partition m25p0.barebox-environment not completely inside device m25p0

You define a 256k environment partition in the devicetree, but your
(wrongly detected) device has only 32k.

> unable to handle paging request at address 0xfffffff2

Of course barebox shouldn't crash here, that seems to be a bug.

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

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

* Re: Question about SPI NOR flash
  2014-05-13 10:00 ` Sascha Hauer
@ 2014-05-13 10:22   ` Holger Schurig
  2014-05-13 10:24     ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Holger Schurig @ 2014-05-13 10:22 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

> Your device is detected as a 32KB mr25h256 instead
> of the n25q512 you really have.

Oh, something here is flaky. Because sometimes it get's detected
correctly. Sigh. This here with dev_dbg() turned into dev_info() and
the partition things removed from the DTS:

detected i.MX6 Quad revision 1.2
mdio_bus: miibus0: probed
m25p80 spiflash@00: n25q512 (65536 Kbytes)
m25p80 spiflash@00: mtd .name = <NULL>, .size = 0x4000000 (64MiB)
.erasesize = 0x00001000 (4KiB) .numeraseregions = 0
imx-esdhc 2194000.usdhc: registered as 2194000.usdhc
imx-esdhc 219c000.usdhc: registered as 219c000.usdhc
environment load /dev/env0: No such file or directory
Maybe you have to create the partition.
no valid environment found on /dev/env0. Using default environment
running /env/bin/init...




> http://lists.infradead.org/pipermail/linux-mtd/2014-January/051382.html?#

Hmm, this isn't in origin/master. I'm a bit confused.

What should I use, master or next?  And why do both get patches
applied regularly?

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

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

* Re: Question about SPI NOR flash
  2014-05-13 10:22   ` Holger Schurig
@ 2014-05-13 10:24     ` Sascha Hauer
  2014-05-13 11:35       ` Holger Schurig
  0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2014-05-13 10:24 UTC (permalink / raw)
  To: Holger Schurig; +Cc: barebox

On Tue, May 13, 2014 at 12:22:13PM +0200, Holger Schurig wrote:
> > Your device is detected as a 32KB mr25h256 instead
> > of the n25q512 you really have.
> 
> Oh, something here is flaky. Because sometimes it get's detected
> correctly. Sigh. This here with dev_dbg() turned into dev_info() and
> the partition things removed from the DTS:

You could limit the maximum frequency of the spi bus.

> 
> detected i.MX6 Quad revision 1.2
> mdio_bus: miibus0: probed
> m25p80 spiflash@00: n25q512 (65536 Kbytes)
> m25p80 spiflash@00: mtd .name = <NULL>, .size = 0x4000000 (64MiB)
> .erasesize = 0x00001000 (4KiB) .numeraseregions = 0
> imx-esdhc 2194000.usdhc: registered as 2194000.usdhc
> imx-esdhc 219c000.usdhc: registered as 219c000.usdhc
> environment load /dev/env0: No such file or directory
> Maybe you have to create the partition.
> no valid environment found on /dev/env0. Using default environment
> running /env/bin/init...
> 
> 
> > http://lists.infradead.org/pipermail/linux-mtd/2014-January/051382.html?#
> 
> Hmm, this isn't in origin/master. I'm a bit confused.

This is a Linux patch. What I meant is that the same could be missing in
barebox.

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

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

* Re: Question about SPI NOR flash
  2014-05-13 10:24     ` Sascha Hauer
@ 2014-05-13 11:35       ` Holger Schurig
  2014-05-22 16:14         ` Holger Schurig
  0 siblings, 1 reply; 6+ messages in thread
From: Holger Schurig @ 2014-05-13 11:35 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hmm, this patch waits for both RDSR bitmask 0x01 not set AND for RDFSR
bitmask 0x80 set. I looked at u-boot, which does either one or the
other, depending on an E_FSR flag in the probe data.

However, still no joice (althought a printk revealed that the FSR
ready bit was set).

The NOR flash is actually a dual-die chip, so I'm now looking into
u-boot's CONFIG_SF_DUAL_FLASH code ...

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

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

* Re: Question about SPI NOR flash
  2014-05-13 11:35       ` Holger Schurig
@ 2014-05-22 16:14         ` Holger Schurig
  0 siblings, 0 replies; 6+ messages in thread
From: Holger Schurig @ 2014-05-22 16:14 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Just to keep you informed:

I can now erase my n25q512 (JEDEC 20ba20) from Linux. To do this, I
applied the SPI-NOR patches from
http://git.infradead.org/l2-mtd.git/shortlog/refs/heads/spinor (from
tag 3.15-rc1 to HEAD). On top of it, I applied
http://patchwork.ozlabs.org/patch/341355/

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

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

end of thread, other threads:[~2014-05-22 16:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-13  8:55 Question about SPI NOR flash Holger Schurig
2014-05-13 10:00 ` Sascha Hauer
2014-05-13 10:22   ` Holger Schurig
2014-05-13 10:24     ` Sascha Hauer
2014-05-13 11:35       ` Holger Schurig
2014-05-22 16:14         ` Holger Schurig

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