phal: set pdbg environment variable
pdbg needs PDBG_DTB environment variable initialisation
prior to pdbg init to set correct device tree back-end.
Tested: verified normal boot without systemd global variable set.
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: I7ac70cbb1966edcb85db0a862781149a0bc0f492
diff --git a/procedures/phal/common_utils.cpp b/procedures/phal/common_utils.cpp
index 99daa7b..4ead474 100644
--- a/procedures/phal/common_utils.cpp
+++ b/procedures/phal/common_utils.cpp
@@ -6,6 +6,7 @@
#include "phalerror/phal_error.hpp"
#include "procedures/phal/common_utils.hpp"
+#include <fmt/format.h>
#include <libekb.H>
#include <phosphor-logging/log.hpp>
@@ -26,6 +27,18 @@
// add callback methods for debug traces and for boot failures
openpower::pel::addBootErrorCallbacks();
+ // PDBG_DTB environment variable set to CEC device tree path
+ static constexpr auto PDBG_DTB_PATH =
+ "/var/lib/phosphor-software-manager/pnor/rw/DEVTREE";
+
+ if (setenv("PDBG_DTB", PDBG_DTB_PATH, 1))
+ {
+ log<level::ERR>(
+ fmt::format("Failed to set PDBG_DTB: ({})", strerror(errno))
+ .c_str());
+ throw std::runtime_error("Failed to set PDBG_DTB");
+ }
+
if (!pdbg_targets_init(NULL))
{
log<level::ERR>("pdbg_targets_init failed");