]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
pytest: qspi: Fix issues with qspi_write_twice
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Fri, 23 Feb 2018 06:23:24 +0000 (11:53 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 23 Feb 2018 13:45:34 +0000 (14:45 +0100)
This patch fixes the issue with qspi_write_twice by properly
calculating the sizes, offsets and by erasing the region
before writing to it. This also removes unnecessary
erase block. Thsi fixes the issue of CRC failures in
qspi_write_twice.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
test/py/tests/test_qspi.py

index e495837f87ed80a14b08188fdd96c2d43b4cce26..5f60923bbdc5fe7e2f15def8e48879d8c832983f 100644 (file)
@@ -146,10 +146,10 @@ def test_qspi_erase_block(u_boot_console):
 # Random write till page size, random till size and full size
 def qspi_write_twice(u_boot_console):
 
-    qspi_erase_block(u_boot_console)
     addr = u_boot_utils.find_ram_base(u_boot_console)
     expected_write = "Written: OK"
     expected_read = "Read: OK"
+    expected_erase = "Erased: OK"
 
     old_size = 0
     # TODO maybe add alignment and different start for pages
@@ -163,6 +163,23 @@ def qspi_write_twice(u_boot_console):
 
         expected_crc32 = m.group(1)
         # print expected_crc32
+        if old_size % page_size:
+            old_size /= page_size
+            old_size *= page_size
+
+        if size % erase_size:
+            erasesize = size/erase_size + 1
+            erasesize *= erase_size
+
+        eraseoffset = old_size/erase_size
+        eraseoffset *= erase_size
+
+        timeout = 100000000
+        start = 0
+        with u_boot_console.temporary_timeout(timeout):
+           output = u_boot_console.run_command('sf erase %x %x' % (eraseoffset, erasesize))
+           assert expected_erase in output
+
         output = u_boot_console.run_command('sf write %x %x %x' % (addr + total_size, old_size, size))
         assert expected_write in output
         output = u_boot_console.run_command('sf read %x %x %x' % (addr + total_size + offset, old_size, size))