 +    "fi; "                                                              \
 +    "setenv upgrade_available 0; "                                      \
 +    "saveenv; "                                                         \
-+    "run mender_setup\0"
++    "run mender_setup\0"                                                \
++                                                                        \
++    "mender_try_to_recover="                                            \
++    "if test ${upgrade_available} = 1; "                                \
++    "then reset; "                                                      \
++    "fi\0"
 +
 +#endif /* ENV_MENDER_H */
 diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf

From 4811089b0e308f17d54832a405723e64deea2636 Mon Sep 17 00:00:00 2001
From: Kristian Amlie <kristian.amlie@mender.io>
Date: Fri, 12 Aug 2016 10:15:11 +0200
Subject: [PATCH] Generic boot code for Mender.

 #endif
diff --git a/include/env_mender.h b/include/env_mender.h
new file mode 100644
index 0000000..d13d0b1
--- /dev/null
+++ b/include/env_mender.h
@@ -0,0 +1,64 @@
+/*
+  Copyright (C) 2016  Mender Software
+
