Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making the except block more explicit, to catch OSError. #102

Open
mohitanand001 opened this issue May 28, 2019 · 2 comments
Open

Making the except block more explicit, to catch OSError. #102

mohitanand001 opened this issue May 28, 2019 · 2 comments

Comments

@mohitanand001
Copy link
Contributor

try:
currentPath = os.getcwd()
commonPath = currentPath.replace('fbtp/unittests', 'common')
sys.path.insert(0, commonPath)
except Exception:
pass

Can the above snippet be changed to the following?

 try: 
     currentPath = os.getcwd() 
     commonPath = currentPath.replace('fbtp/unittests', 'common') 
     sys.path.insert(0, commonPath) 
 except OSError: 
     pass

Can I raise a PR for this?

@benwei13
Copy link
Contributor

benwei13 commented Jun 7, 2019

Hi @farziengineer , that's a great point! Please raise a PR. Thank you!

facebook-github-bot pushed a commit that referenced this issue Aug 17, 2019
Summary:
As title
Pull Request resolved: facebookexternal/openbmc.celestica#102

Test Plan: Can not provide log, should test on site.

Reviewed By: joancaneus

fbshipit-source-id: 43493f480d
bbinxie pushed a commit to SW-CSA/openbmc that referenced this issue Aug 29, 2019
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
bbinxie pushed a commit to SW-CSA/openbmc that referenced this issue Aug 29, 2019
Summary:
As title, m95m02-util can be replaced by dd.
There's no reason to keep this program.
Pull Request resolved: facebookexternal/openbmc.accton#105

Test Plan: Same as facebook#102 .

Reviewed By: benwei13

fbshipit-source-id: ec7c5b951
@Goforitzjl
Copy link

.

facebook-github-bot pushed a commit that referenced this issue Nov 4, 2020
Summary:
This PR has the changes necessary to support multiboot.

facebookexternal/openbmc.arista#1 - fpga_util changes to support multiboot
facebookexternal/openbmc.arista#2 - Update CIT fw tests in conjunction with this change

Change facebookexternal/openbmc.arista#1: fpga_util.sh
For elbert fpga_util spi flash devices, let's use spi-nor driver.
The issue with loading this driver at dts is that some devices might not
be enabled or behind a mux. Instead add a method bind_spi_nor which will
enable this driver in userspace after the muxes are set properly.

Interacting with this mtd device will not do anything unless the mux is
selected which is only in the context of fpga_util.sh

I am leaving some code in case we decide to go back to spidev in the
future.

Testing:
Able to reprogram and pimreset different PIM types and see images being
reloaded. There is still some issue intermittently where PIM stay
showing up as 'VERSION NOT DETECTED' and we are investigating,
However, this can be recoved via powercycle or reprogramming, and is
only 2-3/100 cycles.

Able to read TH4 QSPI with this change as well. For TH4 QSPI we re-bind
the spi-nor to re-initialize it. Since this upgrade is rare we will just
bind everytime.

Change facebookexternal/openbmc.arista#2: Update Elbert FW CIT tests
- Update manifest jsons to match latest programmables
- Add CIT and external fw upgrade test cases

Example Logs:
NOTE: you can ignore bios issues

```
% python3 cit_runner.py --platform elbert --run-test "tests.elbert.external_fw_upgrade_test_multip
le" --external --bmc-host fd7a:629f:52a4:1b1c:d6af:f7ff:fe2f:320d --firmware-opt-args="-f -v"
test_collective_firmware_upgrade (tests.elbert.external_fw_upgrade_test_multiple.CollectiveFwUpgradeTest)
This test file will enable us to do all the upgrade and ... Start firmware upgrade test!
Connecting to UUT ....................................................... Done
Checking version ........................................................ Warning
Warning!
bios: Cannot get current version on UUT, defaulting to upgrade
Checking binary on UUT .................................................. Done                                                                     [95/5226]
Updating: bios .......................................................... Done
Updating: scm ........................................................... Done
Updating: smb ........................................................... Done
Updating: smb_cpld ...................................................... Done
Updating: fan ........................................................... Done
Updating: pim_base ...................................................... Done
Updating: pim16q ........................................................ Done
Updating: pim8ddm ....................................................... Done
Power cycle UUT ......................................................... Done
Reconnecting to DUT ..................................................... Done
Checking version ........................................................ Warning
Warning!
bios: Cannot get current version on UUT, defaulting to upgrade

***********************************************************************************
                                    Test Summary
***********************************************************************************
     Name       Previous     Current      Package        Result   Time elapsed
-----------------------------------------------------------------------------------
     bios         N/A          N/A          4.10         Passed      86.81s
     scm          1.13         1.13         1.13         Passed      65.83s
     smb          1.18         1.18         1.18         Passed      66.06s
   smb_cpld       4.1          4.1          4.1          Passed      26.35s
     fan          1.2          1.2          1.2          Passed      26.44s
   pim_base       1.1          1.1          1.1          Passed      5.28s
    pim16q        6.4          6.4          6.4          Passed      7.49s
   pim8ddm        7.3          7.3          7.3          Passed      7.51s
-----------------------------------------------------------------------------------
ok

----------------------------------------------------------------------
Ran 1 test in 621.406s

Pull Request resolved: facebookexternal/openbmc.arista#102

Reviewed By: mikechoifb

fbshipit-source-id: a67b5e19c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants