From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: MIME-Version: 1.0 In-Reply-To: <54043FDA.4050707@gmail.com> References: <54043FDA.4050707@gmail.com> Date: Mon, 1 Sep 2014 13:48:25 +0200 Message-ID: From: Mark Marshall Content-Type: multipart/mixed; boundary=001a11c251dea88f110501ff94da List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [RFC] MTD m25p80 3-byte addressing and boot problem To: Matteo Fortini Cc: barebox@lists.infradead.org, linux-mtd@lists.infradead.org, mike@steroidmicros.com --001a11c251dea88f110501ff94da Content-Type: text/plain; charset=UTF-8 Hi. We had the same problem here, but luckily our Flash also supported a different read command that took the larger address. I made a (small) modification to the m25p80 driver to use this command when the flash supported it. I've attached the two patches that come from my tree that are relevant. The first one (42) just changes to the page size used to access the flash, and is only needed so that you don;t get conflicts wit the second. The second patch (45) is the one of interest. These patches are against v3.2.52-rt73 from the real-time tree, and there are (obviously) other patches either side of them, but they should show what I have done. At some point (!) I'll try to push these up-stream, but as ou can see, we are well behind the curve at the moment, which makes this harder. Regards, Mark Marshall. PS. On our original prototype hardware we had no reset line connected to the flash, so even a hard reset wouldn't get things back to how they should be when Linux was changing the bank register! I think that the longer commands should be used if the flash chip supports them in preference to either bank switching or "converting" the small commands to longer ones. On 1 September 2014 11:43, Matteo Fortini wrote: > If a Linux/Barebox system is using an SPI flash of size >= 16 MB, the driver > is switching to 3-byte addressing to be able to use linear access to the > whole memory. > > This leads to the impossibility to boot a board after a warm reset, because > all bootloaders use the standard 2-byte addressing (if the board doesn't > physically reset the flash or do something similar). > > Some documentation in the following links: > http://www.at91.com/discussions/viewtopic.php/f,30/t,22849.html > https://community.freescale.com/docs/DOC-93632 > > The solution proposed on freescale forums is not final: it involves > switching back to 2-byte addressing after every access, which still leaves a > small window in which a warm reset would be fatal. > > One solution would be to use the bank command in the flash, using each 16MB > bank linearly, and changing bank depending on the address. This would be > messy for accesses which are crossing the boundary, but it is doable. > > I'm asking here for comments before I start patching the code. Right now I > resorted to stick to 2-byte addressing and leave half of my NOR (32MB) > unused. > > TIA, > M > > ______________________________________________________ > Linux MTD discussion mailing list > http://lists.infradead.org/mailman/listinfo/linux-mtd/ --001a11c251dea88f110501ff94da Content-Type: text/x-patch; charset=US-ASCII; name="0042-m25p80-Use-a-512-byte-page-size-for-Spansion-flash-s.patch" Content-Disposition: attachment; filename="0042-m25p80-Use-a-512-byte-page-size-for-Spansion-flash-s.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hzjqriyc0 RnJvbSA5ZmU5NmY5ZmU4OTNlNGY4YTQyYzM3ZGY1ZGIxZTI5ZDViYWI3MzllIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXJrIE1hcnNoYWxsIDxNYXJrLk1hcnNoYWxsQG9taWNyb24u YXQ+CkRhdGU6IFRodSwgMjUgQXByIDIwMTMgMTM6NTA6MzAgKzAyMDAKU3ViamVjdDogW1BBVENI IDQyLzk2XSBtMjVwODA6IFVzZSBhIDUxMiBieXRlIHBhZ2Ugc2l6ZSBmb3IgU3BhbnNpb24gZmxh c2gKIHMyNWZsNTEycwoKVGhlIHMyNWZsNTEycyBmbGFzaCBmcm9tIFNwbmFzaW9uIGhhcyBhIDUx MiBieXRlIHdyaXRlIHBhZ2Ugc2l6ZSwKd2hpY2ggbWVhbnMgdGhhdCB3ZSBjYW4gd3JpdGUgNTEy IGJ5dGVzIGF0IGEgdGltZSAoaW5zdGVhZCBvZiAyNTYpLgoKVGhpcyBzaW5nbGUgY2hhbmdlIG1h a2VzIHdyaXRpbmcgdG8gdGhlIGZsYXNoIGFib3V0IDJ4J3MgZmFzdGVyLgoKU2lnbmVkLW9mZi1i eTogTWFyayBNYXJzaGFsbCA8bWFyay5tYXJzaGFsbEBvbWljcm9uLmF0PgotLS0KIGRyaXZlcnMv bXRkL2RldmljZXMvbTI1cDg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pemUpLAkJCQlcCkBAIC02OTgsNyArNzA4LDcgQEAgc3RhdGlj IGNvbnN0IHN0cnVjdCBzcGlfZGV2aWNlX2lkIG0yNXBfaWRzW10gPSB7CiAJeyAiczI1c2wwNjRh IiwgIElORk8oMHgwMTAyMTYsICAgICAgMCwgIDY0ICogMTAyNCwgMTI4LCAwKSB9LAogCXsgInMy NWZsMjU2czAiLCBJTkZPKDB4MDEwMjE5LCAweDRkMDAsIDI1NiAqIDEwMjQsIDEyOCwgMCkgfSwK IAl7ICJzMjVmbDI1NnMxIiwgSU5GTygweDAxMDIxOSwgMHg0ZDAxLCAgNjQgKiAxMDI0LCA1MTIs IDApIH0sCi0JeyAiczI1Zmw1MTJzIiwgIElORk8oMHgwMTAyMjAsIDB4NGQwMCwgMjU2ICogMTAy NCwgMjU2LCAwKSB9LAorCXsgInMyNWZsNTEycyIsIElORk9QKDB4MDEwMjIwLCAweDRkMDAsIDI1 NiAqIDEwMjQsIDI1NiwgNTEyLCAwKSB9LAogCXsgInM3MGZsMDFncyIsICBJTkZPKDB4MDEwMjIx LCAweDRkMDAsIDI1NiAqIDEwMjQsIDI1NiwgMCkgfSwKIAl7ICJzMjVzbDEyODAwIiwgSU5GTygw eDAxMjAxOCwgMHgwMzAwLCAyNTYgKiAxMDI0LCAgNjQsIDApIH0sCiAJeyAiczI1c2wxMjgwMSIs IElORk8oMHgwMTIwMTgsIDB4MDMwMSwgIDY0ICogMTAyNCwgMjU2LCAwKSB9LAotLSAKMS43Ljku NQoK --001a11c251dea88f110501ff94da Content-Type: text/x-patch; charset=US-ASCII; name="0045-m25p80-Use-the-4-byte-address-read-command.patch" Content-Disposition: attachment; filename="0045-m25p80-Use-the-4-byte-address-read-command.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hzjqriys1 RnJvbSA3YzE0Yjg5NGYxODg0YmY3OTE1NDE3Y2U4Yjc0N2IxMWI2ZjYwM2M2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9t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UgKnNwaSkKIAkJZmxhc2gtPm10ZC5lcmFzZXNpemUgPSBpbmZv LT5zZWN0b3Jfc2l6ZTsKIAl9CiAKKwlmbGFzaC0+cmVhZF9vcGNvZGUgPSBPUENPREVfUkVBRDsK KwlmbGFzaC0+d3JpdGVfb3Bjb2RlID0gT1BDT0RFX1BQOworCiAJaWYgKGluZm8tPmZsYWdzICYg TTI1UF9OT19FUkFTRSkKIAkJZmxhc2gtPm10ZC5mbGFncyB8PSBNVERfTk9fRVJBU0U7CiAKLS0g CjEuNy45LjUKCg== --001a11c251dea88f110501ff94da Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox --001a11c251dea88f110501ff94da--