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: cfaa077ebdf6958c229dfee39f4f9dec8185e59f (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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
From df1281792f6886b41c99919e8197c2c2d369d0ca 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] 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    | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 meson.build       |  1 +
 meson_options.txt |  3 +++
 static/flash.cpp  | 42 ++++++++++++++++++++++++++++++++++++++++--
 ubi/flash.cpp     |  9 +++------
 5 files changed, 91 insertions(+), 9 deletions(-)

diff --git a/activation.cpp b/activation.cpp
index eb57587..901caf3 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -92,7 +92,50 @@ auto Activation::activation(Activations value) -> Activations
         value ==
             softwareServer::Activation::Activations::ActivatingAsStandbySpare)
     {
+#ifdef 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 // !FWUPD_SCRIPT
 #ifdef HOST_BIOS_UPGRADE
         auto purpose = parent.versions.find(versionId)->second->purpose();
         if (purpose == VersionPurpose::Host)
@@ -115,7 +158,6 @@ auto Activation::activation(Activations value) -> Activations
             return softwareServer::Activation::activation(value);
         }
 #endif
-
         auto versionStr = parent.versions.find(versionId)->second->version();
 
         if (!minimum_ship_level::verify(versionStr))
@@ -179,6 +221,7 @@ auto Activation::activation(Activations value) -> Activations
         return softwareServer::Activation::activation(
             softwareServer::Activation::Activations::Active);
 #endif
+#endif // FWUPD_SCRIPT
     }
     else
     {
diff --git a/meson.build b/meson.build
index 0a7a6a6..5990168 100644
--- a/meson.build
+++ b/meson.build
@@ -57,6 +57,7 @@ conf.set('WANT_SIGNATURE_VERIFY', \
     get_option('verify-signature').enabled() or \
     get_option('verify-full-signature').enabled())
 conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
+conf.set('FWUPD_SCRIPT', get_option('fwupd-script').enabled())
 
 # Configurable variables
 conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
diff --git a/meson_options.txt b/meson_options.txt
index 355773c..f0c8730 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -25,6 +25,9 @@ option('verify-signature', type: 'feature',
 option('verify-full-signature', type: 'feature',
     description: 'Enable image full signature validation.')
 
+option('fwupd-script', type: 'feature',
+    description: 'Enable fwupd script support.')
+
 # Variables
 option(
     'active-bmc-max-allowed', type: 'integer',
diff --git a/static/flash.cpp b/static/flash.cpp
index 101828b..5506a59 100644
--- a/static/flash.cpp
+++ b/static/flash.cpp
@@ -22,9 +22,11 @@ namespace updater
 
 namespace fs = std::filesystem;
 using namespace phosphor::software::image;
+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.
@@ -36,11 +38,47 @@ 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(__attribute__((unused))
+                                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 a263bfb..c58eefc 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