diff --git a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/lib/Makefile b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/lib/Makefile new file mode 100644 index 000000000000..5473d942f13d --- /dev/null +++ b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/lib/Makefile @@ -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 diff --git a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/elbert_eeprom.c b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/lib/elbert_eeprom.c similarity index 97% rename from meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/elbert_eeprom.c rename to meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/lib/elbert_eeprom.c index 996e36dc6720..31a3a95ff245 100644 --- a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/elbert_eeprom.c +++ b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/lib/elbert_eeprom.c @@ -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}; @@ -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: diff --git a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/elbert_eeprom.h b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/lib/elbert_eeprom.h similarity index 100% rename from meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/elbert_eeprom.h rename to meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/lib/elbert_eeprom.h diff --git a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/Makefile b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/Makefile index d36c10e68238..15c3b9b17f92 100644 --- a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/Makefile +++ b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/Makefile @@ -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 diff --git a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/elbert_weutil.c b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/elbert_weutil.c index abacbb48ec99..f69cbb2b7f5e 100644 --- a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/elbert_weutil.c +++ b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/files/utils/elbert_weutil.c @@ -19,7 +19,8 @@ #include #include -#include "elbert_eeprom.h" +#include +#include #include #define BMC_MGMT_MACADDR "/sys/class/net/eth0/address" diff --git a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/libelbert-eeprom_0.1.bb b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/libelbert-eeprom_0.1.bb new file mode 100644 index 000000000000..70c4e524dd8d --- /dev/null +++ b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/libelbert-eeprom_0.1.bb @@ -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" diff --git a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/wedge-eeprom_%.bbappend b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/wedge-eeprom_%.bbappend index 575df79b62a5..f373ac8b5ca3 100644 --- a/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/wedge-eeprom_%.bbappend +++ b/meta-facebook/meta-elbert/recipes-utils/wedge-eeprom/wedge-eeprom_%.bbappend @@ -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"