Issues with SPI NOR flash
Hi all,
I'm running into a problem with the SPI NOR connected to our host processor. We're using a Macronix MX25L25645GMI-08G connected to the spi1 device on an AST2500. This device is muxed between our host processor and the BMC. When our host processor is powered off, the BMC has exclusive access to it.
Anyway, the behavior is that I can read the SPI NOR without any difficulty, however, when I write to it the SPI nor appears to be filled with garbage. If I had to guess, I'd guess that the SPI driver is not waiting for the SPI NOR to complete the write operation before moving to the next block.
Here is the relevant section from our device tree:
&spi1 {
status = "okay";
flash@0 {
status = "okay";
compatible = "jedec,spi-nor", "spi-nor";
label = "host";
m25p,fast-read;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <1>;
spi-max-frequency = <50000000>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
bootloader@0 {
reg = <0x0 0x1000000>;
label = "host-
bootloader";
};
kernel@1000000 {
reg = <0x1000000
0x1000000>;
label = "host-kernel";
};
};
};
};Note that our host is also running 4.19 and has no trouble writing to the SPI NOR. The corruption seems worse when flashcp is used compared to just cp. I noticed that flashcp writes in 4K blocks. The Macronix device has a 256 byte page buffer. I have tried slowing down the bus to 5MHz and that made no difference. Note that we are currently using single bit mode for both the host and BMC processors for this flash, though we plan to move to move to QPI on the host processor later.
Before the write operation the host processor has not had any access to the SPI NOR. The host is powered down and the BMC is rebooted to force a clean state.
-Aaron
Signature · 4 lines
Aaron Williams Senior Software Engineer Marvell Semiconductor, Inc. (408) 943-7198 (510) 789-8988 (cell)
Hi Aaron,
Quoted 51 lines · Aaron Williams
Hi all,
I'm running into a problem with the SPI NOR connected to our host processor. We're using a Macronix MX25L25645GMI-08G connected to the spi1 device on an AST2500. This device is muxed between our host processor and the BMC. When our host processor is powered off, the BMC has exclusive access to it.
Anyway, the behavior is that I can read the SPI NOR without any difficulty, however, when I write to it the SPI nor appears to be filled with garbage. If I had to guess, I'd guess that the SPI driver is not waiting for the SPI NOR to complete the write operation before moving to the next block.
Here is the relevant section from our device tree:
&spi1 { status = "okay"; flash@0 { status = "okay"; compatible = "jedec,spi-nor", "spi-nor"; label = "host"; m25p,fast-read; spi-tx-bus-width = <1>; spi-rx-bus-width = <1>; spi-max-frequency = <50000000>; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; bootloader@0 { reg = <0x0 0x1000000>; label = "host- bootloader"; }; kernel@1000000 { reg = <0x1000000 0x1000000>; label = "host-kernel"; }; }; }; };Note that our host is also running 4.19 and has no trouble writing to the SPI NOR. The corruption seems worse when flashcp is used compared to just cp. I noticed that flashcp writes in 4K blocks. The Macronix device has a 256 byte page buffer. I have tried slowing down the bus to 5MHz and that made no difference. Note that we are currently using single bit mode for both the host and BMC processors for this flash, though we plan to move to move to QPI on the host processor later.
Quoted 4 lines
Before the write operation the host processor has not had any access to the SPI NOR. The host is powered down and the BMC is rebooted to force a clean state.
Did you find the problem? I've added Cédric to Cc in case you haven't - he should be able to answer questions about the flash stack.
Andrew
Hi Andrew,
I did, thank you.
The issue is that I had to unbind the driver when powering on our SOC and bind it again when we power our SOC off. That solved the problem and allows the SPI NOR to be reinitialized into the proper mode. Right now I have this in our power management process.
-Aaron
Quoted 81 lines · PST Andrew Jeffery
External Email
----------------------------------------------------------------------
Hi Aaron,Quoted 66 lines · Aaron Williams
Hi all,
I'm running into a problem with the SPI NOR connected to our host processor. We're using a Macronix MX25L25645GMI-08G connected to the spi1 device on an AST2500. This device is muxed between our host processor and the BMC. When our host processor is powered off, the BMC has exclusive access to it.
Anyway, the behavior is that I can read the SPI NOR without any difficulty,
however, when I write to it the SPI nor appears to be filled with garbage. If I had to guess, I'd guess that the SPI driver is not waiting for the SPI NOR to complete the write operation before moving to the next block.Here is the relevant section from our device tree:
&spi1 {
status = "okay"; flash@0 { status = "okay"; compatible = "jedec,spi-nor", "spi-nor"; label = "host"; m25p,fast-read; spi-tx-bus-width = <1>; spi-rx-bus-width = <1>; spi-max-frequency = <50000000>; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; bootloader@0 { reg = <0x0 0x1000000>; label = "host-bootloader";
}; kernel@1000000 { reg = <0x1000000
0x1000000>;label = "host-kernel"; }; }; };};
Note that our host is also running 4.19 and has no trouble writing to the SPI NOR. The corruption seems worse when flashcp is used compared to just cp. I noticed that flashcp writes in 4K blocks. The Macronix device has a 256 byte page buffer. I have tried slowing down the bus to 5MHz and that made no difference. Note that we are currently using single bit mode for both the host and BMC processors for this flash, though we plan to move to move to QPI on the host processor later.
Quoted 4 lines
Before the write operation the host processor has not had any access to the
SPI NOR. The host is powered down and the BMC is rebooted to force a clean state.Did you find the problem? I've added Cédric to Cc in case you haven't - he should be able to answer questions about the flash stack.
Andrew
Signature · 4 lines
Aaron Williams Senior Software Engineer Marvell Semiconductor, Inc. (408) 943-7198 (510) 789-8988 (cell)
Hello,
Quoted 9 lines · Andrew Jeffery
Hi Aaron,
Quoted 6 lines · Aaron Williams
Hi all,
I'm running into a problem with the SPI NOR connected to our host processor. We're using a Macronix MX25L25645GMI-08G connected to the spi1 device on an AST2500. This device is muxed between our host processor and the BMC. When our host processor is powered off, the BMC has exclusive access to it.
yes but there could be different (incompatible) states in the SPI controller drivers on each kernel (BMC, Host) and in the flash module as well. That is why having only one side doing the control is usually preferred.
Quoted 4 lines
Quoted 4 lines
Anyway, the behavior is that I can read the SPI NOR without any difficulty, however, when I write to it the SPI nor appears to be filled with garbage. I had to guess, I'd guess that the SPI driver is not waiting for the SPI NOR to complete the write operation before moving to the next block.
When the host is powered off, you seem to be able to read the PNOR correctly, (I assume you did the write from the host side then) but the first write from the BMC trashes the contents ?
Quoted 31 lines
Quoted 31 lines
Here is the relevant section from our device tree:
&spi1 { status = "okay"; flash@0 { status = "okay"; compatible = "jedec,spi-nor", "spi-nor"; label = "host"; m25p,fast-read; spi-tx-bus-width = <1>; spi-rx-bus-width = <1>; spi-max-frequency = <50000000>; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; bootloader@0 { reg = <0x0 0x1000000>; label = "host- bootloader"; }; kernel@1000000 { reg = <0x1000000 0x1000000>; label = "host-kernel"; }; }; }; };
Quoted 7 lines
Quoted 7 lines
Note that our host is also running 4.19 and has no trouble writing to the SPI NOR. The corruption seems worse when flashcp is used compared to just cp. I noticed that flashcp writes in 4K blocks. The Macronix device has a 256 byte page buffer. I have tried slowing down the bus to 5MHz and that made no difference. Note that we are currently using single bit mode for both the host and BMC processors for this flash, though we plan to move to move to QPI on the host processor later.
What about 4BYTE mode ? have you checked in which mode the flash device is left by the host ? That could be a problem.
C.
Quoted 9 lines
Quoted 4 lines
Before the write operation the host processor has not had any access to the SPI NOR. The host is powered down and the BMC is rebooted to force a clean state.
Did you find the problem? I've added Cédric to Cc in case you haven't - he should be able to answer questions about the flash stack. Andrew
Hi,
In this case, only one side controls it at a time. The drivers are incompatible. The BMC relinquishes control before the SOC is powered on and cannot access it again until after the SOC is powered off. By using unbind and bind on the BMC it allows the BMC to reinitialize the SPI NOR into the proper mode when it binds (after the SOC is powered off). There is also a reset control line driven by the BMC to the SPI NOR as well.
So the procedure is when power is on to the SOC the BMC cannot access the SPI NOR (there is also a mux). When the SOC is powered off the SPI NOR is reset and the mux switches to the BMC which then binds the driver to the SPI NOR, initializing it so it can write to the SPI NOR.
Reads don't seem to be a problem when switching between the SOC and the BMC and the SOC has hardware support for arbitration but this is not used (and the current BMC driver lacks support for doing arbitration).
-Aaron
Quoted 97 lines · PST Cédric Le Goater
External Email
----------------------------------------------------------------------
Hello,Quoted 10 lines · Andrew Jeffery
Hi Aaron,
Quoted 7 lines · Aaron Williams
Hi all,
I'm running into a problem with the SPI NOR connected to our host processor. We're using a Macronix MX25L25645GMI-08G connected to the spi1 device on an AST2500. This device is muxed between our host processor and the BMC. When our host processor is powered off, the BMC has exclusive access to it.
yes but there could be different (incompatible) states in the SPI controller drivers on each kernel (BMC, Host) and in the flash module as well. That is why having only one side doing the control is usually preferred.
Quoted 6 lines
Quoted 6 lines
Anyway, the behavior is that I can read the SPI NOR without any difficulty,
however, when I write to it the SPI nor appears to be filled with garbage.
I had to guess, I'd guess that the SPI driver is not waiting for the SPI NOR to complete the write operation before moving to the next block.When the host is powered off, you seem to be able to read the PNOR correctly, (I assume you did the write from the host side then) but the first write from the BMC trashes the contents ?
Quoted 44 lines
Quoted 44 lines
Here is the relevant section from our device tree:
&spi1 {
status = "okay"; flash@0 { status = "okay"; compatible = "jedec,spi-nor", "spi-nor"; label = "host"; m25p,fast-read; spi-tx-bus-width = <1>; spi-rx-bus-width = <1>; spi-max-frequency = <50000000>; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; bootloader@0 { reg = <0x0 0x1000000>; label = "host-bootloader";
}; kernel@1000000 { reg = <0x1000000
0x1000000>;label = "host-kernel"; }; }; };};
Quoted 7 lines
Quoted 7 lines
Note that our host is also running 4.19 and has no trouble writing to the SPI NOR. The corruption seems worse when flashcp is used compared to just cp. I noticed that flashcp writes in 4K blocks. The Macronix device has a 256 byte page buffer. I have tried slowing down the bus to 5MHz and that made no difference. Note that we are currently using single bit mode for both the host and BMC processors for this flash, though we plan to move to move to QPI on the host processor later.
What about 4BYTE mode ? have you checked in which mode the flash device is left by the host ? That could be a problem.
C.
Quoted 9 lines
Quoted 5 lines
Before the write operation the host processor has not had any access to the
SPI NOR. The host is powered down and the BMC is rebooted to force a clean
state.Did you find the problem? I've added Cédric to Cc in case you haven't - he should be able to answer questions about the flash stack. Andrew
Signature · 4 lines
Aaron Williams Senior Software Engineer Marvell Semiconductor, Inc. (408) 943-7198 (510) 789-8988 (cell)
Hi,
I forgot to add that the host does use 4 byte mode, but with the reset this works.
-Aaron
Quoted 97 lines · PST Cédric Le Goater
External Email
----------------------------------------------------------------------
Hello,Quoted 10 lines · Andrew Jeffery
Hi Aaron,
Quoted 7 lines · Aaron Williams
Hi all,
I'm running into a problem with the SPI NOR connected to our host processor. We're using a Macronix MX25L25645GMI-08G connected to the spi1 device on an AST2500. This device is muxed between our host processor and the BMC. When our host processor is powered off, the BMC has exclusive access to it.
yes but there could be different (incompatible) states in the SPI controller drivers on each kernel (BMC, Host) and in the flash module as well. That is why having only one side doing the control is usually preferred.
Quoted 6 lines
Quoted 6 lines
Anyway, the behavior is that I can read the SPI NOR without any difficulty,
however, when I write to it the SPI nor appears to be filled with garbage.
I had to guess, I'd guess that the SPI driver is not waiting for the SPI NOR to complete the write operation before moving to the next block.When the host is powered off, you seem to be able to read the PNOR correctly, (I assume you did the write from the host side then) but the first write from the BMC trashes the contents ?
Quoted 44 lines
Quoted 44 lines
Here is the relevant section from our device tree:
&spi1 {
status = "okay"; flash@0 { status = "okay"; compatible = "jedec,spi-nor", "spi-nor"; label = "host"; m25p,fast-read; spi-tx-bus-width = <1>; spi-rx-bus-width = <1>; spi-max-frequency = <50000000>; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; bootloader@0 { reg = <0x0 0x1000000>; label = "host-bootloader";
}; kernel@1000000 { reg = <0x1000000
0x1000000>;label = "host-kernel"; }; }; };};
Quoted 7 lines
Quoted 7 lines
Note that our host is also running 4.19 and has no trouble writing to the SPI NOR. The corruption seems worse when flashcp is used compared to just cp. I noticed that flashcp writes in 4K blocks. The Macronix device has a 256 byte page buffer. I have tried slowing down the bus to 5MHz and that made no difference. Note that we are currently using single bit mode for both the host and BMC processors for this flash, though we plan to move to move to QPI on the host processor later.
What about 4BYTE mode ? have you checked in which mode the flash device is left by the host ? That could be a problem.
C.
Quoted 9 lines
Quoted 5 lines
Before the write operation the host processor has not had any access to the
SPI NOR. The host is powered down and the BMC is rebooted to force a clean
state.Did you find the problem? I've added Cédric to Cc in case you haven't - he should be able to answer questions about the flash stack. Andrew
Signature · 4 lines
Aaron Williams Senior Software Engineer Marvell Semiconductor, Inc. (408) 943-7198 (510) 789-8988 (cell)