<div dir="ltr">Tested and seems to work as intended. However, I think the image too big messages should be printed at the default verbosity. <div><br></div><div>Currently, if make fails to generate the final image, it doesn't give any message to acknowledge, and appears to have succeeded, there are just "mysteriously" missing files in the output directory.</div><div><br></div><div>--Jonathan<br><div><br></div><div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 13, 2015 at 9:16 AM Stephan Maka <<a href="mailto:stephan@spaceboyz.net" target="_blank">stephan@spaceboyz.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is very useful for trimming images towards 4 MiB flash size.<br>
<br>
Signed-off-by: Stephan Maka <<a href="mailto:stephan@spaceboyz.net" target="_blank">stephan@spaceboyz.net</a>><br>
---<br>
 tools/firmware-utils/src/mktplinkfw.c | 20 ++++++++++----------<br>
 1 file changed, 10 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c<br>
index 09536c6..850aff4 100644<br>
--- a/tools/firmware-utils/src/mktplinkfw.c<br>
+++ b/tools/firmware-utils/src/mktplinkfw.c<br>
@@ -657,10 +657,10 @@ static int check_options(void)<br>
        kernel_len = kernel_info.file_size;<br>
<br>
        if (combined) {<br>
-               if (kernel_info.file_size ><br>
-                   fw_max_len - sizeof(struct fw_header)) {<br>
+               int exceed_bytes = kernel_info.file_size - (fw_max_len - sizeof(struct fw_header));<br>
+               if (exceed_bytes > 0) {<br>
                        if (!ignore_size) {<br>
-                               ERR("kernel image is too big");<br>
+                               ERR("kernel image is too big by %i bytes", exceed_bytes);<br>
                                return -1;<br>
                        }<br>
                        layout->fw_max_len = sizeof(struct fw_header) +<br>
@@ -684,20 +684,20 @@ static int check_options(void)<br>
<br>
                        DBG("kernel length aligned to %u", kernel_len);<br>
<br>
-                       if (kernel_len + rootfs_info.file_size ><br>
-                           fw_max_len - sizeof(struct fw_header)) {<br>
-                               ERR("images are too big");<br>
+                       int exceed_bytes = kernel_len + rootfs_info.file_size - (fw_max_len - sizeof(struct fw_header));<br>
+                       if (exceed_bytes > 0) {<br>
+                               ERR("images are too big by %i bytes", exceed_bytes);<br>
                                return -1;<br>
                        }<br>
                } else {<br>
-                       if (kernel_info.file_size ><br>
-                           rootfs_ofs - sizeof(struct fw_header)) {<br>
+                       int exceed_bytes = kernel_info.file_size - (rootfs_ofs - sizeof(struct fw_header));<br>
+                       if (exceed_bytes > 0) {<br>
                                ERR("kernel image is too big");<br>
                                return -1;<br>
                        }<br>
<br>
-                       if (rootfs_info.file_size ><br>
-                           (fw_max_len - rootfs_ofs)) {<br>
+                       exceed_bytes = rootfs_info.file_size - (fw_max_len - rootfs_ofs);<br>
+                       if (exceed_bytes > 0) {<br>
                                ERR("rootfs image is too big");<br>
                                return -1;<br>
                        }<br>
--<br>
2.1.4<br>
_______________________________________________<br>
openwrt-devel mailing list<br>
<a href="mailto:openwrt-devel@lists.openwrt.org" target="_blank">openwrt-devel@lists.openwrt.org</a><br>
<a href="https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel" rel="noreferrer" target="_blank">https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel</a><br>
</blockquote></div></div></div></div>