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 1bpJwk-0004Vb-VL for barebox@lists.infradead.org; Wed, 28 Sep 2016 18:51:13 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Wed, 28 Sep 2016 20:50:11 +0200 Message-Id: <20160928185017.25002-2-u.kleine-koenig@pengutronix.de> In-Reply-To: <20160928185017.25002-1-u.kleine-koenig@pengutronix.de> References: <20160928185017.25002-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 1/7] scripts: kwboot: try to resync on packet boundary after receiving a NAK To: barebox@lists.infradead.org SWYgd2Ugc2VudCB0aGUgYm9vdCBtZXNzYWdlIHRvbyBvZnRlbiB0aGUgQ1BVIG1pZ2h0IGFscmVh ZHkgaGF2ZSBzdGFydGVkCnRvIGludGVycHJldCB0aGlzIGFzIGFuIHhtb2RlbSBwYWNrZXQuIEFz IHNlbmRlciBhbmQgcmVjZWl2ZXIgYXJlIG5vdCBpbgpzeW5jIGl0J3MgaW1wb3NzaWJsZSB0byB0 cmFuc2ZlciBhIHBhY2tldCBzdWNjZXNzZnVsbHkuCgpBZnRlciBpbnNwZWN0aW5nIHRoZSBib290 Uk9NIG9mIGFuIEFybWFkYSBYUCBtYWNoaW5lICh2ZXJzaW9uIDEuMjApIEkgZm91bmQKdGhhdCBv biBzZW5kaW5nIDB4ZmYgdGhlIENQVSByZXBsaWVzIHdpdGggYSBOQUsgd2hlbiB3YWl0aW5nIGZv ciBhIHBhY2tldAphbmQgYWxsb3dzIHRvIHN0YXJ0IGEgbmV3I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