Scripts in env variables for simple U-Boot and firmware upgrade
authorPiotr Dymacz <pepe2k@gmail.com>
Wed, 19 Mar 2014 23:24:26 +0000 (00:24 +0100)
committerPiotr Dymacz <pepe2k@gmail.com>
Wed, 19 Mar 2014 23:24:26 +0000 (00:24 +0100)
u-boot/include/configs/ap121.h
u-boot/include/configs/ar7240.h
u-boot/include/configs/db12x.h

index a62962e93a584dda13187a50cade45f435a9e7cc..45a7f601564925e0acb75445a7eae7b1da85a34d 100755 (executable)
 #define CONFIG_LOADADDR                        0x80800000
 
 #if defined(CONFIG_FOR_DLINK_DIR505_A1)
-       #define CFG_LOAD_ADDR           0x9F080000
+       #define CFG_LOAD_ADDR                    0x9F080000
+       #define UPDATE_SCRIPT_FW_ADDR   "0x9F080000"
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
-       #define CFG_LOAD_ADDR           0x9F050000
+       #define CFG_LOAD_ADDR                    0x9F050000
+       #define UPDATE_SCRIPT_FW_ADDR   "0x9F050000"
 #elif defined(CONFIG_FOR_DRAGINO_V2)
-       #define CFG_LOAD_ADDR           0x9F040000
+       #define CFG_LOAD_ADDR                    0x9F040000
+       #define UPDATE_SCRIPT_FW_ADDR   "0x9F040000"
 #else
-       #define CFG_LOAD_ADDR           0x9F020000
+       #define CFG_LOAD_ADDR                    0x9F020000
+       #define UPDATE_SCRIPT_FW_ADDR   "0x9F020000"
 #endif
 
 #if defined(CONFIG_FOR_DLINK_DIR505_A1)
 
 #if defined(CONFIG_FOR_DLINK_DIR505_A1)
        #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES          (64 * 1024)
+       #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x10000"
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES          (256 * 1024)
+       #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x40000"
 #elif defined(CONFIG_FOR_DRAGINO_V2)
        #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES          (192 * 1024)
+       #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x30000"
 #else
        #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES          (64 * 1024)
+       #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x10000"
 #endif
 
 // Firmware partition offset
 
 /*-----------------------------------------------------------------------*/
 
+/*
+ * Additional environment variables for simple upgrades
+ */
+#define CONFIG_EXTRA_ENV_SETTINGS      "uboot_addr=0x9F000000\0" \
+                                                                       "uboot_name=uboot.bin\0" \
+                                                                       "uboot_size=" UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES "\0" \
+                                                                       "uboot_upg=" \
+                                                                               "if ping $serverip; then " \
+                                                                                       "tftp $loadaddr $uboot_name && " \
+                                                                                       "if itest.l $filesize == $uboot_size; then " \
+                                                                                               "erase $uboot_addr +$filesize && " \
+                                                                                               "cp.b $loadaddr $uboot_addr $filesize && " \
+                                                                                               "echo OK!; " \
+                                                                                       "else " \
+                                                                                               "echo ERROR! Wrong file size!; " \
+                                                                                       "fi; " \
+                                                                               "else " \
+                                                                                       "ERROR! Server not reachable!; " \
+                                                                               "fi\0" \
+                                                                       "firmware_addr=" UPDATE_SCRIPT_FW_ADDR "\0" \
+                                                                       "firmware_name=firmware.bin\0" \
+                                                                       "firmware_upg=" \
+                                                                               "if ping $serverip; then " \
+                                                                                       "tftp $loadaddr $firmware_name && " \
+                                                                                       "erase $firmware_addr +$filesize && " \
+                                                                                       "cp.b $loadaddr $firmware_addr $filesize && " \
+                                                                                       "echo OK!; " \
+                                                                               "else " \
+                                                                                       "ERROR! Server not reachable!; " \
+                                                                               "fi\0" \
+                                                                       SILENT_ENV_VARIABLE
+
 #define CFG_ATHRS26_PHY                                1
 #define CFG_AG7240_NMACS                       2
 #define CFG_MII0_RMII                          1
