tool: add board opeartions 05/268305/5
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 20 Dec 2021 06:41:53 +0000 (15:41 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 21 Dec 2021 00:23:38 +0000 (09:23 +0900)
Change-Id: I300c324d1175fe53b1b69520b4c9ba29219a91fc
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
13 files changed:
CMakeLists.txt
packaging/deviced.spec
src/tools/partition-switch/CMakeLists.txt [deleted file]
src/tools/partition-switch/partition-switch.c [deleted file]
tools/board/CMakeLists.txt [new file with mode: 0644]
tools/board/clear-boot-mode.c [new file with mode: 0644]
tools/board/get-boot-mode.c [new file with mode: 0644]
tools/board/set-boot-success.c [new file with mode: 0644]
tools/board/switch-partition.c [new file with mode: 0644]
tools/devicectl/CMakeLists.txt [moved from src/tools/devicectl/CMakeLists.txt with 100% similarity]
tools/devicectl/devicectl.c [moved from src/tools/devicectl/devicectl.c with 100% similarity]
tools/devicectl/usb.c [moved from src/tools/devicectl/usb.c with 100% similarity]
tools/devicectl/usb.h [moved from src/tools/devicectl/usb.h with 100% similarity]

index 5e4c717..4a47b81 100644 (file)
@@ -317,8 +317,8 @@ ENDIF()
 
 ADD_SUBDIRECTORY(src/battery-monitor)
 ADD_SUBDIRECTORY(src/libdeviced)
-ADD_SUBDIRECTORY(src/tools/devicectl)
-ADD_SUBDIRECTORY(src/tools/partition-switch)
+ADD_SUBDIRECTORY(tools/devicectl)
+ADD_SUBDIRECTORY(tools/board)
 IF(TIZEN_FEATURE_USBHOST_TEST STREQUAL on)
        ADD_SUBDIRECTORY(tests/usb-host-ffs-test-daemon)
 ENDIF()
index 7191f5d..7adeb77 100644 (file)
@@ -314,7 +314,10 @@ mv %{_libdir}/iot-headless-power.so %{_libdir}/deviced/power.so
 #if #{?usb_module} == on ==> always on
 %{_bindir}/direct_set_debug.sh
 %{TZ_SYS_DUMPGEN}/dump_pmstate_log.sh
-%attr(2551,root,root) %{_bindir}/partition_switch
+%attr(2551,root,root) %{_bindir}/device_board_switch_partition
+%attr(2551,root,root) %{_bindir}/device_board_set_boot_success
+%attr(2551,root,root) %{_bindir}/device_board_clear_boot_mode
+%attr(2551,root,root) %{_bindir}/device_board_get_boot_mode
 #endif
 
 %files auto-test
diff --git a/src/tools/partition-switch/CMakeLists.txt b/src/tools/partition-switch/CMakeLists.txt
deleted file mode 100644 (file)
index 402eef8..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-SET(CMAKE_C_FLAGS ENV${CFLAGS})
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(REQUIRED_PKGS REQUIRED hal-api-device)
-FOREACH(flag ${REQUIRED_PKGS_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS ${EXTRA_CFLAGS})
-
-ADD_EXECUTABLE(partition_switch partition-switch.c)
-SET_TARGET_PROPERTIES(partition_switch PROPERTIES COMPILE_FLAGS "-fPIE")
-SET_TARGET_PROPERTIES(partition_switch PROPERTIES LINK_FLAGS "-pie")
-TARGET_LINK_LIBRARIES(partition_switch ${REQUIRED_PKGS_LDFLAGS})
-
-INSTALL(TARGETS partition_switch DESTINATION bin)
diff --git a/src/tools/partition-switch/partition-switch.c b/src/tools/partition-switch/partition-switch.c
deleted file mode 100644 (file)
index d06fd02..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <hal/device/hal-board.h>
-
-int main(int argc, char *argv[])
-{
-       return hal_device_board_switch_partition(argc, argv);
-}
diff --git a/tools/board/CMakeLists.txt b/tools/board/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2ac7eab
--- /dev/null
@@ -0,0 +1,21 @@
+SET(CMAKE_C_FLAGS ENV${CFLAGS})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(REQUIRED_PKGS REQUIRED hal-api-device)
+FOREACH(flag ${REQUIRED_PKGS_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS ${EXTRA_CFLAGS})
+
+MACRO(ADD_BOOT_EXECUTABLE BINARY_NAME SRCS)
+       ADD_EXECUTABLE(${BINARY_NAME} ${SRCS})
+       SET_TARGET_PROPERTIES(${BINARY_NAME} PROPERTIES COMPILE_FLAGS "-fPIE")
+       SET_TARGET_PROPERTIES(${BINARY_NAME} PROPERTIES LINK_FLAGS "-pie")
+       TARGET_LINK_LIBRARIES(${BINARY_NAME} ${REQUIRED_PKGS_LDFLAGS})
+       INSTALL(TARGETS ${BINARY_NAME} DESTINATION bin)
+ENDMACRO()
+
+ADD_BOOT_EXECUTABLE(device_board_switch_partition switch-partition.c)
+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)
diff --git a/tools/board/clear-boot-mode.c b/tools/board/clear-boot-mode.c
new file mode 100644 (file)
index 0000000..38075f9
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * device-board-clear-boot-mode
+ *
+ * Copyright (c) 2021 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 <hal/device/hal-board.h>
+
+int main(int argc, char *argv[])
+{
+       return hal_device_board_clear_boot_mode();
+}
diff --git a/tools/board/get-boot-mode.c b/tools/board/get-boot-mode.c
new file mode 100644 (file)
index 0000000..29ddde5
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * device-board-get-boot-mode
+ *
+ * Copyright (c) 2021 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 buffer[1024] = { 0, };
+       int ret;
+
+       ret = hal_device_board_get_boot_mode(buffer, sizeof(buffer));
+       if (ret == 0)
+               printf("%s", buffer);
+
+       return ret;
+}
diff --git a/tools/board/set-boot-success.c b/tools/board/set-boot-success.c
new file mode 100644 (file)
index 0000000..16ec3a5
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * device-board-set-boot-success
+ *
+ * Copyright (c) 2021 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 <hal/device/hal-board.h>
+
+int main(int argc, char *argv[])
+{
+       return hal_device_board_set_boot_success();
+}
diff --git a/tools/board/switch-partition.c b/tools/board/switch-partition.c
new file mode 100644 (file)
index 0000000..6c8c580
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * device-board-switch-partition
+ *
+ * Copyright (c) 2021 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 <hal/device/hal-board.h>
+
+int main(int argc, char *argv[])
+{
+       return hal_device_board_switch_partition(argc, argv);
+}