From e91ee6437c9dead5b3184b61faf9c2f04434e85c Mon Sep 17 00:00:00 2001 From: Ben Wei Date: Wed, 22 Apr 2020 12:11:18 -0700 Subject: [PATCH] fby3: move fw-util in fby3 to common (#1015) Summary: -move fw-util in fby3 to common. -log the update event in log-util. For example: Updating 1OU BIC Bootloader on slot2. File: DVT_BIC_PKG/Y3BB1M_D01.bin Updated 1OU BIC Bootloader on slot2. File: DVT_BIC_PKG/Y3BB1M_D01.bin. Result: Success Updating 1OU BIC Bootloader on slot2. File: DVT_BIC_PKG/Y3BBDL_D01.bin Updated 1OU BIC Bootloader on slot2. File: DVT_BIC_PKG/Y3BBDL_D01.bin. Result: Fail -libbic a) add force update to compatible with the previous CPLD b) declare FW_XXX variables for all components c) modify bic_get_fw_ver and bic_update_fw for fw-util d) add the string names of all components Pull Request resolved: https://github.com/facebookexternal/openbmc.wiwynn/pull/1015 Test Plan: -build code(pass) -update bmc/rom(pass) -update sb/1ou/2ou bic/bicbl(pass) -update vr(pass) -update 1ou/2ou/bb/sb cpld(pass) root@bmc-oob:~# fw-util bmc --update cpld Y3CNIC_E03.rpd image is not a valid CPLD image for NIC expansion board Upgrade of bmc : cpld failed root@bmc-oob:~# fw-util bmc --force --update cpld Y3CNIC_E03.rpd rpd file size = 376832 bytes. OnChip Flash Status = 0xFFFFFD80. image type = 0x1. Max10 Unprotect Sector 5. Max10 Erase Sector 5 Erase sector SUCCESS. Max10 Erase Sector 0 Erase sector SUCCESS. Progress: Addr: 0xBFFFC [100 %] Done! Force upgrade of bmc : cpld succeeded root@bmc-oob:~# fw-util bmc --update cpld Y3CNIC_D02_signed.rpd rpd file size = 376832 bytes. OnChip Flash Status = 0xFFFFFD98. image type = 0x1. Max10 Unprotect Sector 5. Max10 Erase Sector 5 Erase sector SUCCESS. Max10 Erase Sector 0 Erase sector SUCCESS. Progress: Addr: 0xBFFFC [100 %] Done! Upgrade of bmc : cpld succeeded root@bmc-oob:~# power-util slot1 12V-cycle 12V Power cycling fru 1... packet_write_wait: Connection to 192.168.88.182 port 22: Broken pipe root@guaigaui-Freedom:/home/tony# ssh 192.168.88.182 root@192.168.88.182's password: root@bmc-oob:~# fw-util bmc --version | grep -i cpld BMC CPLD Version: 00060D02 root@bmc-oob:~# fw-util slot1 --update bb_cpld Y3CBD_D02_signed.rpd slot_id: 1, comp: f, intf: 0, img: Y3CBD_D02_signed.rpd, force: 0 OnChip Flash Status = 0xFFFFFD80., slot_id 0x1, sectype 0x0, intf: 0x10, read 376833 bytes. Erase sector SUCCESS. Erase sector SUCCESS. updated cpld: 100 % Elapsed time: 312 sec. Upgrade of slot1 : bb_cpld succeeded root@bmc-oob:~# fw-util slot1 --update bb_cpld Y3CM_D01.jed slot_id: 1, comp: f, intf: 0, img: Y3CM_D01.jed, force: 0 OnChip Flash Status = 0xFFFFFD94., slot_id 0x1, sectype 0x0, intf: 0x10, read 505952 bytes. The size of image is not expected! Upgrade of slot1 : bb_cpld failed root@bmc-oob:~# fw-util slot1 --update cpld Y3CDL_D01_signed.rpd slot_id: 1, comp: 1, intf: 0, img: Y3CDL_D01_signed.rpd, force: 0 OnChip Flash Status = 0xFFFFFC00., slot_id 0x1, sectype 0x0, intf: 0xff, read 376833 bytes. Erase sector SUCCESS. Erase sector SUCCESS. updated cpld: 100 % Elapsed time: 301 sec. Upgrade of slot1 : cpld succeeded root@bmc-oob:~# fw-util slot1 --update cpld Y3CBD_D02_signed.rpd slot_id: 1, comp: 1, intf: 0, img: Y3CBD_D02_signed.rpd, force: 0 OnChip Flash Status = 0xFFFFFC14., slot_id 0x1, sectype 0x0, intf: 0xff, read 376833 bytes. The image is not the valid CPLD image for this component. Upgrade of slot1 : cpld failed root@bmc-oob:/mnt/data1# fw-util bmc --update rom flash-fby3-v2020.15.3 Flashing to device: /dev/mtd12 Erasing block: 401/401 (100%) Writing kb: 25635/25635 (100%) Verifying kb: 25635/25635 (100%) Upgrade of bmc : rom succeeded root@bmc-oob:/mnt/data1# fw-util bmc --update bmc flash-fby3-v2020.15.3 Flashing to device: /dev/mtd5 Erasing block: 401/401 (100%) Writing kb: 25635/25635 (100%) Verifying kb: 25635/25635 (100%) Upgrade of bmc : bmc succeeded root@bmc-oob:/mnt/data1# fw-util bmc --update cpld DVT_CPLD_PKG/Y3CDL_D01_signed.rpd image is not a valid CPLD image for baseboard Upgrade of bmc : cpld failed root@bmc-oob:/mnt/data1# fw-util bmc --update cpld DVT_CPLD_PKG/Y3CBD_D02_signed.rpd rpd file size = 376832 bytes. OnChip Flash Status = 0xFFFFFC00. image type = 0x1. Max10 Unprotect Sector 5. Max10 Erase Sector 5 Erase sector SUCCESS. Max10 Erase Sector 0 Erase sector SUCCESS. Progress: Addr: 0xBFFFC [100 %] Done! Upgrade of bmc : cpld succeeded root@bmc-oob:/mnt/data1# fw-util slot2 --update 1ou_bic DVT_BIC_PKG/Y3BR1M_D02.bin slot_id: 2, comp: 7, intf: 0, img: DVT_BIC_PKG/Y3BR1M_D02.bin, force: 0 file size = 146002 bytes, slot = 2, intf = 0x5 bytes/per read = 244 updated bic: 5 % updated bic: 10 % updated bic: 15 % updated bic: 20 % updated bic: 25 % updated bic: 30 % updated bic: 35 % updated bic: 40 % updated bic: 45 % updated bic: 50 % updated bic: 55 % updated bic: 60 % updated bic: 65 % updated bic: 70 % updated bic: 75 % updated bic: 80 % updated bic: 85 % updated bic: 90 % updated bic: 95 % updated bic: 100 % Upgrade of slot2 : 1ou_bic succeeded root@bmc-oob:/mnt/data1# fw-util slot2 --version | grep -i 1ou 1OU Bridge-IC Version: v25.02 root@bmc-oob:/mnt/data1# fw-util slot2 --update 1ou_cpld DVT_CPLD_PKG/Y3CM_D01.jed slot_id: 2, comp: 9, intf: 0, img: DVT_CPLD_PKG/Y3CM_D01.jed, force: 0 [ChkSUM]bb18 CPLD DevID: 612BB043 updated cpld: 5 % updated cpld: 10 % updated cpld: 15 % updated cpld: 20 % updated cpld: 25 % updated cpld: 30 % updated cpld: 35 % updated cpld: 40 % updated cpld: 45 % updated cpld: 50 % updated cpld: 55 % updated cpld: 60 % updated cpld: 65 % updated cpld: 70 % updated cpld: 75 % updated cpld: 80 % updated cpld: 85 % updated cpld: 90 % updated cpld: 95 % updated cpld: 100 % Upgrade of slot2 : 1ou_cpld succeeded root@bmc-oob:/mnt/data1# power-util slot2 12V-cycle 12V Power cycling fru 2... root@bmc-oob:/mnt/data1# fw-util slot2 --version | grep -i 1ou 1OU Bridge-IC Version: v25.02 1OU Bridge-IC Bootloader Version: v15.02 1OU CPLD Version: 00050D01 root@bmc-oob:/mnt/data1# fw-util slot1 --update bic DVT_BIC_PKG/Y3BRDL_D03.bin slot1 is empty root@bmc-oob:/mnt/data1# fw-util slot2 --update bic DVT_BIC_PKG/Y3BBDL_D01.bin slot_id: 2, comp: 2, intf: 0, img: DVT_BIC_PKG/Y3BBDL_D01.bin, force: 0 file size = 16400 bytes, slot = 2, intf = 0xff This file cannot be updated to this component! Invalid BIC file! Upgrade of slot2 : bic failed root@bmc-oob:/mnt/data1# fw-util slot2 --update bicbl DVT_BIC_PKG/Y3BBDL_D01.bin slot_id: 2, comp: 4, intf: 0, img: DVT_BIC_PKG/Y3BBDL_D01.bin, force: 0 file size = 16400 bytes, slot = 2, comp = 0x2 Update BIC bootloader updated bic bootloader: 5 % updated bic bootloader: 10 % updated bic bootloader: 15 % updated bic bootloader: 20 % updated bic bootloader: 25 % updated bic bootloader: 30 % updated bic bootloader: 35 % updated bic bootloader: 40 % updated bic bootloader: 45 % updated bic bootloader: 50 % updated bic bootloader: 55 % updated bic bootloader: 60 % updated bic bootloader: 65 % updated bic bootloader: 70 % updated bic bootloader: 75 % updated bic bootloader: 80 % updated bic bootloader: 85 % updated bic bootloader: 90 % updated bic bootloader: 95 % updated bic bootloader: 100 % Upgrade of slot2 : bicbl succeeded root@bmc-oob:/mnt/data1# fw-util slot2 --update 1ou_bicbl DVT_BIC_PKG/Y3BBDL_D01.bin slot_id: 2, comp: 8, intf: 0, img: DVT_BIC_PKG/Y3BBDL_D01.bin, force: 0 file size = 16400 bytes, slot = 2, comp = 0x2 This file cannot be updated to this component! Invalid BIC bootloader file! Upgrade of slot2 : 1ou_bicbl failed root@bmc-oob:/mnt/data1# fw-util slot2 --update 1ou_bicbl DVT_BIC_PKG/Y3BB1M_D01.bin slot_id: 2, comp: 8, intf: 0, img: DVT_BIC_PKG/Y3BB1M_D01.bin, force: 0 file size = 16400 bytes, slot = 2, comp = 0x2 Update BIC bootloader updated bic bootloader: 5 % updated bic bootloader: 10 % updated bic bootloader: 15 % updated bic bootloader: 20 % updated bic bootloader: 25 % updated bic bootloader: 30 % updated bic bootloader: 35 % updated bic bootloader: 40 % updated bic bootloader: 45 % updated bic bootloader: 50 % updated bic bootloader: 55 % updated bic bootloader: 60 % updated bic bootloader: 65 % updated bic bootloader: 70 % updated bic bootloader: 75 % updated bic bootloader: 80 % updated bic bootloader: 85 % updated bic bootloader: 90 % updated bic bootloader: 95 % updated bic bootloader: 100 % Upgrade of slot2 : 1ou_bicbl succeeded root@bmc-oob:~# fw-util slot2 --update vr 01D2_SN1906016_VCCIN.csv slot_id: 2, comp: 5, intf: 0, img: 01D2_SN1906016_VCCIN.csv, force: 0 VR vendor=TI(6.1) Update VCCIN/VSA...Upgrade of slot2 : vr succeeded root@bmc-oob:~# fw-util slot2 --update vr E2AA_SN1906016_VCCIO.csv slot_id: 2, comp: 5, intf: 0, img: E2AA_SN1906016_VCCIO.csv, force: 0 VR vendor=TI(6.1) Update VCCIO...Upgrade of slot2 : vr succeeded root@bmc-oob:~# fw-util slot2 --update vr 855B_SN1906016_VDDQ_ABC.csv slot_id: 2, comp: 5, intf: 0, img: 855B_SN1906016_VDDQ_ABC.csv, force: 0 VR vendor=TI(6.1) Update VDDQ_ABC...Upgrade of slot2 : vr succeeded root@bmc-oob:~# fw-util slot2 --update vr B629_SN1906016_VDDQ_DEF.csv slot_id: 2, comp: 5, intf: 0, img: B629_SN1906016_VDDQ_DEF.csv, force: 0 VR vendor=TI(6.1) Update VDDQ_DEF...Upgrade of slot2 : vr succeeded root@bmc-oob:~# fw-util slot2 --update bios Y3DLD03.bin slot_id: 2, comp: 6, intf: 0, img: Y3DLD03.bin, force: 0 `````````````````````` Input: Y3DLD03.bin, USB timeout: 3000ms updated bios: 5 % updated bios: 10 % updated bios: 15 % updated bios: 20 % updated bios: 25 % updated bios: 30 % updated bios: 35 % updated bios: 40 % updated bios: 45 % updated bios: 50 % updated bios: 55 % updated bios: 60 % updated bios: 65 % updated bios: 70 % updated bios: 75 % updated bios: 80 % updated bios: 85 % updated bios: 90 % updated bios: 95 % updated bios: 100 % Elapsed time: 808 sec. Upgrade of slot2 : bios succeeded root@bmc-oob:~# ./fw-util slot1 --update vt Y3DLD03.bin USAGE: ./fw-util all|FRU --version [all|COMPONENT] ./fw-util FRU --update [--]COMPONENT IMAGE_PATH ./fw-util FRU --force --update [--]COMPONENT IMAGE_PATH ./fw-util FRU --dump [--]COMPONENT IMAGE_PATH FRU : Components ---------- : ---------- bmc : bmc cpld fscd rom tpm nic : nic slot1 : 1ou_bic 1ou_bicbl 1ou_cpld 2ou_bic 2ou_bicbl 2ou_cpld bb_bic bb_bicbl bb_cpld bic bicbl bios cpld me vr slot2 : 1ou_bic 1ou_bicbl 1ou_cpld 2ou_bic 2ou_bicbl 2ou_cpld bic bicbl bios cpld me vr slot3 : 1ou_bic 1ou_bicbl 1ou_cpld 2ou_bic 2ou_bicbl 2ou_cpld bic bicbl bios cpld me vr slot4 : 1ou_bic 1ou_bicbl 1ou_cpld 2ou_bic 2ou_bicbl 2ou_cpld bic bicbl bios cpld me vr Reviewed By: amithash fbshipit-source-id: a1e0ebaf0a --- .../recipes-fby3/fw-util/files/Makefile | 14 - .../fw-util/files/{bios.cpp => bic_bios.cpp} | 8 +- .../recipes-fby3/fw-util/files/bic_bios.h | 19 + .../recipes-fby3/fw-util/files/bic_cpld.cpp | 78 +--- .../recipes-fby3/fw-util/files/bic_cpld.h | 21 - .../fw-util/files/bic_cpld_ext.cpp | 57 +++ .../recipes-fby3/fw-util/files/bic_cpld_ext.h | 23 + .../recipes-fby3/fw-util/files/bic_fw.cpp | 187 +------- .../recipes-fby3/fw-util/files/bic_fw.h | 52 --- .../recipes-fby3/fw-util/files/bic_fw_ext.cpp | 94 ++++ .../recipes-fby3/fw-util/files/bic_fw_ext.h | 36 ++ .../recipes-fby3/fw-util/files/bic_me.cpp | 34 -- .../recipes-fby3/fw-util/files/bic_me.h | 16 - .../recipes-fby3/fw-util/files/bic_vr.cpp | 11 +- .../recipes-fby3/fw-util/files/bic_vr.h | 6 +- .../recipes-fby3/fw-util/files/bios.h | 19 - .../recipes-fby3/fw-util/files/bmc.cpp | 223 --------- .../recipes-fby3/fw-util/files/bmc.h | 24 - .../recipes-fby3/fw-util/files/bmc_cpld.cpp | 78 ++-- .../recipes-fby3/fw-util/files/bmc_cpld.h | 22 +- .../fw-util/files/check_image.cpp | 434 ------------------ .../recipes-fby3/fw-util/files/expansion.cpp | 52 +++ .../recipes-fby3/fw-util/files/expansion.h | 20 + .../recipes-fby3/fw-util/files/fscd.cpp | 32 -- .../recipes-fby3/fw-util/files/fscd.h | 14 - .../recipes-fby3/fw-util/files/fw-util.cpp | 417 ----------------- .../recipes-fby3/fw-util/files/fw-util.h | 128 ------ .../fw-util/files/image_parts.json | 92 ---- .../recipes-fby3/fw-util/files/nic.cpp | 104 ----- .../recipes-fby3/fw-util/files/nic.h | 18 - .../recipes-fby3/fw-util/files/nic_ext.cpp | 80 ---- .../recipes-fby3/fw-util/files/nic_ext.h | 17 - .../recipes-fby3/fw-util/files/platform.cpp | 186 ++++---- .../recipes-fby3/fw-util/files/server.cpp | 49 -- .../recipes-fby3/fw-util/files/server.h | 14 - .../recipes-fby3/fw-util/files/system.cpp | 118 ----- .../recipes-fby3/fw-util/fw-util_0.2.bbappend | 40 ++ .../recipes-fby3/fw-util/fw-util_0.3.bb | 61 --- .../recipes-fby3/plat-libs/files/bic/bic.h | 11 +- .../files/bic/bic_cpld_altera_fwupdate.c | 2 +- .../plat-libs/files/bic/bic_fwupdate.c | 121 +++-- .../plat-libs/files/bic/bic_fwupdate.h | 3 +- .../plat-libs/files/bic/bic_ipmi.c | 112 +++-- .../plat-libs/files/bic/bic_ipmi.h | 2 +- 44 files changed, 692 insertions(+), 2457 deletions(-) delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/Makefile rename meta-facebook/meta-fby3/recipes-fby3/fw-util/files/{bios.cpp => bic_bios.cpp} (93%) mode change 100644 => 100755 create mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_bios.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.h create mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld_ext.cpp create mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld_ext.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw.h create mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw_ext.cpp create mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw_ext.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_me.cpp delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_me.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bios.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc.cpp delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/check_image.cpp create mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/expansion.cpp create mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/expansion.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fscd.cpp delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fscd.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fw-util.cpp delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fw-util.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/image_parts.json delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic.cpp delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic_ext.cpp delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic_ext.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/server.cpp delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/server.h delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/files/system.cpp create mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/fw-util_0.2.bbappend delete mode 100644 meta-facebook/meta-fby3/recipes-fby3/fw-util/fw-util_0.3.bb diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/Makefile b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/Makefile deleted file mode 100644 index 1f85a6e37e3b..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -#Copyright 2017-present Facebook. All Rights Reserved. - -CPP_SRCS := $(wildcard *.cpp) -CXXFLAGS += -std=c++11 -Wall -Werror -g - -all: fw-util - -fw-util: $(CPP_SRCS) - $(CXX) $(CXXFLAGS) -pthread -o $@ $^ $(LDFLAGS) - -.PHONY: clean - -clean: - rm -rf *.o fw-util diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bios.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_bios.cpp old mode 100644 new mode 100755 similarity index 93% rename from meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bios.cpp rename to meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_bios.cpp index 323e91eb0d51..927f2ed4dc7b --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bios.cpp +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_bios.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "bios.h" +#include "bic_bios.h" #include #ifdef BIC_SUPPORT #include @@ -54,7 +54,7 @@ int BiosComponent::update(string image) { sleep(3); bic_switch_mux_for_bios_spi(slot_id, MUX_SWITCH_CPLD); sleep(1); - ret = bic_update_fw(slot_id, UPDATE_BIOS, intf, (char *)image.c_str(), 1); + ret = bic_update_fw(slot_id, fw_comp, (char *)image.c_str(), FORCE_UPDATE_UNSET); if (ret != 0) { return -1; } @@ -97,7 +97,7 @@ int BiosComponent::print_version() { ret = pal_get_sysfw_ver(fruid, ver); // Print BIOS Version if ( ret < 0 ) { - cout << "BIOS Version: NA" << endl; + throw "Error in getting the version of BIOS"; } else { printf("BIOS Version: "); cout << &ver[3] << endl; @@ -106,7 +106,7 @@ int BiosComponent::print_version() { printf("BIOS Version: NA (%s)\n", err.c_str()); } - return ret; + return FW_STATUS_SUCCESS; } #endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_bios.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_bios.h new file mode 100644 index 000000000000..cd398f1912cb --- /dev/null +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_bios.h @@ -0,0 +1,19 @@ +#ifndef BIC_BIOS_H_ +#define BIC_BIOS_H_ +#include "fw-util.h" +#include "server.h" + + +class BiosComponent : public Component { + uint8_t slot_id = 0; + uint8_t fw_comp = 0; + Server server; + public: + BiosComponent(std::string fru, std::string comp, uint8_t _slot_id, uint8_t _fw_comp) + : Component(fru, comp), slot_id(_slot_id), fw_comp(_fw_comp), server(_slot_id, fru) {} + int update(std::string image); + int fupdate(std::string image); + int print_version(); +}; + +#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.cpp index 43e2bf64d0d9..95ecdd316fbd 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.cpp +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.cpp @@ -1,79 +1,9 @@ -#include -#include -#include #include #include -#include -#include -#include -#include -#include +#include #include "bic_cpld.h" -#ifdef BIC_SUPPORT -#include -using namespace std; - -int CpldComponent::print_version() -{ - uint8_t ver[4] = {0}; - int ret = 0; - string board_name = board(); - - //make the strig to uppercase. - transform(board_name.begin(), board_name.end(), board_name.begin(), ::toupper); - - try { - server.ready(); - if ( intf == NONE_INTF || intf == BB_BIC_INTF ) { - ; // do nothing - } else { - ret = bic_is_m2_exp_prsnt(slot_id); - if ( ret < 0 ) { - throw "Error in getting the present status of " + board_name; - } else if ( intf == FEXP_BIC_INTF && (ret == PRESENT_1OU || ret == (PRESENT_1OU + PRESENT_2OU)) ) { - ; // Correct status, do nothing - } else if ( intf == REXP_BIC_INTF && (ret == PRESENT_2OU || ret == (PRESENT_1OU + PRESENT_2OU)) ) { - ; // Correct status, do nothing - } else { - throw board_name + " Board is empty"; - } - } - ret = bic_show_fw_ver(slot_id, FW_CPLD, ver, bus, addr, intf); - // Print CPLD Version - if ( ret < 0 ) { - throw "Error in getting the version of " + board_name; - } else { - printf("%s CPLD Version: %02X%02X%02X%02X\n", board_name.c_str(), ver[3], ver[2], ver[1], ver[0]); - } - } catch(string err) { - printf("%s CPLD Version: NA (%s)\n", board_name.c_str(), err.c_str()); - } - return ret; -} - -int CpldComponent::update(string image) -{ - int ret = 0; - try { - server.ready(); - ret = bic_update_fw(slot_id, UPDATE_CPLD, intf, (char *)image.c_str(), 0); - } catch (string err) { - return FW_STATUS_NOT_SUPPORTED; - } - return ret; -} - -int CpldComponent::fupdate(string image) -{ - int ret = 0; - try { - server.ready(); - ret = bic_update_fw(slot_id, UPDATE_CPLD, intf, (char *)image.c_str(), 1); - } catch (string err) { - return FW_STATUS_NOT_SUPPORTED; - } - return ret; -} +using namespace std; -#endif +int CpldComponent::print_version() { return FW_STATUS_NOT_SUPPORTED; } +int CpldComponent::update(string image) { return FW_STATUS_NOT_SUPPORTED; } diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.h deleted file mode 100644 index dd0ee0bc16cb..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _BIC_CPLD_H_ -#define _BIC_CPLD_H_ -#include -#include "fw-util.h" -#include "server.h" - -class CpldComponent : public Component { - uint8_t slot_id = 0; - uint8_t bus = 0; - uint8_t addr = 0; - uint8_t intf = 0; - Server server; - public: - CpldComponent(std::string fru, std::string board, std::string comp, uint8_t _slot_id, uint8_t _bus, uint8_t _addr, uint8_t _intf) - : Component(fru, board, comp), slot_id(_slot_id), bus(_bus), addr(_addr), intf(_intf), server(_slot_id, fru){} - int print_version(); - int update(std::string image); - int fupdate(std::string image); -}; - -#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld_ext.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld_ext.cpp new file mode 100644 index 000000000000..e5e8b9fb67fd --- /dev/null +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld_ext.cpp @@ -0,0 +1,57 @@ +#include "fw-util.h" +#include +#include +#include "server.h" +#include +#include "bic_cpld_ext.h" +#ifdef BIC_SUPPORT +#include + +using namespace std; + +int CpldExtComponent::update(string image) { + int ret = 0; + try { + server.ready(); + expansion.ready(); + ret = bic_update_fw(slot_id, fw_comp, (char *)image.c_str(), FORCE_UPDATE_UNSET); + } catch (string err) { + return FW_STATUS_NOT_SUPPORTED; + } + return ret; +} + +int CpldExtComponent::fupdate(string image) { + int ret = 0; + try { + server.ready(); + expansion.ready(); + ret = bic_update_fw(slot_id, fw_comp, (char *)image.c_str(), FORCE_UPDATE_SET); + } catch (string err) { + return FW_STATUS_NOT_SUPPORTED; + } + return ret; +} + +int CpldExtComponent::print_version() { + int ret = 0; + uint8_t ver[32] = {0}; + string board_name = name; + transform(board_name.begin(), board_name.end(), board_name.begin(), ::toupper); + try { + server.ready(); + expansion.ready(); + // Print Bridge-IC Version + ret = bic_get_fw_ver(slot_id, fw_comp, ver); + if ( ret < 0 ) { + throw "Error in getting the version of " + board_name; + } else { + printf("%s CPLD Version: %02X%02X%02X%02X\n", board_name.c_str(), ver[3], ver[2], ver[1], ver[0]); + } + } catch(string err) { + printf("%s CPLD Version: NA (%s)\n", board_name.c_str(), err.c_str()); + } + return FW_STATUS_SUCCESS; +} +#endif + diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld_ext.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld_ext.h new file mode 100644 index 000000000000..d8097e8d2e09 --- /dev/null +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld_ext.h @@ -0,0 +1,23 @@ +#ifndef _BIC_CPLD_EXT_H_ +#define _BIC_CPLD_EXT_H_ +#include "bic_cpld.h" +#include "server.h" +#include "expansion.h" + +using namespace std; + +class CpldExtComponent : public CpldComponent { + uint8_t slot_id = 0; + uint8_t fw_comp = 0; + string name; + Server server; + ExpansionBoard expansion; + public: + CpldExtComponent(string fru, string comp, uint8_t _slot_id, string _name, uint8_t _fw_comp) + : CpldComponent(fru, comp, _slot_id), slot_id(_slot_id), fw_comp(_fw_comp), name(_name), server(_slot_id, fru), expansion(_slot_id, fru, _name, _fw_comp) {} + int update(string image); + int fupdate(string image); + int print_version(); +}; + +#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw.cpp index 1e3579df3d5f..3a4ded7d6158 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw.cpp +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw.cpp @@ -1,189 +1,12 @@ -#include "fw-util.h" #include #include -#include "server.h" -#include #include "bic_fw.h" -#ifdef BIC_SUPPORT -#include using namespace std; -/* - * The functions are used for the BIC of the server board -*/ -int BicFwComponent::update(string image) { - int ret = 0; - - try { - server.ready(); - ret = bic_update_fw(slot_id, UPDATE_BIC, intf, (char *)image.c_str(), 0); - } catch (string err) { - return FW_STATUS_NOT_SUPPORTED; - } - return ret; -} - -int BicFwComponent::fupdate(string image) { - return FW_STATUS_NOT_SUPPORTED; -} - -int BicFwComponent::print_version() { - uint8_t ver[32]= {0}; - int ret = 0; - string board_name = board(); - - transform(board_name.begin(), board_name.end(), board_name.begin(), ::toupper); - try { - server.ready(); - ret = bic_show_fw_ver(slot_id, FW_BIC, ver, 0, 0, intf); - // Print Bridge-IC Version - if ( ret < 0 ) { - throw "Error in getting the version of " + board_name; - } else { - printf("Bridge-IC Version: v%x.%02x\n", ver[0], ver[1]); - } - } catch(string err) { - printf("Bridge-IC Version: NA (%s)\n", err.c_str()); - } - return ret; -} - -int BicFwBlComponent::update(string image) { - int ret = 0; - - try { - server.ready(); - ret = bic_update_fw(slot_id, UPDATE_BIC_BOOTLOADER, intf, (char *)image.c_str(), 0); - } catch(string err) { - return FW_STATUS_NOT_SUPPORTED; - } - return ret; -} - -int BicFwBlComponent::print_version() { - uint8_t ver[32] = {0}; - int ret = 0; - string board_name = board(); - - transform(board_name.begin(), board_name.end(), board_name.begin(), ::toupper); - try { - server.ready(); - ret = bic_show_fw_ver(slot_id, FW_BIC_BOOTLOADER, ver, 0, 0, intf); - // Print Bridge-IC Bootloader Version - if ( ret < 0 ) { - throw "Error in getting the version of " + board_name; - } else { - printf("Bridge-IC Bootloader Version: v%x.%02x\n", ver[0], ver[1]); - } - } catch(string err) { - printf("Bridge-IC Bootloader Version: NA (%s)\n", err.c_str()); - } - return ret; -} - -/* - * The functions are used for the 2nd BIC of the expansion board -*/ - -int BicFwExtComponent::update(string image) { - int ret = 0; - try { - server.ready(); - ret = bic_update_fw(slot_id, UPDATE_BIC, intf, (char *)image.c_str(), 0); - } catch (string err) { - return FW_STATUS_NOT_SUPPORTED; - } - return ret; -} - -int BicFwExtComponent::fupdate(string image) { - return FW_STATUS_NOT_SUPPORTED; -} - -int BicFwExtComponent::print_version() { - uint8_t ver[32] = {0}; - int ret = 0; - string board_name = board(); - - //make the strig to uppercase. - transform(board_name.begin(), board_name.end(), board_name.begin(), ::toupper); - try { - server.ready(); - if ( intf == BB_BIC_INTF ) { - ; // do nothing - } else { - ret = bic_is_m2_exp_prsnt(slot_id); - if ( ret < 0 ) { - throw "Error in getting the present status of " + board_name; - } else if ( intf == FEXP_BIC_INTF && (ret == PRESENT_1OU || ret == (PRESENT_1OU + PRESENT_2OU)) ) { - ; // Correct status, do nothing - } else if ( intf == REXP_BIC_INTF && (ret == PRESENT_2OU || ret == (PRESENT_1OU + PRESENT_2OU)) ) { - ; // Correct status, do nothing - } else { - throw board_name + " Board is empty"; - } - } - ret = bic_show_fw_ver(slot_id, FW_BIC, ver, 0, 0, intf); - // Print Bridge-IC Version - if ( ret < 0 ) { - throw "Error in getting the version of " + board_name; - } else { - printf("%s Bridge-IC Version: v%x.%02x\n", board_name.c_str(), ver[0], ver[1]); - } - } catch(string err) { - printf("%s Bridge-IC Version: NA (%s)\n", board_name.c_str(), err.c_str()); - } - return ret; -} - -int BicFwBlExtComponent::update(string image) { - int ret = 0; - - try { - server.ready(); - ret = bic_update_fw(slot_id, UPDATE_BIC_BOOTLOADER, intf, (char *)image.c_str(), 0); - } catch(string err) { - return FW_STATUS_NOT_SUPPORTED; - } - return ret; -} - -int BicFwBlExtComponent::print_version() { - uint8_t ver[32] = {0}; - int ret = 0; - string board_name = board(); - - //make the strig to uppercase. - transform(board_name.begin(), board_name.end(), board_name.begin(), ::toupper); - try { - server.ready(); - if ( intf == BB_BIC_INTF ) { - ; // do nothing - } else { - ret = bic_is_m2_exp_prsnt(slot_id); - if ( ret < 0 ) { - throw "Error in getting the present status of " + board_name; - } else if ( intf == FEXP_BIC_INTF && (ret == PRESENT_1OU || ret == (PRESENT_1OU + PRESENT_2OU)) ) { - ; // Correct status, do nothing - } else if ( intf == REXP_BIC_INTF && (ret == PRESENT_2OU || ret == (PRESENT_1OU + PRESENT_2OU)) ) { - ; // Correct status, do nothing - } else { - throw board_name + " Board is empty"; - } - } - ret = bic_show_fw_ver(slot_id, FW_BIC_BOOTLOADER, ver, 0, 0, intf); - // Print Bridge-IC Bootloader Version - if ( ret < 0 ) { - throw "Error in getting the version of " + board_name; - } else { - printf("%s Bridge-IC Bootloader Version: v%x.%02x\n", board_name.c_str(), ver[0], ver[1]); - } - } catch(string err) { - printf("%s Bridge-IC Bootloader Version: NA (%s)\n", board_name.c_str(), err.c_str()); - } - return 0; -} - -#endif +int BicFwComponent::update(string image) { return FW_STATUS_NOT_SUPPORTED; } +int BicFwComponent::fupdate(string image) { return FW_STATUS_NOT_SUPPORTED; } +int BicFwComponent::print_version() { return FW_STATUS_NOT_SUPPORTED; } +int BicFwBlComponent::update(string image) { return FW_STATUS_NOT_SUPPORTED; } +int BicFwBlComponent::print_version() { return FW_STATUS_NOT_SUPPORTED; } diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw.h deleted file mode 100644 index 1e218dc2e6c1..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _BIC_FW_H_ -#define _BIC_FW_H_ -#include "fw-util.h" -#include "server.h" - -class BicFwComponent : public Component { - uint8_t slot_id = 0; - uint8_t intf = 0; - Server server; - public: - BicFwComponent(std::string fru, std::string board, std::string comp, uint8_t _slot_id, uint8_t _intf) - : Component(fru, board, comp), slot_id(_slot_id), intf(_intf), server(_slot_id, fru) {} - int update(std::string image); - int fupdate(std::string image); - int print_version(); -}; - -class BicFwBlComponent : public Component { - uint8_t slot_id = 0; - uint8_t intf = 0; - Server server; - public: - BicFwBlComponent(std::string fru, std::string board, std::string comp, uint8_t _slot_id, uint8_t _intf) - : Component(fru, board, comp), slot_id(_slot_id), intf(_intf), server(_slot_id, fru) {} - int update(std::string image); - int print_version(); -}; - -class BicFwExtComponent : public Component { - uint8_t slot_id = 0; - uint8_t intf = 0; - Server server; - public: - BicFwExtComponent(std::string fru, std::string board, std::string comp, uint8_t _slot_id, uint8_t _intf) - : Component(fru, board, comp), slot_id(_slot_id), intf(_intf), server(_slot_id, fru) {} - int update(std::string image); - int fupdate(std::string image); - int print_version(); -}; - -class BicFwBlExtComponent : public Component { - uint8_t slot_id = 0; - uint8_t intf = 0; - Server server; - public: - BicFwBlExtComponent(std::string fru, std::string board, std::string comp, uint8_t _slot_id, uint8_t _intf) - : Component(fru, board, comp), slot_id(_slot_id), intf(_intf), server(_slot_id, fru) {} - int update(std::string image); - int print_version(); -}; - -#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw_ext.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw_ext.cpp new file mode 100644 index 000000000000..d693bb024bf3 --- /dev/null +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw_ext.cpp @@ -0,0 +1,94 @@ +#include "fw-util.h" +#include +#include +#include "server.h" +#include +#include "bic_fw_ext.h" +#ifdef BIC_SUPPORT +#include + +using namespace std; + +int BicFwExtComponent::update(string image) { + int ret = 0; + try { + server.ready(); + expansion.ready(); + ret = bic_update_fw(slot_id, fw_comp, (char *)image.c_str(), FORCE_UPDATE_UNSET); + } catch (string err) { + printf("%s\n", err.c_str()); + return FW_STATUS_NOT_SUPPORTED; + } + return ret; +} + +int BicFwExtComponent::fupdate(string image) { + int ret = 0; + try { + server.ready(); + expansion.ready(); + ret = bic_update_fw(slot_id, fw_comp, (char *)image.c_str(), FORCE_UPDATE_SET); + } catch (string err) { + printf("%s\n", err.c_str()); + return FW_STATUS_NOT_SUPPORTED; + } + return ret; +} + +int BicFwExtComponent::print_version() { + int ret = 0; + uint8_t ver[32] = {0}; + string board_name = name; + transform(board_name.begin(), board_name.end(), board_name.begin(), ::toupper); + try { + server.ready(); + expansion.ready(); + // Print Bridge-IC Version + ret = bic_get_fw_ver(slot_id, fw_comp, ver); + if ( ret < 0 ) { + throw "Error in getting the version of " + board_name; + } else { + printf("%s Bridge-IC Version: v%x.%02x\n", board_name.c_str(), ver[0], ver[1]); + } + } catch(string err) { + printf("%s Bridge-IC Version: NA (%s)\n", board_name.c_str(), err.c_str()); + } + return FW_STATUS_SUCCESS; +} + +int BicFwExtBlComponent::update(string image) { + int ret = 0; + try { + server.ready(); + expansion.ready(); + ret = bic_update_fw(slot_id, fw_comp, (char *)image.c_str(), FORCE_UPDATE_UNSET); + } catch(string err) { + printf("%s\n", err.c_str()); + return FW_STATUS_NOT_SUPPORTED; + } + return ret; +} + +int BicFwExtBlComponent::print_version() { + int ret = 0; + uint8_t ver[32]; + + string board_name = name; + transform(board_name.begin(), board_name.end(), board_name.begin(), ::toupper); + try { + server.ready(); + expansion.ready(); + // Print Bridge-IC Bootloader Version + ret = bic_get_fw_ver(slot_id, fw_comp, ver); + if ( ret < 0 ) { + throw "Error in getting the version of " + board_name; + } else { + printf("%s Bridge-IC Bootloader Version: v%x.%02x\n", board_name.c_str(), ver[0], ver[1]); + } + } catch(string err) { + printf("%s Bridge-IC Bootloader Version: NA (%s)\n", board_name.c_str(), err.c_str()); + } + return FW_STATUS_SUCCESS; +} +#endif + diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw_ext.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw_ext.h new file mode 100644 index 000000000000..3b918436f680 --- /dev/null +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_fw_ext.h @@ -0,0 +1,36 @@ +#ifndef _BIC_FW_EXT_H_ +#define _BIC_FW_EXT_H_ +#include "bic_fw.h" +#include "server.h" +#include "expansion.h" + +using namespace std; + +class BicFwExtComponent : public BicFwComponent { + uint8_t slot_id = 0; + uint8_t fw_comp = 0; + string name; + Server server; + ExpansionBoard expansion; + public: + BicFwExtComponent(string fru, string comp, uint8_t _slot_id, string _name, uint8_t _fw_comp) + : BicFwComponent(fru, comp, _slot_id), slot_id(_slot_id), fw_comp(_fw_comp), name(_name), server(_slot_id, fru), expansion(_slot_id, fru, _name, _fw_comp) {} + int update(string image); + int fupdate(string image); + int print_version(); +}; + +class BicFwExtBlComponent : public BicFwBlComponent { + uint8_t slot_id = 0; + uint8_t fw_comp = 0; + string name; + Server server; + ExpansionBoard expansion; + public: + BicFwExtBlComponent(string fru, string comp, uint8_t _slot_id, string _name, uint8_t _fw_comp) + : BicFwBlComponent(fru, comp, _slot_id), slot_id(_slot_id), fw_comp(_fw_comp), name(_name), server(_slot_id, fru), expansion(_slot_id, fru, _name, _fw_comp) {} + int update(string image); + int print_version(); +}; + +#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_me.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_me.cpp deleted file mode 100644 index e897b6e81b08..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_me.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "fw-util.h" -#include -#include -#include "server.h" -#include -#include "bic_me.h" -#ifdef BIC_SUPPORT -#include - -using namespace std; - -int MeFwComponent::print_version() { - uint8_t ver[32] = {0}; - int ret = 0; - string board_name = board(); - - transform(board_name.begin(), board_name.end(), board_name.begin(), ::toupper); - try { - server.ready(); - ret = bic_show_fw_ver(slot_id, FW_ME, ver, 0, 0, intf); - // Print ME Version - if ( ret < 0 ) { - throw "Error in getting the version of " + board_name; - } else { - printf("ME Version: %x.%x.%x.%x%x\n", ver[0], ver[1], ver[2], ver[3], ver[4]); - } - } catch(string err) { - printf("ME Version: NA (%s)\n", err.c_str()); - } - return ret; -} - -#endif - diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_me.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_me.h deleted file mode 100644 index 72982149bce7..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_me.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _BIC_ME_H_ -#define _BIC_ME_H_ -#include "fw-util.h" -#include "server.h" - -class MeFwComponent : public Component { - uint8_t slot_id = 0; - uint8_t intf = 0; - Server server; - public: - MeFwComponent(std::string fru, std::string board, std::string comp, uint8_t _slot_id, uint8_t _intf) - : Component(fru, board, comp), slot_id(_slot_id), intf(_intf), server(_slot_id, fru) {} - int print_version(); -}; - -#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_vr.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_vr.cpp index 34af16775738..b1985f011164 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_vr.cpp +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_vr.cpp @@ -32,8 +32,10 @@ int VrComponent::print_version() addr = vr.first; server.ready(); - ret = bic_get_vr_ver_cache(slot_id, intf, bus, addr, ver_str); - if ( ret == 0 ) { + ret = bic_get_vr_ver_cache(slot_id, NONE_INTF, bus, addr, ver_str); + if ( ret < 0 ) { + throw "Error in getting the version of " + vr.second; + } else { printf("%s Version : %s \n", vr.second.c_str(), ver_str); //ex. ver_str = Infineon 0x588C254B } @@ -47,11 +49,12 @@ int VrComponent::print_version() int VrComponent::update(string image) { - int ret; + int ret = 0; try { server.ready(); - return bic_update_fw(slot_id, UPDATE_VR, intf, (char *)image.c_str(), 0); + ret = bic_update_fw(slot_id, FW_VR, (char *)image.c_str(), FORCE_UPDATE_UNSET); } catch (string err) { + printf("%s\n", err.c_str()); return FW_STATUS_NOT_SUPPORTED; } return ret; diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_vr.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_vr.h index 0049bf988974..65d11be6272d 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_vr.h +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_vr.h @@ -6,11 +6,11 @@ class VrComponent : public Component { uint8_t slot_id = 0; - uint8_t intf = 0; + uint8_t fw_comp = 0; Server server; public: - VrComponent(std::string fru, std::string board, std::string comp, uint8_t _slot_id, uint8_t _intf) - : Component(fru, board, comp), slot_id(_slot_id), intf(_intf), server(_slot_id, fru){} + VrComponent(std::string fru, std::string comp, uint8_t _slot_id, uint8_t _fw_comp) + : Component(fru, comp), slot_id(_slot_id), fw_comp(_fw_comp), server(_slot_id, fru){} int print_version(); int update(std::string image); }; diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bios.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bios.h deleted file mode 100644 index 4b558a034ff6..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bios.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _BIOS_H_ -#define _BIOS_H_ -#include "fw-util.h" -#include "server.h" - -class BiosComponent : public Component { - uint8_t slot_id = 0; - uint8_t intf = 0; - Server server; - - public: - BiosComponent(std::string fru, std::string board, std::string comp, uint8_t _slot_id, uint8_t _intf) - : Component(fru, board, comp), slot_id(_slot_id), intf(_intf), server(_slot_id, fru) {} - int update(std::string image); - int fupdate(std::string image); - int print_version(); -}; - -#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc.cpp deleted file mode 100644 index a6731f421767..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "bmc.h" - -using namespace std; - -#define BMC_RW_OFFSET (64 * 1024) -#define ROMX_SIZE (84 * 1024) - -int BmcComponent::update(string image_path) -{ - string dev; - int ret; - string flash_image = image_path; - stringstream cmd_str; - - if (_mtd_name == "") { - // Upgrade not supported - return FW_STATUS_NOT_SUPPORTED; - } - - if (is_valid(image_path) == false) { - system.error << image_path << " is not a valid BMC image for " << system.name() << endl; - return FW_STATUS_FAILURE; - } - - if (!system.get_mtd_name(_mtd_name, dev)) { - system.error << "Failed to get device for " << _mtd_name << endl; - return FW_STATUS_FAILURE; - } - - syslog(LOG_CRIT, "BMC fw upgrade initiated"); - - system.output << "Flashing to device: " << dev << endl; - if (_skip_offset > 0 || _writable_offset > 0) { - flash_image = image_path + "-tmp"; - // Ensure that we are not overwriting an existing file. - while (access( flash_image.c_str(), F_OK ) != -1) { - flash_image.append("_"); - } - // Open input image and seek skipping to the writable offset. - int fd_r = open(image_path.c_str(), O_RDONLY); - if (fd_r < 0) { - system.error << "Cannot open " << image_path << " for reading" << endl; - return FW_STATUS_FAILURE; - } - if (lseek(fd_r, _skip_offset, SEEK_SET) != (off_t)_skip_offset) { - close(fd_r); - system.error << "Cannot seek " << image_path << endl; - return FW_STATUS_FAILURE; - } - // create tmp file for writing. - int fd_w = open(flash_image.c_str(), O_WRONLY | O_CREAT, 0666); - if (fd_w < 0) { - system.error << "Cannot write to " << flash_image << endl; - close(fd_r); - return FW_STATUS_FAILURE; - } - uint8_t buf[1024]; - size_t r_b; - - if (_skip_offset > _writable_offset) { - size_t copy = _skip_offset - _writable_offset; - int fd_d = open(dev.c_str(), O_RDONLY); - if (fd_d < 0) { - close(fd_r); - close(fd_w); - return FW_STATUS_FAILURE; - } - while (copy > 0) { - size_t to_copy = copy > sizeof(buf) ? sizeof(buf) : copy; - r_b = read(fd_d, buf, to_copy); - if (r_b != to_copy) { - close(fd_r); - close(fd_w); - close(fd_d); - return FW_STATUS_FAILURE; - } - if (write(fd_w, buf, to_copy) != (int)to_copy) { - close(fd_r); - close(fd_w); - close(fd_d); - return FW_STATUS_FAILURE; - } - copy -= to_copy; - } - close(fd_d); - } - - // Copy from r to w. - while ((r_b = read(fd_r, buf, 1024)) > 0) { - if (write(fd_w, buf, r_b) != (int)r_b) { - close(fd_r); - close(fd_w); - return -1; - } - } - close(fd_r); - close(fd_w); - } - cmd_str << "flashcp -v " << flash_image << " " << dev; - ret = system.runcmd(cmd_str.str()); - if (_writable_offset > 0) { - // this is a temp. file, remove it. - remove(flash_image.c_str()); - } - - // If flashcp cmd was successful, keep historical info that BMC fw was upgraded - if (ret == 0) { - syslog(LOG_CRIT, "BMC fw upgrade completed. Version: %s", get_bmc_version(dev).c_str()); - } - - return ret; -} - -std::string BmcComponent::get_bmc_version() -{ - std::string bmc_ver = "NA"; - std::string mtd; - if (!system.get_mtd_name(_vers_mtd, mtd)) { - return bmc_ver; - } - return get_bmc_version(mtd); -} - -std::string BmcComponent::get_bmc_version(const std::string &mtd) -{ - // parsering the image to get the version string - std::string bmc_ver = "NA"; - char cmd[128]; - FILE *fp; - - snprintf(cmd, sizeof(cmd), - "strings %s | grep -E 'U-Boot 20[[:digit:]]{2}\\.[[:digit:]]{2}'", mtd.c_str()); - fp = popen(cmd, "r"); - if (fp) { - char line[256]; - char *ver = 0; - while (fgets(line, sizeof(line), fp)) { - int ret; - ret = sscanf(line, "U-Boot 20%*2d.%*2d%*[ ]%m[^ \n]%*[ ](%*[^)])\n", &ver); - if (1 == ret) { - bmc_ver = ver; - break; - } - } - if (ver) { - free(ver); - } - pclose(fp); - } - - return bmc_ver; -} - -int BmcComponent::print_version() -{ - string mtd; - - string comp = _component; - std::transform(comp.begin(), comp.end(),comp.begin(), ::toupper); - - if (_vers_mtd == "") { - system.output << comp << " Version: " << system.version() << endl; - return FW_STATUS_SUCCESS; - } - - system.output << comp << " Version: " << get_bmc_version() << endl; - return FW_STATUS_SUCCESS; -} - -class SystemConfig { - public: - bool dual_flash; - System system; - SystemConfig() : system() { - // If flash1 exists, then we have two flashes - if (system.get_mtd_name("flash1")) { - dual_flash = true; - } else { - dual_flash = false; - } - if (dual_flash) { - int vboot = system.vboot_support_status(); - if (vboot != VBOOT_NO_SUPPORT) { - // If verified boot is enabled, we should - // have the romx partition - if (vboot == VBOOT_HW_ENFORCE) { - // Locked down, Update from a 64k offset. - static BmcComponent bmc("bmc", "bmc", "bmc", system, "flash1rw", "u-boot", BMC_RW_OFFSET, ROMX_SIZE); - // Locked down, Allow getting version of ROM, but do not allow - // upgrading it. - static BmcComponent rom("bmc", "bmc", "rom", system, "", "u-bootro"); - } else { - // Unlocked Flash, Upgrade the full BMC flash1. - static BmcComponent bmc("bmc", "bmc", "bmc", system, "flash1", "u-boot"); - // Unlocked flash, Allow upgrading the ROM. - static BmcComponent rom("bmc", "bmc", "rom", system, "flash0", "u-bootro"); - } - } else { - // non-verified-boot. BMC boots off of flash0. - static BmcComponent bmc("bmc", "bmc", "bmc", system, "flash0", "u-boot"); - // Dual flash supported, but not in verified boot format. - // Allow flashing the second flash. Read version from u-boot partition. - static BmcComponent bmcalt("bmc", "bmc", "altbmc", system, "flash1", "u-bootx"); - } - // Verified boot supported and in dual-flash mode. - } else { - // We just have the one flash. Allow upgrading flash0. - static BmcComponent bmc("bmc", "bmc", "bmc", system, "flash0"); - } - } -}; - -SystemConfig bmc_sysconf; diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc.h deleted file mode 100644 index 2651caae06ff..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _BMC_H_ -#define _BMC_H_ -#include -#include "fw-util.h" - -class BmcComponent : public Component { - protected: - System &system; - std::string _mtd_name; - std::string _vers_mtd; - size_t _writable_offset; - size_t _skip_offset; - std::string get_bmc_version(void); - std::string get_bmc_version(const std::string &mtd); - public: - BmcComponent(std::string fru, std::string board, std::string comp, System &sys, std::string mtd, std::string vers = "", size_t w_offset = 0, size_t skip_offset = 0) - : Component(fru, board, comp), system(sys), _mtd_name(mtd), _vers_mtd(vers), _writable_offset(w_offset), _skip_offset(skip_offset) {} - - int update(std::string image); - int print_version(); - virtual bool is_valid(std::string &image); -}; - -#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc_cpld.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc_cpld.cpp index c4d7c735fc11..3fae2866444a 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc_cpld.cpp +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc_cpld.cpp @@ -94,10 +94,14 @@ image_info BmcCpldComponent::check_image(string image, bool force) { int BmcCpldComponent::get_cpld_version(uint8_t *ver) { int ret = 0; - uint8_t tbuf[4] = {0x00, 0x20, 0x00, 0x28}; + uint32_t ver_reg = ON_CHIP_FLASH_USER_VER; + uint8_t tbuf[4] = {0x00}; uint8_t tlen = 4; uint8_t rlen = 4; int i2cfd = 0; + + memcpy(tbuf, (uint8_t *)&ver_reg, tlen); + reverse(tbuf, tbuf + 4); string i2cdev = "/dev/i2c-" + to_string(bus); if ((i2cfd = open(i2cdev.c_str(), O_RDWR)) < 0) { @@ -116,11 +120,6 @@ int BmcCpldComponent::get_cpld_version(uint8_t *ver) { return ret; } -/* - * The definition of ON_CHIP_FLASH_USER_VER in fby3 is different to libfpga. - * TODO: We should add ON_CHIP_FLASH_USER_VER into altera_max10_attr_t, - * so it can be defined by each project. -*/ int BmcCpldComponent::print_version() { uint8_t ver[4] = {0}; @@ -129,9 +128,8 @@ int BmcCpldComponent::print_version() // Print CPLD Version transform(fru_name.begin(), fru_name.end(), fru_name.begin(), ::toupper); if ( get_cpld_version(ver) < 0 ) { - printf("%s CPLD Version: NA\n", fru_name.c_str()); - } - else { + throw "Error in getting the version of " + fru_name; + } else { printf("%s CPLD Version: %02X%02X%02X%02X\n", fru_name.c_str(), ver[3], ver[2], ver[1], ver[0]); } } catch(string err) { @@ -140,10 +138,47 @@ int BmcCpldComponent::print_version() return 0; } -int BmcCpldComponent::update(string image) +int BmcCpldComponent::update_cpld(string image) { int ret = 0; char key[32] = {0}; + uint8_t bmc_location = 0; + string bmc_location_str; + string image_tmp; + size_t pos = image.find("-tmp"); + image_tmp = image.substr(0, pos); + + if ( fby3_common_get_bmc_location(&bmc_location) < 0 ) { + printf("Failed to initialize the fw-util\n"); + return FW_STATUS_FAILURE; + } + + if ( bmc_location == NIC_BMC ) { + bmc_location_str = "NIC Expansion"; + } else { + bmc_location_str = "baseboard"; + } + + syslog(LOG_CRIT, "Updating CPLD on %s. File: %s", bmc_location_str.c_str(), image_tmp.c_str()); + if (cpld_intf_open(pld_type, INTF_I2C, &attr)) { + printf("Cannot open i2c!\n"); + ret = FW_STATUS_FAILURE; + } else { + //TODO: need to update 2 CFMs + ret = cpld_program((char *)image.c_str(), key, false); + cpld_intf_close(INTF_I2C); + if ( ret < 0 ) { + printf("Error Occur at updating CPLD FW!\n"); + } + } + + syslog(LOG_CRIT, "Updated CPLD on %s. File: %s. Result: %s", bmc_location_str.c_str(), image_tmp.c_str(), (ret < 0)?"Fail":"Success"); + return ret; +} + +int BmcCpldComponent::update(string image) +{ + int ret = 0; image_info image_sts = check_image(image, false); if ( image_sts.result == false ) { @@ -154,16 +189,7 @@ int BmcCpldComponent::update(string image) //use the new path image = image_sts.new_path; - if (cpld_intf_open(pld_type, INTF_I2C, &attr)) { - printf("Cannot open i2c!\n"); - return -1; - } - - ret = cpld_program((char *)image.c_str(), key, false); - cpld_intf_close(INTF_I2C); - if (ret) { - printf("Error Occur at updating CPLD FW!\n"); - } + ret = update_cpld(image); //remove the tmp file remove(image.c_str()); @@ -173,21 +199,11 @@ int BmcCpldComponent::update(string image) int BmcCpldComponent::fupdate(string image) { int ret = 0; - char key[32] = {0}; image_info image_sts = check_image(image, true); image = image_sts.new_path; - if (cpld_intf_open(pld_type, INTF_I2C, &attr)) { - printf("Cannot open i2c!\n"); - return -1; - } - - ret = cpld_program((char *)image.c_str(), key, false); - cpld_intf_close(INTF_I2C); - if (ret) { - printf("Error Occur at updating CPLD FW!\n"); - } + ret = update_cpld(image); //remove the tmp file remove(image.c_str()); diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc_cpld.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc_cpld.h index f2ef200bb20e..82b701c85bbf 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc_cpld.h +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bmc_cpld.h @@ -4,6 +4,8 @@ #include "fw-util.h" #include +using namespace std; + // on-chip Flash IP #define ON_CHIP_FLASH_IP_CSR_BASE (0x00200020) #define ON_CHIP_FLASH_IP_CSR_STATUS_REG (ON_CHIP_FLASH_IP_CSR_BASE + 0x0) @@ -13,13 +15,15 @@ // Dual-boot IP #define DUAL_BOOT_IP_BASE (0x00200000) -#define CFM0_START_ADDR (0x00064000) -#define CFM0_END_ADDR (0x000BFFFF) +#define CFM1_START_ADDR (0x00064000) +#define CFM1_END_ADDR (0x000BFFFF) +#define CFM2_START_ADDR (0x00008000) +#define CFM2_END_ADDR (0x00063FFF) enum { CFM_IMAGE_NONE = 0, - CFM_IMAGE_0, CFM_IMAGE_1, + CFM_IMAGE_2, }; typedef struct image_check { @@ -34,13 +38,15 @@ class BmcCpldComponent : public Component { altera_max10_attr_t attr; int get_cpld_version(uint8_t *ver); private: - image_info check_image(std::string image, bool force); + image_info check_image(string image, bool force); + int update_cpld(string image); public: - BmcCpldComponent(std::string fru, std::string board, std::string comp, uint8_t type, uint8_t _bus, uint8_t _addr) - : Component(fru, board, comp), pld_type(type), bus(_bus), addr(_addr), attr{bus, addr, CFM_IMAGE_0, CFM0_START_ADDR, CFM0_END_ADDR, ON_CHIP_FLASH_IP_CSR_BASE, ON_CHIP_FLASH_IP_DATA_REG, DUAL_BOOT_IP_BASE} {} + BmcCpldComponent(string fru, string comp, uint8_t type, uint8_t _bus, uint8_t _addr) + : Component(fru, comp), pld_type(type), bus(_bus), addr(_addr), + attr{bus, addr, CFM_IMAGE_1, CFM1_START_ADDR, CFM1_END_ADDR, ON_CHIP_FLASH_IP_CSR_BASE, ON_CHIP_FLASH_IP_DATA_REG, DUAL_BOOT_IP_BASE} {} int print_version(); - int update(std::string image); - int fupdate(std::string image); + int update(string image); + int fupdate(string image); }; #endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/check_image.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/check_image.cpp deleted file mode 100644 index e5e33dbeee15..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/check_image.cpp +++ /dev/null @@ -1,434 +0,0 @@ -#include -#include -#include -#include -#include -#include -extern "C" { - #include -} -#include -#include -#include "bmc.h" - -int __attribute__((weak)) fdt_first_subnode(const void *fdt, int offset) -{ - int depth = 0; - - offset = fdt_next_node(fdt, offset, &depth); - if (offset < 0 || depth != 1) - return -FDT_ERR_NOTFOUND; - - return offset; -} -int __attribute__((weak)) fdt_next_subnode(const void *fdt, int offset) -{ - int depth = 1; - do { - offset = fdt_next_node(fdt, offset, &depth); - if (offset < 0 || depth < 1) - return -FDT_ERR_NOTFOUND; - } while (depth > 1); - return offset; -} - -#ifndef fdt_for_each_subnode -#define fdt_for_each_subnode(node, fdt, parent) \ - for (node = fdt_first_subnode(fdt, parent); \ - node >= 0; \ - node = fdt_next_subnode(fdt, node)) -#endif - -#define FLASH_SIZE (32 * 1024 * 1024) - -using namespace std; - -class Checker { - protected: - string name; - off_t offset; - off_t size; - public: - Checker(string n, off_t of, off_t sz) : name(n), offset(of), size(sz) {} - virtual bool is_valid(const unsigned char *image) { - return true; - } -}; - -class LegacyChecker : public Checker { - private: - static const uint32_t MAGIC = 0x27051956; - static const off_t HEADER_SIZE = 64; - static const off_t MAGIC_OFFSET = 0; - static const off_t HEADER_CRC_OFFSET = 4; - static const off_t SIZE_OFFSET = 12; - static const off_t DATA_CRC_OFFSET = 24; - uint32_t get_word(const unsigned char *bytes, off_t offset) - { - return ntohl(*(uint32_t *)(bytes + offset)); - } - void set_word(const unsigned char *bytes, off_t offset, uint32_t word) - { - *(uint32_t *)(bytes + offset) = htonl(word); - } - public: - LegacyChecker(string n, off_t of, off_t sz) : Checker(n, of, sz) {} - - virtual bool is_valid(const unsigned char *image) { - uint32_t hcrc, dcrc, hcrc_c, dcrc_c; - unsigned char hdr[HEADER_SIZE]; - const unsigned char *data; - - if (size <= HEADER_SIZE) { - return false; - } - image = image + offset; - - memcpy(hdr, image, HEADER_SIZE); - if (get_word(hdr, MAGIC_OFFSET) != MAGIC) { - return false; - } - hcrc = get_word(hdr, HEADER_CRC_OFFSET); - set_word(hdr, HEADER_CRC_OFFSET, 0); - hcrc_c = crc32(0, hdr, HEADER_SIZE); - if (hcrc != hcrc_c) { - return false; - } - dcrc = get_word(hdr, DATA_CRC_OFFSET); - off_t len = (off_t)get_word(hdr, SIZE_OFFSET); - data = image + HEADER_SIZE; - if (len + HEADER_SIZE > size) { - return false; - } - dcrc_c = crc32(0, data, len); - if (dcrc != dcrc_c) { - return false; - } - return true; - } -}; - -class FITChecker : public Checker { - int num_nodes; - public: - FITChecker(string n, off_t of, off_t sz, int nodes) : Checker(n, of, sz), num_nodes(nodes) {} - - virtual bool is_valid(const unsigned char *image) { - const void *fdt = (const void *)(image + offset); - int nodep, node, hashnode; - size_t data_size; - uint32_t data_pos; - const unsigned char *data = NULL; - unsigned char shasum[SHA256_DIGEST_LENGTH]; - int len = 0; - int valid_nodes = 0; - - if (size < (off_t)FDT_V17_SIZE || fdt_check_header(fdt) != 0) { - return false; - } - - // Get the list of images stored in this FDT - nodep = fdt_subnode_offset(fdt, 0, "images"); - if (nodep < 0) { - return false; - } - - // For each image, compute the sha256 digest and - // compare it against the one stored in the FDT */ - fdt_for_each_subnode(node, fdt, nodep) { - if (node < 0) { - continue; - } - // Get the data portion and compute its sha256 digest */ - data = (const unsigned char *)fdt_getprop(fdt, node, "data", &len); - if (!data || len == 0) { - // Could not find data property. See if we have - // a link to the image instead */ - data = (const unsigned char *)fdt_getprop(fdt, node, "data-size", &len); - if (!data || len != 4) { - return false; - } - data_size = ntohl(*(uint32_t *)data); - data = (const unsigned char *)fdt_getprop(fdt, node, "data-position", &len); - if (!data || len != 4) { - return false; - } - data_pos = ntohl(*(uint32_t *)data); - data = (const unsigned char *)fdt + data_pos; - } else { - data_size = (size_t)len; - } - if ((off_t)data_size > size) { - // This partition cannot contain this FDT. Most - // probably we are using the wrong partition - //description - return false; - } - SHA256(data, data_size, shasum); - - // Get the sha256 digest stored in the image */ - hashnode = fdt_subnode_offset(fdt, node, "hash@1"); - if (hashnode < 0) { - return false; - } - data = (const unsigned char *)fdt_getprop(fdt, hashnode, "algo", &len); - if (!data || strlen("sha256") > (unsigned int)len || strcmp((char *)data, "sha256") != 0) { - return false; - } - data = (const unsigned char *)fdt_getprop(fdt, hashnode, "value", &len); - if (!data || len != SHA256_DIGEST_LENGTH) { - return false; - } - - // Check if they match */ - if (memcmp(data, shasum, SHA256_DIGEST_LENGTH)) { - return false; - } - valid_nodes++; - } - nodep = fdt_subnode_offset(fdt, 0, "configurations"); - if (nodep < 0) { - return false; - } - return valid_nodes >= num_nodes ? true : false; - } -}; - -class PartitionDescriptor -{ - string name; - off_t offset; - off_t size; - Checker *checker; - int num_nodes; - string type; - public: - PartitionDescriptor(string n, json_t *obj) : name(n), offset(0), size(0), num_nodes(1) { - json_t *tmp = json_object_get(obj, "offset"); - if (!tmp || !json_is_number(tmp)) { - throw "OFFSET not found parsing " + name; - } - offset = json_integer_value(tmp) * 1024; - - tmp = json_object_get(obj, "size"); - if (!tmp || !json_is_number(tmp)) { - throw "SIZE not found parsing " + name; - } - size = json_integer_value(tmp) * 1024; - if (size == 0) { - throw "SIZE cannot be zero parsing " + name; - } - - tmp = json_object_get(obj, "type"); - if (!tmp || !json_is_string(tmp)) { - throw "TYPE not found parsing " + name; - } - type = string(json_string_value(tmp)); - - tmp = json_object_get(obj, "num-nodes"); - if (tmp && json_is_number(tmp)) { - num_nodes = json_integer_value(tmp); - } - - if (type == "fit") { - checker = new FITChecker(name, offset, size, num_nodes); - } else if (type == "legacy") { - checker = new LegacyChecker(name, offset, size); - } else if (type == "ignore") { - checker = new Checker(name, offset, size); - } else { - throw "TYPE unknown" + type + " in " + name; - } - } - bool valid(const unsigned char *image, off_t image_size) - { - if (image_size < offset) - return false; - // A valid image might not take up the whole partition. - // So image_size < offset + size is possible. - return checker->is_valid(image); - } -}; - -class ImageDescriptor { - string name; - list partitions; - public: - ImageDescriptor(string n, json_t *obj) : name(n), partitions() { - int num = json_object_size(obj); - if (num == 0) { - return; - } - void *it; - int i; - for (i = 0, it = json_object_iter(obj); - i < num && it != NULL; - i++, it = json_object_iter_next(obj, it)) { - const char *name = json_object_iter_key(it); - json_t *el = json_object_iter_value(it); - try { - partitions.push_back(new PartitionDescriptor(string(name), el)); - } catch (string &ex) { - throw string("Exception received parsing ") + name + " (" + ex + ")"; - } - } - } - bool is_valid(const unsigned char *image, size_t size) { - for (auto it = partitions.begin(); it != partitions.end(); it++) { - if (!(*it)->valid(image, size)) { - return false; - } - } - return true; - } - ~ImageDescriptor() { - partitions.clear(); - } -}; - -class ImageDescriptorList; - -class Image { - const unsigned char *image; - size_t fsize; - int fd; - friend class ImageDescriptorList; - bool match(const char *s, const char *p) - { - for (; *s != '\0' && *p != '\0'; s++, p++) { - bool esc = false; - if (*p == '\\') { - p++; - esc = true; - } - // If escaping and we are looking for a decimal - if (esc && *p == 'd') { - if (!isdigit(*s)) { - return false; - } - } else if (*p != *s) { - return false; - } - } - return true; - } - bool istrncmp(const char *s1, const char *s2, size_t len) - { - for (size_t i = 0; i < len; i++, s1++, s2++) { - if (tolower(*s1) != tolower(*s2)) - return false; - } - return true; - } - public: - Image(string &file) : image(NULL) { - fd = open(file.c_str(), O_RDONLY); - if (fd < 0) { - throw "Cannot open " + string(file); - } - fsize = lseek(fd, 0, SEEK_END); - if (fsize == 0) { - throw "Zero size image file " + string(file); - } - lseek(fd, 0, SEEK_SET); - unsigned char *img = (unsigned char *)calloc(FLASH_SIZE, 1); - for (int bread = 0; bread < (int)fsize;) { - int rc = read(fd, img + bread, fsize - bread); - if (rc > 0) { - bread += rc; - } - } - image = (const unsigned char *)img; - } - ~Image() { - if (image) - free((void *)image); - if (fd >= 0) - close(fd); - } - bool supports_machine(string &machine) { - // Just dont check in the last 256 bytes of the image. Technically we - // need to find this in the uboot section so it should be pretty early on. - for (int i = 0; i < (int)fsize - 256; i++) { - const char *str = (const char *)&image[i]; - if (isalnum(image[i]) && match(str, "U-Boot \\d\\d\\d\\d\\.\\d\\d ")) { - str += 15; - if (*str == '(') { - for (int j = 0; j < 32 && *str != ')'; j++, str++); - if (*(str++) != ')') - continue; - for (; *str == ' '; str++); - } - if (istrncmp(str, machine.c_str(), machine.size())) - return true; - } - } - return false; - } -}; - - - -class ImageDescriptorList { - list images; - json_t *conf; - public: - ImageDescriptorList(const char *desc_file) : conf(NULL) { - json_t *conf; - json_error_t error; - int num; - - conf = json_load_file(desc_file, 0, &error); - if (!conf) { - throw "Cannot load file " + string(desc_file); - } - num = json_object_size(conf); - if (num == 0) { - throw "Unsupported number of images in " + string(desc_file); - } - int i; - void *iter; - for (i = 0, iter = json_object_iter(conf); - i < num && iter; - i++, iter = json_object_iter_next(conf, iter)) { - const char *key = json_object_iter_key(iter); - json_t *obj = (json_t *)json_object_iter_value(iter); - try { - images.push_back(new ImageDescriptor(string(key), obj)); - } catch (string &ex) { - throw "Parsing " + string(desc_file) + " invalid " + string(key) + " (" + ex + ")"; - } - } - } - ~ImageDescriptorList() { - if (conf) - json_decref(conf); - } - bool is_valid(Image &image) - { - for (auto it = images.begin(); it != images.end(); it++) { - if ((*it)->is_valid(image.image, image.fsize)) - return true; - } - return false; - } -}; - -bool BmcComponent::is_valid(string &file) -{ - bool valid = false; - try { - Image image(file); - string machine = system.name(); - if (!image.supports_machine(machine)) { - return false; - } - ImageDescriptorList desc_list(system.partition_conf().c_str()); - valid = desc_list.is_valid(image); - } catch(string &ex) { - cerr << ex << endl; - return false; - } - return valid; -} - diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/expansion.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/expansion.cpp new file mode 100644 index 000000000000..9f44c2453d3b --- /dev/null +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/expansion.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include "expansion.h" +#ifdef BIC_SUPPORT +#include + +using namespace std; + +void ExpansionBoard::ready() +{ + uint8_t config_status = 0; + bool is_present = true; + int ret = 0; + + switch(fw_comp) { + case FW_CPLD: + case FW_BIC: + case FW_BIC_BOOTLOADER: + case FW_BB_BIC: + case FW_BB_BIC_BOOTLOADER: + case FW_BB_CPLD: + return; + } + + ret = bic_is_m2_exp_prsnt(slot_id); + if ( ret < 0 ) { + throw "Failed to get the config from " + fru + ":" + board_name; + } + + config_status = (uint8_t) ret; + switch (fw_comp) { + case FW_1OU_BIC: + case FW_1OU_BIC_BOOTLOADER: + case FW_1OU_CPLD: + if ( (config_status & PRESENT_1OU) != PRESENT_1OU ) + is_present = false; + break; + case FW_2OU_BIC: + case FW_2OU_BIC_BOOTLOADER: + case FW_2OU_CPLD: + if ( (config_status & PRESENT_2OU) != PRESENT_2OU ) + is_present = false; + break; + default: + break; + } + + if ( is_present == false ) + throw board_name + " is empty"; +} +#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/expansion.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/expansion.h new file mode 100644 index 000000000000..607c2f85f539 --- /dev/null +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/expansion.h @@ -0,0 +1,20 @@ +#ifndef _EXPANSION_H_ +#define _EXPANSION_H_ +#include "server.h" + +using namespace std; + +class ExpansionBoard : public Server { + private: + uint8_t slot_id = 0; + string fru; + string board_name; + uint8_t fw_comp = 0; + public: + ExpansionBoard(uint8_t _slot_id, string _fru, string _board_name, uint8_t _fw_comp) + : Server(_slot_id, fru), slot_id(_slot_id), fru(_fru), board_name(_board_name), fw_comp(_fw_comp) {} + // Throws exception if not + void ready(); +}; + +#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fscd.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fscd.cpp deleted file mode 100644 index 6fa3672caf09..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fscd.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include -#include "fw-util.h" -#include "fscd.h" -#include - -#define FSC_CONFIG "/etc/fsc-config.json" - -using namespace std; - -int FscdComponent::print_version() - { - json_error_t error; - json_t *conf, *vers; - - cout << "Fan Speed Controller Version: "; - conf = json_load_file(FSC_CONFIG, 0, &error); - if(!conf) { - cout << "NA" << endl; - return FW_STATUS_FAILURE; - } - vers = json_object_get(conf, "version"); - if(!vers || !json_is_string(vers)) { - cout << "NA" << endl; - } else { - cout << string(json_string_value(vers)) << endl; - } - json_decref(conf); - return FW_STATUS_SUCCESS; - } diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fscd.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fscd.h deleted file mode 100644 index 45395b285192..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fscd.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _FSCD_H_ -#define _FSCD_H_ -#include "fw-util.h" - -using namespace std; - -class FscdComponent : public Component { - public: - FscdComponent(string fru, string board, string comp) - : Component(fru, board, comp) {} - int print_version(); -}; - -#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fw-util.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fw-util.cpp deleted file mode 100644 index 9d22c8cf6f26..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fw-util.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/* - * fw-util.cpp - * - * Copyright 2017-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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "fw-util.h" - -using namespace std; - -string exec_name = "Unknown"; -std::map>> *Component::fru_list = NULL; - -Component::Component(string fru, string board, string component) - : _fru(fru), _board(board), _component(component) -{ - fru_list_setup(); - (*fru_list)[fru][board][component] = this; -} - -Component::~Component() -{ - (*fru_list)[_fru][_board].erase(_component); - (*fru_list)[_fru].erase(_board); - if ((*fru_list)[_fru].size() == 0) { - fru_list->erase(_fru); - } -} - -bool Component::is_fru_list_valid() { - if (!fru_list) { - cerr << "is fru list created?" << endl; - return false; - } - return true; -} - -bool Component::is_fru_valid(string fru) { - if (fru_list->find(fru) == fru_list->end() && fru != "all" ) { - if ( fru.empty() ) { - cerr << "FRU is not set" << endl; - } else { - cerr << "Invalid fru: " << fru << endl; - } - return false; - } - return true; -} - -bool Component::is_board_valid(string fru, string board) { - if ((*fru_list)[fru].find(board) == (*fru_list)[fru].end()) { - if ( board.empty() ) { - cerr << "Board is not set" << endl; - } else { - cerr << "Invalid board: " << board << endl; - } - return false; - } - return true; -} - -bool Component::is_component_valid(string fru, string board, string comp) { - if ((*fru_list)[fru][board].find(comp) == (*fru_list)[fru][board].end()) { - if ( comp.empty() ) { - cerr << "a component or an action is not set" << endl; - } else { - cerr << "Invalid component: " << comp << endl; - } - return false; - } - return true; -} - -Component *Component::get_component(string fru, string board, string comp) -{ - return (*fru_list)[fru][board][comp]; -} - -class ProcessLock { - private: - string file; - int fd; - uint8_t _fru; - bool _ok; - bool _terminate; - public: - ProcessLock() { - _terminate = false; - } - - void lock_file(uint8_t fru, string file){ - _ok = false; - _fru = fru; - fd = open(file.c_str(), O_RDWR|O_CREAT, 0666); - if (fd < 0) { - return; - } - if (flock(fd, LOCK_EX | LOCK_NB) < 0) { - close(fd); - fd = -1; - return; - } - _ok = true; - } - - void setTerminate(bool terminate) { - _terminate = terminate; - } - - bool getTerminate() { - return _terminate; - } - - uint8_t getFru() { - return _fru; - } - - ~ProcessLock() { - if (_ok) { - remove(file.c_str()); - close(fd); - } - } - - bool ok() { - return _ok; - } -}; - -ProcessLock * plock = new ProcessLock(); - -void fw_util_sig_handler(int signo) { - if (plock) { - plock->setTerminate(true); - printf("Terminated requested. Waiting for earlier operation complete.\n"); - syslog(LOG_DEBUG, "slot%u fw_util_sig_handler signo=%d",plock->getFru(), signo); - } -} - -void usage() -{ - cout << "USAGE: " << exec_name << " all|FRU --version" << endl; - cout << " " << exec_name << " FRU BOARD --update [--]COMPONENT IMAGE_PATH" << endl; - cout << " " << exec_name << " FRU BOARD --force --update [--]COMPONENT IMAGE_PATH" << endl; - cout << "FRU : Board : Components" << endl; - cout << "-------:--------------:-------------"<< endl; - cout << "bmc :bmc :bmc cpld rom "<< endl; - cout << "nic :nic :nic" << endl; - cout << "slot1 :bb sb 1ou 2ou :bic bicbl bios cpld me vr" << endl; - cout << "slot2 :sb 1ou 2ou :bic bicbl bios cpld me vr" << endl; - cout << "slot3 :sb 1ou 2ou :bic bicbl bios cpld me vr" << endl; - cout << "slot4 :sb 1ou 2ou :bic bicbl bios cpld me vr" << endl; - - if (plock) - delete plock; -} - -#define BIT(x) (1 << x) -#define FW_UPDATE BIT(0) -#define FW_VERSION BIT(1) -#define FW_SCHEDULE_ADD BIT(2) -#define FW_SCHEDULE_DEL BIT(3) -#define FW_SCHEDULE_SHOW BIT(4) - -struct args_t { - string fru; - string board; - bool force; - uint8_t action; - string component; - string image; -}; - -void parse_arg(int argc, char **argv, struct args_t ¶m) { - int idx = 0; - int args_size = 0; - std::vector all_args; - - if ( argc < 3 ) { - cerr << "The length of params are invalid!" << endl; - usage(); - exit(EXIT_FAILURE); - } - - //convert it to the string - all_args.assign(argv + 1, argv + argc); - args_size = all_args.size(); - - //get the fru - param.fru = all_args[idx++]; - - ///Suppose you want to get the firmware version - if ( args_size == 2 && all_args[idx] == "--version" ) { - param.action = FW_VERSION; - } else { - param.board = all_args[idx++]; - while ( idx < args_size ) { - if ( all_args[idx] == "--update" ) { - param.action |= FW_UPDATE; - idx++; - - if ( idx >= args_size ) break; - - //check that the data are values or options - if ( all_args[idx] == "--del" && all_args[idx] == "--add" && all_args[idx] == "--list" ) { - continue; - } - - if ( idx + 1 < args_size ) { - param.component = all_args[idx++]; - if ( param.component.rfind("--", 0) == 0 ) - param.component = param.component.substr(2); - param.image = all_args[idx]; - } else { - //only get one option, suppose it to a component - param.component = all_args[idx]; - if ( param.component.rfind("--", 0) == 0 ) - param.component = param.component.substr(2); - } - } else if ( all_args[idx] == "--force" ) { - param.force = true; - } else if ( all_args[idx] == "--add" ) { - cout << "--add is not supported" << endl; - } else if ( all_args[idx] == "--del" ) { - cout << "--del is not supported" << endl; - } else if ( all_args[idx] == "--list" ) { - cout << "--list is not supported" << endl; - } - idx++; - } - } -} - -void show_fw_version(string target) { - for ( auto fru : (*Component::fru_list) ) { - if ( target == "all" || target == fru.first ) { - for ( auto board:fru.second ) { - for ( auto comp:board.second ) { - comp.second->print_version(); - - if (plock && plock->getTerminate()) { - // Do not call destructor explicitly, since it's an undefined behaviour. - // While the constructor uses new, and the destructor uses delete. - syslog(LOG_DEBUG, "slot%u Terminated complete.",plock->getFru()); - printf("Terminated complete.\n"); - delete plock; - cout << endl; - } - } - } - cout << endl; - } - } -} - -int do_fw_update(string fru, string board, string comp, string image, bool force) { - - Component *comp_hndler = Component::get_component(fru, board, comp); - - if ( comp_hndler == NULL ) { - cerr << "Cannot be NULL here" << endl; - return FW_STATUS_NOT_SUPPORTED; - } - - if ( force == true ) { - return comp_hndler->fupdate(image); - } - - return comp_hndler->update(image); -} - -int main(int argc, char *argv[]) -{ - struct args_t fw_args{}; - struct sigaction sa; - int ret = FW_STATUS_NOT_SUPPORTED; - uint8_t fru_id = 0; - System system; - - exec_name = argv[0]; - - parse_arg(argc, argv, fw_args); - -#if 0 - cout << "fru " << fw_args.fru << endl; - cout << "board " << fw_args.board << endl; - cout << "force " << +fw_args.force << endl; - cout << "action " << +fw_args.action << endl; - cout << "comp " << fw_args.component << endl; - cout << "img " << fw_args.image << endl; -#endif - - sa.sa_handler = fw_util_sig_handler; - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - sigaction(SIGHUP, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - sigaction(SIGQUIT, &sa, NULL); - sigaction(SIGSEGV, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGPIPE, &sa, NULL); // for ssh terminate - - //check the fru list is created - if ( Component::is_fru_list_valid() == false ) { - exit(EXIT_FAILURE); - } - - //check the fru is valid - if ( Component::is_fru_valid(fw_args.fru) == false && fw_args.fru != "all" ) { - usage(); - exit(EXIT_FAILURE); - } - - //only one fru can be handled at the same time. - if ( plock != NULL ) { - plock->lock_file(system.get_fru_id(fw_args.fru), system.lock_file(fw_args.fru)); - if ( plock->ok() == false ) { - cerr << "Another instance of fw-util already running" << endl; - delete plock; - exit(EXIT_FAILURE); - } - } - - //if user want to get the version of FWs, we check the fru only. - if ( fw_args.action == FW_VERSION ) { - //show version - show_fw_version(fw_args.fru); - return 0; - } else if ( fw_args.fru != "all" ) { - //we don't support to update ALL components - //check the other params further - if ( Component::is_board_valid(fw_args.fru, fw_args.board) == false || \ - Component::is_component_valid(fw_args.fru, fw_args.board, fw_args.component) == false ) { - usage(); - exit(EXIT_FAILURE); - } - } else { - cerr << "Invalid length parameter" << endl; - usage(); - exit(EXIT_FAILURE); - } - - string str_act(""); - - //valid the aciton - switch (fw_args.action) { - case FW_UPDATE: - { - ifstream f(fw_args.image); - if ( fw_args.image.empty() || !f.good() ) { - cerr << "The image path is empty or it cannot be accessed" << endl; - usage(); - exit(EXIT_FAILURE); - } - - if ( fw_args.force == true ) { - str_act.assign("Force upgrade"); - } else { - str_act.assign("Upgrade"); - } - fru_id = system.get_fru_id(fw_args.fru); - system.set_update_ongoing(fru_id, 60 * 10); - usleep(200000); //wait 0.2s for the last command(get sensor reading) finish. - ret = do_fw_update(fw_args.fru, fw_args.board, fw_args.component, fw_args.image, fw_args.force); - system.set_update_ongoing(fru_id, 0); - } - break; - case FW_SCHEDULE_ADD: - case FW_SCHEDULE_DEL: - case FW_SCHEDULE_SHOW: - default: - cerr << "Invalid action!" << endl; - usage(); - exit(EXIT_FAILURE); - break; - } - - if (ret == FW_STATUS_SUCCESS) { - cout << str_act << " of " << fw_args.fru << " : " << fw_args.board << " : " << fw_args.component << " succeeded" << endl; - } else { - cerr << str_act << " of " << fw_args.fru << " : " << fw_args.board << " : " << fw_args.component; - if (ret == FW_STATUS_NOT_SUPPORTED) { - cerr << " not supported" << endl; - } else { - cerr << " failed" << endl; - } - } - - return ret; -} diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fw-util.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fw-util.h deleted file mode 100644 index 88c0f2e79db1..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/fw-util.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef _FW_UTIL_H_ -#define _FW_UTIL_H_ -#include -#include -#include -#include - -#define FW_STATUS_SUCCESS 0 -#define FW_STATUS_FAILURE -1 -#define FW_STATUS_NOT_SUPPORTED -2 - -class Component { - protected: - std::string _fru; - std::string _board; - std::string _component; - - public: - static std::map>> *fru_list; - static bool is_fru_list_valid(); - static bool is_fru_valid(std::string fru); - static bool is_board_valid(std::string fru, std::string board); - static bool is_component_valid(std::string fru, std::string board, std::string comp); - static Component *get_component(std::string fru, std::string board, std::string comp); - static void fru_list_setup() { - if ( !fru_list ) { - fru_list = new std::map>> (); - } - } - - // Constructor for a real component. - Component(std::string fru, std::string board, std::string component); - virtual ~Component(); - - std::string &fru(void) { return _fru; } - std::string &board(void) { return _board; } - std::string &component(void) { return _component; } - virtual int update(std::string image) { return FW_STATUS_NOT_SUPPORTED; } - virtual int fupdate(std::string image) { return FW_STATUS_NOT_SUPPORTED; } - virtual int dump(std::string image) { return FW_STATUS_NOT_SUPPORTED; } - virtual int print_version() { return FW_STATUS_NOT_SUPPORTED; } - -}; - -#if 0 -class Component { - protected: - std::string _fru; - std::string _component; - - public: - static std::map> *fru_list; - static Component *find_component(std::string fru, std::string comp); - static void fru_list_setup() { - if (!fru_list) { - fru_list = new std::map>(); - } - } - // Constructor for a real component. - Component(std::string fru, std::string component); - virtual ~Component(); - - std::string &component(void) { return _component; } - std::string &fru(void) { return _fru; } - virtual bool is_alias(void) { return false; } - virtual std::string &alias_component(void) { return _component; } - virtual std::string &alias_fru(void) { return _fru; } - virtual int update(std::string image) { return FW_STATUS_NOT_SUPPORTED; } - virtual int fupdate(std::string image) { return FW_STATUS_NOT_SUPPORTED; } - virtual int dump(std::string image) { return FW_STATUS_NOT_SUPPORTED; } - virtual int print_version() { return FW_STATUS_NOT_SUPPORTED; } -}; -#endif - -#if 0 -class AliasComponent : public Component { - std::string _target_fru; - std::string _target_comp_name; - Component *_target_comp; - bool setup(); - public: - AliasComponent(std::string fru, std::string comp, std::string t_fru, std::string t_comp); - bool is_alias(void) { return true; } - std::string &alias_component(void) { return _target_comp_name; } - std::string &alias_fru(void) { return _target_fru; } - int update(std::string image); - int fupdate(std::string image); - int dump(std::string image); - int print_version(); -}; -#endif - -enum { - VBOOT_NO_SUPPORT, - VBOOT_NO_ENFORCE, - VBOOT_SW_ENFORCE, - VBOOT_HW_ENFORCE -}; - -class System { - public: - std::ostream &output; - std::ostream &error; - - System() : output(std::cout), error(std::cerr) {} - System(std::ostream &out, std::ostream &err): output(out), error(err) {} - - virtual int runcmd(const std::string &cmd); - virtual int vboot_support_status(); - virtual bool get_mtd_name(std::string name, std::string &dev); - bool get_mtd_name(std::string name) { - std::string unused; - return get_mtd_name(name, unused); - } - virtual std::string version(); - std::string name() { - std::string vers = version(); - std::string mc = vers.substr(0, vers.find("-")); - std::transform(mc.begin(), mc.end(), mc.begin(), ::tolower); - return mc; - } - virtual std::string& partition_conf(); - virtual uint8_t get_fru_id(std::string &name); - virtual void set_update_ongoing(uint8_t fru_id, int timeo); - virtual std::string lock_file(std::string &name); -}; - -#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/image_parts.json b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/image_parts.json deleted file mode 100644 index 32745ddf3774..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/image_parts.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "vboot": { - "spl": { - "offset": 0, - "size": 84, - "type": "ignore" - }, - "recovery": { - "offset": 84, - "size": 300, - "type": "ignore" - }, - "env": { - "offset": 384, - "size": 128, - "type": "ignore" - }, - "uboot": { - "offset": 512, - "size": 384, - "type": "fit" - }, - "unified-fit": { - "offset": 896, - "size": 27776, - "type": "fit", - "num-nodes": 2 - } - }, - "fit": { - "uboot": { - "offset": 0, - "size": 384, - "type": "ignore" - }, - "env": { - "offset": 384, - "size": 128, - "type": "ignore" - }, - "unified-fit": { - "offset": 512, - "size": 27776, - "type": "fit", - "num-nodes": 2 - } - }, - "legacy": { - "uboot": { - "offset": 0, - "size": 384, - "type": "ignore" - }, - "env": { - "offset": 384, - "size": 128, - "type": "ignore" - }, - "kernel": { - "offset": 512, - "size": 4096, - "type": "legacy" - }, - "rootfs": { - "offset": 4608, - "size": 24064, - "type": "legacy" - } - }, - "legacy_fido": { - "uboot": { - "offset": 0, - "size": 384, - "type": "ignore" - }, - "env": { - "offset": 384, - "size": 128, - "type": "ignore" - }, - "kernel": { - "offset": 512, - "size": 2560, - "type": "legacy" - }, - "rootfs": { - "offset": 3072, - "size": 12288, - "type": "legacy" - } - } -} diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic.cpp deleted file mode 100644 index db34b695688f..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include -#include "nic.h" - -#define NCSI_DATA_PAYLOAD 64 -#define NCSI_MIN_DATA_PAYLOAD 36 - -using namespace std; - -typedef struct { - char mfg_name[10]; // manufacture name - uint32_t mfg_id; // manufacture id - void (*get_nic_fw)(uint8_t *, char *); -} nic_info_st; - -static void -get_mlx_fw_version(uint8_t *buf, char *version) -{ - int ver_index_based = 20; - int major = 0; - int minor = 0; - int revision = 0; - - major = buf[ver_index_based++]; - minor = buf[ver_index_based++]; - revision = buf[ver_index_based++] << 8; - revision += buf[ver_index_based++]; - - sprintf(version, "%d.%d.%d", major, minor, revision); -} - -static void -get_bcm_fw_version(uint8_t *buf, char *version) -{ - int ver_start_index = 8; //the index is defined in the NC-SI spec - const int ver_end_index = 19; - char ver[32]={0}; - int i = 0; - - for( ; ver_start_index <= ver_end_index; ver_start_index++, i++) - { - if ( 0 == buf[ver_start_index] ) - { - break; - } - ver[i] = buf[ver_start_index]; - } - - strcat(version, ver); -} - -static nic_info_st support_nic_list[] = -{ - {"Mellanox", 0x19810000, get_mlx_fw_version}, - {"Broadcom", 0x3d110000, get_bcm_fw_version}, -}; - -static int nic_list_size = sizeof(support_nic_list) / sizeof(nic_info_st); - -int NicComponent::print_version() { - char display_nic_str[128]={0}; - char version[32]={0}; - char vendor[32]={0}; - uint8_t buf[NCSI_DATA_PAYLOAD]={0}; - uint32_t nic_mfg_id=0; - FILE *file = NULL; - bool is_unknown_mfg_id = true; - int current_nic; - - file = fopen(NIC_FW_VER_PATH, "rb"); - if (NULL == file) { - return FW_STATUS_FAILURE; - } - - if (fread(buf, sizeof(uint8_t), NCSI_DATA_PAYLOAD, file) < NCSI_MIN_DATA_PAYLOAD) { - fclose(file); - return FW_STATUS_FAILURE; - } - - fclose(file); - //get the manufcture id - nic_mfg_id = (buf[35]<<24) + (buf[34]<<16) + (buf[33]<<8) + buf[32]; - - for ( current_nic=0; current_nic -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "nic_ext.h" - -using namespace std; - -int NicExtComponent::_get_ncsi_vid(void) { - NCSI_NL_MSG_T *nl_msg; - NCSI_NL_RSP_T *nl_rsp; - Get_Version_ID_Response *vidresp; - uint8_t nic_fw_ver[4] = {0}; - int fd, ret = -1; - - nl_msg = (NCSI_NL_MSG_T *)calloc(1, sizeof(NCSI_NL_MSG_T)); - if (!nl_msg) { - printf("%s: allocate nl_msg buffer failed\n", __func__); - return -1; - } - - sprintf(nl_msg->dev_name, "eth%u", _if_idx); - nl_msg->channel_id = 0; - nl_msg->cmd = NCSI_GET_VERSION_ID; - nl_msg->payload_length = 0; - - do { - nl_rsp = send_nl_msg_libnl(nl_msg); - if (!nl_rsp) { - break; - } - if (((NCSI_Response_Packet *)nl_rsp->msg_payload)->Response_Code) { - break; - } - - if (access("/tmp/cache_store", F_OK) == -1) { - mkdir("/tmp/cache_store", 0777); - } - - fd = open(_ver_path.c_str(), O_RDWR | O_CREAT, 0666); - if (fd < 0) { - break; - } - - lseek(fd, (long)&((Get_Version_ID_Response *)0)->fw_ver, SEEK_SET); - ret = read(fd, nic_fw_ver, sizeof(nic_fw_ver)); - if (ret && (ret != sizeof(nic_fw_ver))) { - close(fd); - break; - } - - vidresp = (Get_Version_ID_Response *)((NCSI_Response_Packet *)nl_rsp->msg_payload)->Payload_Data; - if (!ret || memcmp(vidresp->fw_ver, nic_fw_ver, sizeof(nic_fw_ver))) { - lseek(fd, 0, SEEK_SET); - if (write(fd, vidresp, sizeof(Get_Version_ID_Response)) == sizeof(Get_Version_ID_Response)) { - syslog(LOG_WARNING, "updated %s", _ver_path.c_str()); - } - } - close(fd); - ret = 0; - } while (0); - - free(nl_msg); - if (nl_rsp) - free(nl_rsp); - - return ret; -} - -int NicExtComponent::print_version() { - _get_ncsi_vid(); - return NicComponent::print_version(); -} - diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic_ext.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic_ext.h deleted file mode 100644 index 1bd8138ac475..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/nic_ext.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _NIC_EXT_H_ -#define _NIC_EXT_H_ -#include "nic.h" - - -using namespace std; - -class NicExtComponent : public NicComponent { - uint8_t _if_idx; - int _get_ncsi_vid(void); - public: - NicExtComponent(string fru, string board, string comp, uint8_t idx) - : NicComponent(fru, board, comp), _if_idx(idx) {} - int print_version(); -}; - -#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/platform.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/platform.cpp index 4210f2d4265d..5a17cf361fbf 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/platform.cpp +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/platform.cpp @@ -1,80 +1,28 @@ -#include "bic_fw.h" -#include "bic_me.h" -#include "bic_cpld.h" -#include "bic_vr.h" +#include "bic_fw_ext.h" +#include "bic_cpld_ext.h" #include "bmc_cpld.h" -#include "bios.h" -#include "fscd.h" #include "nic_ext.h" +#include "bic_me.h" +#include "bic_bios.h" +#include "bic_vr.h" +#include #ifdef BIC_SUPPORT #include -#include -// Register BIC FW and BL components -/**************** - *param1 - string fru - *param2 - string board - *param3 - string comp - *param4 - uint8_t slot_id - *param5 - uint8_t intf -*****************/ - -/*The BIC of the server board*/ -BicFwComponent bicfw1("slot1", "sb", "bic", FRU_SLOT1, NONE_INTF); -BicFwComponent bicfw2("slot2", "sb", "bic", FRU_SLOT2, NONE_INTF); -BicFwComponent bicfw3("slot3", "sb", "bic", FRU_SLOT3, NONE_INTF); -BicFwComponent bicfw4("slot4", "sb", "bic", FRU_SLOT4, NONE_INTF); - -BicFwBlComponent bicfwbl1("slot1", "sb", "bicbl", FRU_SLOT1, NONE_INTF); -BicFwBlComponent bicfwbl2("slot2", "sb", "bicbl", FRU_SLOT2, NONE_INTF); -BicFwBlComponent bicfwbl3("slot3", "sb", "bicbl", FRU_SLOT3, NONE_INTF); -BicFwBlComponent bicfwbl4("slot4", "sb", "bicbl", FRU_SLOT4, NONE_INTF); - -/*The BIC of the 2OU board*/ -BicFwExtComponent bic_2ou_fw1("slot1", "2ou", "bic", FRU_SLOT1, REXP_BIC_INTF); -BicFwExtComponent bic_2ou_fw2("slot2", "2ou", "bic", FRU_SLOT2, REXP_BIC_INTF); -BicFwExtComponent bic_2ou_fw3("slot3", "2ou", "bic", FRU_SLOT3, REXP_BIC_INTF); -BicFwExtComponent bic_2ou_fw4("slot4", "2ou", "bic", FRU_SLOT4, REXP_BIC_INTF); - -BicFwBlExtComponent bic_2ou_fwbl1("slot1", "2ou", "bicbl", FRU_SLOT1, REXP_BIC_INTF); -BicFwBlExtComponent bic_2ou_fwbl2("slot2", "2ou", "bicbl", FRU_SLOT2, REXP_BIC_INTF); -BicFwBlExtComponent bic_2ou_fwbl3("slot3", "2ou", "bicbl", FRU_SLOT3, REXP_BIC_INTF); -BicFwBlExtComponent bic_2ou_fwbl4("slot4", "2ou", "bicbl", FRU_SLOT4, REXP_BIC_INTF); - -/*The ME of the serverboard*/ -MeFwComponent me_fw1("slot1", "sb", "me", FRU_SLOT1, NONE_INTF); -MeFwComponent me_fw2("slot2", "sb", "me", FRU_SLOT2, NONE_INTF); -MeFwComponent me_fw3("slot3", "sb", "me", FRU_SLOT3, NONE_INTF); -MeFwComponent me_fw4("slot4", "sb", "me", FRU_SLOT4, NONE_INTF); - -/*The CPLD of the server board*/ -CpldComponent cpld_fw1("slot1", "sb", "cpld", FRU_SLOT1, 2, 0x80, NONE_INTF); -CpldComponent cpld_fw2("slot2", "sb", "cpld", FRU_SLOT2, 2, 0x80, NONE_INTF); -CpldComponent cpld_fw3("slot3", "sb", "cpld", FRU_SLOT3, 2, 0x80, NONE_INTF); -CpldComponent cpld_fw4("slot4", "sb", "cpld", FRU_SLOT4, 2, 0x80, NONE_INTF); - -/*The CPLD of the 2OU board*/ -CpldComponent cpld_2ou_fw1("slot1", "2ou", "cpld", FRU_SLOT1, 0, 0x80, REXP_BIC_INTF); -CpldComponent cpld_2ou_fw2("slot2", "2ou", "cpld", FRU_SLOT2, 0, 0x80, REXP_BIC_INTF); -CpldComponent cpld_2ou_fw3("slot3", "2ou", "cpld", FRU_SLOT3, 0, 0x80, REXP_BIC_INTF); -CpldComponent cpld_2ou_fw4("slot4", "2ou", "cpld", FRU_SLOT4, 0, 0x80, REXP_BIC_INTF); - -/*The BIOS of the server board*/ -BiosComponent bios_fw1("slot1", "sb", "bios", FRU_SLOT1, NONE_INTF); -BiosComponent bios_fw2("slot2", "sb", "bios", FRU_SLOT2, NONE_INTF); -BiosComponent bios_fw3("slot3", "sb", "bios", FRU_SLOT3, NONE_INTF); -BiosComponent bios_fw4("slot4", "sb", "bios", FRU_SLOT4, NONE_INTF); - -/*The fscd of BMC*/ -FscdComponent fscd("bmc", "bmc", "fscd"); - -/*The VR of the server board*/ -VrComponent vr_fw1("slot1", "sb", "vr", FRU_SLOT1, NONE_INTF); -VrComponent vr_fw2("slot2", "sb", "vr", FRU_SLOT2, NONE_INTF); -VrComponent vr_fw3("slot3", "sb", "vr", FRU_SLOT3, NONE_INTF); -VrComponent vr_fw4("slot4", "sb", "vr", FRU_SLOT4, NONE_INTF); - -NicExtComponent nic_fw("nic", "nic", "nic", 0); +NicExtComponent nic_fw("nic", "nic", "nic_fw_ver", FRU_NIC, 0x00); +MeComponent me_fw1("slot1", "me", FRU_SLOT1); + +//slot1 2ou bic/bicbl/cpld +BicFwExtComponent bic_2ou_fw1("slot1", "2ou_bic" , FRU_SLOT1, "2ou", FW_2OU_BIC); +BicFwExtBlComponent bicbl_2ou_fw1("slot1", "2ou_bicbl", FRU_SLOT1, "2ou", FW_2OU_BIC_BOOTLOADER); +CpldExtComponent cpld_2ou_fw1("slot1", "2ou_cpld" , FRU_SLOT1, "2ou", FW_2OU_CPLD); + +//slot1 sb bic/bicbl/cpld/bios/vr +BicFwExtComponent bic_fw1("slot1", "bic" , FRU_SLOT1, "sb", FW_BIC); +BicFwExtBlComponent bicbl_fw1("slot1", "bicbl", FRU_SLOT1, "sb", FW_BIC_BOOTLOADER); +CpldExtComponent cpld_fw1("slot1", "cpld" , FRU_SLOT1, "sb", FW_CPLD); +BiosComponent bios_fw1("slot1", "bios" , FRU_SLOT1, FW_BIOS); +VrComponent vr_fw1("slot1", "vr" , FRU_SLOT1, FW_VR); class ClassConfig { public: @@ -85,37 +33,77 @@ class ClassConfig { exit(EXIT_FAILURE); } - //class2 if ( bmc_location == NIC_BMC ) { - static BmcCpldComponent cpld_bmc("bmc", "bmc", "cpld", MAX10_10M25, 9, 0x40); - static BicFwExtComponent bic_bb_fw1("slot1", "bb", "bic", FRU_SLOT1, BB_BIC_INTF); - static BicFwBlExtComponent bic_bb_fwbl1("slot1", "bb", "bicbl", FRU_SLOT1, BB_BIC_INTF); - static CpldComponent cpld_bb_fw1("slot1", "bb", "cpld", FRU_SLOT1, 0, 0x80, BB_BIC_INTF); + static BmcCpldComponent cpld_bmc("bmc", "cpld", MAX10_10M25, 9, 0x40); + + //slot1 bb bic/bicbl/cpld + static BicFwExtComponent bic_bb_fw1("slot1", "bb_bic" , FRU_SLOT1, "bb", FW_BB_BIC); + static BicFwExtBlComponent bicbl_bb_fw1("slot1", "bb_bicbl", FRU_SLOT1, "bb", FW_BB_BIC_BOOTLOADER); + static CpldExtComponent cpld_bb_fw1("slot1", "bb_cpld" , FRU_SLOT1, "bb", FW_BB_CPLD); } else { - //class1 - /*The BIC of the 1OU board*/ - static BicFwExtComponent bic_1ou_fw1("slot1", "1ou", "bic", FRU_SLOT1, FEXP_BIC_INTF); - static BicFwExtComponent bic_1ou_fw2("slot2", "1ou", "bic", FRU_SLOT2, FEXP_BIC_INTF); - static BicFwExtComponent bic_1ou_fw3("slot3", "1ou", "bic", FRU_SLOT3, FEXP_BIC_INTF); - static BicFwExtComponent bic_1ou_fw4("slot4", "1ou", "bic", FRU_SLOT4, FEXP_BIC_INTF); - - static BicFwBlExtComponent bic_1ou_fwbl1("slot1", "1ou", "bicbl", FRU_SLOT1, FEXP_BIC_INTF); - static BicFwBlExtComponent bic_1ou_fwbl2("slot2", "1ou", "bicbl", FRU_SLOT2, FEXP_BIC_INTF); - static BicFwBlExtComponent bic_1ou_fwbl3("slot3", "1ou", "bicbl", FRU_SLOT3, FEXP_BIC_INTF); - static BicFwBlExtComponent bic_1ou_fwbl4("slot4", "1ou", "bicbl", FRU_SLOT4, FEXP_BIC_INTF); - - /*The CPLD of the 1OU board*/ - static CpldComponent cpld_1ou_fw1("slot1", "1ou", "cpld", FRU_SLOT1, 0, 0x80, FEXP_BIC_INTF); - static CpldComponent cpld_1ou_fw2("slot2", "1ou", "cpld", FRU_SLOT2, 0, 0x80, FEXP_BIC_INTF); - static CpldComponent cpld_1ou_fw3("slot3", "1ou", "cpld", FRU_SLOT3, 0, 0x80, FEXP_BIC_INTF); - static CpldComponent cpld_1ou_fw4("slot4", "1ou", "cpld", FRU_SLOT4, 0, 0x80, FEXP_BIC_INTF); - - /*The CPLD of BMC*/ - static BmcCpldComponent cpld_bmc("bmc", "bmc", "cpld", MAX10_10M25, 12, 0x40); + //slot1 1ou bic/bicbl/cpld + static BicFwExtComponent bic_1ou_fw1("slot1", "1ou_bic" , FRU_SLOT1, "1ou", FW_1OU_BIC); + static BicFwExtBlComponent bicbl_1ou_fw1("slot1", "1ou_bicbl", FRU_SLOT1, "1ou", FW_1OU_BIC_BOOTLOADER); + static CpldExtComponent cpld_1ou_fw1("slot1", "1ou_cpld" , FRU_SLOT1, "1ou", FW_1OU_CPLD); + + //slot2 sb bic/bicbl/cpld/bios/vr + static BicFwExtComponent bic_fw2("slot2", "bic" , FRU_SLOT2, "sb", FW_BIC); + static BicFwExtBlComponent bicbl_fw2("slot2", "bicbl", FRU_SLOT2, "sb", FW_BIC_BOOTLOADER); + static CpldExtComponent cpld_fw2("slot2", "cpld" , FRU_SLOT2, "sb", FW_CPLD); + static BiosComponent bios_fw2("slot2", "bios" , FRU_SLOT2, FW_BIOS); + static VrComponent vr_fw2("slot2", "vr" , FRU_SLOT2, FW_VR); + + //slot2 1ou bic/bicbl/cpld + static BicFwExtComponent bic_1ou_fw2("slot2", "1ou_bic" , FRU_SLOT2, "1ou", FW_1OU_BIC); + static BicFwExtBlComponent bicbl_1ou_fw2("slot2", "1ou_bicbl", FRU_SLOT2, "1ou", FW_1OU_BIC_BOOTLOADER); + static CpldExtComponent cpld_1ou_fw2("slot2", "1ou_cpld" , FRU_SLOT2, "1ou", FW_1OU_CPLD); + + //slot2 2ou bic/bicbl/cpld + static BicFwExtComponent bic_2ou_fw2("slot2", "2ou_bic" , FRU_SLOT2, "2ou", FW_2OU_BIC); + static BicFwExtBlComponent bicbl_2ou_fw2("slot2", "2ou_bicbl", FRU_SLOT2, "2ou", FW_2OU_BIC_BOOTLOADER); + static CpldExtComponent cpld_2ou_fw2("slot2", "2ou_cpld" , FRU_SLOT2, "2ou", FW_2OU_CPLD); + + //slot3 sb bic/bicbl/cpld/bios/vr + static BicFwExtComponent bic_fw3("slot3", "bic" , FRU_SLOT3, "sb", FW_BIC); + static BicFwExtBlComponent bicbl_fw3("slot3", "bicbl", FRU_SLOT3, "sb", FW_BIC_BOOTLOADER); + static CpldExtComponent cpld_fw3("slot3", "cpld" , FRU_SLOT3, "sb", FW_CPLD); + static BiosComponent bios_fw3("slot3", "bios" , FRU_SLOT3, FW_BIOS); + static VrComponent vr_fw3("slot3", "vr" , FRU_SLOT3, FW_VR); + + //slot3 1ou bic/bicbl/cpld + static BicFwExtComponent bic_1ou_fw3("slot3", "1ou_bic" , FRU_SLOT3, "1ou", FW_1OU_BIC); + static BicFwExtBlComponent bicbl_1ou_fw3("slot3", "1ou_bicbl", FRU_SLOT3, "1ou", FW_1OU_BIC_BOOTLOADER); + static CpldExtComponent cpld_1ou_fw3("slot3", "1ou_cpld" , FRU_SLOT3, "1ou", FW_1OU_CPLD); + + //slot3 2ou bic/bicbl/cpld + static BicFwExtComponent bic_2ou_fw3("slot3", "2ou_bic" , FRU_SLOT3, "2ou", FW_2OU_BIC); + static BicFwExtBlComponent bicbl_2ou_fw3("slot3", "2ou_bicbl", FRU_SLOT3, "2ou", FW_2OU_BIC_BOOTLOADER); + static CpldExtComponent cpld_2ou_fw3("slot3", "2ou_cpld" , FRU_SLOT3, "2ou", FW_2OU_CPLD); + + //slot4 sb bic/bicbl/cpld/bios/vr + static BicFwExtComponent bic_fw4("slot4", "bic" , FRU_SLOT4, "sb", FW_BIC); + static BicFwExtBlComponent bicbl_fw4("slot4", "bicbl", FRU_SLOT4, "sb", FW_BIC_BOOTLOADER); + static CpldExtComponent cpld_fw4("slot4", "cpld" , FRU_SLOT4, "sb", FW_CPLD); + static BiosComponent bios_fw4("slot4", "bios" , FRU_SLOT4, FW_BIOS); + static VrComponent vr_fw4("slot4", "vr" , FRU_SLOT4, FW_VR); + + //slot4 1ou bic/bicbl/cpld + static BicFwExtComponent bic_1ou_fw4("slot4", "1ou_bic" , FRU_SLOT4, "1ou", FW_1OU_BIC); + static BicFwExtBlComponent bicbl_1ou_fw4("slot4", "1ou_bicbl", FRU_SLOT4, "1ou", FW_1OU_BIC_BOOTLOADER); + static CpldExtComponent cpld_1ou_fw4("slot4", "1ou_cpld" , FRU_SLOT4, "1ou", FW_1OU_CPLD); + + //slot4 2ou bic/bicbl/cpld + static BicFwExtComponent bic_2ou_fw4("slot4", "2ou_bic" , FRU_SLOT4, "2ou", FW_2OU_BIC); + static BicFwExtBlComponent bicbl_2ou_fw4("slot4", "2ou_bicbl", FRU_SLOT4, "2ou", FW_2OU_BIC_BOOTLOADER); + static CpldExtComponent cpld_2ou_fw4("slot4", "2ou_cpld" , FRU_SLOT4, "2ou", FW_2OU_CPLD); + + static BmcCpldComponent cpld_bmc("bmc", "cpld", MAX10_10M25, 12, 0x40); + static MeComponent me_fw2("slot2", "me", FRU_SLOT2); + static MeComponent me_fw3("slot3", "me", FRU_SLOT3); + static MeComponent me_fw4("slot4", "me", FRU_SLOT4); } - } + } }; ClassConfig platform_config; - #endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/server.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/server.cpp deleted file mode 100644 index 844bc87d8587..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/server.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include -#include -#include "server.h" - -using namespace std; - -void Server::ready() -{ - int ret; - uint8_t status; - ret = pal_is_fru_prsnt(_slot_id, &status); - if (ret < 0) { -#ifdef DEBUG - cerr << "pal_is_fru_prsnt failed for fru " << _slot_id << endl; -#endif - throw "get " + fru_name + " present failed"; - } - - if (status == 0) { -#ifdef DEBUG - cerr << "slot" << _slot_id << " is empty!" << endl; -#endif - throw fru_name + " is empty"; - } - - ret = pal_get_server_power(_slot_id, &status); - if (ret < 0) { -#ifdef DEBUG - cerr << "Failed to get server power status. Stopping update" << endl; -#endif - throw "get " + fru_name + " power status failed"; - } - - if (status == SERVER_12V_OFF) { -#ifdef DEBUG - cerr << "Can't update FW version since the server is 12V off!" << endl; -#endif - throw fru_name + " power 12V-off"; - } - - if (!pal_is_slot_support_update(_slot_id)) { -#ifdef DEBUG - cerr << "slot" << _slot_id << " is not a server" << endl; -#endif - throw "fru " + fru_name + " is not a server"; - } -} diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/server.h b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/server.h deleted file mode 100644 index debcb3e639fb..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/server.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _SERVER_H_ -#define _SERVER_H_ - -class Server { - private: - uint8_t _slot_id; - std::string fru_name; - public: - Server(uint8_t slot_id, std::string fru) : _slot_id(slot_id), fru_name(fru) {} - // Throws exception if not - void ready(); -}; - -#endif diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/system.cpp b/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/system.cpp deleted file mode 100644 index 4b5e5f3b2caa..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/files/system.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "fw-util.h" - -#define PAGE_SIZE 0x1000 -#define VERIFIED_BOOT_STRUCT_BASE 0x1E720000 -#define VERIFIED_BOOT_HARDWARE_ENFORCE(base) \ - *((uint8_t *)(base + 0x215)) - -using namespace std; - -int System::runcmd(const string &cmd) -{ -#ifdef DEBUG - cout << "Executing: " << cmd << endl; -#endif - int status = system(cmd.c_str()); - if (status == -1) { - return 127; - } - if (WIFEXITED(status) && (WEXITSTATUS(status) == 0)) - return FW_STATUS_SUCCESS; - return FW_STATUS_FAILURE; -} - -int System::vboot_support_status(void) -{ - struct vbs *v = vboot_status(); - if (!v) - return VBOOT_NO_SUPPORT; - if (v->hardware_enforce) - return VBOOT_HW_ENFORCE; - if (v->software_enforce) - return VBOOT_SW_ENFORCE; - return VBOOT_NO_ENFORCE; -} - -bool System::get_mtd_name(string name, string &dev) -{ - FILE* partitions = fopen("/proc/mtd", "r"); - char line[256], mnt_name[32]; - unsigned int mtdno; - bool found = false; - - name.insert(0, 1, '"'); - name += '"'; - dev.clear(); - - if (!partitions) { - return false; - } - while (fgets(line, sizeof(line), partitions)) { - if(sscanf(line, "mtd%d: %*x %*x %s", - &mtdno, mnt_name) == 2) { - if(!strcmp(name.c_str(), mnt_name)) { - dev = "/dev/mtd"; - dev.append(to_string(mtdno)); - found = true; - break; - } - } - } - fclose(partitions); - return found; -} - -string System::version() -{ - static string ret = ""; - if (ret == "") { - char vers[128] = "NA"; - FILE *fp = fopen("/etc/issue", "r"); - if (fp) { - if (fscanf(fp, "OpenBMC Release %s\n", vers) == 1) { - ret = vers; - } - fclose(fp); - } - } - return ret; -} - -string& System::partition_conf() -{ - static string parts = "/etc/image_parts.json"; - return parts; -} - -uint8_t System::get_fru_id(string &name) -{ - uint8_t fru_id; - if (pal_get_fru_id((char *)name.c_str(), &fru_id)) - { - - // Set to some default FRU which should be present - // in the system. - fru_id = 1; - } - return fru_id; -} - -void System::set_update_ongoing(uint8_t fru_id, int timeo) -{ - pal_set_fw_update_ongoing(fru_id, timeo); -} - -string System::lock_file(string &name) -{ - return "/var/run/fw-util-" + name + ".lock"; -} diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/fw-util_0.2.bbappend b/meta-facebook/meta-fby3/recipes-fby3/fw-util/fw-util_0.2.bbappend new file mode 100644 index 000000000000..83ff6c7734e7 --- /dev/null +++ b/meta-facebook/meta-fby3/recipes-fby3/fw-util/fw-util_0.2.bbappend @@ -0,0 +1,40 @@ +# Copyright 2018-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 + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "\ + file://nic_ext.cpp \ + file://nic_ext.h \ + file://bmc_cpld.cpp \ + file://bmc_cpld.h \ + file://platform.cpp \ + file://bic_fw_ext.h \ + file://bic_fw_ext.cpp \ + file://expansion.h \ + file://expansion.cpp \ + file://bic_cpld_ext.cpp \ + file://bic_cpld_ext.h \ + file://bic_bios.cpp \ + file://bic_vr.h \ + file://bic_vr.cpp \ + " + +CXXFLAGS += " -DBIC_SUPPORT " +DEPENDS += " libbic libfpga libfby3-common libncsi libnl-wrapper libkv libobmc-i2c " +RDEPENDS_${PN} += " libbic libfpga libfby3-common libncsi libnl-wrapper libkv libobmc-i2c " +LDFLAGS += " -lbic -lfpga -lfby3_common -lnl-wrapper -lkv -lobmc-i2c " diff --git a/meta-facebook/meta-fby3/recipes-fby3/fw-util/fw-util_0.3.bb b/meta-facebook/meta-fby3/recipes-fby3/fw-util/fw-util_0.3.bb deleted file mode 100644 index 1ac6d47e2ee0..000000000000 --- a/meta-facebook/meta-fby3/recipes-fby3/fw-util/fw-util_0.3.bb +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2017-present Facebook. All Rights Reserved. - -SUMMARY = "Firmware Utility" -DESCRIPTION = "Utility to upgrade firmware and to display firmware version of various components in the system" -SECTION = "base" -PR = "r1" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://fw-util.cpp;beginline=4;endline=16;md5=5f8ba3cd0f216026550dbcc0186d5599" - -SRC_URI =+ "file://Makefile \ - file://fw-util.h \ - file://fw-util.cpp \ - file://system.cpp \ - file://server.h \ - file://server.cpp \ - file://nic.cpp \ - file://nic.h \ - file://nic_ext.cpp \ - file://nic_ext.h \ - file://bic_fw.cpp \ - file://bic_fw.h \ - file://bic_me.cpp \ - file://bic_me.h \ - file://bmc.cpp \ - file://bmc.h \ - file://bmc_cpld.cpp \ - file://bmc_cpld.h \ - file://bic_cpld.cpp \ - file://bic_cpld.h \ - file://bios.cpp \ - file://bios.h \ - file://check_image.cpp \ - file://image_parts.json \ - file://platform.cpp \ - file://fscd.cpp \ - file://fscd.h \ - file://bic_vr.cpp \ - file://bic_vr.h \ - " - -S = "${WORKDIR}" - -#The definition for the project -CXXFLAGS += " -DBIC_SUPPORT " -DEPENDS += "libipmi libipmb libbic libocpdbg-lcd libobmc-i2c libfpga libfby3-common libncsi libnl-wrapper" -RDEPENDS_${PN} += "libipmi libipmb libbic libocpdbg-lcd libobmc-i2c libfpga libfby3-common libncsi libnl-wrapper" -LDFLAGS += " -lipmi -lipmb -lbic -locpdbg-lcd -lobmc-i2c -lfpga -lfby3_common -lncsi -lnl-wrapper" - -LDFLAGS =+ " -lpthread -ljansson -lfdt -lcrypto -lz -lpal -lvbs -ldl " -DEPENDS += "jansson libpal dtc zlib openssl libvbs " -RDEPENDS_${PN} += "jansson libpal zlib openssl libvbs " - -do_install() { - install -d ${D}${bindir} - install -m 0755 fw-util ${D}${bindir}/fw-util - install -d ${D}${sysconfdir} - install -m 0644 ${WORKDIR}/image_parts.json ${D}${sysconfdir}/image_parts.json -} - -FILES_${PN} = "${prefix}/bin" -FILES_${PN} += "${sysconfdir}/image_parts.json" diff --git a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic.h b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic.h index 70c715ecbb19..0ca4b52b5deb 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic.h +++ b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic.h @@ -54,7 +54,16 @@ enum { FW_ME, FW_BIC_BOOTLOADER, FW_VR, - FW_EXP_CPLD, + FW_BIOS, + FW_1OU_BIC, + FW_1OU_BIC_BOOTLOADER, + FW_1OU_CPLD, + FW_2OU_BIC, + FW_2OU_BIC_BOOTLOADER, + FW_2OU_CPLD, + FW_BB_BIC, + FW_BB_BIC_BOOTLOADER, + FW_BB_CPLD, }; enum { diff --git a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_cpld_altera_fwupdate.c b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_cpld_altera_fwupdate.c index 2c67742245a9..b05614ae4ec4 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_cpld_altera_fwupdate.c +++ b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_cpld_altera_fwupdate.c @@ -506,7 +506,7 @@ update_bic_cpld_altera(uint8_t slot_id, char *image, uint8_t intf, uint8_t force //So, the other will know the CPLD is updating by reading the register. //If the status of CPLD is 1h, it means the CPLD update is ongoing. Otherwise, it should be 0. //Since the update don't start, return ret if one of them is failure. - if ( intf == BB_BIC_INTF ) { + if ( intf == BB_BIC_INTF && force != FORCE_UPDATE_SET) { //generate random numbers from 1 to 9 srand(time(NULL)); int interval = (rand()%10); diff --git a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_fwupdate.c b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_fwupdate.c index 20ced6cdc14b..0befac8dec73 100755 --- a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_fwupdate.c +++ b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_fwupdate.c @@ -966,60 +966,113 @@ update_bic_bootloader_fw(uint8_t slot_id, uint8_t comp, uint8_t intf, char *path return ret; } +static char* +get_component_name(uint8_t comp) { + switch (comp) { + case FW_CPLD: + return "SB CPLD"; + case FW_BIC: + return "SB BIC"; + case FW_BIC_BOOTLOADER: + return "SB BIC Bootloader"; + case FW_VR: + return "VR"; + case FW_BIOS: + return "BIOS"; + case FW_1OU_BIC: + return "1OU BIC"; + case FW_1OU_BIC_BOOTLOADER: + return "1OU BIC Bootloader"; + case FW_1OU_CPLD: + return "1OU CPLD"; + case FW_2OU_BIC: + return "2OU BIC"; + case FW_2OU_BIC_BOOTLOADER: + return "2OU BIC Bootloader"; + case FW_2OU_CPLD: + return "2OU CPLD"; + case FW_BB_BIC: + return "BB BIC"; + case FW_BB_BIC_BOOTLOADER: + return "BB BIC Bootloader"; + case FW_BB_CPLD: + return "BB CPLD"; + default: + return "Unknown"; + } + + return "NULL"; +} + int -bic_update_fw(uint8_t slot_id, uint8_t comp, uint8_t intf, char *path, uint8_t force) { - int ret = 0; +bic_update_fw(uint8_t slot_id, uint8_t comp, char *path, uint8_t force) { + int ret = BIC_STATUS_SUCCESS; + uint8_t intf = 0x0; char ipmb_content[] = "ipmb"; char* loc = strstr(path, ipmb_content); printf("slot_id: %x, comp: %x, intf: %x, img: %s, force: %x\n", slot_id, comp, intf, path, force); + syslog(LOG_CRIT, "Updating %s on slot%d. File: %s", get_component_name(comp), slot_id, path); + //get the intf switch (comp) { - case UPDATE_BIC: - ret = update_bic_runtime_fw(slot_id, comp, intf, path, force); + case FW_CPLD: + case FW_ME: + case FW_BIC: + case FW_BIC_BOOTLOADER: + intf = NONE_INTF; break; - case UPDATE_BIC_BOOTLOADER: - ret = update_bic_bootloader_fw(slot_id, comp, intf , path, force); + case FW_1OU_BIC: + case FW_1OU_BIC_BOOTLOADER: + case FW_1OU_CPLD: + intf = FEXP_BIC_INTF; break; - case UPDATE_CPLD: - if ( intf == NONE_INTF || intf == BB_BIC_INTF ) { - ret = update_bic_cpld_altera(slot_id, path, intf, force); - } else { - ret = update_bic_cpld_lattice(slot_id, path, intf, force); - } + case FW_2OU_BIC: + case FW_2OU_BIC_BOOTLOADER: + case FW_2OU_CPLD: + intf = REXP_BIC_INTF; break; - case UPDATE_VR: - ret = update_bic_vr(slot_id, path, force); - break; - case UPDATE_BIOS: - if (loc != NULL) { - ret = update_bic_bios(slot_id, path, force); - } else { - ret = update_bic_usb_bios(slot_id, path); - } + case FW_BB_BIC: + case FW_BB_BIC_BOOTLOADER: + case FW_BB_CPLD: + intf = BB_BIC_INTF; break; } - return ret; -} - -int -bic_show_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver, uint8_t bus, uint8_t addr, uint8_t intf) { - int ret = 0; - switch(comp) { + //run cmd + switch (comp) { case FW_BIC: + case FW_1OU_BIC: + case FW_2OU_BIC: + case FW_BB_BIC: + ret = update_bic_runtime_fw(slot_id, UPDATE_BIC, intf, path, force); + break; case FW_BIC_BOOTLOADER: - case FW_ME: - ret = bic_get_fw_ver(slot_id, comp, ver, intf); + case FW_1OU_BIC_BOOTLOADER: + case FW_2OU_BIC_BOOTLOADER: + case FW_BB_BIC_BOOTLOADER: + ret = update_bic_bootloader_fw(slot_id, UPDATE_BIC_BOOTLOADER, intf , path, force); + break; + case FW_1OU_CPLD: + case FW_2OU_CPLD: + ret = update_bic_cpld_lattice(slot_id, path, intf, force); break; + case FW_BB_CPLD: case FW_CPLD: - if ( intf == NONE_INTF || intf == BB_BIC_INTF ) { - ret = bic_get_cpld_ver(slot_id, comp, ver, bus, addr, intf); - } else if ( intf == FEXP_BIC_INTF || intf == REXP_BIC_INTF ) { - ret = bic_get_exp_cpld_ver(slot_id, comp, ver, bus, addr, intf); + ret = update_bic_cpld_altera(slot_id, path, intf, force); + break; + case FW_BIOS: + if (loc != NULL) { + ret = update_bic_bios(slot_id, path, force); + } else { + ret = update_bic_usb_bios(slot_id, path); } break; + case FW_VR: + ret = update_bic_vr(slot_id, path, force); + break; } + syslog(LOG_CRIT, "Updated %s on slot%d. File: %s. Result: %s", get_component_name(comp), slot_id, path, (ret < 0)?"Fail":"Success"); return ret; } diff --git a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_fwupdate.h b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_fwupdate.h index 594000eff601..6b233083da79 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_fwupdate.h +++ b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_fwupdate.h @@ -37,8 +37,7 @@ enum { UPDATE_PCIE_SWITCH, }; -int bic_update_fw(uint8_t slot_id, uint8_t comp, uint8_t intf, char *path, uint8_t force); -int bic_show_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver, uint8_t bus, uint8_t addr, uint8_t intf); +int bic_update_fw(uint8_t slot_id, uint8_t comp, char *path, uint8_t force); #ifdef __cplusplus } // extern "C" diff --git a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_ipmi.c b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_ipmi.c index f51ca6772dd7..49f8ce568056 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_ipmi.c +++ b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_ipmi.c @@ -342,46 +342,94 @@ bic_write_fruid(uint8_t slot_id, uint8_t fru_id, const char *path, uint8_t intf) // OEM - Get Firmware Version // Netfn: 0x38, Cmd: 0x0B int -bic_get_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver, uint8_t intf) { +bic_get_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver) { uint8_t tbuf[4] = {0x00}; - uint8_t rbuf[MAX_IPMB_RES_LEN] = {0x00}; + uint8_t rbuf[16] = {0x00}; + uint8_t tlen = 4; uint8_t rlen = 0; - int ret; - uint8_t bmc_location = 0; - - if ( fby3_common_get_bmc_location(&bmc_location) < 0 ) { - syslog(LOG_ERR, "%s() Cannot get the location of BMC", __func__); - ret = BIC_STATUS_FAILURE; - goto error_exit; + uint8_t fw_comp = 0x0; + uint8_t intf = 0x0; + int ret = BIC_STATUS_FAILURE; + + //get the component + switch (comp) { + case FW_1OU_BIC: + case FW_2OU_BIC: + case FW_BB_BIC: + fw_comp = FW_BIC; + break; + case FW_1OU_BIC_BOOTLOADER: + case FW_2OU_BIC_BOOTLOADER: + case FW_BB_BIC_BOOTLOADER: + fw_comp = FW_BIC_BOOTLOADER; + break; + default: + fw_comp = comp; + break; } - if ( (bmc_location == BB_BMC || bmc_location == DVT_BB_BMC) && (intf == BB_BIC_INTF) ) { - ret = BIC_STATUS_FAILURE; - goto error_exit; - } else if ( bmc_location == NIC_BMC && (intf == FEXP_BIC_INTF) ) { - ret = BIC_STATUS_FAILURE; - goto error_exit; + //get the intf + switch (comp) { + case FW_CPLD: + case FW_ME: + case FW_BIC: + case FW_BIC_BOOTLOADER: + intf = NONE_INTF; + break; + case FW_1OU_BIC: + case FW_1OU_BIC_BOOTLOADER: + case FW_1OU_CPLD: + intf = FEXP_BIC_INTF; + break; + case FW_2OU_BIC: + case FW_2OU_BIC_BOOTLOADER: + case FW_2OU_CPLD: + intf = REXP_BIC_INTF; + break; + case FW_BB_BIC: + case FW_BB_BIC_BOOTLOADER: + case FW_BB_CPLD: + intf = BB_BIC_INTF; + break; } - // File the IANA ID - memcpy(tbuf, (uint8_t *)&IANA_ID, 3); - - // Fill the component for which firmware is requested - tbuf[3] = comp; - - ret = bic_ipmb_send(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_FW_VER, tbuf, 0x04, rbuf, &rlen, intf); - - // rlen should be greater than or equal to 4 (IANA + Data1 +...+ DataN) - if ( ret < 0 || rlen < 4 ) { - syslog(LOG_ERR, "%s: ret: %d, rlen: %d\n", __func__, ret, rlen); - ret = BIC_STATUS_FAILURE; - goto error_exit; + //run cmd + switch (comp) { + case FW_CPLD: + case FW_ME: + case FW_BIC: + case FW_BIC_BOOTLOADER: + case FW_1OU_BIC: + case FW_1OU_BIC_BOOTLOADER: + case FW_2OU_BIC: + case FW_2OU_BIC_BOOTLOADER: + case FW_BB_BIC: + case FW_BB_BIC_BOOTLOADER: + // File the IANA ID + memcpy(tbuf, (uint8_t *)&IANA_ID, 3); + + // Fill the component for which firmware is requested + tbuf[3] = fw_comp; + + ret = bic_ipmb_send(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_FW_VER, tbuf, tlen, rbuf, &rlen, intf); + // rlen should be greater than or equal to 4 (IANA + Data1 +...+ DataN) + if ( ret < 0 || rlen < 4 ) { + syslog(LOG_ERR, "%s: ret: %d, rlen: %d, slot_id:%x, intf:%x\n", __func__, ret, rlen, slot_id, intf); + ret = BIC_STATUS_FAILURE; + } else { + //Ignore IANA ID + memcpy(ver, &rbuf[3], rlen-3); + } + break; + case FW_1OU_CPLD: + case FW_2OU_CPLD: + ret = bic_get_exp_cpld_ver(slot_id, fw_comp, ver, 0/*bus 0*/, 0x80/*8-bit addr*/, intf); + break; + case FW_BB_CPLD: + ret = bic_get_cpld_ver(slot_id, fw_comp, ver, 0/*bus 0*/, 0x80/*8-bit addr*/, intf); + break; } - //Ignore IANA ID - memcpy(ver, &rbuf[3], rlen-3); - -error_exit: return ret; } diff --git a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_ipmi.h b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_ipmi.h index 34dfe6d1e81b..19db18681d37 100644 --- a/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_ipmi.h +++ b/meta-facebook/meta-fby3/recipes-fby3/plat-libs/files/bic/bic_ipmi.h @@ -33,7 +33,7 @@ int bic_get_fruid_info(uint8_t slot_id, uint8_t fru_id, ipmi_fruid_info_t *info, int bic_read_fruid(uint8_t slot_id, uint8_t fru_id, const char *path, int *fru_size, uint8_t intf); int bic_write_fruid(uint8_t slot_id, uint8_t fru_id, const char *path, uint8_t intf); int bic_get_sdr(uint8_t slot_id, ipmi_sel_sdr_req_t *req, ipmi_sel_sdr_res_t *res, uint8_t *rlen, uint8_t intf); -int bic_get_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver, uint8_t intf); +int bic_get_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver); int bic_get_1ou_type(uint8_t slot_id, uint8_t *type); int bic_get_80port_record(uint8_t slot_id, uint8_t *rbuf, uint8_t *rlen, uint8_t intf); int bic_get_cpld_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver, uint8_t bus, uint8_t addr, uint8_t intf);