index 8fbdeb75b2e03ad1f6e1a451f7dbb470d707be3b..faa4af029a7b1dc911984583b168afa1b991a042 100755 (executable)
@@ -36,7 +36,9 @@
 #define CFG_RX_ETH_BUFFER   16
 
 #if defined(CONFIG_SILENT_CONSOLE)
-       #define CONFIG_EXTRA_ENV_SETTINGS       "silent=1\0"
+       #define SILENT_ENV_VARIABLE     "silent=1\0"
+#else
+       #define SILENT_ENV_VARIABLE     ""
 #endif
 
 /*
index 109fa3ccfcfa7ead9339bab17bceb95bf0f0ce32..f298a9ad265c1f12b153a4de15562f397189f471 100755 (executable)
@@ -47,8 +47,9 @@
 #undef CONFIG_LOADADDR\r
 #define CONFIG_LOADADDR                0x80800000\r
 \r
-#define        CFG_LOAD_ADDR           0x9F020000\r
-#define CONFIG_BOOTCOMMAND "bootm 0x9F020000"\r
+#define        CFG_LOAD_ADDR                    0x9F020000\r
+#define UPDATE_SCRIPT_FW_ADDR  "0x9F020000"\r
+#define CONFIG_BOOTCOMMAND             "bootm 0x9F020000"\r
 \r
 \r
 #define CONFIG_IPADDR          192.168.1.1\r
 \r
 // U-Boot partition size\r
 #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES         (64 * 1024)\r
+#define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                      "0x10000"\r
 \r
 // ART partition size\r
 #define WEBFAILSAFE_UPLOAD_ART_SIZE_IN_BYTES           (64 * 1024)\r
 \r
 /*-----------------------------------------------------------------------*/\r
 \r
+/*\r
+ * Additional environment variables for simple upgrades\r
+ */\r
+#define CONFIG_EXTRA_ENV_SETTINGS      "uboot_addr=0x9F000000\0" \\r
+                                                                       "uboot_name=uboot.bin\0" \\r
+                                                                       "uboot_size=" UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES "\0" \\r
+                                                                       "uboot_upg=" \\r
+                                                                               "if ping $serverip; then " \\r
+                                                                                       "tftp $loadaddr $uboot_name && " \\r
+                                                                                       "if itest.l $filesize == $uboot_size; then " \\r
+                                                                                               "erase $uboot_addr +$filesize && " \\r
+                                                                                               "cp.b $loadaddr $uboot_addr $filesize && " \\r
+                                                                                               "echo OK!; " \\r
+                                                                                       "else " \\r
+                                                                                               "echo ERROR! Wrong file size!; " \\r
+                                                                                       "fi; " \\r
+                                                                               "else " \\r
+                                                                                       "ERROR! Server not reachable!; " \\r
+                                                                               "fi\0" \\r
+                                                                       "firmware_addr=" UPDATE_SCRIPT_FW_ADDR "\0" \\r
+                                                                       "firmware_name=firmware.bin\0" \\r
+                                                                       "firmware_upg=" \\r
+                                                                               "if ping $serverip; then " \\r
+                                                                                       "tftp $loadaddr $firmware_name && " \\r
+                                                                                       "erase $firmware_addr +$filesize && " \\r
+                                                                                       "cp.b $loadaddr $firmware_addr $filesize && " \\r
+                                                                                       "echo OK!; " \\r
+                                                                               "else " \\r
+                                                                                       "ERROR! Server not reachable!; " \\r
+                                                                               "fi\0" \\r
+                                                                       SILENT_ENV_VARIABLE\r
+\r
 /* For Merlin, both PCI, PCI-E interfaces are valid */\r
 #define AR7240_ART_PCICFG_OFFSET       12\r
 \r