From 5f6f4dd465c4099ff1ba0bef978154705cede22c Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Tue, 28 Apr 2015 14:42:08 +0200 Subject: [PATCH] Make U-Boot image upgrade scripts in environment variables compatible with bigger images --- u-boot/include/configs/ap121.h | 16 ++++++++++++---- u-boot/include/configs/db12x.h | 14 ++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/u-boot/include/configs/ap121.h b/u-boot/include/configs/ap121.h index ef0d7f5..6ec8cbe 100644 --- a/u-boot/include/configs/ap121.h +++ b/u-boot/include/configs/ap121.h @@ -884,13 +884,18 @@ #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 @@ -951,12 +956,15 @@ #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!; " \ diff --git a/u-boot/include/configs/db12x.h b/u-boot/include/configs/db12x.h index fd02389..8e22735 100644 --- a/u-boot/include/configs/db12x.h +++ b/u-boot/include/configs/db12x.h @@ -164,7 +164,10 @@ // 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) @@ -193,12 +196,15 @@ #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!; " \ -- 2.25.1