From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1boTq4-0005rh-KP for barebox@lists.infradead.org; Mon, 26 Sep 2016 11:12:49 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Mon, 26 Sep 2016 13:12:22 +0200 Message-Id: <20160926111222.15087-1-u.kleine-koenig@pengutronix.de> In-Reply-To: <20160926081543.16088-1-u.kleine-koenig@pengutronix.de> References: <20160926081543.16088-1-u.kleine-koenig@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: [PATCH v2] scripts: kwboot: improve reliability on Armada XP To: barebox@lists.infradead.org Cc: Thomas Petazzoni , Kevin Smith , Stefan Roese VGhpcyBpbnRyb2R1Y2VzIHNldmVyYWwgY2hhbmdlcyB0aGF0IGltcHJvdmUgcHVzaGluZyBhIGJv b3QgaW1hZ2UgdmlhClVBUlQgdG8gYW4gQXJtYWRhIFhQIGJhc2VkIG1hY2hpbmUgKE5ldGdlYXIg Uk4gMjEyMCB3aXRoIEJvb3RST00gMS4yMCkuClRoZXkgd2VyZSBmb3VuZCBieSBpbnNwZWN0aW5n IHRoZSBzb3VyY2UsIHRoZSBhY3R1YWwgY29tbXVuaWNhdGlvbiBhbmQKZGlzYXNzZW1ibGluZyB0 aGUgYm9vdCBST00uCgpUaGUgY2hhbmdlcyBhcmU6CiAtIERvbid0IHVzZSBub24tYmxvY2tpbmcg b3Blbi4gVGhpcyBwcmV2ZW50cyB0cnlpbmcgdG8gcmVhZCB0aGUgYW5zd2VyCiAgIGZyb20gdGhl IFNvQyBiZWZvcmUgdGhlIG1hZ2ljIH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