diff --git a/include/usb-dbg.hpp b/include/usb-dbg.hpp
index e5102c4..39623e7 100644
--- a/include/usb-dbg.hpp
+++ b/include/usb-dbg.hpp
@@ -112,6 +112,7 @@
 struct frame frame_info;
 struct frame frame_sel;
 struct frame frame_snr;
+struct frame frame_postcode;
 
 enum ENUM_PANEL
 {
diff --git a/meson.build b/meson.build
index a771f06..dbf46a8 100644
--- a/meson.build
+++ b/meson.build
@@ -35,6 +35,7 @@
 conf_data = configuration_data()
 conf_data.set_quoted('INSTANCES',host_instances)
 conf_data.set('POST_CODE_BYTES', get_option('post-code-bytes'))
+conf_data.set('DEBUG_CARD_FRAME_SIZE', get_option('debug-card-frame-size'))
 
 configure_file(input: 'meson_config.h.in',
                output: 'config.h',
diff --git a/meson.options b/meson.options
index fbcbabb..61a698a 100644
--- a/meson.options
+++ b/meson.options
@@ -1,6 +1,7 @@
 option('tests', type: 'feature', description: 'Build tests')
 option('bic', type: 'feature', description: 'Enable bic handlers')
 option('post-code-bytes', type: 'integer', description: 'Post code byte size.', value: 1)
+option('debug-card-frame-size', type: 'integer', description: 'debug card frame size.', value: 2)
 option(
   'host-instances',
   type: 'string',
diff --git a/meson_config.h.in b/meson_config.h.in
index d4470a0..de8bd07 100644
--- a/meson_config.h.in
+++ b/meson_config.h.in
@@ -4,3 +4,5 @@
 inline static const std::string hostInstances = @INSTANCES@;
 
 inline static const size_t postCodeSize = @POST_CODE_BYTES@;
+
+inline static const size_t debugCardFrameSize = @DEBUG_CARD_FRAME_SIZE@;
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 8516e54..c721f0d 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -749,7 +749,7 @@
 {
     uint8_t* req = reinterpret_cast<uint8_t*>(request);
     uint8_t* res = reinterpret_cast<uint8_t*>(response);
-    uint8_t num_frames = 3;
+    uint8_t num_frames = debugCardFrameSize;
 
     std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
     res[SIZE_IANA_ID] = num_frames;
diff --git a/src/usb-dbg.cpp b/src/usb-dbg.cpp
index 67b464b..d2f9f05 100644
--- a/src/usb-dbg.cpp
+++ b/src/usb-dbg.cpp
@@ -612,209 +612,6 @@
     return -1;
 }
 
-static int udbg_get_cri_sel(uint8_t, uint8_t page, uint8_t* next,
-                            uint8_t* count, uint8_t* buffer)
-{
-    if (page == 1)
-    {
-        // initialize and clear frame
-        frame_sel.init(FRAME_BUFF_SIZE);
-        frame_sel.overwrite = 1;
-        frame_sel.max_page = 20;
-        snprintf(frame_sel.title, 32, "Cri SEL");
-
-        static constexpr const auto depth = 0;
-        std::vector<std::string> paths;
-
-        std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
-
-        auto mapperCall = dbus->new_method_call(
-            "xyz.openbmc_project.ObjectMapper",
-            "/xyz/openbmc_project/object_mapper",
-            "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths");
-        static constexpr std::array<const char*, 1> interface = {
-            "xyz.openbmc_project.Logging.Entry"};
-        mapperCall.append("/", depth, interface);
-
-        try
-        {
-            auto reply = dbus->call(mapperCall);
-            reply.read(paths);
-        }
-        catch (sdbusplus::exception_t& e)
-        {
-            phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
-            return -1;
-        }
-
-        std::string message;
-
-        // Iterate each loggings
-        for (const auto& path : paths)
-        {
-            Value variant = ipmi::getDbusProperty(
-                *dbus, "xyz.openbmc_project.Logging", path,
-                "xyz.openbmc_project.Logging.Entry", "Severity");
-
-            // Only filter critical sel
-            if (std::get<std::string>(variant) !=
-                "xyz.openbmc_project.Logging.Entry.Level.Critical")
-            {
-                continue;
-            }
-
-            variant = ipmi::getDbusProperty(
-                *dbus, "xyz.openbmc_project.Logging", path,
-                "xyz.openbmc_project.Logging.Entry", "Message");
-            message = std::get<std::string>(variant);
-
-            frame_sel.insert(message.c_str(), 0);
-        }
-    }
-    if (page > frame_sel.pages)
-    {
-        return -1;
-    }
-    int ret = frame_sel.getPage(page, (char*)buffer, FRAME_PAGE_BUF_SIZE);
-    if (ret < 0)
-    {
-        *count = 0;
-        return -1;
-    }
-    *count = (uint8_t)ret;
-
-    if (page < frame_sel.pages)
-        *next = page + 1;
-    else
-        *next = 0xFF; // Set the value of next to 0xFF to indicate this is the
-                      // last page
-
-    return 0;
-}
-
-static int udbg_get_cri_sensor(uint8_t, uint8_t page, uint8_t* next,
-                               uint8_t* count, uint8_t* buffer)
-{
-    int ret;
-    double fvalue;
-    size_t pos = plat_get_fru_sel();
-
-    if (page == 1)
-    {
-        // Only update frame data while getting page 1
-
-        // initialize and clear frame
-        frame_snr.init(FRAME_BUFF_SIZE);
-        snprintf(frame_snr.title, 32, "CriSensor");
-
-        nlohmann::json senObj;
-
-        /* Get critical sensor names stored in json file */
-        std::ifstream file(JSON_SENSOR_NAMES_FILE);
-        if (file)
-        {
-            file >> senObj;
-            file.close();
-        }
-        else
-        {
-            phosphor::logging::log<phosphor::logging::level::ERR>(
-                "Critical Sensor names file not found",
-                phosphor::logging::entry("CRI_SENSOR_NAMES_FILE=%s",
-                                         JSON_SENSOR_NAMES_FILE));
-            return -1;
-        }
-
-        /* Get sensors values for all critical sensors */
-        for (auto& j : senObj.items())
-        {
-            std::string senName = j.key();
-            auto val = j.value();
-
-            if (senName[0] == '_')
-            {
-                senName = std::to_string(pos) + senName;
-            }
-
-            if (ipmi::storage::getSensorValue(senName, fvalue) == 0)
-            {
-                std::stringstream ss;
-                int prec = 0; // Default value
-
-                if (val.find("precision") != val.end())
-                    prec = val["precision"];
-
-                ss << std::fixed << std::setprecision(prec) << fvalue;
-
-                std::string senStr;
-                if (val.find("short_name") != val.end())
-                    senStr = val["short_name"];
-                else
-                    senStr = senName;
-
-                senStr += ss.str();
-
-                /* Get unit string for sensor and append in output */
-                std::string unitStr;
-                if (ipmi::storage::getSensorUnit(senName, unitStr) == 0)
-                    senStr += unitStr;
-
-                std::string thresholdStr;
-                int ret = ipmi::storage::getSensorThreshold(senName,
-                                                            thresholdStr);
-                if (ret < 0)
-                {
-                    phosphor::logging::log<phosphor::logging::level::ERR>(
-                        "Error getting critical sensor threshold status",
-                        phosphor::logging::entry("CRI_SENSOR_NAME=%s",
-                                                 senName.c_str()));
-                    return -1;
-                }
-                if (thresholdStr.size() != 0)
-                {
-                    senStr += ("/" + thresholdStr);
-                    std::string senStrWithBlinkAndInvertColor =
-                        ESC_ALT + senStr + ESC_RST;
-                    frame_snr.append(senStrWithBlinkAndInvertColor.c_str(), 0);
-                }
-                else
-                {
-                    frame_snr.append(senStr.c_str(), 0);
-                }
-            }
-            else
-            {
-                phosphor::logging::log<phosphor::logging::level::INFO>(
-                    "Critical sensor not found",
-                    phosphor::logging::entry("CRI_SENSOR_NAME=%s",
-                                             senName.c_str()));
-            }
-        }
-
-    } // End of update frame
-
-    if (page > frame_snr.pages)
-    {
-        return -1;
-    }
-
-    ret = frame_snr.getPage(page, (char*)buffer, FRAME_PAGE_BUF_SIZE);
-    if (ret < 0)
-    {
-        *count = 0;
-        return -1;
-    }
-    *count = (uint8_t)ret;
-
-    if (page < frame_snr.pages)
-        *next = page + 1;
-    else
-        *next = 0xFF; // Set the value of next to 0xFF to indicate this is the
-                      // last page
-
-    return 0;
-}
-
 static int getBiosVer(std::string& ver, size_t hostPosition)
 {
     nlohmann::json appObj;
@@ -1069,6 +866,74 @@
     return 0;
 }
 
+static int udbg_get_postcode(uint8_t, uint8_t page, uint8_t* next,
+                             uint8_t* count, uint8_t* buffer)
+{
+    if (page == 1)
+    {
+        // Initialize and clear frame (example initialization)
+        frame_postcode.init(FRAME_BUFF_SIZE);
+        snprintf(frame_postcode.title, 32, "Extra Post Code");
+        frame_sel.overwrite = 1;
+        frame_sel.max_page = 5;
+
+        // Synchronously get D-Bus connection
+        auto bus = sdbusplus::bus::new_default();
+
+        // Build D-Bus method call
+        auto method = bus.new_method_call(
+            "xyz.openbmc_project.State.Boot.PostCode0",  // Target service name
+            "/xyz/openbmc_project/State/Boot/PostCode0", // Object path
+            "xyz.openbmc_project.State.Boot.PostCode",   // Interface name
+            "GetPostCodes");                             // Method name
+
+        method.append(uint16_t(1)); // Add method parameter, assuming it's page
+
+        try
+        {
+            auto reply = bus.call(method); // Send synchronous method call
+
+            // Read postcode value
+            std::vector<std::tuple<uint64_t, std::vector<uint8_t>>> postcodes;
+            reply.read(postcodes);
+
+            // Insert retrieved postcodes into frame_postcode
+            std::string result;
+            for (const auto& [code, extra] : postcodes)
+            {
+                result = std::format("{:02x}", code);
+                frame_postcode.append(result.c_str(), 0);
+            }
+        }
+        catch (const std::exception& e)
+        {
+            // Handle exceptions
+            std::cerr << "Error retrieving postcodes: " << e.what()
+                      << std::endl;
+            return -1;
+        }
+    }
+
+    if (page > frame_postcode.pages)
+    {
+        return -1;
+    }
+
+    int ret = frame_postcode.getPage(page, (char*)buffer, FRAME_PAGE_BUF_SIZE);
+    if (ret < 0)
+    {
+        *count = 0;
+        return -1;
+    }
+    *count = (uint8_t)ret;
+
+    if (page < frame_postcode.pages)
+        *next = page + 1;
+    else
+        *next = 0xFF; // Set next to 0xFF to indicate last page
+    return 0;
+}
+
 int plat_udbg_get_frame_data(uint8_t frame, uint8_t page, uint8_t* next,
                              uint8_t* count, uint8_t* buffer)
 {
@@ -1076,10 +941,8 @@
     {
         case 1: // info_page
             return udbg_get_info_page(frame, page, next, count, buffer);
-        case 2: // critical SEL
-            return udbg_get_cri_sel(frame, page, next, count, buffer);
-        case 3: // critical Sensor
-            return udbg_get_cri_sensor(frame, page, next, count, buffer);
+        case 2: // Extra Post Code
+            return udbg_get_postcode(frame, page, next, count, buffer);
         default:
             return -1;
     }
