Skip to content

Commit

Permalink
fby3 : implement updating expansion CPLD via USB (#1255)
Browse files Browse the repository at this point in the history
Summary:
- Implement the USB update path for expansion CPLD.
- Keep the original IPMI update path. When the update image file name contains "ipmb", it would update expansion CPLD via IPMB.

Pull Request resolved: facebookexternal/openbmc.wiwynn#1255

Test Plan:
- Build code:pass
- Update 2OU CPLD:pass
// USB interface
root@bmc-oob:~# fw-util slot3 --update 2ou_cpld Y3CM_D01.jed
slot_id: 3, comp: c, intf: 0, img: Y3CM_D01.jed, force: 0
Init libusb Successful!
1cc0:0007 (bus 1, device 43) path: 1.3.3.2.4
Manufactured : Texas Instruments
Product : Virtual COM Port
----------------------------------------
Device Descriptors:
Vendor ID : 1cc0
Product ID : 7
Serial Number : 3
Size of Device Descriptor : 18
Type of Descriptor : 1
USB Specification Release Number : 272
Device Release Number : 256
Device Class : 2
Device Sub-Class : 0
Device Protocol : 0
Max. Packet Size : 64
No. of Configuraions : 1
Configured value : 1
Claimed Interface: 1, EP addr: 0x01
-----------------------------------

Interface Descriptors:
  Number of Interfaces : 0x2
  Length : 0x9
  Desc_Type : 0x2
  Config_index : 0x5
  Total length : 67
  Configuration Value  : 0x1
  Configuration Attributes : 0xc0
  MaxPower(mA) : 0
    Interface:
      bInterfaceNumber:   0
      bAlternateSetting:  0
      bNumEndpoints:      1
      bInterfaceClass:    2
      bInterfaceSubClass: 2
      bInterfaceProtocol: 1
      iInterface:         4

      EndPoint Descriptors:
        bLength: 7
        bDescriptorType: 0x5
        bEndpointAddress: 0x81
        Maximum Packet Size: 0x10
        bmAttributes: 0x3
        bInterval: 0x1
-----------------------------------
    Interface:
      bInterfaceNumber:   1
      bAlternateSetting:  0
      bNumEndpoints:      2
      bInterfaceClass:    10
      bInterfaceSubClass: 0
      bInterfaceProtocol: 0
      iInterface:         0

      EndPoint Descriptors:
        bLength: 7
        bDescriptorType: 0x5
        bEndpointAddress: 0x82
        Maximum Packet Size: 0x40
        bmAttributes: 0x2
        bInterval: 0x0
      EndPoint Descriptors:
        bLength: 7
        bDescriptorType: 0x5
        bEndpointAddress: 0x1
        Maximum Packet Size: 0x40
        bmAttributes: 0x2
        bInterval: 0x0
-----------------------------------
Input: Y3CM_D01.jed, USB timeout: 3000ms
[ChkSUM]bb18
CPLD DevID: 612BB043
[Update CPLD via USB]
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 %
verify cpld: 5 %
verify cpld: 10 %
verify cpld: 15 %
verify cpld: 20 %
verify cpld: 25 %
verify cpld: 30 %
verify cpld: 35 %
verify cpld: 40 %
verify cpld: 45 %
verify cpld: 50 %
verify cpld: 55 %
verify cpld: 60 %
verify cpld: 65 %
verify cpld: 70 %
verify cpld: 75 %
verify cpld: 80 %
verify cpld: 85 %
verify cpld: 90 %
verify cpld: 95 %
verify cpld: 100 %
Upgrade of slot3 : 2ou_cpld succeeded
root@bmc-oob:~# power-util slot3 12V-cycle
12V Power cycling fru 3...
root@bmc-oob:~# fw-util slot3 --version | grep "2OU CPLD"
2OU CPLD Version: 00050D01
root@bmc-oob:~#

//IPMB interface
root@bmc-oob:~# fw-util slot3 --version | grep "2OU CPLD"
2OU CPLD Version: 00050D01
root@bmc-oob:~# fw-util slot3 --update 2ou_cpld ipmb_Y3CM_A01.jed
slot_id: 3, comp: c, intf: 0, img: ipmb_Y3CM_A01.jed, force: 0
[ChkSUM]bb31
CPLD DevID: 612BB043
[Update CPLD via Exp BIC]
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 %
verify cpld: 5 %
verify cpld: 10 %
verify cpld: 15 %
verify cpld: 20 %
verify cpld: 25 %
verify cpld: 30 %
verify cpld: 35 %
verify cpld: 40 %
verify cpld: 45 %
verify cpld: 50 %
verify cpld: 55 %
verify cpld: 60 %
verify cpld: 65 %
verify cpld: 70 %
verify cpld: 75 %
verify cpld: 80 %
verify cpld: 85 %
verify cpld: 90 %
verify cpld: 95 %
verify cpld: 100 %
Upgrade of slot3 : 2ou_cpld succeeded
root@bmc-oob:~# power-util slot3 12V-cycle
12V Power cycling fru 3...
root@bmc-oob:~# fw-util slot3 --version | grep "2OU CPLD"
2OU CPLD Version: 00050A01

Reviewed By: williamspatrick

fbshipit-source-id: cf74e14474
  • Loading branch information
benwei13 authored and facebook-github-bot committed Oct 17, 2020
1 parent a072304 commit e4fb071
Show file tree
Hide file tree
Showing 8 changed files with 488 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@ using namespace std;

int CpldExtComponent::update(string image) {
int ret = 0;
int intf = FEXP_BIC_INTF;
string comp = component();
try {
server.ready();
expansion.ready();
if (comp == "1ou_cpld") {
intf = FEXP_BIC_INTF;
} else {
intf = REXP_BIC_INTF;
}
remote_bic_set_gpio(slot_id, EXP_GPIO_RST_USB_HUB, VALUE_HIGH, intf);
bic_set_gpio(slot_id, GPIO_RST_USB_HUB, VALUE_HIGH);
ret = bic_update_fw(slot_id, fw_comp, (char *)image.c_str(), FORCE_UPDATE_UNSET);
bic_set_gpio(slot_id, GPIO_RST_USB_HUB, VALUE_LOW);
remote_bic_set_gpio(slot_id, EXP_GPIO_RST_USB_HUB, VALUE_LOW, intf);
} catch (string err) {
return FW_STATUS_NOT_SUPPORTED;
}
Expand All @@ -23,10 +34,21 @@ int CpldExtComponent::update(string image) {

int CpldExtComponent::fupdate(string image) {
int ret = 0;
int intf = FEXP_BIC_INTF;
string comp = component();
try {
server.ready();
expansion.ready();
if (comp == "1ou_cpld") {
intf = FEXP_BIC_INTF;
} else {
intf = REXP_BIC_INTF;
}
remote_bic_set_gpio(slot_id, EXP_GPIO_RST_USB_HUB, VALUE_HIGH, intf);
bic_set_gpio(slot_id, GPIO_RST_USB_HUB, VALUE_HIGH);
ret = bic_update_fw(slot_id, fw_comp, (char *)image.c_str(), FORCE_UPDATE_SET);
bic_set_gpio(slot_id, GPIO_RST_USB_HUB, VALUE_HIGH);
remote_bic_set_gpio(slot_id, EXP_GPIO_RST_USB_HUB, VALUE_LOW, intf);
} catch (string err) {
return FW_STATUS_NOT_SUPPORTED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ extern "C" {
#define IPMB_RETRY_DELAY_TIME 500

#define MAX_CHECK_DEVICE_TIME 8
#define GPIO_RST_USB_HUB 0x10
#define EXP_GPIO_RST_USB_HUB 0x9
#define VALUE_LOW 0
#define VALUE_HIGH 1

/*IFX VR pages*/
#define VR_PAGE 0x00
#define VR_PAGE32 0x32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ extern "C" {

#include "bic_xfer.h"
#include "bic.h"
#include <libusb-1.0/libusb.h>

#define BIOS_CAPSULE_OFFSET 0x7F0000
#define CPLD_CAPSULE_OFFSET 0x17F0000

int print_configuration(struct libusb_device_handle *hDevice,struct libusb_config_descriptor *config);
int active_config(struct libusb_device *dev,struct libusb_device_handle *handle);
int bic_get_fw_cksum(uint8_t slot_id, uint8_t target, uint32_t offset, uint32_t len, uint8_t *ver);
int update_bic_bios(uint8_t slot_id, uint8_t comp, char *image, uint8_t force);
int update_bic_usb_bios(uint8_t slot_id, uint8_t comp, char *image);
Expand Down
Loading

0 comments on commit e4fb071

Please sign in to comment.