Skip to content

Commit

Permalink
ELBERT: refactors EEPROM code to library and fixes PIM8DDM part numbe…
Browse files Browse the repository at this point in the history
…r in weutil (#126)

Summary:
This makes two changes to the Elbert wedge-eeprom code:
1. Refactors the elbert-eeprom code into its own library so that it can be used by the Elbert platform-lib code.
2. Fixes an issue where garbage characters are printed at the end of the PIM8DDM part number in weutil.

## Testing

EEPROM CIT tests pass.

Verified that the PIM8DDM part number is now correct:
```
root@bmc-oob:~# pim_types.sh
PIM 2: PIM16Q
PIM 3: PIM16Q
PIM 4: PIM16Q
PIM 5: PIM16Q
PIM 6: PIM8DDM
PIM 7: PIM16Q
PIM 8: PIM16Q
PIM 9: PIM16Q

root@bmc-oob:~# weutil pim6
Wedge EEPROM pim6:
Version: 0
Product Name: ELBERT
Product Part Number: 7388-8D
System Assembly Part Number: ASY055040104
Facebook PCBA Part Number:
Facebook PCB Part Number:
ODM PCBA Part Number: PCA015220106
ODM PCBA Serial Number:
Product Production State: 0
Product Version: 10
Product Sub-Version: 1
Product Serial Number: JAS20370017
Product Asset Tag:
System Manufacturer:
System Manufacturing Date: 2020010100
PCB Manufacturer:
Assembled At:
Local MAC: D4:AF:F7:2F:32:A6
Extended MAC Base: D4:AF:F7:2F:98:D0
Extended MAC Address Size: 139
Location on Fabric:
CRC8: 0x0
```

Pull Request resolved: facebookexternal/openbmc.arista#126

Reviewed By: benwei13

fbshipit-source-id: 2dfb73f46c
  • Loading branch information
joancaneus authored and facebook-github-bot committed Dec 21, 2020
1 parent f4d1f80 commit c15a765
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2020-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: libelbert_eeprom.so

libelbert_eeprom.so: elbert_eeprom.c
$(CC) $(CFLAGS) -fPIC -c -o elbert_eeprom.o elbert_eeprom.c
$(CC) -shared -o libelbert_eeprom.so elbert_eeprom.o -lc $(LDFLAGS)

.PHONY: clean

clean:
rm -rf *.o libelbert_eeprom.so
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#define ELBERT_EEPROM_FIELD_FLDVAR 0x09
#define ELBERT_EEPROM_FIELD_HWREV 0x0B
#define ELBERT_EEPROM_FIELD_SERIAL 0x0E
#define ELBERT_PIM8DDM "7388-8D"

// Map between PIM and SMBus channel
static int pim_bus_p1[8] = {16, 17, 18, 23, 20, 21, 22, 19};
Expand Down Expand Up @@ -367,6 +368,14 @@ int elbert_eeprom_parse(const char *target, struct wedge_eeprom_st *eeprom)
// This cuts off the Product field into 9 characters max
// We allocate FBW_EEPROM_F_PRODUCT_NUMBER + 2
eeprom->fbw_product_number[FBW_EEPROM_F_PRODUCT_NUMBER + 1] = '\0';

// Remove garbage characters from the end of 7388-8D
if(!strncmp(
eeprom->fbw_product_number,
ELBERT_PIM8DDM,
strlen(ELBERT_PIM8DDM))) {
eeprom->fbw_product_number[FBW_EEPROM_F_PRODUCT_NUMBER - 1] = '\0';
}
break;

case ELBERT_EEPROM_FIELD_MACBASE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

utils: weutil

weutil: elbert_weutil.o elbert_eeprom.o
$(CC) -o $@ $^ -lwedge_eeprom $(LDFLAGS)
weutil: elbert_weutil.o
$(CC) -o $@ $^ -lwedge_eeprom -lelbert_eeprom $(LDFLAGS)

.PHONY: clean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#include <errno.h>
#include <stdio.h>

#include "elbert_eeprom.h"
#include <facebook/wedge_eeprom.h>
#include <facebook/elbert_eeprom.h>
#include <string.h>
#define BMC_MGMT_MACADDR "/sys/class/net/eth0/address"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2020-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 = "Elbert EEPROM Library"
DESCRIPTION = "library for elbert eeprom"
SECTION = "base"
PR = "r1"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://elbert_eeprom.c;beginline=4;endline=16;md5=da35978751a9d71b73679307c4d296ec"

SRC_URI = "file://lib \
"

LDFLAGS += "-llog -lobmc-i2c -lwedge_eeprom"
DEPENDS += "liblog libobmc-i2c libwedge-eeprom"
RDEPENDS_${PN} = "liblog libobmc-i2c libwedge-eeprom"

S = "${WORKDIR}/lib"

do_install() {
install -d ${D}${libdir}
install -m 0644 libelbert_eeprom.so ${D}${libdir}/libelbert_eeprom.so

install -d ${D}${includedir}/facebook
install -m 0644 elbert_eeprom.h ${D}${includedir}/facebook/elbert_eeprom.h
}

FILES_${PN} = "${libdir}/libelbert_eeprom.so"
FILES_${PN}-dev = "${includedir}/facebook/elbert_eeprom.h"
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
LIC_FILES_CHKSUM = "file://elbert_weutil.c;beginline=4;endline=16;md5=da35978751a9d71b73679307c4d296ec"
SRC_URI += " \
file://utils/elbert_eeprom.h \
file://utils/elbert_eeprom.c \
file://utils/elbert_weutil.c \
file://utils/Makefile \
"

LDFLAGS += "-llog"
DEPENDS += "liblog"
RDEPENDS_${PN} += "liblog"
RDEPENDS_${PN} += "libelbert-eeprom"
DEPENDS += "libelbert-eeprom"

0 comments on commit c15a765

Please sign in to comment.