[OpenWrt-Devel] [PATCH] firmware-utils mktplinkfw: print amount of exceeding bytes

Jonathan Bennett jbscience87 at gmail.com
Mon Jul 13 11:26:57 EDT 2015


Tested and seems to work as intended. However, I think the image too big
messages should be printed at the default verbosity.

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.

--Jonathan


On Mon, Jul 13, 2015 at 9:16 AM Stephan Maka <stephan at spaceboyz.net> wrote:

> This is very useful for trimming images towards 4 MiB flash size.
>
> Signed-off-by: Stephan Maka <stephan at spaceboyz.net>
> ---
>  tools/firmware-utils/src/mktplinkfw.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/tools/firmware-utils/src/mktplinkfw.c
> b/tools/firmware-utils/src/mktplinkfw.c
> index 09536c6..850aff4 100644
> --- a/tools/firmware-utils/src/mktplinkfw.c
> +++ b/tools/firmware-utils/src/mktplinkfw.c
> @@ -657,10 +657,10 @@ static int check_options(void)
>         kernel_len = kernel_info.file_size;
>
>         if (combined) {
> -               if (kernel_info.file_size >
> -                   fw_max_len - sizeof(struct fw_header)) {
> +               int exceed_bytes = kernel_info.file_size - (fw_max_len -
> sizeof(struct fw_header));
> +               if (exceed_bytes > 0) {
>                         if (!ignore_size) {
> -                               ERR("kernel image is too big");
> +                               ERR("kernel image is too big by %i bytes",
> exceed_bytes);
>                                 return -1;
>                         }
>                         layout->fw_max_len = sizeof(struct fw_header) +
> @@ -684,20 +684,20 @@ static int check_options(void)
>
>                         DBG("kernel length aligned to %u", kernel_len);
>
> -                       if (kernel_len + rootfs_info.file_size >
> -                           fw_max_len - sizeof(struct fw_header)) {
> -                               ERR("images are too big");
> +                       int exceed_bytes = kernel_len +
> rootfs_info.file_size - (fw_max_len - sizeof(struct fw_header));
> +                       if (exceed_bytes > 0) {
> +                               ERR("images are too big by %i bytes",
> exceed_bytes);
>                                 return -1;
>                         }
>                 } else {
> -                       if (kernel_info.file_size >
> -                           rootfs_ofs - sizeof(struct fw_header)) {
> +                       int exceed_bytes = kernel_info.file_size -
> (rootfs_ofs - sizeof(struct fw_header));
> +                       if (exceed_bytes > 0) {
>                                 ERR("kernel image is too big");
>                                 return -1;
>                         }
>
> -                       if (rootfs_info.file_size >
> -                           (fw_max_len - rootfs_ofs)) {
> +                       exceed_bytes = rootfs_info.file_size - (fw_max_len
> - rootfs_ofs);
> +                       if (exceed_bytes > 0) {
>                                 ERR("rootfs image is too big");
>                                 return -1;
>                         }
> --
> 2.1.4
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20150713/a07f5996/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list