Make web based recovery optional, as configurable httpd command
authorPiotr Dymacz <pepe2k@gmail.com>
Wed, 31 Aug 2016 23:36:59 +0000 (01:36 +0200)
committerPiotr Dymacz <pepe2k@gmail.com>
Wed, 31 Aug 2016 23:36:59 +0000 (01:36 +0200)
u-boot/common/cmd_net.c
u-boot/include/configs/qca9k_common.h
u-boot/include/env_scripts.h
u-boot/net/httpd.c
u-boot/net/net.c

index 9effeb00bc85d301a81eec715d5947a323b3d0ed..a9d0cc15f34d1acaea8bcd5ccd0c67efdc34fb5f 100644 (file)
 extern int do_bootm(cmd_tbl_t *, int, int, char *[]);
 static int netboot_common(proto_t, cmd_tbl_t *, int, char *[]);
 
+#if defined(CONFIG_CMD_HTTPD)
 int do_httpd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
        return NetLoopHttpd();
 }
 U_BOOT_CMD(httpd, 1, 1, do_httpd, "start www server for firmware recovery\n", NULL);
+#endif /* CONFIG_CMD_HTTPD */
 
 int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
        return netboot_common(TFTP, cmdtp, argc, argv);
index 548e8eaa7e764d077a96b126d2b954930530f7a3..9fb2d324c315ee36744958839c910b84dd21ea47 100644 (file)
 #define CONFIG_CMD_ECHO
 #define CONFIG_CMD_ENV
 #define CONFIG_CMD_FLASH
+#define CONFIG_CMD_HTTPD
 #define CONFIG_CMD_IMI
 #define CONFIG_CMD_ITEST
 #define CONFIG_CMD_LED
index 0f32d3ed7ca7ef6ee836ac4422f5fc857bfff294..558d079b15962ececf0104112ba325a38cb1f528 100644 (file)
                #error "Reset button definition is required for recovery"
        #endif
 
+       #if defined(CONFIG_CMD_HTTPD)
+               #define SCRIPT_HTTP_PART_1      \
+               "echo - 3s for web based recovery;"
+
+               #define SCRIPT_HTTP_PART_2      \
+               "elif test $cnt -ge 3; then " \
+                       "echo HTTP server is starting for firmware update...;" \
+                       "setenv stop_boot 1;" \
+                       "echo;" \
+                       "httpd;" \
+               "elif test $cnt -lt 3; then "
+       #else
+               #define SCRIPT_HTTP_PART_1      ""
+               #define SCRIPT_HTTP_PART_2      \
+               "elif test $cnt -lt 5; then "
+       #endif
+
        #define CONFIG_ENV_BTN_RECOVERY_SCRIPT  \
                "recovery=" \
                "if button; then " \
                        "sleep 600;" \
                        "setenv cnt 0;" \
                        "echo Keep button pressed for at least:;" \
-                       "echo - 3s for web based recovery;" \
+                       SCRIPT_HTTP_PART_1 \
                        "echo - 5s for U-Boot console;" \
                        "echo - 7s for network console;" \
                        "echo;" \
                                "echo Starting U-Boot console...;" \
                                "setenv stop_boot 1;" \
                                "echo;" \
-                       "elif test $cnt -ge 3; then " \
-                               "echo HTTP server is starting for firmware update...;" \
-                               "setenv stop_boot 1;" \
-                               "echo;" \
-                               "httpd;" \
-                       "elif test $cnt -lt 3; then " \
+                       SCRIPT_HTTP_PART_2 \
                                "echo \\#\\# Error: button was not pressed long enough!;" \
                                "echo Continuing normal boot...;" \
                                "echo;" \
index ca174cae51109d3132f1472509e8ba3db4547bd6..6f9c4a2a363c3f24ba900827e6441fe0eaee1748 100644 (file)
@@ -8,6 +8,8 @@
 #include <command.h>
 #include <net.h>
 #include <asm/byteorder.h>
+
+#if defined(CONFIG_CMD_HTTPD)
 #include "httpd.h"
 
 #include "../httpd/uipopt.h"
@@ -176,3 +178,4 @@ int do_http_progress(const int state){
 
        return(0);
 }
+#endif /* CONFIG_CMD_HTTPD */
index 2d2d22493c6ea545443eeb8a4021d0ac8d451d8a..4e30c8b4334f0b6e21d9849a4208f7f110a2b071 100644 (file)
 #include "tftp.h"
 #include "rarp.h"
 #include "nfs.h"
+#if defined(CONFIG_CMD_HTTPD)
 #include "httpd.h"
+#endif
 
 #if defined(CONFIG_CMD_SNTP)
 #include "sntp.h"
 #endif
 
+#if defined(CONFIG_CMD_HTTPD)
 #include "../httpd/uipopt.h"
 #include "../httpd/uip.h"
 #include "../httpd/uip_arp.h"
+#endif
 
 #if defined(CONFIG_CMD_NET)
 
@@ -102,6 +106,7 @@ DECLARE_GLOBAL_DATA_PTR;
        #define ARP_TIMEOUT_COUNT  (CONFIG_NET_RETRY_COUNT)
 #endif
 
+#if defined(CONFIG_CMD_HTTPD)
 unsigned char *webfailsafe_data_pointer = NULL;
 int    webfailsafe_is_running = 0;
 int    webfailsafe_ready_for_upgrade = 0;
@@ -110,6 +115,7 @@ int webfailsafe_upgrade_type = WEBFAILSAFE_UPGRADE_TYPE_FIRMWARE;
 void NetReceiveHttpd(volatile uchar * inpkt, int len);
 
 extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+#endif
 
 /** BOOTP EXTENTIONS **/
 IPaddr_t NetOurSubnetMask = 0;         /* Our subnet mask (0=unknown) */
@@ -757,10 +763,12 @@ void NetReceive(volatile uchar * inpkt, int len){
        printf("Packet received\n");
 #endif
 
+       #if defined(CONFIG_CMD_HTTPD)
        if(webfailsafe_is_running){
                NetReceiveHttpd(inpkt, len);
                return;
        }
+       #endif
 
        NetRxPkt = inpkt;
        NetRxPktLen = len;
@@ -1367,6 +1375,8 @@ ushort getenv_VLAN(char *var){
  * HTTPD section
  */
 
+#if defined(CONFIG_CMD_HTTPD)
+
 #define BUF    ((struct uip_eth_hdr *)&uip_buf[0])
 
 void NetSendHttpd(void){
@@ -1589,3 +1599,4 @@ int NetLoopHttpd(void){
 
        return(-1);
 }
+#endif /* CONFIG_CMD_HTTPD */