Skip to content

Commit

Permalink
fby3: move fw-util in fby3 to common (#1015)
Browse files Browse the repository at this point in the history
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: facebookexternal/openbmc.wiwynn#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
[email protected]'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
  • Loading branch information
benwei13 authored and facebook-github-bot committed Apr 22, 2020
1 parent 0666bc0 commit e91ee64
Show file tree
Hide file tree
Showing 44 changed files with 692 additions and 2,457 deletions.
14 changes: 0 additions & 14 deletions meta-facebook/meta-fby3/recipes-fby3/fw-util/files/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <cstring>
#include <syslog.h>
#include <unistd.h>
#include "bios.h"
#include "bic_bios.h"
#include <openbmc/pal.h>
#ifdef BIC_SUPPORT
#include <facebook/bic.h>
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -106,7 +106,7 @@ int BiosComponent::print_version() {
printf("BIOS Version: NA (%s)\n", err.c_str());
}

return ret;
return FW_STATUS_SUCCESS;
}

#endif
19 changes: 19 additions & 0 deletions meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_bios.h
Original file line number Diff line number Diff line change
@@ -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
78 changes: 4 additions & 74 deletions meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.cpp
Original file line number Diff line number Diff line change
@@ -1,79 +1,9 @@
#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cstring>
#include <unistd.h>
#include <fcntl.h>
#include <algorithm>
#include <sys/mman.h>
#include <syslog.h>
#include <stdlib.h>
#include "bic_cpld.h"
#ifdef BIC_SUPPORT
#include <facebook/bic.h>
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; }
21 changes: 0 additions & 21 deletions meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "fw-util.h"
#include <cstdio>
#include <cstring>
#include "server.h"
#include <openbmc/pal.h>
#include "bic_cpld_ext.h"
#ifdef BIC_SUPPORT
#include <facebook/bic.h>

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

23 changes: 23 additions & 0 deletions meta-facebook/meta-fby3/recipes-fby3/fw-util/files/bic_cpld_ext.h
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit e91ee64

Please sign in to comment.