@@ -66,17 +66,23 @@ int CodeUpdate::setCurrentBootSide(const std::string& currSide)
66
66
67
67
int CodeUpdate::setNextBootSide (const std::string& nextSide)
68
68
{
69
+ info (" setNextBootSide, nextSide={NXT_SIDE}" , " NXT_SIDE" , nextSide);
69
70
pldm_boot_side_data pldmBootSideData = readBootSideFile ();
70
- currBootSide = pldmBootSideData.current_boot_side ;
71
+ currBootSide = (pldmBootSideData.current_boot_side == " Perm" ? Pside
72
+ : Tside);
71
73
nextBootSide = nextSide;
72
- pldmBootSideData.next_boot_side = nextSide;
74
+ pldmBootSideData.next_boot_side = ( nextSide == Pside ? " Perm " : " Temp " ) ;
73
75
std::string objPath{};
74
76
if (nextBootSide == currBootSide)
75
77
{
78
+ info (" Current bootside is same as next boot side" );
79
+ info (" setting priority of running version 0" );
76
80
objPath = runningVersion;
77
81
}
78
82
else
79
83
{
84
+ info (" Current bootside is not same as next boot side" );
85
+ info (" setting priority of non running version 0" );
80
86
objPath = nonRunningVersion;
81
87
}
82
88
if (objPath.empty ())
@@ -99,7 +105,9 @@ int CodeUpdate::setNextBootSide(const std::string& nextSide)
99
105
catch (const std::exception & e)
100
106
{
101
107
// Alternate side may not be present due to a failed code update
102
- info (" Alternate side not present due to failed code update" );
108
+ error (
109
+ " Alternate side may not be present due to a failed code update. ERROR = {ERR}" ,
110
+ " ERR" , e);
103
111
return PLDM_PLATFORM_INVALID_STATE_VALUE;
104
112
}
105
113
@@ -218,6 +226,19 @@ void CodeUpdate::setVersions()
218
226
pldm_boot_side_data pldmBootSideData;
219
227
std::string nextBootSideBiosValue =
220
228
getBiosAttrValue (" fw_boot_side" );
229
+
230
+ // We enter this path during Genesis boot/boot after Factory reset.
231
+ // PLDM waits for Entity manager to populate System Type. After
232
+ // receiving system Type from EM it populates the bios attributes
233
+ // specific to that system We do not have bios attributes populated
234
+ // when we reach here so setting it to default value of the
235
+ // attribute as mentioned in the json files.
236
+ if (nextBootSideBiosValue.empty ())
237
+ {
238
+ info (
239
+ " Boot side is not initialized yet, so setting default value" );
240
+ nextBootSideBiosValue = " Temp" ;
241
+ }
221
242
pldmBootSideData.current_boot_side = nextBootSideBiosValue;
222
243
pldmBootSideData.next_boot_side = nextBootSideBiosValue;
223
244
pldmBootSideData.running_version_object = runningPath;
@@ -304,15 +325,16 @@ void CodeUpdate::setVersions()
304
325
}));
305
326
fwUpdateMatcher.push_back (std::make_unique<sdbusplus::bus::match_t >(
306
327
pldm::utils::DBusHandler::getBus (),
307
- " interface='org.freedesktop.DBus.ObjectManager',type='signal',"
328
+ " sender='xyz.openbmc_project.Software.BMC.Updater', interface='org.freedesktop.DBus.ObjectManager',type='signal',"
308
329
" member='InterfacesAdded',path='/xyz/openbmc_project/software'" ,
309
330
[this ](sdbusplus::message_t & msg) {
310
331
DBusInterfaceAdded interfaces;
311
332
sdbusplus::message::object_path path;
312
333
msg.read (path, interfaces);
313
-
334
+ info ( " Software interface got added " );
314
335
for (auto & interface : interfaces)
315
336
{
337
+ info (" Interface is {I}" , " I" , interface.first );
316
338
if (interface.first == " xyz.openbmc_project.Software.Activation" )
317
339
{
318
340
auto imageInterface = " xyz.openbmc_project.Software.Activation" ;
@@ -468,6 +490,7 @@ void CodeUpdate::processRenameEvent()
468
490
nextBootSide = Pside;
469
491
470
492
auto sensorId = getBootSideRenameStateSensor ();
493
+ info (" Received sendor id for rename {ID}" , " ID" , sensorId);
471
494
sendStateSensorEvent (sensorId, PLDM_STATE_SENSOR_STATE, 0 ,
472
495
PLDM_BOOT_SIDE_HAS_BEEN_RENAMED,
473
496
PLDM_BOOT_SIDE_NOT_RENAMED);
@@ -481,6 +504,7 @@ void CodeUpdate::processRenameEvent()
481
504
482
505
void CodeUpdate::writeBootSideFile (const pldm_boot_side_data& pldmBootSideData)
483
506
{
507
+ fs::create_directories (bootSideDirPath.parent_path ());
484
508
std::ofstream writeFile (bootSideDirPath.string (),
485
509
std::ios::out | std::ios::binary);
486
510
if (writeFile)
@@ -713,6 +737,16 @@ int processCodeUpdateLid(const std::string& filePath)
713
737
fs::create_directories (imageDirPath);
714
738
fs::create_directories (lidDirPath);
715
739
740
+ // Set the lid directory permissions to 777
741
+ std::error_code ec;
742
+ fs::permissions (lidDirPath, fs::perms::all, fs::perm_options::replace, ec);
743
+ if (ec)
744
+ {
745
+ error (" Failed to set the lid directory permissions:{ERR}" , " ERR" ,
746
+ ec.message ());
747
+ return PLDM_ERROR;
748
+ }
749
+
716
750
constexpr auto bmcClass = 0x2000 ;
717
751
if (htons (header.lidClass ) == bmcClass)
718
752
{
@@ -735,6 +769,17 @@ int processCodeUpdateLid(const std::string& filePath)
735
769
ofs << ifs.rdbuf ();
736
770
ofs.flush ();
737
771
ofs.close ();
772
+ // Set the lid file permissions to 440
773
+ std::error_code ec;
774
+ fs::permissions (lidNoHeaderPath,
775
+ fs::perms::owner_read | fs::perms::group_read,
776
+ fs::perm_options::replace, ec);
777
+ if (ec)
778
+ {
779
+ error (" Failed to set the lid file permissions: {ERR}" , " ERR" ,
780
+ ec.message ());
781
+ return PLDM_ERROR;
782
+ }
738
783
}
739
784
740
785
ifs.close ();
@@ -757,7 +802,7 @@ int CodeUpdate::assembleCodeUpdateImage()
757
802
auto method = bus.new_method_call (UPDATER_SERVICE, SOFTWARE_PATH,
758
803
LID_INTERFACE,
759
804
" AssembleCodeUpdateImage" );
760
- bus.call_noreply (method);
805
+ bus.call_noreply (method, dbusTimeout );
761
806
}
762
807
catch (const std::exception & e)
763
808
{
0 commit comments