[source] firmware-utils: mktplinkfw: fix JFFS2 EOF markers

LEDE Commits lede-commits at lists.infradead.org
Thu Dec 14 00:29:54 PST 2017


blogic pushed a commit to source.git, branch master:
https://git.lede-project.org/1a51241cb1be87a45cac12753a437f786329afc6

commit 1a51241cb1be87a45cac12753a437f786329afc6
Author: Sergey Ryazanov <ryazanov.s.a at gmail.com>
AuthorDate: Wed Oct 11 01:07:08 2017 +0300

    firmware-utils: mktplinkfw: fix JFFS2 EOF markers
    
    mktplinkfw/mktplinkfw2 utilities put JFFS2 EOF market only at 64KB
    boundary, this could lead to current device configuration lost during
    the sysupgrade on a device, which is equpped with flash with the 4KB
    erase block size (e.g. TP-Link Archer C20).
    
    This happens when 64KB and 4KB alignments do not match, so the JFFS2
    data is written not exactly at the partition beginnig and startup
    scripts can not find the JFFS2 during the first boot just after the
    sysupgrade.
    
    Fix this by placing additional JFFS2 EOF marker at a 4KB boundary. Also
    keep the marker at 64KB intact, so the utilities will produce images
    suitable for devices with both 4KB and 64KB erase blocks.
    
    Fixes: 29a2c2ea80441895a2ffe100d854d2b26d5fa606 (add ability to put
    jffs2 eof marker into the image)
    
    Signed-off-by: Sergey Ryazanov <ryazanov.s.a at gmail.com>
---
 tools/firmware-utils/src/mktplinkfw-lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/firmware-utils/src/mktplinkfw-lib.c b/tools/firmware-utils/src/mktplinkfw-lib.c
index b2b6de2..e321327 100644
--- a/tools/firmware-utils/src/mktplinkfw-lib.c
+++ b/tools/firmware-utils/src/mktplinkfw-lib.c
@@ -121,7 +121,7 @@ static int pad_jffs2(char *buf, int currlen, int maxlen)
 	uint32_t pad_mask;
 
 	len = currlen;
-	pad_mask = (64 * 1024);
+	pad_mask = (4 * 1024) | (64 * 1024);	/* EOF at 4KB and at 64KB */
 	while ((len < maxlen) && (pad_mask != 0)) {
 		uint32_t mask;
 		int i;



More information about the lede-commits mailing list