Define and use image size limit in bytes instead of KB
authorPiotr Dymacz <pepe2k@gmail.com>
Sun, 28 Aug 2016 23:39:48 +0000 (01:39 +0200)
committerPiotr Dymacz <pepe2k@gmail.com>
Sun, 28 Aug 2016 23:39:48 +0000 (01:39 +0200)
Makefile
u-boot/Makefile
u-boot/httpd/httpd.c

index e9bd3ce6523739ba96293ecfad86bd07b7bb89b2..ac9284f0693e88055b92969eab972a568b8bfcc3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -147,7 +147,7 @@ endef
 # $(2): if set to 1, use LZMA
 # $(3): other parameters passed to subdir make
 define build
-  args="IMG_SIZE=$(call img_size,$(1)) \
+  args="IMG_SIZE=$$((1024*$(call img_size,$(1)))) \
         IMG_LZMA=$(call is_one,$(2)) \
         $(strip $(3))"; \
   cd $(SOURCE_DIR) && \
index 616bf344d07bce21e999ebf87e8afcf5aa782d01..96b008ac7c6a2c99a8f1e38d7fbb2a8d008c563e 100644 (file)
@@ -32,8 +32,8 @@ export TOPDIR
 
 # Some variables passed as arguments in cmd
 ifneq ($(IMG_SIZE),)
-  CONFIG_MAX_UBOOT_SIZE_KB = $(IMG_SIZE)
-  export CONFIG_MAX_UBOOT_SIZE_KB
+  CONFIG_MAX_UBOOT_SIZE = $(IMG_SIZE)
+  export CONFIG_MAX_UBOOT_SIZE
 endif
 
 ifeq ($(IMG_LZMA),1)
@@ -138,8 +138,8 @@ define config_init
     $(call echo_yellow,  Custom recovery web:\tno) \
   )
 
-  $(if $(CONFIG_MAX_UBOOT_SIZE_KB), \
-    $(call echo_yellow,  Image size limit:\t$(CONFIG_MAX_UBOOT_SIZE_KB) KB),
+  $(if $(CONFIG_MAX_UBOOT_SIZE), \
+    $(call echo_yellow,  Image size limit:\t$$(($(CONFIG_MAX_UBOOT_SIZE) / 1024)) KB),
     $(call echo_yellow,  Image size limit:\tnot specified)
   )
 
@@ -167,8 +167,8 @@ define config_init
 
   $(if $(3),$(call define_add,CONFIG_GPIO_RESET_BTN,$(strip $(3))))
   $(if $(filter $(4),1),$(call define_add,CONFIG_GPIO_RESET_BTN_ACTIVE_LOW,1))
-  $(if $(CONFIG_MAX_UBOOT_SIZE_KB), \
-    $(call define_add,CONFIG_MAX_UBOOT_SIZE_KB,$(CONFIG_MAX_UBOOT_SIZE_KB))
+  $(if $(CONFIG_MAX_UBOOT_SIZE), \
+    $(call define_add,CONFIG_MAX_UBOOT_SIZE,$(CONFIG_MAX_UBOOT_SIZE))
   )
 
   $(if $(filter $(CONFIG_SKIP_LOWLEVEL_INIT),1), \
index 767cf173e2bf5134d15d57e32fc4a4adaabdddad..1303e79eb00a8dff646d2636e03a54d213655825 100644 (file)
@@ -193,7 +193,7 @@ static int httpd_findandstore_firstchunk(void){
                                // has correct size (for every type of upgrade)
 
                                // U-Boot
-                               if((webfailsafe_upgrade_type == WEBFAILSAFE_UPGRADE_TYPE_UBOOT) && (hs->upload_total > (CONFIG_MAX_UBOOT_SIZE_KB * 1024))){
+                               if((webfailsafe_upgrade_type == WEBFAILSAFE_UPGRADE_TYPE_UBOOT) && (hs->upload_total > CONFIG_MAX_UBOOT_SIZE)){
 
                                        printf("## Error: file too big!\n");
                                        webfailsafe_upload_failed = 1;
@@ -466,7 +466,7 @@ void httpd_appcall(void){
                                                printf("Data will be downloaded at 0x%X in RAM\n", CONFIG_LOADADDR);
                                        }
 
-                                       memset((void *)webfailsafe_data_pointer, 0xFF, (CONFIG_MAX_UBOOT_SIZE_KB * 1024));
+                                       memset((void *)webfailsafe_data_pointer, 0xFF, CONFIG_MAX_UBOOT_SIZE);
 
                                        if(httpd_findandstore_firstchunk()){
                                                data_start_found = 1;