summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch
blob: 355261e8fd58f6ac76a4a431807f83339bbd73eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
From 32d90301c494c1b43f8e1d74ac9e7c1dc2fe486a Mon Sep 17 00:00:00 2001
From: Jennifer Lee <jennifer1.lee@intel.com>
Date: Mon, 10 Dec 2018 10:36:44 -0800
Subject: [PATCH 1/1] Modified firmware activation to launch fwupd.sh through

 non-ubi fs code path to match more closely to the upstream design 	-
 Added option FWUPD_SCRIPT to saperate intel customized code 	- Adopted
 ActivationProgress from ubi fs activation code mainly for progress indicator
 for ipmi update

Signed-off-by: Jennifer Lee <jennifer1.lee@intel.com>
Signed-off-by: James Feist <james.feist@linux.intel.com>
---
 activation.cpp   | 43 +++++++++++++++++++++++++++++++++++++++++++
 configure.ac     |  7 +++++++
 static/flash.cpp | 41 +++++++++++++++++++++++++++++++++++++++--
 ubi/flash.cpp    |  9 +++------
 4 files changed, 92 insertions(+), 8 deletions(-)

diff --git a/activation.cpp b/activation.cpp
index ab76420..91e3a10 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -200,6 +200,49 @@ auto Activation::activation(Activations value) -> Activations
                     softwareServer::Activation::Activations::Active);
             }
         }
+#elif defined(FWUPD_SCRIPT)
+        if (!activationProgress)
+        {
+            // Enable systemd signals
+            Activation::subscribeToSystemdSignals();
+            parent.freeSpace(*this);
+
+            activationProgress =
+                std::make_unique<ActivationProgress>(bus, path);
+
+#ifdef WANT_SIGNATURE_VERIFY
+            fs::path uploadDir(IMG_UPLOAD_DIR);
+            if (!verifySignature(uploadDir / versionId, SIGNED_IMAGE_CONF_PATH))
+            {
+                onVerifyFailed();
+                // Stop the activation process, if fieldMode is enabled.
+                if (parent.control::FieldMode::fieldModeEnabled())
+                {
+                    return softwareServer::Activation::activation(
+                        softwareServer::Activation::Activations::Failed);
+                }
+            }
+#endif
+            flashWrite();
+        }
+        else if (activationProgress->progress() == 100)
+        {
+            log<level::ERR>("[Jennifer] progress == 100...");
+            if (!redundancyPriority)
+            {
+                redundancyPriority =
+                    std::make_unique<RedundancyPriority>(bus, path, *this, 0);
+            }
+
+            // Remove version object from image manager
+            Activation::deleteImageManagerObject();
+
+            // Create active association
+            parent.createActiveAssociation(path);
+
+            return softwareServer::Activation::activation(
+                softwareServer::Activation::Activations::Active);
+        }
 #else // !UBIFS_LAYOUT
 
 #ifdef WANT_SIGNATURE_VERIFY
diff --git a/configure.ac b/configure.ac
index 5fba420..3b5fdab 100755
--- a/configure.ac
+++ b/configure.ac
@@ -194,6 +194,13 @@ AS_IF([test "x$enable_host_bios_upgrade" == "xyes"], \
     [AC_DEFINE([HOST_BIOS_UPGRADE],[],[Enable host bios upgrade support.])])
 AM_CONDITIONAL([HOST_BIOS_UPGRADE], [test "x$enable_host_bios_upgrade" == "xyes"])
 
+# setup fwupd script support
+AC_ARG_ENABLE([fwupd_script],
+    AS_HELP_STRING([--enable-fwupd_script], [Enable fwupd script support.]))
+AS_IF([test "x$enable_fwupd_script" == "xyes"], \
+    [AC_DEFINE([FWUPD_SCRIPT],[],[Enable fwupd script support.])])
+AM_CONDITIONAL([FWUPD_SCRIPT], [test "x$enable_fwupd_script" == "xyes"])
+
 # Check for header files.
 AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd development package required])])
 AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...openbmc/sdbusplus package required])])
diff --git a/static/flash.cpp b/static/flash.cpp
index 82c2393..1bf29d5 100644
--- a/static/flash.cpp
+++ b/static/flash.cpp
@@ -20,9 +20,11 @@ namespace updater
 {
 
 namespace fs = std::experimental::filesystem;
+namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
 
 void Activation::flashWrite()
 {
+#ifndef FWUPD_SCRIPT
     // For static layout code update, just put images in /run/initramfs.
     // It expects user to trigger a reboot and an updater script will program
     // the image to flash during reboot.
@@ -33,11 +35,46 @@ void Activation::flashWrite()
         fs::copy_file(uploadDir / versionId / bmcImage, toPath / bmcImage,
                       fs::copy_options::overwrite_existing);
     }
+
+#else
+    auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+                                      SYSTEMD_INTERFACE, "StartUnit");
+    method.append("fwupd@" + versionId + ".service", "replace");
+    bus.call_noreply(method);
+#endif
 }
 
-void Activation::onStateChanges(sdbusplus::message::message& /*msg*/)
+void Activation::onStateChanges(sdbusplus::message::message& msg)
 {
-    // Empty
+#ifndef FWUPD_SCRIPT
+    uint32_t newStateID{};
+    sdbusplus::message::object_path newStateObjPath;
+    std::string newStateUnit{};
+    std::string newStateResult{};
+
+    msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
+
+    auto rwServiceFile = "fwupdw@" + versionId + ".service";
+
+    if (newStateUnit == rwServiceFile && newStateResult == "done")
+    {
+        activationProgress->progress(100);
+    }
+
+    if (newStateUnit == rwServiceFile)
+    {
+        if (newStateResult == "failed" || newStateResult == "dependency")
+        {
+            Activation::activation(
+                softwareServer::Activation::Activations::Failed);
+        }
+        else
+        {
+            Activation::activation(
+                softwareServer::Activation::Activations::Activating);
+        }
+    }
+#endif
 }
 
 } // namespace updater
diff --git a/ubi/flash.cpp b/ubi/flash.cpp
index 5af2a17..ffa9348 100644
--- a/ubi/flash.cpp
+++ b/ubi/flash.cpp
@@ -15,13 +15,10 @@ void Activation::flashWrite()
 {
     auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
                                       SYSTEMD_INTERFACE, "StartUnit");
-    std::string rwServiceFile =
-        "obmc-flash-bmc-ubirw@" + versionId + ".service";
-    method.append(rwServiceFile, "replace");
+    method.append("obmc-flash-bmc-ubirw.service", "replace");
     bus.call_noreply(method);
 
-    std::string roServiceFile =
-        "obmc-flash-bmc-ubiro@" + versionId + ".service";
+    auto roServiceFile = "obmc-flash-bmc-ubiro@" + versionId + ".service";
     method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
                                  SYSTEMD_INTERFACE, "StartUnit");
     method.append(roServiceFile, "replace");
@@ -40,7 +37,7 @@ void Activation::onStateChanges(sdbusplus::message::message& msg)
     // Read the msg and populate each variable
     msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
 
-    auto rwServiceFile = "obmc-flash-bmc-ubirw@" + versionId + ".service";
+    auto rwServiceFile = "obmc-flash-bmc-ubirw.service";
     auto roServiceFile = "obmc-flash-bmc-ubiro@" + versionId + ".service";
     auto ubootVarsServiceFile =
         "obmc-flash-bmc-updateubootvars@" + versionId + ".service";
-- 
2.17.1