diff --git a/README.md b/README.md index 4bf83845..65eb0cb8 100644 --- a/README.md +++ b/README.md @@ -211,8 +211,8 @@ Some context information about the used commands: - Chip 0 Copy 0: `/tmp/mntupdate-xdi-qspi0-nom-rootfs` - Chip 0 Copy 1: `/tmp/mntupdate-xdi-qspi0-gold-rootfs` - - Slot 0 Copy 0: `/tmp/mntupdate-xdi-qspi1-nom-rootfs` - - Slot 0 Copy 0: `/tmp/mntupdate-xdi-qspi1-gold-rootfs` + - Slot 1 Copy 0: `/tmp/mntupdate-xdi-qspi1-nom-rootfs` + - Slot 1 Copy 1: `/tmp/mntupdate-xdi-qspi1-gold-rootfs` 2. Writing the file with a regular `cp ` command 3. Enabling the writeprotection using the `writeprotect 1` utility. diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 398e1e85..e5cdb1aa 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -207,18 +207,31 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_ if (size < 2) { return HasActionsIF::INVALID_PARAMETERS; } + if (data[0] > 1 or data[1] > 1) { + return HasActionsIF::INVALID_PARAMETERS; + } + auto chip = static_cast(data[0]); + auto copy = static_cast(data[1]); path archivePath = path(config::SD_0_MOUNT_POINT) / path(config::OBSW_UPDATE_ARCHIVE_FILE_NAME); if (not exists(archivePath)) { return HasFileSystemIF::FILE_DOES_NOT_EXIST; } - std::ostringstream cmd("tar -xJvf"); + ostringstream cmd("tar -xJvf"); cmd << " " << archivePath; - int result = std::system(cmd.str().c_str()); + int result = system(cmd.str().c_str()); if (result != 0) { utility::handleSystemError(result, "CoreController::executeAction: SW Update Decompression"); } + cmd.clear(); + cmd << "xsc_mount_copy " << data[0] << " " << data[1]; + result = system(cmd.str().c_str()); + if (result != 0) { + std::string ctxString = + "CoreController::executeAction: SW Update Mounting " + data[0] + " " + data[1]; + utility::handleSystemError(result, ctxString); + } return HasActionsIF::EXECUTION_FINISHED; } case (SWITCH_IMG_LOCK): { @@ -1868,6 +1881,24 @@ void CoreController::readHkData() { } } +const char *CoreController::getXscMountDir(xsc::Chip chip, xsc::Copy copy) { + if (chip == xsc::Chip::CHIP_0) { + if (copy == xsc::Copy::COPY_0) { + return CHIP_0_COPY_0_MOUNT_DIR; + } else if (copy == xsc::Copy::COPY_1) { + return CHIP_0_COPY_1_MOUNT_DIR; + } + } else if (chip == xsc::Chip::CHIP_1) { + if (copy == xsc::Copy::COPY_0) { + return CHIP_1_COPY_0_MOUNT_DIR; + } else if (copy == xsc::Copy::COPY_1) { + return CHIP_1_COPY_1_MOUNT_DIR; + } + } + sif::error << "Invalid chip or copy passed to CoreController::getXscMountDir" << std::endl; + return CHIP_0_COPY_0_MOUNT_DIR; +} + bool CoreController::isNumber(const std::string &s) { return !s.empty() && std::find_if(s.begin(), s.end(), [](unsigned char c) { return !std::isdigit(c); }) == s.end(); diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 4a630863..d7f05769 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -119,6 +119,7 @@ class CoreController : public ExtendedControllerBase { static ReturnValue_t generateChipStateFile(); static ReturnValue_t incrementAllocationFailureCount(); static void getCurrentBootCopy(xsc::Chip& chip, xsc::Copy& copy); + static const char* getXscMountDir(xsc::Chip chip, xsc::Copy copy); ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true);