summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>2024-06-28 12:01:31 +0200
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>2024-07-08 14:15:36 +0200
commitd0660d6f0f59360ed2226a07846e5993f0fa254d (patch)
tree15f40a96ac23613432440b52dfb60e6e11b700d0
parent6ee9f36ec2bd2838cd05612bf588f3e0596535de (diff)
downloaddevice-rpi-tizen_8.0.tar.gz
device-rpi-tizen_8.0.tar.bz2
device-rpi-tizen_8.0.zip
Use set_upgrade_type to select the type of upgrade: * online * offline After reboot fota, u-boot will run online or offline upgrade based on the selected type. Change-Id: I33c86c91d6f7e13db7a29dde10d3c360b977dd37
-rw-r--r--hw/board/board.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/hw/board/board.c b/hw/board/board.c
index c396ff1..b02f22d 100644
--- a/hw/board/board.c
+++ b/hw/board/board.c
@@ -37,6 +37,7 @@
#define PARTITION_B_STATUS_PATH INFORM_MNT_PATH"/partition-b-status.info"
#define REBOOT_PARAM_PATH INFORM_MNT_PATH"/reboot-param.bin"
#define UPGRADE_STATE_PATH INFORM_MNT_PATH"/upgrade-state.info"
+#define UPGRADE_TYPE_PATH INFORM_MNT_PATH"/upgrade-type.info"
#define SERIAL_FILE_PATH "/sys/firmware/devicetree/base/serial-number"
#define PARTITION_STATUS_OK "ok"
@@ -44,6 +45,9 @@
#define PARTITION_STATUS_FAILED "failed"
#define BOOT_MODE_NORMAL "norm"
+#define UPGRADE_TYPE_ONLINE "online"
+#define UPGRADE_TYPE_OFFLINE "offline"
+
static int get_device_serial_number(char *buffer, int len)
{
FILE *fp;
@@ -339,6 +343,50 @@ static int get_upgrade_state(char *buffer, const int max_len)
return 0;
}
+static int set_upgrade_type(char *type)
+{
+ if (type == NULL)
+ return -EINVAL;
+
+ if (strcmp(type, UPGRADE_TYPE_ONLINE) != 0 &&
+ strcmp(type, UPGRADE_TYPE_OFFLINE) != 0) {
+ return -EINVAL;
+ }
+
+ /* clear contents of the file first */
+ if (truncate(UPGRADE_TYPE_PATH, 0) == -1) {
+ int ferror = errno;
+ errno = 0;
+ return -ferror;
+ }
+
+ return sys_set_str(UPGRADE_TYPE_PATH, type);
+}
+
+static int get_upgrade_type(char *buffer, const int max_len)
+{
+ int ret = 0;
+
+ if (buffer == NULL)
+ return -EINVAL;
+
+ if (max_len < 1)
+ return -EINVAL;
+
+ ret = sys_get_str(UPGRADE_TYPE_PATH, buffer, max_len - 1);
+ if (ret < 0)
+ return ret;
+
+ trim_str(buffer);
+
+ if (strcmp(buffer, UPGRADE_TYPE_ONLINE) != 0 &&
+ strcmp(buffer, UPGRADE_TYPE_OFFLINE) != 0) {
+ return -ENOENT;
+ }
+
+ return 0;
+}
+
static int board_init(void **data)
{
hal_backend_board_funcs *board_funcs;
@@ -368,6 +416,9 @@ static int board_init(void **data)
*data = (void *)board_funcs;
+ board_funcs->set_upgrade_type = set_upgrade_type;
+ board_funcs->get_upgrade_type = get_upgrade_type;
+
return 0;
}