Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b387a7f2 authored by JP Abgrall's avatar JP Abgrall Committed by Gerrit Code Review
Browse files

Merge "Wait for device to disappear after reboot-bootloader."

parents ac568b8f 157b0017
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ include $(CLEAR_VARS)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../mkbootimg \
  $(LOCAL_PATH)/../../extras/ext4_utils
LOCAL_SRC_FILES := protocol.c engine.c bootimg.c fastboot.c
LOCAL_SRC_FILES := protocol.c engine.c bootimg.c fastboot.c util.c
LOCAL_MODULE := fastboot
LOCAL_MODULE_TAGS := debug

@@ -69,7 +69,7 @@ $(call dist-for-goals,dist_files sdk,$(LOCAL_BUILT_MODULE))

ifeq ($(HOST_OS),linux)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := usbtest.c usb_linux.c
LOCAL_SRC_FILES := usbtest.c usb_linux.c util.c
LOCAL_MODULE := usbtest
include $(BUILD_HOST_EXECUTABLE)
endif
+8 −23
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@
#include <stdbool.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

@@ -48,34 +47,13 @@

#define ARRAY_SIZE(x)           (sizeof(x)/sizeof(x[0]))

double now()
{
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
}

char *mkmsg(const char *fmt, ...)
{
    char buf[256];
    char *s;
    va_list ap;

    va_start(ap, fmt);
    vsprintf(buf, fmt, ap);
    va_end(ap);

    s = strdup(buf);
    if (s == 0) die("out of memory");
    return s;
}

#define OP_DOWNLOAD   1
#define OP_COMMAND    2
#define OP_QUERY      3
#define OP_NOTICE     4
#define OP_FORMAT     5
#define OP_DOWNLOAD_SPARSE 6
#define OP_WAIT_FOR_DISCONNECT 7

typedef struct Action Action;

@@ -587,6 +565,11 @@ void fb_queue_notice(const char *notice)
    a->data = (void*) notice;
}

void fb_queue_wait_for_disconnect(void)
{
    queue_action(OP_WAIT_FOR_DISCONNECT, "");
}

int fb_execute_queue(usb_handle *usb)
{
    Action *a;
@@ -628,6 +611,8 @@ int fb_execute_queue(usb_handle *usb)
            status = fb_download_data_sparse(usb, a->data);
            status = a->func(a, status, status ? fb_get_error() : "");
            if (status) break;
        } else if (a->op == OP_WAIT_FOR_DISCONNECT) {
            usb_wait_for_disconnect(usb);
        } else {
            die("bogus action");
        }
+1 −12
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
@@ -82,17 +81,6 @@ unsigned second_offset = 0x00f00000;
unsigned tags_offset    = 0x00000100;


void die(const char *fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    fprintf(stderr,"error: ");
    vfprintf(stderr, fmt, ap);
    fprintf(stderr,"\n");
    va_end(ap);
    exit(1);
}

void get_my_path(char *path);

char *find_item(const char *item, const char *product)
@@ -1031,6 +1019,7 @@ int main(int argc, char **argv)
        fb_queue_reboot();
    } else if (wants_reboot_bootloader) {
        fb_queue_command("reboot-bootloader", "rebooting into bootloader");
        fb_queue_wait_for_disconnect();
    }

    if (fb_queue_is_empty())
+3 −0
Original line number Diff line number Diff line
@@ -58,10 +58,13 @@ void fb_queue_reboot(void);
void fb_queue_command(const char *cmd, const char *msg);
void fb_queue_download(const char *name, void *data, unsigned size);
void fb_queue_notice(const char *notice);
void fb_queue_wait_for_disconnect(void);
int fb_execute_queue(usb_handle *usb);
int fb_queue_is_empty(void);

/* util stuff */
double now();
char *mkmsg(const char *fmt, ...);
void die(const char *fmt, ...);

/* Current product */
+1 −1
Original line number Diff line number Diff line
@@ -62,6 +62,6 @@ usb_handle *usb_open(ifc_match_func callback);
int usb_close(usb_handle *h);
int usb_read(usb_handle *h, void *_data, int len);
int usb_write(usb_handle *h, const void *_data, int len);

int usb_wait_for_disconnect(usb_handle *h);

#endif
Loading