partition-switch: add new tool for partition switch 27/265227/2
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 13 Oct 2021 01:57:33 +0000 (10:57 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 19 Oct 2021 01:41:51 +0000 (10:41 +0900)
Add new tool for switching partition during FOTA. In addition to
this partition-switch tool, this patch makes new "tools" directory
to collect codes that produce executables, and those executables
will be packaged into deviced-tools.

Change-Id: I3d91265e97d4aeefc374fb7eb3a496ed7b670ce3
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
CMakeLists.txt
packaging/deviced.spec
src/tools/devicectl/CMakeLists.txt [moved from src/devicectl/CMakeLists.txt with 100% similarity]
src/tools/devicectl/devicectl.c [moved from src/devicectl/devicectl.c with 100% similarity]
src/tools/devicectl/usb.c [moved from src/devicectl/usb.c with 100% similarity]
src/tools/devicectl/usb.h [moved from src/devicectl/usb.h with 100% similarity]
src/tools/partition-switch/CMakeLists.txt [new file with mode: 0644]
src/tools/partition-switch/partition-switch.c [new file with mode: 0644]

index 0aef649..a75ab28 100644 (file)
@@ -325,7 +325,8 @@ ENDIF()
 
 ADD_SUBDIRECTORY(src/battery-monitor)
 ADD_SUBDIRECTORY(src/libdeviced)
-ADD_SUBDIRECTORY(src/devicectl)
+ADD_SUBDIRECTORY(src/tools/devicectl)
+ADD_SUBDIRECTORY(src/tools/partition-switch)
 IF(TIZEN_FEATURE_USBHOST_TEST STREQUAL on)
        ADD_SUBDIRECTORY(src/usb-host-ffs-test-daemon)
 ENDIF()
index c0dc3a3..4b3a7c1 100644 (file)
@@ -321,6 +321,7 @@ 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
 #endif
 
 %files auto-test
diff --git a/src/tools/partition-switch/CMakeLists.txt b/src/tools/partition-switch/CMakeLists.txt
new file mode 100644 (file)
index 0000000..402eef8
--- /dev/null
@@ -0,0 +1,15 @@
+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
new file mode 100644 (file)
index 0000000..d06fd02
--- /dev/null
@@ -0,0 +1,6 @@
+#include <hal/device/hal-board.h>
+
+int main(int argc, char *argv[])
+{
+       return hal_device_board_switch_partition(argc, argv);
+}