SET(OUTPUT_BIN_NAME osu)
PROJECT(update-control-tools-${OUTPUT_BIN_NAME} C)
+SET(PKG_MODULES
+ hal-api-device
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(REQUIRED_PKGS REQUIRED ${PKG_MODULES})
+
+FOREACH(flag ${REQUIRED_PKGS_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
INCLUDE_DIRECTORIES(. ${CMAKE_SOURCE_DIR}/include)
FILE(GLOB_RECURSE SRCS osu.c resize.c update.c)
struct arguments {
bool resize;
bool update;
+ bool online;
};
static void print_help(char*);
args->resize = false;
args->update = false;
+ args->online = false;
struct option long_options[] = {
{"resize", no_argument, NULL, 'r'},
{"update", no_argument, NULL, 'u'},
+ {"offline-update", no_argument, NULL, 'f'},
+ {"online-update", no_argument, NULL, 'n'},
{"help", no_argument, NULL, 'h'},
{}
};
args->resize = true;
return 0;
}
- case 'u': {
+ case 'u':
+ case 'f': {
args->update = true;
return 0;
}
+ case 'n': {
+ args->update = true;
+ args->online = true;
+ return 0;
+ }
case 'h': {
print_help(argv[0]);
return 0;
printf("Usage:\n"
" %s [--help|--resize|--update]\n\n"
"Possible arguments:\n"
- " --help Print this help\n"
- " --update Trigger the OS Upgrade\n"
- " --resize Run resize2fs on the rootfs partition.\n"
+ " --help Print this help\n"
+ " --update Trigger the OS Upgrade (Offline Upgrade)\n"
+ " --offline-update Trigger the OS Offline Upgrade\n"
+ " --online-update Trigger the OS Online Upgrade\n"
+ " --resize Run resize2fs on the rootfs partition.\n"
" After that, performing the OS Upgrade will be impossible.\n\n" ,my_name);
}
return do_resize();
if (args.update)
- return do_update();
+ return do_update(args.online);
print_help(argv[0]);
#include "update_control.h"
#include "update.h"
+#include <hal/device/hal-board.h>
-int do_update(void)
+
+#define UPDATE_TYPE_ONLINE "online"
+#define UPDATE_TYPE_OFFLINE "offline"
+
+int set_update_type(bool online)
+{
+ char *type;
+ if (online) {
+ type = UPDATE_TYPE_ONLINE;
+ } else {
+ type = UPDATE_TYPE_OFFLINE;
+ }
+ return hal_device_board_set_upgrade_type(type);
+}
+
+int do_update(bool online)
{
int ret = 0;
int ret_deinit = 0;
+ ret = set_update_type(online);
+ if (ret != 0) {
+ printf("Failed to set update type\n");
+ return ret;
+ }
+
ret = update_control_initialize();
if (ret != UPDATE_CONTROL_ERROR_NONE) {
printf("Failed to initialize: %d\n", ret);