tools/pci: refactor did variable for NuvotonPciBridge
Symptom:
Host tool "burn_my_bmc" for in-band firmware update didn't work
and exception is about PCI device cannot find in NPCM8xx platform.
root@localhost:~#
burn_my_bmc --command update --interface ipmipci --image test.sig
--sig test.sig --type dummy
Sending over the firmware image.
Opening the cleanup blob
Committing to the cleanup blob
Closing cleanup blob
Exception received: Couldn't find supported PCI device
Root cause:
There are new Nuvoton PCI device-id in NPCM8xx platform.
The previous device-id 0x0750 is hardcode for NPCM7xx platform.
However, NPCM8xx PCI device is using new device-id 0x0850.
Thus, host tool will throw the exception from NotFoundException().
Solution:
We need to refactor this "did" variable to make host tool
"burn_my_bmc" can work well for these two kinds of PCI devices.
Tested:
In-band firmware update can work well in NPCM8xx with did change to 0x0850.
Here is the result of "lspci" from host side for refer it.
root@localhost:~# lspci -v | grep d7:
d7:01.0 Unassigned class [ff00]: Winbond Electronics Corp Device 0850 (rev 08)
d7:02.0 Unassigned class [ff00]: Winbond Electronics Corp Device 0850 (rev 08)
Change-Id: I2917298f13b0bcd7de3b2ff71173c546ea3cb02b
Signed-off-by: Tim Lee <timlee660101@gmail.com>
diff --git a/README.md b/README.md
index 2ebbd28..1085270 100644
--- a/README.md
+++ b/README.md
@@ -176,6 +176,15 @@
| ---------------- | ------- | -------------------------------------------------------------------- |
| `MAPPED_ADDRESS` | 0 | The address used for mapping P2A or LPC into the BMC's memory-space. |
+There are two kinds of PCI device-id for NPCM7xx and NPCM8xx respectively. For
+NPCM7xx the device-id is using 0x0750 and NPCM8xx is using 0x0850. Use this
+variable that can help to build host tool burn_my_bmc compatible with different
+platforms and make in-band firmware update work well.
+
+| Variable | Default | Meaning |
+| ----------------- | ------- | ------------------------------------- |
+| `NUVOTON_PCI_DID` | 0x0750 | The device-id for Nuvoton PCI bridge. |
+
If a platform enables p2a as the transport mechanism, a specific vendor must be
selected via the following configuration option. Currently, only one is
supported.
diff --git a/meson.build b/meson.build
index 7ea5697..b28fc5e 100644
--- a/meson.build
+++ b/meson.build
@@ -28,6 +28,7 @@
conf_data.set_quoted('UPDATE_STATUS_FILENAME', get_option('update-status-filename'))
conf_data.set_quoted('BIOS_VERIFY_STATUS_FILENAME', get_option('bios-verify-status-filename'))
conf_data.set('MAPPED_ADDRESS', get_option('mapped-address'))
+conf_data.set('NUVOTON_PCI_DID', get_option('nuvoton-pci-did'))
conf_h = configure_file(
diff --git a/meson.options b/meson.options
index c348409..f1dd4f8 100644
--- a/meson.options
+++ b/meson.options
@@ -18,6 +18,8 @@
# Host Tool Options
option('ppc', type: 'boolean', value: false, description: 'Enable ppc host memory access')
+# Default value 1872 is 0x0750 below
+option('nuvoton-pci-did', type : 'integer', value : 1872, description : 'The device-id for Nuvoton PCI bridge')
# Configuration Details
diff --git a/tools/meson.build b/tools/meson.build
index 826d04c..29fd3b4 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -20,6 +20,7 @@
'pciaccess.cpp',
'p2a.cpp',
'progress.cpp',
+ conf_h,
dependencies: updater_pre,
include_directories: root_inc)
diff --git a/tools/pci.hpp b/tools/pci.hpp
index 8f40910..c13a4e1 100644
--- a/tools/pci.hpp
+++ b/tools/pci.hpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "config.h"
+
#pragma once
#include "data.hpp"
@@ -97,7 +99,7 @@
private:
static constexpr std::uint32_t vid = 0x1050;
- static constexpr std::uint32_t did = 0x0750;
+ static constexpr std::uint32_t did = NUVOTON_PCI_DID;
static constexpr int bar = 0;
static constexpr struct pci_id_match match
{