added support for downloading to our custom bootloader
diff --git a/bbb_cape/src/bbb/byte_io.h b/bbb_cape/src/bbb/byte_io.h
new file mode 100644
index 0000000..41708e9
--- /dev/null
+++ b/bbb_cape/src/bbb/byte_io.h
@@ -0,0 +1,51 @@
+#ifndef BBB_BYTE_READER_H_
+#define BBB_BYTE_READER_H_
+
+#include <sys/types.h>
+
+#include "aos/common/time.h"
+
+namespace bbb {
+
+class ByteReaderInterface {
+ public:
+  virtual ~ByteReaderInterface() {}
+
+  // Implemented by subclasses to provide a data source
+  // for these algorithms.
+  // Returns the number of bytes read, -1 if there is an error in errno, or -2
+  // if reading takes longer than timeout.
+  virtual ssize_t ReadBytes(
+      uint8_t *dest, size_t max_bytes,
+      const ::aos::time::Time &timeout = ::aos::time::Time(0, 0)) = 0;
+};
+
+class ByteWriterInterface {
+ public:
+  virtual ~ByteWriterInterface() {}
+
+  // Implemented by subclasses to actually write the data somewhere.
+  // Returns true if it succeeds or false if it fails and there is an error in
+  // errno.
+  virtual bool WriteBytes(uint8_t *bytes, size_t number_bytes) = 0;
+};
+
+class ByteReaderWriterInterface : public ByteReaderInterface,
+                                  public ByteWriterInterface {};
+
+class ByteReaderAndWriter : public ByteReaderWriterInterface {
+ public:
+  ByteReaderAndWriter(ByteReaderInterface *reader, ByteWriterInterface *writer)
+      : reader_(reader), writer_(writer) {}
+
+  ByteReaderInterface *reader() { return reader_; }
+  ByteWriterInterface *writer() { return writer_; }
+
+ private:
+  ByteReaderInterface *const reader_;
+  ByteWriterInterface *const writer_;
+};
+
+}  // namespace bbb
+
+#endif  // BBB_BYTE_READER_H_