wip
diff --git a/bootloader.c b/bootloader.c
index d4039d8..e88160d 100644
--- a/bootloader.c
+++ b/bootloader.c
@@ -22,6 +22,8 @@
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 static int get_bootloader_message_mtd(struct bootloader_message *out, const Volume* v);
 static int set_bootloader_message_mtd(const struct bootloader_message *in, const Volume* v);
@@ -140,8 +142,26 @@
 // for misc partitions on block devices
 // ------------------------------------
 
+static void wait_for_device(const char* fn) {
+    int tries = 0;
+    int ret;
+    struct stat buf;
+    do {
+        ++tries;
+        ret = stat(fn, &buf);
+        if (ret) {
+            printf("stat %s try %d: %s\n", fn, tries, strerror(errno));
+            sleep(1);
+        }
+    } while (ret && tries < 10);
+    if (ret) {
+        printf("failed to stat %s\n", fn);
+    }
+}
+
 static int get_bootloader_message_block(struct bootloader_message *out,
                                         const Volume* v) {
+    wait_for_device(v->device);
     FILE* f = fopen(v->device, "rb");
     if (f == NULL) {
         LOGE("Can't open %s\n(%s)\n", v->device, strerror(errno));
@@ -163,6 +183,7 @@
 
 static int set_bootloader_message_block(const struct bootloader_message *in,
                                         const Volume* v) {
+    wait_for_device(v->device);
     FILE* f = fopen(v->device, "wb");
     if (f == NULL) {
         LOGE("Can't open %s\n(%s)\n", v->device, strerror(errno));
@@ -328,4 +349,4 @@
     }
  
     return 0;
-}
\ No newline at end of file
+}