diff options
author | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2024-07-02 12:29:14 +0200 |
---|---|---|
committer | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2024-07-04 14:41:53 +0200 |
commit | e20823a5b4ce4cc25f7e90461575434c0de80651 (patch) | |
tree | 313f7ba175f4dc8e9d43311661e675010175cd49 | |
parent | 70cccb40bf116a54468f34dfa6c1eeac4f73fad2 (diff) | |
download | device-visionfive2-e20823a5b4ce4cc25f7e90461575434c0de80651.tar.gz device-visionfive2-e20823a5b4ce4cc25f7e90461575434c0de80651.tar.bz2 device-visionfive2-e20823a5b4ce4cc25f7e90461575434c0de80651.zip |
Add upgrade type featureaccepted/tizen/unified/x/20240708.014828
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: Ie9fc41224140d0ef4a7a481dcbb4718954dc85e8
-rw-r--r-- | hw/board/board.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/hw/board/board.c b/hw/board/board.c index 1db770c..271e1a2 100644 --- a/hw/board/board.c +++ b/hw/board/board.c @@ -36,6 +36,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" @@ -43,6 +44,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; @@ -338,6 +342,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 sysfs_write_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 = sysfs_read_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_device_board_funcs *device_board_funcs; @@ -370,6 +418,9 @@ static int board_init(void **data) device_board_funcs->set_upgrade_state = set_upgrade_state; device_board_funcs->get_upgrade_state = get_upgrade_state; + device_board_funcs->set_upgrade_type = set_upgrade_type; + device_board_funcs->get_upgrade_type = get_upgrade_type; + return 0; } |