Add setter/getter tool for upgrade state 67/312767/3
authorSangYoun Kwak <sy.kwak@samsung.com>
Wed, 5 Jun 2024 07:48:33 +0000 (16:48 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Fri, 14 Jun 2024 07:34:27 +0000 (16:34 +0900)
To make upgrade state settable and gettable, corresponding tools are
added:
 * device_board_get_upgrade_state
 * device_board_set_upgrade_state

Since the names "upgrade status" and "upgrade state" are similar,
to distinguish them, "upgrade status" is renamed as
"upgrade progress status".

Change-Id: Ia25aac24c1c48e375f152b1a8d999ecc1b95ed0a
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
packaging/deviced.spec
tools/board/CMakeLists.txt
tools/board/get-upgrade-progress-status.c [new file with mode: 0644]
tools/board/get-upgrade-state.c [new file with mode: 0644]
tools/board/get-upgrade-status.c [deleted file]
tools/board/set-upgrade-progress-status.c [new file with mode: 0644]
tools/board/set-upgrade-state.c [new file with mode: 0644]
tools/board/set-upgrade-status.c [deleted file]

index 60697d610d65d7e66d3503685aa142a0746c5ae6..830d875e223db6444f33a84b4ef9d921587ca13e 100644 (file)
@@ -332,8 +332,10 @@ mv %{_libdir}/tv-display.so %{_libdir}/deviced/display.so
 %attr(0555,system_fw,system_fw) %{_bindir}/device_board_get_partition_ab_cloned
 %attr(0555,system_fw,system_fw) %{_bindir}/device_board_set_partition_status
 %attr(0555,system_fw,system_fw) %{_bindir}/device_board_get_partition_status
-%attr(0554,system_fw,system_fw) %{_bindir}/device_board_set_upgrade_status
-%attr(0555,system_fw,system_fw) %{_bindir}/device_board_get_upgrade_status
+%attr(0554,system_fw,system_fw) %{_bindir}/device_board_set_upgrade_progress_status
+%attr(0555,system_fw,system_fw) %{_bindir}/device_board_get_upgrade_progress_status
+%attr(0554,system_fw,system_fw) %{_bindir}/device_board_set_upgrade_state
+%attr(0555,system_fw,system_fw) %{_bindir}/device_board_get_upgrade_state
 
 %files auto-test
 %manifest deviced.manifest
index a87ccc0f675d06fa9d12b1eefd5c3772f73fc78c..334fb54036fe121f35c6f361a8f58ed615fd22be 100644 (file)
@@ -27,5 +27,8 @@ ADD_BOOT_EXECUTABLE(device_board_set_partition_ab_cloned set-partition-ab-cloned
 ADD_BOOT_EXECUTABLE(device_board_get_partition_status get-partition-status.c)
 ADD_BOOT_EXECUTABLE(device_board_set_partition_status set-partition-status.c)
 
-ADD_BOOT_EXECUTABLE(device_board_set_upgrade_status set-upgrade-status.c)
-ADD_BOOT_EXECUTABLE(device_board_get_upgrade_status get-upgrade-status.c)
+ADD_BOOT_EXECUTABLE(device_board_set_upgrade_progress_status set-upgrade-progress-status.c)
+ADD_BOOT_EXECUTABLE(device_board_get_upgrade_progress_status get-upgrade-progress-status.c)
+
+ADD_BOOT_EXECUTABLE(device_board_set_upgrade_state set-upgrade-state.c)
+ADD_BOOT_EXECUTABLE(device_board_get_upgrade_state get-upgrade-state.c)
diff --git a/tools/board/get-upgrade-progress-status.c b/tools/board/get-upgrade-progress-status.c
new file mode 100644 (file)
index 0000000..585206a
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * device-board-get-upgrade-progress-status
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <hal/device/hal-board.h>
+
+int main(int argc, char *argv[])
+{
+       int status;
+       int ret;
+
+       ret = hal_device_board_get_upgrade_progress_status(&status);
+
+       if(ret < 0) {
+               printf("FAILURE\n");
+               return 1;
+       }
+
+       printf("%d\n", status);
+       return 0;
+}
diff --git a/tools/board/get-upgrade-state.c b/tools/board/get-upgrade-state.c
new file mode 100644 (file)
index 0000000..6c552fa
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * device-board-get-upgrade-state
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <hal/device/hal-board.h>
+
+#define BUFFER_LEN 1024
+
+int main(int argc, char *argv[])
+{
+       char state_buffer[BUFFER_LEN];
+       int ret;
+
+       ret = hal_device_board_get_upgrade_state(state_buffer, BUFFER_LEN);
+       if(ret < 0) {
+               printf("FAILURE\n");
+               return 1;
+       }
+
+       printf("%s\n", state_buffer);
+       return 0;
+}
diff --git a/tools/board/get-upgrade-status.c b/tools/board/get-upgrade-status.c
deleted file mode 100644 (file)
index 860f01a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * device-board-get-upgrade-status
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <hal/device/hal-board.h>
-
-int main(int argc, char *argv[])
-{
-       int status;
-       int ret;
-
-       ret = hal_device_board_get_upgrade_status(&status);
-
-       if(ret < 0) {
-               printf("FAILURE\n");
-               return 1;
-       }
-
-       printf("%d\n", status);
-       return 0;
-}
diff --git a/tools/board/set-upgrade-progress-status.c b/tools/board/set-upgrade-progress-status.c
new file mode 100644 (file)
index 0000000..d4631d8
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * device-board-set-upgrade-progress-status
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <hal/device/hal-board.h>
+
+static int parse_integer(const char *str, int *val)
+{
+       char *endptr = NULL;
+       long longval = 0;
+
+       errno = 0;
+       longval = strtol(str, &endptr, 10);
+
+       if(errno || *endptr) {
+               errno = 0;
+               return -EINVAL;
+       }
+
+       if(longval > INT_MAX || longval < INT_MIN) {
+               return -EINVAL;
+       }
+
+       *val = (int)longval;
+
+       return 0;
+}
+
+int main(int argc, char *argv[])
+{
+       int status;
+       int parse_ret, ret;
+
+       if(argc < 2) {
+               goto err;
+       }
+
+       parse_ret = parse_integer(argv[1], &status);
+
+       if(parse_ret < 0) {
+               goto err;
+       }
+
+       ret = hal_device_board_set_upgrade_progress_status(status);
+
+       if(ret < 0) {
+               goto err;
+       }
+
+       printf("SUCCESS\n");
+       return 0;
+
+err:
+       printf("FAILURE\n");
+       return 1;
+}
diff --git a/tools/board/set-upgrade-state.c b/tools/board/set-upgrade-state.c
new file mode 100644 (file)
index 0000000..f66ecbc
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * device-board-set-upgrade-state
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <hal/device/hal-board.h>
+
+int main(int argc, char *argv[])
+{
+       char *state_from = NULL;
+       char *state_to = NULL;
+       int ret = 0;
+
+       if(argc < 3)
+               goto error;
+
+       state_from = argv[1];
+       state_to = argv[2];
+
+       ret = hal_device_board_set_upgrade_state(state_from, state_to);
+       if(ret < 0)
+               goto error;
+
+       printf("SUCCESS\n");
+       return 0;
+
+error:
+       printf("FAILURE\n");
+       return 1;
+}
diff --git a/tools/board/set-upgrade-status.c b/tools/board/set-upgrade-status.c
deleted file mode 100644 (file)
index c0810e4..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * device-board-set-upgrade-status
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <limits.h>
-
-#include <hal/device/hal-board.h>
-
-static int parse_integer(const char *str, int *val)
-{
-       char *endptr = NULL;
-       long longval = 0;
-
-       errno = 0;
-       longval = strtol(str, &endptr, 10);
-
-       if(errno || *endptr) {
-               errno = 0;
-               return -EINVAL;
-       }
-
-       if(longval > INT_MAX || longval < INT_MIN) {
-               return -EINVAL;
-       }
-
-       *val = (int)longval;
-
-       return 0;
-}
-
-int main(int argc, char *argv[])
-{
-       int status;
-       int parse_ret, ret;
-
-       if(argc < 2) {
-               goto err;
-       }
-
-       parse_ret = parse_integer(argv[1], &status);
-
-       if(parse_ret < 0) {
-               goto err;
-       }
-
-       ret = hal_device_board_set_upgrade_status(status);
-
-       if(ret < 0) {
-               goto err;
-       }
-
-       printf("SUCCESS\n");
-       return 0;
-
-err:
-       printf("FAILURE\n");
-       return 1;
-}