Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minipack: spi_util.sh improvement (facebook#102)
Summary: # Summary: 1. replace "m95m02-util" with "dd" for phy eeprom erase/read/write 2. add debug message for flash erase/read/write 3. add check_parameter() function if the format is not matched will display usage 4. exit program directly in error condition 5. modify usage description # Test plan: ## M95M02 TEST ### Original eeprom image root@bmc-oob: # spi_util.sh read spi2 PIM1 PHY1_EE whole_image_spi_D011_A.bin Select PIM Device: PHY1_EE Config SPI2 Done. 1024+0 records in 1024+0 records out ### Erasing m95m02 test root@bmc-oob: # spi_util.sh erase spi2 PIM1 PHY1_EE Select PIM Device: PHY1_EE Config SPI2 Done. 1024+0 records in 1024+0 records out root@bmc-oob: # spi_util.sh read spi2 PIM1 PHY1_EE erase_content Select PIM Device: PHY1_EE Config SPI2 Done. 1024+0 records in 1024+0 records out root@bmc-oob: # hexdump -C erase_content 00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00040000 ### Create a small size file to test padding function root@bmc-oob: # echo "fill 0xff test" > fill_test root@bmc-oob: # hexdump -C fill_test 00000000 66 69 6c 6c 20 30 78 66 66 20 74 65 73 74 0a |fill 0xff test.| 0000000f ### Writing m95m02 with a small size image (padding 0xff test) root@bmc-oob: # spi_util.sh write spi2 PIM1 PHY1_EE fill_test Select PIM Device: PHY1_EE Config SPI2 Done. 1024+0 records in 1024+0 records out 1+0 records in 1+0 records out 1024+0 records in 1024+0 records out root@bmc-oob: # spi_util.sh read spi2 PIM1 PHY1_EE read_back_fill_test Select PIM Device: PHY1_EE Config SPI2 Done. 1024+0 records in 1024+0 records out root@bmc-oob: # hexdump -C read_back_fill_test 00000000 66 69 6c 6c 20 30 78 66 66 20 74 65 73 74 0a ff |fill 0xff test..| 00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00040000 root@bmc-oob: # md5sum whole_image_spi_D011_A.bin 8639ab4af04e54da033f17973f2d5779 whole_image_spi_D011_A.bin ### Writing m95m02 with the same size image root@bmc-oob: # spi_util.sh write spi2 PIM1 PHY1_EE whole_image_spi_D011_A.bin Select PIM Device: PHY1_EE Config SPI2 Done. 1024+0 records in 1024+0 records out 1024+0 records in 1024+0 records out root@bmc-oob: # spi_util.sh read spi2 PIM1 PHY1_EE read_back_D011 Select PIM Device: PHY1_EE Config SPI2 Done. 1024+0 records in 1024+0 records out root@bmc-oob: # md5sum read_back_D011 8639ab4af04e54da033f17973f2d5779 read_back_D011 ## DOMFPGA TEST ### Back up original file root@bmc-oob: # spi_util.sh read spi2 PIM1 DOM_FPGA_FLASH dom Select PIM Device: DOM_FPGA_FLASH Config SPI2 Done. delay loop is unreliable, trying to continue flashrom v0.9.8-r1888 on Linux 4.1.51 (armv6l) flashrom is free software, get the source code at http://www.flashrom.org Calibrating delay loop... delay loop is unreliable, trying to continue OK. Found Winbond flash chip "W25Q32.V" (4096 kB, SPI) on linux_spi. Reading flash... done. ### Create a small size file to test padding 0xff root@bmc-oob: # echo "a small size file" > test_file root@bmc-oob: # spi_util.sh write spi2 PIM1 DOM_FPGA_FLASH test_file Select PIM Device: DOM_FPGA_FLASH Config SPI2 Done. delay loop is unreliable, trying to continue 1+0 records in 1+0 records out delay loop is unreliable, trying to continue flashrom v0.9.8-r1888 on Linux 4.1.51 (armv6l) flashrom is free software, get the source code at http://www.flashrom.org Calibrating delay loop... delay loop is unreliable, trying to continue OK. Found Winbond flash chip "W25Q32.V" (4096 kB, SPI) on linux_spi. Reading old flash chip contents... done. Erasing and writing flash chip... Erase/write done. Verifying flash... VERIFIED. ### Read back and dump root@bmc-oob: # spi_util.sh read spi2 PIM1 DOM_FPGA_FLASH read_back_test Select PIM Device: DOM_FPGA_FLASH Config SPI2 Done. flashrom v0.9.8-r1888 on Linux 4.1.51 (armv6l) flashrom is free software, get the source code at http://www.flashrom.org Calibrating delay loop... delay loop is unreliable, trying to continue OK. Found Winbond flash chip "W25Q32.V" (4096 kB, SPI) on linux_spi. Reading flash... done. root@bmc-oob: # hexdump -C read_back_test 00000000 61 20 73 6d 61 6c 6c 20 73 69 7a 65 20 66 69 6c |a small size fil| 00000010 65 0a ff ff ff ff ff ff ff ff ff ff ff ff ff ff |e...............| 00000020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00400000 ### Read the original file checksum root@bmc-oob: # md5sum dom 92fc035681faf6fbf4c4d49f9bae7ded dom ### Write back the original file (size is equal to flash) root@bmc-oob: # spi_util.sh write spi2 PIM1 DOM_FPGA_FLASH dom Select PIM Device: DOM_FPGA_FLASH Config SPI2 Done. delay loop is unreliable, trying to continue delay loop is unreliable, trying to continue flashrom v0.9.8-r1888 on Linux 4.1.51 (armv6l) flashrom is free software, get the source code at http://www.flashrom.org Calibrating delay loop... delay loop is unreliable, trying to continue OK. Found Winbond flash chip "W25Q32.V" (4096 kB, SPI) on linux_spi. Reading old flash chip contents... done. Erasing and writing flash chip... Erase/write done. Verifying flash... VERIFIED. ### Read again and compare the checksum root@bmc-oob: # spi_util.sh read spi2 PIM1 DOM_FPGA_FLASH dom Select PIM Device: DOM_FPGA_FLASH Config SPI2 Done. delay loop is unreliable, trying to continue flashrom v0.9.8-r1888 on Linux 4.1.51 (armv6l) flashrom is free software, get the source code at http://www.flashrom.org Calibrating delay loop... delay loop is unreliable, trying to continue OK. Found Winbond flash chip "W25Q32.V" (4096 kB, SPI) on linux_spi. Reading flash... done. root@bmc-oob: # md5sum dom 92fc035681faf6fbf4c4d49f9bae7ded dom ## Usage display root@bmc-oob: # spi_util.sh Usage: spi_util.sh \<op> spi1 \<spi1 device> \<file> spi_util.sh \<op> spi2 \<pim#> \<spi2 device> \<file> \<op> : read, write, erase \<spi1 device> : IOB_FPGA_FLASH, TH3_FLASH, BCM5396_EE, BACKUP_BIOS \<pim#> : PIM1, PIM2, PIM3, PIM4, PIM5, PIM6, PIM7, PIM8 \<spi2 device> : PHY1_EE, PHY2_EE, PH3_EE, PHY4_EE, DOM_FPGA_FLASH Examples: spi_util.sh write spi1 IOB_FPGA_FLASH iob.bit spi_util.sh read spi2 PIM1 PHY1_EE image.bin spi_util.sh erase spi2 PIM1 DOM_FPGA_FLASH Pull Request resolved: facebookexternal/openbmc.accton#102 Reviewed By: mikechoifb fbshipit-source-id: 30b36d994
- Loading branch information