Add new command to get current partition and modify switch-partition command 44/274544/2
authorSangYoun Kwak <sy.kwak@samsung.com>
Mon, 2 May 2022 05:37:12 +0000 (14:37 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Tue, 3 May 2022 02:37:36 +0000 (02:37 +0000)
Change-Id: I32bfe926c07ae82db5c977a889c7302e03a207a8
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
packaging/deviced.spec
tools/board/CMakeLists.txt
tools/board/clear-partition-ab-cloned.c
tools/board/get-current-partition.c [new file with mode: 0644]
tools/board/get-partition-ab-cloned.c
tools/board/get-upgrade-status.c
tools/board/set-partition-ab-cloned.c
tools/board/set-upgrade-status.c
tools/board/switch-partition.c

index 5d19ec8..4fdeb7a 100644 (file)
@@ -325,6 +325,7 @@ mv %{_libdir}/iot-headless-battery.so %{_libdir}/deviced/battery.so
 %attr(0554,system_fw,system_fw) %{_bindir}/device_board_set_boot_success
 %attr(0554,system_fw,system_fw) %{_bindir}/device_board_clear_boot_mode
 %attr(0555,system_fw,system_fw) %{_bindir}/device_board_get_boot_mode
+%attr(0554,system_fw,system_fw) %{_bindir}/device_board_get_current_partition
 %attr(0554,system_fw,system_fw) %{_bindir}/device_board_switch_partition
 %attr(0554,system_fw,system_fw) %{_bindir}/device_board_set_partition_ab_cloned
 %attr(0554,system_fw,system_fw) %{_bindir}/device_board_clear_partition_ab_cloned
index 533901d..83c1d31 100644 (file)
@@ -19,6 +19,7 @@ ADD_BOOT_EXECUTABLE(device_board_set_boot_success set-boot-success.c)
 ADD_BOOT_EXECUTABLE(device_board_clear_boot_mode clear-boot-mode.c)
 ADD_BOOT_EXECUTABLE(device_board_get_boot_mode get-boot-mode.c)
 
+ADD_BOOT_EXECUTABLE(device_board_get_current_partition get-current-partition.c)
 ADD_BOOT_EXECUTABLE(device_board_switch_partition switch-partition.c)
 ADD_BOOT_EXECUTABLE(device_board_clear_partition_ab_cloned clear-partition-ab-cloned.c)
 ADD_BOOT_EXECUTABLE(device_board_get_partition_ab_cloned get-partition-ab-cloned.c)
index 6c4437d..7311b05 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * device-board-get-boot-mode
+ * device-board-clear-partition-ab-cloned
  *
  * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
  *
diff --git a/tools/board/get-current-partition.c b/tools/board/get-current-partition.c
new file mode 100644 (file)
index 0000000..23f1177
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * device-board-get-current-partition
+ *
+ * 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[])
+{
+       char partition_ab;
+       int ret;
+
+       ret = hal_device_board_get_current_partition(&partition_ab);
+
+       if(ret < 0) {
+               printf("FAILURE\n");
+               return 1;
+       }
+
+       printf("%c\n", partition_ab);
+       return 0;
+}
index d843930..2de6932 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * device-board-get-boot-mode
+ * device-board-get-partition-ab-cloned
  *
  * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
  *
index f66ad36..860f01a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * device-board-get-boot-mode
+ * device-board-get-upgrade-status
  *
  * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
  *
index 941fe0d..6bc927e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * device-board-get-boot-mode
+ * device-board-set-partition-ab-cloned
  *
  * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
  *
index 6080d63..c0810e4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * device-board-switch-partition
+ * device-board-set-upgrade-status
  *
  * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
  *
index 973e4ac..639a29f 100644 (file)
@@ -27,12 +27,14 @@ int main(int argc, char *argv[])
        int ret;
 
        if(argc < 2) {
-               goto err;
-       }
-
-       partition_ab = argv[1][0];
-       if(partition_ab != 'a' && partition_ab != 'b') {
-               goto err;
+               /* toggle partition */
+               partition_ab = '\0';
+       } else {
+               partition_ab = argv[1][0];
+
+               if(partition_ab != 'a' && partition_ab != 'b') {
+                       goto err;
+               }
        }
 
        ret = hal_device_board_switch_partition(partition_ab);