uboot-202307: add CONFIG_NET_FORCE_IPADDR to set fixed ipaddr

This commit is contained in:
hanwckf
2023-08-31 00:54:51 +08:00
parent 31b0b329cd
commit 0d797b3381
3 changed files with 20 additions and 0 deletions

View File

@@ -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:",

View File

@@ -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

View File

@@ -110,6 +110,7 @@
#include <test/test.h>
#include <net/tcp.h>
#include <net/wget.h>
#include <linux/stringify.h>
#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__);