diff --git a/uboot-mtk-20230718-09eda825/board/mediatek/common/load_data.c b/uboot-mtk-20230718-09eda825/board/mediatek/common/load_data.c index db0de8c5f..066316470 100644 --- a/uboot-mtk-20230718-09eda825/board/mediatek/common/load_data.c +++ b/uboot-mtk-20230718-09eda825/board/mediatek/common/load_data.c @@ -123,18 +123,24 @@ static int load_tftp(ulong addr, size_t *data_size, const char *env_name) char file_name[CONFIG_SYS_CBSIZE + 1]; u32 size; +#ifdef CONFIG_NET_FORCE_IPADDR + printf("U-Boot's IP address: %s, IP netmask: %s\n", __stringify(CONFIG_IPADDR), __stringify(CONFIG_NETMASK)); +#else if (env_update("ipaddr", CONFIG_IPADDR, "Input U-Boot's IP address:", NULL, 0)) return CMD_RET_FAILURE; +#endif if (env_update("serverip", CONFIG_SERVERIP, "Input TFTP server's IP address:", NULL, 0)) return CMD_RET_FAILURE; +#ifndef CONFIG_NET_FORCE_IPADDR #ifdef CONFIG_NETMASK if (env_update("netmask", CONFIG_NETMASK, "Input IP netmask:", NULL, 0)) return CMD_RET_FAILURE; +#endif #endif if (env_update(env_name, "", "Input file name:", diff --git a/uboot-mtk-20230718-09eda825/net/Kconfig b/uboot-mtk-20230718-09eda825/net/Kconfig index 5c1299406..b352b23a7 100644 --- a/uboot-mtk-20230718-09eda825/net/Kconfig +++ b/uboot-mtk-20230718-09eda825/net/Kconfig @@ -265,6 +265,10 @@ config MTK_HTTPD help Enable mediatek httpd framework that allows some customized features. +config NET_FORCE_IPADDR + bool "Use ipaddr and netmask with CONFIG_IPADDR and CONFIG_NETMASK" + default n + endif # if NET config SYS_RX_ETH_BUFFER diff --git a/uboot-mtk-20230718-09eda825/net/net.c b/uboot-mtk-20230718-09eda825/net/net.c index 3e7fbebb3..cafda5cb7 100644 --- a/uboot-mtk-20230718-09eda825/net/net.c +++ b/uboot-mtk-20230718-09eda825/net/net.c @@ -110,6 +110,7 @@ #include #include #include +#include #include "arp.h" #include "bootp.h" #include "cdp.h" @@ -218,6 +219,7 @@ int __maybe_unused net_busy_flag; /**********************************************************************/ +#ifndef CONFIG_NET_FORCE_IPADDR static int on_ipaddr(const char *name, const char *value, enum env_op op, int flags) { @@ -229,6 +231,7 @@ static int on_ipaddr(const char *name, const char *value, enum env_op op, return 0; } U_BOOT_ENV_CALLBACK(ipaddr, on_ipaddr); +#endif static int on_gatewayip(const char *name, const char *value, enum env_op op, int flags) @@ -242,6 +245,7 @@ static int on_gatewayip(const char *name, const char *value, enum env_op op, } U_BOOT_ENV_CALLBACK(gatewayip, on_gatewayip); +#ifndef CONFIG_NET_FORCE_IPADDR static int on_netmask(const char *name, const char *value, enum env_op op, int flags) { @@ -253,6 +257,7 @@ static int on_netmask(const char *name, const char *value, enum env_op op, return 0; } U_BOOT_ENV_CALLBACK(netmask, on_netmask); +#endif static int on_serverip(const char *name, const char *value, enum env_op op, int flags) @@ -444,6 +449,11 @@ int net_loop(enum proto_t protocol) net_try_count = 1; debug_cond(DEBUG_INT_STATE, "--- net_loop Entry\n"); +#ifdef CONFIG_NET_FORCE_IPADDR + net_ip = string_to_ip(__stringify(CONFIG_IPADDR)); + net_netmask = string_to_ip(__stringify(CONFIG_NETMASK)); +#endif + #ifdef CONFIG_PHY_NCSI if (phy_interface_is_ncsi() && protocol != NCSI && !ncsi_active()) { printf("%s: configuring NCSI first\n", __func__);