Make U-Boot image upgrade scripts in environment variables compatible with bigger...
authorPiotr Dymacz <pepe2k@gmail.com>
Tue, 28 Apr 2015 12:42:08 +0000 (14:42 +0200)
committerPiotr Dymacz <pepe2k@gmail.com>
Tue, 28 Apr 2015 12:42:08 +0000 (14:42 +0200)
u-boot/include/configs/ap121.h
u-boot/include/configs/db12x.h

index ef0d7f566643b1051c1623ae20f8749750f280b7..6ec8cbe004994bd4db31227ab05028143d7bfe82 100644 (file)
 
 #if defined(CONFIG_FOR_DLINK_DIR505_A1)
        #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x10000"
+       #define UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES        UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x40000"
+       #define UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES        UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES
 #elif defined(CONFIG_FOR_DRAGINO_V2) || \
       defined(CONFIG_FOR_MESH_POTATO_V2)
        #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x30000"
+       #define UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES        UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES
 #else
-       #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x10000"
+       // TODO: should be == CONFIG_MAX_UBOOT_SIZE_KB
+       #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x1EC00"
+       #define UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES        "0x20000"
 #endif
 
 // Firmware partition offset
 #define CONFIG_EXTRA_ENV_SETTINGS      "uboot_addr=0x9F000000\0" \
                                                                        "uboot_name=uboot.bin\0" \
                                                                        "uboot_size=" UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES "\0" \
+                                                                       "uboot_backup_size=" UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES "\0" \
                                                                        "uboot_upg=" \
                                                                                "if ping $serverip; then " \
+                                                                                       "mw.b $loadaddr 0xFF $uboot_backup_size && " \
+                                                                                       "cp.b $uboot_addr $loadaddr $uboot_backup_size && " \
                                                                                        "tftp $loadaddr $uboot_name && " \
-                                                                                       "if itest.l $filesize == $uboot_size; then " \
-                                                                                               "erase $uboot_addr +$filesize && " \
-                                                                                               "cp.b $loadaddr $uboot_addr $filesize && " \
+                                                                                       "if itest.l $filesize <= $uboot_size; then " \
+                                                                                               "erase $uboot_addr +$uboot_backup_size && " \
+                                                                                               "cp.b $loadaddr $uboot_addr $uboot_backup_size && " \
                                                                                                "echo OK!; " \
                                                                                        "else " \
                                                                                                "echo ERROR! Wrong file size!; " \
index fd02389c9b98b6ef28258943ab62762b8f945286..8e227351dc9b57dd4f56c5d50084558f1a6a2002 100644 (file)
 
 // U-Boot partition size
 #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES         (CONFIG_MAX_UBOOT_SIZE_KB * 1024)
-#define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                      "0x10000"
+
+// TODO: should be == CONFIG_MAX_UBOOT_SIZE_KB
+#define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                      "0x1EC00"
+#define UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES       "0x20000"
 
 // ART partition size
 #define WEBFAILSAFE_UPLOAD_ART_SIZE_IN_BYTES           (64 * 1024)
 #define CONFIG_EXTRA_ENV_SETTINGS      "uboot_addr=0x9F000000\0" \
                                                                        "uboot_name=uboot.bin\0" \
                                                                        "uboot_size=" UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES "\0" \
+                                                                       "uboot_backup_size=" UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES "\0" \
                                                                        "uboot_upg=" \
                                                                                "if ping $serverip; then " \
+                                                                                       "mw.b $loadaddr 0xFF $uboot_backup_size && " \
+                                                                                       "cp.b $uboot_addr $loadaddr $uboot_backup_size && " \
                                                                                        "tftp $loadaddr $uboot_name && " \
-                                                                                       "if itest.l $filesize == $uboot_size; then " \
-                                                                                               "erase $uboot_addr +$filesize && " \
-                                                                                               "cp.b $loadaddr $uboot_addr $filesize && " \
+                                                                                       "if itest.l $filesize <= $uboot_size; then " \
+                                                                                               "erase $uboot_addr +$uboot_backup_size && " \
+                                                                                               "cp.b $loadaddr $uboot_addr $uboot_backup_size && " \
                                                                                                "echo OK!; " \
                                                                                        "else " \
                                                                                                "echo ERROR! Wrong file size!; " \