From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YW4I2-0005eU-02 for barebox@lists.infradead.org; Thu, 12 Mar 2015 14:40:49 +0000 From: Jan Luebbe Date: Thu, 12 Mar 2015 15:39:58 +0100 Message-Id: <1426171199-2729-4-git-send-email-jlu@pengutronix.de> In-Reply-To: <1426171199-2729-1-git-send-email-jlu@pengutronix.de> References: <1426171199-2729-1-git-send-email-jlu@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [RFC 3/4] FIT: add FIT image support To: barebox@lists.infradead.org VGhlIEZJVCBpbWFnZSBmb3JtYXQgd2FzIGRlZmluZWQgZm9yIFUtQm9vdCBhbmQgaGFzIGJlZW4g YWRvcHRlZCBieSB0aGUKZGVwdGhjaGFyZ2UgcHJvamVjdCBhcyB3ZWxsLiBJdCBpcyBpbnRlbmRl ZCB0byBiZSBhIHJlcGxhY2VtZW50IGZvciB0aGUKdWltYWdlIGZvcm1hdCBhbmQgaGFzIGJlZW4g ZXh0ZW5kZWQgdG8gc3VwcG9ydCBzaWduaW5nIG9mIGtlcm5lbCwKaW5pdHJhbWZzIGFuZCBkZXZp Y2V0cmVlIGltYWdlcy4gVGhpcyBwYXRjaCBhZGRzIHN1cHBvcnQgZm9yIGJvb3RpbmcgRklUCmlt YWdlcyB0byBiYXJlYm94LgoKVG8gdmVyaWZ5IHNpZ25lZCBpbWFnZXMsIHRoZSBSU0EgcHVibGlj IGtleSBkYXRhIG11c3QgYmUgYXZhaWxhYmxlIGluCnRoZSBpbnRlcm5hbCBkZXZpY2UgdHJlZS4g Q3VycmVudGx5IG9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Cit2b2lkIGZpdF9jbG9zZShzdHJ1 Y3QgZml0X2hhbmRsZSAqaGFuZGxlKTsKKworI2VuZGlmCS8qIF9fSU1BR0VfRklUX0hfXyAqLwot LSAKMi4xLjQKCgpfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f XwpiYXJlYm94IG1haWxpbmcgbGlzdApiYXJlYm94QGxpc3RzLmluZnJhZGVhZC5vcmcKaHR0cDov L2xpc3RzLmluZnJhZGVhZC5vcmcvbWFpbG1hbi9saXN0aW5mby9iYXJlYm94Cg==