diff options
author | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2024-06-28 12:01:31 +0200 |
---|---|---|
committer | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2024-07-04 11:37:56 +0200 |
commit | c7475715135891be6e3854f3f13b3f6ea2cf2952 (patch) | |
tree | 222779dc4aa8d51ebe7d9a4e7335f2eeca0ff346 | |
parent | 298639364991a70e0247202f436f86d7f0bbf58f (diff) | |
download | device-rpi-c7475715135891be6e3854f3f13b3f6ea2cf2952.tar.gz device-rpi-c7475715135891be6e3854f3f13b3f6ea2cf2952.tar.bz2 device-rpi-c7475715135891be6e3854f3f13b3f6ea2cf2952.zip |
Add upgrade type featureaccepted/tizen/unified/x/20240708.014820accepted/tizen/unified/dev/20240709.043434accepted/tizen/unified/20240708.173201
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.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/hw/board/board.c b/hw/board/board.c index 3e9233a..311e0dd 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; } |