beaglebone: adds barebox bootloader

jkt: This is a port of https://patchwork.ozlabs.org/patch/614226/

Change-Id: I646d843fe2b9248d5a2ed3855142f1545b7bab52
Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz>
diff --git a/board/czechlight_beaglebone/barebox.env/boot/sd b/board/czechlight_beaglebone/barebox.env/boot/sd
new file mode 100644
index 0000000..0cd1be6
--- /dev/null
+++ b/board/czechlight_beaglebone/barebox.env/boot/sd
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+global.bootm.image=/boot/zImage
+
+# Default to using the barebox built-in dtb
+# global.bootm.oftree=/boot/oftree
+
+# No initrd
+# global.bootm.initrd=<path to initrd>
+
+global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"
diff --git a/board/czechlight_beaglebone/barebox.env/config-board b/board/czechlight_beaglebone/barebox.env/config-board
new file mode 100644
index 0000000..cd7b26d
--- /dev/null
+++ b/board/czechlight_beaglebone/barebox.env/config-board
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+global.boot.default=sd
+
diff --git a/board/czechlight_beaglebone/genimage.cfg b/board/czechlight_beaglebone/genimage.cfg
new file mode 100644
index 0000000..a058ce9
--- /dev/null
+++ b/board/czechlight_beaglebone/genimage.cfg
@@ -0,0 +1,32 @@
+image boot.vfat {
+	vfat {
+		file MLO {
+			image = "barebox-am33xx-beaglebone-mlo.img"
+		}
+		file barebox.bin {
+			image = "barebox-am33xx-beaglebone.img"
+		}
+		files = {
+			"barebox.env",
+			"zImage"
+		}
+	}
+	size = 32M
+}
+
+image sdcard.img {
+	hdimage {
+	}
+
+	partition boot {
+		partition-type = 0xC
+		in-partition-table = "yes"
+		bootable = "true"
+		image = "boot.vfat"
+	}
+
+	partition rootfs {
+		partition-type = 0x83
+		image = "rootfs.ext4"
+	}
+}
diff --git a/board/czechlight_beaglebone/post-image.sh b/board/czechlight_beaglebone/post-image.sh
new file mode 100755
index 0000000..149ffb1
--- /dev/null
+++ b/board/czechlight_beaglebone/post-image.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+BOARD_DIR="$(dirname $0)"
+GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
+GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
+
+rm -rf "${GENIMAGE_TMP}"
+
+genimage \
+	--rootpath "${TARGET_DIR}" \
+	--tmppath "${GENIMAGE_TMP}" \
+	--inputpath "${BINARIES_DIR}" \
+	--outputpath "${BINARIES_DIR}" \
+	--config "${GENIMAGE_CFG}"
+
+exit $?
+