Skip to content

Commit

Permalink
pem-util: add pem-util for wedge400 (#68)
Browse files Browse the repository at this point in the history
Summary:
Utility for pem to show pem's information
Pull Request resolved: facebookexternal/openbmc.celestica#68

Test Plan:
root@bmc-oob:~# pem-util pem2 --get_pem_info

PEM Information                 : PEM2 (Bus:23 Addr:0x58)
---------------                 : -----------------------
Version                         : 3
Product Name                    : WEDGE400-AC-F
Product Part Number             : 20-002230
Product Version                 : 1
Product Sub-Version             : 255
Product Serial Number           : F0A1119160001
System Manufacturer             : CLS
System Manufacturing Date       : 04-19-19

PEM Hot Swap status             : PEM2 (Bus:23 Addr:0x58)
---------------                 : -----------------------
PEM2_IN_VOLT                    : 12.14 Volts
PEM2_OUT_VOLT                   : 12.14 Volts
PEM2_CURR                       : 12.10 Amps
PEM2_POWER                      : 147.66 Watts
PEM2_FAN1_SPEED                 : 8228.00 RPM
PEM2_FAN2_SPEED                 : 7200.00 RPM
PEM2_HOT_SWAP_TEMP              : 28.80 C
PEM2_AIR_INLET_TEMP             : 9.38 C
PEM2_AIR_OUTLET_TEMP            : 28.62 C
ON_STATUS                       : 1
FET_BAD_COOLDOWN_STATUS         : 0
FET_SHORT_PRESENT               : 0
ON_PIN_STATUS                   : 1
POWER_GOOD_STATUS               : 1
OC_COOLDOWN_STATUS              : 0
UV_STATUS                       : 0
OV_STATUS                       : 0
GPIO3_STATUS                    : 0
GPIO2_STATUS                    : 1
GPIO1_STATUS                    : 1
ALERT_STATUS                    : 1
EEPROM_BUSY                     : 0
ADC_IDLE                        : 0
TICKER_OVERFLOW_PRESENT         : 0
METER_OVERFLOW_PRESENT          : 0

EEPROM Done                     : 0
FET Bad Fault                   : 0
FET Short Fault                 : 0
On Fault                        : 0
Power Bad Fault                 : 0
OC Fault                        : 0
UV Fault                        : 0
OV Fault                        : 0

Power Alarm High                : 0
Power Alarm Low                 : 1
Vsense Alarm High               : 0
Vsense Alarm Low                : 1
VSourve Alarm High              : 0
VSourve Alarm Low               : 0
VGPIO Alarm High                : 1
VGPIO Alarm Low                 : 0
root@bmc-oob:~#
root@bmc-oob:~# pem-util pem2 --get_eeprom_info --clear

Hot Swap EEPROM Default Information: PEM2 (Bus:23 Addr:0x58)
---------------                 : -----------------------
On Fault Mask                   : 0
On Delay                        : 0
On/Enb                          : 1
Mass Write Enable               : 1
Fet on                          : 1
OC Autoretry                    : 1
UV Autoretry                    : 1
OV Autoretry                    : 1
On FB Mode                      : external
On UV Mode                      : external
On OV Mode                      : external
On Vin Mode                     : 12V

EEPROM Done Alert               : 0
FET Bad Fault Alert             : 0
FET Short Alert                 : 0
On Alert                        : 0
PB Alert                        : 0
OC Alert                        : 0
UV Alert                        : 0
OV Alert                        : 0
Power Alarm High                : 0
Power Alarm Low                 : 0
Vsense Alarm High               : 0
Vsense Alarm Low                : 0
VSourve Alarm High              : 0
VSourve Alarm Low               : 0
VGPIO Alarm High                : 0
VGPIO Alarm Low                 : 0

EEPROM Done                     : 0
FET Bad Fault                   : 0
FET Short Fault                 : 0
On Fault                        : 0
Power Bad Fault                 : 0
OC Fault                        : 0
UV Fault                        : 0
OV Fault                        : 0

Power Alarm High                : 0
Power Alarm Low                 : 0
Vsense Alarm High               : 0
Vsense Alarm Low                : 0
VSourve Alarm High              : 0
VSourve Alarm Low               : 0
VGPIO Alarm High                : 0
VGPIO Alarm Low                 : 0

GPIO3 PD                        : 0
GPIO2 PD                        : 1
GPIO1 Config                    : Power Good
GPIO1 Output                    : 0
ADC Conv Alert                  : 0
Stress to GPIO2                 : 0
Meter Overflow Alert            : 0

Coulomb Meter                   : 0
Tick Out                        : 0
Int Clock Out                   : 0
Clock Divider                   : 8

ILIM Adjust                     : 1
Foldback Mode                   : 2
Vsource/VDD                     : 1
GPIO Mode                       : 0
ADC 16-BIT/12-BIT               : 16-bit
root@bmc-oob:~#
root@bmc-oob:~# pem-util pem2 --get_eeprom_info --print

FRU Information                 : PEM2 (Bus:23 Addr:0x58)
---------------                 : -----------------------
Version                         : 3
Product Name                    : WEDGE400-AC-F
Product Part Number             : 20-002230
System Assembly Part Number     : N/A-
Facebook PCBA Part Number       : 132-000094-01
Facebook PCB Part Number        : 131-000072-01
ODM PCBA Part Number            : R1149G000101
ODM PCBA Serial Number          : G011219140030
Product Production State        : 1
Product Version                 : 1
Product Sub-Version             : 255
Product Serial Number           : F0A1119160001
Product Asset Tag               : 5850014
System Manufacturer             : CLS
System Manufacturing Date       : 04-19-19
PCB Manufacturer                : WUS
Assembled At                    : CLS
Local MAC                       : 00:E0:EC:DC:70:1C
Extended MAC Base               : 00:E0:EC:DC:70:1D
Extended MAC Address Size       : 143
Location on Fabric              : SMB
CRC8                            : 0x9

Hot Swap EEPROM Information     : PEM2 (Bus:23 Addr:0x58)
---------------                 : -----------------------
On Fault Mask                   : 0
On Delay                        : 0
On/Enb                          : 1
Mass Write Enable               : 1
Fet on                          : 1
OC Autoretry                    : 1
UV Autoretry                    : 1
OV Autoretry                    : 1
On FB Mode                      : external
On UV Mode                      : external
On OV Mode                      : external
On Vin Mode                     : 12V

EEPROM Done Alert               : 0
FET Bad Fault Alert             : 0
FET Short Alert                 : 0
On Alert                        : 0
PB Alert                        : 0
OC Alert                        : 0
UV Alert                        : 0
OV Alert                        : 0
Power Alarm High                : 0
Power Alarm Low                 : 0
Vsense Alarm High               : 0
Vsense Alarm Low                : 0
VSourve Alarm High              : 0
VSourve Alarm Low               : 0
VGPIO Alarm High                : 0
VGPIO Alarm Low                 : 0

EEPROM Done                     : 1
FET Bad Fault                   : 0
FET Short Fault                 : 0
On Fault                        : 0
Power Bad Fault                 : 0
OC Fault                        : 0
UV Fault                        : 0
OV Fault                        : 0

Power Alarm High                : 0
Power Alarm Low                 : 0
Vsense Alarm High               : 0
Vsense Alarm Low                : 0
VSourve Alarm High              : 0
VSourve Alarm Low               : 0
VGPIO Alarm High                : 0
VGPIO Alarm Low                 : 0

GPIO3 PD                        : 0
GPIO2 PD                        : 1
GPIO1 Config                    : Power Good
GPIO1 Output                    : 0
ADC Conv Alert                  : 0
Stress to GPIO2                 : 0
Meter Overflow Alert            : 0

Coulomb Meter                   : 0
Tick Out                        : 0
Int Clock Out                   : 0
Clock Divider                   : 8

ILIM Adjust                     : 1
Foldback Mode                   : 2
Vsource/VDD                     : 1
GPIO Mode                       : 0
ADC 16-BIT/12-BIT               : 16-bit
root@bmc-oob:~#
root@bmc-oob:~# pem-util pem2 --get_blackbox_info --print

FRU Information                 : PEM2 (Bus:23 Addr:0x58)
---------------                 : -----------------------
Version                         : 3
Product Name                    : WEDGE400-AC-F
Product Part Number             : 20-002230
System Assembly Part Number     : N/A-
Facebook PCBA Part Number       : 132-000094-01
Facebook PCB Part Number        : 131-000072-01
ODM PCBA Part Number            : R1149G000101
ODM PCBA Serial Number          : G011219140030
Product Production State        : 1
Product Version                 : 1
Product Sub-Version             : 255
Product Serial Number           : F0A1119160001
Product Asset Tag               : 5850014
System Manufacturer             : CLS
System Manufacturing Date       : 04-19-19
PCB Manufacturer                : WUS
Assembled At                    : CLS
Local MAC                       : 00:E0:EC:DC:70:1C
Extended MAC Base               : 00:E0:EC:DC:70:1D
Extended MAC Address Size       : 143
Location on Fabric              : SMB
CRC8                            : 0x9

Hot Swap EEPROM Information     : PEM2 (Bus:23 Addr:0x58)
---------------                 : -----------------------
On Fault Mask                   : 0
On Delay                        : 0
On/Enb                          : 1
Mass Write Enable               : 1
Fet on                          : 1
OC Autoretry                    : 1
UV Autoretry                    : 1
OV Autoretry                    : 1
On FB Mode                      : external
On UV Mode                      : external
On OV Mode                      : external
On Vin Mode                     : 12V

EEPROM Done Alert               : 0
FET Bad Fault Alert             : 0
FET Short Alert                 : 0
On Alert                        : 0
PB Alert                        : 0
OC Alert                        : 0
UV Alert                        : 0
OV Alert                        : 0
Power Alarm High                : 0
Power Alarm Low                 : 0
Vsense Alarm High               : 0
Vsense Alarm Low                : 0
VSourve Alarm High              : 0
VSourve Alarm Low               : 0
VGPIO Alarm High                : 0
VGPIO Alarm Low                 : 0

EEPROM Done                     : 1
FET Bad Fault                   : 0
FET Short Fault                 : 0
On Fault                        : 0
Power Bad Fault                 : 0
OC Fault                        : 0
UV Fault                        : 0
OV Fault                        : 0

Power Alarm High                : 0
Power Alarm Low                 : 0
Vsense Alarm High               : 0
Vsense Alarm Low                : 0
VSourve Alarm High              : 0
VSourve Alarm Low               : 0
VGPIO Alarm High                : 0
VGPIO Alarm Low                 : 0

GPIO3 PD                        : 0
GPIO2 PD                        : 1
GPIO1 Config                    : Power Good
GPIO1 Output                    : 0
ADC Conv Alert                  : 0
Stress to GPIO2                 : 0
Meter Overflow Alert            : 0

Coulomb Meter                   : 0
Tick Out                        : 0
Int Clock Out                   : 0
Clock Divider                   : 8

ILIM Adjust                     : 1
Foldback Mode                   : 2
Vsource/VDD                     : 1
GPIO Mode                       : 0
ADC 16-BIT/12-BIT               : 16-bit

PEM Hot Swap status             : PEM2 (Bus:23 Addr:0x58)
---------------                 : -----------------------
PEM2_IN_VOLT                    : 12.14 Volts
PEM2_OUT_VOLT                   : 12.14 Volts
PEM2_CURR                       : 12.16 Amps
PEM2_POWER                      : 146.98 Watts
PEM2_FAN1_SPEED                 : 7200.00 RPM
PEM2_FAN2_SPEED                 : 7200.00 RPM
PEM2_HOT_SWAP_TEMP              : 29.33 C
PEM2_AIR_INLET_TEMP             : 9.50 C
PEM2_AIR_OUTLET_TEMP            : 29.00 C
ON_STATUS                       : 1
FET_BAD_COOLDOWN_STATUS         : 0
FET_SHORT_PRESENT               : 0
ON_PIN_STATUS                   : 1
POWER_GOOD_STATUS               : 1
OC_COOLDOWN_STATUS              : 0
UV_STATUS                       : 0
OV_STATUS                       : 0
GPIO3_STATUS                    : 0
GPIO2_STATUS                    : 1
GPIO1_STATUS                    : 1
ALERT_STATUS                    : 1
EEPROM_BUSY                     : 0
ADC_IDLE                        : 0
TICKER_OVERFLOW_PRESENT         : 0
METER_OVERFLOW_PRESENT          : 0

EEPROM Done                     : 0
FET Bad Fault                   : 0
FET Short Fault                 : 0
On Fault                        : 0
Power Bad Fault                 : 0
OC Fault                        : 0
UV Fault                        : 0
OV Fault                        : 0

Power Alarm High                : 0
Power Alarm Low                 : 1
Vsense Alarm High               : 0
Vsense Alarm Low                : 1
VSourve Alarm High              : 0
VSourve Alarm Low               : 0
VGPIO Alarm High                : 1
VGPIO Alarm Low                 : 0

root@bmc-oob:~#

Reviewed By: benwei13

fbshipit-source-id: a83c304508
  • Loading branch information
joancaneus authored and facebook-github-bot committed Aug 20, 2019
1 parent 0b93b87 commit f850e65
Show file tree
Hide file tree
Showing 7 changed files with 1,557 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Copyright 2019-present Facebook. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
#

all: pem-util

CFLAGS += -Wall -Werror

psu-util: pem-util.o
$(CC) $(CFLAGS) -std=gnu99 -o $@ $^ $(LDFLAGS)

.PHONY: clean

clean:
rm -rf *.o pem-util
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* pem-util
*
* Copyright 2019-present Facebook. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <facebook/wedge400-pem.h>

static const char *option_list[] = {
" --get_pem_info",
" --get_eeprom_info",
" options:",
" --print",
" --clear",
" --get_blackbox_info",
" options:",
" --print",
" --clear",
};

static void
print_usage(const char *name) {
int i;

printf("Usage: %s <pem1|pem2> <command> <options>\n", name);
printf(" command:\n");
for (i = 0; i < sizeof(option_list)/sizeof(option_list[0]); i++)
printf(" %s\n", option_list[i]);
}

int
main(int argc, const char *argv[]) {
uint8_t pem_num = 0, prsnt = 0;
int pid_file = 0;
int ret = 0;

if (argc < 3) {
print_usage(argv[0]);
return -1;
}

if (!strcmp(argv[1], "pem1")) {
pem_num = 0;
}
else if (!strcmp(argv[1] , "pem2")) {
pem_num = 1;
}
else {
print_usage(argv[0]);
return -1;
}

pid_file = open("/var/run/pem-util.pid", O_CREAT | O_RDWR, 0666);
if (flock(pid_file, LOCK_EX | LOCK_NB) && (errno == EWOULDBLOCK)) {
printf("Another pem-util instance is running...\n");
exit(EXIT_FAILURE);
}

ret = is_pem_prsnt(pem_num, &prsnt);
if (ret) {
printf("Get PEM%d present error!\n", pem_num + 1);
return ret;
}
if (!prsnt) {
printf("PEM%d is not present!\n", pem_num + 1);
return -1;
}

if (!strcmp(argv[2], "--get_pem_info")) {
ret = get_pem_info(pem_num);
}
else if (!strcmp(argv[2], "--get_blackbox_info") && argv[3] != NULL) {
ret = get_blackbox_info(pem_num, argv[3]);
}
else if (!strcmp(argv[2], "--get_eeprom_info") && argv[3] != NULL) {
ret = get_eeprom_info(pem_num, argv[3]);
}
else {
print_usage(argv[0]);
return -1;
}

return ret;
}
41 changes: 41 additions & 0 deletions meta-facebook/meta-wedge400/recipes-utils/pem-util/pem-util_0.1.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2019-present Facebook. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA

SUMMARY = "PEM Utility"
DESCRIPTION = "Utility to update PEM and get PEM EEPROM."
SECTION = "base"
PR = "r1"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://pem-util.c;beginline=5;endline=16;md5=69348da7e13c557a246cf7e5b163ea27"


SRC_URI = "file://utils \
"

S = "${WORKDIR}/utils"

LDFLAGS = "-lfruid -lpal -lwedge400-pem "

DEPENDS += "libwedge400-pem"
RDEPENDS_${PN} += "libwedge400-pem"

do_install() {
install -d ${D}${bindir}
install -m 755 pem-util ${D}${bindir}/pem-util
}

FILES_${PN} = "${bindir}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2019-present Facebook. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA

lib: libwedge400-pem.so

CFLAGS += -Wall -Werror

libwedge400-pem.so: wedge400-pem.c
$(CC) $(CFLAGS) -fPIC -c -o wedge400-pem.o wedge400-pem.c
$(CC) -shared -o libwedge400-pem.so wedge400-pem.o $(LDFLAGS) -lc

.PHONY: clean

clean:
rm -rf *.o libwedge400-pem.so
Loading

0 comments on commit f850e65

Please sign in to comment.