Add simple recovery image

* Essentially just u-boot dd'd onto a small partition.

Change-Id: I868cf46d64fee00d13bb2d927543a7529e1ef4c6
diff --git a/Makefile b/Makefile
index 3bd28df..fe5721e 100644
--- a/Makefile
+++ b/Makefile
@@ -43,6 +43,7 @@
 include $(ROOTDIR)/build/rootfs.mk
 include $(ROOTDIR)/build/sdcard.mk
 include $(ROOTDIR)/build/u-boot.mk
+include $(ROOTDIR)/build/recovery.mk
 
 include $(ROOTDIR)/build/docker.mk
 include $(ROOTDIR)/build/packages.mk
diff --git a/recovery.mk b/recovery.mk
new file mode 100644
index 0000000..d7b999b
--- /dev/null
+++ b/recovery.mk
@@ -0,0 +1,41 @@
+# Copyright 2018 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ifeq ($(ROOTDIR),)
+$(error $$ROOTDIR IS NOT DEFINED -- don\'t forget to source setup.sh)
+endif
+
+include $(ROOTDIR)/build/preamble.mk
+
+recovery: $(PRODUCT_OUT)/recovery.img
+recovery-xz: $(PRODUCT_OUT)/recovery.img.xz
+
+recovery-allocate: | $(PRODUCT_OUT)
+	fallocate -l 4M $(PRODUCT_OUT)/recovery.img
+
+$(PRODUCT_OUT)/recovery.img: recovery-allocate \
+                           $(ROOTDIR)/build/u-boot.mk \
+                           | $(PRODUCT_OUT)/u-boot.imx
+	dd if=$(PRODUCT_OUT)/u-boot.imx of=$(PRODUCT_OUT)/recovery.img conv=notrunc seek=66 bs=512
+
+$(PRODUCT_OUT)/recovery.img.xz: $(PRODUCT_OUT)/recovery.img
+	xz -k -T0 -0 $(PRODUCT_OUT)/recovery.img
+
+targets::
+	@echo "recovery     - generate a flashable recovery image"
+
+clean::
+	rm -f $(PRODUCT_OUT)/recovery.img
+
+.PHONY:: recovery recovery-xz