sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
PATCH v2 1/1 sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
The content of Bank Address Register (BAR) is volatile. It is cleared after power cycle or reset command (RESET F0h).
Some memories (like e.g. s25fl256s) use it to access memory larger than 0x1000000 (16 MiB).
The problem shows up when one:
1. Reads/writes/erases memory > 16 MiB
2. Calls "reset" u-boot command (which is not causing BAR to be cleared)
In the above scenario, the SoC ROM sends 0x000000 address to read SPL. Unfortunately, the BA24 bit is still set and hence it receives content from 0x1000000 (16 MiB) memory address.
As a result the SoC aborts and we hang. Only power cycle can take the SoC out of this state.
How to reproduce/test:
sf probe; sf erase 0x1200000 0x800000; reset
sf probe; sf erase 0x1200000 0x800000; sf write 0x11000000 0x1200000 0x800000; reset sf probe; sf read 0x11000000 0x1200000 0x800000; reset
---
Changes in v2:
- Rename cleanup_bar() to clean_bar()
- Rewrite in-code comments
--- drivers/mtd/spi/spi_flash.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/mtd/spi/spi_flash.c +33 -0
@@ -113,6 +113,27 @@ static int write_cr(struct spi_flash *flash, u8 wc)#endif #ifdef CONFIG_SPI_FLASH_BAR +/* +* This "cleanup" is necessary in a situation when one was accessing +* spi flash memory > 16 MiB by using Bank Address Register's BA24 bit. +* +* After it the BA24 bit shall be cleared to allow access to correct +* memory region after SW reset (by calling "reset" command). +* +* Otherwise, the BA24 bit may be left set and then after reset, the +* ROM would read/write/erase SPL from 16 MiB * bank_sel address. +*/ +static int clean_bar (struct spi_flash *flash) +{ +u8 cmd, bank_sel =0 ; + +if (flash->bank_curr ==0 ) +return 0 ; + cmd = flash->bank_write_cmd; + +return spi_flash_write_common (flash, &cmd,1 , &bank_sel,1 ); +} +static int write_bar (struct spi_flash *flash,u32 offset) {u8 cmd, bank_sel;
@@ -339,6 +360,10 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len) len -= erase_size; } +#ifdef CONFIG_SPI_FLASH_BAR + ret =clean_bar (flash); +#endif +return ret; }
@@ -397,6 +422,10 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, offset += chunk_len; } +#ifdef CONFIG_SPI_FLASH_BAR + ret =clean_bar (flash); +#endif +return ret; }
@@ -500,6 +529,10 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, data += read_len; } +#ifdef CONFIG_SPI_FLASH_BAR + ret =clean_bar (flash); +#endif +free (cmd);return ret; }
Signature · 1 line
2.1.4
PATCH v2 1/1 sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
Quoted 17 lines · Lukasz Majewski
The content of Bank Address Register (BAR) is volatile. It is cleared after power cycle or reset command (RESET F0h).
Some memories (like e.g. s25fl256s) use it to access memory larger than
0x1000000(16 MiB).The problem shows up when one:
1. Reads/writes/erases memory > 16 MiB
2. Calls "reset" u-boot command (which is not causing BAR to be cleared)In the above scenario, the SoC ROM sends
0x000000address to read SPL. Unfortunately, the BA24 bit is still set and hence it receives content from0x1000000(16 MiB) memory address.
As a result the SoC aborts and we hang. Only power cycle can take the SoC out of this state.
Quoted 5 lines
How to reproduce/test:
sf probe; sf erase
0x12000000x800000; reset
sf probe; sf erase0x12000000x800000; sf write0x110000000x12000000x800000; reset sf probe; sf read0x110000000x12000000x800000; reset
Sorry, I didn't follow this test.. are you writing on at 18MiB offset and doing reset how it will reproduce? because we can write it 0x0 and after reset the ROM look for 16MiB on this flash this is what you concern about right?
thanks!
Signature · 4 lines
Jagan Teki Free Software Engineer | www.openedev.com U-Boot, Linux | Upstream Maintainer Hyderabad, India.
PATCH v2 1/1 sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
Quoted 18 lines · Jagan Teki
Quoted 17 lines · Lukasz Majewski
The content of Bank Address Register (BAR) is volatile. It is cleared after power cycle or reset command (RESET F0h).
Some memories (like e.g. s25fl256s) use it to access memory larger than
0x1000000(16 MiB).The problem shows up when one:
1. Reads/writes/erases memory > 16 MiB
2. Calls "reset" u-boot command (which is not causing BAR to be cleared)In the above scenario, the SoC ROM sends
0x000000address to read SPL. Unfortunately, the BA24 bit is still set and hence it receives content from0x1000000(16 MiB) memory address.
As a result the SoC aborts and we hang. Only power cycle can take the SoC out of this state.
Quoted 8 lines
Quoted 5 lines
How to reproduce/test:
sf probe; sf erase
0x12000000x800000; reset
sf probe; sf erase0x12000000x800000; sf write0x110000000x12000000x800000; reset sf probe; sf read0x110000000x12000000x800000; resetSorry, I didn't follow this test.. are you writing on at 18MiB offset and doing reset how it will reproduce?
Please start with erase test case first.
The problem shows up when you try to access SPI-NOR memory > 16 MiB. It works with current code, since BAR is adjusted properly.
Then after this access (without removing power), please type 'reset' command.
You will observe, that the board will not boot (if SPI-NOR is a booting device).
The problem is that ROM bootloader tries to access 0x0 address, but BA24 (in the SPI-NOR controller) is programmed from last operation (to 0x1). Hence, the ROM Boot reads from 0x1000000 address.
Quoted 3 lines
because we can write it
0x0and
after reset the ROM look for 16MiB on this flash this is what you concern about right?
The problem is with not clearing bit BA24 after each operation. This causes hangs after "reset" command.
Quoted 3 lines
thanks!
Signature · 9 lines
Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
PATCH v2 1/1 sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
Hi Jagan,
Quoted 37 lines · Jagan Teki
Quoted 20 lines · Lukasz Majewski
Quoted 19 lines
The content of Bank Address Register (BAR) is volatile. It is cleared after power cycle or reset command (RESET F0h).
Some memories (like e.g. s25fl256s) use it to access memory larger than
0x1000000(16 MiB).The problem shows up when one:
1. Reads/writes/erases memory > 16 MiB
2. Calls "reset" u-boot command (which is not causing BAR to be cleared)In the above scenario, the SoC ROM sends
0x000000address to read SPL. Unfortunately, the BA24 bit is still set and hence it receives content from0x1000000(16 MiB) memory address.
As a result the SoC aborts and we hang. Only power cycle can take the SoC out of this state.How to reproduce/test:
Quoted 7 lines
Quoted 4 lines
sf probe; sf erase
0x12000000x800000; reset
sf probe; sf erase0x12000000x800000; sf write0x110000000x12000000x800000; reset
sf probe; sf read0x110000000x12000000x800000; resetSorry, I didn't follow this test.. are you writing on at 18MiB offset and doing reset how it will reproduce?
Please start with erase test case first.
The problem shows up when you try to access SPI-NOR memory > 16 MiB. It works with current code, since BAR is adjusted properly.
Then after this access (without removing power), please type 'reset' command.
Quoted 6 lines
You will observe, that the board will not boot (if SPI-NOR is a booting device).
The problem is that ROM bootloader tries to access
0x0address, but BA24 (in the SPI-NOR controller) is programmed from last operation (to0x1). Hence, the ROM Boot reads from0x1000000address.
And maybe some explanation why and how it was discovered.
I was storing in u-boot rootfs on SPI-NOR. This data crossed 16 MiB boundary on my Spansion memory.
After this operation I wanted to move forward with factory setup procedure and executed "reset".
The board hanged and I had to power cycle it to have it working again.
Quoted 15 lines
Quoted 5 lines
because we can write it
0x0and
after reset the ROM look for 16MiB on this flash this is what you concern about right?The problem is with not clearing bit BA24 after each operation. This causes hangs after "reset" command.
Quoted 3 lines
thanks!
Signature · 9 lines
Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
PATCH v2 1/1 sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
In reply to Łukasz MajewskiQuoted 41 lines · Å�ukasz Majewski
Quoted 22 lines · Jagan Teki
Quoted 20 lines · Lukasz Majewski
The content of Bank Address Register (BAR) is volatile. It is cleared after power cycle or reset command (RESET F0h).
Some memories (like e.g. s25fl256s) use it to access memory larger than
0x1000000(16 MiB).The problem shows up when one:
1. Reads/writes/erases memory > 16 MiB
2. Calls "reset" u-boot command (which is not causing BAR to be cleared)In the above scenario, the SoC ROM sends
0x000000address to read SPL. Unfortunately, the BA24 bit is still set and hence it receives content from0x1000000(16 MiB) memory address.
As a result the SoC aborts and we hang. Only power cycle can take the SoC out of this state.How to reproduce/test:
Quoted 8 lines
Quoted 4 lines
sf probe; sf erase
0x12000000x800000; reset
sf probe; sf erase0x12000000x800000; sf write0x110000000x12000000x800000; reset
sf probe; sf read0x110000000x12000000x800000; resetSorry, I didn't follow this test.. are you writing on at 18MiB offset and doing reset how it will reproduce?
Please start with erase test case first.
The problem shows up when you try to access SPI-NOR memory > 16 MiB. It works with current code, since BAR is adjusted properly.
Then after this access (without removing power), please type 'reset' command.
Quoted 11 lines
You will observe, that the board will not boot (if SPI-NOR is a booting device).
The problem is that ROM bootloader tries to access
0x0address, but BA24 (in the SPI-NOR controller) is programmed from last operation (to0x1). Hence, the ROM Boot reads from0x1000000address.Quoted 3 lines
because we can write it
0x0and
after reset the ROM look for 16MiB on this flash this is what you concern about right?
Yes, I understand ROM look at 16MiB, but the test-case you have erase is from 18MiB right, it should be 0x0 on the test case right?
thanks!
Signature · 4 lines
Jagan Teki Free Software Engineer | www.openedev.com U-Boot, Linux | Upstream Maintainer Hyderabad, India.
PATCH v2 1/1 sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
Hi Jagan,
Quoted 50 lines · Å�ukasz Majewski
Quoted 49 lines · Jagan Teki
Quoted 22 lines · Lukasz Majewski
Quoted 20 lines
The content of Bank Address Register (BAR) is volatile. It is cleared after power cycle or reset command (RESET F0h).
Some memories (like e.g. s25fl256s) use it to access memory larger than
0x1000000(16 MiB).The problem shows up when one:
1. Reads/writes/erases memory > 16 MiB
2. Calls "reset" u-boot command (which is not causing BAR to be cleared)In the above scenario, the SoC ROM sends
0x000000address to read SPL. Unfortunately, the BA24 bit is still set and hence it receives content from0x1000000(16 MiB) memory address.
As a result the SoC aborts and we hang. Only power cycle can take the SoC out of this state.How to reproduce/test:
Quoted 8 lines
Quoted 4 lines
sf probe; sf erase
0x12000000x800000; reset
sf probe; sf erase0x12000000x800000; sf write0x110000000x12000000x800000; reset
sf probe; sf read0x110000000x12000000x800000; resetSorry, I didn't follow this test.. are you writing on at 18MiB offset and doing reset how it will reproduce?
Please start with erase test case first.
The problem shows up when you try to access SPI-NOR memory > 16 MiB. It works with current code, since BAR is adjusted properly.
Then after this access (without removing power), please type 'reset' command.
You will observe, that the board will not boot (if SPI-NOR is a booting device).
The problem is that ROM bootloader tries to access
0x0address, but BA24 (in the SPI-NOR controller) is programmed from last operation (to0x1). Hence, the ROM Boot reads from0x1000000address.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
because we can write it
0x0and
after reset the ROM look for 16MiB on this flash this is what you concern about right?Yes, I understand ROM look at 16MiB, but the test-case you have erase is from 18MiB right, it should be
0x0on the test case right?
No it is correct.
The value 0x12000000 must only be > 16 MiB. After accessing this location, the BA24 bit is set.
Then after "reset" the BA24 is still set and hence BOOT ROM reads from wrong address.
Quoted 3 lines
thanks!
Signature · 9 lines
Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
PATCH v2 1/1 sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
Quoted 70 lines · Łukasz Majewski
Hi Jagan,
Quoted 58 lines · Łukasz Majewski
Quoted 57 lines · Jagan Teki
Quoted 32 lines · Lukasz Majewski
Quoted 20 lines
The content of Bank Address Register (BAR) is volatile. It is cleared after power cycle or reset command (RESET F0h).
Some memories (like e.g. s25fl256s) use it to access memory larger than
0x1000000(16 MiB).The problem shows up when one:
1. Reads/writes/erases memory > 16 MiB
2. Calls "reset" u-boot command (which is not causing BAR to be cleared)In the above scenario, the SoC ROM sends
0x000000address to read SPL. Unfortunately, the BA24 bit is still set and hence it receives content from0x1000000(16 MiB) memory address.
As a result the SoC aborts and we hang. Only power cycle can take the SoC out of this state.Quoted 6 lines
How to reproduce/test:
sf probe; sf erase
0x12000000x800000; reset
sf probe; sf erase0x12000000x800000; sf write0x110000000x12000000x800000; reset
sf probe; sf read0x110000000x12000000x800000; resetQuoted 2 lines
Sorry, I didn't follow this test.. are you writing on at 18MiB offset and doing reset how it will reproduce?
Please start with erase test case first.
The problem shows up when you try to access SPI-NOR memory > 16 MiB. It works with current code, since BAR is adjusted properly.
Then after this access (without removing power), please type 'reset' command.
You will observe, that the board will not boot (if SPI-NOR is a booting device).
The problem is that ROM bootloader tries to access
0x0address, but BA24 (in
the SPI-NOR controller) is programmed from last operation (to0x1). Hence,
the ROM Boot reads from0x1000000address.Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
because we can write it
0x0and
after reset the ROM look for 16MiB on this flash this is what you concern about right?Yes, I understand ROM look at 16MiB, but the test-case you have erase is from 18MiB right, it should be
0x0on the test case right?
Quoted 7 lines
No it is correct.
The value
0x12000000must only be > 16 MiB. After accessing this location, the BA24 bit is set.Then after "reset" the BA24 is still set and hence BOOT ROM reads from wrong address.
OK, I was thinking in other way around even that has similar issue.
thanks!
Signature · 4 lines
Jagan Teki Free Software Engineer | www.openedev.com U-Boot, Linux | Upstream Maintainer Hyderabad, India.
PATCH v2 1/1 sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
In reply to Lukasz MajewskiQuoted 39 lines · Lukasz Majewski
The content of Bank Address Register (BAR) is volatile. It is cleared after power cycle or reset command (RESET F0h).
Some memories (like e.g. s25fl256s) use it to access memory larger than
0x1000000(16 MiB).The problem shows up when one:
1. Reads/writes/erases memory > 16 MiB
2. Calls "reset" u-boot command (which is not causing BAR to be cleared)In the above scenario, the SoC ROM sends
0x000000address to read SPL. Unfortunately, the BA24 bit is still set and hence it receives content from0x1000000(16 MiB) memory address.
As a result the SoC aborts and we hang. Only power cycle can take the SoC out of this state.How to reproduce/test:
sf probe; sf erase
0x12000000x800000; reset
sf probe; sf erase0x12000000x800000; sf write0x110000000x12000000x800000; reset sf probe; sf read0x110000000x12000000x800000; resetSigned-off-by Lukasz Majewski <[email protected]>---
Changes in v2:- Rename
cleanup_bar()toclean_bar()
- Rewrite in-code comments--- drivers/mtd/spi/spi_flash.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)drivers/mtd/spi/spi_flash.c +0
-0
drivers/mtd/spi/spi_flash.c static int write_cr(struct spi_flash *flash, u8 wc) · line 117
Quoted 5 lines
drivers/mtd/spi/spi_flash.c +2
-0@@ -113,6 +113,27 @@ static int write_cr(struct spi_flash *flash, u8 wc)#endif #ifdef CONFIG_SPI_FLASH_BAR +/* +* This "cleanup" is necessary in a situation when one was accessing
Update cleanup with clean_bar
Applied to u-boot-spi/master
thanks!
Signature · 4 lines
Jagan Teki Free Software Engineer | www.openedev.com U-Boot, Linux | Upstream Maintainer Hyderabad, India.
PATCH v2 1/1 sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation
Quoted 42 lines · Jagan Teki
Quoted 41 lines · Lukasz Majewski
The content of Bank Address Register (BAR) is volatile. It is cleared after power cycle or reset command (RESET F0h).
Some memories (like e.g. s25fl256s) use it to access memory larger than
0x1000000(16 MiB).The problem shows up when one:
1. Reads/writes/erases memory > 16 MiB
2. Calls "reset" u-boot command (which is not causing BAR to be cleared)In the above scenario, the SoC ROM sends
0x000000address to read SPL. Unfortunately, the BA24 bit is still set and hence it receives content from0x1000000(16 MiB) memory address.
As a result the SoC aborts and we hang. Only power cycle can take the SoC out of this state.How to reproduce/test:
sf probe; sf erase
0x12000000x800000; reset
sf probe; sf erase0x12000000x800000; sf write0x110000000x12000000x800000; reset sf probe; sf read0x110000000x12000000x800000; resetSigned-off-by Lukasz Majewski <[email protected]>---
Changes in v2:- Rename
cleanup_bar()toclean_bar()
- Rewrite in-code comments--- drivers/mtd/spi/spi_flash.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)drivers/mtd/spi/spi_flash.c +0
-0@@ -113,6 +113,27 @@ static int write_cr(struct spi_flash *flash, u8 wc)#endif
Quoted 7 lines
drivers/mtd/spi/spi_flash.c static int write_cr(struct spi_flash *flash, u8 wc) · line 117
Quoted 3 lines
drivers/mtd/spi/spi_flash.c +2
-0#ifdef CONFIG_SPI_FLASH_BAR +/* +* This "cleanup" is necessary in a situation when one was accessing Update cleanup with
clean_barApplied to u-boot-spi/master
Thanks :-)
Quoted 3 lines
thanks!
Signature · 9 lines
Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de