uboot-2025: add force ipaddr support

This commit is contained in:
hanwckf
2025-08-21 12:53:45 +08:00
parent 95f51717eb
commit 4ece916d9e
3 changed files with 19 additions and 2 deletions

View File

@@ -123,19 +123,23 @@ 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", CONFIG_IPADDR, 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

@@ -233,6 +233,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
source "net/lwip/Kconfig"

View File

@@ -220,6 +220,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)
{
@@ -231,6 +232,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)
@@ -244,6 +246,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)
{
@@ -255,6 +258,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)
@@ -451,6 +455,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(CONFIG_IPADDR);
net_netmask = string_to_ip(CONFIG_NETMASK);
#endif
#ifdef CONFIG_PHY_NCSI
if (phy_interface_is_ncsi() && protocol != NCSI && !ncsi_active()) {
printf("%s: configuring NCSI first\n", __func__);